123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Whlabel extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_whlabel','whlabel');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_purchase','purchase');
- $this->load->_model('Model_excel','excel');
- $this->load->_model('Model_fullorder','fullorder');
- $this->load->_model('Model_fullordertt','fullordertt');
- $this->load->_model('Model_fullorder_smt','fullorder_smt');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- $this->load->_model('Model_express','express');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_typeclass','typeclass');
- $this->load->_model('Model_country','country');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_kdniao','kdniao');
- $this->load->_model('Model_notice','notice');
- $this->load->_model('Model_dhl','dhl');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_fullorderexcel','fullorderexcel');
- $this->load->_model('Model_ljg','ljg');
- $this->load->_model('Model_usps','usps');
- $this->load->_model('Model_specialstock','specialstock');
- $this->load->_model('Model_whlabellabel','whlabellabel');
- $this->load->_model('Model_whlabelwz','whlabelwz');
- $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
- $this->load->_model('Model_whlabeltransport','whlabeltransport');
- $this->load->_model('Model_orderurl','orderurl');
- $this->load->_model('Model_brand','brand');
- $this->load->_model('Model_classid','classid');
- $this->load->_model('Model_apiyy','apiyy');
- $this->load->_model('Model_power','power');
- $this->load->_model('Model_whlabel_type','whlabel_type');
- $this->load->_model('Model_company','company');
- $this->load->_model('Model_whlabel_list','whlabel_list');
- $this->load->_model("Model_logic_whlabel","logic_whlabel");
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'existence')//在库标签
- {
- $this->_existence();
- }
- else if($arg == 'cpbqdc')//在库标签
- {
- $this->_cpbqdc();
- }
- else if($arg == 'type')//进销存浏览
- {
- $this->_type();
- }
- else if($arg == 'typedy')//进销存浏览店员页面
- {
- $this->_typedy($arg_array);
- }
- else if($arg == 'typedy_ck')//进销存浏览店员页面
- {
- $this->_typedy_ck($arg_array);
- }
- else if($arg == 'typeck')
- {
- $this->_typeck($arg_array);
- }
- else if($arg == 'whlabeckdc')
- {
- $this->_whlabeckdc($arg_array);
- }
- else if($arg == 'usatype')//美仓进销存浏览
- {
- $this->_usatype();
- }
- else if($arg == 'usatypeapp')//美仓APP进销存浏览
- {
- $this->_usatypeapp();
- }
- else if($arg == 'enteradd')//入库操作
- {
- $this->_enteradd();
- }
- else if($arg == 'enteredit')//修改
- {
- $this->_enteredit($arg_array);
- }
- else if($arg == 'enter')//入库浏览
- {
- $this->_enter();
- }
- else if($arg == 'out')//出库浏览
- {
- $this->_out();
- }
- else if($arg == 'label')//出库标签浏览
- {
- $this->_label();
- }
- else if($arg == 'outorder')//独立站出库订单
- {
- $this->_outorder();
- }
- else if($arg == 'soutorder')//速卖通出库订单
- {
- $this->_soutorder();
- }
- else if($arg == 'toutorder')//TT出库订单
- {
- $this->_toutorder();
- }
- else if($arg == 'retreat')//退库订单
- {
- $this->_retreat();
- }
- else if($arg == 'retreatlk')//退库订单
- {
- $this->_retreatlk();
- }
- else if($arg == 'change')//更换标签
- {
- $this->_change();
- }
- else if($arg == 'del')//删除
- {
- $this->_del();
- }
- else if($arg == 'exceljxc')//进销存信息导出
- {
- $this->_exceljxc();
- }
- else if($arg == 'excelr')//入库信息导出
- {
- $this->_excelr();
- }
- else if($arg == 'excelct')//出库、退库信息导出
- {
- $this->_excelct();
- }
- else if($arg == 'dccrtype')//根据出入库类型导出
- {
- $this->_dccrtype();
- }
- else if($arg == 'excelcr')//出库、退库信息导出
- {
- $this->_excelcr();
- }
- else if($arg == 'kcyz')//库存验证
- {
- $this->_kcyz();
- }
- else if($arg == 'kj')//库存扣减
- {
- $this->_kj($arg_array);
- }
- else if($arg == 'presetout')//预设库存导入
- {
- $this->_presetout($arg_array);
- }
- else if($arg == 'presetedit')//预设库存导入
- {
- $this->_presetedit($arg_array);
- }
- else if($arg == 'summary')//汇总导出
- {
- $this->_summary($arg_array);
- }
- else if($arg == 'manifest')//usps发货清单
- {
- $this->_manifest();
- }
- else if($arg == 'abnormal')//占单异常
- {
- $this->_abnormal();
- }
- else if($arg == 'error')//0库存SKU
- {
- $this->_error();
- }
- else if($arg == 'errorexcel')//0库存SKU导出
- {
- $this->_errorexcel();
- }
- else if($arg == 'db')
- {
- $this->_db();
- }
- else if($arg == 'dbrk')
- {
- $this->_dbrk();
- }
- else if($arg == 'whlabelczdc')
- {
- $this->_whlabelczdc();
- }
- else if($arg == 'print')
- {
- $this->_print($arg_array);
- }
- else if($arg == 'usaprint')
- {
- $this->_usaprint($arg_array);
- }
- else if($arg == 'printck')
- {
- $this->_printck($arg_array);
- }
- else if($arg == 'printrk')
- {
- $this->_printrk($arg_array);
- }
- else if($arg == 'printxzrk')
- {
- $this->_printxzrk($arg_array);
- }
- else if($arg == 'printexcel')
- {
- $this->_printexcel($arg_array);
- }
- else if($arg == 'uck')
- {
- $this->_uck();
- }
- else if($arg == 'whlabelexcelzh')
- {
- $this->_whlabelexcelzh();
- }
- else if($arg == 'fc')
- {
- $this->_fc();
- }
- else if($arg == 'fcmb')
- {
- $this->_fcmb();
- }
- else if($arg == 'fcexcel')
- {
- $this->_fcexcel();
- }
- else if($arg == 'fcjxc')
- {
- $this->_fcjxc($arg_array);
- }
- else if($arg == '0kcdel')
- {
- $this->_0kcdel();//导表删除0库存
- }
- else if($arg == 'gbhtype')
- {
- $this->_gbhtype();//更改备货状态
- }
- else
- {
- $this->_index();
- }
- }
- //管理
- public function _index()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "1=1 ";
- if($timetk && $timetj)
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- if($state != '')
- {
- $where .= " and state = '$state'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $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);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['outk'] != 0)
- {
- $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
- }
- else
- {
- $info_list[$key]['outk'] = "";
- }
- if($value['printing'] != 0)
- {
- $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
- }
- else
- {
- $info_list[$key]['printing'] = "";
- }
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
- else if($value['state'] == 10)
- {
- $info_list[$key]['state'] = "美店零售";
- }
- if($value['text'] == "")
- {
- $info_list[$key]['text'] = "";
- }
- $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['outsku']))
- {
- $cz = $this->input->post('cz',true);
- if($cz == '1')
- {
- $sku = $this->input->post('outsku',true);
- if($sku)
- {
- $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
- }
- $this->whlabel->save(array('state'=>10,'outk'=>time(),'time'=>time(),'cktype'=>1),$data[0]['id']);
- echo json_encode(array('success'=>true));exit;
- }
- }
- else
- {
- $sku = $this->input->post('outsku',true);
- if($sku)
- {
- $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
- }
- $this->whlabel->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
- echo json_encode(array('success'=>true));exit;
- }
- }
- }
- $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
- $this->_Template('whlabel',$this->data);
- }
- //在库标签
- public function _existence()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $sid = $this->whlabel->read($v);
- $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
- if($count > 0)
- {
- echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
- }
- $zt = $this->whlabeltransport->find_all('sku = "'.$sid['sku'].'" and warehouse = "'.$sid['warehouse'].'" and features = "'.$sid['features'].'" and cz = "0"');
- if(count($zt) > 0)
- {
- echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
- }
- $this->whlabel->remove($v);
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $label = $this->input->post('label',true);
-
- $where = "1=1 and state = 0";
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- //数据排序
- $order_str = "time asc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['printing'] != 0)
- {
- $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
- }
- else
- {
- $info_list[$key]['printing'] = "";
- }
-
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_existence',$this->data);
- }
- //进销存浏览
- public function _typedy($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $hairnumber = $this->input->post('hairnumber',true);
- $cklx = $this->input->post('cklx',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
-
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if(!empty($hairnumber)){
- $where .= " and features like '%-128-%' ";
- if($hairnumber < 0){
- $class_list = $this->typeclass->find_all('classid = 43');
- foreach($class_list as $v){
- $where .= " and features not like '%-".$v['id']."-%'";
- }
- }else{
- $where .= " and features like '%-$hairnumber-%'";
- }
- }
- $where_add = '';
- if($cklx)
- {
- $shop = $this->shop->read($cklx);
- $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
- $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
- $number = $value['number'];$ftime = time()-15*24*3600;
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['features'] = count($c);
- $z = count($z);//查看订单号
- $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
- $ztdata = '';
- if(count($zt) > 0)
- {
- foreach ($zt as $vv)
- {
- $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
- }
- }
- $info_list[$key]['number'] = $ztdata;
- $info_list[$key]['sm'] = $z;
- $details = array();
- $cpid = array();
- foreach ($c as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
- if($value['shop'] != '')
- {
- $shop = explode(',',trim($value['shop'],','));
- $shop = $this->shop->read($shop[0]);
- $info_list[$key]['shop'] = $shop['shopname'];
- }
- }
- $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
- echo json_encode($rows);exit;
- }
- $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
- $this->_Template('whlabel_typedy',$this->data);
- }
-
- //进销存浏览
- public function _typedy_ck($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $cklx = $this->input->post('cklx',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- $where_add = '';
- if($cklx)
- {
- $shop = $this->shop->read($cklx);
- $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $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);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $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);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $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);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,text');
- //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$c[0]['text'].'</p>';
- $ftime = time()-15*24*3600;
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['features'] = count($c)<10?"<em style='color:#F00'>".count($c)."</em>":count($c);
- //$z = count($z);//查看订单号
- //$info_list[$key]['zd'] = $z;
- $details = array();
- $cpid = array();
- foreach ($c as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
- if($value['shop'] != '')
- {
- $shop = explode(',',trim($value['shop'],','));
- $shop = $this->shop->read($shop[0]);
- $info_list[$key]['shop'] = $shop['shopname'];
- }
- }
-
- $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
- echo json_encode($rows);exit;
- }
- $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
- $this->_Template('whlabel_typedy_ck',$this->data);
- }
-
-
- public function _typeck($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = 13;
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- }
- $info_list = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,sm,details,cpbz,features,number,',$order_str,$start,$perpage);
- //取得信息列表
- $t = array();
- $typeclass = $this->typeclass->find_all();
- foreach ($typeclass as $v)
- {
- $t[$v['id']] = $v;
- }
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $mc = $this->whlabel->find_all("sku = '".$value['sku']."' and features = '".$value['features']."' and warehouse = '".$value['warehouse']."'",'cpbz','id desc',0,1);
- $warehouse = $this->warehouse->read($value['warehouse']);
- $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');
- $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'].'"');
- $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
- $number = $value['number'];$ftime = time()-15*24*3600;
- $z = count($z);//查看订单号
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['features'] = count($c);
- $info_list[$key]['number'] = $z;
- //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
- $details = array();
- $cpid = array();
- foreach ($c as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
- $classid = $this->classid->sku();
- $pm = $classid;
- $features = explode('-',trim($value['features'],'-'));
- foreach($features as $v)
- {
- $zh = explode('|',trim($t[$v]['zh'],'|'));
- $pm[$t[$v]['classid']] = $zh[0];
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $info_list[$key]['sm'] = $zh;
-
- }
- $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
- echo json_encode($rows);exit;
- }
- $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
- $this->_Template('whlabel_typeck',$this->data);
- }
- //进销存导出
- public function _whlabeckdc()
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['excel']))
- {
- $where = "sku != 'Preset'";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $category = $this->input->get('category',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $lacetype = $this->input->get('lacetype',true);
- $size = $this->input->get('size',true);
- $density = $this->input->get('density',true);
- $haircap = $this->input->get('haircap',true);
- $sku = $this->input->get('sku',true);
- $details = $this->input->get('details',true);
- $warehouse = 13;
- $excelid = $this->input->get('sid',true);
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- $xzid = '';
- if($excelid)
- {
- $excelid = explode(',',trim($excelid,','));
- foreach ($excelid as $key=>$value)
- {
- $xzid .= " id = ".$value." or";
- }
- $xzid = " and (".rtrim($xzid,'or').")";;
- }
- //取得信息列表
- /**
- $info_list = $this->whlabel->find_all($where.$xzid,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
- }
- **/
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $tc = array();$tcdata = array();
- $typeclass = $this->typeclass->find_all();
- foreach ($typeclass as $v)
- {
- $tc[$v['id']] = $v;
- }
- $list = array();
- $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
- foreach ($rows as $key=>$value)
- {
- $bm = '03';
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $classid = $this->classid->sku();
- $pm = $classid;
- $jm = $classid;
- $features = explode('-',trim($value['features'],'-'));
- foreach($features as $v)
- {
- if(isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']]))
- {
- if($tc[$v]['bm'] != '')
- {
- $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
- }
- }
- if(isset($tc[$v]))
- {
- $zh = explode('|',trim($tc[$v]['zh'],'|'));
- $pm[$tc[$v]['classid']] = $zh[0];
- }
- if(isset($tc[$v]))
- {
- if(isset($jm[$tc[$v]['classid']]))
- {
- $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
-
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $rows[$key]['dbcontent'] = $zh;
- $rows[$key]['cpbz'] = $bm.implode("",$bmpx);
- $jm = array_filter($jm);
- $rows[$key]['cs'] = implode("-",$jm);
- $sd = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
- $details = array();
- $cpid = array();
- $cpbz = array();
- $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
- foreach ($sd as $k=>$v)
- {
- if($v['state'] == 0)
- {
- $c++;
- }
- if($v['state'] != 9)
- {
- $g++;
- }
- if($v['state'] == 1)
- {
- $x++;
- }
- if($v['state'] == 2)
- {
- $t++;
- }
- if($v['state'] == 8)
- {
- $s++;
- }
- if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
- {
- $q++;
- }
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- if($v['cpbz'] != '')
- {
- $cpbz[$v['cpbz']] = $v['cpbz'];
- }
- }
- $rows[$key]['details'] = implode("、",$details);
- $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
- $number = $value['number'];
- $ftime = time()-15*24*3600;
- $rows[$key]['warehouse'] = $wh[$value['warehouse']];
- $rows[$key]['number'] = $g;
- $rows[$key]['features'] = $c;
- $rows[$key]['x'] = $x;
- $rows[$key]['t'] = $t;
- $rows[$key]['s'] = $s;
- $rows[$key]['q'] = $q;
- $rows[$key]['wzsl'] = count($details);
- }
- $title = "进销存统计表".date('Y-m-d',time());
- $titlename = "<table border=1>
- <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>位置</td>
- <td>库存编码</td>
- <td>SKU</td>
- <td>用友编码</td>
- <td>用友料号</td>
- <td>产品英文名</td>
- <td>产品中文名</td>
- <td>入库总量</td>
- <td>库存数量</td>
- <td>销售数量</td>
- <td>退货数量</td>
- <td>删除数量</td>
- <td>其它操作</td>
- <td>位置数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- }
-
- public function _type()
- {
- $vip = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $fgshop = "";$sid = "";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- if($user['vip'] == 1)
- {
- $vip = 1;
- }
- }
- else
- {
- header('Location: /');exit;
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $company = array();
- $ct = $this->company->find_all();
- foreach($ct as $k=>$v)
- {
- $company[$v['id']] = $v['title'];
- }
- $sp = array();
- $s = $this->shop->find_all('1=1','id,shopname');
- foreach ($s as $v)
- {
- $sp[$v['id']] = $v['shopname'];
- }
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $shop = $this->input->post('shop',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $hairnumber = $this->input->post('hairnumber',true);
- $type = $this->input->post('type',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $cpbz = $this->input->post('cpbz',true);
- $where = "1=1";$gj = "";$ck = "";
-
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop like '%$shop%'";
- }
-
- if($type)
- {
- $where .= " and type = '$type'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- if($cpbz){
- $where .= " and cpbz like '%$cpbz%' ";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if(!empty($hairnumber)){
- $where .= " and features like '%-128-%' ";
- if($hairnumber < 0){
- $class_list = $this->typeclass->find_all('classid = 43');
- foreach($class_list as $v){
- $where .= " and features not like '%-".$v['id']."-%'";
- }
- }else{
- $where .= " and features like '%-$hairnumber-%'";
- }
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $fjnr = '';
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $fjnr .= " and sku like '%$sku%'";
- }
- if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $fjnr .= " and title like '%$title%'";
- }
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['id']] = $v['title'];
- }
-
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm',$order_str,$start,$perpage);//改这需要修改_gbhtype
-
- //取得信息列表
- $info_list = $this->logic_whlabel->dataTran($info_list,['pm']);
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- if(isset($wt[$value['type']]))
- {
- $info_list[$key]['type'] = $wt[$value['type']];
- }
- else
- {
- $info_list[$key]['type'] = '未设置';
- }
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
- $ztdata = '';
- if(count($zt) > 0)
- {
- foreach ($zt as $vv)
- {
- $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
- }
- }
- $qbdata = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $cdata = array_filter($qbdata, function($item) {
- return $item['state'] < 1;
- });
- $c = array_sum(array_column($cdata, 'jnum'));
-
- $gdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
- return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
- });
- $g = array_sum(array_column($gdata, 'jnum'));
-
- $xdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
- return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
- });
- $x = array_sum(array_column($xdata, 'jnum'));
-
- $tdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
- return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
- });
- $t = array_sum(array_column($tdata, 'jnum'));
-
- $zdata = array_filter($qbdata, function($item) {
- return $item['zd'] != "" && $item['state'] < 1;
- });
- $z = array_sum(array_column($zdata, 'jnum'));
-
- $zdata = array_filter($qbdata, function($item) {
- return $item['zd'] != "" && $item['state'] < 1;
- });
- $z = array_sum(array_column($zdata, 'jnum'));
-
- //$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');
- //$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'].'"');
- //$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'].'"');
- //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
- //$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'].'"');
- $details = array();
- $cpid = array();
- $od = array();$odid = '';
- $companytitle = '';
- foreach ($qbdata as $v)
- {
- if($v['zd'] != "" && $v['state'] < 1)
- {
- if(!isset($od[$v['zd']]))
- {
- $od[$v['zd']] = 1;//所有数据sku
- }
- else
- {
- $od[$v['zd']] = $od[$v['zd']]+1;
- }
- }
- if($v['state'] < 1)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- if($v['companytitle'] != '' && stripos($companytitle,$company[$v['companytitle']]) === false)
- {
- $companytitle .= '<p>'.$company[$v['companytitle']].'</p>';
- }
- }
- foreach ($od as $k=>$vv)
- {
- $odid .= $k.'数量'.$vv;
- }
- $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
- $number = $value['number'];$ftime = time()-15*24*3600;
- $z = $z.'('.$odid.')';//查看订单号
- $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
- $info_list[$key]['features'] = $c;
- $info_list[$key]['number'] = $ztdata;
- $info_list[$key]['sm'] = $g;
- $info_list[$key]['x'] = $x;
- $info_list[$key]['t'] = $t;
- $info_list[$key]['z'] = $z;
- /**
- foreach ($cdata as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- **/
- $info_list[$key]['shop'] = '';
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
- if($value['shop'] != '')
- {
- $shop = explode(',',trim($value['shop'],','));
- $info_list[$key]['shop'] = '<p>'.$sp[$shop[0]].'</p>';
- }
- $info_list[$key]['shop'] .= $companytitle;
- /**
- $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
- if(isset($companytitle[0]))
- {
- foreach ($companytitle as $k=>$v)
- {
- if($v['companytitle'] != '')
- {
- $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
- }
- }
- }
- **/
- }
- $final_all_list = [];
- foreach($info_list as $k=>$v){
- $final_all_list[] = [
- 'id'=>$v['id'],
- "warehouse"=>$v["warehouse"],
- "purchase"=>$v["purchase"],
- "sku"=>$v["sku"],
- "title"=>$v["title"]."<br/>".$v["pm"],
- "details"=>$v["details"],
- "shop"=>$v["shop"],
- "cpbz"=>$v["cpbz"],
- "type"=>$v["type"],
- "features"=>$v["features"],
- "number"=>$v["number"],
- "sm"=>$v["sm"],
- "x"=>$v["x"],
- "t"=>$v["t"],
- "z"=>$v["z"]
- ];
- }
-
- $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_all_list));
- echo json_encode($rows);exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['shop'] = $wlshop;
- $this->data['vip'] = $vip;
- $this->_Template('whlabel_type',$this->data);
- }
-
- //美仓进销存浏览
- public function _usatype()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $lacecolor = $this->input->post('lacecolor',true);
- $cklx = $this->input->post('cklx',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- $where_add = '';
- if($cklx)
- {
- $shop = $this->shop->read($cklx);
- $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
- $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $od = array();$odid = '';
- foreach ($z as $v)
- {
- if(!isset($od[$v['zd']]))
- {
- $od[$v['zd']] = 1;//所有数据sku
- }
- else
- {
- $od[$v['zd']] = $od[$v['zd']]+1;
- }
- }
- foreach ($od as $k=>$vv)
- {
- $odid .= $k.'数量'.$vv.' ';
- }
- $z = count($z).'('.$odid.')';//查看订单号
- $info_list[$key]['features'] = $c;
- $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
- $ztdata = '';
- if(count($zt) > 0)
- {
- foreach ($zt as $vv)
- {
- $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
- }
- }
- $info_list[$key]['warehouse'] = $ztdata;
- $info_list[$key]['g'] = $g;
- $info_list[$key]['x'] = $x;
- $info_list[$key]['t'] = $t;
- $info_list[$key]['z'] = $z;
- }
- $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
- echo json_encode($rows);exit;
- }
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['warehouse'] = $warehouse;
- $this->_Template('whlabel_typeusa',$this->data);
- }
- //美仓进销存浏览
- public function _usatypeapp()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $warehouse = 5;
- $title = $this->input->post('title',true);
- $state = $this->input->post('state',true);
-
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($title)
- {
- $st = explode(' ',trim($title,' '));
- foreach ($st as $v)
- {
- $where .= " and title like '%$v%'";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
- }
- $rowsdq = array_slice($rows,$start,$perpage);
- foreach ($rowsdq as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
- $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
- $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
- $od = array();$odid = '';
- $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
- }
- $total = count($rows);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('phone/p_usatypeapp',$this->data);
- }
- //入库操作
- public function _enteradd()
- {
- $dt = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $tc = $this->typeclass->find_all();
- $typeclass = array();
- foreach ($tc as $v)
- {
- $tcjm[$v['id']] = array($v['jm'],$v['classid']);
- $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['sku']))
- {
- $list = array();$num = "";$title = "";$features = "";
- $order = $this->input->post('order',true);
- $shop = $this->input->post('shop',true);
- $post['shop'] = ($shop!="")?','.$shop:"";
- $sku = $this->input->post('sku',true);
- $post['sm'] = $this->input->post('sm',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['retreatwarehouse'] = $post['warehouse'];
- $post['state'] = $this->input->post('state',true);
- $post['rktype'] = $this->input->post('rktype',true);
- $post['text'] = $this->input->post('text',true);
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $xzsku = $this->input->post('xzsku',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
- if(!$post['purchase'])
- {
- $post['purchase'] = 1;
- }
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- $classid = $this->classid->sku();
- $scsku = $classid;
- $pm = $classid;
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $post[$k] = $v;
- $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
- if($k != 'size')
- {
- $title .= $typeclass[$v]['title']." ";
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['title'] == '9A')
- {
- $pm[$typeclass[$v]['classid']] = '9A';
- }
- else if($typeclass[$v]['title'] == '10A')
- {
- $pm[$typeclass[$v]['classid']] = '10A';
- }
- else
- {
- $clzh = $typeclass[$v]['zh'];
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
- $clzh = $clzh[0];
- }
- $pm[$typeclass[$v]['classid']] = $clzh;
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- if($list['size'])
- {
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- }
- $time = time();
- if($xzsku)
- {
- $scsku = implode("-",$scsku);
- $scsku = str_replace('- ','-',trim($scsku,'-'));
- $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $post['sku'] = trim($scsku,' ');
- }
- else
- {
- $post['sku'] = $sku;
- }
- //$post['sku'] = trim($sku,' ');
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
- if($yza)
- {
- if($post['features'] != $yza[0]['features'])
- {
- echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
- }
- }
- $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
- if($yzb)
- {
- if($post['sku'] != $yzb[0]['sku'])
- {
- echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
- }
- }
- if(isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
- {
- echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
- }
- if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
- {
- echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
- }
- if($post['rktype'] == '' && $post['warehouse'] == 5)
- {
- echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
- }
- $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
- if(isset($yz[0]['type']))
- {
- $post['type'] = $yz[0]['type'];
- }
- if($post['state'] == 9)//如果选择预设库存
- {
- $this->whlabel->insert($post);
- }
- else
- {
- /**
- $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
- if($ljg == 1)
- {
- for($i=0;$i<$order;$i++)
- {
- $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
- $this->whlabel->insert($post);
- }
- }
- **/
- //if($post['warehouse'] == '5')
- //{
-
- //}
- $yydata = $post;
- $yydata['zh'] = $zh;
- /**
- $wl = $this->apiyy->get_cjlp($yydata);
- if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
- {
- echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
- }
- if($wl['Data'][0]['m_isSucess'] != 1)
- {
- echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
- }
- **/
- for($i=0;$i<$order;$i++)
- {
- $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
- $this->whlabel->insert($post);
- }
- }
- echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('whlabel_enteradd',$this->data);
- }
- //修改产品
- public function _enteredit($arg_array)
- {
- $dt = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['sku']))
- {
- $list = array();$num = "";$title = "";$features = "";
- $id = $this->input->post('id',true);
- $order = $this->input->post('order',true);
- $shop = $this->input->post('shop',true);
- $post['shop'] = ($shop!="")?','.$shop:"";
- $post['sku'] = $this->input->post('sku',true);
- $post['sm'] = $this->input->post('sm',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['retreatwarehouse'] = $post['warehouse'];
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $list['size'] = rtrim($size,',');
- $post['rktype'] = $this->input->post('rktype',true);
- $post['text'] = $this->input->post('text',true);
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
- if(!$post['purchase'])
- {
- $post['purchase'] = 1;
- }
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $typeclass = $this->typeclass->read($v);
- if($k != 'size')
- {
- $title .= $typeclass['title']." ";
- }
- }
- }
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- $time = time();
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $post['time'] = $time;//操作时间
- if($post['rktype'] == '' && $post['warehouse'] == 5)
- {
- echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
- }
- if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
- {
- echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
- }
- $uid = $this->whlabel->read($id);
- $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
- if($datanum > 0)
- {
- echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
- }
- if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
- {
- $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
- if($yza)
- {
- if($post['features'] != $yza[0]['features'])
- {
- echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
- }
- }
- $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
- if($yzb)
- {
- if($post['sku'] != $yzb[0]['sku'])
- {
- echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
- }
- }
- if($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
- {
- echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
- }
- $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
- foreach ($data as $v)
- {
- $post['id'] = $v['id'];
- $this->whlabel->save($post,$v['id']);
- }
- }
- else
- {
- $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
- if($data > 0)
- {
- echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
- }
- else
- {
- $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
- foreach ($data as $v)
- {
- $post['id'] = $v['id'];
- $this->whlabel->save($post,$v['id']);
- }
- }
- }
- echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
- }
- $uid = $this->whlabel->read($arg_array[0]);
- $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
- $this->data['enter'] = $uid ;
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('whlabel_enteredit',$this->data);
- }
- //入库浏览
- public function _enter()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $sid = $this->whlabel->read($v);
- $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
- if($count > 0)
- {
- echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
- }
- $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
- foreach ($info_list as $va)
- {
- $this->whlabel->remove($va['id']);
- }
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- $sp = array();
- $s = $this->shop->find_all('1=1','id,shopname');
- foreach ($s as $v)
- {
- $sp[$v['id']] = $v['shopname'];
- }
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- $where .= " and enter > '$ktime' and enter < '$jtime'";
- }
- //数据排序
- $order_str = "enter desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
- foreach ($info_list as $k=>$v)
- {
- $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
- if($v['shop']=='')
- {
- $s = '通用';
- }
- else
- {
- $info_list[$k]['shop'] = '';
- foreach (explode(',',trim($v['shop'],',')) as $val)
- {
- $info_list[$k]['shop'] .= $sp[$val].'</br>';
- }
- }
- $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
- $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
- $info_list[$k]['g'] = $g;
- }
- $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_enter',$this->data);
- }
- //出库浏览
- public function _out()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "state=3";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($ktime && $jtime)
- {
- $where .= " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'sku');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
- }
- $rows = array_unique($rows);//删除重复记录
- foreach ($rows as $key=>$value)
- {
- $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
- $ck = $this->warehouse->read($data['warehouse']);
- $warehouse = $ck['title'];
- $gy = $this->purchase->read($data['purchase']);
- $purchase = $gy['purchase'];
- $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
- $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);
- }
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_out',$this->data);
- }
-
- //出库标签浏览
- public function _label()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
-
- $where = "state=1";
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- //数据排序
- $order_str = "outk desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['outk'] != 0)
- {
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
- }
- else
- {
- $info_list[$key]['outk'] = "";
- }
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_label',$this->data);
- }
- //独立站出库订单
- public function _outorder()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- else
- {
- echo "请重新登录";
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $xztime = $this->input->post('xztime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $sfxh = $this->input->post('sfxh',true);
- $express = $this->input->post('express',true);
- $waybill = $this->input->post('waybill',true);
- $library = $this->input->post('library',true);
- $country = $this->input->post('country',true);
- $so = $this->input->post('so',true);
- $libraryconfirm = $this->input->post('libraryconfirm',true);
- $print = $this->input->post('print',true);
- $state = $this->input->post('state',true);
- $orderurl = $this->input->post('orderurl',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- /**
- $sj = $this->input->post('sj',true);
- if($sj)
- {
- $sj = $this->input->post('sj',true);
- }
- else
- {
- $sj = "fullorder";
- }
- **/
- $sj = "fullorder";
- $where = "1=1";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($libraryconfirm)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- if($sfxh != '')
- {
- $where .= " and sfxh = '$sfxh'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($source)
- {
- if($source == '2d')
- {
- $where .= " and source >= '2'";
- }
- else
- {
- $where .= " and source = '$source'";
- }
- }
- if(isset($_SESSION['api']))
- {
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- }
- $where .= " and (".rtrim($fgshop,'or').")";
- }
- if($orderurl)
- {
- $url = $this->orderurl->read($orderurl);
- $where .= " and link like '%".$url['url']."%'";
- }
- //数据排序
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->$sj->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $user = $this->user->get_api($_SESSION['api']);
- $powerid = $this->power->read($user['power']);
- $powertext = explode('|',trim($powerid['excelid'],'|'));
- $pid = '';
- foreach ($powertext as $v)
- {
- $pid .= " id = ".$v." or";
- }
- $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
- $this->data['fullorderexcel'] = $fullorderexcel;
- $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
- $this->data['orderurl'] = $orderurl;
- $this->_Template('whlabel_outorder',$this->data);
- }
-
- //tt出库
- public function _toutorder()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- else
- {
- echo "请重新登录";
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $xztime = $this->input->post('xztime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $sfxh = $this->input->post('sfxh',true);
- $express = $this->input->post('express',true);
- $waybill = $this->input->post('waybill',true);
- $library = $this->input->post('library',true);
- $country = $this->input->post('country',true);
- $so = $this->input->post('so',true);
- $libraryconfirm = $this->input->post('libraryconfirm',true);
- $print = $this->input->post('print',true);
- $state = $this->input->post('state',true);
- $orderurl = $this->input->post('orderurl',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- /**
- $sj = $this->input->post('sj',true);
- if($sj)
- {
- $sj = $this->input->post('sj',true);
- }
- else
- {
- $sj = "fullorder";
- }
- **/
- $sj = "fullordertt";
- $where = "1=1";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($libraryconfirm)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- if($sfxh != '')
- {
- $where .= " and sfxh = '$sfxh'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($source)
- {
- if($source == '2d')
- {
- $where .= " and source >= '2'";
- }
- else
- {
- $where .= " and source = '$source'";
- }
- }
- if(isset($_SESSION['api']))
- {
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- }
- $where .= " and (".rtrim($fgshop,'or').")";
- }
- if($orderurl)
- {
- $url = $this->orderurl->read($orderurl);
- $where .= " and link like '%".$url['url']."%'";
- }
- //数据排序
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->$sj->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $user = $this->user->get_api($_SESSION['api']);
- $powerid = $this->power->read($user['power']);
- $powertext = explode('|',trim($powerid['excelid'],'|'));
- $pid = '';
- foreach ($powertext as $v)
- {
- $pid .= " id = ".$v." or";
- }
- $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
- $this->data['fullorderexcel'] = $fullorderexcel;
- $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
- $this->data['orderurl'] = $orderurl;
- $this->_Template('whlabel_toutorder',$this->data);
- }
-
- //速卖通出库订单
- public function _soutorder()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $xztime = $this->input->post('xztime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $express = $this->input->post('express',true);
- $waybill = $this->input->post('waybill',true);
- $library = $this->input->post('library',true);
- $country = $this->input->post('country',true);
- $sfxh = $this->input->post('sfxh',true);
- $libraryconfirm = $this->input->post('libraryconfirm',true);
- $print = $this->input->post('print',true);
- $state = $this->input->post('state',true);
- $so = $this->input->post('so',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- /**
- $sj = $this->input->post('sj',true);
- if($sj)
- {
- $sj = $this->input->post('sj',true);
- }
- else
- {
- $sj = "fullorder";
- }
- **/
- $sj = "fullordersmt";
- $where = "1=1";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($libraryconfirm)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($sfxh != '')
- {
- $where .= " and sfxh = '$sfxh'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- else
- {
- if(isset($_SESSION['api']))
- {
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- }
- $where .= " and (".rtrim($fgshop,'or').")";
- }
- }
- //数据排序
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->$sj->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $user = $this->user->get_api($_SESSION['api']);
- $powerid = $this->power->read($user['power']);
- $powertext = explode('|',trim($powerid['excelid'],'|'));
- $pid = '';
- foreach ($powertext as $v)
- {
- $pid .= " id = ".$v." or";
- }
- $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
- $this->data['fullorderexcel'] = $fullorderexcel;
- $this->_Template('whlabel_soutorder',$this->data);
- }
-
- //订单退库
- public function _retreat()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $state = $this->input->post('state',true);
- $review = $this->input->post('review',true);
- $state = $this->input->post('state',true);
- $express = $this->input->post('express',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $user = $this->input->post('user',true);
- $name = $this->input->post('name',true);
- $waybill = $this->input->post('waybill',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "(state=206 or state=210) and mergeid = 0";
- if($warehouse)
- {
- $where .= " and state = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and buytime > '$timetk' and buytime < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($review)
- {
- $where .= " and review = '$review'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($name)
- {
- $where .= " and name = '$name'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
- $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['title'];
- $typeclass = $this->typeclass->read($value['state']);
- $info_list[$key]['state'] = $typeclass['title'];
- }
- $total = $this->fullorder->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $this->_Template('whlabel_retreat',$this->data);
- }
- //退库标签浏览
- public function _retreatlk()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
-
- $where = "state=2";
- if($timetk && $timetj)
- {
- $where .= " and retreat > '$timetk' and retreat < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
- $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['outk'] != 0)
- {
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
- }
- else
- {
- $info_list[$key]['outk'] = "";
- }
- if($value['retreat'] != 0)
- {
- $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
- }
- else
- {
- $info_list[$key]['retreat'] = "";
- }
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_retreatlk',$this->data);
- }
- //更换标签及浏览
- public function _change()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $label = $this->input->post('label',true);
- $oldlabel = $this->input->post('oldlabel',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "state=10 ";
- if($timetk && $timetj)
- {
- $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- if($oldlabel)
- {
- $where .= " and oldlabel = '$oldlabel'";
- }
- //数据排序
- $order_str = "time asc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_change',$this->data);
- }
-
- //产品标签
- public function _cpbqdc()
- {
- if(isset($_GET['excel']))
- {
- $where = "1=1";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $warehouse = $this->input->get('warehouse',true);
- $state = $this->input->get('state',true);
- $timetk = $this->input->get('timetkk',true);
- $timetj = $this->input->get('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($state || $state == 0)
- {
- $where .= " and state = '$state'";
- }
- if($timetk && $timetj)
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['time']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
- $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);
- }
- $title = "产品标签统计表";
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>入库时间</td>
- <td>操作时间</td>
- <td>备注</td>
- <td>数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- //进销存导出
- public function _exceljxc()
- {
- $classid = $this->classid->sku();
- $pm = $classid;
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach ($tc as $v)
- {
- $typeclass[$v['id']] = $v;
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['excel']))
- {
- $where = "sku != 'Preset'";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $category = $this->input->get('category',true);
- $warehouse = $this->input->get('warehouse',true);
- $excelid = $this->input->get('sid',true);
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- $xzid = '';
- if($excelid)
- {
- $excelid = explode(',',trim($excelid,','));
- foreach ($excelid as $key=>$value)
- {
- $xzid .= " id = ".$value." or";
- }
- $xzid = " and (".rtrim($xzid,'or').")";;
- }
- //取得信息列表
- /**
- $info_list = $this->whlabel->find_all($where.$xzid,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
- }
- **/
-
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['id']] = $v['title'];
- }
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $list = array();
- $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
- foreach ($rows as $key=>$value)
- {
- if(isset($wt[$value['type']]))
- {
- $rows[$key]['type'] = $wt[$value['type']];
- }
- else
- {
- $rows[$key]['type'] = '未设置';
- }
- $bm = '03';
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $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');
- $details = array();
- $cpid = array();
- $cpbz = array();
- $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
- foreach ($sd as $k=>$v)
- {
- if($v['state'] == 0)
- {
- $c++;
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- if($v['cpbz'] != '')
- {
- $cpbz[$v['cpbz']] = $v['cpbz'];
- }
- }
- if($v['state'] != 9)
- {
- $g++;
- }
- if($v['state'] == 1)
- {
- $x++;
- }
- if($v['state'] == 2)
- {
- $t++;
- }
- if($v['state'] == 8)
- {
- $s++;
- }
- if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
- {
- $q++;
- }
- $details[$v['details']] = $v['details'];
- }
- $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'].'"');
- $rows[$key]['details'] = implode("、",$details);
- $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
- $number = $value['number'];
- $ftime = time()-15*24*3600;
- $rows[$key]['warehouse'] = $wh[$value['warehouse']];
- $rows[$key]['number'] = $g;
- $rows[$key]['c'] = $c;
- $rows[$key]['x'] = $x;
- $rows[$key]['t'] = $t;
- $rows[$key]['s'] = $s;
- $rows[$key]['q'] = $q;
- $rows[$key]['z'] = $z;
-
- // $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- // $features = explode('-',trim($features,'-'));
- // $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
- // $pm = $classid;
- // $jm = $classid;
- // foreach($features as $k=>$v)
- // {
- // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
- // {
- // if($typeclass[$v]['bm'] != '')
- // {
- // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
- // }
- // }
- // if($v != 0)
- // {
- // if(!isset($typeclass[$v]))
- // {
- // continue;
- // }
- // if(isset($pm[$typeclass[$v]['classid']]))
- // {
- // if(stripos($typeclass[$v]['zh'],'|') !== false)
- // {
- // $tz = explode('|',$typeclass[$v]['zh']);
- // $pm[$typeclass[$v]['classid']] = $tz[0];
- // }
- // else
- // {
- // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- // }
- // }
- // if(isset($jm[$typeclass[$v]['classid']]))
- // {
- // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
-
- // }
- // }
- // }
- // $jm = array_filter($jm);
- // $rows[$key]['bs'] = implode("-",$jm);
- // $rows[$key]['cs'] = $bm.implode("",$bmpx);
- // $zh = implode(" ",$pm);
- // $zh = str_replace('自然色 ','',trim($zh,' '));
- // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- // $rows[$key]['features'] = $zh;
-
- }
- $list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
-
- $final_list = [];
- foreach($list as $k=>$v){
- if(empty($v['sku'])){
- continue;
- }
- $final_list[] = [
- "warehouse"=>$v["warehouse"],
- "purchase"=>$v["purchase"],
- "details"=>$v["details"],
- "cpid"=>$v["cpid"],
- "dbcontent"=>$v["dbcontent"],
- "sku"=>$v["sku"],
- "cs"=>$v["bm"],
- "bs"=>$v["jm"],
- "title"=>$v["title"],
- "features"=>$v["pm"],
- "cpbz"=>$v["cpbz"],
- "sm"=>$v["sm"],
- "type"=>$v["type"],
- "number"=>$v["number"],
- "c"=>$v["c"],
- "x"=>$v["x"],
- "t"=>$v["t"],
- "s"=>$v["s"],
- "q"=>$v["q"],
- "z"=>$v["z"],
- "weight"=>$v['weight'],
- ];
- }
- $title = "总进销存统计表";
- $titlename = "<table border=1>
- <tr><th colspan='20' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>位置</td>
- <td>库存编码</td>
- <td>类目</td>
- <td>SKU</td>
- <td>用友编码</td>
- <td>用友料号</td>
- <td>商品名称</td>
- <td>商品中文</td>
- <td>产品备注</td>
- <td>说明</td>
- <td>类型</td>
- <td>入库总量</td>
- <td>库存数量</td>
- <td>销售数量</td>
- <td>退货数量</td>
- <td>删除数量</td>
- <td>其它操作</td>
- <td>占单数量</td>
- <td>重量(g)</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($final_list,$titlename,$filename,$tail);
- }
- }
- //入库导出
- public function _excelr()
- {
- if(isset($_GET['excel']))
- {
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $purchase = $this->input->get('purchase',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($ktime && $jtime)
- {
- $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $list = array();
- $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
- foreach ($rows as $value)
- {
- $ck = $this->warehouse->read($value['warehouse']);
- $warehouse = $ck['title'];
- $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
- $retreatwarehouse = $tkck['title'];
- $gy = $this->purchase->read($value['purchase']);
- $purchase = $gy['title'];
- $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
- $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
- $titlename = "<table border=1>
- <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>时间</td>
- <td>数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
-
- //出库、退库导出
- public function _excelct()
- {
- $classid = $this->classid->sku();
- $pm = $classid;
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach ($tc as $v)
- {
- $typeclass[$v['id']] = $v;
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['excel']))
- {
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $type = $this->input->get('excel',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $lacetype = $this->input->get('lacetype',true);
- $lacecolor = $this->input->get('lacecolor',true);
- $density = $this->input->get('density',true);
- $haircap = $this->input->get('haircap',true);
- $purchase = $this->input->get('purchase',true);
- $title = $this->input->get('title',true);
- $state = $this->input->get('state',true);
- $sid = $this->input->get('sid',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- if($type == 1)
- {
- $tl = '出库';
- $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
- }
- else if($type == 2)
- {
- $tl = '退库';
- $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
- }
- else if($type == 3)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- else if($type == 4)
- {
- $tl = '出库+零售';
- $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
- }
- else if($type == 5)
- {
- $tl = '零售';
- $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
- }
- }
- $sidwhere = '';
- if($sid)
- {
- $sd = "";
- $s = explode(',',trim($sid,','));
- foreach ($s as $value)
- {
- $sd .= " id = ".$value." or";
- }
- $sidwhere = " and (".rtrim($sd,'or').")";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- if($type != 3 && $type != 5)
- {
- if($type == 1 || $type == 4)
- {
- $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- $features = explode('-',trim($features,'-'));
- $pm = $classid;
- foreach($features as $k=>$v)
- {
- if($v != 0)
- {
- if(!isset($typeclass[$v]))
- {
- continue;
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $tz = explode('|',$typeclass[$v]['zh']);
- $pm[$typeclass[$v]['classid']] = $tz[0];
- }
- else
- {
- $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',trim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- $info_list[$key]['features'] = $zh;
- }
- }
- else
- {
- $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- $features = explode('-',trim($features,'-'));
- $pm = $classid;
- foreach($features as $k=>$v)
- {
- if($v != 0)
- {
- if(!isset($typeclass[$v]))
- {
- continue;
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $tz = explode('|',$typeclass[$v]['zh']);
- $pm[$typeclass[$v]['classid']] = $tz[0];
- }
- else
- {
- $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',trim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- $info_list[$key]['features'] = $zh;
- }
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
- $titlename = "<table border=1>
- <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>SKU</td>
- <td>商品名称</td>
- <td>商品中文</td>
- <td>标签</td>
- <td>订单号</td>
- <td>运单号</td>
- <td>".$tl."时间(中国时间)</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
- }
- else if($type == 5)
- {
- $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- $features = explode('-',trim($features,'-'));
- $pm = $classid;
- foreach($features as $k=>$v)
- {
- if($v != 0)
- {
- if(!isset($typeclass[$v]))
- {
- continue;
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $tz = explode('|',$typeclass[$v]['zh']);
- $pm[$typeclass[$v]['classid']] = $tz[0];
- }
- else
- {
- $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',trim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- $info_list[$key]['features'] = $zh;
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>SKU</td>
- <td>商品名称</td>
- <td>商品中文</td>
- <td>标签</td>
- <td>".$tl."时间(中国时间)</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
- }
- else
- {
- /**
- $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
- }
- **/
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['id']] = $v['title'];
- }
- $classid = $this->classid->sku();
- $list = array();
- $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
- foreach ($rows as $key=>$value)
- {
- $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $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');
- $details = array();
- $cpid = array();
- $cpbz = array();
- $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
- foreach ($sd as $k=>$v)
- {
- if($v['state'] == 0)
- {
- $c++;
- }
- if($v['state'] != 9)
- {
- $g++;
- }
- if($v['outk'] > 1)
- {
- $x++;
- }
- if($v['retreat'] > 0)
- {
- $t++;
- }
- if($v['state'] == 8)
- {
- $s++;
- }
- if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
- {
- $q++;
- }
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- if($v['cpbz'] != '')
- {
- $cpbz[$v['cpbz']] = $v['cpbz'];
- }
- }
- if(isset($wt[$value['type']]))
- {
- $rows[$key]['type'] = $wt[$value['type']];
- }
- else
- {
- $rows[$key]['type'] = '未设置';
- }
- $rows[$key]['details'] = implode("、",$details);
- $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
- $ftime = time()-15*24*3600;
- $rows[$key]['warehouse'] = $wh[$value['warehouse']];
- $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
- $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);
- $rows[$key]['c'] = $c;
- $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);
- $rows[$key]['t'] = $t;
-
-
- $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'].'"');
- $rows[$key]['z'] = $z;
- $jm = $classid;
-
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
- $features = explode('-',trim($features,'-'));
- $pm = $classid;
- foreach($features as $k=>$v)
- {
- if($v != 0)
- {
- if(!isset($typeclass[$v]))
- {
- continue;
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $tz = explode('|',$typeclass[$v]['zh']);
- $pm[$typeclass[$v]['classid']] = $tz[0];
- }
- else
- {
- $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
- }
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['jm'])
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
- }
- }
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',trim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
- $rows[$key]['features'] = $zh;
- $jm = array_filter($jm);//去除空值
- $jm = implode("-",$jm);
- $rows[$key]['jm'] = $jm;
- $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
- $titlename = "<table border=1>
- <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>位置</td>
- <td>库存编码</td>
- <td>SKU</td>
- <td>商品名称</td>
- <td>商品中文</td>
- <td>产品备注</td>
- <td>说明</td>
- <td>类型</td>
- <td>入库总量</td>
- <td>库存数量</td>
- <td>销售数量</td>
- <td>退货数量</td>
- <td>占单数量</td>
- <td>料号</td>
- <td>类目</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- }
- }
-
- //出库+入库数据整合
- public function _excelcr()
- {
- if(isset($_GET['excel']))
- {
- $type = $this->input->get('excel',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $purchase = $this->input->get('purchase',true);
- $state = $this->input->get('state',true);
- $sid = $this->input->get('sid',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
- }
- $sidwhere = '';
- if($sid)
- {
- $sd = "";
- $s = explode(',',trim($sid,','));
- foreach ($s as $value)
- {
- $sd .= " id = ".$value." or";
- }
- $sidwhere .= " and (".rtrim($sd,'or').")";
- }
-
- //取得信息列表
- $timeread = $ktime;
- $timenum = ceil(($jtime - $ktime) / (24*3600));
- $timelist = array();
- for($i=0;$i<$timenum;$i++)
- {
- $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
- $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
- }
-
- $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
- //echo "<pre>";
- //print_r($info_list);
- //exit();
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $thistime = $timelist;
- if(isset($rows[strtolower($value['sku'])]))
- {
- if($value['outk'] > $ktime && $value['state'] < $jtime)
- {
- $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
- }
- if($value['enter'] > $ktime && $value['enter'] < $jtime)
- {
- $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
- }
- }
- else
- {
- if($value['outk'] > $ktime && $value['outk'] < $jtime)
- {
- $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
- }
- if($value['enter'] > $ktime && $value['enter'] < $jtime)
- {
- $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
- }
- $rows[strtolower($value['sku'])] = $thistime;
- }
- }
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
-
- $str .= "<table border=1><tr><td>SKU</td>";
- foreach ($timelist as $k=>$v)
- {
- $str .="<td>".$k."出库</td>";
- $str .="<td>".$k."入库</td>";
- }
- $str .= "</tr></table>";
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
- foreach ($rows as $key=>$val)
- {
- $str .= "<tr><td>".strtoupper($key)."</td>";
- foreach ($val as $k=>$v)
- {
- $str .= "<td>".$val[$k]['c']."</td>";
- if($val[$k]['r'] > 0)
- {
- $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
- }
- else
- {
- $str .= "<td>".$val[$k]['r']."</td>";
- }
- }
- $str .= "</tr>";
- }
- $str .= "</table>";
- $str .= "</body></html>";
- header( "Content-Type: application/vnd.ms-excel; name='excel'" );
- header( "Content-type: application/octet-stream" );
- header( "Content-Disposition: attachment; filename=".time().'.xls' );
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header( "Pragma: no-cache" );
- header( "Expires: 0" );
- exit($str);
-
- }
- }
-
-
- //数量调整模板导出
- public function _presetout()
- {
- if(isset($_GET['excel']))
- {
- $where = "sku != 'Preset' and purchase != 0";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
- $rows = array();$list = array();
- foreach ($info_list as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $number = $value['number'];$ftime = time()-15*24*3600;
- $purchase = $this->purchase->read($value['purchase']);
- $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
- }
- $title = "库存模板";
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商编码</td>
- <td>SKU</td>
- <td>增减数量(正数或负数)</td>
- <td>增减备注</td>
- <td>扣减方式:0减少库存1删除库存</td>
- <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
- <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- //数量调整模板导入
- public function _presetedit()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "./data/excel/PHPExcel/IOFactory.php";
- $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- $phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();
- foreach ($list as $key=>$value)
- {
- $time = time();
- if($value['0'] == "")
- {
- continue;
- }
- $warehouse = $this->warehouse->get_title($value['0']);
- $purchase = $this->purchase->get_bm($value['1']);
- $sku = $value['2'];
- $num = $value['3'];//调整数量
- $text = $value['4'];//扣减说明
- $type = $value['5'];//调整方式0扣减1删除
- $rktype = $value['6']!=''?$value['6']:0;//增加库存
- $cktype = $value['7']!=''?$value['7']:0;//减少库存
- $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
- if(!$purchase)//如果没有这个SKU
- {
- $ed[] = array($purchase.'-不存在此供应商编码');
- $j++;
- continue;
- }
- if(!$d)//如果没有这个SKU
- {
- $ed[] = array($sku.'-库存中不存在此SKU');
- $j++;
- continue;
- }
- if(!isset($warehouse['id']))
- {
- $ed[] = array($sku.'-仓库名错误!');
- $j++;
- continue;
- }
- if($type != '0' && $type != '1')
- {
- $ed[] = array($sku.'-扣减方式填写错误!');
- $j++;
- continue;
- }
- if($num < 0)//扣减库存
- {
- if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
- {
- $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
- $j++;
- continue;
- }
- $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
- if(count($data) < abs($num))
- {
- $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
- $j++;
- continue;
- }
- if($type == 0)//如果扣减方式为 扣减库存
- {
- for($i=0;$i<abs($num);$i++)
- {
- $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
- }
- }
- else if($type == 1)
- {
- $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
- if(count($zt) > 0)
- {
- $ed[] = array($sku.'-有在途库存无法删除!');
- $j++;
- continue;
- }
- for($i=0;$i<abs($num);$i++)
- {
- $this->whlabel->remove($data[$i]['id']);
- }
- }
- }
- else if($num > 0)//增加库存
- {
- if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
- {
- $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
- $j++;
- continue;
- }
- $post['sku'] = $d['sku'];
- $post['shop'] = $d['shop'];
- $post['warehouse'] = $warehouse['id'];
- $post['purchase'] = $purchase['id'];
- $post['retreatwarehouse'] = $d['retreatwarehouse'];
- $post['state'] = 0;
- $post['title'] = $d['title'];
- $post['number'] = $d['number'];
- $post['features'] = $d['features'];
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- $post['rktype'] = $rktype;
- for($i=0;$i<$num;$i++)
- {
- $post['label'] = time().rand(100,999).$i;
- $this->whlabel->insert($post);
- }
- }
- sleep(1);//防止入库时间一样,需要延迟1秒
- }
- if($j > 0)
- {
- $tt = date('Ymd',time());
- $title = '库存导入错误信息-'.$tt;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
- }
- }
- }
- //笛卡儿积
- function cp($ps,$sets,$list)
- {
- $result = array();$j=0;
- for($i=0,$count=count($sets); $i<$count-1; $i++)
- {
- if($i==0)
- {
- $result = $sets[$i];
- }
- $tmp = array();
- foreach($result as $res)
- {
- foreach($sets[$i+1] as $set)
- {
- $tmp[] = $res.','.$set;
- }
- }
- $result = $tmp;
- }
- $this->db->trans_begin();
- foreach ($result as $v)
- {
- $post = array();$title = "";$num="";
- $data = explode(',',$v);
- for($i=0;$i<count($list); $i++)
- {
- $post[$list[$i]] = $data[$i];
- $typeclass = $this->typeclass->read($data[$i]);
- $title = $title.$typeclass['title']." ";
- if($data[$i] != 0)
- {
- $num .=$data[$i];//所有数据ID拼接
- }
- }
- foreach ($ps as $kp=>$vp)
- {
- $post[$kp] = $vp;
- }
- $post['number'] = $num;
- $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
- if($info_list)
- {
- $j++;
- }
- else
- {
- $skunum = $this->whlabel->find_count();
- $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
- $post['title'] = rtrim($title,' ');
- $this->whlabel->insert($post);
- }
-
- }
- if ($this->db->trans_status() === FALSE)
- {
- $this->db->trans_commit();
- return NULL;
- }
- else
- {
- $this->db->trans_commit();
- return $j;
- }
- }
- public function _kj($arg_array)
- {
- if(isset($_POST['sku']))
- {
- $time = time();
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $num = $this->input->post('num',true);
- $text = $this->input->post('text',true);
- $purchase = $this->input->post('purchase',true);
- $cktype = $this->input->post('cktype',true);
- $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
- if($cktype != 1 && $text == '')
- {
- echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
- }
- if($num > count($order))
- {
- echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
- }
- else
- {
- for($i=0;$i<$num;$i++)
- {
- $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
- }
- }
- echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
- }
- $uid = $this->whlabel->read($arg_array[0]);
- $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
- $this->data['data'] = $uid ;
- $this->_Template('whlabel_kj',$this->data);
- }
- public function _summary($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['excel']))
- {
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";
- if($ktime && $jtime)
- {
- $where .= " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
- $details = array();
- $cpid = array();
- foreach ($x as $k=>$v)
- {
- if($v['details'] != '')
- {
- $details[$v['details']] = $v['details'];
- }
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
- $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
- $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
- $info_list[$key]['s'] = $s;
- $info_list[$key]['x'] = count($x);
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>供应商</td>
- <td>出库位置</td>
- <td>出库编码</td>
- <td>SKU</td>
- <td>产品名</td>
- <td>总剩余库存</td>
- <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
- }
- }
- //usps发货清单
- public function _manifest()
- {
- if(isset($_POST['manifest']))
- {
- $wltext = $this->input->post('wltext',true);
- $time = time()-16*3600;
- $ptime = strtotime(date('Y-m-d',$time));
- $waybill = array();
- $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
- foreach ($fullorder as $v)
- {
- $waybill[$v['waybill']] = $v['waybill'];
- }
- $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
- foreach ($fullordersmt as $v)
- {
- $waybill[$v['waybill']] = $v['waybill'];
- }
- $wltext = explode(';',$wltext);
- foreach ($wltext as $v)
- {
- if(isset($waybill[$v]))
- {
- unset($waybill[$v]);
- }
- }
- $data = $this->usps->get_manifest($waybill);
- if(isset($data['Description']))
- {
- echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
- }
- else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
- {
- $bctime = date('Ymd',time());
- $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
- echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>$data,'success'=>false));exit;
- }
- }
- }
- public function _pdf($pdf,$title,$bctime)
- {
- $pdf_path = './data/pdf/'.$bctime.'/';
- $file_base64 = $pdf;
- $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
- $file_base64 = base64_decode($file_base64);
- if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
- file_put_contents($pdf_path.$title.'.pdf',$file_base64);
- return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
- }
-
-
-
-
- /**
- *
- *
- *
- 进销存占单异常索引
- *
- *
- *
- **/
-
- public function _abnormal()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $where = "1=1";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku'])] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- if($value['shop'] != '')
- {
- $shop = $value['shop'];
- $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');
- $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');
- $order = array_merge($orderdlz,$ordersmt);
- $od = 0;$a = '';$orid = '';
- foreach ($order as $v)
- {
- $or = explode('|',ltrim($v['whlabel'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $number)
- {
- $od += $orod[1];
- }
- }
- $orid .= $v['number'].'-';
- }
- }
- else
- {
- $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
- $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
- $order = array_merge($orderdlz,$ordersmt);
- $od = 0;$a = '';$orid = '';$qt = array();
- foreach ($order as $v)
- {
- $or = explode('|',ltrim($v['whlabel'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $number)
- {
- $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
- if($czzs > 0)
- {
- if(isset($qt[$v['shop']]))
- {
- if($qt[$v['shop']] < $orod[1])
- {
- $od += $orod[1];//专属小于单量不计算剩余直接归入通用
- $orid .= $v['number'].'+数量'.$orod[1].'-';
- }
- else
- {
- $qt[$v['shop']] -= $orod[1];
- }
- }
- else
- {
- $qt[$v['shop']] = $czzs;
- }
- }
- else
- {
- $od += $orod[1];
- $orid .= $v['number'].'+数量'.$orod[1].'-';
- }
- }
- }
- }
- }
- $z = $od.'('.$orid.')';//查看订单号
- //$z = $od;
- if($od > $c)
- {
- $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
- }
- }
- $listdata = array_slice($list,$start,$perpage);
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
- echo json_encode($rows);exit;
- }
- $this->_Template('whlabel_abnormal',$this->data);
- }
- /**
- *
- *
- *
- 进销存占单异常索引
- *
- *
- *
- **/
-
- public function _error()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "sku != 'Preset'";
- $gj = '';
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- else
- {
- if($ktime && $jtime)
- {
- $gj = " and time > '$ktime' and time < '$jtime'";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- //$info_list = $this->whlabel->find_all($where.$gj,'*');
- $rows = array();$list = array();
- $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
- // foreach ($info_list as $value)
- // {
- // $warehouse = $this->warehouse->read($value['warehouse']);
- // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
- // $number = $value['number'];$ftime = time()-15*24*3600;
- // if($c < 1)
- // {
- // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
- // }
- // }
-
-
- $warehouse_list = $this->warehouse->find_all();
- $warehouse_list = array_column($warehouse_list,null,'id');
-
- foreach ($info_list as $value)
- {
- $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
- 'title'=>"",
- ];
- $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- if($c < 1)
- {
- $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
- }
- }
- // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
- // $query = $this->db->query($sql);
-
- // $info_list = $query->result_array();
- // $sql_two = "select title,id from crowd_warehouse";
- // $query_two = $this->db->query($sql_two);
- // $warehouse_list = $query_two->result_array();
- // $warehouse_arr = array_column($warehouse_list,null,'id');
- // foreach ($info_list as $value)
- // {
- // if(isset($warehouse_arr[$value['warehouse']])){
- // $warehouse = $warehouse_arr[$value['warehouse']];
- // }else{
- // $warehouse = [
- // 'id'=>0,
- // 'title'=>"异常",
- // ];
- // }
- // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
- // $number = $value['number'];$ftime = time()-15*24*3600;
- // if($c < 1)
- // {
- // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
- // }
- // }
- $listdata = array_slice($list,$start,$perpage);
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
- echo json_encode($rows);exit;
- }
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',trim($id_arr,','));
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $dd = $this->whlabel->read($v);
- if(!isset($dd['id']))
- {
- echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
- }
- $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
- if(isset($zt[0]))
- {
- echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
- }
- $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
- foreach ($deldd as $vv)
- {
- $this->whlabel->remove($vv['id']);
- }
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- $this->_Template('whlabel_error',$this->data);
- }
-
- public function _errorexcel()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($_GET['page']))
- {
- $page = $this->input->get('page',true);
- $perpage = $this->input->get('perpage',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "sku != 'Preset'";
- $gj = '';
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- else
- {
- if($ktime && $jtime)
- {
- $gj = " and time > '$ktime' and time < '$jtime'";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $rows = array();$list = array();
- $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
- foreach ($info_list as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- if($c < 1)
- {
- $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
- }
- }
- $title = "0库存汇总";
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>当前库存</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- /**
- *
- *
- * 占单
- *
- *
- **/
- public function _kcyz()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['warehouse']))
- {
- return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
- $warehouse = $this->input->post('warehouse',true);
- $whlabel = $this->input->post('whlabel',true);
- $id = $this->input->post('id',true);
- $shop = $this->input->post('shop',true);
- $number = $this->input->post('number',true);
- if(!$whlabel || $whlabel == '|')
- {
- return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
- }
- $pp = explode('|',trim($whlabel,'|'));
- $x = 0;$save = array();
- foreach ($pp as $va)
- {
- $num = explode('-',$va);
- if($number)
- {
- $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 = '')");//通用
- $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
- }
- else
- {
- $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
- $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
- }
- $x++;
- if(count($whlabel)+count($shopwhlabel) < $num[1])
- {
- $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
- }
- }
- if(isset($save[0]))
- {
- echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
- }
- else
- {
- echo json_encode(array('success'=>true));exit;
- }
- }
- }
-
- public function _db()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "dbtime > 0";
- if($timetk && $timetj)
- {
- $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- if($warehouse == 12)
- {
- $w = 'specialstock';
- }
- else
- {
- $w = 'whlabel';
- }
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($state != '')
- {
- $where .= " and state = '$state'";
- }
- //数据排序
- $order_str = "dbtime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->$w->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['dbtime'] != 0)
- {
- $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
- }
- else
- {
- $info_list[$key]['dbtime'] = "";
- }
-
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
-
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['outsku']))
- {
- $time = time();
- $cz = $this->input->post('cz',true);
- $label = $this->input->post('outsku',true);
- $sl = $this->input->post('sl',true);
- $num = $this->input->post('num',true);
- //$warehouse = $this->input->post('warehouse',true);
- if(!$sl)
- {
- $sl = 1;
- }
- if(!$warehouse)
- {
- echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
- }
- $dblabel = $this->whlabellabel->get_label($label);
- if($dblabel)
- {
- $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
- }
- if(count($data) < $num)
- {
- echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
- }
- for($i=0;$i<$sl;$i++)
- {
- $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
- }
- echo json_encode(array('success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
- }
- }
- $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
- $this->_Template('whlabel_db',$this->data);
- }
-
- public function _dbrk()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $ctime = $this->input->post('ctime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "dbtime > 0";
- if($timetk && $timetj)
- {
- $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($state != '')
- {
- $where .= " and state = '$state'";
- }
- //数据排序
- $order_str = "dbtime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['dbtime'] != 0)
- {
- $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
- }
- else
- {
- $info_list[$key]['dbtime'] = "";
- }
-
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
-
- }
- $total = $this->whlabel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['rsku']))
- {
- $cz = $this->input->post('cz',true);
- $label = $this->input->post('rsku',true);
- $sl = $this->input->post('sl',true);
- $warehouse = $this->input->post('warehouse',true);
- if(!$sl)
- {
- $sl = 1;
- }
- if(!$warehouse)
- {
- echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
- }
- $dblabel = $this->whlabellabel->get_label($label);
- if($dblabel)
- {
- $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
- }
- if($sl > count($data))
- {
- echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
- }
- $time = time();
- for($i=0;$i<$sl;$i++)
- {
- $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']);
- }
- echo json_encode(array('success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
- }
- }
- $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
- $this->_Template('whlabel_dbrk',$this->data);
- }
-
-
- public function _whlabelczdc()
- {
- if(isset($_GET['excel']))
- {
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $state = $this->input->get('state',true);
- $sku = $this->input->get('sku',true);
- $ctime = $this->input->get('ctime',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $timetk = $this->input->get('timetkk',true);
- $timetj = $this->input->get('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "dbtime > 0";
- if($timetk && $timetj)
- {
- $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- //取得信息列表
- $info_list = $this->whlabel->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['sku']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
- $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
-
- if($value['state'] == 0)
- {
- $value['state'] = "在库";
- }
- else if($value['state'] == 3)
- {
- $value['state'] = "调拨中";
- }
- $list[] = array($value['sku'],$value['title'],$db,$rk);
- }
- $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
- $titlename = "<table border=1>
- <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>SKU</td>
- <td>产品</td>
- <td>调拨数量</td>
- <td>入库数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
-
- public function _print($arg_array)
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['tmsku']))
- {
- $tmsku = $this->input->post('tmsku',true);
- if(is_numeric($tmsku))
- {
- $yyh = $this->whlabellabel->get_label($tmsku);
- }
- else
- {
- $yyh = $this->whlabellabel->get_sku($tmsku);
- }
- if($yyh)
- {
- echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('success'=>false));exit;
- }
- }
- $classid = $this->classid->sku();
- $pm = $classid;
- $scsku = $classid;
- //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
- if(isset($post['warehouse']))
- {
- if($post['warehouse'])
- {
- $list = array();$num = "";$title = "";$features = "";
- $order = 0;
- $post['shop'] = '';
- $brand = $this->input->post('brand',true);
- if($brand != '0,')
- {
- $b = $this->brand->read(rtrim($brand,','));
- if($b)
- {
- $post['shop'] = str_replace('|',',',$b['shop']);
- }
- }
- $post['details'] = $this->input->post('details',true);//打印数量
- $xbqnum = $this->input->post('xbqnum',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['retreatwarehouse'] = $post['warehouse'];
- $post['cpbz'] = $this->input->post('cpbz',true);
- $post['state'] = 9;
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
-
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $post[$k] = $v;
- $typeclass = $this->typeclass->read($v);
- if(isset($pm[$typeclass['classid']]))
- {
- if(stripos($typeclass['zh'],'|') !== false)
- {
- $exzh = explode('|',$typeclass['zh']);
- $pm[$typeclass['classid']] = $exzh[0];
- }
- else
- {
- $pm[$typeclass['classid']] = $typeclass['zh'];
- }
- }
- $scsku[$typeclass['classid']] = $typeclass['bqsku'];
- if($k != 'size')
- {
- $title .= $typeclass['title']." ";
- }
- }
- }
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- $time = time();
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
- $featurespp = explode('-',trim($featurespp,'-'));
- if(isset($featurespp[5]))
- {
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
- }
- else
- {
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
- }
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- $scsku = implode("-",$scsku);
- $zh = implode(" ",$pm);
- $scsku = str_replace('- ','-',trim($scsku,'-'));
- $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
- $post['sku'] = $bqsku;
- $label = time().rand(0,9);
- $post['label'] = $label;
- $cpid = $this->whlabellabel->find_count();
- $post['cpid'] = $cpid+1;
- $cpid = $post['cpid'];
- //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
-
- //if($whlabelbarcode)
- //{
- //$post['label'] = $whlabelbarcode['label'];
- //if(!$this->whlabellabel->insert($post))
- //{
- // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
- //}
- //}
- //else
- //{
- $this->db->trans_begin();
- $this->whlabellabel->insert($post);
- //$this->whlabelbarcode->insert($post);
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
- }
- //}
- $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
- $purchase = $this->purchase->read($post['purchase']);
- 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));exit;//特殊仓目前不需要仓库选项
- }
- }
- if(isset($_SESSION['api']))
- {
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['wlshop'] = $wlshop;
- $this->data['warehouse'] = $warehouse;
- }
- $whlabelwz = $this->whlabelwz->find_all();
- $this->data['whlabelwz'] = $whlabelwz;
- $this->_Template('whlabel_print',$this->data);
- }
-
-
- public function _usaprint($arg_array)
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['tmsku']))
- {
- $tmsku = $this->input->post('tmsku',true);
- if(is_numeric($tmsku))
- {
- $yyh = $this->whlabellabel->get_label($tmsku);
- }
- else
- {
- $yyh = $this->whlabellabel->get_sku($tmsku);
- }
- if($yyh)
- {
- echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('success'=>false));exit;
- }
- }
- $classid = $this->classid->sku();
- $pm = $classid;
- $scsku = $classid;
- //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
- if(isset($post['warehouse']))
- {
- if($post['warehouse'])
- {
- $list = array();$num = "";$title = "";$features = "";
- $order = 0;
- $post['shop'] = '';
- $brand = $this->input->post('brand',true);
- if($brand != '0,')
- {
- $b = $this->brand->read(rtrim($brand,','));
- if($b)
- {
- $post['shop'] = str_replace('|',',',$b['shop']);
- }
- }
- $post['details'] = $this->input->post('details',true);//打印数量
- $xbqnum = $this->input->post('xbqnum',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $post['retreatwarehouse'] = $post['warehouse'];
- $post['cpbz'] = $this->input->post('cpbz',true);
- $post['state'] = 9;
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
-
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $post[$k] = $v;
- $typeclass = $this->typeclass->read($v);
- if(isset($pm[$typeclass['classid']]))
- {
- if(stripos($typeclass['zh'],'|') !== false)
- {
- $exzh = explode('|',$typeclass['zh']);
- $pm[$typeclass['classid']] = $exzh[0];
- }
- else
- {
- $pm[$typeclass['classid']] = $typeclass['zh'];
- }
- }
- $scsku[$typeclass['classid']] = $typeclass['bqsku'];
- if($k != 'size')
- {
- $title .= $typeclass['title']." ";
- }
- }
- }
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- $time = time();
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $fp = $this->whlabel->get_features($post['features']);
- if(!$fp)
- {
- echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
- }
- $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
- $featurespp = explode('-',trim($featurespp,'-'));
- if(isset($featurespp[5]))
- {
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
- }
- else
- {
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
- }
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- $scsku = implode("-",$scsku);
- $zh = implode(" ",$pm);
- $scsku = str_replace('- ','-',trim($scsku,'-'));
- $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
- $post['sku'] = $fp['sku'];
- $post['label'] = $fp['sku'];
- $cpid = $this->whlabellabel->find_count();
- $post['cpid'] = $cpid+1;
- $cpid = $post['cpid'];
- //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
-
- //if($whlabelbarcode)
- //{
- //$post['label'] = $whlabelbarcode['label'];
- //if(!$this->whlabellabel->insert($post))
- //{
- // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
- //}
- //}
- //else
- //{
- $this->db->trans_begin();
- $this->whlabellabel->insert($post);
- //$this->whlabelbarcode->insert($post);
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
- }
- //}
- $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
- $purchase = $this->purchase->read($post['purchase']);
- 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));exit;//特殊仓目前不需要仓库选项
- }
- }
- if(isset($_SESSION['api']))
- {
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['wlshop'] = $wlshop;
- $this->data['warehouse'] = $warehouse;
- }
- $whlabelwz = $this->whlabelwz->find_all();
- $this->data['whlabelwz'] = $whlabelwz;
- $this->_Template('whlabel_usaprint',$this->data);
- }
-
-
- public function _printrk($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $bs = $this->input->post('bs',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $timetk = $this->input->post('ktime',true);
- $timetj = $this->input->post('jtime',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "1=1 ";
- if($timetk && $timetj)
- {
- $where .= " and enter > '$timetk' and enter < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($bs != '')
- {
- $where .= " and bs = '$bs'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- if($state || $state == 0)
- {
- $where .= " and state = '$state'";
- }
- $ck = ($warehouse == '12')?'specialstock':'whlabel';
- //数据排序
- $order_str = "enter desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
- else if($value['state'] == 10)
- {
- $info_list[$key]['state'] = "美店零售";
- }
- $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
- }
- $total = $this->$ck->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['tmsku']))
- {
- $time = time();
- $tmsku = $this->input->post('tmsku',true);
- //$post['shop'] = $this->input->post('shop',true);
- $num = $this->input->post('num',true);
- $rktype = $this->input->post('rktype',true);
- if($num > 200)
- {
- echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
- }
- if(!$rktype)
- {
- //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
- }
- $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
- /**
- $wz = array();
- foreach ($rk as $key=>$value)
- {
- $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
- }
- if(count($wz) > 1)
- {
- $wz = array_values($wz);
- echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
- }
- **/
- if(isset($rk[0]['purchase']))
- {
- $rk = $rk[0];
- $j = 0;
- $post['purchase'] = $rk['purchase'];
- $post['warehouse'] = $rk['warehouse'];
- $post['retreatwarehouse'] = $rk['warehouse'];
- $post['sku'] = $rk['sku'];
- $post['number'] = $rk['number'];
- $post['features'] = $rk['features'];
- $post['title'] = $rk['title'];
- $post['enter'] = $time;
- $post['time'] = $time;
- $post['bs'] = 1;
- $post['shop'] = $rk['shop'];
- $post['details'] = $rk['details'];
- $post['cpid'] = $rk['cpid'];
- $post['cpbz'] = $rk['cpbz'];
- //$post['rktype'] = $rktype;
- $warehouse = $this->warehouse->read($rk['warehouse']);
- if($warehouse['bdck'] == '')
- {
- echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
- }
- else
- {
- $bdck = $warehouse['bdck'];
- }
- $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
- if(isset($pdwz['details']))
- {
- if($pdwz['details'] != $post['details'])
- {
- echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
- }
- }
- $post['featurespp'] = $rk['featurespp'];
-
- if($post['warehouse'] == '5')
- {
- $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
- if($yza)
- {
- if($post['features'] != $yza[0]['features'])
- {
- echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
- }
- }
- $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
- if($yzb)
- {
- if($post['sku'] != $yzb[0]['sku'])
- {
- echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
- }
- }
- }
- for($i=0;$i<$num;$i++)
- {
- $post['label'] = time().rand(100,999).$i;
- if($this->$bdck->insert($post))
- {
- $j++;
- }
- }
- /**
- if($post['warehouse'] != 12)
- {
- echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
- }
- **/
- if($j == $num)
- {
- echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
- }
- }
- $this->_Template('whlabel_printrk',$this->data);
- }
- public function _printxzrk($arg_array)
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['wzid']))
- {
- $time = time();
- $id = $this->input->post('wzid',true);
- //$post['shop'] = $this->input->post('shop',true);
- $num = 1;
- $rk = $this->whlabellabel->read($id);
- if(isset($rk['purchase']))
- {
- $x = 0;
- $post['purchase'] = $rk['purchase'];
- $post['warehouse'] = $rk['warehouse'];
- $post['retreatwarehouse'] = $rk['warehouse'];
- $post['sku'] = $rk['sku'];
- $post['number'] = $rk['number'];
- $post['features'] = $rk['features'];
- $post['title'] = $rk['title'];
- $post['enter'] = $time;
- $post['time'] = $time;
- $post['bs'] = 1;
- $post['shop'] = $rk['shop'];
- $post['details'] = $rk['details'];
- $post['cpid'] = $rk['cpid'];
- $post['cpbz'] = $rk['cpbz'];
- $warehouse = $this->warehouse->read($rk['warehouse']);
- if($warehouse['bdck'] == '')
- {
- echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
- }
- else
- {
- $bdck = $warehouse['bdck'];
- }
- $post['featurespp'] = $rk['featurespp'];
- $this->db->trans_begin();
- for($i=0;$i<$num;$i++)
- {
- $post['label'] = time().rand(100,999).$i;
- $this->$bdck->insert($post);
- }
- /**
- if($post['warehouse'] != 12)
- {
- echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
- }
- **/
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
- echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
- }
- }
- }
- public function _printck($arg_array)
- {
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $bs = $this->input->post('bs',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $timetk = $this->input->post('ktime',true);
- $timetj = $this->input->post('jtime',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "state=1 ";
- if($timetk && $timetj)
- {
- $where .= " and outk > '$timetk' and outk < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($bs != '')
- {
- $where .= " and bs = '$bs'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- $ck = ($warehouse == '12')?'specialstock':'whlabel';
- //数据排序
- $order_str = "outk desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
- $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
- else if($value['state'] == 10)
- {
- $info_list[$key]['state'] = "美店零售";
- }
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
- }
- $total = $this->$ck->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['tmsku']))
- {
- $time = time();
- $tmsku = $this->input->post('tmsku',true);
- //$post['shop'] = $this->input->post('shop',true);
- $num = $this->input->post('num',true);
- $cktype = $this->input->post('cktype',true);
- $label = $this->whlabellabel->get_label($tmsku);
- if(!$cktype)
- {
- //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
- }
- if(!isset($label['warehouse']))
- {
- echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
- }
- $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
- if(stripos($label['features'],'-126-') !== false)
- {
- $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
- }
- else
- {
- $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 = ''");
- }
- $j = 0;
- if(count($ck) >= $num)
- {
- for($i=0;$i<$num;$i++)
- {
- if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
- {
- $j++;
- }
- }
- if($j == $num)
- {
- echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
- }
- }
- $this->_Template('whlabel_printck',$this->data);
- }
-
-
- public function _printexcel()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
- $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- $phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
- $cmf_arr = array_column($list, '1');
- array_multisort($cmf_arr, SORT_ASC, $list);
- foreach ($list as $key=>$value)
- {
- $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
- if($typeclass)
- {
- $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
- }
- else
- {
- $ed[] = array($value['1'].'-系统未找到此订单信息');
- $i++;
- continue;
- }
- }
- if($i > 0)
- {
- $yc = $i.'条异常';
- }
- echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
-
- }
- }
-
- public function _uck()
- {
- if(isset($_GET['excel']))
- {
- $tc = array();
- $typeclass = $this->typeclass->find_all();
- foreach ($typeclass as $v)
- {
- $tc[$v['id']] = $v['zh'];
- }
- $data = array();$t = array();$rq = '';
- $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
- $ts = $ts/(24*3600);
- for($i=0;$i<$ts;$i++)
- {
- $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
- $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
- }
- $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
- foreach ($info_list as $k=>$v)
- {
- $features = explode('-',trim($v['features'],'-'));
- if(!isset($features[3]) || !isset($features[4]))
- {
- continue;
- }
- $data[$k][0] = $tc[$features[0]];//类型
- $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
- $data[$k][2] = $tc[$features[4]];//曲度
- $data[$k][3] = '';
- if(isset($data[$k][1]))
- {
- $data[$k][3] .= $data[$k][1];
- }
- if(isset($data[$k][2]))
- {
- $data[$k][3] .= $data[$k][2];
- }
- if(isset($features[5]))
- {
- $data[$k][3] .= $tc[$features[5]];
- }
- if(isset($features[2]))
- {
- $data[$k][3] .= $tc[$features[2]];
- }
- //$data[$k][3] 颜色,曲度,头套种类,尺寸
- $data[$k][4] = $v['sku'];
- $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())).'))');//月初库存
- $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
- $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
- $ztrq = '';$ztsl = '';
- if(count($zt) > 0)
- {
- foreach ($zt as $vv)
- {
- $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
- $ztsl .= $vv['num'].'<br>';
- }
- }
- $data[$k][] = trim($ztsl,'<br>');
- $data[$k][] = trim($ztrq,'<br>');
- $byck = 0;
- foreach ($t as $vv)
- {
- $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));
- $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
- $byck += $sl;
- }
- $data[$k][] = ($byck > 0)?$byck:'';
- }
-
- $title = "详情 ".date("Y-m-d",time());
- $titlename = "<table border=1>
- <tr align='center'>
- <td>类别</td>
- <td>颜色</td>
- <td>曲度</td>
- <td>名称</td>
- <td>SKU</td>
- <td>月初库存</td>
- <td>剩余库存</td>
- <td>在途数量</td>
- <td>预达日期</td>".
- $rq
- ."<td>本月出库</td></tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($data,$titlename,$filename,$tail);
- }
- }
-
- public function _whlabelexcelzh()
- {
- if(isset($_GET['excel']))
- {
- $where = "sku != 'Preset'";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $category = $this->input->get('category',true);
- $warehouse = $this->input->get('warehouse',true);
- $excelid = $this->input->get('sid',true);
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- $xzid = '';
- if($excelid)
- {
- $excelid = explode(',',trim($excelid,','));
- foreach ($excelid as $key=>$value)
- {
- $xzid .= " id = ".$value." or";
- }
- $xzid = " and (".rtrim($xzid,'or').")";;
- }
- //取得信息列表
- /**
- $info_list = $this->whlabel->find_all($where.$xzid,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
- }
- **/
- $list = array();
- $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
- foreach ($rows as $key=>$value)
- {
- $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
- $zh = '';
- $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
- foreach ($zt as $v)
- {
- $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
- }
- $zt = array_sum(array_column($zt,'num'));
- $number = $value['number'];
- $ftime = time()-15*24*3600;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $rows[$key]['warehouse'] = $warehouse['title'];
- $rows[$key]['number'] = $c;
- $rows[$key]['features'] = $zh;
- $rows[$key]['hb'] = $c+$zt;
- }
- $title = "导出库存数据及在途中数据".date('Y-m-d',time());
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>库存数量</td>
- <td>在途数量及预达日期</td>
- <td>在途+库存数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- if(isset($_GET['excel']))
- {
- $warehouse = $this->input->get('warehouse',true);
- $sku = $this->input->get('sku',true);
- $cz = $this->input->get('cz',true);
- $text = $this->input->post('text',true);
- $xztime = $this->input->get('xztime',true);
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "time = '0' ";
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($text)
- {
- $where .= " and text like '%$text%'";
- }
- if($cz != '')
- {
- $where .= " and cz = '$cz'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- //数据排序
- $order_str = $xztime." desc";
- //取得信息列表
- $zh = array();
- $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
- foreach ($info_list as $v)
- {
- $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
- $warehouse = $this->warehouse->read($v['warehouse']);
- $v['warehouse'] = $warehouse['title'];
- $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
- $v['stime'] = date('Y-m-d',$v['stime']);
- if(isset($zh[$v['features']]))
- {
- $zh[$v['features']]['num'] += $v['num'];
- }
- else
- {
- $zh[$v['features']] = $v;
- }
- $zh[$v['features']]['features'] = $c;
- }
- $title = "在途数据".date('Y-m-d',time());
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>名称</td>
- <td>在途数量</td>
- <td>库存数量</td>
- <td>添加在途日期</td>
- <td>预达日期</td>
- <td>备注</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($zh,$titlename,$filename,$tail);
- }
- }
-
- public function _fc()
- {
- $vip = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- if($user['vip'] == 1)
- {
- $vip = 1;
- }
- }
- else
- {
- header('Location: /');exit;
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "state = '11'";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $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'].'"');
- $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['number'] = $g;
- $info_list[$key]['features'] = $x;
- $info_list[$key]['x'] = $s;
- }
- $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['vip'] = $vip;
- $this->_Template('whlabel_fc',$this->data);
- }
-
- public function _fcmb()
- {
- $where = "sku != 'Preset'";
- $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
- foreach ($rows as $k=>$v)
- {
- $warehouse = $this->warehouse->read($v['warehouse']);
- $rows[$k]['warehouse'] = $warehouse['title'];
- $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
- $rows[$k]['t'] = '';
- $rows[$k]['n'] = '';
- }
- $title = "封货产品数据导入模板";
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>封存产品总数量</td>
- <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
- <td>数量(填写正整数,留空导入时自动跳过此行)</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
-
- }
- public function _fcexcel()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- libxml_use_internal_errors(true);
- require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
- $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- $phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();
- foreach ($list as $key=>$value)
- {
- $time = time();
- if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
- {
- continue;
- }
- $warehouse = $this->warehouse->get_title($value['0']);
- $sku = $value['1'];
- $type = $value['4'];//调整方式0扣减1删除
- $num = $value['5'];//调整数量
- //$text = $value['4'];//扣减说明
- $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
- if(!$d)//如果没有这个SKU
- {
- $ed[] = array($sku.'-库存中不存在此SKU');
- $j++;
- continue;
- }
- if(!isset($warehouse['id']))
- {
- $ed[] = array($sku.'-仓库名错误!');
- $j++;
- continue;
- }
- if($type == 1 || $type == 2)//扣减库存
- {
- $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
- if(count($data) < abs($num))
- {
- $ed[] = array($sku.'-数量大于封存产品剩余数量!');
- $j++;
- continue;
- }
- if($type == 1)//转入库存
- {
- for($i=0;$i<abs($num);$i++)
- {
- $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
- }
- }
- else if($type == 2)//删除
- {
- for($i=0;$i<abs($num);$i++)
- {
- $this->whlabel->remove($data[$i]['id']);
- }
- }
- }
- else if($type == 0)//增加库存
- {
- $post['sku'] = $d['sku'];
- $post['shop'] = '';
- $post['warehouse'] = $warehouse['id'];
- $post['purchase'] = $d['purchase'];
- $post['retreatwarehouse'] = $d['retreatwarehouse'];
- $post['state'] = 11;
- $post['title'] = $d['title'];
- $post['number'] = $d['number'];
- $post['features'] = $d['features'];
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- for($i=0;$i<$num;$i++)
- {
- $post['label'] = time().rand(100,999).$i;
- $this->whlabel->insert($post);
- }
- }
- sleep(1);//防止入库时间一样,需要延迟1秒
- }
- if($j > 0)
- {
- $tt = date('Ymd',time());
- $title = '库存导入错误信息-'.$tt;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
- }
- }
- }
-
- public function _fcjxc($arg_array)
- {
- if(isset($_GET['excel']))
- {
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku');
- $title = $this->input->get('title');
- $warehouse = $arg_array[0];
- $usa = $this->input->get('usa',true);
- $purchase = $this->input->get('purchase',true);
- $lacetype = $this->input->get('lacetype',true);
- $haircap = $this->input->get('haircap',true);
- $density = $this->input->get('density',true);
- $title = $this->input->get('title',true);
- $state = $this->input->get('state',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $where = "state=11";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- $order_str = "id desc";
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
-
- $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'].'"');
- $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
- $rows[$key] = $value;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $rows[$key]['warehouse'] = $warehouse['title'];
- $rows[$key]['features'] = $g;
- $rows[$key]['a'] = $x;
- $rows[$key]['b'] = $s;
- }
- $title = "总统计表";
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品名称</td>
- <td>录入总量</td>
- <td>取出总量</td>
- <td>剩余总量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- $vip = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- if($user['vip'] == 1)
- {
- $vip = 1;
- }
- }
- else
- {
- header('Location: /');exit;
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $arg_array[0];
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $title = $this->input->post('title',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "state=11";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";$xs=0;
- $rows = array();$list = array();
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku || $title)
- {
- if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- }
- else
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- }
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
-
- $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'].'"');
- $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
- $rows[$key] = $value;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $rows[$key]['warehouse'] = $warehouse['title'];
- $rows[$key]['features'] = $g;
- $rows[$key]['a'] = $x;
- $rows[$key]['b'] = $s;
- $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
- $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天销量
- $yj = $c/($xl/30);
-
- if($yj < 7)
- {
- $rows[$key]['y'] = round($yj).'天销量';
- }
- else
- {
- $rows[$key]['y'] = '正常';
- }
- }
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
-
- $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'].'"');
- $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
- $zs[$key] = $value;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $zs[$key]['warehouse'] = $warehouse['title'];
- $zs[$key]['features'] = $g;
- $zs[$key]['a'] = $x;
- $zs[$key]['b'] = $s;
- $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
- $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天销量
- $yj = $c/($xl/30);
-
- if($yj < 7)
- {
- $zs[$key]['y'] = round($yj).'天销量';
- $rows[$key] = $zs[$key];
- }
- }
- }
-
-
- $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
- echo json_encode($rows);exit;
- }
- $this->data['arg_array'] = $arg_array[0];
- $this->_Template('whlabel_fcjxc',$this->data);
- }
-
- public function _0kcdel()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "./data/excel/PHPExcel/IOFactory.php";
- @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();
- foreach ($list as $key=>$value)
- {
- $time = time();
- if($value['0'] == "" || $value['1'] == "")
- {
- continue;
- }
- $warehouse = $this->warehouse->get_title($value['0']);
- $sku = $value['1'];
- $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
- if(!$d)//如果没有这个SKU
- {
- $ed[] = array($sku.'-库存中不存在此SKU');
- $j++;
- continue;
- }
- if(!isset($warehouse['id']))
- {
- $ed[] = array($sku.'-仓库名错误!');
- $j++;
- continue;
- }
- $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
- if($z < 1)
- {
- $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
- foreach ($z as $v)
- {
- $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
- if(count($zt) > 0)
- {
- $ed[] = array($sku.'-有在途库存无法删除!');
- $j++;
- continue;
- }
- $this->whlabel->remove($v['id']);
- }
- }
- else
- {
- $ed[] = array($sku.'-非0库存!');
- $j++;
- continue;
- }
- }
- if($j > 0)
- {
- $tt = date('Ymd',time());
- $title = '删除0库存错误信息-'.$tt;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
- }
- }
- }
-
- public function _gbhtype()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $n = $this->input->post('n');
- $d = $this->input->post('s');
- if(!$d)
- {
- echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
- }
- $d = explode(',',trim($d,','));
- $t = $this->whlabel_type->read($n);
- //循环删除记录
- foreach ($d as $v)
- {
- $u = $this->whlabel->read($v);
- $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
- foreach ($data as $val)
- {
- $this->whlabel->save(array('type'=>$n),$val['id']);
- }
- }
- echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
- }
- }
-
-
- //出库、退库导出
- public function _dccrtype()
- {
- $classid = $this->classid->sku();
- $pm = $classid;
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach ($tc as $v)
- {
- $typeclass[$v['id']] = $v;
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['sid']))
- {
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $type = $this->input->get('excel',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $lacetype = $this->input->get('lacetype',true);
- $lacecolor = $this->input->get('lacecolor',true);
- $density = $this->input->get('density',true);
- $haircap = $this->input->get('haircap',true);
- $purchase = $this->input->get('purchase',true);
- $title = $this->input->get('title',true);
- $state = $this->input->get('state',true);
- $sid = $this->input->get('sid',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($lacecolor)
- {
- $where .= " and features like '%-$lacecolor-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
- }
- $sidwhere = '';
- if($sid)
- {
- $sd = "";
- $s = explode(',',trim($sid,','));
- foreach ($s as $value)
- {
- $sd .= " id = ".$value." or";
- }
- $sidwhere = " and (".rtrim($sd,'or').")";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $wh = array();
- $w = $this->warehouse->find_all('1=1','id,title');
- foreach ($w as $v)
- {
- $wh[$v['id']] = $v['title'];
- }
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['id']] = $v['title'];
- }
- $classid = $this->classid->sku();
- $list = array();
- $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');
- foreach ($rows_r as $key=>$value)
- {
- $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
- $pm = $classid;
- $jm = $classid;
- $rows_r[$key]['enter'] = '入库';
- $rows_r[$key]['time'] = $value['enter'];
- if($value['rktype'] == 1)
- {
- $rows_r[$key]['rktype'] = '采购入库';
- }
- else if($value['rktype'] == 2)
- {
- $rows_r[$key]['rktype'] = '盘盈调整';
- }
- else if($value['rktype'] == 3)
- {
- $rows_r[$key]['rktype'] = '其他调整入库';
- }
- else if($value['rktype'] == 4)
- {
- $rows_r[$key]['rktype'] = '其他调整入库';
- }
- else if($value['rktype'] == 5)
- {
- $rows_r[$key]['rktype'] = '退库入库';
- }
- else if($value['rktype'] == 6)
- {
- $rows_r[$key]['rktype'] = '退货可用入库';
- }
- else if($value['rktype'] == 7)
- {
- $rows_r[$key]['rktype'] = '形态转换入库';
- }
- else
- {
- $rows_r[$key]['rktype'] = '';
- }
- $features = explode('-',trim($value['features'],'-'));
- foreach($features as $v)
- {
- if(isset($typeclass[$v]))
- {
- $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
- $pm[$typeclass[$v]['classid']] = $zh[0];
- }
- if(isset($typeclass[$v]))
- {
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
-
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $rows_r[$key]['zh'] = $zh;
- $jm = array_filter($jm);
- $rows_r[$key]['features'] = implode("-",$jm);
- $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
- }
-
- $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
- foreach ($rows_c as $key=>$value)
- {
- $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
- $pm = $classid;
- $jm = $classid;
- $rows_c[$key]['time'] = $value['outk'];
- $rows_c[$key]['outk'] = '出库';
- if($value['cktype'] == 1)
- {
- $rows_c[$key]['cktype'] = '销售出库';
- }
- else if($value['cktype'] == 2)
- {
- $rows_c[$key]['cktype'] = '销售美国出库';
- }
- else if($value['cktype'] == 3)
- {
- $rows_c[$key]['cktype'] = '盘亏调整';
- }
- else if($value['cktype'] == 4)
- {
- $rows_c[$key]['cktype'] = '其他调整出库';
- }
- else if($value['cktype'] == 5)
- {
- $rows_c[$key]['cktype'] = '形态转换出库';
- }
- else
- {
- $rows_c[$key]['cktype'] = '';
- }
- $features = explode('-',trim($value['features'],'-'));
- foreach($features as $v)
- {
- if(isset($typeclass[$v]))
- {
- $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
- $pm[$typeclass[$v]['classid']] = $zh[0];
- }
- if(isset($typeclass[$v]))
- {
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
-
- }
- }
- }
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $rows_c[$key]['zh'] = $zh;
- $jm = array_filter($jm);
- $rows_c[$key]['features'] = implode("-",$jm);
- $rows_c[$key]['number'] = 1;
- }
- $merged = $rows_r;
- foreach ($rows_c as $key => $value)
- {
- if (isset($merged[$key]))
- {
- $merged[] = $value;
- }
- else
- {
- $merged[$key] = $value;
- }
- }
- usort($merged, function($a, $b)
- {
- return $a['time'] - $b['time'];
- });
- foreach ($merged as $key=>$value)
- {
- $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>商品名称</td>
- <td>仓库品名</td>
- <td>料号</td>
- <td>时间</td>
- <td>操作</td>
- <td>类型</td>
- <td>数量</td>
- <td>备注</td>
- </tr>
- </table>";
- $filename = $title.".xlsx";
- $tail = "";
- $this->excel->get_fz2($merged,$titlename,$filename,$tail);
-
- }
- }
-
- }
|