Whlabel.php 331 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810
  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 == 'typev1') //进销存浏览
  62. {
  63. $this->_typev1();
  64. } else if ($arg == 'typedy') //进销存浏览店员页面
  65. {
  66. $this->_typedy($arg_array);
  67. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  68. {
  69. $this->_typedy_ck($arg_array);
  70. } else if ($arg == 'typeck') {
  71. $this->_typeck($arg_array);
  72. } else if ($arg == 'whlabeckdc') {
  73. $this->_whlabeckdc($arg_array);
  74. } else if ($arg == 'usatype') //美仓进销存浏览
  75. {
  76. $this->_usatype();
  77. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  78. {
  79. $this->_usatypeapp();
  80. } else if ($arg == 'enteradd') //入库操作
  81. {
  82. $this->_enteradd();
  83. } else if ($arg == 'enteredit') //修改
  84. {
  85. $this->_enteredit($arg_array);
  86. } else if ($arg == 'enter') //入库浏览
  87. {
  88. $this->_enter();
  89. } else if ($arg == 'out') //出库浏览
  90. {
  91. $this->_out();
  92. } else if ($arg == 'label') //出库标签浏览
  93. {
  94. $this->_label();
  95. } else if ($arg == 'outorder') //独立站出库订单
  96. {
  97. $this->_outorder();
  98. } else if ($arg == 'soutorder') //速卖通出库订单
  99. {
  100. $this->_soutorder();
  101. } else if ($arg == 'toutorder') //TT出库订单
  102. {
  103. $this->_toutorder();
  104. }else if ($arg == 'aoutorder') //amz出库订单
  105. {
  106. $this->_aoutorder();
  107. } else if ($arg == 'retreat') //退库订单
  108. {
  109. $this->_retreat();
  110. } else if ($arg == 'retreatlk') //退库订单
  111. {
  112. $this->_retreatlk();
  113. } else if ($arg == 'change') //更换标签
  114. {
  115. $this->_change();
  116. } else if ($arg == 'del') //删除
  117. {
  118. $this->_del();
  119. } else if ($arg == 'exceljxc') //进销存信息导出
  120. {
  121. $this->_exceljxc();
  122. } else if ($arg == 'excelr') //入库信息导出
  123. {
  124. $this->_excelr();
  125. } else if ($arg == 'excelct') //出库、退库信息导出
  126. {
  127. $this->_excelct();
  128. } else if ($arg == 'dccrtype') //根据出入库类型导出
  129. {
  130. $this->_dccrtype();
  131. } else if ($arg == 'excelcr') //出库、退库信息导出
  132. {
  133. $this->_excelcr();
  134. } else if ($arg == 'kcyz') //库存验证
  135. {
  136. $this->_kcyz();
  137. } else if ($arg == 'kj') //库存扣减
  138. {
  139. $this->_kj($arg_array);
  140. } else if ($arg == 'presetout') //预设库存导入
  141. {
  142. $this->_presetout($arg_array);
  143. } else if ($arg == 'presetedit') //预设库存导入
  144. {
  145. $this->_presetedit($arg_array);
  146. }else if ($arg == 'presetedittwo') //预设库存导入
  147. {
  148. $this->_presetedittwo($arg_array);
  149. } else if ($arg == 'summary') //汇总导出
  150. {
  151. $this->_summary($arg_array);
  152. } else if ($arg == 'manifest') //usps发货清单
  153. {
  154. $this->_manifest();
  155. } else if ($arg == 'abnormal') //占单异常
  156. {
  157. $this->_abnormal();
  158. } else if ($arg == 'error') //0库存SKU
  159. {
  160. $this->_error();
  161. } else if ($arg == 'errorexcel') //0库存SKU导出
  162. {
  163. $this->_errorexcel();
  164. } else if ($arg == 'db') {
  165. $this->_db();
  166. } else if ($arg == 'dbrk') {
  167. $this->_dbrk();
  168. } else if ($arg == 'whlabelczdc') {
  169. $this->_whlabelczdc();
  170. } else if ($arg == 'print') {
  171. $this->_print($arg_array);
  172. } else if ($arg == 'usaprint') {
  173. $this->_usaprint($arg_array);
  174. } else if ($arg == 'printck') {
  175. $this->_printck($arg_array);
  176. } else if ($arg == 'printrk') {
  177. $this->_printrk($arg_array);
  178. } else if ($arg == 'printxzrk') {
  179. $this->_printxzrk($arg_array);
  180. } else if ($arg == 'printexcel') {
  181. $this->_printexcel($arg_array);
  182. } else if ($arg == 'uck') {
  183. $this->_uck();
  184. } else if ($arg == 'whlabelexcelzh') {
  185. $this->_whlabelexcelzh();
  186. } else if ($arg == 'fc') {
  187. $this->_fc();
  188. } else if ($arg == 'fcmb') {
  189. $this->_fcmb();
  190. } else if ($arg == 'fcexcel') {
  191. $this->_fcexcel();
  192. } else if ($arg == 'fcjxc') {
  193. $this->_fcjxc($arg_array);
  194. } else if ($arg == '0kcdel') {
  195. $this->_0kcdel(); //导表删除0库存
  196. } else if ($arg == 'gbhtype') {
  197. $this->_gbhtype(); //更改备货状态
  198. } else if($arg == 'excelrjs'){
  199. $this->_excelrjs();
  200. } else if($arg == 'excelctjs'){
  201. $this->_excelctjs();
  202. }else if ($arg == 'exceljxcjs') //进销存信息导出
  203. {
  204. $this->_exceljxcjs();
  205. } else if ($arg == 'summaryjs') //汇总导出
  206. {
  207. $this->_summaryjs($arg_array);
  208. }else if($arg == 'uckjs'){
  209. $this->_uckjs();
  210. }else if ($arg == 'whlabelexcelzhjs') {
  211. $this->_whlabelexcelzhjs();
  212. }else if($arg == 'dccrtypejs'){
  213. $this->_dccrtypejs();
  214. }else if($arg == 'errorexceljs'){
  215. $this->_errorexceljs();
  216. }else if($arg == "w_t_cs"){
  217. $this->_w_t_cs(); //首页
  218. }else {
  219. $this->_index();
  220. }
  221. }
  222. public function _w_t_cs(){
  223. $vip = 0;
  224. if (isset($_SESSION['api'])) {
  225. $user = $this->user->get_api($_SESSION['api']);
  226. $fgshop = "";
  227. $sid = "";
  228. $usersp = explode('|', trim($user['shop'], '|'));
  229. foreach ($usersp as $value) {
  230. $fgshop .= " shop = " . $value . " or";
  231. $sid .= " id = " . $value . " or";
  232. }
  233. if ($user['vip'] == 1) {
  234. $vip = 1;
  235. }
  236. } else {
  237. header('Location: /');
  238. exit;
  239. }
  240. $prc = array();
  241. $purchase = $this->purchase->find_all();
  242. foreach ($purchase as $k => $v) {
  243. $prc[$v['id']] = $v['title'];
  244. }
  245. $company = array();
  246. $ct = $this->company->find_all();
  247. foreach ($ct as $k => $v) {
  248. $company[$v['id']] = $v['title'];
  249. }
  250. $sp = array();
  251. $s = $this->shop->find_all('1=1', 'id,shopname');
  252. foreach ($s as $v) {
  253. $sp[$v['id']] = $v['shopname'];
  254. }
  255. $wh = array();
  256. $w = $this->warehouse->find_all('1=1', 'id,title');
  257. foreach ($w as $v) {
  258. $wh[$v['id']] = $v['title'];
  259. }
  260. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  261. $this->data['shop'] = $wlshop;
  262. $this->data['vip'] = $vip;
  263. $this->_Template('whlabel_typejs', $this->data);
  264. }
  265. //管理
  266. public function _index()
  267. {
  268. $post = $this->input->post(NULL, TRUE);
  269. if (isset($post['page'])) {
  270. $page = $this->input->post('page', true);
  271. $perpage = $this->input->post('perpage', true);
  272. $sku = $this->input->post('sku', true);
  273. $number = $this->input->post('number', true);
  274. $warehouse = $this->input->post('warehouse', true);
  275. $purchase = $this->input->post('purchase', true);
  276. $orderinfo = $this->input->post('orderinfo', true);
  277. $waybill = $this->input->post('waybill', true);
  278. $category = $this->input->post('category', true);
  279. $size = $this->input->post('size', true);
  280. $grade = $this->input->post('grade', true);
  281. $color = $this->input->post('color', true);
  282. $lowe = $this->input->post('lowe', true);
  283. $state = $this->input->post('state', true);
  284. $label = $this->input->post('label', true);
  285. $timetk = $this->input->post('timetkk', true);
  286. $timetj = $this->input->post('timetjj', true);
  287. $timetk = strtotime($timetk);
  288. $timetj = strtotime($timetj);
  289. $where = "1=1 ";
  290. if ($timetk && $timetj) {
  291. $where .= " and time > '$timetk' and time < '$timetj'";
  292. }
  293. if ($sku) {
  294. $where .= " and sku = '$sku'";
  295. }
  296. if ($number) {
  297. $where .= " and number = '$number'";
  298. }
  299. if ($warehouse) {
  300. $where .= " and warehouse = '$warehouse'";
  301. }
  302. if ($purchase) {
  303. $where .= " and purchase = '$purchase'";
  304. }
  305. if ($orderinfo) {
  306. $where .= " and orderinfo = '$orderinfo'";
  307. }
  308. if ($waybill) {
  309. $where .= " and waybill = '$waybill'";
  310. }
  311. if ($category) {
  312. $where .= " and features like '%-$category-%'";
  313. }
  314. if ($size) {
  315. $where .= " and features like '%-$size-%'";
  316. }
  317. if ($grade) {
  318. $where .= " and features like '%-$grade-%'";
  319. }
  320. if ($color) {
  321. $where .= " and features like '%-$color-%'";
  322. }
  323. if ($lowe) {
  324. $where .= " and features like '%-$lowe-%'";
  325. }
  326. if ($label) {
  327. $where .= " and label = '$label'";
  328. }
  329. if ($state != '') {
  330. $where .= " and state = '$state'";
  331. }
  332. //数据排序
  333. $order_str = "time desc";
  334. if (empty($page)) {
  335. $start = 0;
  336. $perpage = 1;
  337. } else {
  338. $start = ($page - 1) * $perpage;
  339. }
  340. //取得信息列表
  341. $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);
  342. foreach ($info_list as $key => $value) {
  343. $warehouse = $this->warehouse->read($value['warehouse']);
  344. $info_list[$key]['warehouse'] = $warehouse['title'];
  345. $purchase = $this->purchase->read($value['purchase']);
  346. $info_list[$key]['purchase'] = $purchase['title'];
  347. if ($value['enter'] != 0) {
  348. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  349. } else {
  350. $info_list[$key]['enter'] = "";
  351. }
  352. if ($value['outk'] != 0) {
  353. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  354. } else {
  355. $info_list[$key]['outk'] = "";
  356. }
  357. if ($value['printing'] != 0) {
  358. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  359. } else {
  360. $info_list[$key]['printing'] = "";
  361. }
  362. if ($value['orderinfo'] == 0) {
  363. $info_list[$key]['orderinfo'] = "";
  364. }
  365. if ($value['waybill'] == 0) {
  366. $info_list[$key]['waybill'] = "";
  367. }
  368. if ($value['state'] == 0) {
  369. $info_list[$key]['state'] = "在库";
  370. } else if ($value['state'] == 1) {
  371. $info_list[$key]['state'] = "出库";
  372. } else if ($value['state'] == 2) {
  373. $info_list[$key]['state'] = "退库";
  374. } else if ($value['state'] == 3) {
  375. $info_list[$key]['state'] = "调拨中";
  376. } else if ($value['state'] == 4) {
  377. $info_list[$key]['state'] = "再加工";
  378. } else if ($value['state'] == 5) {
  379. $info_list[$key]['state'] = "维修中";
  380. } else if ($value['state'] == 6) {
  381. $info_list[$key]['state'] = "盘亏";
  382. } else if ($value['state'] == 7) {
  383. $info_list[$key]['state'] = "更换标签";
  384. } else if ($value['state'] == 8) {
  385. $info_list[$key]['state'] = "其它";
  386. } else if ($value['state'] == 9) {
  387. $info_list[$key]['state'] = "预设";
  388. } else if ($value['state'] == 10) {
  389. $info_list[$key]['state'] = "美店零售";
  390. }
  391. if ($value['text'] == "") {
  392. $info_list[$key]['text'] = "";
  393. }
  394. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  395. }
  396. $total = $this->whlabel->find_count($where);
  397. $pagenum = ceil($total / $perpage);
  398. $over = $total - ($start + $perpage);
  399. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  400. echo json_encode($rows);
  401. exit;
  402. }
  403. if (isset($post['outsku'])) {
  404. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  405. $cz = $this->input->post('cz', true);
  406. if ($cz == '1') {
  407. $sku = $this->input->post('outsku', true);
  408. if ($sku) {
  409. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  410. if (count($data) < 1) {
  411. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  412. exit;
  413. }
  414. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  415. echo json_encode(array('success' => true));
  416. exit;
  417. }
  418. } else {
  419. $sku = $this->input->post('outsku', true);
  420. if ($sku) {
  421. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  422. if (count($data) < 1) {
  423. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  424. exit;
  425. }
  426. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  427. echo json_encode(array('success' => true));
  428. exit;
  429. }
  430. }
  431. }
  432. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  433. $this->_Template('whlabel', $this->data);
  434. }
  435. //在库标签
  436. public function _existence()
  437. {
  438. $post = $this->input->post(NULL, TRUE);
  439. if (isset($post['s'])) {
  440. $id_arr = $this->input->post('s');
  441. $id_arr = explode(',', $id_arr);
  442. if (!$id_arr) {
  443. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  444. exit;
  445. }
  446. //循环删除记录
  447. foreach ($id_arr as $v) {
  448. $sid = $this->whlabel->read($v);
  449. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  450. if ($count > 0) {
  451. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  452. exit;
  453. }
  454. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  455. if (count($zt) > 0) {
  456. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  457. exit;
  458. }
  459. $this->whlabel->remove($v);
  460. }
  461. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  462. exit;
  463. }
  464. if (isset($post['page'])) {
  465. $page = $this->input->post('page', true);
  466. $perpage = $this->input->post('perpage', true);
  467. $warehouse = $this->input->post('warehouse', true);
  468. $label = $this->input->post('label', true);
  469. $where = "1=1 and state = 0";
  470. if ($warehouse) {
  471. $where .= " and warehouse = '$warehouse'";
  472. }
  473. if ($label) {
  474. $where .= " and label = '$label'";
  475. }
  476. //数据排序
  477. $order_str = "time asc";
  478. if (empty($page)) {
  479. $start = 0;
  480. $perpage = 1;
  481. } else {
  482. $start = ($page - 1) * $perpage;
  483. }
  484. //取得信息列表
  485. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  486. foreach ($info_list as $key => $value) {
  487. if ($value['enter'] != 0) {
  488. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  489. } else {
  490. $info_list[$key]['enter'] = "";
  491. }
  492. if ($value['printing'] != 0) {
  493. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  494. } else {
  495. $info_list[$key]['printing'] = "";
  496. }
  497. }
  498. $total = $this->whlabel->find_count($where);
  499. $pagenum = ceil($total / $perpage);
  500. $over = $total - ($start + $perpage);
  501. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  502. echo json_encode($rows);
  503. exit;
  504. }
  505. $this->_Template('whlabel_existence', $this->data);
  506. }
  507. //进销存浏览
  508. public function _typedy($arg_array)
  509. {
  510. $prc = array();
  511. $purchase = $this->purchase->find_all();
  512. foreach ($purchase as $k => $v) {
  513. $prc[$v['id']] = $v['title'];
  514. }
  515. $post = $this->input->post(NULL, TRUE);
  516. if (isset($post['page'])) {
  517. $page = $this->input->post('page', true);
  518. $perpage = $this->input->post('perpage', true);
  519. $category = $this->input->post('category', true);
  520. $size = $this->input->post('size', true);
  521. $grade = $this->input->post('grade', true);
  522. $color = $this->input->post('color', true);
  523. $lowe = $this->input->post('lowe', true);
  524. $sku = $this->input->post('sku');
  525. $title = $this->input->post('title');
  526. $warehouse = $this->input->post('warehouse', true);
  527. $usa = $this->input->post('usa', true);
  528. $purchase = $this->input->post('purchase', true);
  529. $lacetype = $this->input->post('lacetype', true);
  530. $haircap = $this->input->post('haircap', true);
  531. $density = $this->input->post('density', true);
  532. $details = $this->input->post('details', true);
  533. $state = $this->input->post('state', true);
  534. $lacecolor = $this->input->post('lacecolor', true);
  535. $hairnumber = $this->input->post('hairnumber', true);
  536. $cklx = $this->input->post('cklx', true);
  537. $ktime = $this->input->post('ktime', true);
  538. $jtime = $this->input->post('jtime', true);
  539. $sm = $this->input->post('sm', true);
  540. $cpbz = $this->input->post('cpbz', true);
  541. $type = $this->input->post('type', true);
  542. $ktime = strtotime($ktime);
  543. $jtime = strtotime($jtime);
  544. $where = "1=1";
  545. $gj = "";
  546. $ck = "";
  547. if ($usa) {
  548. if (!$warehouse) {
  549. $where .= " and (warehouse = '5' or warehouse = '8')";
  550. }
  551. }
  552. if ($warehouse) {
  553. $where .= " and warehouse = '$warehouse'";
  554. }
  555. if ($details) {
  556. $where .= " and details = '$details'";
  557. }
  558. if ($purchase) {
  559. $where .= " and purchase = '$purchase'";
  560. }
  561. if (isset($state)) {
  562. if($state >-1){
  563. $where .= " and state = '$state'";
  564. }
  565. }
  566. if ($lacetype) {
  567. $where .= " and features like '%-$lacetype-%'";
  568. }
  569. if ($category) {
  570. $where .= " and features like '%-$category-%'";
  571. }
  572. if ($size) {
  573. $where .= " and features like '%-$size-%'";
  574. }
  575. if ($grade) {
  576. $where .= " and features like '%-$grade-%'";
  577. }
  578. if ($color) {
  579. $where .= " and features like '%-$color-%'";
  580. }
  581. if ($lowe) {
  582. $where .= " and features like '%-$lowe-%'";
  583. }
  584. if ($haircap) {
  585. $where .= " and features like '%-$haircap-%'";
  586. }
  587. if ($density) {
  588. $where .= " and features like '%-$density-%'";
  589. }
  590. if ($lacecolor) {
  591. $where .= " and features like '%-$lacecolor-%'";
  592. }
  593. if($sm){
  594. $where .= " and sm like '%".$sm."%'";
  595. }
  596. if($cpbz){
  597. $where .= " and cpbz like '%".$cpbz."%'";
  598. }
  599. if($type){
  600. $where .= " and type = ".$type."";
  601. }
  602. if (!empty($hairnumber)) {
  603. $where .= " and features like '%-128-%' ";
  604. if ($hairnumber < 0) {
  605. $class_list = $this->typeclass->find_all('classid = 43');
  606. foreach ($class_list as $v) {
  607. $where .= " and features not like '%-" . $v['id'] . "-%'";
  608. }
  609. } else {
  610. $where .= " and features like '%-$hairnumber-%'";
  611. }
  612. }
  613. $where_add = '';
  614. if ($cklx) {
  615. $shop = $this->shop->read($cklx);
  616. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  617. }
  618. if ($ktime && $jtime) {
  619. $gj = " and enter > '$ktime' and enter < '$jtime'";
  620. $ck = " and outk > '$ktime' and outk < '$jtime'";
  621. }
  622. //数据排序
  623. $order_str = "id desc";
  624. if (empty($page)) {
  625. $start = 0;
  626. $perpage = 1;
  627. } else {
  628. $start = ($page - 1) * $perpage;
  629. }
  630. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  631. if ($sku) {
  632. $sku = trim($sku, ' ');
  633. $sku = trim($sku, ' ');
  634. $where .= " and sku like '%$sku%'";
  635. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  636. } else if ($title) {
  637. $title = trim($title, ' ');
  638. $title = trim($title, ' ');
  639. $where .= " and title like '%$title%'";
  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. } else {
  642. //$where .= " and time > '$ktime' and time < '$jtime'";
  643. $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);
  644. }
  645. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  646. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  647. foreach ($info_list as $k => $v) {
  648. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  649. unset($info_list[$k]['pm']);
  650. unset($info_list[$k]['jm']);
  651. unset($info_list[$k]['bm']);
  652. }
  653. //取得信息列表
  654. $rows = array();
  655. $list = array();
  656. foreach ($info_list as $key => $value) {
  657. $warehouse = $this->warehouse->read($value['warehouse']);
  658. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  659. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  660. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  661. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  662. $info_list[$key]['label'] = $value['sm'];
  663. $number = $value['number'];
  664. $ftime = time() - 15 * 24 * 3600;
  665. $info_list[$key]['warehouse'] = $warehouse['title'];
  666. $info_list[$key]['features'] = count($c);
  667. $z = count($z); //查看订单号
  668. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  669. $ztdata = '';
  670. if (count($zt) > 0) {
  671. foreach ($zt as $vv) {
  672. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  673. }
  674. }
  675. $info_list[$key]['number'] = $ztdata;
  676. $info_list[$key]['sm'] = $z;
  677. $details = array();
  678. $cpid = array();
  679. foreach ($c as $k => $v) {
  680. $details[$v['details']] = $v['details'];
  681. if ($v['cpid'] != 0) {
  682. $cpid[$v['cpid']] = $v['cpid'];
  683. }
  684. }
  685. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  686. if ($value['shop'] != '') {
  687. $shop = explode(',', trim($value['shop'], ','));
  688. $shop = $this->shop->read($shop[0]);
  689. $info_list[$key]['shop'] = $shop['shopname'];
  690. }
  691. }
  692. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  693. $pagenum = ceil($total / $perpage);
  694. $over = $total - ($start + $perpage);
  695. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  696. echo json_encode($rows);
  697. exit;
  698. }
  699. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  700. $this->_Template('whlabel_typedy', $this->data);
  701. }
  702. //进销存浏览
  703. public function _typedy_ck($arg_array)
  704. {
  705. $prc = array();
  706. $purchase = $this->purchase->find_all();
  707. foreach ($purchase as $k => $v) {
  708. $prc[$v['id']] = $v['title'];
  709. }
  710. $post = $this->input->post(NULL, TRUE);
  711. if (isset($post['page'])) {
  712. $page = $this->input->post('page', true);
  713. $perpage = $this->input->post('perpage', true);
  714. $category = $this->input->post('category', true);
  715. $size = $this->input->post('size', true);
  716. $grade = $this->input->post('grade', true);
  717. $color = $this->input->post('color', true);
  718. $lowe = $this->input->post('lowe', true);
  719. $sku = $this->input->post('sku');
  720. $title = $this->input->post('title');
  721. $warehouse = $this->input->post('warehouse', true);
  722. $usa = $this->input->post('usa', true);
  723. $purchase = $this->input->post('purchase', true);
  724. $lacetype = $this->input->post('lacetype', true);
  725. $haircap = $this->input->post('haircap', true);
  726. $density = $this->input->post('density', true);
  727. $details = $this->input->post('details', true);
  728. $state = $this->input->post('state', true);
  729. $lacecolor = $this->input->post('lacecolor', true);
  730. $cklx = $this->input->post('cklx', true);
  731. $ktime = $this->input->post('ktime', true);
  732. $jtime = $this->input->post('jtime', true);
  733. $ktime = strtotime($ktime);
  734. $jtime = strtotime($jtime);
  735. $where = "1=1";
  736. $gj = "";
  737. $ck = "";
  738. if ($lacetype) {
  739. $where .= " and features like '%-$lacetype-%'";
  740. }
  741. if ($category) {
  742. $where .= " and features like '%-$category-%'";
  743. }
  744. if ($size) {
  745. $where .= " and features like '%-$size-%'";
  746. }
  747. if ($grade) {
  748. $where .= " and features like '%-$grade-%'";
  749. }
  750. if ($color) {
  751. $where .= " and features like '%-$color-%'";
  752. }
  753. if ($lowe) {
  754. $where .= " and features like '%-$lowe-%'";
  755. }
  756. if ($haircap) {
  757. $where .= " and features like '%-$haircap-%'";
  758. }
  759. if ($density) {
  760. $where .= " and features like '%-$density-%'";
  761. }
  762. if ($lacecolor) {
  763. $where .= " and features like '%-$lacecolor-%'";
  764. }
  765. if ($usa) {
  766. if (!$warehouse) {
  767. $where .= " and (warehouse = '5' or warehouse = '8')";
  768. }
  769. }
  770. if ($warehouse) {
  771. $where .= " and warehouse = '$warehouse'";
  772. }
  773. if ($details) {
  774. $where .= " and details = '$details'";
  775. }
  776. if ($purchase) {
  777. $where .= " and purchase = '$purchase'";
  778. }
  779. if ($state) {
  780. $where .= " and state = '$state'";
  781. }
  782. $where_add = '';
  783. if ($cklx) {
  784. $shop = $this->shop->read($cklx);
  785. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  786. }
  787. if ($ktime && $jtime) {
  788. $gj = " and enter > '$ktime' and enter < '$jtime'";
  789. $ck = " and outk > '$ktime' and outk < '$jtime'";
  790. }
  791. //数据排序
  792. $order_str = "id desc";
  793. if (empty($page)) {
  794. $start = 0;
  795. $perpage = 1;
  796. } else {
  797. $start = ($page - 1) * $perpage;
  798. }
  799. if ($sku) {
  800. $sku = trim($sku, ' ');
  801. $sku = trim($sku, ' ');
  802. $where .= " and sku like '%$sku%'";
  803. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  804. } else if ($title) {
  805. $title = trim($title, ' ');
  806. $title = trim($title, ' ');
  807. $where .= " and title like '%$title%'";
  808. $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);
  809. } else {
  810. //$where .= " and time > '$ktime' and time < '$jtime'";
  811. $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);
  812. }
  813. //取得信息列表
  814. $rows = array();
  815. $list = array();
  816. foreach ($info_list as $key => $value) {
  817. $warehouse = $this->warehouse->read($value['warehouse']);
  818. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  819. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  820. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  821. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  822. $ftime = time() - 15 * 24 * 3600;
  823. $info_list[$key]['warehouse'] = $warehouse['title'];
  824. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  825. //$z = count($z);//查看订单号
  826. //$info_list[$key]['zd'] = $z;
  827. $details = array();
  828. $cpid = array();
  829. foreach ($c as $k => $v) {
  830. $details[$v['details']] = $v['details'];
  831. if ($v['cpid'] != 0) {
  832. $cpid[$v['cpid']] = $v['cpid'];
  833. }
  834. }
  835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  836. if ($value['shop'] != '') {
  837. $shop = explode(',', trim($value['shop'], ','));
  838. $shop = $this->shop->read($shop[0]);
  839. $info_list[$key]['shop'] = $shop['shopname'];
  840. }
  841. }
  842. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  843. $pagenum = ceil($total / $perpage);
  844. $over = $total - ($start + $perpage);
  845. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  846. echo json_encode($rows);
  847. exit;
  848. }
  849. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  850. $this->_Template('whlabel_typedy_ck', $this->data);
  851. }
  852. public function _typeck($arg_array)
  853. {
  854. $prc = array();
  855. $purchase = $this->purchase->find_all();
  856. foreach ($purchase as $k => $v) {
  857. $prc[$v['id']] = $v['title'];
  858. }
  859. $post = $this->input->post(NULL, TRUE);
  860. if (isset($post['page'])) {
  861. $page = $this->input->post('page', true);
  862. $perpage = $this->input->post('perpage', true);
  863. $category = $this->input->post('category', true);
  864. $size = $this->input->post('size', true);
  865. $grade = $this->input->post('grade', true);
  866. $color = $this->input->post('color', true);
  867. $lacecolor = $this->input->post('lacecolor', true);
  868. $lowe = $this->input->post('lowe', true);
  869. $sku = $this->input->post('sku');
  870. $title = $this->input->post('title');
  871. $warehouse = 13;
  872. $usa = $this->input->post('usa', true);
  873. $purchase = $this->input->post('purchase', true);
  874. $lacetype = $this->input->post('lacetype', true);
  875. $haircap = $this->input->post('haircap', true);
  876. $density = $this->input->post('density', true);
  877. $details = $this->input->post('details', true);
  878. $state = $this->input->post('state', true);
  879. $ktime = $this->input->post('ktime', true);
  880. $jtime = $this->input->post('jtime', true);
  881. $ktime = strtotime($ktime);
  882. $jtime = strtotime($jtime);
  883. $where = "1=1";
  884. $gj = "";
  885. $ck = "";
  886. if ($lacetype) {
  887. $where .= " and features like '%-$lacetype-%'";
  888. }
  889. if ($category) {
  890. $where .= " and features like '%-$category-%'";
  891. }
  892. if ($size) {
  893. $where .= " and features like '%-$size-%'";
  894. }
  895. if ($grade) {
  896. $where .= " and features like '%-$grade-%'";
  897. }
  898. if ($color) {
  899. $where .= " and features like '%-$color-%'";
  900. }
  901. if ($lacecolor) {
  902. $where .= " and features like '%-$lacecolor-%'";
  903. }
  904. if ($lowe) {
  905. $where .= " and features like '%-$lowe-%'";
  906. }
  907. if ($haircap) {
  908. $where .= " and features like '%-$haircap-%'";
  909. }
  910. if ($density) {
  911. $where .= " and features like '%-$density-%'";
  912. }
  913. if ($warehouse) {
  914. $where .= " and warehouse = '$warehouse'";
  915. }
  916. if ($details) {
  917. $where .= " and details = '$details'";
  918. }
  919. if ($purchase) {
  920. $where .= " and purchase = '$purchase'";
  921. }
  922. if ($state) {
  923. $where .= " and state = '$state'";
  924. }
  925. if ($ktime && $jtime) {
  926. $gj = " and enter > '$ktime' and enter < '$jtime'";
  927. $ck = " and outk > '$ktime' and outk < '$jtime'";
  928. }
  929. //数据排序
  930. $order_str = "id desc";
  931. if (empty($page)) {
  932. $start = 0;
  933. $perpage = 1;
  934. } else {
  935. $start = ($page - 1) * $perpage;
  936. }
  937. if ($sku) {
  938. $sku = trim($sku, ' ');
  939. $sku = trim($sku, ' ');
  940. $where .= " and sku like '%$sku%'";
  941. } else if ($title) {
  942. $title = trim($title, ' ');
  943. $title = trim($title, ' ');
  944. $where .= " and title like '%$title%'";
  945. }
  946. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  947. //取得信息列表
  948. $t = array();
  949. $typeclass = $this->typeclass->find_all();
  950. foreach ($typeclass as $v) {
  951. $t[$v['id']] = $v;
  952. }
  953. $rows = array();
  954. $list = array();
  955. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  956. foreach ($info_list as $key => $value) {
  957. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  958. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  959. $warehouse = $this->warehouse->read($value['warehouse']);
  960. $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');
  961. $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'] . '"');
  962. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  963. $number = $value['number'];
  964. $ftime = time() - 15 * 24 * 3600;
  965. $z = count($z); //查看订单号
  966. $info_list[$key]['warehouse'] = $warehouse['title'];
  967. $info_list[$key]['features'] = count($c);
  968. $info_list[$key]['number'] = $z;
  969. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  970. $details = array();
  971. $cpid = array();
  972. foreach ($c as $k => $v) {
  973. $details[$v['details']] = $v['details'];
  974. if ($v['cpid'] != 0) {
  975. $cpid[$v['cpid']] = $v['cpid'];
  976. }
  977. }
  978. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  979. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  980. unset($info_list[$key]['pm']);
  981. unset($info_list[$key]['jm']);
  982. unset($info_list[$key]['bm']);
  983. }
  984. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  985. $pagenum = ceil($total / $perpage);
  986. $over = $total - ($start + $perpage);
  987. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  988. echo json_encode($rows);
  989. exit;
  990. }
  991. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  992. $this->_Template('whlabel_typeck', $this->data);
  993. }
  994. //进销存导出
  995. public function _whlabeckdc()
  996. {
  997. $prc = array();
  998. $purchase = $this->purchase->find_all();
  999. foreach ($purchase as $k => $v) {
  1000. $prc[$v['id']] = $v['title'];
  1001. }
  1002. if (isset($_GET['excel'])) {
  1003. $where = "sku != 'Preset'";
  1004. //数据排序
  1005. $order_str = "id desc";
  1006. if (empty($page)) {
  1007. $start = 0;
  1008. $perpage = 1;
  1009. } else {
  1010. $start = ($page - 1) * $perpage;
  1011. }
  1012. $category = $this->input->get('category', true);
  1013. $color = $this->input->get('color', true);
  1014. $lowe = $this->input->get('lowe', true);
  1015. $lacetype = $this->input->get('lacetype', true);
  1016. $size = $this->input->get('size', true);
  1017. $density = $this->input->get('density', true);
  1018. $haircap = $this->input->get('haircap', true);
  1019. $sku = $this->input->get('sku', true);
  1020. $details = $this->input->get('details', true);
  1021. $warehouse = 13;
  1022. $excelid = $this->input->get('sid', true);
  1023. if ($category) {
  1024. $where .= " and features like '%-$category-%'";
  1025. }
  1026. if ($color) {
  1027. $where .= " and features like '%-$color-%'";
  1028. }
  1029. if ($lowe) {
  1030. $where .= " and features like '%-$lowe-%'";
  1031. }
  1032. if ($lacetype) {
  1033. $where .= " and features like '%-$lacetype-%'";
  1034. }
  1035. if ($size) {
  1036. $where .= " and features like '%-$size-%'";
  1037. }
  1038. if ($density) {
  1039. $where .= " and features like '%-$density-%'";
  1040. }
  1041. if ($haircap) {
  1042. $where .= " and features like '%-$haircap-%'";
  1043. }
  1044. if ($warehouse) {
  1045. $where .= " and warehouse = '$warehouse'";
  1046. }
  1047. if ($sku) {
  1048. $where .= " and sku like '%$sku%'";
  1049. }
  1050. if ($details) {
  1051. $where .= " and details = '$details'";
  1052. }
  1053. $xzid = '';
  1054. if ($excelid) {
  1055. $excelid = explode(',', trim($excelid, ','));
  1056. foreach ($excelid as $key => $value) {
  1057. $xzid .= " id = " . $value . " or";
  1058. }
  1059. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1060. }
  1061. //取得信息列表
  1062. /**
  1063. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1064. $rows = array();$list = array();
  1065. foreach ($info_list as $key=>$value)
  1066. {
  1067. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1068. }
  1069. **/
  1070. $wh = array();
  1071. $w = $this->warehouse->find_all('1=1', 'id,title');
  1072. foreach ($w as $v) {
  1073. $wh[$v['id']] = $v['title'];
  1074. }
  1075. $tc = array();
  1076. $tcdata = array();
  1077. $list = array();
  1078. $classid = $this->classid->sku();
  1079. $tcall = $this->typeclass->find_all();
  1080. $typeclass = array();
  1081. foreach ($tcall as $v)
  1082. {
  1083. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1084. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1085. }
  1086. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1087. foreach ($rows as $key => $value) {
  1088. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1089. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1090. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1091. $rows[$key]['cpbz'] = $u9_info['bm'];
  1092. $rows[$key]['cs'] = $u9_info['jm'];
  1093. if(empty($value['details'])){
  1094. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1095. }else{
  1096. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1097. }
  1098. $details = array();
  1099. $cpid = array();
  1100. $cpbz = array();
  1101. $c = 0;
  1102. $g = 0;
  1103. $x = 0;
  1104. $t = 0;
  1105. $s = 0;
  1106. $q = 0;
  1107. foreach ($sd as $k => $v) {
  1108. if ($v['state'] == 0) {
  1109. $c++;
  1110. }
  1111. if ($v['state'] != 9) {
  1112. $g++;
  1113. }
  1114. if ($v['state'] == 1) {
  1115. $x++;
  1116. }
  1117. if ($v['state'] == 2) {
  1118. $t++;
  1119. }
  1120. if ($v['state'] == 8) {
  1121. $s++;
  1122. }
  1123. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1124. $q++;
  1125. }
  1126. $details[$v['details']] = $v['details'];
  1127. if ($v['cpid'] != 0) {
  1128. $cpid[$v['cpid']] = $v['cpid'];
  1129. }
  1130. if ($v['cpbz'] != '') {
  1131. $cpbz[$v['cpbz']] = $v['cpbz'];
  1132. }
  1133. }
  1134. $rows[$key]['details'] = implode("、", $details);
  1135. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1136. $number = $value['number'];
  1137. $ftime = time() - 15 * 24 * 3600;
  1138. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1139. $rows[$key]['number'] = $g;
  1140. $rows[$key]['features'] = $c;
  1141. $rows[$key]['x'] = $x;
  1142. $rows[$key]['t'] = $t;
  1143. $rows[$key]['s'] = $s;
  1144. $rows[$key]['q'] = $q;
  1145. $rows[$key]['wzsl'] = count($details);
  1146. //cpbzs
  1147. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1148. $unique_arr = array_unique($tmp_cpbzs);
  1149. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1150. }
  1151. $title = "进销存统计表" . date('Y-m-d', time());
  1152. $titlename = "<table border=1>
  1153. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1154. <tr align='center'>
  1155. <td>仓库</td>
  1156. <td>供应商</td>
  1157. <td>位置</td>
  1158. <td>库存编码</td>
  1159. <td>SKU</td>
  1160. <td>用友编码</td>
  1161. <td>用友料号</td>
  1162. <td>产品英文名</td>
  1163. <td>产品中文名</td>
  1164. <td>备注</td>
  1165. <td>入库总量</td>
  1166. <td>库存数量</td>
  1167. <td>销售数量</td>
  1168. <td>退货数量</td>
  1169. <td>删除数量</td>
  1170. <td>其它操作</td>
  1171. <td>位置数量</td>
  1172. </tr>
  1173. </table>";
  1174. $filename = $title . ".xls";
  1175. $tail = "";
  1176. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1177. }
  1178. }
  1179. public function _type()
  1180. {
  1181. $vip = 0;
  1182. if (isset($_SESSION['api'])) {
  1183. $user = $this->user->get_api($_SESSION['api']);
  1184. $fgshop = "";
  1185. $sid = "";
  1186. $usersp = explode('|', trim($user['shop'], '|'));
  1187. foreach ($usersp as $value) {
  1188. $fgshop .= " shop = " . $value . " or";
  1189. $sid .= " id = " . $value . " or";
  1190. }
  1191. if ($user['vip'] == 1) {
  1192. $vip = 1;
  1193. }
  1194. } else {
  1195. header('Location: /');
  1196. exit;
  1197. }
  1198. $prc = array();
  1199. $purchase = $this->purchase->find_all();
  1200. foreach ($purchase as $k => $v) {
  1201. $prc[$v['id']] = $v['title'];
  1202. }
  1203. $company = array();
  1204. $ct = $this->company->find_all();
  1205. foreach ($ct as $k => $v) {
  1206. $company[$v['id']] = $v['title'];
  1207. }
  1208. $sp = array();
  1209. $s = $this->shop->find_all('1=1', 'id,shopname');
  1210. foreach ($s as $v) {
  1211. $sp[$v['id']] = $v['shopname'];
  1212. }
  1213. $wh = array();
  1214. $w = $this->warehouse->find_all('1=1', 'id,title');
  1215. foreach ($w as $v) {
  1216. $wh[$v['id']] = $v['title'];
  1217. }
  1218. $post = $this->input->post(NULL, TRUE);
  1219. if (isset($post['page'])) {
  1220. $page = $this->input->post('page', true);
  1221. $perpage = $this->input->post('perpage', true);
  1222. $category = $this->input->post('category', true);
  1223. $size = $this->input->post('size', true);
  1224. $grade = $this->input->post('grade', true);
  1225. $color = $this->input->post('color', true);
  1226. $lowe = $this->input->post('lowe', true);
  1227. $sku = $this->input->post('sku');
  1228. $title = $this->input->post('title');
  1229. $warehouse = $this->input->post('warehouse', true);
  1230. $usa = $this->input->post('usa', true);
  1231. $purchase = $this->input->post('purchase', true);
  1232. $lacetype = $this->input->post('lacetype', true);
  1233. $haircap = $this->input->post('haircap', true);
  1234. $density = $this->input->post('density', true);
  1235. $details = $this->input->post('details', true);
  1236. $state = $this->input->post('state', true);
  1237. $shop = $this->input->post('shop', true);
  1238. $lacecolor = $this->input->post('lacecolor', true);
  1239. $hairnumber = $this->input->post('hairnumber', true);
  1240. $type = $this->input->post('type', true);
  1241. $ktime = $this->input->post('ktime', true);
  1242. $jtime = $this->input->post('jtime', true);
  1243. $ktime = strtotime($ktime);
  1244. $jtime = strtotime($jtime);
  1245. $cpbz = $this->input->post('cpbz', true);
  1246. $sm = $this->input->post('sm', true);
  1247. $where = "1=1";
  1248. $gj = "";
  1249. $ck = "";
  1250. if ($usa) {
  1251. if (!$warehouse) {
  1252. $where .= " and (warehouse = '5' or warehouse = '8')";
  1253. }
  1254. }
  1255. if ($warehouse) {
  1256. $where .= " and warehouse = '$warehouse'";
  1257. }
  1258. if ($details) {
  1259. $where .= " and details = '$details'";
  1260. }
  1261. if ($purchase) {
  1262. $where .= " and purchase = '$purchase'";
  1263. }
  1264. if ($state) {
  1265. $where .= " and state = '$state'";
  1266. }
  1267. if ($shop) {
  1268. $where .= " and shop like '%$shop%'";
  1269. }
  1270. if ($type) {
  1271. $where .= " and type = '$type'";
  1272. }
  1273. if ($ktime && $jtime) {
  1274. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1275. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1276. }
  1277. if ($cpbz) {
  1278. $where .= " and cpbz like '%$cpbz%' ";
  1279. }
  1280. if ($sm) {
  1281. $where .= " and sm like '%$sm%' ";
  1282. }
  1283. if ($lacecolor) {
  1284. $where .= " and features like '%-$lacecolor-%'";
  1285. }
  1286. if ($lacetype) {
  1287. $where .= " and features like '%-$lacetype-%'";
  1288. }
  1289. if ($category) {
  1290. $where .= " and features like '%-$category-%'";
  1291. }
  1292. if ($size) {
  1293. $where .= " and features like '%-$size-%'";
  1294. }
  1295. if ($grade) {
  1296. $where .= " and features like '%-$grade-%'";
  1297. }
  1298. if ($color) {
  1299. $where .= " and features like '%-$color-%'";
  1300. }
  1301. if ($lowe) {
  1302. $where .= " and features like '%-$lowe-%'";
  1303. }
  1304. if ($haircap) {
  1305. $where .= " and features like '%-$haircap-%'";
  1306. }
  1307. if ($density) {
  1308. $where .= " and features like '%-$density-%'";
  1309. }
  1310. if (!empty($hairnumber)) {
  1311. $where .= " and features like '%-128-%' ";
  1312. if ($hairnumber < 0) {
  1313. $class_list = $this->typeclass->find_all('classid = 43');
  1314. foreach ($class_list as $v) {
  1315. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1316. }
  1317. } else {
  1318. $where .= " and features like '%-$hairnumber-%'";
  1319. }
  1320. }
  1321. //数据排序
  1322. $order_str = "id desc";
  1323. if (empty($page)) {
  1324. $start = 0;
  1325. $perpage = 1;
  1326. } else {
  1327. $start = ($page - 1) * $perpage;
  1328. }
  1329. $fjnr = '';
  1330. if ($sku) {
  1331. $sku = trim($sku, ' ');
  1332. $sku = trim($sku, ' ');
  1333. $fjnr .= " and sku like '%$sku%'";
  1334. }
  1335. if ($title) {
  1336. $title = trim($title, ' ');
  1337. $title = trim($title, ' ');
  1338. $fjnr .= " and title like '%$title%'";
  1339. }
  1340. $wt = array();
  1341. $whlabel_type = $this->whlabel_type->find_all();
  1342. foreach ($whlabel_type as $v) {
  1343. $wt[$v['id']] = $v['title'];
  1344. }
  1345. //$where .= " and time > '$ktime' and time < '$jtime'";
  1346. $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
  1347. //取得信息列表
  1348. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1349. $rows = array();
  1350. $list = array();
  1351. foreach ($info_list as $key => $value) {
  1352. if (isset($wt[$value['type']])) {
  1353. $info_list[$key]['type'] = $wt[$value['type']];
  1354. } else {
  1355. $info_list[$key]['type'] = '未设置';
  1356. }
  1357. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1358. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1359. $ztdata = '';
  1360. if (count($zt) > 0) {
  1361. foreach ($zt as $vv) {
  1362. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1363. }
  1364. }
  1365. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1366. $cdata = array_filter($qbdata, function ($item) {
  1367. return $item['state'] < 1;
  1368. });
  1369. $c = array_sum(array_column($cdata, 'jnum'));
  1370. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1371. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1372. });
  1373. $g = array_sum(array_column($gdata, 'jnum'));
  1374. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1375. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1376. });
  1377. $x = array_sum(array_column($xdata, 'jnum'));
  1378. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1379. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1380. });
  1381. $t = array_sum(array_column($tdata, 'jnum'));
  1382. // $zdata = array_filter($qbdata, function ($item) {
  1383. // return $item['zd'] != "" && $item['state'] < 1;
  1384. // });
  1385. // $z = array_sum(array_column($zdata, 'jnum'));
  1386. $zdata = array_filter($qbdata, function ($item) {
  1387. return $item['zd'] != "" && $item['state'] < 1;
  1388. });
  1389. $z = array_sum(array_column($zdata, 'jnum'));
  1390. //$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');
  1391. //$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'].'"');
  1392. //$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'].'"');
  1393. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1394. //$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'].'"');
  1395. $details = array();
  1396. $cpid = array();
  1397. $od = array();
  1398. $odid = '';
  1399. $companytitle = '';
  1400. $shop_list = [];
  1401. foreach ($qbdata as $v) {
  1402. if ($v['zd'] != "" && $v['state'] < 1) {
  1403. if (!isset($od[$v['zd']])) {
  1404. $od[$v['zd']] = 1; //所有数据sku
  1405. } else {
  1406. $od[$v['zd']] = $od[$v['zd']] + 1;
  1407. }
  1408. }
  1409. if($v['state'] == 0){
  1410. $details[$v['details']] = $v['details'];
  1411. }
  1412. if ($v['state'] < 1) {
  1413. //$details[$v['details']] = $v['details'];
  1414. if ($v['cpid'] != 0) {
  1415. $cpid[$v['cpid']] = $v['cpid'];
  1416. }
  1417. }
  1418. if($v['state'] == 0){
  1419. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1420. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1421. }
  1422. if ($v['shop'] != '') {
  1423. $shop = explode(',', trim($v['shop'], ','));
  1424. foreach ($shop as $vv) {
  1425. if (!in_array($vv, $shop_list)) {
  1426. $shop_list[] = $vv;
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. foreach ($od as $k => $vv) {
  1433. $odid .= $k . '数量' . $vv;
  1434. }
  1435. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1436. $info_list[$key]['label'] = $value['sm'];
  1437. $number = $value['number'];
  1438. $ftime = time() - 15 * 24 * 3600;
  1439. $z = $z . '(' . $odid . ')'; //查看订单号
  1440. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1441. $info_list[$key]['features'] = $c;
  1442. $info_list[$key]['number'] = $ztdata;
  1443. $info_list[$key]['sm'] = $g;
  1444. $info_list[$key]['x'] = $x;
  1445. $info_list[$key]['t'] = $t;
  1446. $info_list[$key]['z'] = $z;
  1447. /**
  1448. foreach ($cdata as $k=>$v)
  1449. {
  1450. $details[$v['details']] = $v['details'];
  1451. if($v['cpid'] != 0)
  1452. {
  1453. $cpid[$v['cpid']] = $v['cpid'];
  1454. }
  1455. }
  1456. **/
  1457. $info_list[$key]['shop'] = '';
  1458. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1459. // if ($value['shop'] != '') {
  1460. // $shop = explode(',', trim($value['shop'], ','));
  1461. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1462. // }
  1463. $shop_list = array_unique($shop_list);
  1464. $shop_str = '';
  1465. foreach ($shop_list as $v) {
  1466. if(isset($sp[$v])){
  1467. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1468. }
  1469. }
  1470. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1471. /**
  1472. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1473. if(isset($companytitle[0]))
  1474. {
  1475. foreach ($companytitle as $k=>$v)
  1476. {
  1477. if($v['companytitle'] != '')
  1478. {
  1479. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1480. }
  1481. }
  1482. }
  1483. **/
  1484. }
  1485. $final_all_list = [];
  1486. foreach ($info_list as $k => $v) {
  1487. $final_all_list[] = [
  1488. 'id' => $v['id'],
  1489. "warehouse" => $v["warehouse"],
  1490. "purchase" => $v["purchase"],
  1491. "sku" => $v["sku"],
  1492. "title" => $v["title"] . "<br/>" . $v["pm"],
  1493. "details" => $v["details"],
  1494. "shop" => $v["shop"],
  1495. "cpbz" => $v["cpbz"],
  1496. 'label' => $v['label'],
  1497. "type" => $v["type"],
  1498. "features" => $v["features"],
  1499. "number" => $v["number"],
  1500. "sm" => $v["sm"],
  1501. "x" => $v["x"],
  1502. "t" => $v["t"],
  1503. "z" => $v["z"]
  1504. ];
  1505. }
  1506. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1507. $pagenum = ceil($total / $perpage);
  1508. $over = $total - ($start + $perpage);
  1509. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1510. echo json_encode($rows);
  1511. exit;
  1512. }
  1513. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1514. $this->data['shop'] = $wlshop;
  1515. $this->data['vip'] = $vip;
  1516. $this->_Template('whlabel_type', $this->data);
  1517. }
  1518. /**
  1519. * _type 优化版 v1
  1520. * 优化点:
  1521. * 1. 循环内 N+1 查询改为批量预取(方案 A),SQL 从 2+2P 降到固定 4 条
  1522. * 2. 总数统计改为只 COUNT 不传输明细字段(方案 C)
  1523. * 3. 批量 qbdata 查询去掉 features like 条件,走组合键 IN 精确匹配
  1524. * 4. 批量 transport 查询加 ORDER BY stime 保证顺序与原来一致
  1525. */
  1526. public function _typev1()
  1527. {
  1528. $vip = 0;
  1529. if (isset($_SESSION['api'])) {
  1530. $user = $this->user->get_api($_SESSION['api']);
  1531. $fgshop = "";
  1532. $sid = "";
  1533. $usersp = explode('|', trim($user['shop'], '|'));
  1534. foreach ($usersp as $value) {
  1535. $fgshop .= " shop = " . $value . " or";
  1536. $sid .= " id = " . $value . " or";
  1537. }
  1538. if ($user['vip'] == 1) {
  1539. $vip = 1;
  1540. }
  1541. } else {
  1542. header('Location: /');
  1543. exit;
  1544. }
  1545. $prc = array();
  1546. $purchase = $this->purchase->find_all();
  1547. foreach ($purchase as $k => $v) {
  1548. $prc[$v['id']] = $v['title'];
  1549. }
  1550. $company = array();
  1551. $ct = $this->company->find_all();
  1552. foreach ($ct as $k => $v) {
  1553. $company[$v['id']] = $v['title'];
  1554. }
  1555. $sp = array();
  1556. $s = $this->shop->find_all('1=1', 'id,shopname');
  1557. foreach ($s as $v) {
  1558. $sp[$v['id']] = $v['shopname'];
  1559. }
  1560. $wh = array();
  1561. $w = $this->warehouse->find_all('1=1', 'id,title');
  1562. foreach ($w as $v) {
  1563. $wh[$v['id']] = $v['title'];
  1564. }
  1565. $post = $this->input->post(NULL, TRUE);
  1566. if (isset($post['page'])) {
  1567. $page = $this->input->post('page', true);
  1568. $perpage = $this->input->post('perpage', true);
  1569. $category = $this->input->post('category', true);
  1570. $size = $this->input->post('size', true);
  1571. $grade = $this->input->post('grade', true);
  1572. $color = $this->input->post('color', true);
  1573. $lowe = $this->input->post('lowe', true);
  1574. $sku = $this->input->post('sku');
  1575. $title = $this->input->post('title');
  1576. $warehouse = $this->input->post('warehouse', true);
  1577. $usa = $this->input->post('usa', true);
  1578. $purchase = $this->input->post('purchase', true);
  1579. $lacetype = $this->input->post('lacetype', true);
  1580. $haircap = $this->input->post('haircap', true);
  1581. $density = $this->input->post('density', true);
  1582. $details = $this->input->post('details', true);
  1583. $state = $this->input->post('state', true);
  1584. $shop = $this->input->post('shop', true);
  1585. $lacecolor = $this->input->post('lacecolor', true);
  1586. $hairnumber = $this->input->post('hairnumber', true);
  1587. $type = $this->input->post('type', true);
  1588. $ktime = $this->input->post('ktime', true);
  1589. $jtime = $this->input->post('jtime', true);
  1590. $ktime = strtotime($ktime);
  1591. $jtime = strtotime($jtime);
  1592. $cpbz = $this->input->post('cpbz', true);
  1593. $sm = $this->input->post('sm', true);
  1594. $where = "1=1";
  1595. // $where_no_features 用于批量预取,去掉 features like 条件,靠组合键精确匹配
  1596. $where_no_features = "1=1";
  1597. if ($usa) {
  1598. if (!$warehouse) {
  1599. $where .= " and (warehouse = '5' or warehouse = '8')";
  1600. $where_no_features .= " and (warehouse = '5' or warehouse = '8')";
  1601. }
  1602. }
  1603. if ($warehouse) {
  1604. $where .= " and warehouse = '$warehouse'";
  1605. $where_no_features .= " and warehouse = '$warehouse'";
  1606. }
  1607. if ($details) {
  1608. $where .= " and details = '$details'";
  1609. $where_no_features .= " and details = '$details'";
  1610. }
  1611. if ($purchase) {
  1612. $where .= " and purchase = '$purchase'";
  1613. $where_no_features .= " and purchase = '$purchase'";
  1614. }
  1615. if ($state) {
  1616. $where .= " and state = '$state'";
  1617. $where_no_features .= " and state = '$state'";
  1618. }
  1619. if ($shop) {
  1620. $where .= " and shop like '%$shop%'";
  1621. $where_no_features .= " and shop like '%$shop%'";
  1622. }
  1623. if ($type) {
  1624. $where .= " and type = '$type'";
  1625. $where_no_features .= " and type = '$type'";
  1626. }
  1627. if ($cpbz) {
  1628. $where .= " and cpbz like '%$cpbz%' ";
  1629. $where_no_features .= " and cpbz like '%$cpbz%' ";
  1630. }
  1631. if ($sm) {
  1632. $where .= " and sm like '%$sm%' ";
  1633. $where_no_features .= " and sm like '%$sm%' ";
  1634. }
  1635. // features like 条件只加入 $where(列表分组用),不加入 $where_no_features
  1636. if ($lacecolor) {
  1637. $where .= " and features like '%-$lacecolor-%'";
  1638. }
  1639. if ($lacetype) {
  1640. $where .= " and features like '%-$lacetype-%'";
  1641. }
  1642. if ($category) {
  1643. $where .= " and features like '%-$category-%'";
  1644. }
  1645. if ($size) {
  1646. $where .= " and features like '%-$size-%'";
  1647. }
  1648. if ($grade) {
  1649. $where .= " and features like '%-$grade-%'";
  1650. }
  1651. if ($color) {
  1652. $where .= " and features like '%-$color-%'";
  1653. }
  1654. if ($lowe) {
  1655. $where .= " and features like '%-$lowe-%'";
  1656. }
  1657. if ($haircap) {
  1658. $where .= " and features like '%-$haircap-%'";
  1659. }
  1660. if ($density) {
  1661. $where .= " and features like '%-$density-%'";
  1662. }
  1663. if (!empty($hairnumber)) {
  1664. $where .= " and features like '%-128-%' ";
  1665. if ($hairnumber < 0) {
  1666. $class_list = $this->typeclass->find_all('classid = 43');
  1667. foreach ($class_list as $v) {
  1668. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1669. }
  1670. } else {
  1671. $where .= " and features like '%-$hairnumber-%'";
  1672. }
  1673. }
  1674. //数据排序
  1675. $order_str = "id desc";
  1676. if (empty($page)) {
  1677. $start = 0;
  1678. $perpage = 1;
  1679. } else {
  1680. $start = ($page - 1) * $perpage;
  1681. }
  1682. $fjnr = '';
  1683. if ($sku) {
  1684. $sku = trim($sku, ' ');
  1685. $sku = trim($sku, ' ');
  1686. $fjnr .= " and sku like '%$sku%'";
  1687. }
  1688. if ($title) {
  1689. $title = trim($title, ' ');
  1690. $title = trim($title, ' ');
  1691. $fjnr .= " and title like '%$title%'";
  1692. }
  1693. $wt = array();
  1694. $whlabel_type = $this->whlabel_type->find_all();
  1695. foreach ($whlabel_type as $v) {
  1696. $wt[$v['id']] = $v['title'];
  1697. }
  1698. // 列表分组(与原来完全一致)
  1699. $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);
  1700. //取得信息列表
  1701. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1702. // ========== 优化方案 A:批量预取 whlabel 组数据和 transport 数据 ==========
  1703. $keys = array();
  1704. foreach ($info_list as $v) {
  1705. $keys[] = "('" . addslashes($v['sku']) . "','" . addslashes($v['purchase'])
  1706. . "','" . addslashes($v['features']) . "','" . addslashes($v['warehouse']) . "')";
  1707. }
  1708. // 组合键函数,用于 PHP 端按分组索引
  1709. $comboKey = function ($r) {
  1710. return $r['sku'] . '|' . $r['purchase'] . '|' . $r['features'] . '|' . $r['warehouse'];
  1711. };
  1712. // 批量拉取 whlabel 组数据(使用 $where_no_features,不带 features like,靠 IN 元组精确匹配)
  1713. $all_qb = array();
  1714. if (!empty($keys)) {
  1715. $keyInSql = implode(',', $keys);
  1716. $qbAll = $this->whlabel->find_all(
  1717. $where_no_features . " and (sku,purchase,features,warehouse) IN (" . $keyInSql . ")"
  1718. );
  1719. foreach ($qbAll as $r) {
  1720. $all_qb[$comboKey($r)][] = $r;
  1721. }
  1722. }
  1723. // 批量拉取 transport 在途数据(3 列元组: sku,warehouse,features,与 IN 左侧列顺序一致)
  1724. $all_zt = array();
  1725. if (!empty($info_list)) {
  1726. $ztKeys = array();
  1727. foreach ($info_list as $v) {
  1728. $ztKeys[] = "('" . addslashes($v['sku']) . "','"
  1729. . addslashes($v['warehouse']) . "','"
  1730. . addslashes($v['features']) . "')";
  1731. }
  1732. $ztInSql = implode(',', $ztKeys);
  1733. $ztAll = $this->whlabeltransport->find_all(
  1734. "cz = '0' and (sku,warehouse,features) IN (" . $ztInSql . ")",
  1735. '*',
  1736. 'stime'
  1737. );
  1738. foreach ($ztAll as $r) {
  1739. $ck = $r['sku'] . '|' . $r['warehouse'] . '|' . $r['features'];
  1740. $all_zt[$ck][] = $r;
  1741. }
  1742. }
  1743. $rows = array();
  1744. $list = array();
  1745. foreach ($info_list as $key => $value) {
  1746. if (isset($wt[$value['type']])) {
  1747. $info_list[$key]['type'] = $wt[$value['type']];
  1748. } else {
  1749. $info_list[$key]['type'] = '未设置';
  1750. }
  1751. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1752. // transport 在途数据:从预取数组中取
  1753. $ztCk = $value['sku'] . '|' . $value['warehouse'] . '|' . $value['features'];
  1754. $zt = isset($all_zt[$ztCk]) ? $all_zt[$ztCk] : array();
  1755. $ztdata = '';
  1756. if (count($zt) > 0) {
  1757. foreach ($zt as $vv) {
  1758. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1759. }
  1760. }
  1761. // whlabel 组数据:从预取数组中取
  1762. $qbCk = $comboKey($value);
  1763. $qbdata = isset($all_qb[$qbCk]) ? $all_qb[$qbCk] : array();
  1764. $cdata = array_filter($qbdata, function ($item) {
  1765. return $item['state'] < 1;
  1766. });
  1767. $c = array_sum(array_column($cdata, 'jnum'));
  1768. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1769. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1770. });
  1771. $g = array_sum(array_column($gdata, 'jnum'));
  1772. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1773. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1774. });
  1775. $x = array_sum(array_column($xdata, 'jnum'));
  1776. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1777. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1778. });
  1779. $t = array_sum(array_column($tdata, 'jnum'));
  1780. $zdata = array_filter($qbdata, function ($item) {
  1781. return $item['zd'] != "" && $item['state'] < 1;
  1782. });
  1783. $z = array_sum(array_column($zdata, 'jnum'));
  1784. $detailsArr = array();
  1785. $cpid = array();
  1786. $od = array();
  1787. $odid = '';
  1788. $companytitle = '';
  1789. $shop_list = [];
  1790. foreach ($qbdata as $v) {
  1791. if ($v['zd'] != "" && $v['state'] < 1) {
  1792. if (!isset($od[$v['zd']])) {
  1793. $od[$v['zd']] = 1;
  1794. } else {
  1795. $od[$v['zd']] = $od[$v['zd']] + 1;
  1796. }
  1797. }
  1798. if ($v['state'] == 0) {
  1799. $detailsArr[$v['details']] = $v['details'];
  1800. }
  1801. if ($v['state'] < 1) {
  1802. if ($v['cpid'] != 0) {
  1803. $cpid[$v['cpid']] = $v['cpid'];
  1804. }
  1805. }
  1806. if ($v['state'] == 0) {
  1807. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1808. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1809. }
  1810. if ($v['shop'] != '') {
  1811. $shopArr = explode(',', trim($v['shop'], ','));
  1812. foreach ($shopArr as $vv) {
  1813. if (!in_array($vv, $shop_list)) {
  1814. $shop_list[] = $vv;
  1815. }
  1816. }
  1817. }
  1818. }
  1819. }
  1820. foreach ($od as $k => $vv) {
  1821. $odid .= $k . '数量' . $vv;
  1822. }
  1823. $info_list[$key]['cpbz'] = $value['cpbz'];
  1824. $info_list[$key]['label'] = $value['sm'];
  1825. $number = $value['number'];
  1826. $z = $z . '(' . $odid . ')';
  1827. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1828. $info_list[$key]['features'] = $c;
  1829. $info_list[$key]['number'] = $ztdata;
  1830. $info_list[$key]['sm'] = $g;
  1831. $info_list[$key]['x'] = $x;
  1832. $info_list[$key]['t'] = $t;
  1833. $info_list[$key]['z'] = $z;
  1834. $info_list[$key]['shop'] = '';
  1835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $detailsArr) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $detailsArr);
  1836. $shop_list = array_unique($shop_list);
  1837. $shop_str = '';
  1838. foreach ($shop_list as $v) {
  1839. if (isset($sp[$v])) {
  1840. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1841. }
  1842. }
  1843. $info_list[$key]['shop'] = $shop_str . $companytitle;
  1844. }
  1845. $final_all_list = [];
  1846. foreach ($info_list as $k => $v) {
  1847. $final_all_list[] = [
  1848. 'id' => $v['id'],
  1849. "warehouse" => $v["warehouse"],
  1850. "purchase" => $v["purchase"],
  1851. "sku" => $v["sku"],
  1852. "title" => $v["title"] . "<br/>" . $v["pm"],
  1853. "details" => $v["details"],
  1854. "shop" => $v["shop"],
  1855. "cpbz" => $v["cpbz"],
  1856. 'label' => $v['label'],
  1857. "type" => $v["type"],
  1858. "features" => $v["features"],
  1859. "number" => $v["number"],
  1860. "sm" => $v["sm"],
  1861. "x" => $v["x"],
  1862. "t" => $v["t"],
  1863. "z" => $v["z"]
  1864. ];
  1865. }
  1866. // ========== 优化方案 C:总数统计只 COUNT,不传明细字段 ==========
  1867. // 原实现: count(find_pc(..., 'id,warehouse,sku,title,features,number')),传输了大量明细字段
  1868. // 优化为: SELECT COUNT(*) FROM (SELECT 1 FROM whlabel WHERE ... GROUP BY ...) t,只传一个数字
  1869. $countSql = "SELECT COUNT(*) AS cnt FROM (SELECT 1 FROM crowd_whlabel WHERE " . $where . $fjnr . " GROUP BY sku,purchase,features,warehouse) t";
  1870. $countResult = $this->whlabel->query($countSql)->result_array();
  1871. $total = isset($countResult[0]['cnt']) ? (int)$countResult[0]['cnt'] : 0;
  1872. $pagenum = ceil($total / $perpage);
  1873. $over = $total - ($start + $perpage);
  1874. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1875. echo json_encode($rows);
  1876. exit;
  1877. }
  1878. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1879. $this->data['shop'] = $wlshop;
  1880. $this->data['vip'] = $vip;
  1881. $this->_Template('whlabel_typev1', $this->data);
  1882. }
  1883. //美仓进销存浏览
  1884. public function _usatype()
  1885. {
  1886. if (isset($_SESSION['api'])) {
  1887. $user = $this->user->get_api($_SESSION['api']);
  1888. $usp = $user;
  1889. $fgshop = "";
  1890. $sid = "";
  1891. $wid = "";
  1892. $wtype = "";
  1893. $userwh = explode('|', trim($user['warehouse'], '|'));
  1894. foreach ($userwh as $value) {
  1895. $wid .= " id = " . $value . " or";
  1896. $wtype .= " type = " . $value . " or";
  1897. }
  1898. }
  1899. $prc = array();
  1900. $purchase = $this->purchase->find_all();
  1901. foreach ($purchase as $k => $v) {
  1902. $prc[$v['id']] = $v['title'];
  1903. }
  1904. $post = $this->input->post(NULL, TRUE);
  1905. if (isset($post['page'])) {
  1906. $page = $this->input->post('page', true);
  1907. $perpage = $this->input->post('perpage', true);
  1908. $category = $this->input->post('category', true);
  1909. $size = $this->input->post('size', true);
  1910. $grade = $this->input->post('grade', true);
  1911. $color = $this->input->post('color', true);
  1912. $lowe = $this->input->post('lowe', true);
  1913. $sku = $this->input->post('sku');
  1914. $title = $this->input->post('title');
  1915. $warehouse = $this->input->post('warehouse', true);
  1916. $usa = $this->input->post('usa', true);
  1917. $purchase = $this->input->post('purchase', true);
  1918. $lacetype = $this->input->post('lacetype', true);
  1919. $haircap = $this->input->post('haircap', true);
  1920. $density = $this->input->post('density', true);
  1921. $details = $this->input->post('details', true);
  1922. $state = $this->input->post('state', true);
  1923. $lacecolor = $this->input->post('lacecolor', true);
  1924. $cklx = $this->input->post('cklx', true);
  1925. $ktime = $this->input->post('ktime', true);
  1926. $jtime = $this->input->post('jtime', true);
  1927. $ktime = strtotime($ktime);
  1928. $jtime = strtotime($jtime);
  1929. $where = "1=1";
  1930. $gj = "";
  1931. $ck = "";
  1932. if ($lacetype) {
  1933. $where .= " and features like '%-$lacetype-%'";
  1934. }
  1935. if ($category) {
  1936. $where .= " and features like '%-$category-%'";
  1937. }
  1938. if ($size) {
  1939. $where .= " and features like '%-$size-%'";
  1940. }
  1941. if ($grade) {
  1942. $where .= " and features like '%-$grade-%'";
  1943. }
  1944. if ($color) {
  1945. $where .= " and features like '%-$color-%'";
  1946. }
  1947. if ($lowe) {
  1948. $where .= " and features like '%-$lowe-%'";
  1949. }
  1950. if ($haircap) {
  1951. $where .= " and features like '%-$haircap-%'";
  1952. }
  1953. if ($density) {
  1954. $where .= " and features like '%-$density-%'";
  1955. }
  1956. if ($lacecolor) {
  1957. $where .= " and features like '%-$lacecolor-%'";
  1958. }
  1959. if ($usa) {
  1960. if (!$warehouse) {
  1961. $where .= " and (warehouse = '5' or warehouse = '8')";
  1962. }
  1963. }
  1964. if ($warehouse) {
  1965. $where .= " and warehouse = '$warehouse'";
  1966. }
  1967. if ($details) {
  1968. $where .= " and details = '$details'";
  1969. }
  1970. if ($purchase) {
  1971. $where .= " and purchase = '$purchase'";
  1972. }
  1973. if ($state) {
  1974. $where .= " and state = '$state'";
  1975. }
  1976. $where_add = '';
  1977. if ($cklx) {
  1978. $shop = $this->shop->read($cklx);
  1979. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1980. }
  1981. if ($ktime && $jtime) {
  1982. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1983. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1984. }
  1985. //数据排序
  1986. $order_str = "id desc";
  1987. if (empty($page)) {
  1988. $start = 0;
  1989. $perpage = 1;
  1990. } else {
  1991. $start = ($page - 1) * $perpage;
  1992. }
  1993. if ($sku) {
  1994. $sku = trim($sku, ' ');
  1995. $sku = trim($sku, ' ');
  1996. $where .= " and sku like '%$sku%'";
  1997. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1998. } else if ($title) {
  1999. $title = trim($title, ' ');
  2000. $title = trim($title, ' ');
  2001. $where .= " and title like '%$title%'";
  2002. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2003. } else {
  2004. //$where .= " and time > '$ktime' and time < '$jtime'";
  2005. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2006. }
  2007. //取得信息列表
  2008. $rows = array();
  2009. $list = array();
  2010. foreach ($info_list as $key => $value) {
  2011. $warehouse = $this->warehouse->read($value['warehouse']);
  2012. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2013. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2014. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2015. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2016. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2017. $od = array();
  2018. $odid = '';
  2019. foreach ($z as $v) {
  2020. if (!isset($od[$v['zd']])) {
  2021. $od[$v['zd']] = 1; //所有数据sku
  2022. } else {
  2023. $od[$v['zd']] = $od[$v['zd']] + 1;
  2024. }
  2025. }
  2026. foreach ($od as $k => $vv) {
  2027. $odid .= $k . '数量' . $vv . ' ';
  2028. }
  2029. $z = count($z) . '(' . $odid . ')'; //查看订单号
  2030. $info_list[$key]['features'] = $c;
  2031. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  2032. $ztdata = '';
  2033. if (count($zt) > 0) {
  2034. foreach ($zt as $vv) {
  2035. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  2036. }
  2037. }
  2038. $info_list[$key]['warehouse'] = $ztdata;
  2039. $info_list[$key]['g'] = $g;
  2040. $info_list[$key]['x'] = $x;
  2041. $info_list[$key]['t'] = $t;
  2042. $info_list[$key]['z'] = $z;
  2043. }
  2044. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  2045. $pagenum = ceil($total / $perpage);
  2046. $over = $total - ($start + $perpage);
  2047. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  2048. echo json_encode($rows);
  2049. exit;
  2050. }
  2051. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  2052. $this->data['warehouse'] = $warehouse;
  2053. $this->_Template('whlabel_typeusa', $this->data);
  2054. }
  2055. //美仓进销存浏览
  2056. public function _usatypeapp()
  2057. {
  2058. $post = $this->input->post(NULL, TRUE);
  2059. if (isset($post['page'])) {
  2060. $page = $this->input->post('page', true);
  2061. $perpage = $this->input->post('perpage', true);
  2062. $sku = $this->input->post('sku', true);
  2063. $warehouse = 5;
  2064. $title = $this->input->post('title', true);
  2065. $state = $this->input->post('state', true);
  2066. $ktime = $this->input->post('ktime', true);
  2067. $jtime = $this->input->post('jtime', true);
  2068. $ktime = strtotime($ktime);
  2069. $jtime = strtotime($jtime);
  2070. $where = "1=1";
  2071. $gj = "";
  2072. $ck = "";
  2073. if ($title) {
  2074. $st = explode(' ', trim($title, ' '));
  2075. foreach ($st as $v) {
  2076. $where .= " and title like '%$v%'";
  2077. }
  2078. }
  2079. if ($warehouse) {
  2080. $where .= " and warehouse = '$warehouse'";
  2081. }
  2082. if ($state) {
  2083. $where .= " and state = '$state'";
  2084. }
  2085. if ($sku) {
  2086. $where .= " and sku like '%$sku%'";
  2087. }
  2088. if ($ktime && $jtime) {
  2089. $gj = " and enter > '$ktime' and enter < '$jtime'";
  2090. $ck = " and outk > '$ktime' and outk < '$jtime'";
  2091. }
  2092. //数据排序
  2093. $order_str = "id desc";
  2094. if (empty($page)) {
  2095. $start = 0;
  2096. $perpage = 1;
  2097. } else {
  2098. $start = ($page - 1) * $perpage;
  2099. }
  2100. //取得信息列表
  2101. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  2102. $rows = array();
  2103. $list = array();
  2104. foreach ($info_list as $key => $value) {
  2105. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  2106. }
  2107. $rowsdq = array_slice($rows, $start, $perpage);
  2108. foreach ($rowsdq as $value) {
  2109. $warehouse = $this->warehouse->read($value['warehouse']);
  2110. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  2111. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  2112. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2113. $od = array();
  2114. $odid = '';
  2115. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  2116. }
  2117. $total = count($rows);
  2118. $pagenum = ceil($total / $perpage);
  2119. $over = $total - ($start + $perpage);
  2120. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2121. echo json_encode($rows);
  2122. exit;
  2123. }
  2124. $this->_Template('phone/p_usatypeapp', $this->data);
  2125. }
  2126. //入库操作
  2127. public function _enteradd()
  2128. {
  2129. $dt = 0;
  2130. if (isset($_SESSION['api'])) {
  2131. $user = $this->user->get_api($_SESSION['api']);
  2132. $usp = $user;
  2133. $fgshop = "";
  2134. $sid = "";
  2135. $user = explode('|', trim($user['shop'], '|'));
  2136. foreach ($user as $value) {
  2137. $fgshop .= " shop = " . $value . " or";
  2138. $sid .= " id = " . $value . " or";
  2139. }
  2140. }
  2141. $tc = $this->typeclass->find_all();
  2142. $typeclass = array();
  2143. foreach ($tc as $v) {
  2144. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  2145. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  2146. }
  2147. $post = $this->input->post(NULL, TRUE);
  2148. if (isset($post['sku'])) {
  2149. $list = array();
  2150. $num = "";
  2151. $title = "";
  2152. $features = "";
  2153. $order = $this->input->post('order', true);
  2154. $shop = $this->input->post('shop', true);
  2155. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2156. $sku = $this->input->post('sku', true);
  2157. $post['sm'] = $this->input->post('sm', true);
  2158. $post['warehouse'] = $this->input->post('warehouse', true);
  2159. $post['purchase'] = $this->input->post('purchase', true);
  2160. $post['retreatwarehouse'] = $post['warehouse'];
  2161. $post['state'] = $this->input->post('state', true);
  2162. $post['rktype'] = $this->input->post('rktype', true);
  2163. $post['text'] = $this->input->post('text', true);
  2164. $category = $this->input->post('category', true);
  2165. $list['category'] = $category;
  2166. $list['hairtype'] = $this->input->post('hairtype', true);
  2167. $list['grade'] = $this->input->post('grade', true);
  2168. $size = $this->input->post('size', true);
  2169. $xzsku = $this->input->post('xzsku', true);
  2170. $list['size'] = rtrim($size, ',');
  2171. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2172. $list['extension'] = $this->input->post('extension', true);
  2173. if ($category == 1297) {
  2174. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2175. }
  2176. if ($category == 1702) {
  2177. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2178. $list['syother'] = $this->input->post('syother', true);
  2179. }
  2180. if ($category == 133) {
  2181. $list['fittype'] = $this->input->post('fittype', true);
  2182. $list['acother'] = $this->input->post('acother', true);
  2183. }
  2184. $list['color'] = $this->input->post('color', true);
  2185. $list['lowe'] = $this->input->post('lowe', true);
  2186. if (!$post['purchase']) {
  2187. $post['purchase'] = 1;
  2188. }
  2189. if ($category == 127) {
  2190. $list['type'] = $this->input->post('type', true);
  2191. $list['headroad'] = $this->input->post('headroad', true);
  2192. $list['density'] = $this->input->post('density', true);
  2193. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2194. $list['lacesize'] = $this->input->post('lacesize', true);
  2195. }
  2196. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2197. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2198. }
  2199. if ($category == 128) {
  2200. $list['lacetype'] = $this->input->post('lacetype', true);
  2201. $list['haircap'] = $this->input->post('haircap', true);
  2202. $list['density'] = $this->input->post('density', true);
  2203. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2204. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2205. $list['wigother'] = $this->input->post('wigother', true);
  2206. $list['wigother1'] = $this->input->post('wigother1', true);
  2207. $list['wigother2'] = $this->input->post('wigother2', true);
  2208. $list['product_related'] = $this->input->post('product_related', true);
  2209. }
  2210. if ($category == 129) {
  2211. $list['wide'] = $this->input->post('wide', true);
  2212. }
  2213. if ($category == 131) {
  2214. $list['gifttype'] = $this->input->post('gifttype', true);
  2215. $list['giftother'] = $this->input->post('giftother', true);
  2216. }
  2217. if ($category == 134) {
  2218. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2219. }
  2220. if ($category == 1297) {
  2221. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2222. $list['sywigother'] = $this->input->post('sywigother', true);
  2223. }
  2224. if ($category == 130 || $category == 133 || $category == 1702) {
  2225. $list['items'] = $this->input->post('items', true);
  2226. $list['weight'] = $this->input->post('weight', true);
  2227. }
  2228. if($category == 130){
  2229. $list['jfother'] = $this->input->post('jfother', true);
  2230. }
  2231. if ($category == 1702) {
  2232. $list['syhairther'] = $this->input->post('syhairther', true);
  2233. }
  2234. $classid = $this->classid->sku();
  2235. $scsku = $classid;
  2236. $pm = $classid;
  2237. foreach ($list as $k => $v) {
  2238. if ($v != 0) {
  2239. $num .= $v;
  2240. $features .= $v . '-';
  2241. $post[$k] = $v;
  2242. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2243. if ($k != 'size') {
  2244. $title .= $typeclass[$v]['title'] . " ";
  2245. }
  2246. if (isset($pm[$typeclass[$v]['classid']])) {
  2247. if ($typeclass[$v]['title'] == '9A') {
  2248. $pm[$typeclass[$v]['classid']] = '9A';
  2249. } else if ($typeclass[$v]['title'] == '10A') {
  2250. $pm[$typeclass[$v]['classid']] = '10A';
  2251. } else {
  2252. $clzh = $typeclass[$v]['zh'];
  2253. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2254. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2255. $clzh = $clzh[0];
  2256. }
  2257. $pm[$typeclass[$v]['classid']] = $clzh;
  2258. }
  2259. }
  2260. }
  2261. }
  2262. $zh = implode(" ", $pm);
  2263. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2264. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2265. if ($list['size']) {
  2266. $typeclass = $this->typeclass->read($list['size']);
  2267. $title .= $typeclass['title'];
  2268. }
  2269. $time = time();
  2270. if ($xzsku) {
  2271. $scsku = implode("-", $scsku);
  2272. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2273. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2274. $post['sku'] = trim($scsku, ' ');
  2275. } else {
  2276. $post['sku'] = $sku;
  2277. }
  2278. //$post['sku'] = trim($sku,' ');
  2279. $post['title'] = rtrim($title, ' ');
  2280. $post['number'] = $num;
  2281. $post['features'] = '-' . $features;
  2282. $post['enter'] = $time;
  2283. $post['time'] = $time; //操作时间
  2284. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2285. if ($yza) {
  2286. if ($post['features'] != $yza[0]['features']) {
  2287. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2288. exit;
  2289. }
  2290. }
  2291. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2292. if ($yzb) {
  2293. if ($post['sku'] != $yzb[0]['sku']) {
  2294. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2295. exit;
  2296. }
  2297. }
  2298. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2299. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2300. exit;
  2301. }
  2302. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2303. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2304. exit;
  2305. }
  2306. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2307. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2308. exit;
  2309. }
  2310. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2311. if (isset($yz[0]['type'])) {
  2312. $post['type'] = $yz[0]['type'];
  2313. }
  2314. if ($post['state'] == 9) //如果选择预设库存
  2315. {
  2316. $this->whlabel->insert($post);
  2317. } else {
  2318. /**
  2319. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2320. if($ljg == 1)
  2321. {
  2322. for($i=0;$i<$order;$i++)
  2323. {
  2324. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2325. $this->whlabel->insert($post);
  2326. }
  2327. }
  2328. **/
  2329. //if($post['warehouse'] == '5')
  2330. //{
  2331. //}
  2332. $yydata = $post;
  2333. $yydata['zh'] = $zh;
  2334. /**
  2335. $wl = $this->apiyy->get_cjlp($yydata);
  2336. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2337. {
  2338. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2339. }
  2340. if($wl['Data'][0]['m_isSucess'] != 1)
  2341. {
  2342. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2343. }
  2344. **/
  2345. for ($i = 0; $i < $order; $i++) {
  2346. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2347. $this->whlabel->insert($post);
  2348. }
  2349. }
  2350. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2351. exit;
  2352. }
  2353. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2354. $this->data['wlshop'] = $wlshop;
  2355. $this->_Template('whlabel_enteradd', $this->data);
  2356. }
  2357. //修改产品
  2358. public function _enteredit($arg_array)
  2359. {
  2360. $dt = 0;
  2361. if (isset($_SESSION['api'])) {
  2362. $user = $this->user->get_api($_SESSION['api']);
  2363. $usp = $user;
  2364. $fgshop = "";
  2365. $sid = "";
  2366. $user = explode('|', trim($user['shop'], '|'));
  2367. foreach ($user as $value) {
  2368. $fgshop .= " shop = " . $value . " or";
  2369. $sid .= " id = " . $value . " or";
  2370. }
  2371. }
  2372. $post = $this->input->post(NULL, TRUE);
  2373. if (isset($post['sku'])) {
  2374. $list = array();
  2375. $num = "";
  2376. $title = "";
  2377. $features = "";
  2378. $id = $this->input->post('id', true);
  2379. $order = $this->input->post('order', true);
  2380. $shop = $this->input->post('shop', true);
  2381. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2382. $post['sku'] = $this->input->post('sku', true);
  2383. $post['sm'] = $this->input->post('sm', true);
  2384. $post['warehouse'] = $this->input->post('warehouse', true);
  2385. $post['purchase'] = $this->input->post('purchase', true);
  2386. $post['retreatwarehouse'] = $post['warehouse'];
  2387. $category = $this->input->post('category', true);
  2388. $list['category'] = $category;
  2389. $list['hairtype'] = $this->input->post('hairtype', true);
  2390. $list['grade'] = $this->input->post('grade', true);
  2391. $size = $this->input->post('size', true);
  2392. $list['size'] = rtrim($size, ',');
  2393. $post['rktype'] = $this->input->post('rktype', true);
  2394. $post['text'] = $this->input->post('text', true);
  2395. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2396. $list['extension'] = $this->input->post('extension', true);
  2397. if ($category == 1297) {
  2398. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2399. }
  2400. if ($category == 1702) {
  2401. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2402. $list['syother'] = $this->input->post('syother', true);
  2403. }
  2404. if ($category == 133) {
  2405. $list['fittype'] = $this->input->post('fittype', true);
  2406. $list['acother'] = $this->input->post('acother', true);
  2407. }
  2408. $list['color'] = $this->input->post('color', true);
  2409. $list['lowe'] = $this->input->post('lowe', true);
  2410. if (!$post['purchase']) {
  2411. $post['purchase'] = 1;
  2412. }
  2413. if ($category == 127) {
  2414. $list['type'] = $this->input->post('type', true);
  2415. $list['headroad'] = $this->input->post('headroad', true);
  2416. $list['density'] = $this->input->post('density', true);
  2417. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2418. $list['lacesize'] = $this->input->post('lacesize', true);
  2419. }
  2420. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2421. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2422. }
  2423. if ($category == 128) {
  2424. $list['lacetype'] = $this->input->post('lacetype', true);
  2425. $list['haircap'] = $this->input->post('haircap', true);
  2426. $list['density'] = $this->input->post('density', true);
  2427. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2428. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2429. $list['wigother'] = $this->input->post('wigother', true);
  2430. $list['wigother1'] = $this->input->post('wigother1', true);
  2431. $list['wigother2'] = $this->input->post('wigother2', true);
  2432. $list['product_related'] = $this->input->post('product_related', true);
  2433. }
  2434. if ($category == 129) {
  2435. $list['wide'] = $this->input->post('wide', true);
  2436. }
  2437. if ($category == 131) {
  2438. $list['gifttype'] = $this->input->post('gifttype', true);
  2439. $list['giftother'] = $this->input->post('giftother', true);
  2440. }
  2441. if ($category == 134) {
  2442. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2443. }
  2444. if ($category == 1297) {
  2445. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2446. $list['sywigother'] = $this->input->post('sywigother', true);
  2447. }
  2448. if ($category == 130 || $category == 133 || $category == 1702) {
  2449. $list['items'] = $this->input->post('items', true);
  2450. $list['weight'] = $this->input->post('weight', true);
  2451. }
  2452. if($category == 130){
  2453. $list['jfother'] = $this->input->post('jfother', true);
  2454. }
  2455. if ($category == 1702) {
  2456. $list['syhairther'] = $this->input->post('syhairther', true);
  2457. }
  2458. foreach ($list as $k => $v) {
  2459. if ($v != 0) {
  2460. $num .= $v;
  2461. $features .= $v . '-';
  2462. $typeclass = $this->typeclass->read($v);
  2463. if ($k != 'size') {
  2464. $title .= $typeclass['title'] . " ";
  2465. }
  2466. }
  2467. }
  2468. $typeclass = $this->typeclass->read($list['size']);
  2469. $title .= $typeclass['title'];
  2470. $time = time();
  2471. $post['title'] = rtrim($title, ' ');
  2472. $post['number'] = $num;
  2473. $post['features'] = '-' . $features;
  2474. $post['time'] = $time; //操作时间
  2475. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2476. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2477. exit;
  2478. }
  2479. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2480. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2481. exit;
  2482. }
  2483. $uid = $this->whlabel->read($id);
  2484. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2485. if ($datanum > 0) {
  2486. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2487. exit;
  2488. }
  2489. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2490. {
  2491. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2492. if ($yza) {
  2493. if ($post['features'] != $yza[0]['features']) {
  2494. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2495. exit;
  2496. }
  2497. }
  2498. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2499. if ($yzb) {
  2500. if ($post['sku'] != $yzb[0]['sku']) {
  2501. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2502. exit;
  2503. }
  2504. }
  2505. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2506. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2507. exit;
  2508. }
  2509. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2510. foreach ($data as $v) {
  2511. $post['id'] = $v['id'];
  2512. $this->whlabel->save($post, $v['id']);
  2513. }
  2514. } else {
  2515. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2516. if ($data > 0) {
  2517. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2518. exit;
  2519. } else {
  2520. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2521. foreach ($data as $v) {
  2522. $post['id'] = $v['id'];
  2523. $this->whlabel->save($post, $v['id']);
  2524. }
  2525. }
  2526. }
  2527. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2528. exit;
  2529. }
  2530. $uid = $this->whlabel->read($arg_array[0]);
  2531. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2532. $this->data['enter'] = $uid;
  2533. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2534. $this->data['wlshop'] = $wlshop;
  2535. $this->_Template('whlabel_enteredit', $this->data);
  2536. }
  2537. //入库浏览
  2538. public function _enter()
  2539. {
  2540. $post = $this->input->post(NULL, TRUE);
  2541. if (isset($post['s'])) {
  2542. $id_arr = $this->input->post('s');
  2543. $id_arr = explode(',', $id_arr);
  2544. if (!$id_arr) {
  2545. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2546. exit;
  2547. }
  2548. //循环删除记录
  2549. foreach ($id_arr as $v) {
  2550. $sid = $this->whlabel->read($v);
  2551. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2552. if ($count > 0) {
  2553. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2554. exit;
  2555. }
  2556. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2557. foreach ($info_list as $va) {
  2558. $this->whlabel->remove($va['id']);
  2559. }
  2560. }
  2561. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2562. exit;
  2563. }
  2564. $sp = array();
  2565. $s = $this->shop->find_all('1=1', 'id,shopname');
  2566. foreach ($s as $v) {
  2567. $sp[$v['id']] = $v['shopname'];
  2568. }
  2569. $wh = array();
  2570. $w = $this->warehouse->find_all('1=1', 'id,title');
  2571. foreach ($w as $v) {
  2572. $wh[$v['id']] = $v['title'];
  2573. }
  2574. if (isset($post['page'])) {
  2575. $page = $this->input->post('page', true);
  2576. $perpage = $this->input->post('perpage', true);
  2577. $category = $this->input->post('category', true);
  2578. $size = $this->input->post('size', true);
  2579. $grade = $this->input->post('grade', true);
  2580. $color = $this->input->post('color', true);
  2581. $lowe = $this->input->post('lowe', true);
  2582. $sku = $this->input->post('sku', true);
  2583. $warehouse = $this->input->post('warehouse', true);
  2584. $purchase = $this->input->post('purchase', true);
  2585. $ktime = $this->input->post('ktime', true);
  2586. $jtime = $this->input->post('jtime', true);
  2587. $ktime = strtotime($ktime);
  2588. $jtime = strtotime($jtime);
  2589. $where = "1=1";
  2590. $gj = "";
  2591. $ck = "";
  2592. if ($category) {
  2593. $where .= " and features like '%-$category-%'";
  2594. }
  2595. if ($size) {
  2596. $where .= " and features like '%-$size-%'";
  2597. }
  2598. if ($grade) {
  2599. $where .= " and features like '%-$grade-%'";
  2600. }
  2601. if ($color) {
  2602. $where .= " and features like '%-$color-%'";
  2603. }
  2604. if ($lowe) {
  2605. $where .= " and features like '%-$lowe-%'";
  2606. }
  2607. if ($warehouse) {
  2608. $where .= " and warehouse = '$warehouse'";
  2609. }
  2610. if ($purchase) {
  2611. $where .= " and purchase = '$purchase'";
  2612. }
  2613. if ($sku) {
  2614. $where .= " and sku like '%$sku%'";
  2615. }
  2616. if ($ktime && $jtime) {
  2617. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2618. }
  2619. //数据排序
  2620. $order_str = "enter desc";
  2621. if (empty($page)) {
  2622. $start = 0;
  2623. $perpage = 1;
  2624. } else {
  2625. $start = ($page - 1) * $perpage;
  2626. }
  2627. //取得信息列表
  2628. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2629. foreach ($info_list as $k => $v) {
  2630. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2631. if ($v['shop'] == '') {
  2632. $s = '通用';
  2633. } else {
  2634. $info_list[$k]['shop'] = '';
  2635. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2636. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2637. }
  2638. }
  2639. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2640. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2641. $info_list[$k]['g'] = $g;
  2642. }
  2643. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2644. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2645. $pagenum = ceil($total / $perpage);
  2646. $over = $total - ($start + $perpage);
  2647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2648. echo json_encode($rows);
  2649. exit;
  2650. }
  2651. $this->_Template('whlabel_enter', $this->data);
  2652. }
  2653. //出库浏览
  2654. public function _out()
  2655. {
  2656. $post = $this->input->post(NULL, TRUE);
  2657. if (isset($post['page'])) {
  2658. $page = $this->input->post('page', true);
  2659. $perpage = $this->input->post('perpage', true);
  2660. $category = $this->input->post('category', true);
  2661. $size = $this->input->post('size', true);
  2662. $grade = $this->input->post('grade', true);
  2663. $color = $this->input->post('color', true);
  2664. $lowe = $this->input->post('lowe', true);
  2665. $sku = $this->input->post('sku', true);
  2666. $warehouse = $this->input->post('warehouse', true);
  2667. $purchase = $this->input->post('purchase', true);
  2668. $state = $this->input->post('state', true);
  2669. $ktime = $this->input->post('ktime', true);
  2670. $jtime = $this->input->post('jtime', true);
  2671. $ktime = strtotime($ktime);
  2672. $jtime = strtotime($jtime);
  2673. $where = "state=3";
  2674. $gj = "";
  2675. $ck = "";
  2676. if ($category) {
  2677. $where .= " and features like '%-$category-%'";
  2678. }
  2679. if ($size) {
  2680. $where .= " and features like '%-$size-%'";
  2681. }
  2682. if ($grade) {
  2683. $where .= " and features like '%-$grade-%'";
  2684. }
  2685. if ($color) {
  2686. $where .= " and features like '%-$color-%'";
  2687. }
  2688. if ($lowe) {
  2689. $where .= " and features like '%-$lowe-%'";
  2690. }
  2691. if ($state) {
  2692. $where .= " and state = '$state'";
  2693. }
  2694. if ($warehouse) {
  2695. $where .= " and warehouse = '$warehouse'";
  2696. }
  2697. if ($purchase) {
  2698. $where .= " and purchase = '$purchase'";
  2699. }
  2700. if ($sku) {
  2701. $where .= " and sku = '$sku'";
  2702. }
  2703. if ($ktime && $jtime) {
  2704. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2705. }
  2706. //数据排序
  2707. $order_str = "id desc";
  2708. if (empty($page)) {
  2709. $start = 0;
  2710. $perpage = 1;
  2711. } else {
  2712. $start = ($page - 1) * $perpage;
  2713. }
  2714. //取得信息列表
  2715. $info_list = $this->whlabel->find_all($where, 'sku');
  2716. $rows = array();
  2717. $list = array();
  2718. foreach ($info_list as $key => $value) {
  2719. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2720. }
  2721. $rows = array_unique($rows); //删除重复记录
  2722. foreach ($rows as $key => $value) {
  2723. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2724. $ck = $this->warehouse->read($data['warehouse']);
  2725. $warehouse = $ck['title'];
  2726. $gy = $this->purchase->read($data['purchase']);
  2727. $purchase = $gy['purchase'];
  2728. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2729. $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);
  2730. }
  2731. $total = count($list);
  2732. $pagenum = ceil($total / $perpage);
  2733. $over = $total - ($start + $perpage);
  2734. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2735. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2736. echo json_encode($rows);
  2737. exit;
  2738. }
  2739. $this->_Template('whlabel_out', $this->data);
  2740. }
  2741. //出库标签浏览
  2742. public function _label()
  2743. {
  2744. $post = $this->input->post(NULL, TRUE);
  2745. if (isset($post['page'])) {
  2746. $page = $this->input->post('page', true);
  2747. $perpage = $this->input->post('perpage', true);
  2748. $sku = $this->input->post('sku', true);
  2749. $warehouse = $this->input->post('warehouse', true);
  2750. $purchase = $this->input->post('purchase', true);
  2751. $orderinfo = $this->input->post('orderinfo', true);
  2752. $waybill = $this->input->post('waybill', true);
  2753. $category = $this->input->post('category', true);
  2754. $size = $this->input->post('size', true);
  2755. $grade = $this->input->post('grade', true);
  2756. $color = $this->input->post('color', true);
  2757. $lowe = $this->input->post('lowe', true);
  2758. $where = "state=1";
  2759. if ($sku) {
  2760. $where .= " and sku = '$sku'";
  2761. }
  2762. if ($warehouse) {
  2763. $where .= " and warehouse = '$warehouse'";
  2764. }
  2765. if ($purchase) {
  2766. $where .= " and purchase = '$purchase'";
  2767. }
  2768. if ($orderinfo) {
  2769. $where .= " and orderinfo = '$orderinfo'";
  2770. }
  2771. if ($waybill) {
  2772. $where .= " and waybill = '$waybill'";
  2773. }
  2774. if ($category) {
  2775. $where .= " and features like '%-$category-%'";
  2776. }
  2777. if ($size) {
  2778. $where .= " and features like '%-$size-%'";
  2779. }
  2780. if ($grade) {
  2781. $where .= " and features like '%-$grade-%'";
  2782. }
  2783. if ($color) {
  2784. $where .= " and features like '%-$color-%'";
  2785. }
  2786. if ($lowe) {
  2787. $where .= " and features like '%-$lowe-%'";
  2788. }
  2789. //数据排序
  2790. $order_str = "outk desc";
  2791. if (empty($page)) {
  2792. $start = 0;
  2793. $perpage = 1;
  2794. } else {
  2795. $start = ($page - 1) * $perpage;
  2796. }
  2797. //取得信息列表
  2798. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2799. foreach ($info_list as $key => $value) {
  2800. $warehouse = $this->warehouse->read($value['warehouse']);
  2801. $info_list[$key]['warehouse'] = $warehouse['title'];
  2802. $purchase = $this->purchase->read($value['purchase']);
  2803. $info_list[$key]['purchase'] = $purchase['title'];
  2804. if ($value['outk'] != 0) {
  2805. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2806. } else {
  2807. $info_list[$key]['outk'] = "";
  2808. }
  2809. if ($value['orderinfo'] == 0) {
  2810. $info_list[$key]['orderinfo'] = "";
  2811. }
  2812. if ($value['waybill'] == 0) {
  2813. $info_list[$key]['waybill'] = "";
  2814. }
  2815. }
  2816. $total = $this->whlabel->find_count($where);
  2817. $pagenum = ceil($total / $perpage);
  2818. $over = $total - ($start + $perpage);
  2819. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2820. echo json_encode($rows);
  2821. exit;
  2822. }
  2823. $this->_Template('whlabel_label', $this->data);
  2824. }
  2825. //独立站出库订单
  2826. public function _outorder()
  2827. {
  2828. if (isset($_SESSION['api'])) {
  2829. $user = $this->user->get_api($_SESSION['api']);
  2830. $usp = $user;
  2831. $fgshop = "";
  2832. $sid = "";
  2833. $user = explode('|', trim($user['shop'], '|'));
  2834. foreach ($user as $value) {
  2835. $fgshop .= " shop = " . $value . " or";
  2836. $sid .= " id = " . $value . " or";
  2837. }
  2838. } else {
  2839. echo "请重新登录";
  2840. }
  2841. $post = $this->input->post(NULL, TRUE);
  2842. if (isset($post['page'])) {
  2843. $page = $this->input->post('page', true);
  2844. $perpage = $this->input->post('perpage', true);
  2845. $warehouse = $this->input->post('warehouse', true);
  2846. $xztime = $this->input->post('xztime', true);
  2847. $timetk = $this->input->post('timetkk', true);
  2848. $timetj = $this->input->post('timetjj', true);
  2849. $shop = $this->input->post('shop', true);
  2850. $source = $this->input->post('source', true);
  2851. $orderinfo = $this->input->post('orderinfo', true);
  2852. $number = $this->input->post('number', true);
  2853. $sfxh = $this->input->post('sfxh', true);
  2854. $express = $this->input->post('express', true);
  2855. $waybill = $this->input->post('waybill', true);
  2856. $library = $this->input->post('library', true);
  2857. $country = $this->input->post('country', true);
  2858. $so = $this->input->post('so', true);
  2859. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2860. $print = $this->input->post('print', true);
  2861. $state = $this->input->post('state', true);
  2862. $orderurl = $this->input->post('orderurl', true);
  2863. $productid = $this->input->post('productid', true);
  2864. $timetk = strtotime($timetk);
  2865. $timetj = strtotime($timetj);
  2866. /**
  2867. $sj = $this->input->post('sj',true);
  2868. if($sj)
  2869. {
  2870. $sj = $this->input->post('sj',true);
  2871. }
  2872. else
  2873. {
  2874. $sj = "fullorder";
  2875. }
  2876. **/
  2877. $sj = "fullorder";
  2878. $where = "1=1";
  2879. if ($warehouse) {
  2880. $where .= " and type = '$warehouse'";
  2881. }
  2882. if ($timetk && $timetj) {
  2883. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2884. }
  2885. if ($orderinfo) {
  2886. $where .= " and orderinfo = '$orderinfo'";
  2887. }
  2888. if ($number) {
  2889. $where .= " and number = '$number'";
  2890. }
  2891. if ($express) {
  2892. $where .= " and express = '$express'";
  2893. }
  2894. if ($waybill) {
  2895. $where .= " and waybill = '$waybill'";
  2896. }
  2897. if ($library) {
  2898. $where .= " and library = '$library'";
  2899. }
  2900. if ($print) {
  2901. $where .= " and print = '$print'";
  2902. }
  2903. if ($libraryconfirm) {
  2904. $where .= " and libraryconfirm = '$libraryconfirm'";
  2905. }
  2906. if ($state) {
  2907. $where .= " and state = '$state'";
  2908. }
  2909. if ($shop) {
  2910. $where .= " and shop = '$shop'";
  2911. }
  2912. if ($country) {
  2913. $where .= " and country = '$country'";
  2914. }
  2915. if ($sfxh != '') {
  2916. $where .= " and sfxh = '$sfxh'";
  2917. }
  2918. if ($so) {
  2919. $where .= " and shipremarks like '%$so%'";
  2920. }
  2921. if ($source) {
  2922. if ($source == '2d') {
  2923. $where .= " and source >= '2'";
  2924. } else {
  2925. $where .= " and source = '$source'";
  2926. }
  2927. }
  2928. if (isset($_SESSION['api'])) {
  2929. foreach ($user as $value) {
  2930. $fgshop .= " shop = " . $value . " or";
  2931. }
  2932. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2933. }
  2934. if ($orderurl) {
  2935. $url = $this->orderurl->read($orderurl);
  2936. $where .= " and link like '%" . $url['url'] . "%'";
  2937. }
  2938. if($productid){
  2939. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2940. }
  2941. //数据排序
  2942. $order_str = "librarytime desc";
  2943. if (empty($page)) {
  2944. $start = 0;
  2945. $perpage = 1;
  2946. } else {
  2947. $start = ($page - 1) * $perpage;
  2948. }
  2949. //取得信息列表
  2950. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2951. //格式化数据
  2952. foreach ($info_list as $key => $value) {
  2953. $shop = $this->shop->read($value['shop']);
  2954. $info_list[$key]['shop'] = $shop['shopname'];
  2955. $express = $this->express->read($value['express']);
  2956. $info_list[$key]['express'] = $express['servicename'];
  2957. $warehouse = $this->warehouse->read($value['type']);
  2958. $info_list[$key]['type'] = $warehouse['title'];
  2959. if ($value['librarytime'] == '0') {
  2960. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2961. } else {
  2962. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2963. }
  2964. }
  2965. $total = $this->$sj->find_count($where);
  2966. $pagenum = ceil($total / $perpage);
  2967. $over = $total - ($start + $perpage);
  2968. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2969. echo json_encode($rows);
  2970. exit;
  2971. }
  2972. $this->data['express'] = $this->express->find_all();
  2973. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2974. $this->data['wlshop'] = $wlshop;
  2975. $user = $this->user->get_api($_SESSION['api']);
  2976. $powerid = $this->power->read($user['power']);
  2977. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2978. $pid = '';
  2979. foreach ($powertext as $v) {
  2980. $pid .= " id = " . $v . " or";
  2981. }
  2982. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2983. $this->data['fullorderexcel'] = $fullorderexcel;
  2984. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2985. $this->data['orderurl'] = $orderurl;
  2986. $this->_Template('whlabel_outorder', $this->data);
  2987. }
  2988. //tt出库
  2989. public function _toutorder()
  2990. {
  2991. $fgshop = "";
  2992. $sid = "";
  2993. if (isset($_SESSION['api'])) {
  2994. $user = $this->user->get_api($_SESSION['api']);
  2995. $usp = $user;
  2996. $user = explode('|', trim($user['shop'], '|'));
  2997. foreach ($user as $value) {
  2998. $fgshop .= " shop = " . $value . " or";
  2999. $sid .= " id = " . $value . " or";
  3000. }
  3001. } else {
  3002. echo "请重新登录";
  3003. die;
  3004. }
  3005. $post = $this->input->post(NULL, TRUE);
  3006. if (isset($post['page'])) {
  3007. $page = $this->input->post('page', true);
  3008. $perpage = $this->input->post('perpage', true);
  3009. $warehouse = $this->input->post('warehouse', true);
  3010. $xztime = $this->input->post('xztime', true);
  3011. $timetk = $this->input->post('timetkk', true);
  3012. $timetj = $this->input->post('timetjj', true);
  3013. $shop = $this->input->post('shop', true);
  3014. $source = $this->input->post('source', true);
  3015. $orderinfo = $this->input->post('orderinfo', true);
  3016. $number = $this->input->post('number', true);
  3017. $sfxh = $this->input->post('sfxh', true);
  3018. $express = $this->input->post('express', true);
  3019. $waybill = $this->input->post('waybill', true);
  3020. $library = $this->input->post('library', true);
  3021. $country = $this->input->post('country', true);
  3022. $so = $this->input->post('so', true);
  3023. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3024. $print = $this->input->post('print', true);
  3025. $state = $this->input->post('state', true);
  3026. $orderurl = $this->input->post('orderurl', true);
  3027. $timetk = strtotime($timetk);
  3028. $timetj = strtotime($timetj);
  3029. /**
  3030. $sj = $this->input->post('sj',true);
  3031. if($sj)
  3032. {
  3033. $sj = $this->input->post('sj',true);
  3034. }
  3035. else
  3036. {
  3037. $sj = "fullorder";
  3038. }
  3039. **/
  3040. $sj = "fullordertt";
  3041. $where = "1=1";
  3042. if ($warehouse) {
  3043. $where .= " and type = '$warehouse'";
  3044. }
  3045. if ($timetk && $timetj) {
  3046. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3047. }
  3048. if ($orderinfo) {
  3049. $where .= " and orderinfo = '$orderinfo'";
  3050. }
  3051. if ($number) {
  3052. $where .= " and number = '$number'";
  3053. }
  3054. if ($express) {
  3055. $where .= " and express = '$express'";
  3056. }
  3057. if ($waybill) {
  3058. $where .= " and waybill = '$waybill'";
  3059. }
  3060. if ($library) {
  3061. $where .= " and library = '$library'";
  3062. }
  3063. if ($print) {
  3064. $where .= " and print = '$print'";
  3065. }
  3066. if ($libraryconfirm) {
  3067. $where .= " and libraryconfirm = '$libraryconfirm'";
  3068. }
  3069. if ($state) {
  3070. $where .= " and state = '$state'";
  3071. }
  3072. if ($shop) {
  3073. $where .= " and shop = '$shop'";
  3074. }
  3075. if ($country) {
  3076. $where .= " and country = '$country'";
  3077. }
  3078. if ($sfxh != '') {
  3079. $where .= " and sfxh = '$sfxh'";
  3080. }
  3081. if ($so) {
  3082. $where .= " and shipremarks like '%$so%'";
  3083. }
  3084. if ($source) {
  3085. if ($source == '2d') {
  3086. $where .= " and source >= '2'";
  3087. } else {
  3088. $where .= " and source = '$source'";
  3089. }
  3090. }
  3091. if (isset($_SESSION['api'])) {
  3092. foreach ($user as $value) {
  3093. $fgshop .= " shop = " . $value . " or";
  3094. }
  3095. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3096. }
  3097. if ($orderurl) {
  3098. $url = $this->orderurl->read($orderurl);
  3099. $where .= " and link like '%" . $url['url'] . "%'";
  3100. }
  3101. //数据排序
  3102. $order_str = "librarytime desc";
  3103. if (empty($page)) {
  3104. $start = 0;
  3105. $perpage = 1;
  3106. } else {
  3107. $start = ($page - 1) * $perpage;
  3108. }
  3109. //取得信息列表
  3110. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3111. //格式化数据
  3112. foreach ($info_list as $key => $value) {
  3113. $shop = $this->shop->read($value['shop']);
  3114. $info_list[$key]['shop'] = $shop['shopname'];
  3115. $express = $this->express->read($value['express']);
  3116. $info_list[$key]['express'] = $express['servicename'];
  3117. $warehouse = $this->warehouse->read($value['type']);
  3118. $info_list[$key]['type'] = $warehouse['title'];
  3119. if ($value['librarytime'] == '0') {
  3120. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3121. } else {
  3122. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3123. }
  3124. }
  3125. $total = $this->$sj->find_count($where);
  3126. $pagenum = ceil($total / $perpage);
  3127. $over = $total - ($start + $perpage);
  3128. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3129. echo json_encode($rows);
  3130. exit;
  3131. }
  3132. $this->data['express'] = $this->express->find_all();
  3133. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3134. $this->data['wlshop'] = $wlshop;
  3135. $user = $this->user->get_api($_SESSION['api']);
  3136. $powerid = $this->power->read($user['power']);
  3137. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3138. $pid = '';
  3139. foreach ($powertext as $v) {
  3140. $pid .= " id = " . $v . " or";
  3141. }
  3142. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3143. $this->data['fullorderexcel'] = $fullorderexcel;
  3144. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3145. $this->data['orderurl'] = $orderurl;
  3146. $this->_Template('whlabel_toutorder', $this->data);
  3147. }
  3148. //tt出库
  3149. public function _aoutorder()
  3150. {
  3151. if (isset($_SESSION['api'])) {
  3152. $user = $this->user->get_api($_SESSION['api']);
  3153. $usp = $user;
  3154. $fgshop = "";
  3155. $sid = "";
  3156. $user = explode('|', trim($user['shop'], '|'));
  3157. foreach ($user as $value) {
  3158. $fgshop .= " shop = " . $value . " or";
  3159. $sid .= " id = " . $value . " or";
  3160. }
  3161. } else {
  3162. echo "请重新登录";
  3163. }
  3164. $post = $this->input->post(NULL, TRUE);
  3165. if (isset($post['page'])) {
  3166. $page = $this->input->post('page', true);
  3167. $perpage = $this->input->post('perpage', true);
  3168. $warehouse = $this->input->post('warehouse', true);
  3169. $xztime = $this->input->post('xztime', true);
  3170. $timetk = $this->input->post('timetkk', true);
  3171. $timetj = $this->input->post('timetjj', true);
  3172. $shop = $this->input->post('shop', true);
  3173. $source = $this->input->post('source', true);
  3174. $orderinfo = $this->input->post('orderinfo', true);
  3175. $number = $this->input->post('number', true);
  3176. $sfxh = $this->input->post('sfxh', true);
  3177. $express = $this->input->post('express', true);
  3178. $waybill = $this->input->post('waybill', true);
  3179. $library = $this->input->post('library', true);
  3180. $country = $this->input->post('country', true);
  3181. $so = $this->input->post('so', true);
  3182. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3183. $print = $this->input->post('print', true);
  3184. $state = $this->input->post('state', true);
  3185. $orderurl = $this->input->post('orderurl', true);
  3186. $timetk = strtotime($timetk);
  3187. $timetj = strtotime($timetj);
  3188. /**
  3189. $sj = $this->input->post('sj',true);
  3190. if($sj)
  3191. {
  3192. $sj = $this->input->post('sj',true);
  3193. }
  3194. else
  3195. {
  3196. $sj = "fullorder";
  3197. }
  3198. **/
  3199. $sj = "fullorderamz";
  3200. $where = "1=1";
  3201. if ($warehouse) {
  3202. $where .= " and type = '$warehouse'";
  3203. }
  3204. if ($timetk && $timetj) {
  3205. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3206. }
  3207. if ($orderinfo) {
  3208. $where .= " and orderinfo = '$orderinfo'";
  3209. }
  3210. if ($number) {
  3211. $where .= " and number = '$number'";
  3212. }
  3213. if ($express) {
  3214. $where .= " and express = '$express'";
  3215. }
  3216. if ($waybill) {
  3217. $where .= " and waybill = '$waybill'";
  3218. }
  3219. if ($library) {
  3220. $where .= " and library = '$library'";
  3221. }
  3222. if ($print) {
  3223. $where .= " and print = '$print'";
  3224. }
  3225. if ($libraryconfirm) {
  3226. $where .= " and libraryconfirm = '$libraryconfirm'";
  3227. }
  3228. if ($state) {
  3229. $where .= " and state = '$state'";
  3230. }
  3231. if ($shop) {
  3232. $where .= " and shop = '$shop'";
  3233. }
  3234. if ($country) {
  3235. $where .= " and country = '$country'";
  3236. }
  3237. if ($sfxh != '') {
  3238. $where .= " and sfxh = '$sfxh'";
  3239. }
  3240. if ($so) {
  3241. $where .= " and shipremarks like '%$so%'";
  3242. }
  3243. if ($source) {
  3244. if ($source == '2d') {
  3245. $where .= " and source >= '2'";
  3246. } else {
  3247. $where .= " and source = '$source'";
  3248. }
  3249. }
  3250. if (isset($_SESSION['api'])) {
  3251. foreach ($user as $value) {
  3252. $fgshop .= " shop = " . $value . " or";
  3253. }
  3254. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3255. }
  3256. if ($orderurl) {
  3257. $url = $this->orderurl->read($orderurl);
  3258. $where .= " and link like '%" . $url['url'] . "%'";
  3259. }
  3260. //数据排序
  3261. $order_str = "librarytime desc";
  3262. if (empty($page)) {
  3263. $start = 0;
  3264. $perpage = 1;
  3265. } else {
  3266. $start = ($page - 1) * $perpage;
  3267. }
  3268. //取得信息列表
  3269. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3270. //格式化数据
  3271. foreach ($info_list as $key => $value) {
  3272. $shop = $this->shop->read($value['shop']);
  3273. $info_list[$key]['shop'] = $shop['shopname'];
  3274. $express = $this->express->read($value['express']);
  3275. $info_list[$key]['express'] = $express['servicename'];
  3276. $warehouse = $this->warehouse->read($value['type']);
  3277. $info_list[$key]['type'] = $warehouse['title'];
  3278. if ($value['librarytime'] == '0') {
  3279. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3280. } else {
  3281. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3282. }
  3283. }
  3284. $total = $this->$sj->find_count($where);
  3285. $pagenum = ceil($total / $perpage);
  3286. $over = $total - ($start + $perpage);
  3287. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3288. echo json_encode($rows);
  3289. exit;
  3290. }
  3291. $this->data['express'] = $this->express->find_all();
  3292. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3293. $this->data['wlshop'] = $wlshop;
  3294. $user = $this->user->get_api($_SESSION['api']);
  3295. $powerid = $this->power->read($user['power']);
  3296. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3297. $pid = '';
  3298. foreach ($powertext as $v) {
  3299. $pid .= " id = " . $v . " or";
  3300. }
  3301. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3302. $this->data['fullorderexcel'] = $fullorderexcel;
  3303. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3304. $this->data['orderurl'] = $orderurl;
  3305. $this->_Template('whlabel_aoutorder', $this->data);
  3306. }
  3307. //速卖通出库订单
  3308. public function _soutorder()
  3309. {
  3310. if (isset($_SESSION['api'])) {
  3311. $user = $this->user->get_api($_SESSION['api']);
  3312. $usp = $user;
  3313. $fgshop = "";
  3314. $sid = "";
  3315. $user = explode('|', trim($user['shop'], '|'));
  3316. foreach ($user as $value) {
  3317. $sid .= " id = " . $value . " or";
  3318. }
  3319. }
  3320. $post = $this->input->post(NULL, TRUE);
  3321. if (isset($post['page'])) {
  3322. $page = $this->input->post('page', true);
  3323. $perpage = $this->input->post('perpage', true);
  3324. $warehouse = $this->input->post('warehouse', true);
  3325. $xztime = $this->input->post('xztime', true);
  3326. $timetk = $this->input->post('timetkk', true);
  3327. $timetj = $this->input->post('timetjj', true);
  3328. $shop = $this->input->post('shop', true);
  3329. $source = $this->input->post('source', true);
  3330. $orderinfo = $this->input->post('orderinfo', true);
  3331. $number = $this->input->post('number', true);
  3332. $express = $this->input->post('express', true);
  3333. $waybill = $this->input->post('waybill', true);
  3334. $library = $this->input->post('library', true);
  3335. $country = $this->input->post('country', true);
  3336. $sfxh = $this->input->post('sfxh', true);
  3337. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3338. $print = $this->input->post('print', true);
  3339. $state = $this->input->post('state', true);
  3340. $so = $this->input->post('so', true);
  3341. $timetk = strtotime($timetk);
  3342. $timetj = strtotime($timetj);
  3343. /**
  3344. $sj = $this->input->post('sj',true);
  3345. if($sj)
  3346. {
  3347. $sj = $this->input->post('sj',true);
  3348. }
  3349. else
  3350. {
  3351. $sj = "fullorder";
  3352. }
  3353. **/
  3354. $sj = "fullordersmt";
  3355. $where = "1=1";
  3356. if ($warehouse) {
  3357. $where .= " and type = '$warehouse'";
  3358. }
  3359. if ($timetk && $timetj) {
  3360. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3361. }
  3362. if ($orderinfo) {
  3363. $where .= " and orderinfo = '$orderinfo'";
  3364. }
  3365. if ($number) {
  3366. $where .= " and number = '$number'";
  3367. }
  3368. if ($express) {
  3369. $where .= " and express = '$express'";
  3370. }
  3371. if ($waybill) {
  3372. $where .= " and waybill = '$waybill'";
  3373. }
  3374. if ($library) {
  3375. $where .= " and library = '$library'";
  3376. }
  3377. if ($print) {
  3378. $where .= " and print = '$print'";
  3379. }
  3380. if ($libraryconfirm) {
  3381. $where .= " and libraryconfirm = '$libraryconfirm'";
  3382. }
  3383. if ($state) {
  3384. $where .= " and state = '$state'";
  3385. }
  3386. if ($shop) {
  3387. $where .= " and shop = '$shop'";
  3388. }
  3389. if ($sfxh != '') {
  3390. $where .= " and sfxh = '$sfxh'";
  3391. }
  3392. if ($so) {
  3393. $where .= " and shipremarks like '%$so%'";
  3394. }
  3395. if ($source) {
  3396. $where .= " and source = '$source'";
  3397. }
  3398. if ($country) {
  3399. $where .= " and country = '$country'";
  3400. } else {
  3401. if (isset($_SESSION['api'])) {
  3402. foreach ($user as $value) {
  3403. $fgshop .= " shop = " . $value . " or";
  3404. }
  3405. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3406. }
  3407. }
  3408. //数据排序
  3409. $order_str = "librarytime desc";
  3410. if (empty($page)) {
  3411. $start = 0;
  3412. $perpage = 1;
  3413. } else {
  3414. $start = ($page - 1) * $perpage;
  3415. }
  3416. //取得信息列表
  3417. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3418. //格式化数据
  3419. foreach ($info_list as $key => $value) {
  3420. $shop = $this->shop->read($value['shop']);
  3421. $info_list[$key]['shop'] = $shop['shopname'];
  3422. $express = $this->express->read($value['express']);
  3423. $info_list[$key]['express'] = $express['servicename'];
  3424. $warehouse = $this->warehouse->read($value['type']);
  3425. $info_list[$key]['type'] = $warehouse['title'];
  3426. if ($value['librarytime'] == '0') {
  3427. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3428. } else {
  3429. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3430. }
  3431. }
  3432. $total = $this->$sj->find_count($where);
  3433. $pagenum = ceil($total / $perpage);
  3434. $over = $total - ($start + $perpage);
  3435. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3436. echo json_encode($rows);
  3437. exit;
  3438. }
  3439. $this->data['express'] = $this->express->find_all();
  3440. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3441. $this->data['wlshop'] = $wlshop;
  3442. $user = $this->user->get_api($_SESSION['api']);
  3443. $powerid = $this->power->read($user['power']);
  3444. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3445. $pid = '';
  3446. foreach ($powertext as $v) {
  3447. $pid .= " id = " . $v . " or";
  3448. }
  3449. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3450. $this->data['fullorderexcel'] = $fullorderexcel;
  3451. $this->_Template('whlabel_soutorder', $this->data);
  3452. }
  3453. //订单退库
  3454. public function _retreat()
  3455. {
  3456. $post = $this->input->post(NULL, TRUE);
  3457. if (isset($post['page'])) {
  3458. $page = $this->input->post('page', true);
  3459. $perpage = $this->input->post('perpage', true);
  3460. $warehouse = $this->input->post('warehouse', true);
  3461. $timetk = $this->input->post('timetk', true);
  3462. $timetj = $this->input->post('timetj', true);
  3463. $shop = $this->input->post('shop', true);
  3464. $source = $this->input->post('source', true);
  3465. $state = $this->input->post('state', true);
  3466. $review = $this->input->post('review', true);
  3467. $state = $this->input->post('state', true);
  3468. $express = $this->input->post('express', true);
  3469. $orderinfo = $this->input->post('orderinfo', true);
  3470. $user = $this->input->post('user', true);
  3471. $name = $this->input->post('name', true);
  3472. $waybill = $this->input->post('waybill', true);
  3473. $timetk = strtotime($timetk);
  3474. $timetj = strtotime($timetj);
  3475. $where = "(state=206 or state=210) and mergeid = 0";
  3476. if ($warehouse) {
  3477. $where .= " and state = '$warehouse'";
  3478. }
  3479. if ($timetk && $timetj) {
  3480. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3481. }
  3482. if ($shop) {
  3483. $where .= " and shop = '$shop'";
  3484. }
  3485. if ($source) {
  3486. $where .= " and source = '$source'";
  3487. }
  3488. if ($state) {
  3489. $where .= " and state = '$state'";
  3490. }
  3491. if ($review) {
  3492. $where .= " and review = '$review'";
  3493. }
  3494. if ($state) {
  3495. $where .= " and state = '$state'";
  3496. }
  3497. if ($express) {
  3498. $where .= " and express = '$express'";
  3499. }
  3500. if ($orderinfo) {
  3501. $where .= " and orderinfo = '$orderinfo'";
  3502. }
  3503. if ($user) {
  3504. $where .= " and user = '$user'";
  3505. }
  3506. if ($name) {
  3507. $where .= " and name = '$name'";
  3508. }
  3509. if ($waybill) {
  3510. $where .= " and waybill = '$waybill'";
  3511. }
  3512. //数据排序
  3513. $order_str = "id desc";
  3514. if (empty($page)) {
  3515. $start = 0;
  3516. $perpage = 1;
  3517. } else {
  3518. $start = ($page - 1) * $perpage;
  3519. }
  3520. //取得信息列表
  3521. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3522. //格式化数据
  3523. foreach ($info_list as $key => $value) {
  3524. $shop = $this->shop->read($value['shop']);
  3525. $info_list[$key]['shop'] = $shop['shopname'];
  3526. $warehouse = $this->warehouse->read($value['warehouse']);
  3527. $info_list[$key]['warehouse'] = $warehouse['title'];
  3528. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3529. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3530. if ($value['waybill'] == 0) {
  3531. $info_list[$key]['waybill'] = "";
  3532. }
  3533. $express = $this->express->read($value['express']);
  3534. $info_list[$key]['express'] = $express['title'];
  3535. $typeclass = $this->typeclass->read($value['state']);
  3536. $info_list[$key]['state'] = $typeclass['title'];
  3537. }
  3538. $total = $this->fullorder->find_count($where);
  3539. $pagenum = ceil($total / $perpage);
  3540. $over = $total - ($start + $perpage);
  3541. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3542. echo json_encode($rows);
  3543. exit;
  3544. }
  3545. $this->data['express'] = $this->express->find_all();
  3546. $this->_Template('whlabel_retreat', $this->data);
  3547. }
  3548. //退库标签浏览
  3549. public function _retreatlk()
  3550. {
  3551. $post = $this->input->post(NULL, TRUE);
  3552. if (isset($post['page'])) {
  3553. $page = $this->input->post('page', true);
  3554. $perpage = $this->input->post('perpage', true);
  3555. $timetk = $this->input->post('timetk', true);
  3556. $timetj = $this->input->post('timetj', true);
  3557. $sku = $this->input->post('sku', true);
  3558. $warehouse = $this->input->post('warehouse', true);
  3559. $purchase = $this->input->post('purchase', true);
  3560. $orderinfo = $this->input->post('orderinfo', true);
  3561. $waybill = $this->input->post('waybill', true);
  3562. $category = $this->input->post('category', true);
  3563. $size = $this->input->post('size', true);
  3564. $grade = $this->input->post('grade', true);
  3565. $color = $this->input->post('color', true);
  3566. $lowe = $this->input->post('lowe', true);
  3567. $state = $this->input->post('state', true);
  3568. $timetk = strtotime($timetk);
  3569. $timetj = strtotime($timetj);
  3570. $where = "state=2";
  3571. if ($timetk && $timetj) {
  3572. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3573. }
  3574. if ($sku) {
  3575. $where .= " and sku = '$sku'";
  3576. }
  3577. if ($warehouse) {
  3578. $where .= " and warehouse = '$warehouse'";
  3579. }
  3580. if ($purchase) {
  3581. $where .= " and purchase = '$purchase'";
  3582. }
  3583. if ($orderinfo) {
  3584. $where .= " and orderinfo = '$orderinfo'";
  3585. }
  3586. if ($waybill) {
  3587. $where .= " and waybill = '$waybill'";
  3588. }
  3589. if ($category) {
  3590. $where .= " and features like '%-$category-%'";
  3591. }
  3592. if ($size) {
  3593. $where .= " and features like '%-$size-%'";
  3594. }
  3595. if ($grade) {
  3596. $where .= " and features like '%-$grade-%'";
  3597. }
  3598. if ($color) {
  3599. $where .= " and features like '%-$color-%'";
  3600. }
  3601. if ($lowe) {
  3602. $where .= " and features like '%-$lowe-%'";
  3603. }
  3604. //数据排序
  3605. $order_str = "time desc";
  3606. if (empty($page)) {
  3607. $start = 0;
  3608. $perpage = 1;
  3609. } else {
  3610. $start = ($page - 1) * $perpage;
  3611. }
  3612. //取得信息列表
  3613. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3614. foreach ($info_list as $key => $value) {
  3615. $warehouse = $this->warehouse->read($value['warehouse']);
  3616. $info_list[$key]['warehouse'] = $warehouse['title'];
  3617. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3618. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3619. $purchase = $this->purchase->read($value['purchase']);
  3620. $info_list[$key]['purchase'] = $purchase['title'];
  3621. if ($value['outk'] != 0) {
  3622. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3623. } else {
  3624. $info_list[$key]['outk'] = "";
  3625. }
  3626. if ($value['retreat'] != 0) {
  3627. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3628. } else {
  3629. $info_list[$key]['retreat'] = "";
  3630. }
  3631. if ($value['orderinfo'] == 0) {
  3632. $info_list[$key]['orderinfo'] = "";
  3633. }
  3634. if ($value['waybill'] == 0) {
  3635. $info_list[$key]['waybill'] = "";
  3636. }
  3637. }
  3638. $total = $this->whlabel->find_count($where);
  3639. $pagenum = ceil($total / $perpage);
  3640. $over = $total - ($start + $perpage);
  3641. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3642. echo json_encode($rows);
  3643. exit;
  3644. }
  3645. $this->_Template('whlabel_retreatlk', $this->data);
  3646. }
  3647. //更换标签及浏览
  3648. public function _change()
  3649. {
  3650. $post = $this->input->post(NULL, TRUE);
  3651. if (isset($post['page'])) {
  3652. $page = $this->input->post('page', true);
  3653. $perpage = $this->input->post('perpage', true);
  3654. $timetk = $this->input->post('timetk', true);
  3655. $timetj = $this->input->post('timetj', true);
  3656. $label = $this->input->post('label', true);
  3657. $oldlabel = $this->input->post('oldlabel', true);
  3658. $timetk = strtotime($timetk);
  3659. $timetj = strtotime($timetj);
  3660. $where = "state=10 ";
  3661. if ($timetk && $timetj) {
  3662. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3663. }
  3664. if ($label) {
  3665. $where .= " and label = '$label'";
  3666. }
  3667. if ($oldlabel) {
  3668. $where .= " and oldlabel = '$oldlabel'";
  3669. }
  3670. //数据排序
  3671. $order_str = "time asc";
  3672. if (empty($page)) {
  3673. $start = 0;
  3674. $perpage = 1;
  3675. } else {
  3676. $start = ($page - 1) * $perpage;
  3677. }
  3678. //取得信息列表
  3679. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3680. foreach ($info_list as $key => $value) {
  3681. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3682. }
  3683. $total = $this->whlabel->find_count($where);
  3684. $pagenum = ceil($total / $perpage);
  3685. $over = $total - ($start + $perpage);
  3686. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3687. echo json_encode($rows);
  3688. exit;
  3689. }
  3690. $this->_Template('whlabel_change', $this->data);
  3691. }
  3692. //产品标签
  3693. public function _cpbqdc()
  3694. {
  3695. if (isset($_GET['excel'])) {
  3696. $where = "1=1";
  3697. //数据排序
  3698. $order_str = "id desc";
  3699. if (empty($page)) {
  3700. $start = 0;
  3701. $perpage = 1;
  3702. } else {
  3703. $start = ($page - 1) * $perpage;
  3704. }
  3705. $warehouse = $this->input->get('warehouse', true);
  3706. $state = $this->input->get('state', true);
  3707. $timetk = $this->input->get('timetkk', true);
  3708. $timetj = $this->input->get('timetjj', true);
  3709. $timetk = strtotime($timetk);
  3710. $timetj = strtotime($timetj);
  3711. if ($warehouse) {
  3712. $where .= " and warehouse = '$warehouse'";
  3713. }
  3714. if ($state || $state == 0) {
  3715. $where .= " and state = '$state'";
  3716. }
  3717. if ($timetk && $timetj) {
  3718. $where .= " and time > '$timetk' and time < '$timetj'";
  3719. }
  3720. //取得信息列表
  3721. $info_list = $this->whlabel->find_all($where, '*');
  3722. $rows = array();
  3723. $list = array();
  3724. foreach ($info_list as $key => $value) {
  3725. $rows[$value['time']] = $value; //所有数据sku
  3726. }
  3727. foreach ($rows as $value) {
  3728. $warehouse = $this->warehouse->read($value['warehouse']);
  3729. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3730. $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);
  3731. }
  3732. $title = "产品标签统计表";
  3733. $titlename = "<table border=1>
  3734. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3735. <tr align='center'>
  3736. <td>仓库</td>
  3737. <td>SKU</td>
  3738. <td>产品</td>
  3739. <td>入库时间</td>
  3740. <td>操作时间</td>
  3741. <td>备注</td>
  3742. <td>数量</td>
  3743. </tr>
  3744. </table>";
  3745. $filename = $title . ".xls";
  3746. $tail = "";
  3747. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3748. }
  3749. }
  3750. //进销存导出
  3751. public function _exceljxc()
  3752. {
  3753. $classid = $this->classid->sku();
  3754. $pm = $classid;
  3755. $typeclass = array();
  3756. $tc = $this->typeclass->find_all();
  3757. foreach ($tc as $v) {
  3758. $typeclass[$v['id']] = $v;
  3759. }
  3760. $prc = array();
  3761. $purchase = $this->purchase->find_all();
  3762. foreach ($purchase as $k => $v) {
  3763. $prc[$v['id']] = $v['title'];
  3764. }
  3765. if (isset($_GET['excel'])) {
  3766. $where = "sku != 'Preset'";
  3767. //数据排序
  3768. $order_str = "id desc";
  3769. if (empty($page)) {
  3770. $start = 0;
  3771. $perpage = 1;
  3772. } else {
  3773. $start = ($page - 1) * $perpage;
  3774. }
  3775. $category = $this->input->get('category', true);
  3776. $warehouse = $this->input->get('warehouse', true);
  3777. $excelid = $this->input->get('sid', true);
  3778. if ($category) {
  3779. $where .= " and features like '%-$category-%'";
  3780. }
  3781. if ($warehouse) {
  3782. $where .= " and warehouse = '$warehouse'";
  3783. }
  3784. $xzid = '';
  3785. if ($excelid) {
  3786. $excelid = explode(',', trim($excelid, ','));
  3787. foreach ($excelid as $key => $value) {
  3788. $xzid .= " id = " . $value . " or";
  3789. }
  3790. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3791. }
  3792. //取得信息列表
  3793. /**
  3794. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3795. $rows = array();$list = array();
  3796. foreach ($info_list as $key=>$value)
  3797. {
  3798. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3799. }
  3800. **/
  3801. $wt = array();
  3802. $whlabel_type = $this->whlabel_type->find_all();
  3803. foreach ($whlabel_type as $v) {
  3804. $wt[$v['id']] = $v['title'];
  3805. }
  3806. $wh = array();
  3807. $w = $this->warehouse->find_all('1=1', 'id,title');
  3808. foreach ($w as $v) {
  3809. $wh[$v['id']] = $v['title'];
  3810. }
  3811. $list = array();
  3812. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3813. foreach ($rows as $key => $value) {
  3814. if (isset($wt[$value['type']])) {
  3815. $rows[$key]['type'] = $wt[$value['type']];
  3816. } else {
  3817. $rows[$key]['type'] = '未设置';
  3818. }
  3819. $bm = '03';
  3820. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3821. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3822. $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');
  3823. $details = array();
  3824. $cpid = array();
  3825. $cpbz = array();
  3826. $c = 0;
  3827. $g = 0;
  3828. $x = 0;
  3829. $t = 0;
  3830. $s = 0;
  3831. $q = 0;
  3832. foreach ($sd as $k => $v) {
  3833. if ($v['state'] == 0) {
  3834. $c++;
  3835. if ($v['cpid'] != 0) {
  3836. $cpid[$v['cpid']] = $v['cpid'];
  3837. }
  3838. if ($v['cpbz'] != '') {
  3839. $cpbz[$v['cpbz']] = $v['cpbz'];
  3840. }
  3841. }
  3842. if ($v['state'] != 9) {
  3843. $g++;
  3844. }
  3845. if ($v['state'] == 1) {
  3846. $x++;
  3847. }
  3848. if ($v['state'] == 2) {
  3849. $t++;
  3850. }
  3851. if ($v['state'] == 8) {
  3852. $s++;
  3853. }
  3854. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3855. $q++;
  3856. }
  3857. $details[$v['details']] = $v['details'];
  3858. }
  3859. $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'] . '"');
  3860. $rows[$key]['details'] = implode("、", $details);
  3861. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3862. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3863. $number = $value['number'];
  3864. $ftime = time() - 15 * 24 * 3600;
  3865. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3866. $rows[$key]['number'] = $g;
  3867. $rows[$key]['c'] = $c;
  3868. $rows[$key]['x'] = $x;
  3869. $rows[$key]['t'] = $t;
  3870. $rows[$key]['s'] = $s;
  3871. $rows[$key]['q'] = $q;
  3872. $rows[$key]['z'] = $z;
  3873. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3874. $features = explode('-', trim($features, '-'));
  3875. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3876. // $pm = $classid;
  3877. // $jm = $classid;
  3878. // foreach($features as $k=>$v)
  3879. // {
  3880. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3881. // {
  3882. // if($typeclass[$v]['bm'] != '')
  3883. // {
  3884. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3885. // }
  3886. // }
  3887. // if($v != 0)
  3888. // {
  3889. // if(!isset($typeclass[$v]))
  3890. // {
  3891. // continue;
  3892. // }
  3893. // if(isset($pm[$typeclass[$v]['classid']]))
  3894. // {
  3895. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3896. // {
  3897. // $tz = explode('|',$typeclass[$v]['zh']);
  3898. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3899. // }
  3900. // else
  3901. // {
  3902. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3903. // }
  3904. // }
  3905. // if(isset($jm[$typeclass[$v]['classid']]))
  3906. // {
  3907. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3908. // }
  3909. // }
  3910. // }
  3911. // $jm = array_filter($jm);
  3912. // $rows[$key]['bs'] = implode("-",$jm);
  3913. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3914. // $zh = implode(" ",$pm);
  3915. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3916. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3917. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3918. // $rows[$key]['features'] = $zh;
  3919. }
  3920. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3921. $final_list = [];
  3922. foreach ($list as $k => $v) {
  3923. if (empty($v['sku'])) {
  3924. continue;
  3925. }
  3926. $final_list[] = [
  3927. "warehouse" => $v["warehouse"],
  3928. "purchase" => $v["purchase"],
  3929. "details" => $v["details"],
  3930. "cpid" => $v["cpid"],
  3931. "dbcontent" => $v["dbcontent"],
  3932. "sku" => $v["sku"],
  3933. "cs" => $v["bm"],
  3934. "bs" => $v["jm"],
  3935. "title" => $v["title"],
  3936. "features" => $v["pm"],
  3937. "cpbz" => $v["cpbz"],
  3938. "sm" => $v["sm"],
  3939. "type" => $v["type"],
  3940. "number" => $v["number"],
  3941. "c" => $v["c"],
  3942. "x" => $v["x"],
  3943. "t" => $v["t"],
  3944. "s" => $v["s"],
  3945. "q" => $v["q"],
  3946. "z" => $v["z"],
  3947. "weight" => $v['weight'],
  3948. ];
  3949. }
  3950. $title = "总进销存统计表";
  3951. $titlename = "<table border=1>
  3952. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3953. <tr align='center'>
  3954. <td>仓库</td>
  3955. <td>供应商</td>
  3956. <td>位置</td>
  3957. <td>库存编码</td>
  3958. <td>类目</td>
  3959. <td>SKU</td>
  3960. <td>用友编码</td>
  3961. <td>用友料号</td>
  3962. <td>商品名称</td>
  3963. <td>商品中文</td>
  3964. <td>产品备注</td>
  3965. <td>库位负责人</td>
  3966. <td>类型</td>
  3967. <td>入库总量</td>
  3968. <td>库存数量</td>
  3969. <td>销售数量</td>
  3970. <td>退货数量</td>
  3971. <td>删除数量</td>
  3972. <td>其它操作</td>
  3973. <td>占单数量</td>
  3974. <td>重量(g)</td>
  3975. </tr>
  3976. </table>";
  3977. $filename = $title . ".xls";
  3978. $tail = "";
  3979. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3980. }
  3981. }
  3982. //入库导出
  3983. public function _excelr()
  3984. {
  3985. if (isset($_GET['excel'])) {
  3986. $category = $this->input->get('category', true);
  3987. $size = $this->input->get('size', true);
  3988. $grade = $this->input->get('grade', true);
  3989. $color = $this->input->get('color', true);
  3990. $lowe = $this->input->get('lowe', true);
  3991. $sku = $this->input->get('sku', true);
  3992. $warehouse = $this->input->get('warehouse', true);
  3993. $purchase = $this->input->get('purchase', true);
  3994. $ktime = $this->input->get('ktime', true);
  3995. $jtime = $this->input->get('jtime', true);
  3996. $rktype = $this->input->get('rktype',true);
  3997. $ktime = strtotime($ktime);
  3998. $jtime = strtotime($jtime);
  3999. $where = "1=1";
  4000. $gj = "";
  4001. $ck = "";
  4002. if ($category) {
  4003. $where .= " and features like '%-$category-%'";
  4004. }
  4005. if ($size) {
  4006. $where .= " and features like '%-$size-%'";
  4007. }
  4008. if ($grade) {
  4009. $where .= " and features like '%-$grade-%'";
  4010. }
  4011. if ($color) {
  4012. $where .= " and features like '%-$color-%'";
  4013. }
  4014. if ($lowe) {
  4015. $where .= " and features like '%-$lowe-%'";
  4016. }
  4017. if ($warehouse) {
  4018. $where .= " and warehouse = '$warehouse'";
  4019. }
  4020. if ($purchase) {
  4021. $where .= " and purchase = '$purchase'";
  4022. }
  4023. if ($sku) {
  4024. $where .= " and sku = '$sku'";
  4025. }
  4026. if($rktype){
  4027. $where .= " and rktype = '$rktype' ";
  4028. }
  4029. if ($ktime && $jtime) {
  4030. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4031. }
  4032. //数据排序
  4033. $order_str = "id desc";
  4034. if (empty($page)) {
  4035. $start = 0;
  4036. $perpage = 1;
  4037. } else {
  4038. $start = ($page - 1) * $perpage;
  4039. }
  4040. $list = array();
  4041. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4042. foreach ($rows as $value) {
  4043. $ck = $this->warehouse->read($value['warehouse']);
  4044. $warehouse = $ck['title'];
  4045. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4046. $retreatwarehouse = $tkck['title'];
  4047. $gy = $this->purchase->read($value['purchase']);
  4048. $purchase = $gy['title'];
  4049. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4050. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4051. }
  4052. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4053. $titlename = "<table border=1>
  4054. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4055. <tr align='center'>
  4056. <td>仓库</td>
  4057. <td>SKU</td>
  4058. <td>产品</td>
  4059. <td>时间</td>
  4060. <td>数量</td>
  4061. </tr>
  4062. </table>";
  4063. $filename = $title . ".xls";
  4064. $tail = "";
  4065. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4066. }
  4067. }
  4068. //出库、退库导出
  4069. public function _excelct()
  4070. {
  4071. $classid = $this->classid->sku();
  4072. $pm = $classid;
  4073. $typeclass = array();
  4074. $tc = $this->typeclass->find_all();
  4075. foreach ($tc as $v) {
  4076. $typeclass[$v['id']] = $v;
  4077. }
  4078. $prc = array();
  4079. $purchase = $this->purchase->find_all();
  4080. foreach ($purchase as $k => $v) {
  4081. $prc[$v['id']] = $v['title'];
  4082. }
  4083. if (isset($_GET['excel'])) {
  4084. $wh = array();
  4085. $w = $this->warehouse->find_all('1=1', 'id,title');
  4086. foreach ($w as $v) {
  4087. $wh[$v['id']] = $v['title'];
  4088. }
  4089. $type = $this->input->get('excel', true);
  4090. $category = $this->input->get('category', true);
  4091. $size = $this->input->get('size', true);
  4092. $grade = $this->input->get('grade', true);
  4093. $color = $this->input->get('color', true);
  4094. $lowe = $this->input->get('lowe', true);
  4095. $sku = $this->input->get('sku', true);
  4096. $title = $this->input->get('title', true);
  4097. $warehouse = $this->input->get('warehouse', true);
  4098. $purchase = $this->input->get('purchase', true);
  4099. $lacetype = $this->input->get('lacetype', true);
  4100. $haircap = $this->input->get('haircap', true);
  4101. $lacecolor = $this->input->get('lacecolor', true);
  4102. $density = $this->input->get('density', true);
  4103. $details = $this->input->get('details', true);
  4104. $state = $this->input->get('state', true);
  4105. $shop = $this->input->get('shop', true);
  4106. $hairnumber = $this->input->get('hairnumber', true);
  4107. $type_leixi = $this->input->get('type', true);
  4108. $cpbz = $this->input->get('cpbz', true);
  4109. $sm = $this->input->get('sm', true);
  4110. $sid = $this->input->get('sid', true);
  4111. $ktime = $this->input->get('ktime', true);
  4112. $jtime = $this->input->get('jtime', true);
  4113. $ktime = strtotime($ktime);
  4114. $jtime = strtotime($jtime);
  4115. //$where = " 1=1 ";
  4116. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4117. $where = " sku != '' ";
  4118. $gj = "";
  4119. $ck = "";
  4120. if ($category) {
  4121. $where .= " and features like '%-$category-%'";
  4122. }
  4123. if ($size) {
  4124. $where .= " and features like '%-$size-%'";
  4125. }
  4126. if ($grade) {
  4127. $where .= " and features like '%-$grade-%'";
  4128. }
  4129. if ($color) {
  4130. $where .= " and features like '%-$color-%'";
  4131. }
  4132. if ($lowe) {
  4133. $where .= " and features like '%-$lowe-%'";
  4134. }
  4135. if ($warehouse) {
  4136. $where .= " and warehouse = '$warehouse'";
  4137. }
  4138. if ($purchase) {
  4139. $where .= " and purchase = '$purchase'";
  4140. }
  4141. if ($state) {
  4142. $where .= " and state = '$state'";
  4143. }
  4144. if ($lacetype) {
  4145. $where .= " and features like '%-$lacetype-%'";
  4146. }
  4147. if ($lacecolor) {
  4148. $where .= " and features like '%-$lacecolor-%'";
  4149. }
  4150. if ($density) {
  4151. $where .= " and features like '%-$density-%'";
  4152. }
  4153. if ($haircap) {
  4154. $where .= " and features like '%-$haircap-%'";
  4155. }
  4156. if ($details) {
  4157. $where .= " and details = '$details'";
  4158. }
  4159. if ($shop) {
  4160. $where .= " and shop like '%$shop%'";
  4161. }
  4162. if ($title) {
  4163. $title = trim($title, ' ');
  4164. $title = trim($title, ' ');
  4165. $where .= " and title like '%$title%'";
  4166. }
  4167. if (!empty($hairnumber)) {
  4168. $where .= " and features like '%-128-%' ";
  4169. if ($hairnumber < 0) {
  4170. $class_list = $this->typeclass->find_all('classid = 43');
  4171. foreach ($class_list as $v) {
  4172. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4173. }
  4174. } else {
  4175. $where .= " and features like '%-$hairnumber-%'";
  4176. }
  4177. }
  4178. if ($type_leixi) {
  4179. $where .= " and type = '$type_leixi'";
  4180. }
  4181. if ($cpbz) {
  4182. $where .= " and cpbz like '%$cpbz%' ";
  4183. }
  4184. if ($sm) {
  4185. $where .= " and sm like '%$sm%' ";
  4186. }
  4187. if ($sku) {
  4188. $sku = trim($sku, ' ');
  4189. $sku = trim($sku, ' ');
  4190. $where .= " and sku like '%$sku%'";
  4191. }
  4192. if ($ktime && $jtime) {
  4193. if ($type == 1) {
  4194. $tl = '出库';
  4195. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4196. } else if ($type == 2) {
  4197. $tl = '退库';
  4198. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4199. } else if ($type == 3) {
  4200. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4201. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4202. } else if ($type == 4) {
  4203. $tl = '出库+零售';
  4204. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4205. } else if ($type == 5) {
  4206. $tl = '零售';
  4207. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4208. }
  4209. }
  4210. $sidwhere = '';
  4211. if ($sid) {
  4212. $sd = "";
  4213. $s = explode(',', trim($sid, ','));
  4214. foreach ($s as $value) {
  4215. $sd .= " id = " . $value . " or";
  4216. }
  4217. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4218. }
  4219. //数据排序
  4220. $order_str = "time desc";
  4221. if (empty($page)) {
  4222. $start = 0;
  4223. $perpage = 1;
  4224. } else {
  4225. $start = ($page - 1) * $perpage;
  4226. }
  4227. //取得信息列表
  4228. if ($type != 3 && $type != 5) {
  4229. if ($type == 1 || $type == 4) {
  4230. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4231. foreach ($info_list as $key => $value) {
  4232. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4233. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4234. $warehouse = $this->warehouse->read($value['warehouse']);
  4235. $info_list[$key]['warehouse'] = $warehouse['title'];
  4236. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4237. $features = explode('-', trim($features, '-'));
  4238. $pm = $classid;
  4239. foreach ($features as $k => $v) {
  4240. if ($v != 0) {
  4241. if (!isset($typeclass[$v])) {
  4242. continue;
  4243. }
  4244. if (isset($pm[$typeclass[$v]['classid']])) {
  4245. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4246. $tz = explode('|', $typeclass[$v]['zh']);
  4247. $pm[$typeclass[$v]['classid']] = $tz[0];
  4248. } else {
  4249. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4250. }
  4251. }
  4252. }
  4253. }
  4254. $zh = implode(" ", $pm);
  4255. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4256. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4257. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4258. $info_list[$key]['features'] = $zh;
  4259. }
  4260. $final_list = [];
  4261. foreach($info_list as $k=>$v){
  4262. $number = "";
  4263. if(!empty($v['orderinfo'])){
  4264. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4265. if(!empty($tmp_info['number'])){
  4266. $number = $tmp_info['number'];
  4267. }
  4268. }
  4269. $final_list[] = [
  4270. 'warehouse'=>$v['warehouse'],
  4271. 'purchase'=>$v['purchase'],
  4272. 'sku'=>$v['sku'],
  4273. 'title'=>$v['title'],
  4274. 'features'=>$v['features'],
  4275. 'label'=>$v['label'],
  4276. 'orderinfo'=>$v['orderinfo'],
  4277. 'number'=>$number,
  4278. 'waybill'=>$v['waybill'],
  4279. 'outk'=>$v['outk'],
  4280. ];
  4281. }
  4282. } else {
  4283. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4284. foreach ($info_list as $key => $value) {
  4285. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4286. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4287. $warehouse = $this->warehouse->read($value['warehouse']);
  4288. $info_list[$key]['warehouse'] = $warehouse['title'];
  4289. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4290. $features = explode('-', trim($features, '-'));
  4291. $pm = $classid;
  4292. foreach ($features as $k => $v) {
  4293. if ($v != 0) {
  4294. if (!isset($typeclass[$v])) {
  4295. continue;
  4296. }
  4297. if (isset($pm[$typeclass[$v]['classid']])) {
  4298. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4299. $tz = explode('|', $typeclass[$v]['zh']);
  4300. $pm[$typeclass[$v]['classid']] = $tz[0];
  4301. } else {
  4302. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4303. }
  4304. }
  4305. }
  4306. }
  4307. $zh = implode(" ", $pm);
  4308. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4309. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4310. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4311. $info_list[$key]['features'] = $zh;
  4312. }
  4313. $final_list = [];
  4314. foreach($info_list as $k=>$v){
  4315. $number = "";
  4316. if(!empty($v['orderinfo'])){
  4317. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4318. if(!empty($tmp_info['number'])){
  4319. $number = $tmp_info['number'];
  4320. }
  4321. }
  4322. $final_list[] = [
  4323. 'warehouse'=>$v['warehouse'],
  4324. 'purchase'=>$v['purchase'],
  4325. 'sku'=>$v['sku'],
  4326. 'title'=>$v['title'],
  4327. 'features'=>$v['features'],
  4328. 'label'=>$v['label'],
  4329. 'orderinfo'=>$v['orderinfo'],
  4330. 'number'=>$number,
  4331. 'waybill'=>$v['waybill'],
  4332. 'retreat'=>$v['retreat'],
  4333. ];
  4334. }
  4335. }
  4336. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4337. $titlename = "<table border=1>
  4338. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4339. <tr align='center'>
  4340. <td>仓库</td>
  4341. <td>供应商</td>
  4342. <td>SKU</td>
  4343. <td>商品名称</td>
  4344. <td>商品中文</td>
  4345. <td>标签</td>
  4346. <td>订单号</td>
  4347. <td>订单编码</td>
  4348. <td>运单号</td>
  4349. <td>" . $tl . "时间(中国时间)</td>
  4350. </tr>
  4351. </table>";
  4352. $filename = $title . ".xls";
  4353. $tail = "";
  4354. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4355. } else if ($type == 5) {
  4356. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4357. foreach ($info_list as $key => $value) {
  4358. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4359. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4360. $warehouse = $this->warehouse->read($value['warehouse']);
  4361. $info_list[$key]['warehouse'] = $warehouse['title'];
  4362. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4363. $features = explode('-', trim($features, '-'));
  4364. $pm = $classid;
  4365. foreach ($features as $k => $v) {
  4366. if ($v != 0) {
  4367. if (!isset($typeclass[$v])) {
  4368. continue;
  4369. }
  4370. if (isset($pm[$typeclass[$v]['classid']])) {
  4371. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4372. $tz = explode('|', $typeclass[$v]['zh']);
  4373. $pm[$typeclass[$v]['classid']] = $tz[0];
  4374. } else {
  4375. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4376. }
  4377. }
  4378. }
  4379. }
  4380. $zh = implode(" ", $pm);
  4381. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4382. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4383. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4384. $info_list[$key]['features'] = $zh;
  4385. }
  4386. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4387. $titlename = "<table border=1>
  4388. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4389. <tr align='center'>
  4390. <td>仓库</td>
  4391. <td>供应商</td>
  4392. <td>SKU</td>
  4393. <td>商品名称</td>
  4394. <td>商品中文</td>
  4395. <td>标签</td>
  4396. <td>" . $tl . "时间(中国时间)</td>
  4397. </tr>
  4398. </table>";
  4399. $filename = $title . ".xls";
  4400. $tail = "";
  4401. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4402. } else {
  4403. /**
  4404. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4405. $rows = array();$list = array();
  4406. foreach ($info_list as $key=>$value)
  4407. {
  4408. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4409. }
  4410. **/
  4411. $wh = array();
  4412. $w = $this->warehouse->find_all('1=1', 'id,title');
  4413. foreach ($w as $v) {
  4414. $wh[$v['id']] = $v['title'];
  4415. }
  4416. $wt = array();
  4417. $whlabel_type = $this->whlabel_type->find_all();
  4418. foreach ($whlabel_type as $v) {
  4419. $wt[$v['id']] = $v['title'];
  4420. }
  4421. $classid = $this->classid->sku();
  4422. $list = array();
  4423. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4424. foreach ($rows as $key => $value) {
  4425. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4426. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4427. $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');
  4428. $details = array();
  4429. $cpid = array();
  4430. $cpbz = array();
  4431. $c = 0;
  4432. $g = 0;
  4433. $x = 0;
  4434. $t = 0;
  4435. $s = 0;
  4436. $q = 0;
  4437. foreach ($sd as $k => $v) {
  4438. if ($v['state'] == 0) {
  4439. $c++;
  4440. }
  4441. if ($v['state'] != 9) {
  4442. $g++;
  4443. }
  4444. if ($v['outk'] > 1) {
  4445. $x++;
  4446. }
  4447. if ($v['retreat'] > 0) {
  4448. $t++;
  4449. }
  4450. if ($v['state'] == 8) {
  4451. $s++;
  4452. }
  4453. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4454. $q++;
  4455. }
  4456. $details[$v['details']] = $v['details'];
  4457. if($v['state'] == 0){
  4458. if ($v['cpid'] != 0) {
  4459. $cpid[$v['cpid']] = $v['cpid'];
  4460. }
  4461. if ($v['cpbz'] != '') {
  4462. $cpbz[$v['cpbz']] = $v['cpbz'];
  4463. }
  4464. }
  4465. }
  4466. if (isset($wt[$value['type']])) {
  4467. $rows[$key]['type'] = $wt[$value['type']];
  4468. } else {
  4469. $rows[$key]['type'] = '未设置';
  4470. }
  4471. $rows[$key]['details'] = implode("、", $details);
  4472. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4473. $ftime = time() - 15 * 24 * 3600;
  4474. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4475. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4476. $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);
  4477. $rows[$key]['c'] = $c;
  4478. $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);
  4479. $rows[$key]['t'] = $t;
  4480. $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'] . '"');
  4481. $rows[$key]['z'] = $z;
  4482. // $jm = $classid;
  4483. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4484. $features = explode('-', trim($features, '-'));
  4485. // $pm = $classid;
  4486. // foreach ($features as $k => $v) {
  4487. // if ($v != 0) {
  4488. // if (!isset($typeclass[$v])) {
  4489. // continue;
  4490. // }
  4491. // if (isset($pm[$typeclass[$v]['classid']])) {
  4492. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4493. // $tz = explode('|', $typeclass[$v]['zh']);
  4494. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4495. // } else {
  4496. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4497. // }
  4498. // if (isset($jm[$typeclass[$v]['classid']])) {
  4499. // if ($typeclass[$v]['jm']) {
  4500. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4501. // }
  4502. // }
  4503. // }
  4504. // }
  4505. // }
  4506. // $zh = implode(" ", $pm);
  4507. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4508. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4509. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4510. // $rows[$key]['features'] = $zh;
  4511. // $jm = array_filter($jm); //去除空值
  4512. // $jm = implode("-", $jm);
  4513. // $rows[$key]['jm'] = $jm;
  4514. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4515. }
  4516. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4517. // echo "<pre>";
  4518. // print_r($tmp_list);
  4519. // die;
  4520. $final_list =[];
  4521. foreach($tmp_list as $k=>$v){
  4522. $final_list[] = [
  4523. "warehouse"=>$v['warehouse'],
  4524. "purchase"=>$v['purchase'],
  4525. "details"=>trim($v['details'],'、'),
  4526. "cpid"=>$v['cpid'],
  4527. "sku"=>$v['sku'],
  4528. "title"=>$v['title'],
  4529. "features"=>$v['pm'],
  4530. "cpbz"=>$v['cpbz'],
  4531. "sm"=>$v['sm'],
  4532. "type"=>$v['type'],
  4533. "g"=>$v["g"],
  4534. "c"=>$v["c"],
  4535. "x"=>$v["x"],
  4536. "t"=>$v["t"],
  4537. "z"=>$v["z"],
  4538. "jm"=>$v["jm"],
  4539. "weight"=>$v["weight"],
  4540. "asd"=>$v["asd"],
  4541. ];
  4542. }
  4543. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4544. $titlename = "<table border=1>
  4545. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4546. <tr align='center'>
  4547. <td>仓库</td>
  4548. <td>供应商</td>
  4549. <td>位置</td>
  4550. <td>库存编码</td>
  4551. <td>SKU</td>
  4552. <td>商品名称</td>
  4553. <td>商品中文</td>
  4554. <td>产品备注</td>
  4555. <td>说明</td>
  4556. <td>类型</td>
  4557. <td>入库总量</td>
  4558. <td>库存数量</td>
  4559. <td>销售数量</td>
  4560. <td>退货数量</td>
  4561. <td>占单数量</td>
  4562. <td>料号</td>
  4563. <td>重量</td>
  4564. <td>类目</td>
  4565. </tr>
  4566. </table>";
  4567. $filename = $title . ".xls";
  4568. $tail = "";
  4569. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4570. }
  4571. }
  4572. }
  4573. //出库+入库数据整合
  4574. public function _excelcr()
  4575. {
  4576. if (isset($_GET['excel'])) {
  4577. $type = $this->input->get('excel', true);
  4578. $category = $this->input->get('category', true);
  4579. $size = $this->input->get('size', true);
  4580. $grade = $this->input->get('grade', true);
  4581. $color = $this->input->get('color', true);
  4582. $lowe = $this->input->get('lowe', true);
  4583. $sku = $this->input->get('sku', true);
  4584. $warehouse = $this->input->get('warehouse', true);
  4585. $purchase = $this->input->get('purchase', true);
  4586. $state = $this->input->get('state', true);
  4587. $sid = $this->input->get('sid', true);
  4588. $ktime = $this->input->get('ktime', true);
  4589. $jtime = $this->input->get('jtime', true);
  4590. $ktime = strtotime($ktime);
  4591. $jtime = strtotime($jtime);
  4592. $where = "1=1";
  4593. $gj = "";
  4594. $ck = "";
  4595. if ($category) {
  4596. $where .= " and features like '%-$category-%'";
  4597. }
  4598. if ($size) {
  4599. $where .= " and features like '%-$size-%'";
  4600. }
  4601. if ($grade) {
  4602. $where .= " and features like '%-$grade-%'";
  4603. }
  4604. if ($color) {
  4605. $where .= " and features like '%-$color-%'";
  4606. }
  4607. if ($lowe) {
  4608. $where .= " and features like '%-$lowe-%'";
  4609. }
  4610. if ($warehouse) {
  4611. $where .= " and warehouse = '$warehouse'";
  4612. }
  4613. if ($purchase) {
  4614. $where .= " and purchase = '$purchase'";
  4615. }
  4616. if ($state) {
  4617. $where .= " and state = '$state'";
  4618. }
  4619. if ($sku) {
  4620. $where .= " and sku like '%$sku%'";
  4621. }
  4622. if ($ktime && $jtime) {
  4623. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4624. }
  4625. $sidwhere = '';
  4626. if ($sid) {
  4627. $sd = "";
  4628. $s = explode(',', trim($sid, ','));
  4629. foreach ($s as $value) {
  4630. $sd .= " id = " . $value . " or";
  4631. }
  4632. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4633. }
  4634. //取得信息列表
  4635. $timeread = $ktime;
  4636. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4637. $timelist = array();
  4638. for ($i = 0; $i < $timenum; $i++) {
  4639. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4640. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4641. }
  4642. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4643. //echo "<pre>";
  4644. //print_r($info_list);
  4645. //exit();
  4646. $rows = array();
  4647. $list = array();
  4648. foreach ($info_list as $key => $value) {
  4649. $thistime = $timelist;
  4650. if (isset($rows[strtolower($value['sku'])])) {
  4651. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4652. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4653. }
  4654. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4655. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4656. }
  4657. } else {
  4658. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4659. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4660. }
  4661. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4662. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4663. }
  4664. $rows[strtolower($value['sku'])] = $thistime;
  4665. }
  4666. }
  4667. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4668. <head>
  4669. <!--[if gte mso 9]><xml>
  4670. <x:ExcelWorkbook>
  4671. <x:ExcelWorksheets>
  4672. <x:ExcelWorksheet>
  4673. <x:Name>EXCEL</x:Name>
  4674. <x:WorksheetOptions>
  4675. <x:Print>
  4676. <x:ValidPrinterInfo />
  4677. </x:Print>
  4678. </x:WorksheetOptions>
  4679. </x:ExcelWorksheet>
  4680. </x:ExcelWorksheets>
  4681. </x:ExcelWorkbook>
  4682. </xml>
  4683. <![endif]-->
  4684. </head><body>";
  4685. $str .= "<table border=1><tr><td>SKU</td>";
  4686. foreach ($timelist as $k => $v) {
  4687. $str .= "<td>" . $k . "出库</td>";
  4688. $str .= "<td>" . $k . "入库</td>";
  4689. }
  4690. $str .= "</tr></table>";
  4691. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4692. foreach ($rows as $key => $val) {
  4693. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4694. foreach ($val as $k => $v) {
  4695. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4696. if ($val[$k]['r'] > 0) {
  4697. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4698. } else {
  4699. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4700. }
  4701. }
  4702. $str .= "</tr>";
  4703. }
  4704. $str .= "</table>";
  4705. $str .= "</body></html>";
  4706. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4707. header("Content-type: application/octet-stream");
  4708. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4709. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4710. header("Pragma: no-cache");
  4711. header("Expires: 0");
  4712. exit($str);
  4713. }
  4714. }
  4715. //数量调整模板导出
  4716. public function _presetout()
  4717. {
  4718. if (isset($_GET['excel'])) {
  4719. $where = "sku != 'Preset' and purchase != 0";
  4720. //数据排序
  4721. $order_str = "id desc";
  4722. if (empty($page)) {
  4723. $start = 0;
  4724. $perpage = 1;
  4725. } else {
  4726. $start = ($page - 1) * $perpage;
  4727. }
  4728. //取得信息列表
  4729. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4730. $rows = array();
  4731. $list = array();
  4732. foreach ($info_list as $value) {
  4733. $warehouse = $this->warehouse->read($value['warehouse']);
  4734. $number = $value['number'];
  4735. $ftime = time() - 15 * 24 * 3600;
  4736. $purchase = $this->purchase->read($value['purchase']);
  4737. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4738. }
  4739. $title = "库存模板";
  4740. $titlename = "<table border=1>
  4741. <tr align='center'>
  4742. <td>仓库</td>
  4743. <td>供应商编码</td>
  4744. <td>SKU</td>
  4745. <td>增减数量(正数或负数)</td>
  4746. <td>增减备注</td>
  4747. <td>库位</td>
  4748. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4749. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4750. </tr>
  4751. </table>";
  4752. $filename = $title . ".xls";
  4753. $tail = "";
  4754. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4755. }
  4756. }
  4757. //数量调整模板导入
  4758. public function _presetedit()
  4759. {
  4760. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4761. $config['upload_path'] = '.' . $dir;
  4762. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4763. $config['allowed_types'] = 'xls|xlsx|csv';
  4764. $config['max_size'] = 10240;
  4765. $this->load->library('upload', $config);
  4766. $this->upload->initialize($config);
  4767. if ($this->upload->do_upload('userfile')) {
  4768. $full_path = $dir . $this->upload->data('file_name');
  4769. $fileName = '.' . $full_path;
  4770. if (!file_exists($fileName)) {
  4771. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4772. exit;
  4773. } else {
  4774. require_once "./data/excel/PHPExcel/IOFactory.php";
  4775. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4776. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4777. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4778. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4779. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4780. ++$column; //如果列数大于26行
  4781. $list = array();
  4782. for ($i = 2; $i <= $row; $i++) // 行数循环
  4783. {
  4784. $data = array();
  4785. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4786. {
  4787. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4788. }
  4789. $list[] = $data;
  4790. }
  4791. }
  4792. $i = 0;
  4793. $j = 0;
  4794. $ed = array();
  4795. foreach ($list as $key => $value) {
  4796. $time = time();
  4797. if ($value['0'] == "") {
  4798. continue;
  4799. }
  4800. $warehouse = $this->warehouse->get_title($value['0']);
  4801. $purchase = $this->purchase->get_bm($value['1']);
  4802. $sku = $value['2'];
  4803. $num = $value['3']; //调整数量
  4804. $text = $value['4']; //扣减说明
  4805. $type = $value['5']; //调整方式0扣减1删除
  4806. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4807. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4808. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4809. if (!$purchase) //如果没有这个SKU
  4810. {
  4811. $ed[] = array($purchase . '-不存在此供应商编码');
  4812. $j++;
  4813. continue;
  4814. }
  4815. if (!$d) //如果没有这个SKU
  4816. {
  4817. $ed[] = array($sku . '-库存中不存在此SKU');
  4818. $j++;
  4819. continue;
  4820. }
  4821. if (!isset($warehouse['id'])) {
  4822. $ed[] = array($sku . '-仓库名错误!');
  4823. $j++;
  4824. continue;
  4825. }
  4826. if ($type != '0' && $type != '1') {
  4827. $ed[] = array($sku . '-扣减方式填写错误!');
  4828. $j++;
  4829. continue;
  4830. }
  4831. if ($num < 0) //扣减库存
  4832. {
  4833. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4834. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4835. $j++;
  4836. continue;
  4837. }
  4838. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4839. if (count($data) < abs($num)) {
  4840. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4841. $j++;
  4842. continue;
  4843. }
  4844. if ($type == 0) //如果扣减方式为 扣减库存
  4845. {
  4846. for ($i = 0; $i < abs($num); $i++) {
  4847. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4848. }
  4849. } else if ($type == 1) {
  4850. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4851. if (count($zt) > 0) {
  4852. $ed[] = array($sku . '-有在途库存无法删除!');
  4853. $j++;
  4854. continue;
  4855. }
  4856. for ($i = 0; $i < abs($num); $i++) {
  4857. $this->whlabel->remove($data[$i]['id']);
  4858. }
  4859. }
  4860. } else if ($num > 0) //增加库存
  4861. {
  4862. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4863. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4864. $j++;
  4865. continue;
  4866. }
  4867. $post['sku'] = $d['sku'];
  4868. $post['shop'] = $d['shop'];
  4869. $post['warehouse'] = $warehouse['id'];
  4870. $post['purchase'] = $purchase['id'];
  4871. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4872. $post['state'] = 0;
  4873. $post['title'] = $d['title'];
  4874. $post['number'] = $d['number'];
  4875. $post['features'] = $d['features'];
  4876. $post['enter'] = $time;
  4877. $post['time'] = $time; //操作时间
  4878. $post['rktype'] = $rktype;
  4879. for ($i = 0; $i < $num; $i++) {
  4880. $post['label'] = time() . rand(100, 999) . $i;
  4881. $this->whlabel->insert($post);
  4882. }
  4883. }
  4884. sleep(1); //防止入库时间一样,需要延迟1秒
  4885. }
  4886. if ($j > 0) {
  4887. $tt = date('Ymd', time());
  4888. $title = '库存导入错误信息-' . $tt;
  4889. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4890. $tail = "\n";
  4891. $filename = $title . ".xls";
  4892. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4893. $dir = '/data/excel/' . $time . '/';
  4894. $file_name = 'error_' . $time . rand(1000, 9999);
  4895. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4896. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4897. fwrite($myfile, $ecl);
  4898. fclose($myfile);
  4899. $error = $dir . $file_name . '.xls';
  4900. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4901. exit;
  4902. } else {
  4903. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4904. exit;
  4905. }
  4906. }
  4907. }
  4908. public function _presetedittwo(){
  4909. $data = $this->input->post(NULL, TRUE);
  4910. if(empty($list)){
  4911. $raw_data = $this->input->raw_input_stream;
  4912. // 解码 JSON
  4913. $data = json_decode($raw_data, true);
  4914. }
  4915. if(empty($data)){
  4916. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4917. exit;
  4918. }
  4919. $list = [];
  4920. if(isset($data['list'])){
  4921. $list = $data['list'];
  4922. }
  4923. $i = 0;
  4924. $j = 0;
  4925. $ed = array();
  4926. foreach ($list as $key => $value) {
  4927. $time = time();
  4928. if ($value['0'] == "") {
  4929. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4930. $j++;
  4931. continue;
  4932. }
  4933. $warehouse = $this->warehouse->get_title($value['0']);
  4934. if(empty($warehouse)){
  4935. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4936. $j++;
  4937. continue;
  4938. }
  4939. $purchase = $this->purchase->get_bm($value['1']);
  4940. $sku = $value['2'];
  4941. $num = $value['3']; //调整数量
  4942. $text = $value['4']; //扣减说明
  4943. $type = 0; //调整方式0扣减1删除
  4944. $details = empty($value['5'])?'':$value['5']; //库位
  4945. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4946. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4947. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4948. if (!$purchase) //如果没有这个SKU
  4949. {
  4950. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4951. $j++;
  4952. continue;
  4953. }
  4954. if (!$d) //如果没有这个SKU
  4955. {
  4956. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4957. $j++;
  4958. continue;
  4959. }
  4960. if (!isset($warehouse['id'])) {
  4961. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4962. $j++;
  4963. continue;
  4964. }
  4965. if ($type != '0' && $type != '1') {
  4966. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4967. $j++;
  4968. continue;
  4969. }
  4970. if ($num < 0) //扣减库存
  4971. {
  4972. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4973. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4974. $j++;
  4975. continue;
  4976. }
  4977. if(!empty($details)){
  4978. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  4979. }else{
  4980. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  4981. }
  4982. if (count($data) < abs($num)) {
  4983. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  4984. $j++;
  4985. continue;
  4986. }
  4987. if ($type == 0) //如果扣减方式为 扣减库存
  4988. {
  4989. for ($i = 0; $i < abs($num); $i++) {
  4990. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4991. }
  4992. } else if ($type == 1) {
  4993. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4994. if (count($zt) > 0) {
  4995. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  4996. $j++;
  4997. continue;
  4998. }
  4999. for ($i = 0; $i < abs($num); $i++) {
  5000. $this->whlabel->remove($data[$i]['id']);
  5001. }
  5002. }
  5003. } else if ($num > 0) //增加库存
  5004. {
  5005. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5006. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5007. $j++;
  5008. continue;
  5009. }
  5010. if(empty($details)){
  5011. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5012. if(empty($tmp_info)){
  5013. $details = '';
  5014. }else{
  5015. $details = $tmp_info['details'];
  5016. }
  5017. }else{
  5018. if($details == 'DZ001'){
  5019. }else{
  5020. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5021. if(empty($tmp_info)){
  5022. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5023. $j++;
  5024. continue;
  5025. }
  5026. }
  5027. }
  5028. $post['sku'] = $d['sku'];
  5029. $post['shop'] = $d['shop'];
  5030. $post['warehouse'] = $warehouse['id'];
  5031. $post['purchase'] = $purchase['id'];
  5032. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5033. $post['state'] = 0;
  5034. $post['title'] = $d['title'];
  5035. $post['number'] = $d['number'];
  5036. $post['features'] = $d['features'];
  5037. $post['details'] = $details;
  5038. $post['enter'] = $time;
  5039. $post['time'] = $time; //操作时间
  5040. $post['rktype'] = $rktype;
  5041. $post['sku_master_id'] = $d['sku_master_id'];
  5042. $post['sku_shop_id'] = $d['sku_shop_id'];
  5043. for ($i = 0; $i < $num; $i++) {
  5044. $post['label'] = time() . rand(100, 999) . $i;
  5045. $this->whlabel->insert($post);
  5046. }
  5047. }
  5048. sleep(1); //防止入库时间一样,需要延迟1秒
  5049. }
  5050. if ($j > 0) {
  5051. $tt = date('Ymd', time());
  5052. $title = '库存导入错误信息-' . $tt;
  5053. $error = $title . '.xls';
  5054. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5055. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5056. exit;
  5057. } else {
  5058. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5059. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5060. exit;
  5061. }
  5062. }
  5063. //笛卡儿积
  5064. function cp($ps, $sets, $list)
  5065. {
  5066. $result = array();
  5067. $j = 0;
  5068. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5069. if ($i == 0) {
  5070. $result = $sets[$i];
  5071. }
  5072. $tmp = array();
  5073. foreach ($result as $res) {
  5074. foreach ($sets[$i + 1] as $set) {
  5075. $tmp[] = $res . ',' . $set;
  5076. }
  5077. }
  5078. $result = $tmp;
  5079. }
  5080. $this->db->trans_begin();
  5081. foreach ($result as $v) {
  5082. $post = array();
  5083. $title = "";
  5084. $num = "";
  5085. $data = explode(',', $v);
  5086. for ($i = 0; $i < count($list); $i++) {
  5087. $post[$list[$i]] = $data[$i];
  5088. $typeclass = $this->typeclass->read($data[$i]);
  5089. $title = $title . $typeclass['title'] . " ";
  5090. if ($data[$i] != 0) {
  5091. $num .= $data[$i]; //所有数据ID拼接
  5092. }
  5093. }
  5094. foreach ($ps as $kp => $vp) {
  5095. $post[$kp] = $vp;
  5096. }
  5097. $post['number'] = $num;
  5098. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5099. if ($info_list) {
  5100. $j++;
  5101. } else {
  5102. $skunum = $this->whlabel->find_count();
  5103. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5104. $post['title'] = rtrim($title, ' ');
  5105. $this->whlabel->insert($post);
  5106. }
  5107. }
  5108. if ($this->db->trans_status() === FALSE) {
  5109. $this->db->trans_commit();
  5110. return NULL;
  5111. } else {
  5112. $this->db->trans_commit();
  5113. return $j;
  5114. }
  5115. }
  5116. public function _kj($arg_array)
  5117. {
  5118. if (isset($_POST['sku'])) {
  5119. $time = time();
  5120. $sku = $this->input->post('sku', true);
  5121. $warehouse = $this->input->post('warehouse', true);
  5122. $num = $this->input->post('num', true);
  5123. $text = $this->input->post('text', true);
  5124. $purchase = $this->input->post('purchase', true);
  5125. $cktype = $this->input->post('cktype', true);
  5126. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5127. if ($cktype != 1 && $text == '') {
  5128. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5129. exit;
  5130. }
  5131. if ($num > count($order)) {
  5132. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5133. exit;
  5134. } else {
  5135. for ($i = 0; $i < $num; $i++) {
  5136. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5137. }
  5138. }
  5139. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5140. exit;
  5141. }
  5142. $uid = $this->whlabel->read($arg_array[0]);
  5143. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5144. $this->data['data'] = $uid;
  5145. $this->_Template('whlabel_kj', $this->data);
  5146. }
  5147. public function _summary($arg_array)
  5148. {
  5149. $prc = array();
  5150. $purchase = $this->purchase->find_all();
  5151. foreach ($purchase as $k => $v) {
  5152. $prc[$v['id']] = $v['title'];
  5153. }
  5154. if (isset($_GET['excel'])) {
  5155. $ktime = $this->input->get('ktime', true);
  5156. $jtime = $this->input->get('jtime', true);
  5157. $ktime = strtotime($ktime);
  5158. $jtime = strtotime($jtime);
  5159. $where = "1=1";
  5160. if ($ktime && $jtime) {
  5161. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5162. }
  5163. //数据排序
  5164. $order_str = "time desc";
  5165. if (empty($page)) {
  5166. $start = 0;
  5167. $perpage = 1;
  5168. } else {
  5169. $start = ($page - 1) * $perpage;
  5170. }
  5171. //取得信息列表
  5172. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5173. foreach ($info_list as $key => $value) {
  5174. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5175. $warehouse = $this->warehouse->read($value['warehouse']);
  5176. $info_list[$key]['warehouse'] = $warehouse['title'];
  5177. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  5178. $details = array();
  5179. $cpid = array();
  5180. foreach ($x as $k => $v) {
  5181. if($v['status'] == 0){
  5182. if ($v['details'] != '') {
  5183. $details[$v['details']] = $v['details'];
  5184. }
  5185. if ($v['cpid'] != 0) {
  5186. $cpid[$v['cpid']] = $v['cpid'];
  5187. }
  5188. }
  5189. }
  5190. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5191. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5192. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5193. $info_list[$key]['s'] = $s;
  5194. $info_list[$key]['x'] = count($x);
  5195. }
  5196. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5197. $titlename = "<table border=1>
  5198. <tr align='center'>
  5199. <td>仓库</td>
  5200. <td>供应商</td>
  5201. <td>出库位置</td>
  5202. <td>出库编码</td>
  5203. <td>SKU</td>
  5204. <td>产品名</td>
  5205. <td>总剩余库存</td>
  5206. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5207. </tr>
  5208. </table>";
  5209. $filename = $title . ".xls";
  5210. $tail = "";
  5211. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5212. }
  5213. }
  5214. //usps发货清单
  5215. public function _manifest()
  5216. {
  5217. if (isset($_POST['manifest'])) {
  5218. $wltext = $this->input->post('wltext', true);
  5219. $time = time() - 16 * 3600;
  5220. $ptime = strtotime(date('Y-m-d', $time));
  5221. $waybill = array();
  5222. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5223. foreach ($fullorder as $v) {
  5224. $waybill[$v['waybill']] = $v['waybill'];
  5225. }
  5226. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5227. foreach ($fullordersmt as $v) {
  5228. $waybill[$v['waybill']] = $v['waybill'];
  5229. }
  5230. $wltext = explode(';', $wltext);
  5231. foreach ($wltext as $v) {
  5232. if (isset($waybill[$v])) {
  5233. unset($waybill[$v]);
  5234. }
  5235. }
  5236. $data = $this->usps->get_manifest($waybill);
  5237. if (isset($data['Description'])) {
  5238. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5239. exit;
  5240. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5241. $bctime = date('Ymd', time());
  5242. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5243. echo json_encode(array('msg' => $pdf, 'success' => true));
  5244. exit;
  5245. } else {
  5246. echo json_encode(array('msg' => $data, 'success' => false));
  5247. exit;
  5248. }
  5249. }
  5250. }
  5251. public function _pdf($pdf, $title, $bctime)
  5252. {
  5253. $pdf_path = './data/pdf/' . $bctime . '/';
  5254. $file_base64 = $pdf;
  5255. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5256. $file_base64 = base64_decode($file_base64);
  5257. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5258. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5259. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5260. }
  5261. /**
  5262. *
  5263. *
  5264. *
  5265. 进销存占单异常索引
  5266. *
  5267. *
  5268. *
  5269. **/
  5270. public function _abnormal()
  5271. {
  5272. $post = $this->input->post(NULL, TRUE);
  5273. if (isset($post['page'])) {
  5274. $page = $this->input->post('page', true);
  5275. $perpage = $this->input->post('perpage', true);
  5276. $sku = $this->input->post('sku', true);
  5277. $where = "1=1";
  5278. //数据排序
  5279. $order_str = "id desc";
  5280. if (empty($page)) {
  5281. $start = 0;
  5282. $perpage = 1;
  5283. } else {
  5284. $start = ($page - 1) * $perpage;
  5285. }
  5286. //取得信息列表
  5287. $info_list = $this->whlabel->find_all($where, '*');
  5288. $rows = array();
  5289. $list = array();
  5290. foreach ($info_list as $key => $value) {
  5291. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5292. }
  5293. foreach ($rows as $value) {
  5294. $warehouse = $this->warehouse->read($value['warehouse']);
  5295. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5296. $number = $value['number'];
  5297. $ftime = time() - 15 * 24 * 3600;
  5298. if ($value['shop'] != '') {
  5299. $shop = $value['shop'];
  5300. $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');
  5301. $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');
  5302. $order = array_merge($orderdlz, $ordersmt);
  5303. $od = 0;
  5304. $a = '';
  5305. $orid = '';
  5306. foreach ($order as $v) {
  5307. $or = explode('|', ltrim($v['whlabel'], '|'));
  5308. for ($i = 0; $i < count($or); $i++) {
  5309. $orod = explode('-', $or[$i]);
  5310. if ($orod[0] == $number) {
  5311. $od += $orod[1];
  5312. }
  5313. }
  5314. $orid .= $v['number'] . '-';
  5315. }
  5316. } else {
  5317. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5318. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5319. $order = array_merge($orderdlz, $ordersmt);
  5320. $od = 0;
  5321. $a = '';
  5322. $orid = '';
  5323. $qt = array();
  5324. foreach ($order as $v) {
  5325. $or = explode('|', ltrim($v['whlabel'], '|'));
  5326. for ($i = 0; $i < count($or); $i++) {
  5327. $orod = explode('-', $or[$i]);
  5328. if ($orod[0] == $number) {
  5329. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5330. if ($czzs > 0) {
  5331. if (isset($qt[$v['shop']])) {
  5332. if ($qt[$v['shop']] < $orod[1]) {
  5333. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5334. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5335. } else {
  5336. $qt[$v['shop']] -= $orod[1];
  5337. }
  5338. } else {
  5339. $qt[$v['shop']] = $czzs;
  5340. }
  5341. } else {
  5342. $od += $orod[1];
  5343. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5344. }
  5345. }
  5346. }
  5347. }
  5348. }
  5349. $z = $od . '(' . $orid . ')'; //查看订单号
  5350. //$z = $od;
  5351. if ($od > $c) {
  5352. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5353. }
  5354. }
  5355. $listdata = array_slice($list, $start, $perpage);
  5356. $total = count($list);
  5357. $pagenum = ceil($total / $perpage);
  5358. $over = $total - ($start + $perpage);
  5359. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5360. echo json_encode($rows);
  5361. exit;
  5362. }
  5363. $this->_Template('whlabel_abnormal', $this->data);
  5364. }
  5365. /**
  5366. *
  5367. *
  5368. *
  5369. 进销存占单异常索引
  5370. *
  5371. *
  5372. *
  5373. **/
  5374. public function _error()
  5375. {
  5376. $post = $this->input->post(NULL, TRUE);
  5377. if (isset($post['page'])) {
  5378. $page = $this->input->post('page', true);
  5379. $perpage = $this->input->post('perpage', true);
  5380. $sku = $this->input->post('sku', true);
  5381. $warehouse = $this->input->post('warehouse', true);
  5382. $ktime = $this->input->post('ktime', true);
  5383. $jtime = $this->input->post('jtime', true);
  5384. $ktime = strtotime($ktime);
  5385. $jtime = strtotime($jtime);
  5386. $where = "sku != 'Preset'";
  5387. $gj = '';
  5388. if ($sku) {
  5389. $where .= " and sku like '%$sku%'";
  5390. } else {
  5391. if ($ktime && $jtime) {
  5392. $gj = " and time > '$ktime' and time < '$jtime'";
  5393. }
  5394. }
  5395. if ($warehouse) {
  5396. $where .= " and warehouse = '$warehouse'";
  5397. }
  5398. //数据排序
  5399. $order_str = "id desc";
  5400. if (empty($page)) {
  5401. $start = 0;
  5402. $perpage = 1;
  5403. } else {
  5404. $start = ($page - 1) * $perpage;
  5405. }
  5406. //取得信息列表
  5407. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5408. $rows = array();
  5409. $list = array();
  5410. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5411. // foreach ($info_list as $value)
  5412. // {
  5413. // $warehouse = $this->warehouse->read($value['warehouse']);
  5414. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5415. // $number = $value['number'];$ftime = time()-15*24*3600;
  5416. // if($c < 1)
  5417. // {
  5418. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5419. // }
  5420. // }
  5421. $warehouse_list = $this->warehouse->find_all();
  5422. $warehouse_list = array_column($warehouse_list, null, 'id');
  5423. foreach ($info_list as $value) {
  5424. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5425. 'title' => "",
  5426. ];
  5427. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5428. $number = $value['number'];
  5429. $ftime = time() - 15 * 24 * 3600;
  5430. if ($c < 1) {
  5431. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5432. }
  5433. }
  5434. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5435. // $query = $this->db->query($sql);
  5436. // $info_list = $query->result_array();
  5437. // $sql_two = "select title,id from crowd_warehouse";
  5438. // $query_two = $this->db->query($sql_two);
  5439. // $warehouse_list = $query_two->result_array();
  5440. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5441. // foreach ($info_list as $value)
  5442. // {
  5443. // if(isset($warehouse_arr[$value['warehouse']])){
  5444. // $warehouse = $warehouse_arr[$value['warehouse']];
  5445. // }else{
  5446. // $warehouse = [
  5447. // 'id'=>0,
  5448. // 'title'=>"异常",
  5449. // ];
  5450. // }
  5451. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5452. // $number = $value['number'];$ftime = time()-15*24*3600;
  5453. // if($c < 1)
  5454. // {
  5455. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5456. // }
  5457. // }
  5458. $listdata = array_slice($list, $start, $perpage);
  5459. $total = count($list);
  5460. $pagenum = ceil($total / $perpage);
  5461. $over = $total - ($start + $perpage);
  5462. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5463. echo json_encode($rows);
  5464. exit;
  5465. }
  5466. if (isset($post['s'])) {
  5467. $id_arr = $this->input->post('s');
  5468. $id_arr = explode(',', trim($id_arr, ','));
  5469. if (!$id_arr) {
  5470. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5471. exit;
  5472. }
  5473. //循环删除记录
  5474. foreach ($id_arr as $v) {
  5475. $dd = $this->whlabel->read($v);
  5476. if (!isset($dd['id'])) {
  5477. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5478. exit;
  5479. }
  5480. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5481. if (isset($zt[0])) {
  5482. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5483. exit;
  5484. }
  5485. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5486. foreach ($deldd as $vv) {
  5487. $this->whlabel->remove($vv['id']);
  5488. }
  5489. }
  5490. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5491. exit;
  5492. }
  5493. $this->_Template('whlabel_error', $this->data);
  5494. }
  5495. public function _errorexcel()
  5496. {
  5497. $post = $this->input->post(NULL, TRUE);
  5498. if (isset($_GET['page'])) {
  5499. $page = $this->input->get('page', true);
  5500. $perpage = $this->input->get('perpage', true);
  5501. $sku = $this->input->get('sku', true);
  5502. $warehouse = $this->input->get('warehouse', true);
  5503. $ktime = $this->input->get('ktime', true);
  5504. $jtime = $this->input->get('jtime', true);
  5505. $ktime = strtotime($ktime);
  5506. $jtime = strtotime($jtime);
  5507. $where = "sku != 'Preset'";
  5508. $gj = '';
  5509. if ($sku) {
  5510. $where .= " and sku like '%$sku%'";
  5511. } else {
  5512. if ($ktime && $jtime) {
  5513. $gj = " and time > '$ktime' and time < '$jtime'";
  5514. }
  5515. }
  5516. if ($warehouse) {
  5517. $where .= " and warehouse = '$warehouse'";
  5518. }
  5519. //数据排序
  5520. $order_str = "id desc";
  5521. if (empty($page)) {
  5522. $start = 0;
  5523. $perpage = 1;
  5524. } else {
  5525. $start = ($page - 1) * $perpage;
  5526. }
  5527. //取得信息列表
  5528. $rows = array();
  5529. $list = array();
  5530. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5531. foreach ($info_list as $value) {
  5532. $warehouse = $this->warehouse->read($value['warehouse']);
  5533. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5534. $number = $value['number'];
  5535. $ftime = time() - 15 * 24 * 3600;
  5536. if ($c < 1) {
  5537. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5538. }
  5539. }
  5540. $title = "0库存汇总";
  5541. $titlename = "<table border=1>
  5542. <tr align='center'>
  5543. <td>仓库</td>
  5544. <td>SKU</td>
  5545. <td>产品</td>
  5546. <td>当前库存</td>
  5547. </tr>
  5548. </table>";
  5549. $filename = $title . ".xls";
  5550. $tail = "";
  5551. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5552. }
  5553. }
  5554. /**
  5555. *
  5556. *
  5557. * 占单
  5558. *
  5559. *
  5560. **/
  5561. public function _kcyz()
  5562. {
  5563. $post = $this->input->post(NULL, TRUE);
  5564. if (isset($post['warehouse'])) {
  5565. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5566. exit; //不再使用
  5567. $warehouse = $this->input->post('warehouse', true);
  5568. $whlabel = $this->input->post('whlabel', true);
  5569. $id = $this->input->post('id', true);
  5570. $shop = $this->input->post('shop', true);
  5571. $number = $this->input->post('number', true);
  5572. if (!$whlabel || $whlabel == '|') {
  5573. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5574. exit;
  5575. }
  5576. $pp = explode('|', trim($whlabel, '|'));
  5577. $x = 0;
  5578. $save = array();
  5579. foreach ($pp as $va) {
  5580. $num = explode('-', $va);
  5581. if ($number) {
  5582. $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 = '')"); //通用
  5583. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5584. } else {
  5585. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5586. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5587. }
  5588. $x++;
  5589. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5590. $save[] = $x - 1;
  5591. continue; //提前先加X不然出错,所以要减1
  5592. }
  5593. }
  5594. if (isset($save[0])) {
  5595. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5596. exit;
  5597. } else {
  5598. echo json_encode(array('success' => true));
  5599. exit;
  5600. }
  5601. }
  5602. }
  5603. public function _db()
  5604. {
  5605. $post = $this->input->post(NULL, TRUE);
  5606. if (isset($post['page'])) {
  5607. $page = $this->input->post('page', true);
  5608. $perpage = $this->input->post('perpage', true);
  5609. $sku = $this->input->post('sku', true);
  5610. $number = $this->input->post('number', true);
  5611. $warehouse = $this->input->post('warehouse', true);
  5612. $purchase = $this->input->post('purchase', true);
  5613. $orderinfo = $this->input->post('orderinfo', true);
  5614. $waybill = $this->input->post('waybill', true);
  5615. $category = $this->input->post('category', true);
  5616. $size = $this->input->post('size', true);
  5617. $grade = $this->input->post('grade', true);
  5618. $color = $this->input->post('color', true);
  5619. $lowe = $this->input->post('lowe', true);
  5620. $state = $this->input->post('state', true);
  5621. $label = $this->input->post('label', true);
  5622. $timetk = $this->input->post('timetkk', true);
  5623. $timetj = $this->input->post('timetjj', true);
  5624. $timetk = strtotime($timetk);
  5625. $timetj = strtotime($timetj);
  5626. $where = "dbtime > 0";
  5627. if ($timetk && $timetj) {
  5628. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5629. }
  5630. if ($sku) {
  5631. $where .= " and sku = '$sku'";
  5632. }
  5633. if ($warehouse) {
  5634. $where .= " and warehouse = '$warehouse'";
  5635. if ($warehouse == 12) {
  5636. $w = 'specialstock';
  5637. } else {
  5638. $w = 'whlabel';
  5639. }
  5640. }
  5641. if ($purchase) {
  5642. $where .= " and purchase = '$purchase'";
  5643. }
  5644. if ($category) {
  5645. $where .= " and features like '%-$category-%'";
  5646. }
  5647. if ($size) {
  5648. $where .= " and features like '%-$size-%'";
  5649. }
  5650. if ($grade) {
  5651. $where .= " and features like '%-$grade-%'";
  5652. }
  5653. if ($color) {
  5654. $where .= " and features like '%-$color-%'";
  5655. }
  5656. if ($lowe) {
  5657. $where .= " and features like '%-$lowe-%'";
  5658. }
  5659. if ($state != '') {
  5660. $where .= " and state = '$state'";
  5661. }
  5662. //数据排序
  5663. $order_str = "dbtime desc";
  5664. if (empty($page)) {
  5665. $start = 0;
  5666. $perpage = 1;
  5667. } else {
  5668. $start = ($page - 1) * $perpage;
  5669. }
  5670. //取得信息列表
  5671. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5672. foreach ($info_list as $key => $value) {
  5673. $warehouse = $this->$w->read($value['warehouse']);
  5674. $info_list[$key]['warehouse'] = $warehouse['title'];
  5675. $purchase = $this->purchase->read($value['purchase']);
  5676. $info_list[$key]['purchase'] = $purchase['title'];
  5677. if ($value['enter'] != 0) {
  5678. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5679. } else {
  5680. $info_list[$key]['enter'] = "";
  5681. }
  5682. if ($value['dbtime'] != 0) {
  5683. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5684. } else {
  5685. $info_list[$key]['dbtime'] = "";
  5686. }
  5687. if ($value['state'] == 0) {
  5688. $info_list[$key]['state'] = "在库";
  5689. } else if ($value['state'] == 1) {
  5690. $info_list[$key]['state'] = "出库";
  5691. } else if ($value['state'] == 2) {
  5692. $info_list[$key]['state'] = "退库";
  5693. } else if ($value['state'] == 3) {
  5694. $info_list[$key]['state'] = "调拨中";
  5695. } else if ($value['state'] == 4) {
  5696. $info_list[$key]['state'] = "再加工";
  5697. } else if ($value['state'] == 5) {
  5698. $info_list[$key]['state'] = "维修中";
  5699. } else if ($value['state'] == 6) {
  5700. $info_list[$key]['state'] = "盘亏";
  5701. } else if ($value['state'] == 7) {
  5702. $info_list[$key]['state'] = "更换标签";
  5703. } else if ($value['state'] == 8) {
  5704. $info_list[$key]['state'] = "其它";
  5705. } else if ($value['state'] == 9) {
  5706. $info_list[$key]['state'] = "预设";
  5707. }
  5708. }
  5709. $total = $this->whlabel->find_count($where);
  5710. $pagenum = ceil($total / $perpage);
  5711. $over = $total - ($start + $perpage);
  5712. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5713. echo json_encode($rows);
  5714. exit;
  5715. }
  5716. if (isset($post['outsku'])) {
  5717. $time = time();
  5718. $cz = $this->input->post('cz', true);
  5719. $label = $this->input->post('outsku', true);
  5720. $sl = $this->input->post('sl', true);
  5721. $num = $this->input->post('num', true);
  5722. //$warehouse = $this->input->post('warehouse',true);
  5723. if (!$sl) {
  5724. $sl = 1;
  5725. }
  5726. if (!$warehouse) {
  5727. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5728. exit;
  5729. }
  5730. $dblabel = $this->whlabellabel->get_label($label);
  5731. if ($dblabel) {
  5732. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5733. if (count($data) < 1) {
  5734. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5735. exit;
  5736. }
  5737. if (count($data) < $num) {
  5738. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5739. exit;
  5740. }
  5741. for ($i = 0; $i < $sl; $i++) {
  5742. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5743. }
  5744. echo json_encode(array('success' => true));
  5745. exit;
  5746. } else {
  5747. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5748. exit;
  5749. }
  5750. }
  5751. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5752. $this->_Template('whlabel_db', $this->data);
  5753. }
  5754. public function _dbrk()
  5755. {
  5756. $post = $this->input->post(NULL, TRUE);
  5757. if (isset($post['page'])) {
  5758. $page = $this->input->post('page', true);
  5759. $perpage = $this->input->post('perpage', true);
  5760. $sku = $this->input->post('sku', true);
  5761. $number = $this->input->post('number', true);
  5762. $warehouse = $this->input->post('warehouse', true);
  5763. $purchase = $this->input->post('purchase', true);
  5764. $orderinfo = $this->input->post('orderinfo', true);
  5765. $waybill = $this->input->post('waybill', true);
  5766. $category = $this->input->post('category', true);
  5767. $size = $this->input->post('size', true);
  5768. $grade = $this->input->post('grade', true);
  5769. $color = $this->input->post('color', true);
  5770. $lowe = $this->input->post('lowe', true);
  5771. $state = $this->input->post('state', true);
  5772. $label = $this->input->post('label', true);
  5773. $ctime = $this->input->post('ctime', true);
  5774. $timetk = $this->input->post('timetkk', true);
  5775. $timetj = $this->input->post('timetjj', true);
  5776. $timetk = strtotime($timetk);
  5777. $timetj = strtotime($timetj);
  5778. $where = "dbtime > 0";
  5779. if ($timetk && $timetj) {
  5780. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5781. }
  5782. if ($sku) {
  5783. $where .= " and sku = '$sku'";
  5784. }
  5785. if ($warehouse) {
  5786. $where .= " and warehouse = '$warehouse'";
  5787. }
  5788. if ($purchase) {
  5789. $where .= " and purchase = '$purchase'";
  5790. }
  5791. if ($category) {
  5792. $where .= " and features like '%-$category-%'";
  5793. }
  5794. if ($size) {
  5795. $where .= " and features like '%-$size-%'";
  5796. }
  5797. if ($grade) {
  5798. $where .= " and features like '%-$grade-%'";
  5799. }
  5800. if ($color) {
  5801. $where .= " and features like '%-$color-%'";
  5802. }
  5803. if ($lowe) {
  5804. $where .= " and features like '%-$lowe-%'";
  5805. }
  5806. if ($state != '') {
  5807. $where .= " and state = '$state'";
  5808. }
  5809. //数据排序
  5810. $order_str = "dbtime desc";
  5811. if (empty($page)) {
  5812. $start = 0;
  5813. $perpage = 1;
  5814. } else {
  5815. $start = ($page - 1) * $perpage;
  5816. }
  5817. //取得信息列表
  5818. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5819. foreach ($info_list as $key => $value) {
  5820. $warehouse = $this->warehouse->read($value['warehouse']);
  5821. $info_list[$key]['warehouse'] = $warehouse['title'];
  5822. $purchase = $this->purchase->read($value['purchase']);
  5823. $info_list[$key]['purchase'] = $purchase['title'];
  5824. if ($value['enter'] != 0) {
  5825. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5826. } else {
  5827. $info_list[$key]['enter'] = "";
  5828. }
  5829. if ($value['dbtime'] != 0) {
  5830. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5831. } else {
  5832. $info_list[$key]['dbtime'] = "";
  5833. }
  5834. if ($value['state'] == 0) {
  5835. $info_list[$key]['state'] = "在库";
  5836. } else if ($value['state'] == 1) {
  5837. $info_list[$key]['state'] = "出库";
  5838. } else if ($value['state'] == 2) {
  5839. $info_list[$key]['state'] = "退库";
  5840. } else if ($value['state'] == 3) {
  5841. $info_list[$key]['state'] = "调拨中";
  5842. } else if ($value['state'] == 4) {
  5843. $info_list[$key]['state'] = "再加工";
  5844. } else if ($value['state'] == 5) {
  5845. $info_list[$key]['state'] = "维修中";
  5846. } else if ($value['state'] == 6) {
  5847. $info_list[$key]['state'] = "盘亏";
  5848. } else if ($value['state'] == 7) {
  5849. $info_list[$key]['state'] = "更换标签";
  5850. } else if ($value['state'] == 8) {
  5851. $info_list[$key]['state'] = "其它";
  5852. } else if ($value['state'] == 9) {
  5853. $info_list[$key]['state'] = "预设";
  5854. }
  5855. }
  5856. $total = $this->whlabel->find_count($where);
  5857. $pagenum = ceil($total / $perpage);
  5858. $over = $total - ($start + $perpage);
  5859. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5860. echo json_encode($rows);
  5861. exit;
  5862. }
  5863. if (isset($post['rsku'])) {
  5864. $cz = $this->input->post('cz', true);
  5865. $label = $this->input->post('rsku', true);
  5866. $sl = $this->input->post('sl', true);
  5867. $warehouse = $this->input->post('warehouse', true);
  5868. if (!$sl) {
  5869. $sl = 1;
  5870. }
  5871. if (!$warehouse) {
  5872. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5873. exit;
  5874. }
  5875. $dblabel = $this->whlabellabel->get_label($label);
  5876. if ($dblabel) {
  5877. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5878. if (count($data) < 1) {
  5879. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5880. exit;
  5881. }
  5882. if ($sl > count($data)) {
  5883. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5884. exit;
  5885. }
  5886. $time = time();
  5887. for ($i = 0; $i < $sl; $i++) {
  5888. $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']);
  5889. }
  5890. echo json_encode(array('success' => true));
  5891. exit;
  5892. } else {
  5893. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5894. exit;
  5895. }
  5896. }
  5897. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5898. $this->_Template('whlabel_dbrk', $this->data);
  5899. }
  5900. public function _whlabelczdc()
  5901. {
  5902. if (isset($_GET['excel'])) {
  5903. //数据排序
  5904. $order_str = "id desc";
  5905. if (empty($page)) {
  5906. $start = 0;
  5907. $perpage = 1;
  5908. } else {
  5909. $start = ($page - 1) * $perpage;
  5910. }
  5911. $state = $this->input->get('state', true);
  5912. $sku = $this->input->get('sku', true);
  5913. $ctime = $this->input->get('ctime', true);
  5914. $category = $this->input->get('category', true);
  5915. $size = $this->input->get('size', true);
  5916. $grade = $this->input->get('grade', true);
  5917. $color = $this->input->get('color', true);
  5918. $lowe = $this->input->get('lowe', true);
  5919. $timetk = $this->input->get('timetkk', true);
  5920. $timetj = $this->input->get('timetjj', true);
  5921. $timetk = strtotime($timetk);
  5922. $timetj = strtotime($timetj);
  5923. $where = "dbtime > 0";
  5924. if ($timetk && $timetj) {
  5925. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5926. }
  5927. if ($category) {
  5928. $where .= " and features like '%-$category-%'";
  5929. }
  5930. if ($size) {
  5931. $where .= " and features like '%-$size-%'";
  5932. }
  5933. if ($grade) {
  5934. $where .= " and features like '%-$grade-%'";
  5935. }
  5936. if ($color) {
  5937. $where .= " and features like '%-$color-%'";
  5938. }
  5939. if ($lowe) {
  5940. $where .= " and features like '%-$lowe-%'";
  5941. }
  5942. //取得信息列表
  5943. $info_list = $this->whlabel->find_all($where, '*');
  5944. $rows = array();
  5945. $list = array();
  5946. foreach ($info_list as $key => $value) {
  5947. $rows[$value['sku']] = $value; //所有数据sku
  5948. }
  5949. foreach ($rows as $value) {
  5950. $warehouse = $this->warehouse->read($value['warehouse']);
  5951. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5952. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5953. if ($value['orderinfo'] == 0) {
  5954. $info_list[$key]['orderinfo'] = "";
  5955. }
  5956. if ($value['waybill'] == 0) {
  5957. $info_list[$key]['waybill'] = "";
  5958. }
  5959. if ($value['state'] == 0) {
  5960. $value['state'] = "在库";
  5961. } else if ($value['state'] == 3) {
  5962. $value['state'] = "调拨中";
  5963. }
  5964. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5965. }
  5966. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5967. $titlename = "<table border=1>
  5968. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5969. <tr align='center'>
  5970. <td>SKU</td>
  5971. <td>产品</td>
  5972. <td>调拨数量</td>
  5973. <td>入库数量</td>
  5974. </tr>
  5975. </table>";
  5976. $filename = $title . ".xls";
  5977. $tail = "";
  5978. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5979. }
  5980. }
  5981. public function _print($arg_array)
  5982. {
  5983. if (isset($_SESSION['api'])) {
  5984. $user = $this->user->get_api($_SESSION['api']);
  5985. $usp = $user;
  5986. $fgshop = "";
  5987. $sid = "";
  5988. $wid = "";
  5989. $wtype = "";
  5990. $usersp = explode('|', trim($user['shop'], '|'));
  5991. $userwh = explode('|', trim($user['warehouse'], '|'));
  5992. foreach ($usersp as $value) {
  5993. $fgshop .= " shop = " . $value . " or";
  5994. $sid .= " id = " . $value . " or";
  5995. }
  5996. foreach ($userwh as $value) {
  5997. $wid .= " id = " . $value . " or";
  5998. $wtype .= " type = " . $value . " or";
  5999. }
  6000. }
  6001. $post = $this->input->post(NULL, TRUE);
  6002. if (isset($post['tmsku'])) {
  6003. $tmsku = $this->input->post('tmsku', true);
  6004. if (is_numeric($tmsku)) {
  6005. $yyh = $this->whlabellabel->get_label($tmsku);
  6006. } else {
  6007. $yyh = $this->whlabellabel->get_sku($tmsku);
  6008. if(empty($yyh)){
  6009. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6010. if($r['code'] == -1 ){
  6011. echo json_encode(array('success' => false));
  6012. exit;
  6013. }else{
  6014. echo json_encode(array('features' => $r['data'], 'success' => true));
  6015. exit;
  6016. }
  6017. }
  6018. }
  6019. if ($yyh) {
  6020. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6021. exit;
  6022. } else {
  6023. echo json_encode(array('success' => false));
  6024. exit;
  6025. }
  6026. }
  6027. $classid = $this->classid->sku();
  6028. $pm = $classid;
  6029. $scsku = $classid;
  6030. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6031. if (isset($post['warehouse'])) {
  6032. if ($post['warehouse']) {
  6033. $list = array();
  6034. $num = "";
  6035. $title = "";
  6036. $features = "";
  6037. $order = 0;
  6038. $post['shop'] = '';
  6039. $brand = $this->input->post('brand', true);
  6040. if ($brand != '0,') {
  6041. $b = $this->brand->read(rtrim($brand, ','));
  6042. if ($b) {
  6043. $post['shop'] = str_replace('|', ',', $b['shop']);
  6044. }
  6045. }
  6046. $post['details'] = $this->input->post('details', true); //打印数量
  6047. $xbqnum = $this->input->post('xbqnum', true);
  6048. $post['purchase'] = $this->input->post('purchase', true);
  6049. $post['warehouse'] = $this->input->post('warehouse', true);
  6050. $post['purchase'] = $this->input->post('purchase', true);
  6051. $post['retreatwarehouse'] = $post['warehouse'];
  6052. $post['cpbz'] = $this->input->post('cpbz', true);
  6053. $post['state'] = 9;
  6054. $category = $this->input->post('category', true);
  6055. $list['category'] = $category;
  6056. $list['hairtype'] = $this->input->post('hairtype', true);
  6057. $list['grade'] = $this->input->post('grade', true);
  6058. $size = $this->input->post('size', true);
  6059. $list['size'] = rtrim($size, ',');
  6060. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6061. $list['extension'] = $this->input->post('extension', true);
  6062. if ($category == 1297) {
  6063. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6064. }
  6065. if ($category == 1702) {
  6066. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6067. $list['syother'] = $this->input->post('syother', true);
  6068. }
  6069. if ($category == 133) {
  6070. $list['fittype'] = $this->input->post('fittype', true);
  6071. $list['acother'] = $this->input->post('acother', true);
  6072. }
  6073. $list['color'] = $this->input->post('color', true);
  6074. $list['lowe'] = $this->input->post('lowe', true);
  6075. if ($category == 127) {
  6076. $list['type'] = $this->input->post('type', true);
  6077. $list['headroad'] = $this->input->post('headroad', true);
  6078. $list['density'] = $this->input->post('density', true);
  6079. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6080. $list['lacesize'] = $this->input->post('lacesize', true);
  6081. }
  6082. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6083. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6084. }
  6085. if ($category == 128) {
  6086. $list['lacetype'] = $this->input->post('lacetype', true);
  6087. $list['haircap'] = $this->input->post('haircap', true);
  6088. $list['density'] = $this->input->post('density', true);
  6089. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6090. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6091. $list['wigother'] = $this->input->post('wigother', true);
  6092. $list['wigother1'] = $this->input->post('wigother1', true);
  6093. $list['wigother2'] = $this->input->post('wigother2', true);
  6094. $list['product_related'] = $this->input->post('product_related', true);
  6095. }
  6096. if ($category == 129) {
  6097. $list['wide'] = $this->input->post('wide', true);
  6098. }
  6099. if ($category == 131) {
  6100. $list['gifttype'] = $this->input->post('gifttype', true);
  6101. $list['giftother'] = $this->input->post('giftother', true);
  6102. }
  6103. if ($category == 134) {
  6104. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6105. }
  6106. if ($category == 1297) {
  6107. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6108. $list['sywigother'] = $this->input->post('sywigother', true);
  6109. }
  6110. if ($category == 130 || $category == 133 || $category == 1702) {
  6111. $list['items'] = $this->input->post('items', true);
  6112. $list['weight'] = $this->input->post('weight', true);
  6113. }
  6114. if ($category == 1702) {
  6115. $list['syhairther'] = $this->input->post('syhairther', true);
  6116. }
  6117. if($category == 130){
  6118. $list['jfother'] = $this->input->post('jfother', true);
  6119. }
  6120. foreach ($list as $k => $v) {
  6121. if ($v != 0) {
  6122. $num .= $v;
  6123. $features .= $v . '-';
  6124. $post[$k] = $v;
  6125. $typeclass = $this->typeclass->read($v);
  6126. if (isset($pm[$typeclass['classid']])) {
  6127. if (stripos($typeclass['zh'], '|') !== false) {
  6128. $exzh = explode('|', $typeclass['zh']);
  6129. $pm[$typeclass['classid']] = $exzh[0];
  6130. } else {
  6131. $pm[$typeclass['classid']] = $typeclass['zh'];
  6132. }
  6133. }
  6134. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6135. if ($k != 'size') {
  6136. $title .= $typeclass['title'] . " ";
  6137. }
  6138. }
  6139. }
  6140. $typeclass = $this->typeclass->read($list['size']);
  6141. $title .= $typeclass['title'];
  6142. $time = time();
  6143. $post['title'] = rtrim($title, ' ');
  6144. $post['number'] = $num;
  6145. $post['features'] = '-' . $features;
  6146. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6147. $featurespp = explode('-', trim($featurespp, '-'));
  6148. if (isset($featurespp[5])) {
  6149. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6150. } else {
  6151. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6152. }
  6153. $post['enter'] = $time;
  6154. $post['time'] = $time; //操作时间
  6155. $scsku = implode("-", $scsku);
  6156. $zh = implode(" ", $pm);
  6157. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6158. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6159. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6160. $post['sku'] = $bqsku;
  6161. $label = time() . rand(0, 9);
  6162. $post['label'] = $label;
  6163. $cpid = $this->whlabellabel->find_count();
  6164. $post['cpid'] = $cpid + 1;
  6165. $cpid = $post['cpid'];
  6166. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6167. //if($whlabelbarcode)
  6168. //{
  6169. //$post['label'] = $whlabelbarcode['label'];
  6170. //if(!$this->whlabellabel->insert($post))
  6171. //{
  6172. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6173. //}
  6174. //}
  6175. //else
  6176. //{
  6177. $this->db->trans_begin();
  6178. $this->whlabellabel->insert($post);
  6179. //$this->whlabelbarcode->insert($post);
  6180. if ($this->db->trans_status() === TRUE) {
  6181. $this->db->trans_commit();
  6182. } else {
  6183. $this->db->trans_rollback();
  6184. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6185. exit;
  6186. }
  6187. //}
  6188. $warehouse_name = "";
  6189. $warehouse = $post['warehouse'];
  6190. if($warehouse == 12){
  6191. $warehouse_name = "特殊库存库";
  6192. }
  6193. // if($warehouse == 13){
  6194. // $warehouse_name = "许昌仓";
  6195. // }
  6196. // if($warehouse == 5){
  6197. // $warehouse_name = "美国店";
  6198. // }
  6199. // if($warehouse == 16){
  6200. // $warehouse_name = "定制头套仓";
  6201. // }
  6202. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6203. if(!empty($warehouse_name)){
  6204. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6205. }
  6206. $purchase = $this->purchase->read($post['purchase']);
  6207. 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));
  6208. exit; //特殊仓目前不需要仓库选项
  6209. }
  6210. }
  6211. if (isset($_SESSION['api'])) {
  6212. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6213. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6214. $this->data['wlshop'] = $wlshop;
  6215. $this->data['warehouse'] = $warehouse;
  6216. }
  6217. $whlabelwz = $this->whlabelwz->find_all();
  6218. $this->data['whlabelwz'] = $whlabelwz;
  6219. $this->_Template('whlabel_print', $this->data);
  6220. }
  6221. public function _usaprint($arg_array)
  6222. {
  6223. if (isset($_SESSION['api'])) {
  6224. $user = $this->user->get_api($_SESSION['api']);
  6225. $usp = $user;
  6226. $fgshop = "";
  6227. $sid = "";
  6228. $wid = "";
  6229. $wtype = "";
  6230. $usersp = explode('|', trim($user['shop'], '|'));
  6231. $userwh = explode('|', trim($user['warehouse'], '|'));
  6232. foreach ($usersp as $value) {
  6233. $fgshop .= " shop = " . $value . " or";
  6234. $sid .= " id = " . $value . " or";
  6235. }
  6236. foreach ($userwh as $value) {
  6237. $wid .= " id = " . $value . " or";
  6238. $wtype .= " type = " . $value . " or";
  6239. }
  6240. }
  6241. $post = $this->input->post(NULL, TRUE);
  6242. if (isset($post['tmsku'])) {
  6243. $tmsku = $this->input->post('tmsku', true);
  6244. if (is_numeric($tmsku)) {
  6245. $yyh = $this->whlabellabel->get_label($tmsku);
  6246. } else {
  6247. $yyh = $this->whlabellabel->get_sku($tmsku);
  6248. }
  6249. if ($yyh) {
  6250. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6251. exit;
  6252. } else {
  6253. echo json_encode(array('success' => false));
  6254. exit;
  6255. }
  6256. }
  6257. $classid = $this->classid->sku();
  6258. $pm = $classid;
  6259. $scsku = $classid;
  6260. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6261. if (isset($post['warehouse'])) {
  6262. if ($post['warehouse']) {
  6263. $list = array();
  6264. $num = "";
  6265. $title = "";
  6266. $features = "";
  6267. $order = 0;
  6268. $post['shop'] = '';
  6269. $brand = $this->input->post('brand', true);
  6270. if ($brand != '0,') {
  6271. $b = $this->brand->read(rtrim($brand, ','));
  6272. if ($b) {
  6273. $post['shop'] = str_replace('|', ',', $b['shop']);
  6274. }
  6275. }
  6276. $post['details'] = $this->input->post('details', true); //打印数量
  6277. $xbqnum = $this->input->post('xbqnum', true);
  6278. $post['purchase'] = $this->input->post('purchase', true);
  6279. $post['warehouse'] = $this->input->post('warehouse', true);
  6280. $post['purchase'] = $this->input->post('purchase', true);
  6281. $post['retreatwarehouse'] = $post['warehouse'];
  6282. $post['cpbz'] = $this->input->post('cpbz', true);
  6283. $post['state'] = 9;
  6284. $category = $this->input->post('category', true);
  6285. $list['category'] = $category;
  6286. $list['hairtype'] = $this->input->post('hairtype', true);
  6287. $list['grade'] = $this->input->post('grade', true);
  6288. $size = $this->input->post('size', true);
  6289. $list['size'] = rtrim($size, ',');
  6290. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6291. $list['extension'] = $this->input->post('extension', true);
  6292. if ($category == 1297) {
  6293. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6294. }
  6295. if ($category == 1702) {
  6296. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6297. $list['syother'] = $this->input->post('syother', true);
  6298. }
  6299. if ($category == 133) {
  6300. $list['fittype'] = $this->input->post('fittype', true);
  6301. $list['acother'] = $this->input->post('acother', true);
  6302. }
  6303. $list['color'] = $this->input->post('color', true);
  6304. $list['lowe'] = $this->input->post('lowe', true);
  6305. if ($category == 127) {
  6306. $list['type'] = $this->input->post('type', true);
  6307. $list['headroad'] = $this->input->post('headroad', true);
  6308. $list['density'] = $this->input->post('density', true);
  6309. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6310. $list['lacesize'] = $this->input->post('lacesize', true);
  6311. }
  6312. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6313. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6314. }
  6315. if ($category == 128) {
  6316. $list['lacetype'] = $this->input->post('lacetype', true);
  6317. $list['haircap'] = $this->input->post('haircap', true);
  6318. $list['density'] = $this->input->post('density', true);
  6319. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6320. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6321. $list['wigother'] = $this->input->post('wigother', true);
  6322. $list['wigother1'] = $this->input->post('wigother1', true);
  6323. $list['wigother2'] = $this->input->post('wigother2', true);
  6324. $list['product_related'] = $this->input->post('product_related', true);
  6325. }
  6326. if ($category == 129) {
  6327. $list['wide'] = $this->input->post('wide', true);
  6328. }
  6329. if ($category == 131) {
  6330. $list['gifttype'] = $this->input->post('gifttype', true);
  6331. $list['giftother'] = $this->input->post('giftother', true);
  6332. }
  6333. if ($category == 134) {
  6334. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6335. }
  6336. if ($category == 1297) {
  6337. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6338. $list['sywigother'] = $this->input->post('sywigother', true);
  6339. }
  6340. if ($category == 130 || $category == 133 || $category == 1702) {
  6341. $list['items'] = $this->input->post('items', true);
  6342. $list['weight'] = $this->input->post('weight', true);
  6343. }
  6344. if ($category == 1702) {
  6345. $list['syhairther'] = $this->input->post('syhairther', true);
  6346. }
  6347. foreach ($list as $k => $v) {
  6348. if ($v != 0) {
  6349. $num .= $v;
  6350. $features .= $v . '-';
  6351. $post[$k] = $v;
  6352. $typeclass = $this->typeclass->read($v);
  6353. if (isset($pm[$typeclass['classid']])) {
  6354. if (stripos($typeclass['zh'], '|') !== false) {
  6355. $exzh = explode('|', $typeclass['zh']);
  6356. $pm[$typeclass['classid']] = $exzh[0];
  6357. } else {
  6358. $pm[$typeclass['classid']] = $typeclass['zh'];
  6359. }
  6360. }
  6361. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6362. if ($k != 'size') {
  6363. $title .= $typeclass['title'] . " ";
  6364. }
  6365. }
  6366. }
  6367. $typeclass = $this->typeclass->read($list['size']);
  6368. $title .= $typeclass['title'];
  6369. $time = time();
  6370. $post['title'] = rtrim($title, ' ');
  6371. $post['number'] = $num;
  6372. $post['features'] = '-' . $features;
  6373. $fp = $this->whlabel->get_features($post['features']);
  6374. if (!$fp) {
  6375. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6376. exit;
  6377. }
  6378. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6379. $featurespp = explode('-', trim($featurespp, '-'));
  6380. if (isset($featurespp[5])) {
  6381. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6382. } else {
  6383. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6384. }
  6385. $post['enter'] = $time;
  6386. $post['time'] = $time; //操作时间
  6387. $scsku = implode("-", $scsku);
  6388. $zh = implode(" ", $pm);
  6389. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6390. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6391. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6392. $post['sku'] = $fp['sku'];
  6393. $post['label'] = $fp['sku'];
  6394. $cpid = $this->whlabellabel->find_count();
  6395. $post['cpid'] = $cpid + 1;
  6396. $cpid = $post['cpid'];
  6397. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6398. //if($whlabelbarcode)
  6399. //{
  6400. //$post['label'] = $whlabelbarcode['label'];
  6401. //if(!$this->whlabellabel->insert($post))
  6402. //{
  6403. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6404. //}
  6405. //}
  6406. //else
  6407. //{
  6408. $this->db->trans_begin();
  6409. $this->whlabellabel->insert($post);
  6410. //$this->whlabelbarcode->insert($post);
  6411. if ($this->db->trans_status() === TRUE) {
  6412. $this->db->trans_commit();
  6413. } else {
  6414. $this->db->trans_rollback();
  6415. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6416. exit;
  6417. }
  6418. //}
  6419. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6420. $purchase = $this->purchase->read($post['purchase']);
  6421. 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));
  6422. exit; //特殊仓目前不需要仓库选项
  6423. }
  6424. }
  6425. if (isset($_SESSION['api'])) {
  6426. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6427. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6428. $this->data['wlshop'] = $wlshop;
  6429. $this->data['warehouse'] = $warehouse;
  6430. }
  6431. $whlabelwz = $this->whlabelwz->find_all();
  6432. $this->data['whlabelwz'] = $whlabelwz;
  6433. $this->_Template('whlabel_usaprint', $this->data);
  6434. }
  6435. public function _printrk($arg_array)
  6436. {
  6437. $prc = array();
  6438. $purchase = $this->purchase->find_all();
  6439. foreach ($purchase as $k => $v) {
  6440. $prc[$v['id']] = $v['title'];
  6441. }
  6442. $post = $this->input->post(NULL, TRUE);
  6443. if (isset($post['page'])) {
  6444. $page = $this->input->post('page', true);
  6445. $perpage = $this->input->post('perpage', true);
  6446. $sku = $this->input->post('sku', true);
  6447. $bs = $this->input->post('bs', true);
  6448. $number = $this->input->post('number', true);
  6449. $warehouse = $this->input->post('warehouse', true);
  6450. $purchase = $this->input->post('purchase', true);
  6451. $orderinfo = $this->input->post('orderinfo', true);
  6452. $waybill = $this->input->post('waybill', true);
  6453. $category = $this->input->post('category', true);
  6454. $size = $this->input->post('size', true);
  6455. $grade = $this->input->post('grade', true);
  6456. $color = $this->input->post('color', true);
  6457. $lowe = $this->input->post('lowe', true);
  6458. $state = $this->input->post('state', true);
  6459. $label = $this->input->post('label', true);
  6460. $timetk = $this->input->post('ktime', true);
  6461. $timetj = $this->input->post('jtime', true);
  6462. $timetk = strtotime($timetk);
  6463. $timetj = strtotime($timetj);
  6464. $where = "1=1 ";
  6465. if ($timetk && $timetj) {
  6466. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6467. }
  6468. if ($sku) {
  6469. $where .= " and sku = '$sku'";
  6470. }
  6471. if ($bs != '') {
  6472. $where .= " and bs = '$bs'";
  6473. }
  6474. if ($number) {
  6475. $where .= " and number = '$number'";
  6476. }
  6477. if ($warehouse) {
  6478. $where .= " and warehouse = '$warehouse'";
  6479. }
  6480. if ($purchase) {
  6481. $where .= " and purchase = '$purchase'";
  6482. }
  6483. if ($orderinfo) {
  6484. $where .= " and orderinfo = '$orderinfo'";
  6485. }
  6486. if ($waybill) {
  6487. $where .= " and waybill = '$waybill'";
  6488. }
  6489. if ($category) {
  6490. $where .= " and features like '%-$category-%'";
  6491. }
  6492. if ($size) {
  6493. $where .= " and features like '%-$size-%'";
  6494. }
  6495. if ($grade) {
  6496. $where .= " and features like '%-$grade-%'";
  6497. }
  6498. if ($color) {
  6499. $where .= " and features like '%-$color-%'";
  6500. }
  6501. if ($lowe) {
  6502. $where .= " and features like '%-$lowe-%'";
  6503. }
  6504. if ($label) {
  6505. $where .= " and label = '$label'";
  6506. }
  6507. if ($state || $state == 0) {
  6508. $where .= " and state = '$state'";
  6509. }
  6510. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6511. //数据排序
  6512. $order_str = "enter desc";
  6513. if (empty($page)) {
  6514. $start = 0;
  6515. $perpage = 1;
  6516. } else {
  6517. $start = ($page - 1) * $perpage;
  6518. }
  6519. //取得信息列表
  6520. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6521. foreach ($info_list as $key => $value) {
  6522. $warehouse = $this->warehouse->read($value['warehouse']);
  6523. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6524. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6525. if ($value['state'] == 0) {
  6526. $info_list[$key]['state'] = "在库";
  6527. } else if ($value['state'] == 1) {
  6528. $info_list[$key]['state'] = "出库";
  6529. } else if ($value['state'] == 2) {
  6530. $info_list[$key]['state'] = "退库";
  6531. } else if ($value['state'] == 3) {
  6532. $info_list[$key]['state'] = "调拨中";
  6533. } else if ($value['state'] == 4) {
  6534. $info_list[$key]['state'] = "再加工";
  6535. } else if ($value['state'] == 5) {
  6536. $info_list[$key]['state'] = "维修中";
  6537. } else if ($value['state'] == 6) {
  6538. $info_list[$key]['state'] = "盘亏";
  6539. } else if ($value['state'] == 7) {
  6540. $info_list[$key]['state'] = "更换标签";
  6541. } else if ($value['state'] == 8) {
  6542. $info_list[$key]['state'] = "其它";
  6543. } else if ($value['state'] == 9) {
  6544. $info_list[$key]['state'] = "预设";
  6545. } else if ($value['state'] == 10) {
  6546. $info_list[$key]['state'] = "美店零售";
  6547. }
  6548. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6549. }
  6550. $total = $this->$ck->find_count($where);
  6551. $pagenum = ceil($total / $perpage);
  6552. $over = $total - ($start + $perpage);
  6553. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6554. echo json_encode($rows);
  6555. exit;
  6556. }
  6557. if (isset($post['tmsku'])) {
  6558. $time = time();
  6559. $tmsku = $this->input->post('tmsku', true);
  6560. //$post['shop'] = $this->input->post('shop',true);
  6561. $num = $this->input->post('num', true);
  6562. $rktype = $this->input->post('rktype', true);
  6563. if ($num > 200) {
  6564. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6565. exit;
  6566. }
  6567. if (!$rktype) {
  6568. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6569. }
  6570. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6571. /**
  6572. $wz = array();
  6573. foreach ($rk as $key=>$value)
  6574. {
  6575. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6576. }
  6577. if(count($wz) > 1)
  6578. {
  6579. $wz = array_values($wz);
  6580. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6581. }
  6582. **/
  6583. if (isset($rk[0]['purchase'])) {
  6584. $rk = $rk[0];
  6585. $j = 0;
  6586. $post['purchase'] = $rk['purchase'];
  6587. $post['warehouse'] = $rk['warehouse'];
  6588. $post['retreatwarehouse'] = $rk['warehouse'];
  6589. $post['sku'] = $rk['sku'];
  6590. $post['number'] = $rk['number'];
  6591. $post['features'] = $rk['features'];
  6592. $post['title'] = $rk['title'];
  6593. $post['enter'] = $time;
  6594. $post['time'] = $time;
  6595. $post['bs'] = 1;
  6596. $post['shop'] = $rk['shop'];
  6597. $post['details'] = $rk['details'];
  6598. $post['cpid'] = $rk['cpid'];
  6599. $post['cpbz'] = $rk['cpbz'];
  6600. $post['rktype'] = $rktype;
  6601. $warehouse = $this->warehouse->read($rk['warehouse']);
  6602. if ($warehouse['bdck'] == '') {
  6603. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6604. exit;
  6605. } else {
  6606. $bdck = $warehouse['bdck'];
  6607. }
  6608. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6609. if (isset($pdwz['details'])) {
  6610. if ($pdwz['details'] != $post['details']) {
  6611. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6612. }else{
  6613. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6614. exit;
  6615. }
  6616. }
  6617. }
  6618. $post['featurespp'] = $rk['featurespp'];
  6619. if ($post['warehouse'] == '5') {
  6620. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6621. if ($yza) {
  6622. if ($post['features'] != $yza[0]['features']) {
  6623. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6624. exit;
  6625. }
  6626. }
  6627. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6628. if ($yzb) {
  6629. if ($post['sku'] != $yzb[0]['sku']) {
  6630. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6631. exit;
  6632. }
  6633. }
  6634. }
  6635. for ($i = 0; $i < $num; $i++) {
  6636. $post['label'] = time() . rand(100, 999) . $i;
  6637. if ($this->$bdck->insert($post)) {
  6638. $j++;
  6639. }
  6640. }
  6641. /**
  6642. if($post['warehouse'] != 12)
  6643. {
  6644. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6645. }
  6646. **/
  6647. $this->whlabelscanlog->insert([
  6648. 'shop'=>$rk['shop'],
  6649. 'type'=>1,
  6650. 'purchase'=>$rk['purchase'],
  6651. 'sku'=>$rk['sku'],
  6652. 'features'=>$rk['features'],
  6653. 'title'=>$rk['title'],
  6654. 'label'=>$rk['label'],
  6655. 'warehouse'=>$rk['warehouse'],
  6656. 'wlid'=>$rk['id'],
  6657. 'num'=>$num,
  6658. 'addtime'=>time()
  6659. ]);
  6660. if ($j == $num) {
  6661. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6662. exit;
  6663. } else {
  6664. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6665. exit;
  6666. }
  6667. } else {
  6668. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6669. exit;
  6670. }
  6671. }
  6672. $this->_Template('whlabel_printrk', $this->data);
  6673. }
  6674. public function _printxzrk($arg_array)
  6675. {
  6676. $post = $this->input->post(NULL, TRUE);
  6677. if (isset($post['wzid'])) {
  6678. $time = time();
  6679. $id = $this->input->post('wzid', true);
  6680. //$post['shop'] = $this->input->post('shop',true);
  6681. $num = 1;
  6682. $rk = $this->whlabellabel->read($id);
  6683. if (isset($rk['purchase'])) {
  6684. $x = 0;
  6685. $post['purchase'] = $rk['purchase'];
  6686. $post['warehouse'] = $rk['warehouse'];
  6687. $post['retreatwarehouse'] = $rk['warehouse'];
  6688. $post['sku'] = $rk['sku'];
  6689. $post['number'] = $rk['number'];
  6690. $post['features'] = $rk['features'];
  6691. $post['title'] = $rk['title'];
  6692. $post['enter'] = $time;
  6693. $post['time'] = $time;
  6694. $post['bs'] = 1;
  6695. $post['shop'] = $rk['shop'];
  6696. $post['details'] = $rk['details'];
  6697. $post['cpid'] = $rk['cpid'];
  6698. $post['cpbz'] = $rk['cpbz'];
  6699. $warehouse = $this->warehouse->read($rk['warehouse']);
  6700. if ($warehouse['bdck'] == '') {
  6701. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6702. exit;
  6703. } else {
  6704. $bdck = $warehouse['bdck'];
  6705. }
  6706. $post['featurespp'] = $rk['featurespp'];
  6707. $this->db->trans_begin();
  6708. for ($i = 0; $i < $num; $i++) {
  6709. $post['label'] = time() . rand(100, 999) . $i;
  6710. $this->$bdck->insert($post);
  6711. }
  6712. /**
  6713. if($post['warehouse'] != 12)
  6714. {
  6715. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6716. }
  6717. **/
  6718. if ($this->db->trans_status() === TRUE) {
  6719. $this->db->trans_commit();
  6720. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6721. exit;
  6722. } else {
  6723. $this->db->trans_rollback();
  6724. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6725. exit;
  6726. }
  6727. } else {
  6728. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6729. exit;
  6730. }
  6731. }
  6732. }
  6733. public function _printck($arg_array)
  6734. {
  6735. $prc = array();
  6736. $purchase = $this->purchase->find_all();
  6737. foreach ($purchase as $k => $v) {
  6738. $prc[$v['id']] = $v['title'];
  6739. }
  6740. $post = $this->input->post(NULL, TRUE);
  6741. if (isset($post['page'])) {
  6742. $page = $this->input->post('page', true);
  6743. $perpage = $this->input->post('perpage', true);
  6744. $sku = $this->input->post('sku', true);
  6745. $bs = $this->input->post('bs', true);
  6746. $number = $this->input->post('number', true);
  6747. $warehouse = $this->input->post('warehouse', true);
  6748. $purchase = $this->input->post('purchase', true);
  6749. $orderinfo = $this->input->post('orderinfo', true);
  6750. $waybill = $this->input->post('waybill', true);
  6751. $category = $this->input->post('category', true);
  6752. $size = $this->input->post('size', true);
  6753. $grade = $this->input->post('grade', true);
  6754. $color = $this->input->post('color', true);
  6755. $lowe = $this->input->post('lowe', true);
  6756. $state = $this->input->post('state', true);
  6757. $label = $this->input->post('label', true);
  6758. $timetk = $this->input->post('ktime', true);
  6759. $timetj = $this->input->post('jtime', true);
  6760. $timetk = strtotime($timetk);
  6761. $timetj = strtotime($timetj);
  6762. $where = "state=1 ";
  6763. if ($timetk && $timetj) {
  6764. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6765. }
  6766. if ($sku) {
  6767. $where .= " and sku = '$sku'";
  6768. }
  6769. if ($bs != '') {
  6770. $where .= " and bs = '$bs'";
  6771. }
  6772. if ($number) {
  6773. $where .= " and number = '$number'";
  6774. }
  6775. if ($warehouse) {
  6776. $where .= " and warehouse = '$warehouse'";
  6777. }
  6778. if ($purchase) {
  6779. $where .= " and purchase = '$purchase'";
  6780. }
  6781. if ($orderinfo) {
  6782. $where .= " and orderinfo = '$orderinfo'";
  6783. }
  6784. if ($waybill) {
  6785. $where .= " and waybill = '$waybill'";
  6786. }
  6787. if ($category) {
  6788. $where .= " and features like '%-$category-%'";
  6789. }
  6790. if ($size) {
  6791. $where .= " and features like '%-$size-%'";
  6792. }
  6793. if ($grade) {
  6794. $where .= " and features like '%-$grade-%'";
  6795. }
  6796. if ($color) {
  6797. $where .= " and features like '%-$color-%'";
  6798. }
  6799. if ($lowe) {
  6800. $where .= " and features like '%-$lowe-%'";
  6801. }
  6802. if ($label) {
  6803. $where .= " and label = '$label'";
  6804. }
  6805. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6806. //数据排序
  6807. $order_str = "outk desc";
  6808. if (empty($page)) {
  6809. $start = 0;
  6810. $perpage = 1;
  6811. } else {
  6812. $start = ($page - 1) * $perpage;
  6813. }
  6814. //取得信息列表
  6815. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6816. foreach ($info_list as $key => $value) {
  6817. $warehouse = $this->warehouse->read($value['warehouse']);
  6818. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6819. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6820. if ($value['state'] == 0) {
  6821. $info_list[$key]['state'] = "在库";
  6822. } else if ($value['state'] == 1) {
  6823. $info_list[$key]['state'] = "出库";
  6824. } else if ($value['state'] == 2) {
  6825. $info_list[$key]['state'] = "退库";
  6826. } else if ($value['state'] == 3) {
  6827. $info_list[$key]['state'] = "调拨中";
  6828. } else if ($value['state'] == 4) {
  6829. $info_list[$key]['state'] = "再加工";
  6830. } else if ($value['state'] == 5) {
  6831. $info_list[$key]['state'] = "维修中";
  6832. } else if ($value['state'] == 6) {
  6833. $info_list[$key]['state'] = "盘亏";
  6834. } else if ($value['state'] == 7) {
  6835. $info_list[$key]['state'] = "更换标签";
  6836. } else if ($value['state'] == 8) {
  6837. $info_list[$key]['state'] = "其它";
  6838. } else if ($value['state'] == 9) {
  6839. $info_list[$key]['state'] = "预设";
  6840. } else if ($value['state'] == 10) {
  6841. $info_list[$key]['state'] = "美店零售";
  6842. }
  6843. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6844. }
  6845. $total = $this->$ck->find_count($where);
  6846. $pagenum = ceil($total / $perpage);
  6847. $over = $total - ($start + $perpage);
  6848. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6849. echo json_encode($rows);
  6850. exit;
  6851. }
  6852. if (isset($post['tmsku'])) {
  6853. $time = time();
  6854. $tmsku = $this->input->post('tmsku', true);
  6855. //$post['shop'] = $this->input->post('shop',true);
  6856. $num = $this->input->post('num', true);
  6857. $cktype = $this->input->post('cktype', true);
  6858. $label = $this->whlabellabel->get_label($tmsku);
  6859. if (!$cktype) {
  6860. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6861. }
  6862. if (!isset($label['warehouse'])) {
  6863. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6864. exit;
  6865. }
  6866. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6867. $extra_where = "";
  6868. if(!empty($label['details'])){
  6869. $extra_where .= " and details = '" . $label['details'] . "'";
  6870. }
  6871. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6872. if (stripos($label['features'], '-126-') !== false) {
  6873. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6874. } else {
  6875. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and purchase = '" . $label['purchase'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6876. }
  6877. $j = 0;
  6878. if (count($ck) >= $num) {
  6879. for ($i = 0; $i < $num; $i++) {
  6880. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6881. {
  6882. $j++;
  6883. }
  6884. }
  6885. $this->whlabelscanlog->insert([
  6886. 'shop'=>$label['shop'],
  6887. 'type'=>2,
  6888. 'purchase'=>$label['purchase'],
  6889. 'sku'=>$label['sku'],
  6890. 'features'=>$label['features'],
  6891. 'title'=>$label['title'],
  6892. 'label'=>$label['label'],
  6893. 'warehouse'=>$label['warehouse'],
  6894. 'wlid'=>$label['id'],
  6895. 'num'=>$num,
  6896. 'addtime'=>time()
  6897. ]);
  6898. if ($j == $num) {
  6899. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6900. exit;
  6901. } else {
  6902. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6903. exit;
  6904. }
  6905. } else {
  6906. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6907. exit;
  6908. }
  6909. }
  6910. if(isset($_SESSION['api']))
  6911. {
  6912. $user = $this->user->get_api($_SESSION['api']);
  6913. if(in_array($user['power'],[1,27])){
  6914. $vip = 1;
  6915. }
  6916. }
  6917. else
  6918. {
  6919. $vip = 0;
  6920. header('Location: /');exit;
  6921. }
  6922. $this->data['vip'] = $vip;
  6923. $this->_Template('whlabel_printck', $this->data);
  6924. }
  6925. public function _printexcel()
  6926. {
  6927. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6928. $config['upload_path'] = '.' . $dir;
  6929. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6930. $config['allowed_types'] = 'xls|xlsx|csv';
  6931. $config['max_size'] = 10240;
  6932. $this->load->library('upload', $config);
  6933. $this->upload->initialize($config);
  6934. if ($this->upload->do_upload('userfile')) {
  6935. $full_path = $dir . $this->upload->data('file_name');
  6936. $fileName = '.' . $full_path;
  6937. if (!file_exists($fileName)) {
  6938. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6939. exit;
  6940. } else {
  6941. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6942. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6943. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6944. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6945. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6946. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6947. ++$column; //如果列数大于26行
  6948. $list = array();
  6949. for ($i = 2; $i <= $row; $i++) // 行数循环
  6950. {
  6951. $data = array();
  6952. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6953. {
  6954. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6955. }
  6956. $list[] = $data;
  6957. }
  6958. }
  6959. $ed = array();
  6960. $i = 0;
  6961. $j = 0;
  6962. $dcdata = array();
  6963. $yc = '';
  6964. $cmf_arr = array_column($list, '1');
  6965. array_multisort($cmf_arr, SORT_ASC, $list);
  6966. foreach ($list as $key => $value) {
  6967. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6968. if ($typeclass) {
  6969. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6970. } else {
  6971. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6972. $i++;
  6973. continue;
  6974. }
  6975. }
  6976. if ($i > 0) {
  6977. $yc = $i . '条异常';
  6978. }
  6979. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6980. exit;
  6981. }
  6982. }
  6983. public function _uck()
  6984. {
  6985. if (isset($_GET['excel'])) {
  6986. $tc = array();
  6987. $typeclass = $this->typeclass->find_all();
  6988. foreach ($typeclass as $v) {
  6989. $tc[$v['id']] = $v['zh'];
  6990. }
  6991. $data = array();
  6992. $t = array();
  6993. $rq = '';
  6994. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6995. $ts = $ts / (24 * 3600);
  6996. for ($i = 0; $i < $ts; $i++) {
  6997. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6998. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6999. }
  7000. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  7001. foreach ($info_list as $k => $v) {
  7002. $features = explode('-', trim($v['features'], '-'));
  7003. if (!isset($features[3]) || !isset($features[4])) {
  7004. continue;
  7005. }
  7006. $data[$k][0] = $tc[$features[0]]; //类型
  7007. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7008. $data[$k][2] = $tc[$features[4]]; //曲度
  7009. $data[$k][3] = '';
  7010. if (isset($data[$k][1])) {
  7011. $data[$k][3] .= $data[$k][1];
  7012. }
  7013. if (isset($data[$k][2])) {
  7014. $data[$k][3] .= $data[$k][2];
  7015. }
  7016. if (isset($features[5])) {
  7017. $data[$k][3] .= $tc[$features[5]];
  7018. }
  7019. if (isset($features[2])) {
  7020. $data[$k][3] .= $tc[$features[2]];
  7021. }
  7022. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7023. $data[$k][4] = $v['sku'];
  7024. $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())) . '))'); //月初库存
  7025. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7026. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7027. $ztrq = '';
  7028. $ztsl = '';
  7029. if (count($zt) > 0) {
  7030. foreach ($zt as $vv) {
  7031. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7032. $ztsl .= $vv['num'] . '<br>';
  7033. }
  7034. }
  7035. $data[$k][] = trim($ztsl, '<br>');
  7036. $data[$k][] = trim($ztrq, '<br>');
  7037. $byck = 0;
  7038. foreach ($t as $vv) {
  7039. $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));
  7040. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7041. $byck += $sl;
  7042. }
  7043. $data[$k][] = ($byck > 0) ? $byck : '';
  7044. }
  7045. $title = "详情 " . date("Y-m-d", time());
  7046. $titlename = "<table border=1>
  7047. <tr align='center'>
  7048. <td>类别</td>
  7049. <td>颜色</td>
  7050. <td>曲度</td>
  7051. <td>名称</td>
  7052. <td>SKU</td>
  7053. <td>月初库存</td>
  7054. <td>剩余库存</td>
  7055. <td>在途数量</td>
  7056. <td>预达日期</td>" .
  7057. $rq
  7058. . "<td>本月出库</td></tr>
  7059. </table>";
  7060. $filename = $title . ".xls";
  7061. $tail = "";
  7062. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7063. }
  7064. }
  7065. public function _whlabelexcelzh()
  7066. {
  7067. if (isset($_GET['excel'])) {
  7068. $where = "sku != 'Preset'";
  7069. //数据排序
  7070. $order_str = "id desc";
  7071. if (empty($page)) {
  7072. $start = 0;
  7073. $perpage = 1;
  7074. } else {
  7075. $start = ($page - 1) * $perpage;
  7076. }
  7077. $category = $this->input->get('category', true);
  7078. $warehouse = $this->input->get('warehouse', true);
  7079. $excelid = $this->input->get('sid', true);
  7080. if ($category) {
  7081. $where .= " and features like '%-$category-%'";
  7082. }
  7083. if ($warehouse) {
  7084. $where .= " and warehouse = '$warehouse'";
  7085. }
  7086. $xzid = '';
  7087. if ($excelid) {
  7088. $excelid = explode(',', trim($excelid, ','));
  7089. foreach ($excelid as $key => $value) {
  7090. $xzid .= " id = " . $value . " or";
  7091. }
  7092. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7093. }
  7094. //取得信息列表
  7095. /**
  7096. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7097. $rows = array();$list = array();
  7098. foreach ($info_list as $key=>$value)
  7099. {
  7100. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7101. }
  7102. **/
  7103. $list = array();
  7104. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7105. foreach ($rows as $key => $value) {
  7106. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7107. $zh = '';
  7108. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7109. foreach ($zt as $v) {
  7110. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7111. }
  7112. $zt = array_sum(array_column($zt, 'num'));
  7113. $number = $value['number'];
  7114. $ftime = time() - 15 * 24 * 3600;
  7115. $warehouse = $this->warehouse->read($value['warehouse']);
  7116. $rows[$key]['warehouse'] = $warehouse['title'];
  7117. $rows[$key]['number'] = $c;
  7118. $rows[$key]['features'] = $zh;
  7119. $rows[$key]['hb'] = $c + $zt;
  7120. }
  7121. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7122. $titlename = "<table border=1>
  7123. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7124. <tr align='center'>
  7125. <td>仓库</td>
  7126. <td>SKU</td>
  7127. <td>产品</td>
  7128. <td>库存数量</td>
  7129. <td>在途数量及预达日期</td>
  7130. <td>在途+库存数量</td>
  7131. </tr>
  7132. </table>";
  7133. $filename = $title . ".xls";
  7134. $tail = "";
  7135. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7136. }
  7137. if (isset($_GET['excel'])) {
  7138. $warehouse = $this->input->get('warehouse', true);
  7139. $sku = $this->input->get('sku', true);
  7140. $cz = $this->input->get('cz', true);
  7141. $text = $this->input->post('text', true);
  7142. $xztime = $this->input->get('xztime', true);
  7143. $timetk = $this->input->get('timetk', true);
  7144. $timetj = $this->input->get('timetj', true);
  7145. $timetk = strtotime($timetk);
  7146. $timetj = strtotime($timetj);
  7147. $where = "time = '0' ";
  7148. if ($warehouse) {
  7149. $where .= " and warehouse = '$warehouse'";
  7150. }
  7151. if ($sku) {
  7152. $where .= " and sku = '$sku'";
  7153. }
  7154. if ($text) {
  7155. $where .= " and text like '%$text%'";
  7156. }
  7157. if ($cz != '') {
  7158. $where .= " and cz = '$cz'";
  7159. }
  7160. if ($timetk && $timetj) {
  7161. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7162. }
  7163. //数据排序
  7164. $order_str = $xztime . " desc";
  7165. //取得信息列表
  7166. $zh = array();
  7167. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7168. foreach ($info_list as $v) {
  7169. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7170. $warehouse = $this->warehouse->read($v['warehouse']);
  7171. $v['warehouse'] = $warehouse['title'];
  7172. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7173. $v['stime'] = date('Y-m-d', $v['stime']);
  7174. if (isset($zh[$v['features']])) {
  7175. $zh[$v['features']]['num'] += $v['num'];
  7176. } else {
  7177. $zh[$v['features']] = $v;
  7178. }
  7179. $zh[$v['features']]['features'] = $c;
  7180. }
  7181. $title = "在途数据" . date('Y-m-d', time());
  7182. $titlename = "<table border=1>
  7183. <tr align='center'>
  7184. <td>仓库</td>
  7185. <td>SKU</td>
  7186. <td>名称</td>
  7187. <td>在途数量</td>
  7188. <td>库存数量</td>
  7189. <td>添加在途日期</td>
  7190. <td>预达日期</td>
  7191. <td>备注</td>
  7192. </tr>
  7193. </table>";
  7194. $filename = $title . ".xls";
  7195. $tail = "";
  7196. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7197. }
  7198. }
  7199. public function _fc()
  7200. {
  7201. $vip = 0;
  7202. if (isset($_SESSION['api'])) {
  7203. $user = $this->user->get_api($_SESSION['api']);
  7204. if ($user['vip'] == 1) {
  7205. $vip = 1;
  7206. }
  7207. } else {
  7208. header('Location: /');
  7209. exit;
  7210. }
  7211. $post = $this->input->post(NULL, TRUE);
  7212. if (isset($post['page'])) {
  7213. $page = $this->input->post('page', true);
  7214. $perpage = $this->input->post('perpage', true);
  7215. $category = $this->input->post('category', true);
  7216. $size = $this->input->post('size', true);
  7217. $grade = $this->input->post('grade', true);
  7218. $color = $this->input->post('color', true);
  7219. $lowe = $this->input->post('lowe', true);
  7220. $sku = $this->input->post('sku');
  7221. $title = $this->input->post('title');
  7222. $warehouse = $this->input->post('warehouse', true);
  7223. $usa = $this->input->post('usa', true);
  7224. $purchase = $this->input->post('purchase', true);
  7225. $lacetype = $this->input->post('lacetype', true);
  7226. $haircap = $this->input->post('haircap', true);
  7227. $density = $this->input->post('density', true);
  7228. $details = $this->input->post('details', true);
  7229. $state = $this->input->post('state', true);
  7230. $ktime = $this->input->post('ktime', true);
  7231. $jtime = $this->input->post('jtime', true);
  7232. $ktime = strtotime($ktime);
  7233. $jtime = strtotime($jtime);
  7234. $where = "state = '11'";
  7235. $gj = "";
  7236. $ck = "";
  7237. if ($lacetype) {
  7238. $where .= " and features like '%-$lacetype-%'";
  7239. }
  7240. if ($category) {
  7241. $where .= " and features like '%-$category-%'";
  7242. }
  7243. if ($size) {
  7244. $where .= " and features like '%-$size-%'";
  7245. }
  7246. if ($grade) {
  7247. $where .= " and features like '%-$grade-%'";
  7248. }
  7249. if ($color) {
  7250. $where .= " and features like '%-$color-%'";
  7251. }
  7252. if ($lowe) {
  7253. $where .= " and features like '%-$lowe-%'";
  7254. }
  7255. if ($haircap) {
  7256. $where .= " and features like '%-$haircap-%'";
  7257. }
  7258. if ($density) {
  7259. $where .= " and features like '%-$density-%'";
  7260. }
  7261. if ($usa) {
  7262. if (!$warehouse) {
  7263. $where .= " and (warehouse = '5' or warehouse = '8')";
  7264. }
  7265. }
  7266. if ($warehouse) {
  7267. $where .= " and warehouse = '$warehouse'";
  7268. }
  7269. if ($details) {
  7270. $where .= " and details = '$details'";
  7271. }
  7272. if ($purchase) {
  7273. $where .= " and purchase = '$purchase'";
  7274. }
  7275. if ($state) {
  7276. $where .= " and state = '$state'";
  7277. }
  7278. if ($ktime && $jtime) {
  7279. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7280. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7281. }
  7282. //数据排序
  7283. $order_str = "id desc";
  7284. if (empty($page)) {
  7285. $start = 0;
  7286. $perpage = 1;
  7287. } else {
  7288. $start = ($page - 1) * $perpage;
  7289. }
  7290. if ($sku) {
  7291. $sku = trim($sku, ' ');
  7292. $sku = trim($sku, ' ');
  7293. $where .= " and sku like '%$sku%'";
  7294. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7295. } else if ($title) {
  7296. $title = trim($title, ' ');
  7297. $title = trim($title, ' ');
  7298. $where .= " and title like '%$title%'";
  7299. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7300. } else {
  7301. //$where .= " and time > '$ktime' and time < '$jtime'";
  7302. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7303. }
  7304. //取得信息列表
  7305. $rows = array();
  7306. $list = array();
  7307. foreach ($info_list as $key => $value) {
  7308. $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'] . '"');
  7309. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7310. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7311. $warehouse = $this->warehouse->read($value['warehouse']);
  7312. $info_list[$key]['warehouse'] = $warehouse['title'];
  7313. $info_list[$key]['number'] = $g;
  7314. $info_list[$key]['features'] = $x;
  7315. $info_list[$key]['x'] = $s;
  7316. }
  7317. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7318. $pagenum = ceil($total / $perpage);
  7319. $over = $total - ($start + $perpage);
  7320. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7321. echo json_encode($rows);
  7322. exit;
  7323. }
  7324. $this->data['vip'] = $vip;
  7325. $this->_Template('whlabel_fc', $this->data);
  7326. }
  7327. public function _fcmb()
  7328. {
  7329. $where = "sku != 'Preset'";
  7330. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7331. foreach ($rows as $k => $v) {
  7332. $warehouse = $this->warehouse->read($v['warehouse']);
  7333. $rows[$k]['warehouse'] = $warehouse['title'];
  7334. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7335. $rows[$k]['t'] = '';
  7336. $rows[$k]['n'] = '';
  7337. }
  7338. $title = "封货产品数据导入模板";
  7339. $titlename = "<table border=1>
  7340. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7341. <tr align='center'>
  7342. <td>仓库</td>
  7343. <td>SKU</td>
  7344. <td>产品</td>
  7345. <td>封存产品总数量</td>
  7346. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7347. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7348. </tr>
  7349. </table>";
  7350. $filename = $title . ".xls";
  7351. $tail = "";
  7352. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7353. }
  7354. public function _fcexcel()
  7355. {
  7356. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7357. $config['upload_path'] = '.' . $dir;
  7358. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7359. $config['allowed_types'] = 'xls|xlsx|csv';
  7360. $config['max_size'] = 10240;
  7361. $this->load->library('upload', $config);
  7362. $this->upload->initialize($config);
  7363. if ($this->upload->do_upload('userfile')) {
  7364. $full_path = $dir . $this->upload->data('file_name');
  7365. $fileName = '.' . $full_path;
  7366. if (!file_exists($fileName)) {
  7367. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7368. exit;
  7369. } else {
  7370. libxml_use_internal_errors(true);
  7371. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7372. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7373. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7374. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7375. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7376. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7377. ++$column; //如果列数大于26行
  7378. $list = array();
  7379. for ($i = 2; $i <= $row; $i++) // 行数循环
  7380. {
  7381. $data = array();
  7382. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7383. {
  7384. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7385. }
  7386. $list[] = $data;
  7387. }
  7388. }
  7389. $i = 0;
  7390. $j = 0;
  7391. $ed = array();
  7392. foreach ($list as $key => $value) {
  7393. $time = time();
  7394. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7395. continue;
  7396. }
  7397. $warehouse = $this->warehouse->get_title($value['0']);
  7398. $sku = $value['1'];
  7399. $type = $value['4']; //调整方式0扣减1删除
  7400. $num = $value['5']; //调整数量
  7401. //$text = $value['4'];//扣减说明
  7402. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7403. if (!$d) //如果没有这个SKU
  7404. {
  7405. $ed[] = array($sku . '-库存中不存在此SKU');
  7406. $j++;
  7407. continue;
  7408. }
  7409. if (!isset($warehouse['id'])) {
  7410. $ed[] = array($sku . '-仓库名错误!');
  7411. $j++;
  7412. continue;
  7413. }
  7414. if ($type == 1 || $type == 2) //扣减库存
  7415. {
  7416. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7417. if (count($data) < abs($num)) {
  7418. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7419. $j++;
  7420. continue;
  7421. }
  7422. if ($type == 1) //转入库存
  7423. {
  7424. for ($i = 0; $i < abs($num); $i++) {
  7425. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7426. }
  7427. } else if ($type == 2) //删除
  7428. {
  7429. for ($i = 0; $i < abs($num); $i++) {
  7430. $this->whlabel->remove($data[$i]['id']);
  7431. }
  7432. }
  7433. } else if ($type == 0) //增加库存
  7434. {
  7435. $post['sku'] = $d['sku'];
  7436. $post['shop'] = '';
  7437. $post['warehouse'] = $warehouse['id'];
  7438. $post['purchase'] = $d['purchase'];
  7439. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7440. $post['state'] = 11;
  7441. $post['title'] = $d['title'];
  7442. $post['number'] = $d['number'];
  7443. $post['features'] = $d['features'];
  7444. $post['enter'] = $time;
  7445. $post['time'] = $time; //操作时间
  7446. for ($i = 0; $i < $num; $i++) {
  7447. $post['label'] = time() . rand(100, 999) . $i;
  7448. $this->whlabel->insert($post);
  7449. }
  7450. }
  7451. sleep(1); //防止入库时间一样,需要延迟1秒
  7452. }
  7453. if ($j > 0) {
  7454. $tt = date('Ymd', time());
  7455. $title = '库存导入错误信息-' . $tt;
  7456. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7457. $tail = "\n";
  7458. $filename = $title . ".xls";
  7459. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7460. $dir = '/data/excel/' . $time . '/';
  7461. $file_name = 'error_' . $time . rand(1000, 9999);
  7462. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7463. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7464. fwrite($myfile, $ecl);
  7465. fclose($myfile);
  7466. $error = $dir . $file_name . '.xls';
  7467. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7468. exit;
  7469. } else {
  7470. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7471. exit;
  7472. }
  7473. }
  7474. }
  7475. public function _fcjxc($arg_array)
  7476. {
  7477. if (isset($_GET['excel'])) {
  7478. $category = $this->input->get('category', true);
  7479. $size = $this->input->get('size', true);
  7480. $grade = $this->input->get('grade', true);
  7481. $color = $this->input->get('color', true);
  7482. $lowe = $this->input->get('lowe', true);
  7483. $sku = $this->input->get('sku');
  7484. $title = $this->input->get('title');
  7485. $warehouse = $arg_array[0];
  7486. $usa = $this->input->get('usa', true);
  7487. $purchase = $this->input->get('purchase', true);
  7488. $lacetype = $this->input->get('lacetype', true);
  7489. $haircap = $this->input->get('haircap', true);
  7490. $density = $this->input->get('density', true);
  7491. $title = $this->input->get('title', true);
  7492. $state = $this->input->get('state', true);
  7493. $ktime = $this->input->get('ktime', true);
  7494. $jtime = $this->input->get('jtime', true);
  7495. $where = "state=11";
  7496. $gj = "";
  7497. $ck = "";
  7498. if ($lacetype) {
  7499. $where .= " and features like '%-$lacetype-%'";
  7500. }
  7501. if ($category) {
  7502. $where .= " and features like '%-$category-%'";
  7503. }
  7504. if ($size) {
  7505. $where .= " and features like '%-$size-%'";
  7506. }
  7507. if ($grade) {
  7508. $where .= " and features like '%-$grade-%'";
  7509. }
  7510. if ($color) {
  7511. $where .= " and features like '%-$color-%'";
  7512. }
  7513. if ($lowe) {
  7514. $where .= " and features like '%-$lowe-%'";
  7515. }
  7516. if ($haircap) {
  7517. $where .= " and features like '%-$haircap-%'";
  7518. }
  7519. if ($density) {
  7520. $where .= " and features like '%-$density-%'";
  7521. }
  7522. if ($usa) {
  7523. if (!$warehouse) {
  7524. $where .= " and (warehouse = '5' or warehouse = '8')";
  7525. }
  7526. }
  7527. if ($warehouse) {
  7528. $where .= " and warehouse = '$warehouse'";
  7529. }
  7530. if ($purchase) {
  7531. $where .= " and purchase = '$purchase'";
  7532. }
  7533. if ($state) {
  7534. $where .= " and state = '$state'";
  7535. }
  7536. $order_str = "id desc";
  7537. if ($sku) {
  7538. $sku = trim($sku, ' ');
  7539. $sku = trim($sku, ' ');
  7540. $where .= " and sku like '%$sku%'";
  7541. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7542. } else if ($title) {
  7543. $title = trim($title, ' ');
  7544. $title = trim($title, ' ');
  7545. $where .= " and title like '%$title%'";
  7546. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7547. } else {
  7548. //$where .= " and time > '$ktime' and time < '$jtime'";
  7549. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7550. }
  7551. //取得信息列表
  7552. $rows = array();
  7553. $list = array();
  7554. foreach ($info_list as $key => $value) {
  7555. $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'] . '"');
  7556. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7557. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7558. $rows[$key] = $value;
  7559. $warehouse = $this->warehouse->read($value['warehouse']);
  7560. $rows[$key]['warehouse'] = $warehouse['title'];
  7561. $rows[$key]['features'] = $g;
  7562. $rows[$key]['a'] = $x;
  7563. $rows[$key]['b'] = $s;
  7564. }
  7565. $title = "总统计表";
  7566. $titlename = "<table border=1>
  7567. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7568. <tr align='center'>
  7569. <td>仓库</td>
  7570. <td>SKU</td>
  7571. <td>产品名称</td>
  7572. <td>录入总量</td>
  7573. <td>取出总量</td>
  7574. <td>剩余总量</td>
  7575. </tr>
  7576. </table>";
  7577. $filename = $title . ".xls";
  7578. $tail = "";
  7579. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7580. }
  7581. $vip = 0;
  7582. if (isset($_SESSION['api'])) {
  7583. $user = $this->user->get_api($_SESSION['api']);
  7584. if ($user['vip'] == 1) {
  7585. $vip = 1;
  7586. }
  7587. } else {
  7588. header('Location: /');
  7589. exit;
  7590. }
  7591. $post = $this->input->post(NULL, TRUE);
  7592. if (isset($post['page'])) {
  7593. $page = $this->input->post('page', true);
  7594. $perpage = $this->input->post('perpage', true);
  7595. $category = $this->input->post('category', true);
  7596. $size = $this->input->post('size', true);
  7597. $grade = $this->input->post('grade', true);
  7598. $color = $this->input->post('color', true);
  7599. $lowe = $this->input->post('lowe', true);
  7600. $sku = $this->input->post('sku');
  7601. $title = $this->input->post('title');
  7602. $warehouse = $arg_array[0];
  7603. $usa = $this->input->post('usa', true);
  7604. $purchase = $this->input->post('purchase', true);
  7605. $lacetype = $this->input->post('lacetype', true);
  7606. $haircap = $this->input->post('haircap', true);
  7607. $density = $this->input->post('density', true);
  7608. $title = $this->input->post('title', true);
  7609. $state = $this->input->post('state', true);
  7610. $ktime = $this->input->post('ktime', true);
  7611. $jtime = $this->input->post('jtime', true);
  7612. $ktime = strtotime($ktime);
  7613. $jtime = strtotime($jtime);
  7614. $where = "state=11";
  7615. $gj = "";
  7616. $ck = "";
  7617. if ($lacetype) {
  7618. $where .= " and features like '%-$lacetype-%'";
  7619. }
  7620. if ($category) {
  7621. $where .= " and features like '%-$category-%'";
  7622. }
  7623. if ($size) {
  7624. $where .= " and features like '%-$size-%'";
  7625. }
  7626. if ($grade) {
  7627. $where .= " and features like '%-$grade-%'";
  7628. }
  7629. if ($color) {
  7630. $where .= " and features like '%-$color-%'";
  7631. }
  7632. if ($lowe) {
  7633. $where .= " and features like '%-$lowe-%'";
  7634. }
  7635. if ($haircap) {
  7636. $where .= " and features like '%-$haircap-%'";
  7637. }
  7638. if ($density) {
  7639. $where .= " and features like '%-$density-%'";
  7640. }
  7641. if ($usa) {
  7642. if (!$warehouse) {
  7643. $where .= " and (warehouse = '5' or warehouse = '8')";
  7644. }
  7645. }
  7646. if ($warehouse) {
  7647. $where .= " and warehouse = '$warehouse'";
  7648. }
  7649. if ($purchase) {
  7650. $where .= " and purchase = '$purchase'";
  7651. }
  7652. if ($state) {
  7653. $where .= " and state = '$state'";
  7654. }
  7655. if ($ktime && $jtime) {
  7656. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7657. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7658. }
  7659. //数据排序
  7660. $order_str = "id desc";
  7661. $xs = 0;
  7662. $rows = array();
  7663. $list = array();
  7664. if (empty($page)) {
  7665. $start = 0;
  7666. $perpage = 1;
  7667. } else {
  7668. $start = ($page - 1) * $perpage;
  7669. }
  7670. if ($sku || $title) {
  7671. if ($title) {
  7672. $title = trim($title, ' ');
  7673. $title = trim($title, ' ');
  7674. $where .= " and title like '%$title%'";
  7675. } else {
  7676. $sku = trim($sku, ' ');
  7677. $sku = trim($sku, ' ');
  7678. $where .= " and sku like '%$sku%'";
  7679. }
  7680. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7681. foreach ($info_list as $key => $value) {
  7682. $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'] . '"');
  7683. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7684. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7685. $rows[$key] = $value;
  7686. $warehouse = $this->warehouse->read($value['warehouse']);
  7687. $rows[$key]['warehouse'] = $warehouse['title'];
  7688. $rows[$key]['features'] = $g;
  7689. $rows[$key]['a'] = $x;
  7690. $rows[$key]['b'] = $s;
  7691. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7692. $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天销量
  7693. $yj = $c / ($xl / 30);
  7694. if ($yj < 7) {
  7695. $rows[$key]['y'] = round($yj) . '天销量';
  7696. } else {
  7697. $rows[$key]['y'] = '正常';
  7698. }
  7699. }
  7700. } else {
  7701. //$where .= " and time > '$ktime' and time < '$jtime'";
  7702. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7703. foreach ($info_list as $key => $value) {
  7704. $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'] . '"');
  7705. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7706. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7707. $zs[$key] = $value;
  7708. $warehouse = $this->warehouse->read($value['warehouse']);
  7709. $zs[$key]['warehouse'] = $warehouse['title'];
  7710. $zs[$key]['features'] = $g;
  7711. $zs[$key]['a'] = $x;
  7712. $zs[$key]['b'] = $s;
  7713. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7714. $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天销量
  7715. $yj = $c / ($xl / 30);
  7716. if ($yj < 7) {
  7717. $zs[$key]['y'] = round($yj) . '天销量';
  7718. $rows[$key] = $zs[$key];
  7719. }
  7720. }
  7721. }
  7722. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7723. $pagenum = ceil($total / $perpage);
  7724. $over = $total - ($start + $perpage);
  7725. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7726. echo json_encode($rows);
  7727. exit;
  7728. }
  7729. $this->data['arg_array'] = $arg_array[0];
  7730. $this->_Template('whlabel_fcjxc', $this->data);
  7731. }
  7732. public function _0kcdel()
  7733. {
  7734. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7735. $config['upload_path'] = '.' . $dir;
  7736. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7737. $config['allowed_types'] = 'xls|xlsx|csv';
  7738. $config['max_size'] = 10240;
  7739. $this->load->library('upload', $config);
  7740. $this->upload->initialize($config);
  7741. if ($this->upload->do_upload('userfile')) {
  7742. $full_path = $dir . $this->upload->data('file_name');
  7743. $fileName = '.' . $full_path;
  7744. if (!file_exists($fileName)) {
  7745. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7746. exit;
  7747. } else {
  7748. require_once "./data/excel/PHPExcel/IOFactory.php";
  7749. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7750. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7751. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7752. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7753. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7754. ++$column; //如果列数大于26行
  7755. $list = array();
  7756. for ($i = 2; $i <= $row; $i++) // 行数循环
  7757. {
  7758. $data = array();
  7759. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7760. {
  7761. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7762. }
  7763. $list[] = $data;
  7764. }
  7765. }
  7766. $i = 0;
  7767. $j = 0;
  7768. $ed = array();
  7769. foreach ($list as $key => $value) {
  7770. $time = time();
  7771. if ($value['0'] == "" || $value['1'] == "") {
  7772. continue;
  7773. }
  7774. $warehouse = $this->warehouse->get_title($value['0']);
  7775. $sku = $value['1'];
  7776. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7777. if (!$d) //如果没有这个SKU
  7778. {
  7779. $ed[] = array($sku . '-库存中不存在此SKU');
  7780. $j++;
  7781. continue;
  7782. }
  7783. if (!isset($warehouse['id'])) {
  7784. $ed[] = array($sku . '-仓库名错误!');
  7785. $j++;
  7786. continue;
  7787. }
  7788. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7789. if ($z < 1) {
  7790. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7791. foreach ($z as $v) {
  7792. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7793. if (count($zt) > 0) {
  7794. $ed[] = array($sku . '-有在途库存无法删除!');
  7795. $j++;
  7796. continue;
  7797. }
  7798. $this->whlabel->remove($v['id']);
  7799. }
  7800. } else {
  7801. $ed[] = array($sku . '-非0库存!');
  7802. $j++;
  7803. continue;
  7804. }
  7805. }
  7806. if ($j > 0) {
  7807. $tt = date('Ymd', time());
  7808. $title = '删除0库存错误信息-' . $tt;
  7809. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7810. $tail = "\n";
  7811. $filename = $title . ".xls";
  7812. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7813. $dir = '/data/excel/' . $time . '/';
  7814. $file_name = 'error_' . $time . rand(1000, 9999);
  7815. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7816. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7817. fwrite($myfile, $ecl);
  7818. fclose($myfile);
  7819. $error = $dir . $file_name . '.xls';
  7820. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7821. exit;
  7822. } else {
  7823. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7824. exit;
  7825. }
  7826. }
  7827. }
  7828. public function _gbhtype()
  7829. {
  7830. $post = $this->input->post(NULL, TRUE);
  7831. if (isset($post['s'])) {
  7832. $n = $this->input->post('n');
  7833. $d = $this->input->post('s');
  7834. if (!$d) {
  7835. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7836. exit;
  7837. }
  7838. $d = explode(',', trim($d, ','));
  7839. $t = $this->whlabel_type->read($n);
  7840. //循环删除记录
  7841. foreach ($d as $v) {
  7842. $u = $this->whlabel->read($v);
  7843. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7844. foreach ($data as $val) {
  7845. $this->whlabel->save(array('type' => $n), $val['id']);
  7846. }
  7847. }
  7848. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7849. }
  7850. }
  7851. //出库、退库导出
  7852. public function _dccrtype()
  7853. {
  7854. $classid = $this->classid->sku();
  7855. $pm = $classid;
  7856. $typeclass = array();
  7857. $tc = $this->typeclass->find_all();
  7858. foreach ($tc as $v) {
  7859. $typeclass[$v['id']] = $v;
  7860. }
  7861. $prc = array();
  7862. $purchase = $this->purchase->find_all();
  7863. foreach ($purchase as $k => $v) {
  7864. $prc[$v['id']] = $v['title'];
  7865. }
  7866. if (isset($_GET['sid'])) {
  7867. $wh = array();
  7868. $w = $this->warehouse->find_all('1=1', 'id,title');
  7869. foreach ($w as $v) {
  7870. $wh[$v['id']] = $v['title'];
  7871. }
  7872. $type = $this->input->get('excel', true);
  7873. $category = $this->input->get('category', true);
  7874. $size = $this->input->get('size', true);
  7875. $grade = $this->input->get('grade', true);
  7876. $color = $this->input->get('color', true);
  7877. $lowe = $this->input->get('lowe', true);
  7878. $sku = $this->input->get('sku', true);
  7879. $warehouse = $this->input->get('warehouse', true);
  7880. $lacetype = $this->input->get('lacetype', true);
  7881. $lacecolor = $this->input->get('lacecolor', true);
  7882. $density = $this->input->get('density', true);
  7883. $haircap = $this->input->get('haircap', true);
  7884. $purchase = $this->input->get('purchase', true);
  7885. $title = $this->input->get('title', true);
  7886. $state = $this->input->get('state', true);
  7887. $sid = $this->input->get('sid', true);
  7888. $ktime = $this->input->get('ktime', true);
  7889. $jtime = $this->input->get('jtime', true);
  7890. $ktime = strtotime($ktime);
  7891. $jtime = strtotime($jtime);
  7892. $where = "1=1";
  7893. $gj = "";
  7894. $ck = "";
  7895. if ($category) {
  7896. $where .= " and features like '%-$category-%'";
  7897. }
  7898. if ($size) {
  7899. $where .= " and features like '%-$size-%'";
  7900. }
  7901. if ($grade) {
  7902. $where .= " and features like '%-$grade-%'";
  7903. }
  7904. if ($color) {
  7905. $where .= " and features like '%-$color-%'";
  7906. }
  7907. if ($lowe) {
  7908. $where .= " and features like '%-$lowe-%'";
  7909. }
  7910. if ($warehouse) {
  7911. $where .= " and warehouse = '$warehouse'";
  7912. }
  7913. if ($purchase) {
  7914. $where .= " and purchase = '$purchase'";
  7915. }
  7916. if ($state) {
  7917. $where .= " and state = '$state'";
  7918. }
  7919. if ($lacetype) {
  7920. $where .= " and features like '%-$lacetype-%'";
  7921. }
  7922. if ($lacecolor) {
  7923. $where .= " and features like '%-$lacecolor-%'";
  7924. }
  7925. if ($density) {
  7926. $where .= " and features like '%-$density-%'";
  7927. }
  7928. if ($haircap) {
  7929. $where .= " and features like '%-$haircap-%'";
  7930. }
  7931. if ($title) {
  7932. $title = trim($title, ' ');
  7933. $title = trim($title, ' ');
  7934. $where .= " and title like '%$title%'";
  7935. }
  7936. if ($sku) {
  7937. $sku = trim($sku, ' ');
  7938. $sku = trim($sku, ' ');
  7939. $where .= " and sku like '%$sku%'";
  7940. }
  7941. if ($ktime && $jtime) {
  7942. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7943. }
  7944. $sidwhere = '';
  7945. if ($sid) {
  7946. $sd = "";
  7947. $s = explode(',', trim($sid, ','));
  7948. foreach ($s as $value) {
  7949. $sd .= " id = " . $value . " or";
  7950. }
  7951. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7952. }
  7953. //数据排序
  7954. $order_str = "time desc";
  7955. if (empty($page)) {
  7956. $start = 0;
  7957. $perpage = 1;
  7958. } else {
  7959. $start = ($page - 1) * $perpage;
  7960. }
  7961. $wh = array();
  7962. $w = $this->warehouse->find_all('1=1', 'id,title');
  7963. foreach ($w as $v) {
  7964. $wh[$v['id']] = $v['title'];
  7965. }
  7966. $wt = array();
  7967. $whlabel_type = $this->whlabel_type->find_all();
  7968. foreach ($whlabel_type as $v) {
  7969. $wt[$v['id']] = $v['title'];
  7970. }
  7971. $classid = $this->classid->sku();
  7972. $list = array();
  7973. $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');
  7974. foreach ($rows_r as $key => $value) {
  7975. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7976. $pm = $classid;
  7977. $jm = $classid;
  7978. $rows_r[$key]['enter'] = '入库';
  7979. $rows_r[$key]['time'] = $value['enter'];
  7980. if ($value['rktype'] == 1) {
  7981. $rows_r[$key]['rktype'] = '采购入库';
  7982. } else if ($value['rktype'] == 2) {
  7983. $rows_r[$key]['rktype'] = '盘盈调整';
  7984. } else if ($value['rktype'] == 3) {
  7985. $rows_r[$key]['rktype'] = '其他调整入库';
  7986. } else if ($value['rktype'] == 4) {
  7987. $rows_r[$key]['rktype'] = '其他调整入库';
  7988. } else if ($value['rktype'] == 5) {
  7989. $rows_r[$key]['rktype'] = '退库入库';
  7990. } else if ($value['rktype'] == 6) {
  7991. $rows_r[$key]['rktype'] = '退货可用入库';
  7992. } else if ($value['rktype'] == 7) {
  7993. $rows_r[$key]['rktype'] = '形态转换入库';
  7994. } else {
  7995. $rows_r[$key]['rktype'] = '';
  7996. }
  7997. $features = explode('-', trim($value['features'], '-'));
  7998. foreach ($features as $v) {
  7999. if (isset($typeclass[$v])) {
  8000. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8001. $pm[$typeclass[$v]['classid']] = $zh[0];
  8002. }
  8003. if (isset($typeclass[$v])) {
  8004. if (isset($jm[$typeclass[$v]['classid']])) {
  8005. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8006. }
  8007. }
  8008. }
  8009. $zh = implode(" ", $pm);
  8010. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8011. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8012. $rows_r[$key]['zh'] = $zh;
  8013. $jm = array_filter($jm);
  8014. $rows_r[$key]['features'] = implode("-", $jm);
  8015. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8016. }
  8017. $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');
  8018. foreach ($rows_c as $key => $value) {
  8019. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8020. $pm = $classid;
  8021. $jm = $classid;
  8022. $rows_c[$key]['time'] = $value['outk'];
  8023. $rows_c[$key]['outk'] = '出库';
  8024. if ($value['cktype'] == 1) {
  8025. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8026. } else if ($value['cktype'] == 2) {
  8027. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8028. } else if ($value['cktype'] == 3) {
  8029. $rows_c[$key]['cktype'] = '盘亏调整';
  8030. } else if ($value['cktype'] == 4) {
  8031. $rows_c[$key]['cktype'] = '其他调整出库';
  8032. } else if ($value['cktype'] == 5) {
  8033. $rows_c[$key]['cktype'] = '形态转换出库';
  8034. } else {
  8035. $rows_c[$key]['cktype'] = '';
  8036. }
  8037. unset($rows_c[$key]['state']);
  8038. $features = explode('-', trim($value['features'], '-'));
  8039. foreach ($features as $v) {
  8040. if (isset($typeclass[$v])) {
  8041. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8042. $pm[$typeclass[$v]['classid']] = $zh[0];
  8043. }
  8044. if (isset($typeclass[$v])) {
  8045. if (isset($jm[$typeclass[$v]['classid']])) {
  8046. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8047. }
  8048. }
  8049. }
  8050. $zh = implode(" ", $pm);
  8051. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8052. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8053. $rows_c[$key]['zh'] = $zh;
  8054. $jm = array_filter($jm);
  8055. $rows_c[$key]['features'] = implode("-", $jm);
  8056. $rows_c[$key]['number'] = 1;
  8057. }
  8058. $merged = $rows_r;
  8059. foreach ($rows_c as $key => $value) {
  8060. if (isset($merged[$key])) {
  8061. $merged[] = $value;
  8062. } else {
  8063. $merged[$key] = $value;
  8064. }
  8065. }
  8066. usort($merged, function ($a, $b) {
  8067. return $a['time'] - $b['time'];
  8068. });
  8069. foreach ($merged as $key => $value) {
  8070. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8071. }
  8072. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8073. $titlename = "<table border=1>
  8074. <tr align='center'>
  8075. <td>仓库</td>
  8076. <td>SKU</td>
  8077. <td>商品名称</td>
  8078. <td>仓库品名</td>
  8079. <td>料号</td>
  8080. <td>时间</td>
  8081. <td>操作</td>
  8082. <td>类型</td>
  8083. <td>数量</td>
  8084. <td>备注</td>
  8085. </tr>
  8086. </table>";
  8087. $filename = $title . ".xlsx";
  8088. $tail = "";
  8089. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8090. }
  8091. }
  8092. /*************************************处理exceljs导出****************************************************/
  8093. public function _excelrjs(){
  8094. if (isset($_GET['excel'])) {
  8095. $category = $this->input->get('category', true);
  8096. $size = $this->input->get('size', true);
  8097. $grade = $this->input->get('grade', true);
  8098. $color = $this->input->get('color', true);
  8099. $lowe = $this->input->get('lowe', true);
  8100. $sku = $this->input->get('sku', true);
  8101. $warehouse = $this->input->get('warehouse', true);
  8102. $purchase = $this->input->get('purchase', true);
  8103. $ktime = $this->input->get('ktime', true);
  8104. $jtime = $this->input->get('jtime', true);
  8105. $ktime = strtotime($ktime);
  8106. $jtime = strtotime($jtime);
  8107. $where = "1=1";
  8108. $gj = "";
  8109. $ck = "";
  8110. if ($category) {
  8111. $where .= " and features like '%-$category-%'";
  8112. }
  8113. if ($size) {
  8114. $where .= " and features like '%-$size-%'";
  8115. }
  8116. if ($grade) {
  8117. $where .= " and features like '%-$grade-%'";
  8118. }
  8119. if ($color) {
  8120. $where .= " and features like '%-$color-%'";
  8121. }
  8122. if ($lowe) {
  8123. $where .= " and features like '%-$lowe-%'";
  8124. }
  8125. if ($warehouse) {
  8126. $where .= " and warehouse = '$warehouse'";
  8127. }
  8128. if ($purchase) {
  8129. $where .= " and purchase = '$purchase'";
  8130. }
  8131. if ($sku) {
  8132. $where .= " and sku = '$sku'";
  8133. }
  8134. if ($ktime && $jtime) {
  8135. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8136. }
  8137. //数据排序
  8138. $order_str = "id desc";
  8139. if (empty($page)) {
  8140. $start = 0;
  8141. $perpage = 1;
  8142. } else {
  8143. $start = ($page - 1) * $perpage;
  8144. }
  8145. $list = array();
  8146. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8147. foreach ($rows as $value) {
  8148. $ck = $this->warehouse->read($value['warehouse']);
  8149. $warehouse = $ck['title'];
  8150. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8151. $retreatwarehouse = $tkck['title'];
  8152. $gy = $this->purchase->read($value['purchase']);
  8153. $purchase = $gy['title'];
  8154. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8155. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8156. }
  8157. if(empty($list)){
  8158. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8159. }else{
  8160. $final_list = [];
  8161. foreach($list as $v){
  8162. $final_list[] = array_values($v);
  8163. }
  8164. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8165. array_unshift($final_list,[
  8166. "仓库","SKU","商品名称","时间","数量"
  8167. ]);
  8168. array_unshift($final_list,[
  8169. $title,"","","",""
  8170. ]);
  8171. $merges = [
  8172. [
  8173. "s"=>["r"=>0,"c"=>0],
  8174. "e"=>["r"=>0,"c"=>4]
  8175. ]
  8176. ];
  8177. $cols = [
  8178. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8179. ];
  8180. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8181. }
  8182. }
  8183. }
  8184. //出库、退库导出
  8185. public function _excelctjs()
  8186. {
  8187. $classid = $this->classid->sku();
  8188. $pm = $classid;
  8189. $typeclass = array();
  8190. $tc = $this->typeclass->find_all();
  8191. foreach ($tc as $v) {
  8192. $typeclass[$v['id']] = $v;
  8193. }
  8194. $prc = array();
  8195. $purchase = $this->purchase->find_all();
  8196. foreach ($purchase as $k => $v) {
  8197. $prc[$v['id']] = $v['title'];
  8198. }
  8199. if (isset($_GET['excel'])) {
  8200. $wh = array();
  8201. $w = $this->warehouse->find_all('1=1', 'id,title');
  8202. foreach ($w as $v) {
  8203. $wh[$v['id']] = $v['title'];
  8204. }
  8205. $type = $this->input->get('excel', true);
  8206. $category = $this->input->get('category', true);
  8207. $size = $this->input->get('size', true);
  8208. $grade = $this->input->get('grade', true);
  8209. $color = $this->input->get('color', true);
  8210. $lowe = $this->input->get('lowe', true);
  8211. $sku = $this->input->get('sku', true);
  8212. $title = $this->input->get('title', true);
  8213. $warehouse = $this->input->get('warehouse', true);
  8214. $purchase = $this->input->get('purchase', true);
  8215. $lacetype = $this->input->get('lacetype', true);
  8216. $haircap = $this->input->get('haircap', true);
  8217. $lacecolor = $this->input->get('lacecolor', true);
  8218. $density = $this->input->get('density', true);
  8219. $details = $this->input->get('details', true);
  8220. $state = $this->input->get('state', true);
  8221. $shop = $this->input->get('shop', true);
  8222. $hairnumber = $this->input->get('hairnumber', true);
  8223. $type_leixi = $this->input->get('type', true);
  8224. $cpbz = $this->input->get('cpbz', true);
  8225. $sm = $this->input->get('sm', true);
  8226. $sid = $this->input->get('sid', true);
  8227. $ktime = $this->input->get('ktime', true);
  8228. $jtime = $this->input->get('jtime', true);
  8229. $ktime = strtotime($ktime);
  8230. $jtime = strtotime($jtime);
  8231. //$where = " 1=1 ";
  8232. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8233. $where = " sku != '' ";
  8234. $gj = "";
  8235. $ck = "";
  8236. if ($category) {
  8237. $where .= " and features like '%-$category-%'";
  8238. }
  8239. if ($size) {
  8240. $where .= " and features like '%-$size-%'";
  8241. }
  8242. if ($grade) {
  8243. $where .= " and features like '%-$grade-%'";
  8244. }
  8245. if ($color) {
  8246. $where .= " and features like '%-$color-%'";
  8247. }
  8248. if ($lowe) {
  8249. $where .= " and features like '%-$lowe-%'";
  8250. }
  8251. if ($warehouse) {
  8252. $where .= " and warehouse = '$warehouse'";
  8253. }
  8254. if ($purchase) {
  8255. $where .= " and purchase = '$purchase'";
  8256. }
  8257. if ($state) {
  8258. $where .= " and state = '$state'";
  8259. }
  8260. if ($lacetype) {
  8261. $where .= " and features like '%-$lacetype-%'";
  8262. }
  8263. if ($lacecolor) {
  8264. $where .= " and features like '%-$lacecolor-%'";
  8265. }
  8266. if ($density) {
  8267. $where .= " and features like '%-$density-%'";
  8268. }
  8269. if ($haircap) {
  8270. $where .= " and features like '%-$haircap-%'";
  8271. }
  8272. if ($details) {
  8273. $where .= " and details = '$details'";
  8274. }
  8275. if ($shop) {
  8276. $where .= " and shop like '%$shop%'";
  8277. }
  8278. if ($title) {
  8279. $title = trim($title, ' ');
  8280. $title = trim($title, ' ');
  8281. $where .= " and title like '%$title%'";
  8282. }
  8283. if (!empty($hairnumber)) {
  8284. $where .= " and features like '%-128-%' ";
  8285. if ($hairnumber < 0) {
  8286. $class_list = $this->typeclass->find_all('classid = 43');
  8287. foreach ($class_list as $v) {
  8288. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8289. }
  8290. } else {
  8291. $where .= " and features like '%-$hairnumber-%'";
  8292. }
  8293. }
  8294. if ($type_leixi) {
  8295. $where .= " and type = '$type_leixi'";
  8296. }
  8297. if ($cpbz) {
  8298. $where .= " and cpbz like '%$cpbz%' ";
  8299. }
  8300. if ($sm) {
  8301. $where .= " and sm like '%$sm%' ";
  8302. }
  8303. if ($sku) {
  8304. $sku = trim($sku, ' ');
  8305. $sku = trim($sku, ' ');
  8306. $where .= " and sku like '%$sku%'";
  8307. }
  8308. if ($ktime && $jtime) {
  8309. if ($type == 1) {
  8310. $tl = '出库';
  8311. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8312. } else if ($type == 2) {
  8313. $tl = '退库';
  8314. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8315. } else if ($type == 3) {
  8316. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8317. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8318. } else if ($type == 4) {
  8319. $tl = '出库+零售';
  8320. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8321. } else if ($type == 5) {
  8322. $tl = '零售';
  8323. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8324. }
  8325. }
  8326. $sidwhere = '';
  8327. if ($sid) {
  8328. $sd = "";
  8329. $s = explode(',', trim($sid, ','));
  8330. foreach ($s as $value) {
  8331. $sd .= " id = " . $value . " or";
  8332. }
  8333. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8334. }
  8335. //数据排序
  8336. $order_str = "time desc";
  8337. if (empty($page)) {
  8338. $start = 0;
  8339. $perpage = 1;
  8340. } else {
  8341. $start = ($page - 1) * $perpage;
  8342. }
  8343. //取得信息列表
  8344. if ($type != 3 && $type != 5) {
  8345. if ($type == 1 || $type == 4) {
  8346. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8347. foreach ($info_list as $key => $value) {
  8348. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8349. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8350. $warehouse = $this->warehouse->read($value['warehouse']);
  8351. $info_list[$key]['warehouse'] = $warehouse['title'];
  8352. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8353. $features = explode('-', trim($features, '-'));
  8354. $pm = $classid;
  8355. foreach ($features as $k => $v) {
  8356. if ($v != 0) {
  8357. if (!isset($typeclass[$v])) {
  8358. continue;
  8359. }
  8360. if (isset($pm[$typeclass[$v]['classid']])) {
  8361. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8362. $tz = explode('|', $typeclass[$v]['zh']);
  8363. $pm[$typeclass[$v]['classid']] = $tz[0];
  8364. } else {
  8365. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8366. }
  8367. }
  8368. }
  8369. }
  8370. $zh = implode(" ", $pm);
  8371. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8372. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8373. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8374. $info_list[$key]['features'] = $zh;
  8375. }
  8376. $final_list = [];
  8377. foreach($info_list as $k=>$v){
  8378. $number = "";
  8379. if(!empty($v['orderinfo'])){
  8380. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8381. if(!empty($tmp_info['number'])){
  8382. $number = $tmp_info['number'];
  8383. }
  8384. }
  8385. $final_list[] = [
  8386. 'warehouse'=>$v['warehouse'],
  8387. 'purchase'=>$v['purchase'],
  8388. 'sku'=>$v['sku'],
  8389. 'title'=>$v['title'],
  8390. 'features'=>$v['features'],
  8391. 'label'=>$v['label'],
  8392. 'orderinfo'=>$v['orderinfo'],
  8393. 'number'=>$number,
  8394. 'waybill'=>$v['waybill'],
  8395. 'outk'=>$v['outk'],
  8396. ];
  8397. }
  8398. } else {
  8399. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8400. foreach ($info_list as $key => $value) {
  8401. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8402. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8403. $warehouse = $this->warehouse->read($value['warehouse']);
  8404. $info_list[$key]['warehouse'] = $warehouse['title'];
  8405. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8406. $features = explode('-', trim($features, '-'));
  8407. $pm = $classid;
  8408. foreach ($features as $k => $v) {
  8409. if ($v != 0) {
  8410. if (!isset($typeclass[$v])) {
  8411. continue;
  8412. }
  8413. if (isset($pm[$typeclass[$v]['classid']])) {
  8414. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8415. $tz = explode('|', $typeclass[$v]['zh']);
  8416. $pm[$typeclass[$v]['classid']] = $tz[0];
  8417. } else {
  8418. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8419. }
  8420. }
  8421. }
  8422. }
  8423. $zh = implode(" ", $pm);
  8424. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8425. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8426. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8427. $info_list[$key]['features'] = $zh;
  8428. }
  8429. $final_list = [];
  8430. foreach($info_list as $k=>$v){
  8431. $number = "";
  8432. if(!empty($v['orderinfo'])){
  8433. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8434. if(!empty($tmp_info['number'])){
  8435. $number = $tmp_info['number'];
  8436. }
  8437. }
  8438. $final_list[] = [
  8439. 'warehouse'=>$v['warehouse'],
  8440. 'purchase'=>$v['purchase'],
  8441. 'sku'=>$v['sku'],
  8442. 'title'=>$v['title'],
  8443. 'features'=>$v['features'],
  8444. 'label'=>$v['label'],
  8445. 'orderinfo'=>$v['orderinfo'],
  8446. 'number'=>$number,
  8447. 'waybill'=>$v['waybill'],
  8448. 'retreat'=>$v['retreat'],
  8449. ];
  8450. }
  8451. }
  8452. if(empty($final_list)){
  8453. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8454. }else{
  8455. $end_list = [];
  8456. foreach($final_list as $v){
  8457. $end_list[] = array_values($v);
  8458. }
  8459. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8460. array_unshift($end_list,[
  8461. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8462. ]);
  8463. array_unshift($end_list,[
  8464. $title,"","","","","","","","",""
  8465. ]);
  8466. $merges = [
  8467. [
  8468. "s"=>["r"=>0,"c"=>0],
  8469. "e"=>["r"=>0,"c"=>9]
  8470. ]
  8471. ];
  8472. $cols = [
  8473. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8474. ];
  8475. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8476. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8477. ] )));
  8478. }
  8479. } else if ($type == 5) {
  8480. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8481. foreach ($info_list as $key => $value) {
  8482. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8483. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8484. $warehouse = $this->warehouse->read($value['warehouse']);
  8485. $info_list[$key]['warehouse'] = $warehouse['title'];
  8486. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8487. $features = explode('-', trim($features, '-'));
  8488. $pm = $classid;
  8489. foreach ($features as $k => $v) {
  8490. if ($v != 0) {
  8491. if (!isset($typeclass[$v])) {
  8492. continue;
  8493. }
  8494. if (isset($pm[$typeclass[$v]['classid']])) {
  8495. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8496. $tz = explode('|', $typeclass[$v]['zh']);
  8497. $pm[$typeclass[$v]['classid']] = $tz[0];
  8498. } else {
  8499. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8500. }
  8501. }
  8502. }
  8503. }
  8504. $zh = implode(" ", $pm);
  8505. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8506. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8507. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8508. $info_list[$key]['features'] = $zh;
  8509. }
  8510. if(empty($info_list)){
  8511. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8512. }else{
  8513. $final_list = [];
  8514. foreach($info_list as $v){
  8515. $final_list[] = array_values($v);
  8516. }
  8517. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8518. array_unshift($final_list,[
  8519. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8520. ]);
  8521. array_unshift($final_list,[
  8522. $title,"","","","","","",
  8523. ]);
  8524. $merges = [
  8525. [
  8526. "s"=>["r"=>0,"c"=>0],
  8527. "e"=>["r"=>0,"c"=>6]
  8528. ]
  8529. ];
  8530. $cols = [
  8531. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8532. ];
  8533. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8534. }
  8535. } else {
  8536. $wh = array();
  8537. $w = $this->warehouse->find_all('1=1', 'id,title');
  8538. foreach ($w as $v) {
  8539. $wh[$v['id']] = $v['title'];
  8540. }
  8541. $wt = array();
  8542. $whlabel_type = $this->whlabel_type->find_all();
  8543. foreach ($whlabel_type as $v) {
  8544. $wt[$v['id']] = $v['title'];
  8545. }
  8546. $classid = $this->classid->sku();
  8547. $list = array();
  8548. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8549. foreach ($rows as $key => $value) {
  8550. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8551. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8552. $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');
  8553. $details = array();
  8554. $cpid = array();
  8555. $cpbz = array();
  8556. $c = 0;
  8557. $g = 0;
  8558. $x = 0;
  8559. $t = 0;
  8560. $s = 0;
  8561. $q = 0;
  8562. foreach ($sd as $k => $v) {
  8563. if ($v['state'] == 0) {
  8564. $c++;
  8565. }
  8566. if ($v['state'] != 9) {
  8567. $g++;
  8568. }
  8569. if ($v['outk'] > 1) {
  8570. $x++;
  8571. }
  8572. if ($v['retreat'] > 0) {
  8573. $t++;
  8574. }
  8575. if ($v['state'] == 8) {
  8576. $s++;
  8577. }
  8578. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8579. $q++;
  8580. }
  8581. $details[$v['details']] = $v['details'];
  8582. if ($v['cpid'] != 0) {
  8583. $cpid[$v['cpid']] = $v['cpid'];
  8584. }
  8585. if ($v['cpbz'] != '') {
  8586. $cpbz[$v['cpbz']] = $v['cpbz'];
  8587. }
  8588. }
  8589. if (isset($wt[$value['type']])) {
  8590. $rows[$key]['type'] = $wt[$value['type']];
  8591. } else {
  8592. $rows[$key]['type'] = '未设置';
  8593. }
  8594. $rows[$key]['details'] = implode("、", $details);
  8595. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8596. $ftime = time() - 15 * 24 * 3600;
  8597. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8598. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8599. $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);
  8600. $rows[$key]['c'] = $c;
  8601. $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);
  8602. $rows[$key]['t'] = $t;
  8603. $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'] . '"');
  8604. $rows[$key]['z'] = $z;
  8605. // $jm = $classid;
  8606. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8607. $features = explode('-', trim($features, '-'));
  8608. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8609. }
  8610. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8611. $final_list =[];
  8612. foreach($tmp_list as $k=>$v){
  8613. $final_list[] = [
  8614. "warehouse"=>$v['warehouse'],
  8615. "purchase"=>$v['purchase'],
  8616. "details"=>$v['details'],
  8617. "cpid"=>$v['cpid'],
  8618. "sku"=>$v['sku'],
  8619. "title"=>$v['title'],
  8620. "features"=>$v['pm'],
  8621. "cpbz"=>$v['cpbz'],
  8622. "sm"=>$v['sm'],
  8623. "type"=>$v['type'],
  8624. "g"=>$v["g"],
  8625. "c"=>$v["c"],
  8626. "x"=>$v["x"],
  8627. "t"=>$v["t"],
  8628. "z"=>$v["z"],
  8629. "jm"=>$v["jm"],
  8630. "weight"=>$v["weight"],
  8631. "asd"=>$v["asd"],
  8632. ];
  8633. }
  8634. if(empty($final_list)){
  8635. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8636. }else{
  8637. $end_list = [];
  8638. foreach($final_list as $v){
  8639. $end_list[] = array_values($v);
  8640. }
  8641. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8642. array_unshift($end_list,[
  8643. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8644. ]);
  8645. array_unshift($end_list,[
  8646. $title,"","","","","","","","","","","","","","","","","",""
  8647. ]);
  8648. $merges = [
  8649. [
  8650. "s"=>["r"=>0,"c"=>0],
  8651. "e"=>["r"=>0,"c"=>6]
  8652. ]
  8653. ];
  8654. $cols = [
  8655. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8656. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8657. ];
  8658. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8659. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8660. ])));
  8661. }
  8662. }
  8663. }
  8664. }
  8665. public function _exceljxcjs(){
  8666. $classid = $this->classid->sku();
  8667. $pm = $classid;
  8668. $typeclass = array();
  8669. $tc = $this->typeclass->find_all();
  8670. foreach ($tc as $v) {
  8671. $typeclass[$v['id']] = $v;
  8672. }
  8673. $prc = array();
  8674. $purchase = $this->purchase->find_all();
  8675. foreach ($purchase as $k => $v) {
  8676. $prc[$v['id']] = $v['title'];
  8677. }
  8678. if(!isset($_GET['excel'])){
  8679. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8680. }
  8681. $where = "sku != 'Preset'";
  8682. //数据排序
  8683. $order_str = "id desc";
  8684. if (empty($page)) {
  8685. $start = 0;
  8686. $perpage = 1;
  8687. } else {
  8688. $start = ($page - 1) * $perpage;
  8689. }
  8690. $category = $this->input->get('category', true);
  8691. $warehouse = $this->input->get('warehouse', true);
  8692. $excelid = $this->input->get('sid', true);
  8693. if ($category) {
  8694. $where .= " and features like '%-$category-%'";
  8695. }
  8696. if ($warehouse) {
  8697. $where .= " and warehouse = '$warehouse'";
  8698. }
  8699. $xzid = '';
  8700. if ($excelid) {
  8701. $excelid = explode(',', trim($excelid, ','));
  8702. foreach ($excelid as $key => $value) {
  8703. $xzid .= " id = " . $value . " or";
  8704. }
  8705. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8706. }
  8707. $wt = array();
  8708. $whlabel_type = $this->whlabel_type->find_all();
  8709. foreach ($whlabel_type as $v) {
  8710. $wt[$v['id']] = $v['title'];
  8711. }
  8712. $wh = array();
  8713. $w = $this->warehouse->find_all('1=1', 'id,title');
  8714. foreach ($w as $v) {
  8715. $wh[$v['id']] = $v['title'];
  8716. }
  8717. $list = array();
  8718. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8719. foreach ($rows as $key => $value) {
  8720. if (isset($wt[$value['type']])) {
  8721. $rows[$key]['type'] = $wt[$value['type']];
  8722. } else {
  8723. $rows[$key]['type'] = '未设置';
  8724. }
  8725. $bm = '03';
  8726. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8727. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8728. $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');
  8729. $details = array();
  8730. $cpid = array();
  8731. $cpbz = array();
  8732. $c = 0;
  8733. $g = 0;
  8734. $x = 0;
  8735. $t = 0;
  8736. $s = 0;
  8737. $q = 0;
  8738. foreach ($sd as $k => $v) {
  8739. if ($v['state'] == 0) {
  8740. $c++;
  8741. if ($v['cpid'] != 0) {
  8742. $cpid[$v['cpid']] = $v['cpid'];
  8743. }
  8744. if ($v['cpbz'] != '') {
  8745. $cpbz[$v['cpbz']] = $v['cpbz'];
  8746. }
  8747. }
  8748. if ($v['state'] != 9) {
  8749. $g++;
  8750. }
  8751. if ($v['state'] == 1) {
  8752. $x++;
  8753. }
  8754. if ($v['state'] == 2) {
  8755. $t++;
  8756. }
  8757. if ($v['state'] == 8) {
  8758. $s++;
  8759. }
  8760. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8761. $q++;
  8762. }
  8763. $details[$v['details']] = $v['details'];
  8764. }
  8765. $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'] . '"');
  8766. $rows[$key]['details'] = implode("、", $details);
  8767. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8768. $number = $value['number'];
  8769. $ftime = time() - 15 * 24 * 3600;
  8770. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8771. $rows[$key]['number'] = $g;
  8772. $rows[$key]['c'] = $c;
  8773. $rows[$key]['x'] = $x;
  8774. $rows[$key]['t'] = $t;
  8775. $rows[$key]['s'] = $s;
  8776. $rows[$key]['q'] = $q;
  8777. $rows[$key]['z'] = $z;
  8778. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8779. $features = explode('-', trim($features, '-'));
  8780. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8781. }
  8782. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8783. $final_list = [];
  8784. foreach ($list as $k => $v) {
  8785. if (empty($v['sku'])) {
  8786. continue;
  8787. }
  8788. $final_list[] = [
  8789. $v["warehouse"],
  8790. $v["purchase"],
  8791. $v["details"],
  8792. $v["cpid"],
  8793. $v["dbcontent"],
  8794. $v["sku"],
  8795. $v["bm"],
  8796. $v["jm"],
  8797. $v["title"],
  8798. $v["pm"],
  8799. $v["cpbz"],
  8800. $v["sm"],
  8801. $v["type"],
  8802. $v["number"],
  8803. $v["c"],
  8804. $v["x"],
  8805. $v["t"],
  8806. $v["s"],
  8807. $v["q"],
  8808. $v["z"],
  8809. $v['weight'],
  8810. ];
  8811. }
  8812. if(empty($final_list)){
  8813. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8814. }
  8815. $title = "总进销存统计表";
  8816. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8817. $merges = [
  8818. [
  8819. "s"=>["r"=>0,"c"=>0],
  8820. "e"=>["r"=>0,"c"=>21]
  8821. ]
  8822. ];
  8823. $cols = [
  8824. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8825. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8826. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8827. ];
  8828. array_unshift($final_list, $first_row);
  8829. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8830. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8831. }
  8832. public function _summaryjs($arg_array)
  8833. {
  8834. $prc = array();
  8835. $purchase = $this->purchase->find_all();
  8836. foreach ($purchase as $k => $v) {
  8837. $prc[$v['id']] = $v['title'];
  8838. }
  8839. if (isset($_GET['excel'])) {
  8840. $ktime = $this->input->get('ktime', true);
  8841. $jtime = $this->input->get('jtime', true);
  8842. $ktime = strtotime($ktime);
  8843. $jtime = strtotime($jtime);
  8844. $where = "1=1";
  8845. if ($ktime && $jtime) {
  8846. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8847. }
  8848. //数据排序
  8849. $order_str = "time desc";
  8850. if (empty($page)) {
  8851. $start = 0;
  8852. $perpage = 1;
  8853. } else {
  8854. $start = ($page - 1) * $perpage;
  8855. }
  8856. //取得信息列表
  8857. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8858. foreach ($info_list as $key => $value) {
  8859. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8860. $warehouse = $this->warehouse->read($value['warehouse']);
  8861. $info_list[$key]['warehouse'] = $warehouse['title'];
  8862. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8863. $details = array();
  8864. $cpid = array();
  8865. foreach ($x as $k => $v) {
  8866. if ($v['details'] != '') {
  8867. $details[$v['details']] = $v['details'];
  8868. }
  8869. if ($v['cpid'] != 0) {
  8870. $cpid[$v['cpid']] = $v['cpid'];
  8871. }
  8872. }
  8873. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8874. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8875. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8876. $info_list[$key]['s'] = $s;
  8877. $info_list[$key]['x'] = count($x);
  8878. }
  8879. if(empty($info_list)){
  8880. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8881. }
  8882. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8883. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8884. $merges = [
  8885. [
  8886. "s"=>["r"=>0,"c"=>0],
  8887. "e"=>["r"=>0,"c"=>7]
  8888. ]
  8889. ];
  8890. $cols = [
  8891. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8892. ];
  8893. $final_list = [];
  8894. foreach($info_list as $k => $v){
  8895. $final_list[] = array_values($v);
  8896. }
  8897. array_unshift($final_list, $first_row);
  8898. array_unshift($final_list,[
  8899. $title,"","","","","","","","",
  8900. ]);
  8901. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8902. $titlename = "<table border=1>
  8903. <tr align='center'>
  8904. <td>仓库</td>
  8905. <td>供应商</td>
  8906. <td>出库位置</td>
  8907. <td>出库编码</td>
  8908. <td>SKU</td>
  8909. <td>产品名</td>
  8910. <td>总剩余库存</td>
  8911. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8912. </tr>
  8913. </table>";
  8914. $filename = $title . ".xls";
  8915. $tail = "";
  8916. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8917. }
  8918. }
  8919. public function _uckjs()
  8920. {
  8921. if (isset($_GET['excel'])) {
  8922. $tc = array();
  8923. $typeclass = $this->typeclass->find_all();
  8924. foreach ($typeclass as $v) {
  8925. $tc[$v['id']] = $v['zh'];
  8926. }
  8927. $first_row = [
  8928. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8929. ];
  8930. $t = array();
  8931. $rq = '';
  8932. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8933. $ts = $ts / (24 * 3600);
  8934. for ($i = 0; $i < $ts; $i++) {
  8935. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8936. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8937. }
  8938. $day_len = count($t);
  8939. $first_row[] = "本月出库";
  8940. $merges = [
  8941. ];
  8942. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8943. $excel_key = 1;
  8944. $final_list = [];
  8945. foreach ($info_list as $k => $v) {
  8946. $features = explode('-', trim($v['features'], '-'));
  8947. if (!isset($features[3]) || !isset($features[4])) {
  8948. continue;
  8949. }
  8950. $tmp = [];
  8951. $tmp[0] = $tc[$features[0]]; //类型
  8952. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8953. $tmp[2] = $tc[$features[4]]; //曲度
  8954. $tmp[3] = '';
  8955. if (isset($data[$k][1])) {
  8956. $tmp[3] .=$tmp[1];
  8957. }
  8958. if (isset($data[$k][2])) {
  8959. $tmp[3] .= $tmp[2];
  8960. }
  8961. if (isset($features[5])) {
  8962. $tmp[3] .= $tc[$features[5]];
  8963. }
  8964. if (isset($features[2])) {
  8965. $tmp[3] .= $tc[$features[2]];
  8966. }
  8967. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8968. $tmp[4] = $v['sku'];
  8969. $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())) . '))'); //月初库存
  8970. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8971. $tmp[7] ="";
  8972. $tmp[8] ="";
  8973. $byck = 0;
  8974. foreach ($t as $vv) {
  8975. $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));
  8976. $tmp[] = ($sl > 0) ? $sl : '';
  8977. $byck += $sl;
  8978. }
  8979. $tmp[] = ($byck > 0) ? $byck : '';
  8980. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8981. // $ztrq = '';
  8982. // $ztsl = '';
  8983. // if (count($zt) > 0) {
  8984. // foreach ($zt as $vv) {
  8985. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8986. // $ztsl .= $vv['num'] . '<br>';
  8987. // }
  8988. // }
  8989. if(empty($zt)){
  8990. $final_list[] = $tmp;
  8991. $excel_key = $excel_key + 1;
  8992. }else{
  8993. $len = count($zt);
  8994. if($len == 1){
  8995. $tmp[7] = $zt[0]['num'] ;
  8996. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8997. $final_list[] = $tmp;
  8998. $excel_key = $excel_key + 1;
  8999. }else{
  9000. foreach($zt as $vv){
  9001. $tmp[7] = "";
  9002. $tmp[8] = "";
  9003. $tmp[7] = $vv['num'];
  9004. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9005. $final_list[] = $tmp;
  9006. }
  9007. $merges[] = [
  9008. "s"=>["r"=>$excel_key,"c"=>0],
  9009. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9010. ];
  9011. $merges[] = [
  9012. "s"=>["r"=>$excel_key,"c"=>1],
  9013. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9014. ];
  9015. $merges[] = [
  9016. "s"=>["r"=>$excel_key,"c"=>2],
  9017. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9018. ];
  9019. $merges[] = [
  9020. "s"=>["r"=>$excel_key,"c"=>3],
  9021. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9022. ];
  9023. $merges[] = [
  9024. "s"=>["r"=>$excel_key,"c"=>4],
  9025. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9026. ];
  9027. $merges[] = [
  9028. "s"=>["r"=>$excel_key,"c"=>5],
  9029. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9030. ];
  9031. $merges[] = [
  9032. "s"=>["r"=>$excel_key,"c"=>6],
  9033. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9034. ];
  9035. for($i=1;$i<=$day_len;$i++){
  9036. $merges[] = [
  9037. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9038. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9039. ];
  9040. }
  9041. $merges[] = [
  9042. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9043. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9044. ];
  9045. $excel_key = $excel_key + $len;
  9046. }
  9047. }
  9048. }
  9049. $title = "详情 " . date("Y-m-d", time());
  9050. if(empty($final_list)){
  9051. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9052. }
  9053. $cols = [
  9054. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9055. ];
  9056. array_unshift($final_list, $first_row);
  9057. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9058. }
  9059. }
  9060. public function _whlabelexcelzhjs(){
  9061. if(empty($_GET['excel'])){
  9062. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9063. }
  9064. $where = "sku != 'Preset' and sku != '' ";
  9065. //数据排序
  9066. $order_str = "id desc";
  9067. if (empty($page)) {
  9068. $start = 0;
  9069. $perpage = 1;
  9070. } else {
  9071. $start = ($page - 1) * $perpage;
  9072. }
  9073. $category = $this->input->get('category', true);
  9074. $warehouse = $this->input->get('warehouse', true);
  9075. $excelid = $this->input->get('sid', true);
  9076. if ($category) {
  9077. $where .= " and features like '%-$category-%'";
  9078. }
  9079. if ($warehouse) {
  9080. $where .= " and warehouse = '$warehouse'";
  9081. }
  9082. $xzid = '';
  9083. if ($excelid) {
  9084. $excelid = explode(',', trim($excelid, ','));
  9085. foreach ($excelid as $key => $value) {
  9086. $xzid .= " id = " . $value . " or";
  9087. }
  9088. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9089. }
  9090. $merges = [
  9091. [
  9092. "s"=>["r"=>0,"c"=>0],
  9093. "e"=>["r"=>0,"c"=>6]
  9094. ]
  9095. ];
  9096. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9097. $excel_index = 2;
  9098. $final_list = [];
  9099. foreach ($rows as $key => $value) {
  9100. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9101. $zh = '';
  9102. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9103. // foreach ($zt_list as $v) {
  9104. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9105. // }
  9106. $zt = array_sum(array_column($zt_list, 'num'));
  9107. $number = $value['number'];
  9108. $ftime = time() - 15 * 24 * 3600;
  9109. $warehouse = $this->warehouse->read($value['warehouse']);
  9110. // $rows[$key]['warehouse'] = $warehouse['title'];
  9111. // $rows[$key]['number'] = $c;
  9112. // $rows[$key]['features'] = $zh;
  9113. //$rows[$key]['hb'] = $c + $zt;
  9114. $tmp = [];
  9115. $tmp[0] = $warehouse['title'];
  9116. $tmp[1] = $value['sku'];
  9117. $tmp[2] = $value['title'];
  9118. $tmp[3] = $c;
  9119. $tmp[4] = "";
  9120. $tmp[5] = $c + $zt;
  9121. if(empty($zt_list)){
  9122. $tmp[4] = "";
  9123. $final_list[] = $tmp;
  9124. $excel_index = $excel_index + 1;
  9125. }else{
  9126. if(count($zt_list) == 1){
  9127. $tmp[4] = "";
  9128. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9129. $final_list[] = $tmp;
  9130. $excel_index = $excel_index + 1;
  9131. }else{
  9132. $len = count($zt_list);
  9133. foreach ($zt_list as $v){
  9134. $tmp[4] = "";
  9135. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9136. $final_list[] = $tmp;
  9137. }
  9138. $merges[] = [
  9139. "s"=>["r"=>$excel_index,"c"=>0],
  9140. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9141. ];
  9142. $merges[] = [
  9143. "s"=>["r"=>$excel_index,"c"=>1],
  9144. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9145. ];
  9146. $merges[] = [
  9147. "s"=>["r"=>$excel_index,"c"=>2],
  9148. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9149. ];
  9150. $merges[] = [
  9151. "s"=>["r"=>$excel_index,"c"=>3],
  9152. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9153. ];
  9154. $merges[] = [
  9155. "s"=>["r"=>$excel_index,"c"=>5],
  9156. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9157. ];
  9158. $excel_index = $excel_index + $len;
  9159. }
  9160. }
  9161. }
  9162. $first_row = [
  9163. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9164. ];
  9165. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9166. if(empty($final_list)){
  9167. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9168. }
  9169. $cols = [
  9170. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9171. ];
  9172. array_unshift($final_list, $first_row);
  9173. array_unshift($final_list, [
  9174. $title,"","","","",""
  9175. ]);
  9176. $end_list = [];
  9177. foreach ($final_list as $key => $value) {
  9178. $end_list[] = array_values($value);
  9179. }
  9180. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9181. }
  9182. //出库、退库导出
  9183. public function _dccrtypejs()
  9184. {
  9185. $classid = $this->classid->sku();
  9186. $pm = $classid;
  9187. $typeclass = array();
  9188. $tc = $this->typeclass->find_all();
  9189. foreach ($tc as $v) {
  9190. $typeclass[$v['id']] = $v;
  9191. }
  9192. $prc = array();
  9193. $purchase = $this->purchase->find_all();
  9194. foreach ($purchase as $k => $v) {
  9195. $prc[$v['id']] = $v['title'];
  9196. }
  9197. if (isset($_GET['sid'])) {
  9198. $wh = array();
  9199. $w = $this->warehouse->find_all('1=1', 'id,title');
  9200. foreach ($w as $v) {
  9201. $wh[$v['id']] = $v['title'];
  9202. }
  9203. $type = $this->input->get('excel', true);
  9204. $category = $this->input->get('category', true);
  9205. $size = $this->input->get('size', true);
  9206. $grade = $this->input->get('grade', true);
  9207. $color = $this->input->get('color', true);
  9208. $lowe = $this->input->get('lowe', true);
  9209. $sku = $this->input->get('sku', true);
  9210. $warehouse = $this->input->get('warehouse', true);
  9211. $lacetype = $this->input->get('lacetype', true);
  9212. $lacecolor = $this->input->get('lacecolor', true);
  9213. $density = $this->input->get('density', true);
  9214. $haircap = $this->input->get('haircap', true);
  9215. $purchase = $this->input->get('purchase', true);
  9216. $title = $this->input->get('title', true);
  9217. $state = $this->input->get('state', true);
  9218. $sid = $this->input->get('sid', true);
  9219. $ktime = $this->input->get('ktime', true);
  9220. $jtime = $this->input->get('jtime', true);
  9221. $ktime = strtotime($ktime);
  9222. $jtime = strtotime($jtime);
  9223. $where = "1=1";
  9224. $gj = "";
  9225. $ck = "";
  9226. if ($category) {
  9227. $where .= " and features like '%-$category-%'";
  9228. }
  9229. if ($size) {
  9230. $where .= " and features like '%-$size-%'";
  9231. }
  9232. if ($grade) {
  9233. $where .= " and features like '%-$grade-%'";
  9234. }
  9235. if ($color) {
  9236. $where .= " and features like '%-$color-%'";
  9237. }
  9238. if ($lowe) {
  9239. $where .= " and features like '%-$lowe-%'";
  9240. }
  9241. if ($warehouse) {
  9242. $where .= " and warehouse = '$warehouse'";
  9243. }
  9244. if ($purchase) {
  9245. $where .= " and purchase = '$purchase'";
  9246. }
  9247. if ($state) {
  9248. $where .= " and state = '$state'";
  9249. }
  9250. if ($lacetype) {
  9251. $where .= " and features like '%-$lacetype-%'";
  9252. }
  9253. if ($lacecolor) {
  9254. $where .= " and features like '%-$lacecolor-%'";
  9255. }
  9256. if ($density) {
  9257. $where .= " and features like '%-$density-%'";
  9258. }
  9259. if ($haircap) {
  9260. $where .= " and features like '%-$haircap-%'";
  9261. }
  9262. if ($title) {
  9263. $title = trim($title, ' ');
  9264. $title = trim($title, ' ');
  9265. $where .= " and title like '%$title%'";
  9266. }
  9267. if ($sku) {
  9268. $sku = trim($sku, ' ');
  9269. $sku = trim($sku, ' ');
  9270. $where .= " and sku like '%$sku%'";
  9271. }
  9272. if ($ktime && $jtime) {
  9273. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9274. }
  9275. $sidwhere = '';
  9276. if ($sid) {
  9277. $sd = "";
  9278. $s = explode(',', trim($sid, ','));
  9279. foreach ($s as $value) {
  9280. $sd .= " id = " . $value . " or";
  9281. }
  9282. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9283. }
  9284. //数据排序
  9285. $order_str = "time desc";
  9286. if (empty($page)) {
  9287. $start = 0;
  9288. $perpage = 1;
  9289. } else {
  9290. $start = ($page - 1) * $perpage;
  9291. }
  9292. $wh = array();
  9293. $w = $this->warehouse->find_all('1=1', 'id,title');
  9294. foreach ($w as $v) {
  9295. $wh[$v['id']] = $v['title'];
  9296. }
  9297. $wt = array();
  9298. $whlabel_type = $this->whlabel_type->find_all();
  9299. foreach ($whlabel_type as $v) {
  9300. $wt[$v['id']] = $v['title'];
  9301. }
  9302. $classid = $this->classid->sku();
  9303. $list = array();
  9304. $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');
  9305. foreach ($rows_r as $key => $value) {
  9306. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9307. $pm = $classid;
  9308. $jm = $classid;
  9309. $rows_r[$key]['enter'] = '入库';
  9310. $rows_r[$key]['time'] = $value['enter'];
  9311. if ($value['rktype'] == 1) {
  9312. $rows_r[$key]['rktype'] = '采购入库';
  9313. } else if ($value['rktype'] == 2) {
  9314. $rows_r[$key]['rktype'] = '盘盈调整';
  9315. } else if ($value['rktype'] == 3) {
  9316. $rows_r[$key]['rktype'] = '其他调整入库';
  9317. } else if ($value['rktype'] == 4) {
  9318. $rows_r[$key]['rktype'] = '其他调整入库';
  9319. } else if ($value['rktype'] == 5) {
  9320. $rows_r[$key]['rktype'] = '退库入库';
  9321. } else if ($value['rktype'] == 6) {
  9322. $rows_r[$key]['rktype'] = '退货可用入库';
  9323. } else if ($value['rktype'] == 7) {
  9324. $rows_r[$key]['rktype'] = '形态转换入库';
  9325. } else {
  9326. $rows_r[$key]['rktype'] = '';
  9327. }
  9328. $features = explode('-', trim($value['features'], '-'));
  9329. foreach ($features as $v) {
  9330. if (isset($typeclass[$v])) {
  9331. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9332. $pm[$typeclass[$v]['classid']] = $zh[0];
  9333. }
  9334. if (isset($typeclass[$v])) {
  9335. if (isset($jm[$typeclass[$v]['classid']])) {
  9336. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9337. }
  9338. }
  9339. }
  9340. $zh = implode(" ", $pm);
  9341. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9342. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9343. $rows_r[$key]['zh'] = $zh;
  9344. $jm = array_filter($jm);
  9345. $rows_r[$key]['features'] = implode("-", $jm);
  9346. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9347. }
  9348. $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');
  9349. foreach ($rows_c as $key => $value) {
  9350. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9351. $pm = $classid;
  9352. $jm = $classid;
  9353. $rows_c[$key]['time'] = $value['outk'];
  9354. $rows_c[$key]['outk'] = '出库';
  9355. if ($value['cktype'] == 1) {
  9356. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9357. } else if ($value['cktype'] == 2) {
  9358. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9359. } else if ($value['cktype'] == 3) {
  9360. $rows_c[$key]['cktype'] = '盘亏调整';
  9361. } else if ($value['cktype'] == 4) {
  9362. $rows_c[$key]['cktype'] = '其他调整出库';
  9363. } else if ($value['cktype'] == 5) {
  9364. $rows_c[$key]['cktype'] = '形态转换出库';
  9365. } else {
  9366. $rows_c[$key]['cktype'] = '';
  9367. }
  9368. unset($rows_c[$key]['state']);
  9369. $features = explode('-', trim($value['features'], '-'));
  9370. foreach ($features as $v) {
  9371. if (isset($typeclass[$v])) {
  9372. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9373. $pm[$typeclass[$v]['classid']] = $zh[0];
  9374. }
  9375. if (isset($typeclass[$v])) {
  9376. if (isset($jm[$typeclass[$v]['classid']])) {
  9377. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9378. }
  9379. }
  9380. }
  9381. $zh = implode(" ", $pm);
  9382. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9383. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9384. $rows_c[$key]['zh'] = $zh;
  9385. $jm = array_filter($jm);
  9386. $rows_c[$key]['features'] = implode("-", $jm);
  9387. $rows_c[$key]['number'] = 1;
  9388. }
  9389. $merged = $rows_r;
  9390. foreach ($rows_c as $key => $value) {
  9391. if (isset($merged[$key])) {
  9392. $merged[] = $value;
  9393. } else {
  9394. $merged[$key] = $value;
  9395. }
  9396. }
  9397. usort($merged, function ($a, $b) {
  9398. return $a['time'] - $b['time'];
  9399. });
  9400. foreach ($merged as $key => $value) {
  9401. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9402. }
  9403. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9404. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9405. $cols = [
  9406. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9407. ];
  9408. $final_list= [];
  9409. foreach($merged as $key => $value){
  9410. $final_list[] = array_values($value) ;
  9411. }
  9412. if(empty($merged)){
  9413. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9414. }
  9415. array_unshift($final_list, $first_row);
  9416. $end_list = [];
  9417. foreach ($final_list as $key => $value) {
  9418. $end_list[] = array_values($value);
  9419. }
  9420. $merges = [];
  9421. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9422. }
  9423. }
  9424. public function _errorexceljs()
  9425. {
  9426. $post = $this->input->post(NULL, TRUE);
  9427. if (isset($_GET['page'])) {
  9428. $page = $this->input->get('page', true);
  9429. $perpage = $this->input->get('perpage', true);
  9430. $sku = $this->input->get('sku', true);
  9431. $warehouse = $this->input->get('warehouse', true);
  9432. $ktime = $this->input->get('ktime', true);
  9433. $jtime = $this->input->get('jtime', true);
  9434. $ktime = strtotime($ktime);
  9435. $jtime = strtotime($jtime);
  9436. $where = "sku != 'Preset'";
  9437. $gj = '';
  9438. if ($sku) {
  9439. $where .= " and sku like '%$sku%'";
  9440. } else {
  9441. if ($ktime && $jtime) {
  9442. $gj = " and time > '$ktime' and time < '$jtime'";
  9443. }
  9444. }
  9445. if ($warehouse) {
  9446. $where .= " and warehouse = '$warehouse'";
  9447. }
  9448. //数据排序
  9449. $order_str = "id desc";
  9450. if (empty($page)) {
  9451. $start = 0;
  9452. $perpage = 1;
  9453. } else {
  9454. $start = ($page - 1) * $perpage;
  9455. }
  9456. //取得信息列表
  9457. $rows = array();
  9458. $list = array();
  9459. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9460. foreach ($info_list as $value) {
  9461. $warehouse = $this->warehouse->read($value['warehouse']);
  9462. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9463. $number = $value['number'];
  9464. $ftime = time() - 15 * 24 * 3600;
  9465. if ($c < 1) {
  9466. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9467. }
  9468. }
  9469. $title = "0库存汇总";
  9470. $first_row = ["仓库","SKU","产品","当前库存"];
  9471. $cols = [
  9472. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9473. ];
  9474. $final_list= [];
  9475. foreach($list as $key => $value){
  9476. $final_list[] = array_values($value) ;
  9477. }
  9478. if(empty($final_list)){
  9479. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9480. }
  9481. array_unshift($final_list, $first_row);
  9482. $merges = [];
  9483. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9484. }
  9485. }
  9486. }