Whlabel.php 290 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else if($arg == 'excelrjs'){
  190. $this->_excelrjs();
  191. } else if($arg == 'excelctjs'){
  192. $this->_excelctjs();
  193. }else if($arg == 'excelcrjs'){
  194. $this->_excelcrjs();
  195. }else if($arg == "w_t_cs"){
  196. $this->_w_t_cs(); //首页
  197. }else {
  198. $this->_index();
  199. }
  200. }
  201. public function _w_t_cs(){
  202. $vip = 0;
  203. if (isset($_SESSION['api'])) {
  204. $user = $this->user->get_api($_SESSION['api']);
  205. $fgshop = "";
  206. $sid = "";
  207. $usersp = explode('|', trim($user['shop'], '|'));
  208. foreach ($usersp as $value) {
  209. $fgshop .= " shop = " . $value . " or";
  210. $sid .= " id = " . $value . " or";
  211. }
  212. if ($user['vip'] == 1) {
  213. $vip = 1;
  214. }
  215. } else {
  216. header('Location: /');
  217. exit;
  218. }
  219. $prc = array();
  220. $purchase = $this->purchase->find_all();
  221. foreach ($purchase as $k => $v) {
  222. $prc[$v['id']] = $v['title'];
  223. }
  224. $company = array();
  225. $ct = $this->company->find_all();
  226. foreach ($ct as $k => $v) {
  227. $company[$v['id']] = $v['title'];
  228. }
  229. $sp = array();
  230. $s = $this->shop->find_all('1=1', 'id,shopname');
  231. foreach ($s as $v) {
  232. $sp[$v['id']] = $v['shopname'];
  233. }
  234. $wh = array();
  235. $w = $this->warehouse->find_all('1=1', 'id,title');
  236. foreach ($w as $v) {
  237. $wh[$v['id']] = $v['title'];
  238. }
  239. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  240. $this->data['shop'] = $wlshop;
  241. $this->data['vip'] = $vip;
  242. $this->_Template('whlabel_typejs', $this->data);
  243. }
  244. //管理
  245. public function _index()
  246. {
  247. $post = $this->input->post(NULL, TRUE);
  248. if (isset($post['page'])) {
  249. $page = $this->input->post('page', true);
  250. $perpage = $this->input->post('perpage', true);
  251. $sku = $this->input->post('sku', true);
  252. $number = $this->input->post('number', true);
  253. $warehouse = $this->input->post('warehouse', true);
  254. $purchase = $this->input->post('purchase', true);
  255. $orderinfo = $this->input->post('orderinfo', true);
  256. $waybill = $this->input->post('waybill', true);
  257. $category = $this->input->post('category', true);
  258. $size = $this->input->post('size', true);
  259. $grade = $this->input->post('grade', true);
  260. $color = $this->input->post('color', true);
  261. $lowe = $this->input->post('lowe', true);
  262. $state = $this->input->post('state', true);
  263. $label = $this->input->post('label', true);
  264. $timetk = $this->input->post('timetkk', true);
  265. $timetj = $this->input->post('timetjj', true);
  266. $timetk = strtotime($timetk);
  267. $timetj = strtotime($timetj);
  268. $where = "1=1 ";
  269. if ($timetk && $timetj) {
  270. $where .= " and time > '$timetk' and time < '$timetj'";
  271. }
  272. if ($sku) {
  273. $where .= " and sku = '$sku'";
  274. }
  275. if ($number) {
  276. $where .= " and number = '$number'";
  277. }
  278. if ($warehouse) {
  279. $where .= " and warehouse = '$warehouse'";
  280. }
  281. if ($purchase) {
  282. $where .= " and purchase = '$purchase'";
  283. }
  284. if ($orderinfo) {
  285. $where .= " and orderinfo = '$orderinfo'";
  286. }
  287. if ($waybill) {
  288. $where .= " and waybill = '$waybill'";
  289. }
  290. if ($category) {
  291. $where .= " and features like '%-$category-%'";
  292. }
  293. if ($size) {
  294. $where .= " and features like '%-$size-%'";
  295. }
  296. if ($grade) {
  297. $where .= " and features like '%-$grade-%'";
  298. }
  299. if ($color) {
  300. $where .= " and features like '%-$color-%'";
  301. }
  302. if ($lowe) {
  303. $where .= " and features like '%-$lowe-%'";
  304. }
  305. if ($label) {
  306. $where .= " and label = '$label'";
  307. }
  308. if ($state != '') {
  309. $where .= " and state = '$state'";
  310. }
  311. //数据排序
  312. $order_str = "time desc";
  313. if (empty($page)) {
  314. $start = 0;
  315. $perpage = 1;
  316. } else {
  317. $start = ($page - 1) * $perpage;
  318. }
  319. //取得信息列表
  320. $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);
  321. foreach ($info_list as $key => $value) {
  322. $warehouse = $this->warehouse->read($value['warehouse']);
  323. $info_list[$key]['warehouse'] = $warehouse['title'];
  324. $purchase = $this->purchase->read($value['purchase']);
  325. $info_list[$key]['purchase'] = $purchase['title'];
  326. if ($value['enter'] != 0) {
  327. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  328. } else {
  329. $info_list[$key]['enter'] = "";
  330. }
  331. if ($value['outk'] != 0) {
  332. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  333. } else {
  334. $info_list[$key]['outk'] = "";
  335. }
  336. if ($value['printing'] != 0) {
  337. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  338. } else {
  339. $info_list[$key]['printing'] = "";
  340. }
  341. if ($value['orderinfo'] == 0) {
  342. $info_list[$key]['orderinfo'] = "";
  343. }
  344. if ($value['waybill'] == 0) {
  345. $info_list[$key]['waybill'] = "";
  346. }
  347. if ($value['state'] == 0) {
  348. $info_list[$key]['state'] = "在库";
  349. } else if ($value['state'] == 1) {
  350. $info_list[$key]['state'] = "出库";
  351. } else if ($value['state'] == 2) {
  352. $info_list[$key]['state'] = "退库";
  353. } else if ($value['state'] == 3) {
  354. $info_list[$key]['state'] = "调拨中";
  355. } else if ($value['state'] == 4) {
  356. $info_list[$key]['state'] = "再加工";
  357. } else if ($value['state'] == 5) {
  358. $info_list[$key]['state'] = "维修中";
  359. } else if ($value['state'] == 6) {
  360. $info_list[$key]['state'] = "盘亏";
  361. } else if ($value['state'] == 7) {
  362. $info_list[$key]['state'] = "更换标签";
  363. } else if ($value['state'] == 8) {
  364. $info_list[$key]['state'] = "其它";
  365. } else if ($value['state'] == 9) {
  366. $info_list[$key]['state'] = "预设";
  367. } else if ($value['state'] == 10) {
  368. $info_list[$key]['state'] = "美店零售";
  369. }
  370. if ($value['text'] == "") {
  371. $info_list[$key]['text'] = "";
  372. }
  373. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  374. }
  375. $total = $this->whlabel->find_count($where);
  376. $pagenum = ceil($total / $perpage);
  377. $over = $total - ($start + $perpage);
  378. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  379. echo json_encode($rows);
  380. exit;
  381. }
  382. if (isset($post['outsku'])) {
  383. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  384. $cz = $this->input->post('cz', true);
  385. if ($cz == '1') {
  386. $sku = $this->input->post('outsku', true);
  387. if ($sku) {
  388. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  389. if (count($data) < 1) {
  390. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  391. exit;
  392. }
  393. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  394. echo json_encode(array('success' => true));
  395. exit;
  396. }
  397. } else {
  398. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  399. exit;
  400. $sku = $this->input->post('outsku', true);
  401. if ($sku) {
  402. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  403. if (count($data) < 1) {
  404. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  405. exit;
  406. }
  407. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  408. echo json_encode(array('success' => true));
  409. exit;
  410. }
  411. }
  412. }
  413. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  414. $this->_Template('whlabel', $this->data);
  415. }
  416. //在库标签
  417. public function _existence()
  418. {
  419. $post = $this->input->post(NULL, TRUE);
  420. if (isset($post['s'])) {
  421. $id_arr = $this->input->post('s');
  422. $id_arr = explode(',', $id_arr);
  423. if (!$id_arr) {
  424. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  425. exit;
  426. }
  427. //循环删除记录
  428. foreach ($id_arr as $v) {
  429. $sid = $this->whlabel->read($v);
  430. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  431. if ($count > 0) {
  432. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  433. exit;
  434. }
  435. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  436. if (count($zt) > 0) {
  437. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  438. exit;
  439. }
  440. $this->whlabel->remove($v);
  441. }
  442. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  443. exit;
  444. }
  445. if (isset($post['page'])) {
  446. $page = $this->input->post('page', true);
  447. $perpage = $this->input->post('perpage', true);
  448. $warehouse = $this->input->post('warehouse', true);
  449. $label = $this->input->post('label', true);
  450. $where = "1=1 and state = 0";
  451. if ($warehouse) {
  452. $where .= " and warehouse = '$warehouse'";
  453. }
  454. if ($label) {
  455. $where .= " and label = '$label'";
  456. }
  457. //数据排序
  458. $order_str = "time asc";
  459. if (empty($page)) {
  460. $start = 0;
  461. $perpage = 1;
  462. } else {
  463. $start = ($page - 1) * $perpage;
  464. }
  465. //取得信息列表
  466. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  467. foreach ($info_list as $key => $value) {
  468. if ($value['enter'] != 0) {
  469. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  470. } else {
  471. $info_list[$key]['enter'] = "";
  472. }
  473. if ($value['printing'] != 0) {
  474. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  475. } else {
  476. $info_list[$key]['printing'] = "";
  477. }
  478. }
  479. $total = $this->whlabel->find_count($where);
  480. $pagenum = ceil($total / $perpage);
  481. $over = $total - ($start + $perpage);
  482. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  483. echo json_encode($rows);
  484. exit;
  485. }
  486. $this->_Template('whlabel_existence', $this->data);
  487. }
  488. //进销存浏览
  489. public function _typedy($arg_array)
  490. {
  491. $prc = array();
  492. $purchase = $this->purchase->find_all();
  493. foreach ($purchase as $k => $v) {
  494. $prc[$v['id']] = $v['title'];
  495. }
  496. $post = $this->input->post(NULL, TRUE);
  497. if (isset($post['page'])) {
  498. $page = $this->input->post('page', true);
  499. $perpage = $this->input->post('perpage', true);
  500. $category = $this->input->post('category', true);
  501. $size = $this->input->post('size', true);
  502. $grade = $this->input->post('grade', true);
  503. $color = $this->input->post('color', true);
  504. $lowe = $this->input->post('lowe', true);
  505. $sku = $this->input->post('sku');
  506. $title = $this->input->post('title');
  507. $warehouse = $this->input->post('warehouse', true);
  508. $usa = $this->input->post('usa', true);
  509. $purchase = $this->input->post('purchase', true);
  510. $lacetype = $this->input->post('lacetype', true);
  511. $haircap = $this->input->post('haircap', true);
  512. $density = $this->input->post('density', true);
  513. $details = $this->input->post('details', true);
  514. $state = $this->input->post('state', true);
  515. $lacecolor = $this->input->post('lacecolor', true);
  516. $hairnumber = $this->input->post('hairnumber', true);
  517. $cklx = $this->input->post('cklx', true);
  518. $ktime = $this->input->post('ktime', true);
  519. $jtime = $this->input->post('jtime', true);
  520. $sm = $this->input->post('sm', true);
  521. $cpbz = $this->input->post('cpbz', true);
  522. $type = $this->input->post('type', true);
  523. $ktime = strtotime($ktime);
  524. $jtime = strtotime($jtime);
  525. $where = "1=1";
  526. $gj = "";
  527. $ck = "";
  528. if ($usa) {
  529. if (!$warehouse) {
  530. $where .= " and (warehouse = '5' or warehouse = '8')";
  531. }
  532. }
  533. if ($warehouse) {
  534. $where .= " and warehouse = '$warehouse'";
  535. }
  536. if ($details) {
  537. $where .= " and details = '$details'";
  538. }
  539. if ($purchase) {
  540. $where .= " and purchase = '$purchase'";
  541. }
  542. if (isset($state)) {
  543. if($state >-1){
  544. $where .= " and state = '$state'";
  545. }
  546. }
  547. if ($lacetype) {
  548. $where .= " and features like '%-$lacetype-%'";
  549. }
  550. if ($category) {
  551. $where .= " and features like '%-$category-%'";
  552. }
  553. if ($size) {
  554. $where .= " and features like '%-$size-%'";
  555. }
  556. if ($grade) {
  557. $where .= " and features like '%-$grade-%'";
  558. }
  559. if ($color) {
  560. $where .= " and features like '%-$color-%'";
  561. }
  562. if ($lowe) {
  563. $where .= " and features like '%-$lowe-%'";
  564. }
  565. if ($haircap) {
  566. $where .= " and features like '%-$haircap-%'";
  567. }
  568. if ($density) {
  569. $where .= " and features like '%-$density-%'";
  570. }
  571. if ($lacecolor) {
  572. $where .= " and features like '%-$lacecolor-%'";
  573. }
  574. if($sm){
  575. $where .= " and sm like '%".$sm."%'";
  576. }
  577. if($cpbz){
  578. $where .= " and cpbz like '%".$cpbz."%'";
  579. }
  580. if($type){
  581. $where .= " and type = ".$type."";
  582. }
  583. if (!empty($hairnumber)) {
  584. $where .= " and features like '%-128-%' ";
  585. if ($hairnumber < 0) {
  586. $class_list = $this->typeclass->find_all('classid = 43');
  587. foreach ($class_list as $v) {
  588. $where .= " and features not like '%-" . $v['id'] . "-%'";
  589. }
  590. } else {
  591. $where .= " and features like '%-$hairnumber-%'";
  592. }
  593. }
  594. $where_add = '';
  595. if ($cklx) {
  596. $shop = $this->shop->read($cklx);
  597. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  598. }
  599. if ($ktime && $jtime) {
  600. $gj = " and enter > '$ktime' and enter < '$jtime'";
  601. $ck = " and outk > '$ktime' and outk < '$jtime'";
  602. }
  603. //数据排序
  604. $order_str = "id desc";
  605. if (empty($page)) {
  606. $start = 0;
  607. $perpage = 1;
  608. } else {
  609. $start = ($page - 1) * $perpage;
  610. }
  611. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  612. if ($sku) {
  613. $sku = trim($sku, ' ');
  614. $sku = trim($sku, ' ');
  615. $where .= " and sku like '%$sku%'";
  616. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  617. } else if ($title) {
  618. $title = trim($title, ' ');
  619. $title = trim($title, ' ');
  620. $where .= " and title like '%$title%'";
  621. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  622. } else {
  623. //$where .= " and time > '$ktime' and time < '$jtime'";
  624. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  625. }
  626. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  627. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  628. foreach ($info_list as $k => $v) {
  629. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  630. unset($info_list[$k]['pm']);
  631. unset($info_list[$k]['jm']);
  632. unset($info_list[$k]['bm']);
  633. }
  634. //取得信息列表
  635. $rows = array();
  636. $list = array();
  637. foreach ($info_list as $key => $value) {
  638. $warehouse = $this->warehouse->read($value['warehouse']);
  639. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  640. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  641. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  642. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  643. $info_list[$key]['label'] = $value['sm'];
  644. $number = $value['number'];
  645. $ftime = time() - 15 * 24 * 3600;
  646. $info_list[$key]['warehouse'] = $warehouse['title'];
  647. $info_list[$key]['features'] = count($c);
  648. $z = count($z); //查看订单号
  649. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  650. $ztdata = '';
  651. if (count($zt) > 0) {
  652. foreach ($zt as $vv) {
  653. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  654. }
  655. }
  656. $info_list[$key]['number'] = $ztdata;
  657. $info_list[$key]['sm'] = $z;
  658. $details = array();
  659. $cpid = array();
  660. foreach ($c as $k => $v) {
  661. $details[$v['details']] = $v['details'];
  662. if ($v['cpid'] != 0) {
  663. $cpid[$v['cpid']] = $v['cpid'];
  664. }
  665. }
  666. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  667. if ($value['shop'] != '') {
  668. $shop = explode(',', trim($value['shop'], ','));
  669. $shop = $this->shop->read($shop[0]);
  670. $info_list[$key]['shop'] = $shop['shopname'];
  671. }
  672. }
  673. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  674. $pagenum = ceil($total / $perpage);
  675. $over = $total - ($start + $perpage);
  676. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  677. echo json_encode($rows);
  678. exit;
  679. }
  680. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  681. $this->_Template('whlabel_typedy', $this->data);
  682. }
  683. //进销存浏览
  684. public function _typedy_ck($arg_array)
  685. {
  686. $prc = array();
  687. $purchase = $this->purchase->find_all();
  688. foreach ($purchase as $k => $v) {
  689. $prc[$v['id']] = $v['title'];
  690. }
  691. $post = $this->input->post(NULL, TRUE);
  692. if (isset($post['page'])) {
  693. $page = $this->input->post('page', true);
  694. $perpage = $this->input->post('perpage', true);
  695. $category = $this->input->post('category', true);
  696. $size = $this->input->post('size', true);
  697. $grade = $this->input->post('grade', true);
  698. $color = $this->input->post('color', true);
  699. $lowe = $this->input->post('lowe', true);
  700. $sku = $this->input->post('sku');
  701. $title = $this->input->post('title');
  702. $warehouse = $this->input->post('warehouse', true);
  703. $usa = $this->input->post('usa', true);
  704. $purchase = $this->input->post('purchase', true);
  705. $lacetype = $this->input->post('lacetype', true);
  706. $haircap = $this->input->post('haircap', true);
  707. $density = $this->input->post('density', true);
  708. $details = $this->input->post('details', true);
  709. $state = $this->input->post('state', true);
  710. $lacecolor = $this->input->post('lacecolor', true);
  711. $cklx = $this->input->post('cklx', true);
  712. $ktime = $this->input->post('ktime', true);
  713. $jtime = $this->input->post('jtime', true);
  714. $ktime = strtotime($ktime);
  715. $jtime = strtotime($jtime);
  716. $where = "1=1";
  717. $gj = "";
  718. $ck = "";
  719. if ($lacetype) {
  720. $where .= " and features like '%-$lacetype-%'";
  721. }
  722. if ($category) {
  723. $where .= " and features like '%-$category-%'";
  724. }
  725. if ($size) {
  726. $where .= " and features like '%-$size-%'";
  727. }
  728. if ($grade) {
  729. $where .= " and features like '%-$grade-%'";
  730. }
  731. if ($color) {
  732. $where .= " and features like '%-$color-%'";
  733. }
  734. if ($lowe) {
  735. $where .= " and features like '%-$lowe-%'";
  736. }
  737. if ($haircap) {
  738. $where .= " and features like '%-$haircap-%'";
  739. }
  740. if ($density) {
  741. $where .= " and features like '%-$density-%'";
  742. }
  743. if ($lacecolor) {
  744. $where .= " and features like '%-$lacecolor-%'";
  745. }
  746. if ($usa) {
  747. if (!$warehouse) {
  748. $where .= " and (warehouse = '5' or warehouse = '8')";
  749. }
  750. }
  751. if ($warehouse) {
  752. $where .= " and warehouse = '$warehouse'";
  753. }
  754. if ($details) {
  755. $where .= " and details = '$details'";
  756. }
  757. if ($purchase) {
  758. $where .= " and purchase = '$purchase'";
  759. }
  760. if ($state) {
  761. $where .= " and state = '$state'";
  762. }
  763. $where_add = '';
  764. if ($cklx) {
  765. $shop = $this->shop->read($cklx);
  766. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  767. }
  768. if ($ktime && $jtime) {
  769. $gj = " and enter > '$ktime' and enter < '$jtime'";
  770. $ck = " and outk > '$ktime' and outk < '$jtime'";
  771. }
  772. //数据排序
  773. $order_str = "id desc";
  774. if (empty($page)) {
  775. $start = 0;
  776. $perpage = 1;
  777. } else {
  778. $start = ($page - 1) * $perpage;
  779. }
  780. if ($sku) {
  781. $sku = trim($sku, ' ');
  782. $sku = trim($sku, ' ');
  783. $where .= " and sku like '%$sku%'";
  784. $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);
  785. } else if ($title) {
  786. $title = trim($title, ' ');
  787. $title = trim($title, ' ');
  788. $where .= " and title like '%$title%'";
  789. $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);
  790. } else {
  791. //$where .= " and time > '$ktime' and time < '$jtime'";
  792. $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);
  793. }
  794. //取得信息列表
  795. $rows = array();
  796. $list = array();
  797. foreach ($info_list as $key => $value) {
  798. $warehouse = $this->warehouse->read($value['warehouse']);
  799. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  800. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  801. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  802. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  803. $ftime = time() - 15 * 24 * 3600;
  804. $info_list[$key]['warehouse'] = $warehouse['title'];
  805. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  806. //$z = count($z);//查看订单号
  807. //$info_list[$key]['zd'] = $z;
  808. $details = array();
  809. $cpid = array();
  810. foreach ($c as $k => $v) {
  811. $details[$v['details']] = $v['details'];
  812. if ($v['cpid'] != 0) {
  813. $cpid[$v['cpid']] = $v['cpid'];
  814. }
  815. }
  816. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  817. if ($value['shop'] != '') {
  818. $shop = explode(',', trim($value['shop'], ','));
  819. $shop = $this->shop->read($shop[0]);
  820. $info_list[$key]['shop'] = $shop['shopname'];
  821. }
  822. }
  823. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  824. $pagenum = ceil($total / $perpage);
  825. $over = $total - ($start + $perpage);
  826. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  827. echo json_encode($rows);
  828. exit;
  829. }
  830. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  831. $this->_Template('whlabel_typedy_ck', $this->data);
  832. }
  833. public function _typeck($arg_array)
  834. {
  835. $prc = array();
  836. $purchase = $this->purchase->find_all();
  837. foreach ($purchase as $k => $v) {
  838. $prc[$v['id']] = $v['title'];
  839. }
  840. $post = $this->input->post(NULL, TRUE);
  841. if (isset($post['page'])) {
  842. $page = $this->input->post('page', true);
  843. $perpage = $this->input->post('perpage', true);
  844. $category = $this->input->post('category', true);
  845. $size = $this->input->post('size', true);
  846. $grade = $this->input->post('grade', true);
  847. $color = $this->input->post('color', true);
  848. $lacecolor = $this->input->post('lacecolor', true);
  849. $lowe = $this->input->post('lowe', true);
  850. $sku = $this->input->post('sku');
  851. $title = $this->input->post('title');
  852. $warehouse = 13;
  853. $usa = $this->input->post('usa', true);
  854. $purchase = $this->input->post('purchase', true);
  855. $lacetype = $this->input->post('lacetype', true);
  856. $haircap = $this->input->post('haircap', true);
  857. $density = $this->input->post('density', true);
  858. $details = $this->input->post('details', true);
  859. $state = $this->input->post('state', true);
  860. $ktime = $this->input->post('ktime', true);
  861. $jtime = $this->input->post('jtime', true);
  862. $ktime = strtotime($ktime);
  863. $jtime = strtotime($jtime);
  864. $where = "1=1";
  865. $gj = "";
  866. $ck = "";
  867. if ($lacetype) {
  868. $where .= " and features like '%-$lacetype-%'";
  869. }
  870. if ($category) {
  871. $where .= " and features like '%-$category-%'";
  872. }
  873. if ($size) {
  874. $where .= " and features like '%-$size-%'";
  875. }
  876. if ($grade) {
  877. $where .= " and features like '%-$grade-%'";
  878. }
  879. if ($color) {
  880. $where .= " and features like '%-$color-%'";
  881. }
  882. if ($lacecolor) {
  883. $where .= " and features like '%-$lacecolor-%'";
  884. }
  885. if ($lowe) {
  886. $where .= " and features like '%-$lowe-%'";
  887. }
  888. if ($haircap) {
  889. $where .= " and features like '%-$haircap-%'";
  890. }
  891. if ($density) {
  892. $where .= " and features like '%-$density-%'";
  893. }
  894. if ($warehouse) {
  895. $where .= " and warehouse = '$warehouse'";
  896. }
  897. if ($details) {
  898. $where .= " and details = '$details'";
  899. }
  900. if ($purchase) {
  901. $where .= " and purchase = '$purchase'";
  902. }
  903. if ($state) {
  904. $where .= " and state = '$state'";
  905. }
  906. if ($ktime && $jtime) {
  907. $gj = " and enter > '$ktime' and enter < '$jtime'";
  908. $ck = " and outk > '$ktime' and outk < '$jtime'";
  909. }
  910. //数据排序
  911. $order_str = "id desc";
  912. if (empty($page)) {
  913. $start = 0;
  914. $perpage = 1;
  915. } else {
  916. $start = ($page - 1) * $perpage;
  917. }
  918. if ($sku) {
  919. $sku = trim($sku, ' ');
  920. $sku = trim($sku, ' ');
  921. $where .= " and sku like '%$sku%'";
  922. } else if ($title) {
  923. $title = trim($title, ' ');
  924. $title = trim($title, ' ');
  925. $where .= " and title like '%$title%'";
  926. }
  927. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  928. //取得信息列表
  929. $t = array();
  930. $typeclass = $this->typeclass->find_all();
  931. foreach ($typeclass as $v) {
  932. $t[$v['id']] = $v;
  933. }
  934. $rows = array();
  935. $list = array();
  936. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  937. foreach ($info_list as $key => $value) {
  938. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  939. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  940. $warehouse = $this->warehouse->read($value['warehouse']);
  941. $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');
  942. $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'] . '"');
  943. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  944. $number = $value['number'];
  945. $ftime = time() - 15 * 24 * 3600;
  946. $z = count($z); //查看订单号
  947. $info_list[$key]['warehouse'] = $warehouse['title'];
  948. $info_list[$key]['features'] = count($c);
  949. $info_list[$key]['number'] = $z;
  950. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  951. $details = array();
  952. $cpid = array();
  953. foreach ($c as $k => $v) {
  954. $details[$v['details']] = $v['details'];
  955. if ($v['cpid'] != 0) {
  956. $cpid[$v['cpid']] = $v['cpid'];
  957. }
  958. }
  959. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  960. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  961. unset($info_list[$key]['pm']);
  962. unset($info_list[$key]['jm']);
  963. unset($info_list[$key]['bm']);
  964. }
  965. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  966. $pagenum = ceil($total / $perpage);
  967. $over = $total - ($start + $perpage);
  968. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  969. echo json_encode($rows);
  970. exit;
  971. }
  972. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  973. $this->_Template('whlabel_typeck', $this->data);
  974. }
  975. //进销存导出
  976. public function _whlabeckdc()
  977. {
  978. $prc = array();
  979. $purchase = $this->purchase->find_all();
  980. foreach ($purchase as $k => $v) {
  981. $prc[$v['id']] = $v['title'];
  982. }
  983. if (isset($_GET['excel'])) {
  984. $where = "sku != 'Preset'";
  985. //数据排序
  986. $order_str = "id desc";
  987. if (empty($page)) {
  988. $start = 0;
  989. $perpage = 1;
  990. } else {
  991. $start = ($page - 1) * $perpage;
  992. }
  993. $category = $this->input->get('category', true);
  994. $color = $this->input->get('color', true);
  995. $lowe = $this->input->get('lowe', true);
  996. $lacetype = $this->input->get('lacetype', true);
  997. $size = $this->input->get('size', true);
  998. $density = $this->input->get('density', true);
  999. $haircap = $this->input->get('haircap', true);
  1000. $sku = $this->input->get('sku', true);
  1001. $details = $this->input->get('details', true);
  1002. $warehouse = 13;
  1003. $excelid = $this->input->get('sid', true);
  1004. if ($category) {
  1005. $where .= " and features like '%-$category-%'";
  1006. }
  1007. if ($color) {
  1008. $where .= " and features like '%-$color-%'";
  1009. }
  1010. if ($lowe) {
  1011. $where .= " and features like '%-$lowe-%'";
  1012. }
  1013. if ($lacetype) {
  1014. $where .= " and features like '%-$lacetype-%'";
  1015. }
  1016. if ($size) {
  1017. $where .= " and features like '%-$size-%'";
  1018. }
  1019. if ($density) {
  1020. $where .= " and features like '%-$density-%'";
  1021. }
  1022. if ($haircap) {
  1023. $where .= " and features like '%-$haircap-%'";
  1024. }
  1025. if ($warehouse) {
  1026. $where .= " and warehouse = '$warehouse'";
  1027. }
  1028. if ($sku) {
  1029. $where .= " and sku like '%$sku%'";
  1030. }
  1031. if ($details) {
  1032. $where .= " and details = '$details'";
  1033. }
  1034. $xzid = '';
  1035. if ($excelid) {
  1036. $excelid = explode(',', trim($excelid, ','));
  1037. foreach ($excelid as $key => $value) {
  1038. $xzid .= " id = " . $value . " or";
  1039. }
  1040. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1041. }
  1042. //取得信息列表
  1043. /**
  1044. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1045. $rows = array();$list = array();
  1046. foreach ($info_list as $key=>$value)
  1047. {
  1048. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1049. }
  1050. **/
  1051. $wh = array();
  1052. $w = $this->warehouse->find_all('1=1', 'id,title');
  1053. foreach ($w as $v) {
  1054. $wh[$v['id']] = $v['title'];
  1055. }
  1056. $tc = array();
  1057. $tcdata = array();
  1058. $list = array();
  1059. $classid = $this->classid->sku();
  1060. $tcall = $this->typeclass->find_all();
  1061. $typeclass = array();
  1062. foreach ($tcall as $v)
  1063. {
  1064. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1065. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1066. }
  1067. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1068. foreach ($rows as $key => $value) {
  1069. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1070. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1071. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1072. $rows[$key]['cpbz'] = $u9_info['bm'];
  1073. $rows[$key]['cs'] = $u9_info['jm'];
  1074. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1075. $details = array();
  1076. $cpid = array();
  1077. $cpbz = array();
  1078. $c = 0;
  1079. $g = 0;
  1080. $x = 0;
  1081. $t = 0;
  1082. $s = 0;
  1083. $q = 0;
  1084. foreach ($sd as $k => $v) {
  1085. if ($v['state'] == 0) {
  1086. $c++;
  1087. }
  1088. if ($v['state'] != 9) {
  1089. $g++;
  1090. }
  1091. if ($v['state'] == 1) {
  1092. $x++;
  1093. }
  1094. if ($v['state'] == 2) {
  1095. $t++;
  1096. }
  1097. if ($v['state'] == 8) {
  1098. $s++;
  1099. }
  1100. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1101. $q++;
  1102. }
  1103. $details[$v['details']] = $v['details'];
  1104. if ($v['cpid'] != 0) {
  1105. $cpid[$v['cpid']] = $v['cpid'];
  1106. }
  1107. if ($v['cpbz'] != '') {
  1108. $cpbz[$v['cpbz']] = $v['cpbz'];
  1109. }
  1110. }
  1111. $rows[$key]['details'] = implode("、", $details);
  1112. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1113. $number = $value['number'];
  1114. $ftime = time() - 15 * 24 * 3600;
  1115. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1116. $rows[$key]['number'] = $g;
  1117. $rows[$key]['features'] = $c;
  1118. $rows[$key]['x'] = $x;
  1119. $rows[$key]['t'] = $t;
  1120. $rows[$key]['s'] = $s;
  1121. $rows[$key]['q'] = $q;
  1122. $rows[$key]['wzsl'] = count($details);
  1123. }
  1124. $title = "进销存统计表" . date('Y-m-d', time());
  1125. $titlename = "<table border=1>
  1126. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1127. <tr align='center'>
  1128. <td>仓库</td>
  1129. <td>供应商</td>
  1130. <td>位置</td>
  1131. <td>库存编码</td>
  1132. <td>SKU</td>
  1133. <td>用友编码</td>
  1134. <td>用友料号</td>
  1135. <td>产品英文名</td>
  1136. <td>产品中文名</td>
  1137. <td>入库总量</td>
  1138. <td>库存数量</td>
  1139. <td>销售数量</td>
  1140. <td>退货数量</td>
  1141. <td>删除数量</td>
  1142. <td>其它操作</td>
  1143. <td>位置数量</td>
  1144. </tr>
  1145. </table>";
  1146. $filename = $title . ".xls";
  1147. $tail = "";
  1148. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1149. }
  1150. }
  1151. public function _type()
  1152. {
  1153. $vip = 0;
  1154. if (isset($_SESSION['api'])) {
  1155. $user = $this->user->get_api($_SESSION['api']);
  1156. $fgshop = "";
  1157. $sid = "";
  1158. $usersp = explode('|', trim($user['shop'], '|'));
  1159. foreach ($usersp as $value) {
  1160. $fgshop .= " shop = " . $value . " or";
  1161. $sid .= " id = " . $value . " or";
  1162. }
  1163. if ($user['vip'] == 1) {
  1164. $vip = 1;
  1165. }
  1166. } else {
  1167. header('Location: /');
  1168. exit;
  1169. }
  1170. $prc = array();
  1171. $purchase = $this->purchase->find_all();
  1172. foreach ($purchase as $k => $v) {
  1173. $prc[$v['id']] = $v['title'];
  1174. }
  1175. $company = array();
  1176. $ct = $this->company->find_all();
  1177. foreach ($ct as $k => $v) {
  1178. $company[$v['id']] = $v['title'];
  1179. }
  1180. $sp = array();
  1181. $s = $this->shop->find_all('1=1', 'id,shopname');
  1182. foreach ($s as $v) {
  1183. $sp[$v['id']] = $v['shopname'];
  1184. }
  1185. $wh = array();
  1186. $w = $this->warehouse->find_all('1=1', 'id,title');
  1187. foreach ($w as $v) {
  1188. $wh[$v['id']] = $v['title'];
  1189. }
  1190. $post = $this->input->post(NULL, TRUE);
  1191. if (isset($post['page'])) {
  1192. $page = $this->input->post('page', true);
  1193. $perpage = $this->input->post('perpage', true);
  1194. $category = $this->input->post('category', true);
  1195. $size = $this->input->post('size', true);
  1196. $grade = $this->input->post('grade', true);
  1197. $color = $this->input->post('color', true);
  1198. $lowe = $this->input->post('lowe', true);
  1199. $sku = $this->input->post('sku');
  1200. $title = $this->input->post('title');
  1201. $warehouse = $this->input->post('warehouse', true);
  1202. $usa = $this->input->post('usa', true);
  1203. $purchase = $this->input->post('purchase', true);
  1204. $lacetype = $this->input->post('lacetype', true);
  1205. $haircap = $this->input->post('haircap', true);
  1206. $density = $this->input->post('density', true);
  1207. $details = $this->input->post('details', true);
  1208. $state = $this->input->post('state', true);
  1209. $shop = $this->input->post('shop', true);
  1210. $lacecolor = $this->input->post('lacecolor', true);
  1211. $hairnumber = $this->input->post('hairnumber', true);
  1212. $type = $this->input->post('type', true);
  1213. $ktime = $this->input->post('ktime', true);
  1214. $jtime = $this->input->post('jtime', true);
  1215. $ktime = strtotime($ktime);
  1216. $jtime = strtotime($jtime);
  1217. $cpbz = $this->input->post('cpbz', true);
  1218. $sm = $this->input->post('sm', true);
  1219. $where = "1=1";
  1220. $gj = "";
  1221. $ck = "";
  1222. if ($usa) {
  1223. if (!$warehouse) {
  1224. $where .= " and (warehouse = '5' or warehouse = '8')";
  1225. }
  1226. }
  1227. if ($warehouse) {
  1228. $where .= " and warehouse = '$warehouse'";
  1229. }
  1230. if ($details) {
  1231. $where .= " and details = '$details'";
  1232. }
  1233. if ($purchase) {
  1234. $where .= " and purchase = '$purchase'";
  1235. }
  1236. if ($state) {
  1237. $where .= " and state = '$state'";
  1238. }
  1239. if ($shop) {
  1240. $where .= " and shop like '%$shop%'";
  1241. }
  1242. if ($type) {
  1243. $where .= " and type = '$type'";
  1244. }
  1245. if ($ktime && $jtime) {
  1246. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1247. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1248. }
  1249. if ($cpbz) {
  1250. $where .= " and cpbz like '%$cpbz%' ";
  1251. }
  1252. if ($sm) {
  1253. $where .= " and sm like '%$sm%' ";
  1254. }
  1255. if ($lacecolor) {
  1256. $where .= " and features like '%-$lacecolor-%'";
  1257. }
  1258. if ($lacetype) {
  1259. $where .= " and features like '%-$lacetype-%'";
  1260. }
  1261. if ($category) {
  1262. $where .= " and features like '%-$category-%'";
  1263. }
  1264. if ($size) {
  1265. $where .= " and features like '%-$size-%'";
  1266. }
  1267. if ($grade) {
  1268. $where .= " and features like '%-$grade-%'";
  1269. }
  1270. if ($color) {
  1271. $where .= " and features like '%-$color-%'";
  1272. }
  1273. if ($lowe) {
  1274. $where .= " and features like '%-$lowe-%'";
  1275. }
  1276. if ($haircap) {
  1277. $where .= " and features like '%-$haircap-%'";
  1278. }
  1279. if ($density) {
  1280. $where .= " and features like '%-$density-%'";
  1281. }
  1282. if (!empty($hairnumber)) {
  1283. $where .= " and features like '%-128-%' ";
  1284. if ($hairnumber < 0) {
  1285. $class_list = $this->typeclass->find_all('classid = 43');
  1286. foreach ($class_list as $v) {
  1287. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1288. }
  1289. } else {
  1290. $where .= " and features like '%-$hairnumber-%'";
  1291. }
  1292. }
  1293. //数据排序
  1294. $order_str = "id desc";
  1295. if (empty($page)) {
  1296. $start = 0;
  1297. $perpage = 1;
  1298. } else {
  1299. $start = ($page - 1) * $perpage;
  1300. }
  1301. $fjnr = '';
  1302. if ($sku) {
  1303. $sku = trim($sku, ' ');
  1304. $sku = trim($sku, ' ');
  1305. $fjnr .= " and sku like '%$sku%'";
  1306. }
  1307. if ($title) {
  1308. $title = trim($title, ' ');
  1309. $title = trim($title, ' ');
  1310. $fjnr .= " and title like '%$title%'";
  1311. }
  1312. $wt = array();
  1313. $whlabel_type = $this->whlabel_type->find_all();
  1314. foreach ($whlabel_type as $v) {
  1315. $wt[$v['id']] = $v['title'];
  1316. }
  1317. //$where .= " and time > '$ktime' and time < '$jtime'";
  1318. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1319. //取得信息列表
  1320. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1321. $rows = array();
  1322. $list = array();
  1323. foreach ($info_list as $key => $value) {
  1324. if (isset($wt[$value['type']])) {
  1325. $info_list[$key]['type'] = $wt[$value['type']];
  1326. } else {
  1327. $info_list[$key]['type'] = '未设置';
  1328. }
  1329. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1330. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1331. $ztdata = '';
  1332. if (count($zt) > 0) {
  1333. foreach ($zt as $vv) {
  1334. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1335. }
  1336. }
  1337. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1338. $cdata = array_filter($qbdata, function ($item) {
  1339. return $item['state'] < 1;
  1340. });
  1341. $c = array_sum(array_column($cdata, 'jnum'));
  1342. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1343. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1344. });
  1345. $g = array_sum(array_column($gdata, 'jnum'));
  1346. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1347. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1348. });
  1349. $x = array_sum(array_column($xdata, 'jnum'));
  1350. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1351. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1352. });
  1353. $t = array_sum(array_column($tdata, 'jnum'));
  1354. // $zdata = array_filter($qbdata, function ($item) {
  1355. // return $item['zd'] != "" && $item['state'] < 1;
  1356. // });
  1357. // $z = array_sum(array_column($zdata, 'jnum'));
  1358. $zdata = array_filter($qbdata, function ($item) {
  1359. return $item['zd'] != "" && $item['state'] < 1;
  1360. });
  1361. $z = array_sum(array_column($zdata, 'jnum'));
  1362. //$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');
  1363. //$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'].'"');
  1364. //$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'].'"');
  1365. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1366. //$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'].'"');
  1367. $details = array();
  1368. $cpid = array();
  1369. $od = array();
  1370. $odid = '';
  1371. $companytitle = '';
  1372. $shop_list = [];
  1373. foreach ($qbdata as $v) {
  1374. if ($v['zd'] != "" && $v['state'] < 1) {
  1375. if (!isset($od[$v['zd']])) {
  1376. $od[$v['zd']] = 1; //所有数据sku
  1377. } else {
  1378. $od[$v['zd']] = $od[$v['zd']] + 1;
  1379. }
  1380. }
  1381. if ($v['state'] < 1) {
  1382. $details[$v['details']] = $v['details'];
  1383. if ($v['cpid'] != 0) {
  1384. $cpid[$v['cpid']] = $v['cpid'];
  1385. }
  1386. }
  1387. if($v['state'] == 0){
  1388. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1389. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1390. }
  1391. if ($v['shop'] != '') {
  1392. $shop = explode(',', trim($v['shop'], ','));
  1393. foreach ($shop as $vv) {
  1394. if (!in_array($vv, $shop_list)) {
  1395. $shop_list[] = $vv;
  1396. }
  1397. }
  1398. }
  1399. }
  1400. }
  1401. foreach ($od as $k => $vv) {
  1402. $odid .= $k . '数量' . $vv;
  1403. }
  1404. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1405. $info_list[$key]['label'] = $value['sm'];
  1406. $number = $value['number'];
  1407. $ftime = time() - 15 * 24 * 3600;
  1408. $z = $z . '(' . $odid . ')'; //查看订单号
  1409. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1410. $info_list[$key]['features'] = $c;
  1411. $info_list[$key]['number'] = $ztdata;
  1412. $info_list[$key]['sm'] = $g;
  1413. $info_list[$key]['x'] = $x;
  1414. $info_list[$key]['t'] = $t;
  1415. $info_list[$key]['z'] = $z;
  1416. /**
  1417. foreach ($cdata as $k=>$v)
  1418. {
  1419. $details[$v['details']] = $v['details'];
  1420. if($v['cpid'] != 0)
  1421. {
  1422. $cpid[$v['cpid']] = $v['cpid'];
  1423. }
  1424. }
  1425. **/
  1426. $info_list[$key]['shop'] = '';
  1427. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1428. // if ($value['shop'] != '') {
  1429. // $shop = explode(',', trim($value['shop'], ','));
  1430. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1431. // }
  1432. $shop_list = array_unique($shop_list);
  1433. $shop_str = '';
  1434. foreach ($shop_list as $v) {
  1435. if(isset($sp[$v])){
  1436. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1437. }
  1438. }
  1439. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1440. /**
  1441. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1442. if(isset($companytitle[0]))
  1443. {
  1444. foreach ($companytitle as $k=>$v)
  1445. {
  1446. if($v['companytitle'] != '')
  1447. {
  1448. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1449. }
  1450. }
  1451. }
  1452. **/
  1453. }
  1454. $final_all_list = [];
  1455. foreach ($info_list as $k => $v) {
  1456. $final_all_list[] = [
  1457. 'id' => $v['id'],
  1458. "warehouse" => $v["warehouse"],
  1459. "purchase" => $v["purchase"],
  1460. "sku" => $v["sku"],
  1461. "title" => $v["title"] . "<br/>" . $v["pm"],
  1462. "details" => $v["details"],
  1463. "shop" => $v["shop"],
  1464. "cpbz" => $v["cpbz"],
  1465. 'label' => $v['label'],
  1466. "type" => $v["type"],
  1467. "features" => $v["features"],
  1468. "number" => $v["number"],
  1469. "sm" => $v["sm"],
  1470. "x" => $v["x"],
  1471. "t" => $v["t"],
  1472. "z" => $v["z"]
  1473. ];
  1474. }
  1475. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1476. $pagenum = ceil($total / $perpage);
  1477. $over = $total - ($start + $perpage);
  1478. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1479. echo json_encode($rows);
  1480. exit;
  1481. }
  1482. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1483. $this->data['shop'] = $wlshop;
  1484. $this->data['vip'] = $vip;
  1485. $this->_Template('whlabel_type', $this->data);
  1486. }
  1487. //美仓进销存浏览
  1488. public function _usatype()
  1489. {
  1490. if (isset($_SESSION['api'])) {
  1491. $user = $this->user->get_api($_SESSION['api']);
  1492. $usp = $user;
  1493. $fgshop = "";
  1494. $sid = "";
  1495. $wid = "";
  1496. $wtype = "";
  1497. $userwh = explode('|', trim($user['warehouse'], '|'));
  1498. foreach ($userwh as $value) {
  1499. $wid .= " id = " . $value . " or";
  1500. $wtype .= " type = " . $value . " or";
  1501. }
  1502. }
  1503. $prc = array();
  1504. $purchase = $this->purchase->find_all();
  1505. foreach ($purchase as $k => $v) {
  1506. $prc[$v['id']] = $v['title'];
  1507. }
  1508. $post = $this->input->post(NULL, TRUE);
  1509. if (isset($post['page'])) {
  1510. $page = $this->input->post('page', true);
  1511. $perpage = $this->input->post('perpage', true);
  1512. $category = $this->input->post('category', true);
  1513. $size = $this->input->post('size', true);
  1514. $grade = $this->input->post('grade', true);
  1515. $color = $this->input->post('color', true);
  1516. $lowe = $this->input->post('lowe', true);
  1517. $sku = $this->input->post('sku');
  1518. $title = $this->input->post('title');
  1519. $warehouse = $this->input->post('warehouse', true);
  1520. $usa = $this->input->post('usa', true);
  1521. $purchase = $this->input->post('purchase', true);
  1522. $lacetype = $this->input->post('lacetype', true);
  1523. $haircap = $this->input->post('haircap', true);
  1524. $density = $this->input->post('density', true);
  1525. $details = $this->input->post('details', true);
  1526. $state = $this->input->post('state', true);
  1527. $lacecolor = $this->input->post('lacecolor', true);
  1528. $cklx = $this->input->post('cklx', true);
  1529. $ktime = $this->input->post('ktime', true);
  1530. $jtime = $this->input->post('jtime', true);
  1531. $ktime = strtotime($ktime);
  1532. $jtime = strtotime($jtime);
  1533. $where = "1=1";
  1534. $gj = "";
  1535. $ck = "";
  1536. if ($lacetype) {
  1537. $where .= " and features like '%-$lacetype-%'";
  1538. }
  1539. if ($category) {
  1540. $where .= " and features like '%-$category-%'";
  1541. }
  1542. if ($size) {
  1543. $where .= " and features like '%-$size-%'";
  1544. }
  1545. if ($grade) {
  1546. $where .= " and features like '%-$grade-%'";
  1547. }
  1548. if ($color) {
  1549. $where .= " and features like '%-$color-%'";
  1550. }
  1551. if ($lowe) {
  1552. $where .= " and features like '%-$lowe-%'";
  1553. }
  1554. if ($haircap) {
  1555. $where .= " and features like '%-$haircap-%'";
  1556. }
  1557. if ($density) {
  1558. $where .= " and features like '%-$density-%'";
  1559. }
  1560. if ($lacecolor) {
  1561. $where .= " and features like '%-$lacecolor-%'";
  1562. }
  1563. if ($usa) {
  1564. if (!$warehouse) {
  1565. $where .= " and (warehouse = '5' or warehouse = '8')";
  1566. }
  1567. }
  1568. if ($warehouse) {
  1569. $where .= " and warehouse = '$warehouse'";
  1570. }
  1571. if ($details) {
  1572. $where .= " and details = '$details'";
  1573. }
  1574. if ($purchase) {
  1575. $where .= " and purchase = '$purchase'";
  1576. }
  1577. if ($state) {
  1578. $where .= " and state = '$state'";
  1579. }
  1580. $where_add = '';
  1581. if ($cklx) {
  1582. $shop = $this->shop->read($cklx);
  1583. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1584. }
  1585. if ($ktime && $jtime) {
  1586. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1587. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1588. }
  1589. //数据排序
  1590. $order_str = "id desc";
  1591. if (empty($page)) {
  1592. $start = 0;
  1593. $perpage = 1;
  1594. } else {
  1595. $start = ($page - 1) * $perpage;
  1596. }
  1597. if ($sku) {
  1598. $sku = trim($sku, ' ');
  1599. $sku = trim($sku, ' ');
  1600. $where .= " and sku like '%$sku%'";
  1601. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1602. } else if ($title) {
  1603. $title = trim($title, ' ');
  1604. $title = trim($title, ' ');
  1605. $where .= " and title like '%$title%'";
  1606. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1607. } else {
  1608. //$where .= " and time > '$ktime' and time < '$jtime'";
  1609. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1610. }
  1611. //取得信息列表
  1612. $rows = array();
  1613. $list = array();
  1614. foreach ($info_list as $key => $value) {
  1615. $warehouse = $this->warehouse->read($value['warehouse']);
  1616. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1617. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1618. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1619. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1620. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1621. $od = array();
  1622. $odid = '';
  1623. foreach ($z as $v) {
  1624. if (!isset($od[$v['zd']])) {
  1625. $od[$v['zd']] = 1; //所有数据sku
  1626. } else {
  1627. $od[$v['zd']] = $od[$v['zd']] + 1;
  1628. }
  1629. }
  1630. foreach ($od as $k => $vv) {
  1631. $odid .= $k . '数量' . $vv . ' ';
  1632. }
  1633. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1634. $info_list[$key]['features'] = $c;
  1635. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1636. $ztdata = '';
  1637. if (count($zt) > 0) {
  1638. foreach ($zt as $vv) {
  1639. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1640. }
  1641. }
  1642. $info_list[$key]['warehouse'] = $ztdata;
  1643. $info_list[$key]['g'] = $g;
  1644. $info_list[$key]['x'] = $x;
  1645. $info_list[$key]['t'] = $t;
  1646. $info_list[$key]['z'] = $z;
  1647. }
  1648. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1649. $pagenum = ceil($total / $perpage);
  1650. $over = $total - ($start + $perpage);
  1651. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1652. echo json_encode($rows);
  1653. exit;
  1654. }
  1655. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1656. $this->data['warehouse'] = $warehouse;
  1657. $this->_Template('whlabel_typeusa', $this->data);
  1658. }
  1659. //美仓进销存浏览
  1660. public function _usatypeapp()
  1661. {
  1662. $post = $this->input->post(NULL, TRUE);
  1663. if (isset($post['page'])) {
  1664. $page = $this->input->post('page', true);
  1665. $perpage = $this->input->post('perpage', true);
  1666. $sku = $this->input->post('sku', true);
  1667. $warehouse = 5;
  1668. $title = $this->input->post('title', true);
  1669. $state = $this->input->post('state', true);
  1670. $ktime = $this->input->post('ktime', true);
  1671. $jtime = $this->input->post('jtime', true);
  1672. $ktime = strtotime($ktime);
  1673. $jtime = strtotime($jtime);
  1674. $where = "1=1";
  1675. $gj = "";
  1676. $ck = "";
  1677. if ($title) {
  1678. $st = explode(' ', trim($title, ' '));
  1679. foreach ($st as $v) {
  1680. $where .= " and title like '%$v%'";
  1681. }
  1682. }
  1683. if ($warehouse) {
  1684. $where .= " and warehouse = '$warehouse'";
  1685. }
  1686. if ($state) {
  1687. $where .= " and state = '$state'";
  1688. }
  1689. if ($sku) {
  1690. $where .= " and sku like '%$sku%'";
  1691. }
  1692. if ($ktime && $jtime) {
  1693. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1694. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1695. }
  1696. //数据排序
  1697. $order_str = "id desc";
  1698. if (empty($page)) {
  1699. $start = 0;
  1700. $perpage = 1;
  1701. } else {
  1702. $start = ($page - 1) * $perpage;
  1703. }
  1704. //取得信息列表
  1705. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1706. $rows = array();
  1707. $list = array();
  1708. foreach ($info_list as $key => $value) {
  1709. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1710. }
  1711. $rowsdq = array_slice($rows, $start, $perpage);
  1712. foreach ($rowsdq as $value) {
  1713. $warehouse = $this->warehouse->read($value['warehouse']);
  1714. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1715. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1716. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1717. $od = array();
  1718. $odid = '';
  1719. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1720. }
  1721. $total = count($rows);
  1722. $pagenum = ceil($total / $perpage);
  1723. $over = $total - ($start + $perpage);
  1724. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1725. echo json_encode($rows);
  1726. exit;
  1727. }
  1728. $this->_Template('phone/p_usatypeapp', $this->data);
  1729. }
  1730. //入库操作
  1731. public function _enteradd()
  1732. {
  1733. $dt = 0;
  1734. if (isset($_SESSION['api'])) {
  1735. $user = $this->user->get_api($_SESSION['api']);
  1736. $usp = $user;
  1737. $fgshop = "";
  1738. $sid = "";
  1739. $user = explode('|', trim($user['shop'], '|'));
  1740. foreach ($user as $value) {
  1741. $fgshop .= " shop = " . $value . " or";
  1742. $sid .= " id = " . $value . " or";
  1743. }
  1744. }
  1745. $tc = $this->typeclass->find_all();
  1746. $typeclass = array();
  1747. foreach ($tc as $v) {
  1748. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1749. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1750. }
  1751. $post = $this->input->post(NULL, TRUE);
  1752. if (isset($post['sku'])) {
  1753. $list = array();
  1754. $num = "";
  1755. $title = "";
  1756. $features = "";
  1757. $order = $this->input->post('order', true);
  1758. $shop = $this->input->post('shop', true);
  1759. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1760. $sku = $this->input->post('sku', true);
  1761. $post['sm'] = $this->input->post('sm', true);
  1762. $post['warehouse'] = $this->input->post('warehouse', true);
  1763. $post['purchase'] = $this->input->post('purchase', true);
  1764. $post['retreatwarehouse'] = $post['warehouse'];
  1765. $post['state'] = $this->input->post('state', true);
  1766. $post['rktype'] = $this->input->post('rktype', true);
  1767. $post['text'] = $this->input->post('text', true);
  1768. $category = $this->input->post('category', true);
  1769. $list['category'] = $category;
  1770. $list['hairtype'] = $this->input->post('hairtype', true);
  1771. $list['grade'] = $this->input->post('grade', true);
  1772. $size = $this->input->post('size', true);
  1773. $xzsku = $this->input->post('xzsku', true);
  1774. $list['size'] = rtrim($size, ',');
  1775. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1776. $list['extension'] = $this->input->post('extension', true);
  1777. if ($category == 1297) {
  1778. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1779. }
  1780. if ($category == 1702) {
  1781. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1782. $list['syother'] = $this->input->post('syother', true);
  1783. }
  1784. if ($category == 133) {
  1785. $list['fittype'] = $this->input->post('fittype', true);
  1786. $list['acother'] = $this->input->post('acother', true);
  1787. }
  1788. $list['color'] = $this->input->post('color', true);
  1789. $list['lowe'] = $this->input->post('lowe', true);
  1790. if (!$post['purchase']) {
  1791. $post['purchase'] = 1;
  1792. }
  1793. if ($category == 127) {
  1794. $list['type'] = $this->input->post('type', true);
  1795. $list['headroad'] = $this->input->post('headroad', true);
  1796. $list['density'] = $this->input->post('density', true);
  1797. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1798. $list['lacesize'] = $this->input->post('lacesize', true);
  1799. }
  1800. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1801. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1802. }
  1803. if ($category == 128) {
  1804. $list['lacetype'] = $this->input->post('lacetype', true);
  1805. $list['haircap'] = $this->input->post('haircap', true);
  1806. $list['density'] = $this->input->post('density', true);
  1807. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1808. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1809. $list['wigother'] = $this->input->post('wigother', true);
  1810. $list['wigother1'] = $this->input->post('wigother1', true);
  1811. $list['wigother2'] = $this->input->post('wigother2', true);
  1812. }
  1813. if ($category == 129) {
  1814. $list['wide'] = $this->input->post('wide', true);
  1815. }
  1816. if ($category == 131) {
  1817. $list['gifttype'] = $this->input->post('gifttype', true);
  1818. $list['giftother'] = $this->input->post('giftother', true);
  1819. }
  1820. if ($category == 134) {
  1821. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1822. }
  1823. if ($category == 1297) {
  1824. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1825. $list['sywigother'] = $this->input->post('sywigother', true);
  1826. }
  1827. if ($category == 130 || $category == 133 || $category == 1702) {
  1828. $list['items'] = $this->input->post('items', true);
  1829. $list['weight'] = $this->input->post('weight', true);
  1830. }
  1831. if ($category == 1702) {
  1832. $list['syhairther'] = $this->input->post('syhairther', true);
  1833. }
  1834. $classid = $this->classid->sku();
  1835. $scsku = $classid;
  1836. $pm = $classid;
  1837. foreach ($list as $k => $v) {
  1838. if ($v != 0) {
  1839. $num .= $v;
  1840. $features .= $v . '-';
  1841. $post[$k] = $v;
  1842. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1843. if ($k != 'size') {
  1844. $title .= $typeclass[$v]['title'] . " ";
  1845. }
  1846. if (isset($pm[$typeclass[$v]['classid']])) {
  1847. if ($typeclass[$v]['title'] == '9A') {
  1848. $pm[$typeclass[$v]['classid']] = '9A';
  1849. } else if ($typeclass[$v]['title'] == '10A') {
  1850. $pm[$typeclass[$v]['classid']] = '10A';
  1851. } else {
  1852. $clzh = $typeclass[$v]['zh'];
  1853. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1854. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1855. $clzh = $clzh[0];
  1856. }
  1857. $pm[$typeclass[$v]['classid']] = $clzh;
  1858. }
  1859. }
  1860. }
  1861. }
  1862. $zh = implode(" ", $pm);
  1863. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1864. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1865. if ($list['size']) {
  1866. $typeclass = $this->typeclass->read($list['size']);
  1867. $title .= $typeclass['title'];
  1868. }
  1869. $time = time();
  1870. if ($xzsku) {
  1871. $scsku = implode("-", $scsku);
  1872. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1873. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1874. $post['sku'] = trim($scsku, ' ');
  1875. } else {
  1876. $post['sku'] = $sku;
  1877. }
  1878. //$post['sku'] = trim($sku,' ');
  1879. $post['title'] = rtrim($title, ' ');
  1880. $post['number'] = $num;
  1881. $post['features'] = '-' . $features;
  1882. $post['enter'] = $time;
  1883. $post['time'] = $time; //操作时间
  1884. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1885. if ($yza) {
  1886. if ($post['features'] != $yza[0]['features']) {
  1887. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1888. exit;
  1889. }
  1890. }
  1891. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1892. if ($yzb) {
  1893. if ($post['sku'] != $yzb[0]['sku']) {
  1894. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1895. exit;
  1896. }
  1897. }
  1898. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1899. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1900. exit;
  1901. }
  1902. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1903. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1904. exit;
  1905. }
  1906. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1907. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1908. exit;
  1909. }
  1910. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1911. if (isset($yz[0]['type'])) {
  1912. $post['type'] = $yz[0]['type'];
  1913. }
  1914. if ($post['state'] == 9) //如果选择预设库存
  1915. {
  1916. $this->whlabel->insert($post);
  1917. } else {
  1918. /**
  1919. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1920. if($ljg == 1)
  1921. {
  1922. for($i=0;$i<$order;$i++)
  1923. {
  1924. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1925. $this->whlabel->insert($post);
  1926. }
  1927. }
  1928. **/
  1929. //if($post['warehouse'] == '5')
  1930. //{
  1931. //}
  1932. $yydata = $post;
  1933. $yydata['zh'] = $zh;
  1934. /**
  1935. $wl = $this->apiyy->get_cjlp($yydata);
  1936. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1937. {
  1938. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1939. }
  1940. if($wl['Data'][0]['m_isSucess'] != 1)
  1941. {
  1942. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1943. }
  1944. **/
  1945. for ($i = 0; $i < $order; $i++) {
  1946. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1947. $this->whlabel->insert($post);
  1948. }
  1949. }
  1950. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1951. exit;
  1952. }
  1953. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1954. $this->data['wlshop'] = $wlshop;
  1955. $this->_Template('whlabel_enteradd', $this->data);
  1956. }
  1957. //修改产品
  1958. public function _enteredit($arg_array)
  1959. {
  1960. $dt = 0;
  1961. if (isset($_SESSION['api'])) {
  1962. $user = $this->user->get_api($_SESSION['api']);
  1963. $usp = $user;
  1964. $fgshop = "";
  1965. $sid = "";
  1966. $user = explode('|', trim($user['shop'], '|'));
  1967. foreach ($user as $value) {
  1968. $fgshop .= " shop = " . $value . " or";
  1969. $sid .= " id = " . $value . " or";
  1970. }
  1971. }
  1972. $post = $this->input->post(NULL, TRUE);
  1973. if (isset($post['sku'])) {
  1974. $list = array();
  1975. $num = "";
  1976. $title = "";
  1977. $features = "";
  1978. $id = $this->input->post('id', true);
  1979. $order = $this->input->post('order', true);
  1980. $shop = $this->input->post('shop', true);
  1981. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1982. $post['sku'] = $this->input->post('sku', true);
  1983. $post['sm'] = $this->input->post('sm', true);
  1984. $post['warehouse'] = $this->input->post('warehouse', true);
  1985. $post['purchase'] = $this->input->post('purchase', true);
  1986. $post['retreatwarehouse'] = $post['warehouse'];
  1987. $category = $this->input->post('category', true);
  1988. $list['category'] = $category;
  1989. $list['hairtype'] = $this->input->post('hairtype', true);
  1990. $list['grade'] = $this->input->post('grade', true);
  1991. $size = $this->input->post('size', true);
  1992. $list['size'] = rtrim($size, ',');
  1993. $post['rktype'] = $this->input->post('rktype', true);
  1994. $post['text'] = $this->input->post('text', true);
  1995. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1996. $list['extension'] = $this->input->post('extension', true);
  1997. if ($category == 1297) {
  1998. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1999. }
  2000. if ($category == 1702) {
  2001. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2002. $list['syother'] = $this->input->post('syother', true);
  2003. }
  2004. if ($category == 133) {
  2005. $list['fittype'] = $this->input->post('fittype', true);
  2006. $list['acother'] = $this->input->post('acother', true);
  2007. }
  2008. $list['color'] = $this->input->post('color', true);
  2009. $list['lowe'] = $this->input->post('lowe', true);
  2010. if (!$post['purchase']) {
  2011. $post['purchase'] = 1;
  2012. }
  2013. if ($category == 127) {
  2014. $list['type'] = $this->input->post('type', true);
  2015. $list['headroad'] = $this->input->post('headroad', true);
  2016. $list['density'] = $this->input->post('density', true);
  2017. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2018. $list['lacesize'] = $this->input->post('lacesize', true);
  2019. }
  2020. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2021. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2022. }
  2023. if ($category == 128) {
  2024. $list['lacetype'] = $this->input->post('lacetype', true);
  2025. $list['haircap'] = $this->input->post('haircap', true);
  2026. $list['density'] = $this->input->post('density', true);
  2027. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2028. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2029. $list['wigother'] = $this->input->post('wigother', true);
  2030. $list['wigother1'] = $this->input->post('wigother1', true);
  2031. $list['wigother2'] = $this->input->post('wigother2', true);
  2032. }
  2033. if ($category == 129) {
  2034. $list['wide'] = $this->input->post('wide', true);
  2035. }
  2036. if ($category == 131) {
  2037. $list['gifttype'] = $this->input->post('gifttype', true);
  2038. $list['giftother'] = $this->input->post('giftother', true);
  2039. }
  2040. if ($category == 134) {
  2041. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2042. }
  2043. if ($category == 1297) {
  2044. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2045. $list['sywigother'] = $this->input->post('sywigother', true);
  2046. }
  2047. if ($category == 130 || $category == 133 || $category == 1702) {
  2048. $list['items'] = $this->input->post('items', true);
  2049. $list['weight'] = $this->input->post('weight', true);
  2050. }
  2051. if ($category == 1702) {
  2052. $list['syhairther'] = $this->input->post('syhairther', true);
  2053. }
  2054. foreach ($list as $k => $v) {
  2055. if ($v != 0) {
  2056. $num .= $v;
  2057. $features .= $v . '-';
  2058. $typeclass = $this->typeclass->read($v);
  2059. if ($k != 'size') {
  2060. $title .= $typeclass['title'] . " ";
  2061. }
  2062. }
  2063. }
  2064. $typeclass = $this->typeclass->read($list['size']);
  2065. $title .= $typeclass['title'];
  2066. $time = time();
  2067. $post['title'] = rtrim($title, ' ');
  2068. $post['number'] = $num;
  2069. $post['features'] = '-' . $features;
  2070. $post['time'] = $time; //操作时间
  2071. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2072. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2073. exit;
  2074. }
  2075. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2076. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2077. exit;
  2078. }
  2079. $uid = $this->whlabel->read($id);
  2080. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2081. if ($datanum > 0) {
  2082. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2083. exit;
  2084. }
  2085. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2086. {
  2087. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2088. if ($yza) {
  2089. if ($post['features'] != $yza[0]['features']) {
  2090. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2091. exit;
  2092. }
  2093. }
  2094. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2095. if ($yzb) {
  2096. if ($post['sku'] != $yzb[0]['sku']) {
  2097. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2098. exit;
  2099. }
  2100. }
  2101. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2102. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2103. exit;
  2104. }
  2105. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2106. foreach ($data as $v) {
  2107. $post['id'] = $v['id'];
  2108. $this->whlabel->save($post, $v['id']);
  2109. }
  2110. } else {
  2111. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2112. if ($data > 0) {
  2113. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2114. exit;
  2115. } else {
  2116. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2117. foreach ($data as $v) {
  2118. $post['id'] = $v['id'];
  2119. $this->whlabel->save($post, $v['id']);
  2120. }
  2121. }
  2122. }
  2123. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2124. exit;
  2125. }
  2126. $uid = $this->whlabel->read($arg_array[0]);
  2127. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2128. $this->data['enter'] = $uid;
  2129. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2130. $this->data['wlshop'] = $wlshop;
  2131. $this->_Template('whlabel_enteredit', $this->data);
  2132. }
  2133. //入库浏览
  2134. public function _enter()
  2135. {
  2136. $post = $this->input->post(NULL, TRUE);
  2137. if (isset($post['s'])) {
  2138. $id_arr = $this->input->post('s');
  2139. $id_arr = explode(',', $id_arr);
  2140. if (!$id_arr) {
  2141. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2142. exit;
  2143. }
  2144. //循环删除记录
  2145. foreach ($id_arr as $v) {
  2146. $sid = $this->whlabel->read($v);
  2147. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2148. if ($count > 0) {
  2149. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2150. exit;
  2151. }
  2152. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2153. foreach ($info_list as $va) {
  2154. $this->whlabel->remove($va['id']);
  2155. }
  2156. }
  2157. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2158. exit;
  2159. }
  2160. $sp = array();
  2161. $s = $this->shop->find_all('1=1', 'id,shopname');
  2162. foreach ($s as $v) {
  2163. $sp[$v['id']] = $v['shopname'];
  2164. }
  2165. $wh = array();
  2166. $w = $this->warehouse->find_all('1=1', 'id,title');
  2167. foreach ($w as $v) {
  2168. $wh[$v['id']] = $v['title'];
  2169. }
  2170. if (isset($post['page'])) {
  2171. $page = $this->input->post('page', true);
  2172. $perpage = $this->input->post('perpage', true);
  2173. $category = $this->input->post('category', true);
  2174. $size = $this->input->post('size', true);
  2175. $grade = $this->input->post('grade', true);
  2176. $color = $this->input->post('color', true);
  2177. $lowe = $this->input->post('lowe', true);
  2178. $sku = $this->input->post('sku', true);
  2179. $warehouse = $this->input->post('warehouse', true);
  2180. $purchase = $this->input->post('purchase', true);
  2181. $ktime = $this->input->post('ktime', true);
  2182. $jtime = $this->input->post('jtime', true);
  2183. $ktime = strtotime($ktime);
  2184. $jtime = strtotime($jtime);
  2185. $where = "1=1";
  2186. $gj = "";
  2187. $ck = "";
  2188. if ($category) {
  2189. $where .= " and features like '%-$category-%'";
  2190. }
  2191. if ($size) {
  2192. $where .= " and features like '%-$size-%'";
  2193. }
  2194. if ($grade) {
  2195. $where .= " and features like '%-$grade-%'";
  2196. }
  2197. if ($color) {
  2198. $where .= " and features like '%-$color-%'";
  2199. }
  2200. if ($lowe) {
  2201. $where .= " and features like '%-$lowe-%'";
  2202. }
  2203. if ($warehouse) {
  2204. $where .= " and warehouse = '$warehouse'";
  2205. }
  2206. if ($purchase) {
  2207. $where .= " and purchase = '$purchase'";
  2208. }
  2209. if ($sku) {
  2210. $where .= " and sku like '%$sku%'";
  2211. }
  2212. if ($ktime && $jtime) {
  2213. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2214. }
  2215. //数据排序
  2216. $order_str = "enter desc";
  2217. if (empty($page)) {
  2218. $start = 0;
  2219. $perpage = 1;
  2220. } else {
  2221. $start = ($page - 1) * $perpage;
  2222. }
  2223. //取得信息列表
  2224. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2225. foreach ($info_list as $k => $v) {
  2226. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2227. if ($v['shop'] == '') {
  2228. $s = '通用';
  2229. } else {
  2230. $info_list[$k]['shop'] = '';
  2231. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2232. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2233. }
  2234. }
  2235. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2236. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2237. $info_list[$k]['g'] = $g;
  2238. }
  2239. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2240. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2241. $pagenum = ceil($total / $perpage);
  2242. $over = $total - ($start + $perpage);
  2243. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2244. echo json_encode($rows);
  2245. exit;
  2246. }
  2247. $this->_Template('whlabel_enter', $this->data);
  2248. }
  2249. //出库浏览
  2250. public function _out()
  2251. {
  2252. $post = $this->input->post(NULL, TRUE);
  2253. if (isset($post['page'])) {
  2254. $page = $this->input->post('page', true);
  2255. $perpage = $this->input->post('perpage', true);
  2256. $category = $this->input->post('category', true);
  2257. $size = $this->input->post('size', true);
  2258. $grade = $this->input->post('grade', true);
  2259. $color = $this->input->post('color', true);
  2260. $lowe = $this->input->post('lowe', true);
  2261. $sku = $this->input->post('sku', true);
  2262. $warehouse = $this->input->post('warehouse', true);
  2263. $purchase = $this->input->post('purchase', true);
  2264. $state = $this->input->post('state', true);
  2265. $ktime = $this->input->post('ktime', true);
  2266. $jtime = $this->input->post('jtime', true);
  2267. $ktime = strtotime($ktime);
  2268. $jtime = strtotime($jtime);
  2269. $where = "state=3";
  2270. $gj = "";
  2271. $ck = "";
  2272. if ($category) {
  2273. $where .= " and features like '%-$category-%'";
  2274. }
  2275. if ($size) {
  2276. $where .= " and features like '%-$size-%'";
  2277. }
  2278. if ($grade) {
  2279. $where .= " and features like '%-$grade-%'";
  2280. }
  2281. if ($color) {
  2282. $where .= " and features like '%-$color-%'";
  2283. }
  2284. if ($lowe) {
  2285. $where .= " and features like '%-$lowe-%'";
  2286. }
  2287. if ($state) {
  2288. $where .= " and state = '$state'";
  2289. }
  2290. if ($warehouse) {
  2291. $where .= " and warehouse = '$warehouse'";
  2292. }
  2293. if ($purchase) {
  2294. $where .= " and purchase = '$purchase'";
  2295. }
  2296. if ($sku) {
  2297. $where .= " and sku = '$sku'";
  2298. }
  2299. if ($ktime && $jtime) {
  2300. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2301. }
  2302. //数据排序
  2303. $order_str = "id desc";
  2304. if (empty($page)) {
  2305. $start = 0;
  2306. $perpage = 1;
  2307. } else {
  2308. $start = ($page - 1) * $perpage;
  2309. }
  2310. //取得信息列表
  2311. $info_list = $this->whlabel->find_all($where, 'sku');
  2312. $rows = array();
  2313. $list = array();
  2314. foreach ($info_list as $key => $value) {
  2315. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2316. }
  2317. $rows = array_unique($rows); //删除重复记录
  2318. foreach ($rows as $key => $value) {
  2319. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2320. $ck = $this->warehouse->read($data['warehouse']);
  2321. $warehouse = $ck['title'];
  2322. $gy = $this->purchase->read($data['purchase']);
  2323. $purchase = $gy['purchase'];
  2324. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2325. $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);
  2326. }
  2327. $total = count($list);
  2328. $pagenum = ceil($total / $perpage);
  2329. $over = $total - ($start + $perpage);
  2330. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2331. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2332. echo json_encode($rows);
  2333. exit;
  2334. }
  2335. $this->_Template('whlabel_out', $this->data);
  2336. }
  2337. //出库标签浏览
  2338. public function _label()
  2339. {
  2340. $post = $this->input->post(NULL, TRUE);
  2341. if (isset($post['page'])) {
  2342. $page = $this->input->post('page', true);
  2343. $perpage = $this->input->post('perpage', true);
  2344. $sku = $this->input->post('sku', true);
  2345. $warehouse = $this->input->post('warehouse', true);
  2346. $purchase = $this->input->post('purchase', true);
  2347. $orderinfo = $this->input->post('orderinfo', true);
  2348. $waybill = $this->input->post('waybill', true);
  2349. $category = $this->input->post('category', true);
  2350. $size = $this->input->post('size', true);
  2351. $grade = $this->input->post('grade', true);
  2352. $color = $this->input->post('color', true);
  2353. $lowe = $this->input->post('lowe', true);
  2354. $where = "state=1";
  2355. if ($sku) {
  2356. $where .= " and sku = '$sku'";
  2357. }
  2358. if ($warehouse) {
  2359. $where .= " and warehouse = '$warehouse'";
  2360. }
  2361. if ($purchase) {
  2362. $where .= " and purchase = '$purchase'";
  2363. }
  2364. if ($orderinfo) {
  2365. $where .= " and orderinfo = '$orderinfo'";
  2366. }
  2367. if ($waybill) {
  2368. $where .= " and waybill = '$waybill'";
  2369. }
  2370. if ($category) {
  2371. $where .= " and features like '%-$category-%'";
  2372. }
  2373. if ($size) {
  2374. $where .= " and features like '%-$size-%'";
  2375. }
  2376. if ($grade) {
  2377. $where .= " and features like '%-$grade-%'";
  2378. }
  2379. if ($color) {
  2380. $where .= " and features like '%-$color-%'";
  2381. }
  2382. if ($lowe) {
  2383. $where .= " and features like '%-$lowe-%'";
  2384. }
  2385. //数据排序
  2386. $order_str = "outk desc";
  2387. if (empty($page)) {
  2388. $start = 0;
  2389. $perpage = 1;
  2390. } else {
  2391. $start = ($page - 1) * $perpage;
  2392. }
  2393. //取得信息列表
  2394. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2395. foreach ($info_list as $key => $value) {
  2396. $warehouse = $this->warehouse->read($value['warehouse']);
  2397. $info_list[$key]['warehouse'] = $warehouse['title'];
  2398. $purchase = $this->purchase->read($value['purchase']);
  2399. $info_list[$key]['purchase'] = $purchase['title'];
  2400. if ($value['outk'] != 0) {
  2401. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2402. } else {
  2403. $info_list[$key]['outk'] = "";
  2404. }
  2405. if ($value['orderinfo'] == 0) {
  2406. $info_list[$key]['orderinfo'] = "";
  2407. }
  2408. if ($value['waybill'] == 0) {
  2409. $info_list[$key]['waybill'] = "";
  2410. }
  2411. }
  2412. $total = $this->whlabel->find_count($where);
  2413. $pagenum = ceil($total / $perpage);
  2414. $over = $total - ($start + $perpage);
  2415. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2416. echo json_encode($rows);
  2417. exit;
  2418. }
  2419. $this->_Template('whlabel_label', $this->data);
  2420. }
  2421. //独立站出库订单
  2422. public function _outorder()
  2423. {
  2424. if (isset($_SESSION['api'])) {
  2425. $user = $this->user->get_api($_SESSION['api']);
  2426. $usp = $user;
  2427. $fgshop = "";
  2428. $sid = "";
  2429. $user = explode('|', trim($user['shop'], '|'));
  2430. foreach ($user as $value) {
  2431. $fgshop .= " shop = " . $value . " or";
  2432. $sid .= " id = " . $value . " or";
  2433. }
  2434. } else {
  2435. echo "请重新登录";
  2436. }
  2437. $post = $this->input->post(NULL, TRUE);
  2438. if (isset($post['page'])) {
  2439. $page = $this->input->post('page', true);
  2440. $perpage = $this->input->post('perpage', true);
  2441. $warehouse = $this->input->post('warehouse', true);
  2442. $xztime = $this->input->post('xztime', true);
  2443. $timetk = $this->input->post('timetkk', true);
  2444. $timetj = $this->input->post('timetjj', true);
  2445. $shop = $this->input->post('shop', true);
  2446. $source = $this->input->post('source', true);
  2447. $orderinfo = $this->input->post('orderinfo', true);
  2448. $number = $this->input->post('number', true);
  2449. $sfxh = $this->input->post('sfxh', true);
  2450. $express = $this->input->post('express', true);
  2451. $waybill = $this->input->post('waybill', true);
  2452. $library = $this->input->post('library', true);
  2453. $country = $this->input->post('country', true);
  2454. $so = $this->input->post('so', true);
  2455. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2456. $print = $this->input->post('print', true);
  2457. $state = $this->input->post('state', true);
  2458. $orderurl = $this->input->post('orderurl', true);
  2459. $productid = $this->input->post('productid', true);
  2460. $timetk = strtotime($timetk);
  2461. $timetj = strtotime($timetj);
  2462. /**
  2463. $sj = $this->input->post('sj',true);
  2464. if($sj)
  2465. {
  2466. $sj = $this->input->post('sj',true);
  2467. }
  2468. else
  2469. {
  2470. $sj = "fullorder";
  2471. }
  2472. **/
  2473. $sj = "fullorder";
  2474. $where = "1=1";
  2475. if ($warehouse) {
  2476. $where .= " and type = '$warehouse'";
  2477. }
  2478. if ($timetk && $timetj) {
  2479. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2480. }
  2481. if ($orderinfo) {
  2482. $where .= " and orderinfo = '$orderinfo'";
  2483. }
  2484. if ($number) {
  2485. $where .= " and number = '$number'";
  2486. }
  2487. if ($express) {
  2488. $where .= " and express = '$express'";
  2489. }
  2490. if ($waybill) {
  2491. $where .= " and waybill = '$waybill'";
  2492. }
  2493. if ($library) {
  2494. $where .= " and library = '$library'";
  2495. }
  2496. if ($print) {
  2497. $where .= " and print = '$print'";
  2498. }
  2499. if ($libraryconfirm) {
  2500. $where .= " and libraryconfirm = '$libraryconfirm'";
  2501. }
  2502. if ($state) {
  2503. $where .= " and state = '$state'";
  2504. }
  2505. if ($shop) {
  2506. $where .= " and shop = '$shop'";
  2507. }
  2508. if ($country) {
  2509. $where .= " and country = '$country'";
  2510. }
  2511. if ($sfxh != '') {
  2512. $where .= " and sfxh = '$sfxh'";
  2513. }
  2514. if ($so) {
  2515. $where .= " and shipremarks like '%$so%'";
  2516. }
  2517. if ($source) {
  2518. if ($source == '2d') {
  2519. $where .= " and source >= '2'";
  2520. } else {
  2521. $where .= " and source = '$source'";
  2522. }
  2523. }
  2524. if (isset($_SESSION['api'])) {
  2525. foreach ($user as $value) {
  2526. $fgshop .= " shop = " . $value . " or";
  2527. }
  2528. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2529. }
  2530. if ($orderurl) {
  2531. $url = $this->orderurl->read($orderurl);
  2532. $where .= " and link like '%" . $url['url'] . "%'";
  2533. }
  2534. if($productid){
  2535. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2536. }
  2537. //数据排序
  2538. $order_str = "librarytime desc";
  2539. if (empty($page)) {
  2540. $start = 0;
  2541. $perpage = 1;
  2542. } else {
  2543. $start = ($page - 1) * $perpage;
  2544. }
  2545. //取得信息列表
  2546. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2547. //格式化数据
  2548. foreach ($info_list as $key => $value) {
  2549. $shop = $this->shop->read($value['shop']);
  2550. $info_list[$key]['shop'] = $shop['shopname'];
  2551. $express = $this->express->read($value['express']);
  2552. $info_list[$key]['express'] = $express['servicename'];
  2553. $warehouse = $this->warehouse->read($value['type']);
  2554. $info_list[$key]['type'] = $warehouse['title'];
  2555. if ($value['librarytime'] == '0') {
  2556. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2557. } else {
  2558. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2559. }
  2560. }
  2561. $total = $this->$sj->find_count($where);
  2562. $pagenum = ceil($total / $perpage);
  2563. $over = $total - ($start + $perpage);
  2564. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2565. echo json_encode($rows);
  2566. exit;
  2567. }
  2568. $this->data['express'] = $this->express->find_all();
  2569. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2570. $this->data['wlshop'] = $wlshop;
  2571. $user = $this->user->get_api($_SESSION['api']);
  2572. $powerid = $this->power->read($user['power']);
  2573. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2574. $pid = '';
  2575. foreach ($powertext as $v) {
  2576. $pid .= " id = " . $v . " or";
  2577. }
  2578. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2579. $this->data['fullorderexcel'] = $fullorderexcel;
  2580. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2581. $this->data['orderurl'] = $orderurl;
  2582. $this->_Template('whlabel_outorder', $this->data);
  2583. }
  2584. //tt出库
  2585. public function _toutorder()
  2586. {
  2587. $fgshop = "";
  2588. $sid = "";
  2589. if (isset($_SESSION['api'])) {
  2590. $user = $this->user->get_api($_SESSION['api']);
  2591. $usp = $user;
  2592. $user = explode('|', trim($user['shop'], '|'));
  2593. foreach ($user as $value) {
  2594. $fgshop .= " shop = " . $value . " or";
  2595. $sid .= " id = " . $value . " or";
  2596. }
  2597. } else {
  2598. echo "请重新登录";
  2599. die;
  2600. }
  2601. $post = $this->input->post(NULL, TRUE);
  2602. if (isset($post['page'])) {
  2603. $page = $this->input->post('page', true);
  2604. $perpage = $this->input->post('perpage', true);
  2605. $warehouse = $this->input->post('warehouse', true);
  2606. $xztime = $this->input->post('xztime', true);
  2607. $timetk = $this->input->post('timetkk', true);
  2608. $timetj = $this->input->post('timetjj', true);
  2609. $shop = $this->input->post('shop', true);
  2610. $source = $this->input->post('source', true);
  2611. $orderinfo = $this->input->post('orderinfo', true);
  2612. $number = $this->input->post('number', true);
  2613. $sfxh = $this->input->post('sfxh', true);
  2614. $express = $this->input->post('express', true);
  2615. $waybill = $this->input->post('waybill', true);
  2616. $library = $this->input->post('library', true);
  2617. $country = $this->input->post('country', true);
  2618. $so = $this->input->post('so', true);
  2619. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2620. $print = $this->input->post('print', true);
  2621. $state = $this->input->post('state', true);
  2622. $orderurl = $this->input->post('orderurl', true);
  2623. $timetk = strtotime($timetk);
  2624. $timetj = strtotime($timetj);
  2625. /**
  2626. $sj = $this->input->post('sj',true);
  2627. if($sj)
  2628. {
  2629. $sj = $this->input->post('sj',true);
  2630. }
  2631. else
  2632. {
  2633. $sj = "fullorder";
  2634. }
  2635. **/
  2636. $sj = "fullordertt";
  2637. $where = "1=1";
  2638. if ($warehouse) {
  2639. $where .= " and type = '$warehouse'";
  2640. }
  2641. if ($timetk && $timetj) {
  2642. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2643. }
  2644. if ($orderinfo) {
  2645. $where .= " and orderinfo = '$orderinfo'";
  2646. }
  2647. if ($number) {
  2648. $where .= " and number = '$number'";
  2649. }
  2650. if ($express) {
  2651. $where .= " and express = '$express'";
  2652. }
  2653. if ($waybill) {
  2654. $where .= " and waybill = '$waybill'";
  2655. }
  2656. if ($library) {
  2657. $where .= " and library = '$library'";
  2658. }
  2659. if ($print) {
  2660. $where .= " and print = '$print'";
  2661. }
  2662. if ($libraryconfirm) {
  2663. $where .= " and libraryconfirm = '$libraryconfirm'";
  2664. }
  2665. if ($state) {
  2666. $where .= " and state = '$state'";
  2667. }
  2668. if ($shop) {
  2669. $where .= " and shop = '$shop'";
  2670. }
  2671. if ($country) {
  2672. $where .= " and country = '$country'";
  2673. }
  2674. if ($sfxh != '') {
  2675. $where .= " and sfxh = '$sfxh'";
  2676. }
  2677. if ($so) {
  2678. $where .= " and shipremarks like '%$so%'";
  2679. }
  2680. if ($source) {
  2681. if ($source == '2d') {
  2682. $where .= " and source >= '2'";
  2683. } else {
  2684. $where .= " and source = '$source'";
  2685. }
  2686. }
  2687. if (isset($_SESSION['api'])) {
  2688. foreach ($user as $value) {
  2689. $fgshop .= " shop = " . $value . " or";
  2690. }
  2691. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2692. }
  2693. if ($orderurl) {
  2694. $url = $this->orderurl->read($orderurl);
  2695. $where .= " and link like '%" . $url['url'] . "%'";
  2696. }
  2697. //数据排序
  2698. $order_str = "librarytime desc";
  2699. if (empty($page)) {
  2700. $start = 0;
  2701. $perpage = 1;
  2702. } else {
  2703. $start = ($page - 1) * $perpage;
  2704. }
  2705. //取得信息列表
  2706. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2707. //格式化数据
  2708. foreach ($info_list as $key => $value) {
  2709. $shop = $this->shop->read($value['shop']);
  2710. $info_list[$key]['shop'] = $shop['shopname'];
  2711. $express = $this->express->read($value['express']);
  2712. $info_list[$key]['express'] = $express['servicename'];
  2713. $warehouse = $this->warehouse->read($value['type']);
  2714. $info_list[$key]['type'] = $warehouse['title'];
  2715. if ($value['librarytime'] == '0') {
  2716. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2717. } else {
  2718. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2719. }
  2720. }
  2721. $total = $this->$sj->find_count($where);
  2722. $pagenum = ceil($total / $perpage);
  2723. $over = $total - ($start + $perpage);
  2724. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2725. echo json_encode($rows);
  2726. exit;
  2727. }
  2728. $this->data['express'] = $this->express->find_all();
  2729. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2730. $this->data['wlshop'] = $wlshop;
  2731. $user = $this->user->get_api($_SESSION['api']);
  2732. $powerid = $this->power->read($user['power']);
  2733. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2734. $pid = '';
  2735. foreach ($powertext as $v) {
  2736. $pid .= " id = " . $v . " or";
  2737. }
  2738. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2739. $this->data['fullorderexcel'] = $fullorderexcel;
  2740. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2741. $this->data['orderurl'] = $orderurl;
  2742. $this->_Template('whlabel_toutorder', $this->data);
  2743. }
  2744. //tt出库
  2745. public function _aoutorder()
  2746. {
  2747. if (isset($_SESSION['api'])) {
  2748. $user = $this->user->get_api($_SESSION['api']);
  2749. $usp = $user;
  2750. $fgshop = "";
  2751. $sid = "";
  2752. $user = explode('|', trim($user['shop'], '|'));
  2753. foreach ($user as $value) {
  2754. $fgshop .= " shop = " . $value . " or";
  2755. $sid .= " id = " . $value . " or";
  2756. }
  2757. } else {
  2758. echo "请重新登录";
  2759. }
  2760. $post = $this->input->post(NULL, TRUE);
  2761. if (isset($post['page'])) {
  2762. $page = $this->input->post('page', true);
  2763. $perpage = $this->input->post('perpage', true);
  2764. $warehouse = $this->input->post('warehouse', true);
  2765. $xztime = $this->input->post('xztime', true);
  2766. $timetk = $this->input->post('timetkk', true);
  2767. $timetj = $this->input->post('timetjj', true);
  2768. $shop = $this->input->post('shop', true);
  2769. $source = $this->input->post('source', true);
  2770. $orderinfo = $this->input->post('orderinfo', true);
  2771. $number = $this->input->post('number', true);
  2772. $sfxh = $this->input->post('sfxh', true);
  2773. $express = $this->input->post('express', true);
  2774. $waybill = $this->input->post('waybill', true);
  2775. $library = $this->input->post('library', true);
  2776. $country = $this->input->post('country', true);
  2777. $so = $this->input->post('so', true);
  2778. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2779. $print = $this->input->post('print', true);
  2780. $state = $this->input->post('state', true);
  2781. $orderurl = $this->input->post('orderurl', true);
  2782. $timetk = strtotime($timetk);
  2783. $timetj = strtotime($timetj);
  2784. /**
  2785. $sj = $this->input->post('sj',true);
  2786. if($sj)
  2787. {
  2788. $sj = $this->input->post('sj',true);
  2789. }
  2790. else
  2791. {
  2792. $sj = "fullorder";
  2793. }
  2794. **/
  2795. $sj = "fullorderamz";
  2796. $where = "1=1";
  2797. if ($warehouse) {
  2798. $where .= " and type = '$warehouse'";
  2799. }
  2800. if ($timetk && $timetj) {
  2801. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2802. }
  2803. if ($orderinfo) {
  2804. $where .= " and orderinfo = '$orderinfo'";
  2805. }
  2806. if ($number) {
  2807. $where .= " and number = '$number'";
  2808. }
  2809. if ($express) {
  2810. $where .= " and express = '$express'";
  2811. }
  2812. if ($waybill) {
  2813. $where .= " and waybill = '$waybill'";
  2814. }
  2815. if ($library) {
  2816. $where .= " and library = '$library'";
  2817. }
  2818. if ($print) {
  2819. $where .= " and print = '$print'";
  2820. }
  2821. if ($libraryconfirm) {
  2822. $where .= " and libraryconfirm = '$libraryconfirm'";
  2823. }
  2824. if ($state) {
  2825. $where .= " and state = '$state'";
  2826. }
  2827. if ($shop) {
  2828. $where .= " and shop = '$shop'";
  2829. }
  2830. if ($country) {
  2831. $where .= " and country = '$country'";
  2832. }
  2833. if ($sfxh != '') {
  2834. $where .= " and sfxh = '$sfxh'";
  2835. }
  2836. if ($so) {
  2837. $where .= " and shipremarks like '%$so%'";
  2838. }
  2839. if ($source) {
  2840. if ($source == '2d') {
  2841. $where .= " and source >= '2'";
  2842. } else {
  2843. $where .= " and source = '$source'";
  2844. }
  2845. }
  2846. if (isset($_SESSION['api'])) {
  2847. foreach ($user as $value) {
  2848. $fgshop .= " shop = " . $value . " or";
  2849. }
  2850. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2851. }
  2852. if ($orderurl) {
  2853. $url = $this->orderurl->read($orderurl);
  2854. $where .= " and link like '%" . $url['url'] . "%'";
  2855. }
  2856. //数据排序
  2857. $order_str = "librarytime desc";
  2858. if (empty($page)) {
  2859. $start = 0;
  2860. $perpage = 1;
  2861. } else {
  2862. $start = ($page - 1) * $perpage;
  2863. }
  2864. //取得信息列表
  2865. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2866. //格式化数据
  2867. foreach ($info_list as $key => $value) {
  2868. $shop = $this->shop->read($value['shop']);
  2869. $info_list[$key]['shop'] = $shop['shopname'];
  2870. $express = $this->express->read($value['express']);
  2871. $info_list[$key]['express'] = $express['servicename'];
  2872. $warehouse = $this->warehouse->read($value['type']);
  2873. $info_list[$key]['type'] = $warehouse['title'];
  2874. if ($value['librarytime'] == '0') {
  2875. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2876. } else {
  2877. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2878. }
  2879. }
  2880. $total = $this->$sj->find_count($where);
  2881. $pagenum = ceil($total / $perpage);
  2882. $over = $total - ($start + $perpage);
  2883. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2884. echo json_encode($rows);
  2885. exit;
  2886. }
  2887. $this->data['express'] = $this->express->find_all();
  2888. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2889. $this->data['wlshop'] = $wlshop;
  2890. $user = $this->user->get_api($_SESSION['api']);
  2891. $powerid = $this->power->read($user['power']);
  2892. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2893. $pid = '';
  2894. foreach ($powertext as $v) {
  2895. $pid .= " id = " . $v . " or";
  2896. }
  2897. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2898. $this->data['fullorderexcel'] = $fullorderexcel;
  2899. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2900. $this->data['orderurl'] = $orderurl;
  2901. $this->_Template('whlabel_aoutorder', $this->data);
  2902. }
  2903. //速卖通出库订单
  2904. public function _soutorder()
  2905. {
  2906. if (isset($_SESSION['api'])) {
  2907. $user = $this->user->get_api($_SESSION['api']);
  2908. $usp = $user;
  2909. $fgshop = "";
  2910. $sid = "";
  2911. $user = explode('|', trim($user['shop'], '|'));
  2912. foreach ($user as $value) {
  2913. $sid .= " id = " . $value . " or";
  2914. }
  2915. }
  2916. $post = $this->input->post(NULL, TRUE);
  2917. if (isset($post['page'])) {
  2918. $page = $this->input->post('page', true);
  2919. $perpage = $this->input->post('perpage', true);
  2920. $warehouse = $this->input->post('warehouse', true);
  2921. $xztime = $this->input->post('xztime', true);
  2922. $timetk = $this->input->post('timetkk', true);
  2923. $timetj = $this->input->post('timetjj', true);
  2924. $shop = $this->input->post('shop', true);
  2925. $source = $this->input->post('source', true);
  2926. $orderinfo = $this->input->post('orderinfo', true);
  2927. $number = $this->input->post('number', true);
  2928. $express = $this->input->post('express', true);
  2929. $waybill = $this->input->post('waybill', true);
  2930. $library = $this->input->post('library', true);
  2931. $country = $this->input->post('country', true);
  2932. $sfxh = $this->input->post('sfxh', true);
  2933. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2934. $print = $this->input->post('print', true);
  2935. $state = $this->input->post('state', true);
  2936. $so = $this->input->post('so', true);
  2937. $timetk = strtotime($timetk);
  2938. $timetj = strtotime($timetj);
  2939. /**
  2940. $sj = $this->input->post('sj',true);
  2941. if($sj)
  2942. {
  2943. $sj = $this->input->post('sj',true);
  2944. }
  2945. else
  2946. {
  2947. $sj = "fullorder";
  2948. }
  2949. **/
  2950. $sj = "fullordersmt";
  2951. $where = "1=1";
  2952. if ($warehouse) {
  2953. $where .= " and type = '$warehouse'";
  2954. }
  2955. if ($timetk && $timetj) {
  2956. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2957. }
  2958. if ($orderinfo) {
  2959. $where .= " and orderinfo = '$orderinfo'";
  2960. }
  2961. if ($number) {
  2962. $where .= " and number = '$number'";
  2963. }
  2964. if ($express) {
  2965. $where .= " and express = '$express'";
  2966. }
  2967. if ($waybill) {
  2968. $where .= " and waybill = '$waybill'";
  2969. }
  2970. if ($library) {
  2971. $where .= " and library = '$library'";
  2972. }
  2973. if ($print) {
  2974. $where .= " and print = '$print'";
  2975. }
  2976. if ($libraryconfirm) {
  2977. $where .= " and libraryconfirm = '$libraryconfirm'";
  2978. }
  2979. if ($state) {
  2980. $where .= " and state = '$state'";
  2981. }
  2982. if ($shop) {
  2983. $where .= " and shop = '$shop'";
  2984. }
  2985. if ($sfxh != '') {
  2986. $where .= " and sfxh = '$sfxh'";
  2987. }
  2988. if ($so) {
  2989. $where .= " and shipremarks like '%$so%'";
  2990. }
  2991. if ($source) {
  2992. $where .= " and source = '$source'";
  2993. }
  2994. if ($country) {
  2995. $where .= " and country = '$country'";
  2996. } else {
  2997. if (isset($_SESSION['api'])) {
  2998. foreach ($user as $value) {
  2999. $fgshop .= " shop = " . $value . " or";
  3000. }
  3001. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3002. }
  3003. }
  3004. //数据排序
  3005. $order_str = "librarytime desc";
  3006. if (empty($page)) {
  3007. $start = 0;
  3008. $perpage = 1;
  3009. } else {
  3010. $start = ($page - 1) * $perpage;
  3011. }
  3012. //取得信息列表
  3013. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3014. //格式化数据
  3015. foreach ($info_list as $key => $value) {
  3016. $shop = $this->shop->read($value['shop']);
  3017. $info_list[$key]['shop'] = $shop['shopname'];
  3018. $express = $this->express->read($value['express']);
  3019. $info_list[$key]['express'] = $express['servicename'];
  3020. $warehouse = $this->warehouse->read($value['type']);
  3021. $info_list[$key]['type'] = $warehouse['title'];
  3022. if ($value['librarytime'] == '0') {
  3023. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3024. } else {
  3025. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3026. }
  3027. }
  3028. $total = $this->$sj->find_count($where);
  3029. $pagenum = ceil($total / $perpage);
  3030. $over = $total - ($start + $perpage);
  3031. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3032. echo json_encode($rows);
  3033. exit;
  3034. }
  3035. $this->data['express'] = $this->express->find_all();
  3036. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3037. $this->data['wlshop'] = $wlshop;
  3038. $user = $this->user->get_api($_SESSION['api']);
  3039. $powerid = $this->power->read($user['power']);
  3040. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3041. $pid = '';
  3042. foreach ($powertext as $v) {
  3043. $pid .= " id = " . $v . " or";
  3044. }
  3045. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3046. $this->data['fullorderexcel'] = $fullorderexcel;
  3047. $this->_Template('whlabel_soutorder', $this->data);
  3048. }
  3049. //订单退库
  3050. public function _retreat()
  3051. {
  3052. $post = $this->input->post(NULL, TRUE);
  3053. if (isset($post['page'])) {
  3054. $page = $this->input->post('page', true);
  3055. $perpage = $this->input->post('perpage', true);
  3056. $warehouse = $this->input->post('warehouse', true);
  3057. $timetk = $this->input->post('timetk', true);
  3058. $timetj = $this->input->post('timetj', true);
  3059. $shop = $this->input->post('shop', true);
  3060. $source = $this->input->post('source', true);
  3061. $state = $this->input->post('state', true);
  3062. $review = $this->input->post('review', true);
  3063. $state = $this->input->post('state', true);
  3064. $express = $this->input->post('express', true);
  3065. $orderinfo = $this->input->post('orderinfo', true);
  3066. $user = $this->input->post('user', true);
  3067. $name = $this->input->post('name', true);
  3068. $waybill = $this->input->post('waybill', true);
  3069. $timetk = strtotime($timetk);
  3070. $timetj = strtotime($timetj);
  3071. $where = "(state=206 or state=210) and mergeid = 0";
  3072. if ($warehouse) {
  3073. $where .= " and state = '$warehouse'";
  3074. }
  3075. if ($timetk && $timetj) {
  3076. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3077. }
  3078. if ($shop) {
  3079. $where .= " and shop = '$shop'";
  3080. }
  3081. if ($source) {
  3082. $where .= " and source = '$source'";
  3083. }
  3084. if ($state) {
  3085. $where .= " and state = '$state'";
  3086. }
  3087. if ($review) {
  3088. $where .= " and review = '$review'";
  3089. }
  3090. if ($state) {
  3091. $where .= " and state = '$state'";
  3092. }
  3093. if ($express) {
  3094. $where .= " and express = '$express'";
  3095. }
  3096. if ($orderinfo) {
  3097. $where .= " and orderinfo = '$orderinfo'";
  3098. }
  3099. if ($user) {
  3100. $where .= " and user = '$user'";
  3101. }
  3102. if ($name) {
  3103. $where .= " and name = '$name'";
  3104. }
  3105. if ($waybill) {
  3106. $where .= " and waybill = '$waybill'";
  3107. }
  3108. //数据排序
  3109. $order_str = "id desc";
  3110. if (empty($page)) {
  3111. $start = 0;
  3112. $perpage = 1;
  3113. } else {
  3114. $start = ($page - 1) * $perpage;
  3115. }
  3116. //取得信息列表
  3117. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3118. //格式化数据
  3119. foreach ($info_list as $key => $value) {
  3120. $shop = $this->shop->read($value['shop']);
  3121. $info_list[$key]['shop'] = $shop['shopname'];
  3122. $warehouse = $this->warehouse->read($value['warehouse']);
  3123. $info_list[$key]['warehouse'] = $warehouse['title'];
  3124. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3125. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3126. if ($value['waybill'] == 0) {
  3127. $info_list[$key]['waybill'] = "";
  3128. }
  3129. $express = $this->express->read($value['express']);
  3130. $info_list[$key]['express'] = $express['title'];
  3131. $typeclass = $this->typeclass->read($value['state']);
  3132. $info_list[$key]['state'] = $typeclass['title'];
  3133. }
  3134. $total = $this->fullorder->find_count($where);
  3135. $pagenum = ceil($total / $perpage);
  3136. $over = $total - ($start + $perpage);
  3137. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3138. echo json_encode($rows);
  3139. exit;
  3140. }
  3141. $this->data['express'] = $this->express->find_all();
  3142. $this->_Template('whlabel_retreat', $this->data);
  3143. }
  3144. //退库标签浏览
  3145. public function _retreatlk()
  3146. {
  3147. $post = $this->input->post(NULL, TRUE);
  3148. if (isset($post['page'])) {
  3149. $page = $this->input->post('page', true);
  3150. $perpage = $this->input->post('perpage', true);
  3151. $timetk = $this->input->post('timetk', true);
  3152. $timetj = $this->input->post('timetj', true);
  3153. $sku = $this->input->post('sku', true);
  3154. $warehouse = $this->input->post('warehouse', true);
  3155. $purchase = $this->input->post('purchase', true);
  3156. $orderinfo = $this->input->post('orderinfo', true);
  3157. $waybill = $this->input->post('waybill', true);
  3158. $category = $this->input->post('category', true);
  3159. $size = $this->input->post('size', true);
  3160. $grade = $this->input->post('grade', true);
  3161. $color = $this->input->post('color', true);
  3162. $lowe = $this->input->post('lowe', true);
  3163. $state = $this->input->post('state', true);
  3164. $timetk = strtotime($timetk);
  3165. $timetj = strtotime($timetj);
  3166. $where = "state=2";
  3167. if ($timetk && $timetj) {
  3168. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3169. }
  3170. if ($sku) {
  3171. $where .= " and sku = '$sku'";
  3172. }
  3173. if ($warehouse) {
  3174. $where .= " and warehouse = '$warehouse'";
  3175. }
  3176. if ($purchase) {
  3177. $where .= " and purchase = '$purchase'";
  3178. }
  3179. if ($orderinfo) {
  3180. $where .= " and orderinfo = '$orderinfo'";
  3181. }
  3182. if ($waybill) {
  3183. $where .= " and waybill = '$waybill'";
  3184. }
  3185. if ($category) {
  3186. $where .= " and features like '%-$category-%'";
  3187. }
  3188. if ($size) {
  3189. $where .= " and features like '%-$size-%'";
  3190. }
  3191. if ($grade) {
  3192. $where .= " and features like '%-$grade-%'";
  3193. }
  3194. if ($color) {
  3195. $where .= " and features like '%-$color-%'";
  3196. }
  3197. if ($lowe) {
  3198. $where .= " and features like '%-$lowe-%'";
  3199. }
  3200. //数据排序
  3201. $order_str = "time desc";
  3202. if (empty($page)) {
  3203. $start = 0;
  3204. $perpage = 1;
  3205. } else {
  3206. $start = ($page - 1) * $perpage;
  3207. }
  3208. //取得信息列表
  3209. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3210. foreach ($info_list as $key => $value) {
  3211. $warehouse = $this->warehouse->read($value['warehouse']);
  3212. $info_list[$key]['warehouse'] = $warehouse['title'];
  3213. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3214. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3215. $purchase = $this->purchase->read($value['purchase']);
  3216. $info_list[$key]['purchase'] = $purchase['title'];
  3217. if ($value['outk'] != 0) {
  3218. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3219. } else {
  3220. $info_list[$key]['outk'] = "";
  3221. }
  3222. if ($value['retreat'] != 0) {
  3223. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3224. } else {
  3225. $info_list[$key]['retreat'] = "";
  3226. }
  3227. if ($value['orderinfo'] == 0) {
  3228. $info_list[$key]['orderinfo'] = "";
  3229. }
  3230. if ($value['waybill'] == 0) {
  3231. $info_list[$key]['waybill'] = "";
  3232. }
  3233. }
  3234. $total = $this->whlabel->find_count($where);
  3235. $pagenum = ceil($total / $perpage);
  3236. $over = $total - ($start + $perpage);
  3237. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3238. echo json_encode($rows);
  3239. exit;
  3240. }
  3241. $this->_Template('whlabel_retreatlk', $this->data);
  3242. }
  3243. //更换标签及浏览
  3244. public function _change()
  3245. {
  3246. $post = $this->input->post(NULL, TRUE);
  3247. if (isset($post['page'])) {
  3248. $page = $this->input->post('page', true);
  3249. $perpage = $this->input->post('perpage', true);
  3250. $timetk = $this->input->post('timetk', true);
  3251. $timetj = $this->input->post('timetj', true);
  3252. $label = $this->input->post('label', true);
  3253. $oldlabel = $this->input->post('oldlabel', true);
  3254. $timetk = strtotime($timetk);
  3255. $timetj = strtotime($timetj);
  3256. $where = "state=10 ";
  3257. if ($timetk && $timetj) {
  3258. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3259. }
  3260. if ($label) {
  3261. $where .= " and label = '$label'";
  3262. }
  3263. if ($oldlabel) {
  3264. $where .= " and oldlabel = '$oldlabel'";
  3265. }
  3266. //数据排序
  3267. $order_str = "time asc";
  3268. if (empty($page)) {
  3269. $start = 0;
  3270. $perpage = 1;
  3271. } else {
  3272. $start = ($page - 1) * $perpage;
  3273. }
  3274. //取得信息列表
  3275. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3276. foreach ($info_list as $key => $value) {
  3277. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3278. }
  3279. $total = $this->whlabel->find_count($where);
  3280. $pagenum = ceil($total / $perpage);
  3281. $over = $total - ($start + $perpage);
  3282. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3283. echo json_encode($rows);
  3284. exit;
  3285. }
  3286. $this->_Template('whlabel_change', $this->data);
  3287. }
  3288. //产品标签
  3289. public function _cpbqdc()
  3290. {
  3291. if (isset($_GET['excel'])) {
  3292. $where = "1=1";
  3293. //数据排序
  3294. $order_str = "id desc";
  3295. if (empty($page)) {
  3296. $start = 0;
  3297. $perpage = 1;
  3298. } else {
  3299. $start = ($page - 1) * $perpage;
  3300. }
  3301. $warehouse = $this->input->get('warehouse', true);
  3302. $state = $this->input->get('state', true);
  3303. $timetk = $this->input->get('timetkk', true);
  3304. $timetj = $this->input->get('timetjj', true);
  3305. $timetk = strtotime($timetk);
  3306. $timetj = strtotime($timetj);
  3307. if ($warehouse) {
  3308. $where .= " and warehouse = '$warehouse'";
  3309. }
  3310. if ($state || $state == 0) {
  3311. $where .= " and state = '$state'";
  3312. }
  3313. if ($timetk && $timetj) {
  3314. $where .= " and time > '$timetk' and time < '$timetj'";
  3315. }
  3316. //取得信息列表
  3317. $info_list = $this->whlabel->find_all($where, '*');
  3318. $rows = array();
  3319. $list = array();
  3320. foreach ($info_list as $key => $value) {
  3321. $rows[$value['time']] = $value; //所有数据sku
  3322. }
  3323. foreach ($rows as $value) {
  3324. $warehouse = $this->warehouse->read($value['warehouse']);
  3325. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3326. $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);
  3327. }
  3328. $title = "产品标签统计表";
  3329. $titlename = "<table border=1>
  3330. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3331. <tr align='center'>
  3332. <td>仓库</td>
  3333. <td>SKU</td>
  3334. <td>产品</td>
  3335. <td>入库时间</td>
  3336. <td>操作时间</td>
  3337. <td>备注</td>
  3338. <td>数量</td>
  3339. </tr>
  3340. </table>";
  3341. $filename = $title . ".xls";
  3342. $tail = "";
  3343. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3344. }
  3345. }
  3346. //进销存导出
  3347. public function _exceljxc()
  3348. {
  3349. $classid = $this->classid->sku();
  3350. $pm = $classid;
  3351. $typeclass = array();
  3352. $tc = $this->typeclass->find_all();
  3353. foreach ($tc as $v) {
  3354. $typeclass[$v['id']] = $v;
  3355. }
  3356. $prc = array();
  3357. $purchase = $this->purchase->find_all();
  3358. foreach ($purchase as $k => $v) {
  3359. $prc[$v['id']] = $v['title'];
  3360. }
  3361. if (isset($_GET['excel'])) {
  3362. $where = "sku != 'Preset'";
  3363. //数据排序
  3364. $order_str = "id desc";
  3365. if (empty($page)) {
  3366. $start = 0;
  3367. $perpage = 1;
  3368. } else {
  3369. $start = ($page - 1) * $perpage;
  3370. }
  3371. $category = $this->input->get('category', true);
  3372. $warehouse = $this->input->get('warehouse', true);
  3373. $excelid = $this->input->get('sid', true);
  3374. if ($category) {
  3375. $where .= " and features like '%-$category-%'";
  3376. }
  3377. if ($warehouse) {
  3378. $where .= " and warehouse = '$warehouse'";
  3379. }
  3380. $xzid = '';
  3381. if ($excelid) {
  3382. $excelid = explode(',', trim($excelid, ','));
  3383. foreach ($excelid as $key => $value) {
  3384. $xzid .= " id = " . $value . " or";
  3385. }
  3386. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3387. }
  3388. //取得信息列表
  3389. /**
  3390. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3391. $rows = array();$list = array();
  3392. foreach ($info_list as $key=>$value)
  3393. {
  3394. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3395. }
  3396. **/
  3397. $wt = array();
  3398. $whlabel_type = $this->whlabel_type->find_all();
  3399. foreach ($whlabel_type as $v) {
  3400. $wt[$v['id']] = $v['title'];
  3401. }
  3402. $wh = array();
  3403. $w = $this->warehouse->find_all('1=1', 'id,title');
  3404. foreach ($w as $v) {
  3405. $wh[$v['id']] = $v['title'];
  3406. }
  3407. $list = array();
  3408. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3409. foreach ($rows as $key => $value) {
  3410. if (isset($wt[$value['type']])) {
  3411. $rows[$key]['type'] = $wt[$value['type']];
  3412. } else {
  3413. $rows[$key]['type'] = '未设置';
  3414. }
  3415. $bm = '03';
  3416. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3417. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3418. $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');
  3419. $details = array();
  3420. $cpid = array();
  3421. $cpbz = array();
  3422. $c = 0;
  3423. $g = 0;
  3424. $x = 0;
  3425. $t = 0;
  3426. $s = 0;
  3427. $q = 0;
  3428. foreach ($sd as $k => $v) {
  3429. if ($v['state'] == 0) {
  3430. $c++;
  3431. if ($v['cpid'] != 0) {
  3432. $cpid[$v['cpid']] = $v['cpid'];
  3433. }
  3434. if ($v['cpbz'] != '') {
  3435. $cpbz[$v['cpbz']] = $v['cpbz'];
  3436. }
  3437. }
  3438. if ($v['state'] != 9) {
  3439. $g++;
  3440. }
  3441. if ($v['state'] == 1) {
  3442. $x++;
  3443. }
  3444. if ($v['state'] == 2) {
  3445. $t++;
  3446. }
  3447. if ($v['state'] == 8) {
  3448. $s++;
  3449. }
  3450. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3451. $q++;
  3452. }
  3453. $details[$v['details']] = $v['details'];
  3454. }
  3455. $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'] . '"');
  3456. $rows[$key]['details'] = implode("、", $details);
  3457. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3458. $number = $value['number'];
  3459. $ftime = time() - 15 * 24 * 3600;
  3460. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3461. $rows[$key]['number'] = $g;
  3462. $rows[$key]['c'] = $c;
  3463. $rows[$key]['x'] = $x;
  3464. $rows[$key]['t'] = $t;
  3465. $rows[$key]['s'] = $s;
  3466. $rows[$key]['q'] = $q;
  3467. $rows[$key]['z'] = $z;
  3468. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3469. $features = explode('-', trim($features, '-'));
  3470. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3471. // $pm = $classid;
  3472. // $jm = $classid;
  3473. // foreach($features as $k=>$v)
  3474. // {
  3475. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3476. // {
  3477. // if($typeclass[$v]['bm'] != '')
  3478. // {
  3479. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3480. // }
  3481. // }
  3482. // if($v != 0)
  3483. // {
  3484. // if(!isset($typeclass[$v]))
  3485. // {
  3486. // continue;
  3487. // }
  3488. // if(isset($pm[$typeclass[$v]['classid']]))
  3489. // {
  3490. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3491. // {
  3492. // $tz = explode('|',$typeclass[$v]['zh']);
  3493. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3494. // }
  3495. // else
  3496. // {
  3497. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3498. // }
  3499. // }
  3500. // if(isset($jm[$typeclass[$v]['classid']]))
  3501. // {
  3502. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3503. // }
  3504. // }
  3505. // }
  3506. // $jm = array_filter($jm);
  3507. // $rows[$key]['bs'] = implode("-",$jm);
  3508. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3509. // $zh = implode(" ",$pm);
  3510. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3511. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3512. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3513. // $rows[$key]['features'] = $zh;
  3514. }
  3515. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3516. $final_list = [];
  3517. foreach ($list as $k => $v) {
  3518. if (empty($v['sku'])) {
  3519. continue;
  3520. }
  3521. $final_list[] = [
  3522. "warehouse" => $v["warehouse"],
  3523. "purchase" => $v["purchase"],
  3524. "details" => $v["details"],
  3525. "cpid" => $v["cpid"],
  3526. "dbcontent" => $v["dbcontent"],
  3527. "sku" => $v["sku"],
  3528. "cs" => $v["bm"],
  3529. "bs" => $v["jm"],
  3530. "title" => $v["title"],
  3531. "features" => $v["pm"],
  3532. "cpbz" => $v["cpbz"],
  3533. "sm" => $v["sm"],
  3534. "type" => $v["type"],
  3535. "number" => $v["number"],
  3536. "c" => $v["c"],
  3537. "x" => $v["x"],
  3538. "t" => $v["t"],
  3539. "s" => $v["s"],
  3540. "q" => $v["q"],
  3541. "z" => $v["z"],
  3542. "weight" => $v['weight'],
  3543. ];
  3544. }
  3545. $title = "总进销存统计表";
  3546. $titlename = "<table border=1>
  3547. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3548. <tr align='center'>
  3549. <td>仓库</td>
  3550. <td>供应商</td>
  3551. <td>位置</td>
  3552. <td>库存编码</td>
  3553. <td>类目</td>
  3554. <td>SKU</td>
  3555. <td>用友编码</td>
  3556. <td>用友料号</td>
  3557. <td>商品名称</td>
  3558. <td>商品中文</td>
  3559. <td>产品备注</td>
  3560. <td>说明</td>
  3561. <td>类型</td>
  3562. <td>入库总量</td>
  3563. <td>库存数量</td>
  3564. <td>销售数量</td>
  3565. <td>退货数量</td>
  3566. <td>删除数量</td>
  3567. <td>其它操作</td>
  3568. <td>占单数量</td>
  3569. <td>重量(g)</td>
  3570. </tr>
  3571. </table>";
  3572. $filename = $title . ".xls";
  3573. $tail = "";
  3574. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3575. }
  3576. }
  3577. //入库导出
  3578. public function _excelr()
  3579. {
  3580. if (isset($_GET['excel'])) {
  3581. $category = $this->input->get('category', true);
  3582. $size = $this->input->get('size', true);
  3583. $grade = $this->input->get('grade', true);
  3584. $color = $this->input->get('color', true);
  3585. $lowe = $this->input->get('lowe', true);
  3586. $sku = $this->input->get('sku', true);
  3587. $warehouse = $this->input->get('warehouse', true);
  3588. $purchase = $this->input->get('purchase', true);
  3589. $ktime = $this->input->get('ktime', true);
  3590. $jtime = $this->input->get('jtime', true);
  3591. $ktime = strtotime($ktime);
  3592. $jtime = strtotime($jtime);
  3593. $where = "1=1";
  3594. $gj = "";
  3595. $ck = "";
  3596. if ($category) {
  3597. $where .= " and features like '%-$category-%'";
  3598. }
  3599. if ($size) {
  3600. $where .= " and features like '%-$size-%'";
  3601. }
  3602. if ($grade) {
  3603. $where .= " and features like '%-$grade-%'";
  3604. }
  3605. if ($color) {
  3606. $where .= " and features like '%-$color-%'";
  3607. }
  3608. if ($lowe) {
  3609. $where .= " and features like '%-$lowe-%'";
  3610. }
  3611. if ($warehouse) {
  3612. $where .= " and warehouse = '$warehouse'";
  3613. }
  3614. if ($purchase) {
  3615. $where .= " and purchase = '$purchase'";
  3616. }
  3617. if ($sku) {
  3618. $where .= " and sku = '$sku'";
  3619. }
  3620. if ($ktime && $jtime) {
  3621. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3622. }
  3623. //数据排序
  3624. $order_str = "id desc";
  3625. if (empty($page)) {
  3626. $start = 0;
  3627. $perpage = 1;
  3628. } else {
  3629. $start = ($page - 1) * $perpage;
  3630. }
  3631. $list = array();
  3632. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3633. foreach ($rows as $value) {
  3634. $ck = $this->warehouse->read($value['warehouse']);
  3635. $warehouse = $ck['title'];
  3636. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3637. $retreatwarehouse = $tkck['title'];
  3638. $gy = $this->purchase->read($value['purchase']);
  3639. $purchase = $gy['title'];
  3640. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3641. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3642. }
  3643. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3644. $titlename = "<table border=1>
  3645. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3646. <tr align='center'>
  3647. <td>仓库</td>
  3648. <td>SKU</td>
  3649. <td>产品</td>
  3650. <td>时间</td>
  3651. <td>数量</td>
  3652. </tr>
  3653. </table>";
  3654. $filename = $title . ".xls";
  3655. $tail = "";
  3656. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3657. }
  3658. }
  3659. //出库、退库导出
  3660. public function _excelct()
  3661. {
  3662. $classid = $this->classid->sku();
  3663. $pm = $classid;
  3664. $typeclass = array();
  3665. $tc = $this->typeclass->find_all();
  3666. foreach ($tc as $v) {
  3667. $typeclass[$v['id']] = $v;
  3668. }
  3669. $prc = array();
  3670. $purchase = $this->purchase->find_all();
  3671. foreach ($purchase as $k => $v) {
  3672. $prc[$v['id']] = $v['title'];
  3673. }
  3674. if (isset($_GET['excel'])) {
  3675. $wh = array();
  3676. $w = $this->warehouse->find_all('1=1', 'id,title');
  3677. foreach ($w as $v) {
  3678. $wh[$v['id']] = $v['title'];
  3679. }
  3680. $type = $this->input->get('excel', true);
  3681. $category = $this->input->get('category', true);
  3682. $size = $this->input->get('size', true);
  3683. $grade = $this->input->get('grade', true);
  3684. $color = $this->input->get('color', true);
  3685. $lowe = $this->input->get('lowe', true);
  3686. $sku = $this->input->get('sku', true);
  3687. $title = $this->input->get('title', true);
  3688. $warehouse = $this->input->get('warehouse', true);
  3689. $purchase = $this->input->get('purchase', true);
  3690. $lacetype = $this->input->get('lacetype', true);
  3691. $haircap = $this->input->get('haircap', true);
  3692. $lacecolor = $this->input->get('lacecolor', true);
  3693. $density = $this->input->get('density', true);
  3694. $details = $this->input->get('details', true);
  3695. $state = $this->input->get('state', true);
  3696. $shop = $this->input->get('shop', true);
  3697. $hairnumber = $this->input->get('hairnumber', true);
  3698. $type_leixi = $this->input->get('type', true);
  3699. $cpbz = $this->input->get('cpbz', true);
  3700. $sm = $this->input->get('sm', true);
  3701. $sid = $this->input->get('sid', true);
  3702. $ktime = $this->input->get('ktime', true);
  3703. $jtime = $this->input->get('jtime', true);
  3704. $ktime = strtotime($ktime);
  3705. $jtime = strtotime($jtime);
  3706. //$where = " 1=1 ";
  3707. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3708. $where = " sku != '' ";
  3709. $gj = "";
  3710. $ck = "";
  3711. if ($category) {
  3712. $where .= " and features like '%-$category-%'";
  3713. }
  3714. if ($size) {
  3715. $where .= " and features like '%-$size-%'";
  3716. }
  3717. if ($grade) {
  3718. $where .= " and features like '%-$grade-%'";
  3719. }
  3720. if ($color) {
  3721. $where .= " and features like '%-$color-%'";
  3722. }
  3723. if ($lowe) {
  3724. $where .= " and features like '%-$lowe-%'";
  3725. }
  3726. if ($warehouse) {
  3727. $where .= " and warehouse = '$warehouse'";
  3728. }
  3729. if ($purchase) {
  3730. $where .= " and purchase = '$purchase'";
  3731. }
  3732. if ($state) {
  3733. $where .= " and state = '$state'";
  3734. }
  3735. if ($lacetype) {
  3736. $where .= " and features like '%-$lacetype-%'";
  3737. }
  3738. if ($lacecolor) {
  3739. $where .= " and features like '%-$lacecolor-%'";
  3740. }
  3741. if ($density) {
  3742. $where .= " and features like '%-$density-%'";
  3743. }
  3744. if ($haircap) {
  3745. $where .= " and features like '%-$haircap-%'";
  3746. }
  3747. if ($details) {
  3748. $where .= " and details = '$details'";
  3749. }
  3750. if ($shop) {
  3751. $where .= " and shop like '%$shop%'";
  3752. }
  3753. if ($title) {
  3754. $title = trim($title, ' ');
  3755. $title = trim($title, ' ');
  3756. $where .= " and title like '%$title%'";
  3757. }
  3758. if (!empty($hairnumber)) {
  3759. $where .= " and features like '%-128-%' ";
  3760. if ($hairnumber < 0) {
  3761. $class_list = $this->typeclass->find_all('classid = 43');
  3762. foreach ($class_list as $v) {
  3763. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3764. }
  3765. } else {
  3766. $where .= " and features like '%-$hairnumber-%'";
  3767. }
  3768. }
  3769. if ($type_leixi) {
  3770. $where .= " and type = '$type_leixi'";
  3771. }
  3772. if ($cpbz) {
  3773. $where .= " and cpbz like '%$cpbz%' ";
  3774. }
  3775. if ($sm) {
  3776. $where .= " and sm like '%$sm%' ";
  3777. }
  3778. if ($sku) {
  3779. $sku = trim($sku, ' ');
  3780. $sku = trim($sku, ' ');
  3781. $where .= " and sku like '%$sku%'";
  3782. }
  3783. if ($ktime && $jtime) {
  3784. if ($type == 1) {
  3785. $tl = '出库';
  3786. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3787. } else if ($type == 2) {
  3788. $tl = '退库';
  3789. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3790. } else if ($type == 3) {
  3791. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3792. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3793. } else if ($type == 4) {
  3794. $tl = '出库+零售';
  3795. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3796. } else if ($type == 5) {
  3797. $tl = '零售';
  3798. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3799. }
  3800. }
  3801. $sidwhere = '';
  3802. if ($sid) {
  3803. $sd = "";
  3804. $s = explode(',', trim($sid, ','));
  3805. foreach ($s as $value) {
  3806. $sd .= " id = " . $value . " or";
  3807. }
  3808. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3809. }
  3810. //数据排序
  3811. $order_str = "time desc";
  3812. if (empty($page)) {
  3813. $start = 0;
  3814. $perpage = 1;
  3815. } else {
  3816. $start = ($page - 1) * $perpage;
  3817. }
  3818. //取得信息列表
  3819. if ($type != 3 && $type != 5) {
  3820. if ($type == 1 || $type == 4) {
  3821. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3822. foreach ($info_list as $key => $value) {
  3823. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3824. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3825. $warehouse = $this->warehouse->read($value['warehouse']);
  3826. $info_list[$key]['warehouse'] = $warehouse['title'];
  3827. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3828. $features = explode('-', trim($features, '-'));
  3829. $pm = $classid;
  3830. foreach ($features as $k => $v) {
  3831. if ($v != 0) {
  3832. if (!isset($typeclass[$v])) {
  3833. continue;
  3834. }
  3835. if (isset($pm[$typeclass[$v]['classid']])) {
  3836. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3837. $tz = explode('|', $typeclass[$v]['zh']);
  3838. $pm[$typeclass[$v]['classid']] = $tz[0];
  3839. } else {
  3840. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3841. }
  3842. }
  3843. }
  3844. }
  3845. $zh = implode(" ", $pm);
  3846. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3847. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3848. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3849. $info_list[$key]['features'] = $zh;
  3850. }
  3851. $final_list = [];
  3852. foreach($info_list as $k=>$v){
  3853. $number = "";
  3854. if(!empty($v['orderinfo'])){
  3855. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3856. if(!empty($tmp_info['number'])){
  3857. $number = $tmp_info['number'];
  3858. }
  3859. }
  3860. $final_list[] = [
  3861. 'warehouse'=>$v['warehouse'],
  3862. 'purchase'=>$v['purchase'],
  3863. 'sku'=>$v['sku'],
  3864. 'title'=>$v['title'],
  3865. 'features'=>$v['features'],
  3866. 'label'=>$v['label'],
  3867. 'orderinfo'=>$v['orderinfo'],
  3868. 'number'=>$number,
  3869. 'waybill'=>$v['waybill'],
  3870. 'outk'=>$v['outk'],
  3871. ];
  3872. }
  3873. } else {
  3874. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3875. foreach ($info_list as $key => $value) {
  3876. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3877. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3878. $warehouse = $this->warehouse->read($value['warehouse']);
  3879. $info_list[$key]['warehouse'] = $warehouse['title'];
  3880. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3881. $features = explode('-', trim($features, '-'));
  3882. $pm = $classid;
  3883. foreach ($features as $k => $v) {
  3884. if ($v != 0) {
  3885. if (!isset($typeclass[$v])) {
  3886. continue;
  3887. }
  3888. if (isset($pm[$typeclass[$v]['classid']])) {
  3889. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3890. $tz = explode('|', $typeclass[$v]['zh']);
  3891. $pm[$typeclass[$v]['classid']] = $tz[0];
  3892. } else {
  3893. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3894. }
  3895. }
  3896. }
  3897. }
  3898. $zh = implode(" ", $pm);
  3899. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3900. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3901. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3902. $info_list[$key]['features'] = $zh;
  3903. }
  3904. $final_list = [];
  3905. foreach($info_list as $k=>$v){
  3906. $number = "";
  3907. if(!empty($v['orderinfo'])){
  3908. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3909. if(!empty($tmp_info['number'])){
  3910. $number = $tmp_info['number'];
  3911. }
  3912. }
  3913. $final_list[] = [
  3914. 'warehouse'=>$v['warehouse'],
  3915. 'purchase'=>$v['purchase'],
  3916. 'sku'=>$v['sku'],
  3917. 'title'=>$v['title'],
  3918. 'features'=>$v['features'],
  3919. 'label'=>$v['label'],
  3920. 'orderinfo'=>$v['orderinfo'],
  3921. 'number'=>$number,
  3922. 'waybill'=>$v['waybill'],
  3923. 'retreat'=>$v['retreat'],
  3924. ];
  3925. }
  3926. }
  3927. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3928. $titlename = "<table border=1>
  3929. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3930. <tr align='center'>
  3931. <td>仓库</td>
  3932. <td>供应商</td>
  3933. <td>SKU</td>
  3934. <td>商品名称</td>
  3935. <td>商品中文</td>
  3936. <td>标签</td>
  3937. <td>订单号</td>
  3938. <td>订单编码</td>
  3939. <td>运单号</td>
  3940. <td>" . $tl . "时间(中国时间)</td>
  3941. </tr>
  3942. </table>";
  3943. $filename = $title . ".xls";
  3944. $tail = "";
  3945. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3946. } else if ($type == 5) {
  3947. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3948. foreach ($info_list as $key => $value) {
  3949. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3950. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3951. $warehouse = $this->warehouse->read($value['warehouse']);
  3952. $info_list[$key]['warehouse'] = $warehouse['title'];
  3953. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3954. $features = explode('-', trim($features, '-'));
  3955. $pm = $classid;
  3956. foreach ($features as $k => $v) {
  3957. if ($v != 0) {
  3958. if (!isset($typeclass[$v])) {
  3959. continue;
  3960. }
  3961. if (isset($pm[$typeclass[$v]['classid']])) {
  3962. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3963. $tz = explode('|', $typeclass[$v]['zh']);
  3964. $pm[$typeclass[$v]['classid']] = $tz[0];
  3965. } else {
  3966. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3967. }
  3968. }
  3969. }
  3970. }
  3971. $zh = implode(" ", $pm);
  3972. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3973. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3974. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3975. $info_list[$key]['features'] = $zh;
  3976. }
  3977. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3978. $titlename = "<table border=1>
  3979. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3980. <tr align='center'>
  3981. <td>仓库</td>
  3982. <td>供应商</td>
  3983. <td>SKU</td>
  3984. <td>商品名称</td>
  3985. <td>商品中文</td>
  3986. <td>标签</td>
  3987. <td>" . $tl . "时间(中国时间)</td>
  3988. </tr>
  3989. </table>";
  3990. $filename = $title . ".xls";
  3991. $tail = "";
  3992. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3993. } else {
  3994. /**
  3995. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3996. $rows = array();$list = array();
  3997. foreach ($info_list as $key=>$value)
  3998. {
  3999. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4000. }
  4001. **/
  4002. $wh = array();
  4003. $w = $this->warehouse->find_all('1=1', 'id,title');
  4004. foreach ($w as $v) {
  4005. $wh[$v['id']] = $v['title'];
  4006. }
  4007. $wt = array();
  4008. $whlabel_type = $this->whlabel_type->find_all();
  4009. foreach ($whlabel_type as $v) {
  4010. $wt[$v['id']] = $v['title'];
  4011. }
  4012. $classid = $this->classid->sku();
  4013. $list = array();
  4014. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4015. foreach ($rows as $key => $value) {
  4016. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4017. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4018. $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');
  4019. $details = array();
  4020. $cpid = array();
  4021. $cpbz = array();
  4022. $c = 0;
  4023. $g = 0;
  4024. $x = 0;
  4025. $t = 0;
  4026. $s = 0;
  4027. $q = 0;
  4028. foreach ($sd as $k => $v) {
  4029. if ($v['state'] == 0) {
  4030. $c++;
  4031. }
  4032. if ($v['state'] != 9) {
  4033. $g++;
  4034. }
  4035. if ($v['outk'] > 1) {
  4036. $x++;
  4037. }
  4038. if ($v['retreat'] > 0) {
  4039. $t++;
  4040. }
  4041. if ($v['state'] == 8) {
  4042. $s++;
  4043. }
  4044. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4045. $q++;
  4046. }
  4047. $details[$v['details']] = $v['details'];
  4048. if ($v['cpid'] != 0) {
  4049. $cpid[$v['cpid']] = $v['cpid'];
  4050. }
  4051. if ($v['cpbz'] != '') {
  4052. $cpbz[$v['cpbz']] = $v['cpbz'];
  4053. }
  4054. }
  4055. if (isset($wt[$value['type']])) {
  4056. $rows[$key]['type'] = $wt[$value['type']];
  4057. } else {
  4058. $rows[$key]['type'] = '未设置';
  4059. }
  4060. $rows[$key]['details'] = implode("、", $details);
  4061. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4062. $ftime = time() - 15 * 24 * 3600;
  4063. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4064. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4065. $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);
  4066. $rows[$key]['c'] = $c;
  4067. $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);
  4068. $rows[$key]['t'] = $t;
  4069. $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'] . '"');
  4070. $rows[$key]['z'] = $z;
  4071. // $jm = $classid;
  4072. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4073. $features = explode('-', trim($features, '-'));
  4074. // $pm = $classid;
  4075. // foreach ($features as $k => $v) {
  4076. // if ($v != 0) {
  4077. // if (!isset($typeclass[$v])) {
  4078. // continue;
  4079. // }
  4080. // if (isset($pm[$typeclass[$v]['classid']])) {
  4081. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4082. // $tz = explode('|', $typeclass[$v]['zh']);
  4083. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4084. // } else {
  4085. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4086. // }
  4087. // if (isset($jm[$typeclass[$v]['classid']])) {
  4088. // if ($typeclass[$v]['jm']) {
  4089. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4090. // }
  4091. // }
  4092. // }
  4093. // }
  4094. // }
  4095. // $zh = implode(" ", $pm);
  4096. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4097. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4098. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4099. // $rows[$key]['features'] = $zh;
  4100. // $jm = array_filter($jm); //去除空值
  4101. // $jm = implode("-", $jm);
  4102. // $rows[$key]['jm'] = $jm;
  4103. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4104. }
  4105. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4106. // echo "<pre>";
  4107. // print_r($tmp_list);
  4108. // die;
  4109. $final_list =[];
  4110. foreach($tmp_list as $k=>$v){
  4111. $final_list[] = [
  4112. "warehouse"=>$v['warehouse'],
  4113. "purchase"=>$v['purchase'],
  4114. "details"=>$v['details'],
  4115. "cpid"=>$v['cpid'],
  4116. "sku"=>$v['sku'],
  4117. "title"=>$v['title'],
  4118. "features"=>$v['pm'],
  4119. "cpbz"=>$v['cpbz'],
  4120. "sm"=>$v['sm'],
  4121. "type"=>$v['type'],
  4122. "g"=>$v["g"],
  4123. "c"=>$v["c"],
  4124. "x"=>$v["x"],
  4125. "t"=>$v["t"],
  4126. "z"=>$v["z"],
  4127. "jm"=>$v["jm"],
  4128. "weight"=>$v["weight"],
  4129. "asd"=>$v["asd"],
  4130. ];
  4131. }
  4132. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4133. $titlename = "<table border=1>
  4134. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4135. <tr align='center'>
  4136. <td>仓库</td>
  4137. <td>供应商</td>
  4138. <td>位置</td>
  4139. <td>库存编码</td>
  4140. <td>SKU</td>
  4141. <td>商品名称</td>
  4142. <td>商品中文</td>
  4143. <td>产品备注</td>
  4144. <td>说明</td>
  4145. <td>类型</td>
  4146. <td>入库总量</td>
  4147. <td>库存数量</td>
  4148. <td>销售数量</td>
  4149. <td>退货数量</td>
  4150. <td>占单数量</td>
  4151. <td>料号</td>
  4152. <td>重量</td>
  4153. <td>类目</td>
  4154. </tr>
  4155. </table>";
  4156. $filename = $title . ".xls";
  4157. $tail = "";
  4158. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4159. }
  4160. }
  4161. }
  4162. //出库+入库数据整合
  4163. public function _excelcr()
  4164. {
  4165. if (isset($_GET['excel'])) {
  4166. $type = $this->input->get('excel', true);
  4167. $category = $this->input->get('category', true);
  4168. $size = $this->input->get('size', true);
  4169. $grade = $this->input->get('grade', true);
  4170. $color = $this->input->get('color', true);
  4171. $lowe = $this->input->get('lowe', true);
  4172. $sku = $this->input->get('sku', true);
  4173. $warehouse = $this->input->get('warehouse', true);
  4174. $purchase = $this->input->get('purchase', true);
  4175. $state = $this->input->get('state', true);
  4176. $sid = $this->input->get('sid', true);
  4177. $ktime = $this->input->get('ktime', true);
  4178. $jtime = $this->input->get('jtime', true);
  4179. $ktime = strtotime($ktime);
  4180. $jtime = strtotime($jtime);
  4181. $where = "1=1";
  4182. $gj = "";
  4183. $ck = "";
  4184. if ($category) {
  4185. $where .= " and features like '%-$category-%'";
  4186. }
  4187. if ($size) {
  4188. $where .= " and features like '%-$size-%'";
  4189. }
  4190. if ($grade) {
  4191. $where .= " and features like '%-$grade-%'";
  4192. }
  4193. if ($color) {
  4194. $where .= " and features like '%-$color-%'";
  4195. }
  4196. if ($lowe) {
  4197. $where .= " and features like '%-$lowe-%'";
  4198. }
  4199. if ($warehouse) {
  4200. $where .= " and warehouse = '$warehouse'";
  4201. }
  4202. if ($purchase) {
  4203. $where .= " and purchase = '$purchase'";
  4204. }
  4205. if ($state) {
  4206. $where .= " and state = '$state'";
  4207. }
  4208. if ($sku) {
  4209. $where .= " and sku like '%$sku%'";
  4210. }
  4211. if ($ktime && $jtime) {
  4212. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4213. }
  4214. $sidwhere = '';
  4215. if ($sid) {
  4216. $sd = "";
  4217. $s = explode(',', trim($sid, ','));
  4218. foreach ($s as $value) {
  4219. $sd .= " id = " . $value . " or";
  4220. }
  4221. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4222. }
  4223. //取得信息列表
  4224. $timeread = $ktime;
  4225. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4226. $timelist = array();
  4227. for ($i = 0; $i < $timenum; $i++) {
  4228. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4229. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4230. }
  4231. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4232. //echo "<pre>";
  4233. //print_r($info_list);
  4234. //exit();
  4235. $rows = array();
  4236. $list = array();
  4237. foreach ($info_list as $key => $value) {
  4238. $thistime = $timelist;
  4239. if (isset($rows[strtolower($value['sku'])])) {
  4240. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4241. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4242. }
  4243. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4244. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4245. }
  4246. } else {
  4247. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4248. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4249. }
  4250. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4251. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4252. }
  4253. $rows[strtolower($value['sku'])] = $thistime;
  4254. }
  4255. }
  4256. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4257. <head>
  4258. <!--[if gte mso 9]><xml>
  4259. <x:ExcelWorkbook>
  4260. <x:ExcelWorksheets>
  4261. <x:ExcelWorksheet>
  4262. <x:Name>EXCEL</x:Name>
  4263. <x:WorksheetOptions>
  4264. <x:Print>
  4265. <x:ValidPrinterInfo />
  4266. </x:Print>
  4267. </x:WorksheetOptions>
  4268. </x:ExcelWorksheet>
  4269. </x:ExcelWorksheets>
  4270. </x:ExcelWorkbook>
  4271. </xml>
  4272. <![endif]-->
  4273. </head><body>";
  4274. $str .= "<table border=1><tr><td>SKU</td>";
  4275. foreach ($timelist as $k => $v) {
  4276. $str .= "<td>" . $k . "出库</td>";
  4277. $str .= "<td>" . $k . "入库</td>";
  4278. }
  4279. $str .= "</tr></table>";
  4280. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4281. foreach ($rows as $key => $val) {
  4282. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4283. foreach ($val as $k => $v) {
  4284. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4285. if ($val[$k]['r'] > 0) {
  4286. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4287. } else {
  4288. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4289. }
  4290. }
  4291. $str .= "</tr>";
  4292. }
  4293. $str .= "</table>";
  4294. $str .= "</body></html>";
  4295. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4296. header("Content-type: application/octet-stream");
  4297. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4298. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4299. header("Pragma: no-cache");
  4300. header("Expires: 0");
  4301. exit($str);
  4302. }
  4303. }
  4304. //数量调整模板导出
  4305. public function _presetout()
  4306. {
  4307. if (isset($_GET['excel'])) {
  4308. $where = "sku != 'Preset' and purchase != 0";
  4309. //数据排序
  4310. $order_str = "id desc";
  4311. if (empty($page)) {
  4312. $start = 0;
  4313. $perpage = 1;
  4314. } else {
  4315. $start = ($page - 1) * $perpage;
  4316. }
  4317. //取得信息列表
  4318. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4319. $rows = array();
  4320. $list = array();
  4321. foreach ($info_list as $value) {
  4322. $warehouse = $this->warehouse->read($value['warehouse']);
  4323. $number = $value['number'];
  4324. $ftime = time() - 15 * 24 * 3600;
  4325. $purchase = $this->purchase->read($value['purchase']);
  4326. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4327. }
  4328. $title = "库存模板";
  4329. $titlename = "<table border=1>
  4330. <tr align='center'>
  4331. <td>仓库</td>
  4332. <td>供应商编码</td>
  4333. <td>SKU</td>
  4334. <td>增减数量(正数或负数)</td>
  4335. <td>增减备注</td>
  4336. <td>扣减方式:0减少库存1删除库存</td>
  4337. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4338. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4339. </tr>
  4340. </table>";
  4341. $filename = $title . ".xls";
  4342. $tail = "";
  4343. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4344. }
  4345. }
  4346. //数量调整模板导入
  4347. public function _presetedit()
  4348. {
  4349. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4350. $config['upload_path'] = '.' . $dir;
  4351. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4352. $config['allowed_types'] = 'xls|xlsx|csv';
  4353. $config['max_size'] = 10240;
  4354. $this->load->library('upload', $config);
  4355. $this->upload->initialize($config);
  4356. if ($this->upload->do_upload('userfile')) {
  4357. $full_path = $dir . $this->upload->data('file_name');
  4358. $fileName = '.' . $full_path;
  4359. if (!file_exists($fileName)) {
  4360. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4361. exit;
  4362. } else {
  4363. require_once "./data/excel/PHPExcel/IOFactory.php";
  4364. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4365. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4366. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4367. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4368. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4369. ++$column; //如果列数大于26行
  4370. $list = array();
  4371. for ($i = 2; $i <= $row; $i++) // 行数循环
  4372. {
  4373. $data = array();
  4374. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4375. {
  4376. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4377. }
  4378. $list[] = $data;
  4379. }
  4380. }
  4381. $i = 0;
  4382. $j = 0;
  4383. $ed = array();
  4384. foreach ($list as $key => $value) {
  4385. $time = time();
  4386. if ($value['0'] == "") {
  4387. continue;
  4388. }
  4389. $warehouse = $this->warehouse->get_title($value['0']);
  4390. $purchase = $this->purchase->get_bm($value['1']);
  4391. $sku = $value['2'];
  4392. $num = $value['3']; //调整数量
  4393. $text = $value['4']; //扣减说明
  4394. $type = $value['5']; //调整方式0扣减1删除
  4395. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4396. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4397. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4398. if (!$purchase) //如果没有这个SKU
  4399. {
  4400. $ed[] = array($purchase . '-不存在此供应商编码');
  4401. $j++;
  4402. continue;
  4403. }
  4404. if (!$d) //如果没有这个SKU
  4405. {
  4406. $ed[] = array($sku . '-库存中不存在此SKU');
  4407. $j++;
  4408. continue;
  4409. }
  4410. if (!isset($warehouse['id'])) {
  4411. $ed[] = array($sku . '-仓库名错误!');
  4412. $j++;
  4413. continue;
  4414. }
  4415. if ($type != '0' && $type != '1') {
  4416. $ed[] = array($sku . '-扣减方式填写错误!');
  4417. $j++;
  4418. continue;
  4419. }
  4420. if ($num < 0) //扣减库存
  4421. {
  4422. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4423. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4424. $j++;
  4425. continue;
  4426. }
  4427. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4428. if (count($data) < abs($num)) {
  4429. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4430. $j++;
  4431. continue;
  4432. }
  4433. if ($type == 0) //如果扣减方式为 扣减库存
  4434. {
  4435. for ($i = 0; $i < abs($num); $i++) {
  4436. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4437. }
  4438. } else if ($type == 1) {
  4439. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4440. if (count($zt) > 0) {
  4441. $ed[] = array($sku . '-有在途库存无法删除!');
  4442. $j++;
  4443. continue;
  4444. }
  4445. for ($i = 0; $i < abs($num); $i++) {
  4446. $this->whlabel->remove($data[$i]['id']);
  4447. }
  4448. }
  4449. } else if ($num > 0) //增加库存
  4450. {
  4451. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4452. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4453. $j++;
  4454. continue;
  4455. }
  4456. $post['sku'] = $d['sku'];
  4457. $post['shop'] = $d['shop'];
  4458. $post['warehouse'] = $warehouse['id'];
  4459. $post['purchase'] = $purchase['id'];
  4460. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4461. $post['state'] = 0;
  4462. $post['title'] = $d['title'];
  4463. $post['number'] = $d['number'];
  4464. $post['features'] = $d['features'];
  4465. $post['enter'] = $time;
  4466. $post['time'] = $time; //操作时间
  4467. $post['rktype'] = $rktype;
  4468. for ($i = 0; $i < $num; $i++) {
  4469. $post['label'] = time() . rand(100, 999) . $i;
  4470. $this->whlabel->insert($post);
  4471. }
  4472. }
  4473. sleep(1); //防止入库时间一样,需要延迟1秒
  4474. }
  4475. if ($j > 0) {
  4476. $tt = date('Ymd', time());
  4477. $title = '库存导入错误信息-' . $tt;
  4478. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4479. $tail = "\n";
  4480. $filename = $title . ".xls";
  4481. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4482. $dir = '/data/excel/' . $time . '/';
  4483. $file_name = 'error_' . $time . rand(1000, 9999);
  4484. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4485. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4486. fwrite($myfile, $ecl);
  4487. fclose($myfile);
  4488. $error = $dir . $file_name . '.xls';
  4489. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4490. exit;
  4491. } else {
  4492. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4493. exit;
  4494. }
  4495. }
  4496. }
  4497. //笛卡儿积
  4498. function cp($ps, $sets, $list)
  4499. {
  4500. $result = array();
  4501. $j = 0;
  4502. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4503. if ($i == 0) {
  4504. $result = $sets[$i];
  4505. }
  4506. $tmp = array();
  4507. foreach ($result as $res) {
  4508. foreach ($sets[$i + 1] as $set) {
  4509. $tmp[] = $res . ',' . $set;
  4510. }
  4511. }
  4512. $result = $tmp;
  4513. }
  4514. $this->db->trans_begin();
  4515. foreach ($result as $v) {
  4516. $post = array();
  4517. $title = "";
  4518. $num = "";
  4519. $data = explode(',', $v);
  4520. for ($i = 0; $i < count($list); $i++) {
  4521. $post[$list[$i]] = $data[$i];
  4522. $typeclass = $this->typeclass->read($data[$i]);
  4523. $title = $title . $typeclass['title'] . " ";
  4524. if ($data[$i] != 0) {
  4525. $num .= $data[$i]; //所有数据ID拼接
  4526. }
  4527. }
  4528. foreach ($ps as $kp => $vp) {
  4529. $post[$kp] = $vp;
  4530. }
  4531. $post['number'] = $num;
  4532. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4533. if ($info_list) {
  4534. $j++;
  4535. } else {
  4536. $skunum = $this->whlabel->find_count();
  4537. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4538. $post['title'] = rtrim($title, ' ');
  4539. $this->whlabel->insert($post);
  4540. }
  4541. }
  4542. if ($this->db->trans_status() === FALSE) {
  4543. $this->db->trans_commit();
  4544. return NULL;
  4545. } else {
  4546. $this->db->trans_commit();
  4547. return $j;
  4548. }
  4549. }
  4550. public function _kj($arg_array)
  4551. {
  4552. if (isset($_POST['sku'])) {
  4553. $time = time();
  4554. $sku = $this->input->post('sku', true);
  4555. $warehouse = $this->input->post('warehouse', true);
  4556. $num = $this->input->post('num', true);
  4557. $text = $this->input->post('text', true);
  4558. $purchase = $this->input->post('purchase', true);
  4559. $cktype = $this->input->post('cktype', true);
  4560. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4561. if ($cktype != 1 && $text == '') {
  4562. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4563. exit;
  4564. }
  4565. if ($num > count($order)) {
  4566. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4567. exit;
  4568. } else {
  4569. for ($i = 0; $i < $num; $i++) {
  4570. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4571. }
  4572. }
  4573. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4574. exit;
  4575. }
  4576. $uid = $this->whlabel->read($arg_array[0]);
  4577. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4578. $this->data['data'] = $uid;
  4579. $this->_Template('whlabel_kj', $this->data);
  4580. }
  4581. public function _summary($arg_array)
  4582. {
  4583. $prc = array();
  4584. $purchase = $this->purchase->find_all();
  4585. foreach ($purchase as $k => $v) {
  4586. $prc[$v['id']] = $v['title'];
  4587. }
  4588. if (isset($_GET['excel'])) {
  4589. $ktime = $this->input->get('ktime', true);
  4590. $jtime = $this->input->get('jtime', true);
  4591. $ktime = strtotime($ktime);
  4592. $jtime = strtotime($jtime);
  4593. $where = "1=1";
  4594. if ($ktime && $jtime) {
  4595. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4596. }
  4597. //数据排序
  4598. $order_str = "time desc";
  4599. if (empty($page)) {
  4600. $start = 0;
  4601. $perpage = 1;
  4602. } else {
  4603. $start = ($page - 1) * $perpage;
  4604. }
  4605. //取得信息列表
  4606. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4607. foreach ($info_list as $key => $value) {
  4608. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4609. $warehouse = $this->warehouse->read($value['warehouse']);
  4610. $info_list[$key]['warehouse'] = $warehouse['title'];
  4611. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4612. $details = array();
  4613. $cpid = array();
  4614. foreach ($x as $k => $v) {
  4615. if ($v['details'] != '') {
  4616. $details[$v['details']] = $v['details'];
  4617. }
  4618. if ($v['cpid'] != 0) {
  4619. $cpid[$v['cpid']] = $v['cpid'];
  4620. }
  4621. }
  4622. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4623. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4624. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4625. $info_list[$key]['s'] = $s;
  4626. $info_list[$key]['x'] = count($x);
  4627. }
  4628. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4629. $titlename = "<table border=1>
  4630. <tr align='center'>
  4631. <td>仓库</td>
  4632. <td>供应商</td>
  4633. <td>出库位置</td>
  4634. <td>出库编码</td>
  4635. <td>SKU</td>
  4636. <td>产品名</td>
  4637. <td>总剩余库存</td>
  4638. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4639. </tr>
  4640. </table>";
  4641. $filename = $title . ".xls";
  4642. $tail = "";
  4643. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4644. }
  4645. }
  4646. //usps发货清单
  4647. public function _manifest()
  4648. {
  4649. if (isset($_POST['manifest'])) {
  4650. $wltext = $this->input->post('wltext', true);
  4651. $time = time() - 16 * 3600;
  4652. $ptime = strtotime(date('Y-m-d', $time));
  4653. $waybill = array();
  4654. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4655. foreach ($fullorder as $v) {
  4656. $waybill[$v['waybill']] = $v['waybill'];
  4657. }
  4658. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4659. foreach ($fullordersmt as $v) {
  4660. $waybill[$v['waybill']] = $v['waybill'];
  4661. }
  4662. $wltext = explode(';', $wltext);
  4663. foreach ($wltext as $v) {
  4664. if (isset($waybill[$v])) {
  4665. unset($waybill[$v]);
  4666. }
  4667. }
  4668. $data = $this->usps->get_manifest($waybill);
  4669. if (isset($data['Description'])) {
  4670. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4671. exit;
  4672. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4673. $bctime = date('Ymd', time());
  4674. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4675. echo json_encode(array('msg' => $pdf, 'success' => true));
  4676. exit;
  4677. } else {
  4678. echo json_encode(array('msg' => $data, 'success' => false));
  4679. exit;
  4680. }
  4681. }
  4682. }
  4683. public function _pdf($pdf, $title, $bctime)
  4684. {
  4685. $pdf_path = './data/pdf/' . $bctime . '/';
  4686. $file_base64 = $pdf;
  4687. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4688. $file_base64 = base64_decode($file_base64);
  4689. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4690. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4691. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4692. }
  4693. /**
  4694. *
  4695. *
  4696. *
  4697. 进销存占单异常索引
  4698. *
  4699. *
  4700. *
  4701. **/
  4702. public function _abnormal()
  4703. {
  4704. $post = $this->input->post(NULL, TRUE);
  4705. if (isset($post['page'])) {
  4706. $page = $this->input->post('page', true);
  4707. $perpage = $this->input->post('perpage', true);
  4708. $sku = $this->input->post('sku', true);
  4709. $where = "1=1";
  4710. //数据排序
  4711. $order_str = "id desc";
  4712. if (empty($page)) {
  4713. $start = 0;
  4714. $perpage = 1;
  4715. } else {
  4716. $start = ($page - 1) * $perpage;
  4717. }
  4718. //取得信息列表
  4719. $info_list = $this->whlabel->find_all($where, '*');
  4720. $rows = array();
  4721. $list = array();
  4722. foreach ($info_list as $key => $value) {
  4723. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4724. }
  4725. foreach ($rows as $value) {
  4726. $warehouse = $this->warehouse->read($value['warehouse']);
  4727. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4728. $number = $value['number'];
  4729. $ftime = time() - 15 * 24 * 3600;
  4730. if ($value['shop'] != '') {
  4731. $shop = $value['shop'];
  4732. $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');
  4733. $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');
  4734. $order = array_merge($orderdlz, $ordersmt);
  4735. $od = 0;
  4736. $a = '';
  4737. $orid = '';
  4738. foreach ($order as $v) {
  4739. $or = explode('|', ltrim($v['whlabel'], '|'));
  4740. for ($i = 0; $i < count($or); $i++) {
  4741. $orod = explode('-', $or[$i]);
  4742. if ($orod[0] == $number) {
  4743. $od += $orod[1];
  4744. }
  4745. }
  4746. $orid .= $v['number'] . '-';
  4747. }
  4748. } else {
  4749. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4750. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4751. $order = array_merge($orderdlz, $ordersmt);
  4752. $od = 0;
  4753. $a = '';
  4754. $orid = '';
  4755. $qt = array();
  4756. foreach ($order as $v) {
  4757. $or = explode('|', ltrim($v['whlabel'], '|'));
  4758. for ($i = 0; $i < count($or); $i++) {
  4759. $orod = explode('-', $or[$i]);
  4760. if ($orod[0] == $number) {
  4761. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4762. if ($czzs > 0) {
  4763. if (isset($qt[$v['shop']])) {
  4764. if ($qt[$v['shop']] < $orod[1]) {
  4765. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4766. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4767. } else {
  4768. $qt[$v['shop']] -= $orod[1];
  4769. }
  4770. } else {
  4771. $qt[$v['shop']] = $czzs;
  4772. }
  4773. } else {
  4774. $od += $orod[1];
  4775. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4776. }
  4777. }
  4778. }
  4779. }
  4780. }
  4781. $z = $od . '(' . $orid . ')'; //查看订单号
  4782. //$z = $od;
  4783. if ($od > $c) {
  4784. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4785. }
  4786. }
  4787. $listdata = array_slice($list, $start, $perpage);
  4788. $total = count($list);
  4789. $pagenum = ceil($total / $perpage);
  4790. $over = $total - ($start + $perpage);
  4791. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4792. echo json_encode($rows);
  4793. exit;
  4794. }
  4795. $this->_Template('whlabel_abnormal', $this->data);
  4796. }
  4797. /**
  4798. *
  4799. *
  4800. *
  4801. 进销存占单异常索引
  4802. *
  4803. *
  4804. *
  4805. **/
  4806. public function _error()
  4807. {
  4808. $post = $this->input->post(NULL, TRUE);
  4809. if (isset($post['page'])) {
  4810. $page = $this->input->post('page', true);
  4811. $perpage = $this->input->post('perpage', true);
  4812. $sku = $this->input->post('sku', true);
  4813. $warehouse = $this->input->post('warehouse', true);
  4814. $ktime = $this->input->post('ktime', true);
  4815. $jtime = $this->input->post('jtime', true);
  4816. $ktime = strtotime($ktime);
  4817. $jtime = strtotime($jtime);
  4818. $where = "sku != 'Preset'";
  4819. $gj = '';
  4820. if ($sku) {
  4821. $where .= " and sku like '%$sku%'";
  4822. } else {
  4823. if ($ktime && $jtime) {
  4824. $gj = " and time > '$ktime' and time < '$jtime'";
  4825. }
  4826. }
  4827. if ($warehouse) {
  4828. $where .= " and warehouse = '$warehouse'";
  4829. }
  4830. //数据排序
  4831. $order_str = "id desc";
  4832. if (empty($page)) {
  4833. $start = 0;
  4834. $perpage = 1;
  4835. } else {
  4836. $start = ($page - 1) * $perpage;
  4837. }
  4838. //取得信息列表
  4839. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4840. $rows = array();
  4841. $list = array();
  4842. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4843. // foreach ($info_list as $value)
  4844. // {
  4845. // $warehouse = $this->warehouse->read($value['warehouse']);
  4846. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4847. // $number = $value['number'];$ftime = time()-15*24*3600;
  4848. // if($c < 1)
  4849. // {
  4850. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4851. // }
  4852. // }
  4853. $warehouse_list = $this->warehouse->find_all();
  4854. $warehouse_list = array_column($warehouse_list, null, 'id');
  4855. foreach ($info_list as $value) {
  4856. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4857. 'title' => "",
  4858. ];
  4859. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4860. $number = $value['number'];
  4861. $ftime = time() - 15 * 24 * 3600;
  4862. if ($c < 1) {
  4863. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4864. }
  4865. }
  4866. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4867. // $query = $this->db->query($sql);
  4868. // $info_list = $query->result_array();
  4869. // $sql_two = "select title,id from crowd_warehouse";
  4870. // $query_two = $this->db->query($sql_two);
  4871. // $warehouse_list = $query_two->result_array();
  4872. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4873. // foreach ($info_list as $value)
  4874. // {
  4875. // if(isset($warehouse_arr[$value['warehouse']])){
  4876. // $warehouse = $warehouse_arr[$value['warehouse']];
  4877. // }else{
  4878. // $warehouse = [
  4879. // 'id'=>0,
  4880. // 'title'=>"异常",
  4881. // ];
  4882. // }
  4883. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4884. // $number = $value['number'];$ftime = time()-15*24*3600;
  4885. // if($c < 1)
  4886. // {
  4887. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4888. // }
  4889. // }
  4890. $listdata = array_slice($list, $start, $perpage);
  4891. $total = count($list);
  4892. $pagenum = ceil($total / $perpage);
  4893. $over = $total - ($start + $perpage);
  4894. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4895. echo json_encode($rows);
  4896. exit;
  4897. }
  4898. if (isset($post['s'])) {
  4899. $id_arr = $this->input->post('s');
  4900. $id_arr = explode(',', trim($id_arr, ','));
  4901. if (!$id_arr) {
  4902. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4903. exit;
  4904. }
  4905. //循环删除记录
  4906. foreach ($id_arr as $v) {
  4907. $dd = $this->whlabel->read($v);
  4908. if (!isset($dd['id'])) {
  4909. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4910. exit;
  4911. }
  4912. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4913. if (isset($zt[0])) {
  4914. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4915. exit;
  4916. }
  4917. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4918. foreach ($deldd as $vv) {
  4919. $this->whlabel->remove($vv['id']);
  4920. }
  4921. }
  4922. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4923. exit;
  4924. }
  4925. $this->_Template('whlabel_error', $this->data);
  4926. }
  4927. public function _errorexcel()
  4928. {
  4929. $post = $this->input->post(NULL, TRUE);
  4930. if (isset($_GET['page'])) {
  4931. $page = $this->input->get('page', true);
  4932. $perpage = $this->input->get('perpage', true);
  4933. $sku = $this->input->get('sku', true);
  4934. $warehouse = $this->input->get('warehouse', true);
  4935. $ktime = $this->input->get('ktime', true);
  4936. $jtime = $this->input->get('jtime', true);
  4937. $ktime = strtotime($ktime);
  4938. $jtime = strtotime($jtime);
  4939. $where = "sku != 'Preset'";
  4940. $gj = '';
  4941. if ($sku) {
  4942. $where .= " and sku like '%$sku%'";
  4943. } else {
  4944. if ($ktime && $jtime) {
  4945. $gj = " and time > '$ktime' and time < '$jtime'";
  4946. }
  4947. }
  4948. if ($warehouse) {
  4949. $where .= " and warehouse = '$warehouse'";
  4950. }
  4951. //数据排序
  4952. $order_str = "id desc";
  4953. if (empty($page)) {
  4954. $start = 0;
  4955. $perpage = 1;
  4956. } else {
  4957. $start = ($page - 1) * $perpage;
  4958. }
  4959. //取得信息列表
  4960. $rows = array();
  4961. $list = array();
  4962. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4963. foreach ($info_list as $value) {
  4964. $warehouse = $this->warehouse->read($value['warehouse']);
  4965. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4966. $number = $value['number'];
  4967. $ftime = time() - 15 * 24 * 3600;
  4968. if ($c < 1) {
  4969. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4970. }
  4971. }
  4972. $title = "0库存汇总";
  4973. $titlename = "<table border=1>
  4974. <tr align='center'>
  4975. <td>仓库</td>
  4976. <td>SKU</td>
  4977. <td>产品</td>
  4978. <td>当前库存</td>
  4979. </tr>
  4980. </table>";
  4981. $filename = $title . ".xls";
  4982. $tail = "";
  4983. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4984. }
  4985. }
  4986. /**
  4987. *
  4988. *
  4989. * 占单
  4990. *
  4991. *
  4992. **/
  4993. public function _kcyz()
  4994. {
  4995. $post = $this->input->post(NULL, TRUE);
  4996. if (isset($post['warehouse'])) {
  4997. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4998. exit; //不再使用
  4999. $warehouse = $this->input->post('warehouse', true);
  5000. $whlabel = $this->input->post('whlabel', true);
  5001. $id = $this->input->post('id', true);
  5002. $shop = $this->input->post('shop', true);
  5003. $number = $this->input->post('number', true);
  5004. if (!$whlabel || $whlabel == '|') {
  5005. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5006. exit;
  5007. }
  5008. $pp = explode('|', trim($whlabel, '|'));
  5009. $x = 0;
  5010. $save = array();
  5011. foreach ($pp as $va) {
  5012. $num = explode('-', $va);
  5013. if ($number) {
  5014. $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 = '')"); //通用
  5015. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5016. } else {
  5017. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5018. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5019. }
  5020. $x++;
  5021. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5022. $save[] = $x - 1;
  5023. continue; //提前先加X不然出错,所以要减1
  5024. }
  5025. }
  5026. if (isset($save[0])) {
  5027. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5028. exit;
  5029. } else {
  5030. echo json_encode(array('success' => true));
  5031. exit;
  5032. }
  5033. }
  5034. }
  5035. public function _db()
  5036. {
  5037. $post = $this->input->post(NULL, TRUE);
  5038. if (isset($post['page'])) {
  5039. $page = $this->input->post('page', true);
  5040. $perpage = $this->input->post('perpage', true);
  5041. $sku = $this->input->post('sku', true);
  5042. $number = $this->input->post('number', true);
  5043. $warehouse = $this->input->post('warehouse', true);
  5044. $purchase = $this->input->post('purchase', true);
  5045. $orderinfo = $this->input->post('orderinfo', true);
  5046. $waybill = $this->input->post('waybill', true);
  5047. $category = $this->input->post('category', true);
  5048. $size = $this->input->post('size', true);
  5049. $grade = $this->input->post('grade', true);
  5050. $color = $this->input->post('color', true);
  5051. $lowe = $this->input->post('lowe', true);
  5052. $state = $this->input->post('state', true);
  5053. $label = $this->input->post('label', true);
  5054. $timetk = $this->input->post('timetkk', true);
  5055. $timetj = $this->input->post('timetjj', true);
  5056. $timetk = strtotime($timetk);
  5057. $timetj = strtotime($timetj);
  5058. $where = "dbtime > 0";
  5059. if ($timetk && $timetj) {
  5060. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5061. }
  5062. if ($sku) {
  5063. $where .= " and sku = '$sku'";
  5064. }
  5065. if ($warehouse) {
  5066. $where .= " and warehouse = '$warehouse'";
  5067. if ($warehouse == 12) {
  5068. $w = 'specialstock';
  5069. } else {
  5070. $w = 'whlabel';
  5071. }
  5072. }
  5073. if ($purchase) {
  5074. $where .= " and purchase = '$purchase'";
  5075. }
  5076. if ($category) {
  5077. $where .= " and features like '%-$category-%'";
  5078. }
  5079. if ($size) {
  5080. $where .= " and features like '%-$size-%'";
  5081. }
  5082. if ($grade) {
  5083. $where .= " and features like '%-$grade-%'";
  5084. }
  5085. if ($color) {
  5086. $where .= " and features like '%-$color-%'";
  5087. }
  5088. if ($lowe) {
  5089. $where .= " and features like '%-$lowe-%'";
  5090. }
  5091. if ($state != '') {
  5092. $where .= " and state = '$state'";
  5093. }
  5094. //数据排序
  5095. $order_str = "dbtime desc";
  5096. if (empty($page)) {
  5097. $start = 0;
  5098. $perpage = 1;
  5099. } else {
  5100. $start = ($page - 1) * $perpage;
  5101. }
  5102. //取得信息列表
  5103. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5104. foreach ($info_list as $key => $value) {
  5105. $warehouse = $this->$w->read($value['warehouse']);
  5106. $info_list[$key]['warehouse'] = $warehouse['title'];
  5107. $purchase = $this->purchase->read($value['purchase']);
  5108. $info_list[$key]['purchase'] = $purchase['title'];
  5109. if ($value['enter'] != 0) {
  5110. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5111. } else {
  5112. $info_list[$key]['enter'] = "";
  5113. }
  5114. if ($value['dbtime'] != 0) {
  5115. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5116. } else {
  5117. $info_list[$key]['dbtime'] = "";
  5118. }
  5119. if ($value['state'] == 0) {
  5120. $info_list[$key]['state'] = "在库";
  5121. } else if ($value['state'] == 1) {
  5122. $info_list[$key]['state'] = "出库";
  5123. } else if ($value['state'] == 2) {
  5124. $info_list[$key]['state'] = "退库";
  5125. } else if ($value['state'] == 3) {
  5126. $info_list[$key]['state'] = "调拨中";
  5127. } else if ($value['state'] == 4) {
  5128. $info_list[$key]['state'] = "再加工";
  5129. } else if ($value['state'] == 5) {
  5130. $info_list[$key]['state'] = "维修中";
  5131. } else if ($value['state'] == 6) {
  5132. $info_list[$key]['state'] = "盘亏";
  5133. } else if ($value['state'] == 7) {
  5134. $info_list[$key]['state'] = "更换标签";
  5135. } else if ($value['state'] == 8) {
  5136. $info_list[$key]['state'] = "其它";
  5137. } else if ($value['state'] == 9) {
  5138. $info_list[$key]['state'] = "预设";
  5139. }
  5140. }
  5141. $total = $this->whlabel->find_count($where);
  5142. $pagenum = ceil($total / $perpage);
  5143. $over = $total - ($start + $perpage);
  5144. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5145. echo json_encode($rows);
  5146. exit;
  5147. }
  5148. if (isset($post['outsku'])) {
  5149. $time = time();
  5150. $cz = $this->input->post('cz', true);
  5151. $label = $this->input->post('outsku', true);
  5152. $sl = $this->input->post('sl', true);
  5153. $num = $this->input->post('num', true);
  5154. //$warehouse = $this->input->post('warehouse',true);
  5155. if (!$sl) {
  5156. $sl = 1;
  5157. }
  5158. if (!$warehouse) {
  5159. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5160. exit;
  5161. }
  5162. $dblabel = $this->whlabellabel->get_label($label);
  5163. if ($dblabel) {
  5164. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5165. if (count($data) < 1) {
  5166. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5167. exit;
  5168. }
  5169. if (count($data) < $num) {
  5170. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5171. exit;
  5172. }
  5173. for ($i = 0; $i < $sl; $i++) {
  5174. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5175. }
  5176. echo json_encode(array('success' => true));
  5177. exit;
  5178. } else {
  5179. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5180. exit;
  5181. }
  5182. }
  5183. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5184. $this->_Template('whlabel_db', $this->data);
  5185. }
  5186. public function _dbrk()
  5187. {
  5188. $post = $this->input->post(NULL, TRUE);
  5189. if (isset($post['page'])) {
  5190. $page = $this->input->post('page', true);
  5191. $perpage = $this->input->post('perpage', true);
  5192. $sku = $this->input->post('sku', true);
  5193. $number = $this->input->post('number', true);
  5194. $warehouse = $this->input->post('warehouse', true);
  5195. $purchase = $this->input->post('purchase', true);
  5196. $orderinfo = $this->input->post('orderinfo', true);
  5197. $waybill = $this->input->post('waybill', true);
  5198. $category = $this->input->post('category', true);
  5199. $size = $this->input->post('size', true);
  5200. $grade = $this->input->post('grade', true);
  5201. $color = $this->input->post('color', true);
  5202. $lowe = $this->input->post('lowe', true);
  5203. $state = $this->input->post('state', true);
  5204. $label = $this->input->post('label', true);
  5205. $ctime = $this->input->post('ctime', true);
  5206. $timetk = $this->input->post('timetkk', true);
  5207. $timetj = $this->input->post('timetjj', true);
  5208. $timetk = strtotime($timetk);
  5209. $timetj = strtotime($timetj);
  5210. $where = "dbtime > 0";
  5211. if ($timetk && $timetj) {
  5212. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5213. }
  5214. if ($sku) {
  5215. $where .= " and sku = '$sku'";
  5216. }
  5217. if ($warehouse) {
  5218. $where .= " and warehouse = '$warehouse'";
  5219. }
  5220. if ($purchase) {
  5221. $where .= " and purchase = '$purchase'";
  5222. }
  5223. if ($category) {
  5224. $where .= " and features like '%-$category-%'";
  5225. }
  5226. if ($size) {
  5227. $where .= " and features like '%-$size-%'";
  5228. }
  5229. if ($grade) {
  5230. $where .= " and features like '%-$grade-%'";
  5231. }
  5232. if ($color) {
  5233. $where .= " and features like '%-$color-%'";
  5234. }
  5235. if ($lowe) {
  5236. $where .= " and features like '%-$lowe-%'";
  5237. }
  5238. if ($state != '') {
  5239. $where .= " and state = '$state'";
  5240. }
  5241. //数据排序
  5242. $order_str = "dbtime desc";
  5243. if (empty($page)) {
  5244. $start = 0;
  5245. $perpage = 1;
  5246. } else {
  5247. $start = ($page - 1) * $perpage;
  5248. }
  5249. //取得信息列表
  5250. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5251. foreach ($info_list as $key => $value) {
  5252. $warehouse = $this->warehouse->read($value['warehouse']);
  5253. $info_list[$key]['warehouse'] = $warehouse['title'];
  5254. $purchase = $this->purchase->read($value['purchase']);
  5255. $info_list[$key]['purchase'] = $purchase['title'];
  5256. if ($value['enter'] != 0) {
  5257. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5258. } else {
  5259. $info_list[$key]['enter'] = "";
  5260. }
  5261. if ($value['dbtime'] != 0) {
  5262. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5263. } else {
  5264. $info_list[$key]['dbtime'] = "";
  5265. }
  5266. if ($value['state'] == 0) {
  5267. $info_list[$key]['state'] = "在库";
  5268. } else if ($value['state'] == 1) {
  5269. $info_list[$key]['state'] = "出库";
  5270. } else if ($value['state'] == 2) {
  5271. $info_list[$key]['state'] = "退库";
  5272. } else if ($value['state'] == 3) {
  5273. $info_list[$key]['state'] = "调拨中";
  5274. } else if ($value['state'] == 4) {
  5275. $info_list[$key]['state'] = "再加工";
  5276. } else if ($value['state'] == 5) {
  5277. $info_list[$key]['state'] = "维修中";
  5278. } else if ($value['state'] == 6) {
  5279. $info_list[$key]['state'] = "盘亏";
  5280. } else if ($value['state'] == 7) {
  5281. $info_list[$key]['state'] = "更换标签";
  5282. } else if ($value['state'] == 8) {
  5283. $info_list[$key]['state'] = "其它";
  5284. } else if ($value['state'] == 9) {
  5285. $info_list[$key]['state'] = "预设";
  5286. }
  5287. }
  5288. $total = $this->whlabel->find_count($where);
  5289. $pagenum = ceil($total / $perpage);
  5290. $over = $total - ($start + $perpage);
  5291. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5292. echo json_encode($rows);
  5293. exit;
  5294. }
  5295. if (isset($post['rsku'])) {
  5296. $cz = $this->input->post('cz', true);
  5297. $label = $this->input->post('rsku', true);
  5298. $sl = $this->input->post('sl', true);
  5299. $warehouse = $this->input->post('warehouse', true);
  5300. if (!$sl) {
  5301. $sl = 1;
  5302. }
  5303. if (!$warehouse) {
  5304. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5305. exit;
  5306. }
  5307. $dblabel = $this->whlabellabel->get_label($label);
  5308. if ($dblabel) {
  5309. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5310. if (count($data) < 1) {
  5311. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5312. exit;
  5313. }
  5314. if ($sl > count($data)) {
  5315. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5316. exit;
  5317. }
  5318. $time = time();
  5319. for ($i = 0; $i < $sl; $i++) {
  5320. $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']);
  5321. }
  5322. echo json_encode(array('success' => true));
  5323. exit;
  5324. } else {
  5325. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5326. exit;
  5327. }
  5328. }
  5329. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5330. $this->_Template('whlabel_dbrk', $this->data);
  5331. }
  5332. public function _whlabelczdc()
  5333. {
  5334. if (isset($_GET['excel'])) {
  5335. //数据排序
  5336. $order_str = "id desc";
  5337. if (empty($page)) {
  5338. $start = 0;
  5339. $perpage = 1;
  5340. } else {
  5341. $start = ($page - 1) * $perpage;
  5342. }
  5343. $state = $this->input->get('state', true);
  5344. $sku = $this->input->get('sku', true);
  5345. $ctime = $this->input->get('ctime', true);
  5346. $category = $this->input->get('category', true);
  5347. $size = $this->input->get('size', true);
  5348. $grade = $this->input->get('grade', true);
  5349. $color = $this->input->get('color', true);
  5350. $lowe = $this->input->get('lowe', true);
  5351. $timetk = $this->input->get('timetkk', true);
  5352. $timetj = $this->input->get('timetjj', true);
  5353. $timetk = strtotime($timetk);
  5354. $timetj = strtotime($timetj);
  5355. $where = "dbtime > 0";
  5356. if ($timetk && $timetj) {
  5357. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5358. }
  5359. if ($category) {
  5360. $where .= " and features like '%-$category-%'";
  5361. }
  5362. if ($size) {
  5363. $where .= " and features like '%-$size-%'";
  5364. }
  5365. if ($grade) {
  5366. $where .= " and features like '%-$grade-%'";
  5367. }
  5368. if ($color) {
  5369. $where .= " and features like '%-$color-%'";
  5370. }
  5371. if ($lowe) {
  5372. $where .= " and features like '%-$lowe-%'";
  5373. }
  5374. //取得信息列表
  5375. $info_list = $this->whlabel->find_all($where, '*');
  5376. $rows = array();
  5377. $list = array();
  5378. foreach ($info_list as $key => $value) {
  5379. $rows[$value['sku']] = $value; //所有数据sku
  5380. }
  5381. foreach ($rows as $value) {
  5382. $warehouse = $this->warehouse->read($value['warehouse']);
  5383. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5384. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5385. if ($value['orderinfo'] == 0) {
  5386. $info_list[$key]['orderinfo'] = "";
  5387. }
  5388. if ($value['waybill'] == 0) {
  5389. $info_list[$key]['waybill'] = "";
  5390. }
  5391. if ($value['state'] == 0) {
  5392. $value['state'] = "在库";
  5393. } else if ($value['state'] == 3) {
  5394. $value['state'] = "调拨中";
  5395. }
  5396. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5397. }
  5398. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5399. $titlename = "<table border=1>
  5400. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5401. <tr align='center'>
  5402. <td>SKU</td>
  5403. <td>产品</td>
  5404. <td>调拨数量</td>
  5405. <td>入库数量</td>
  5406. </tr>
  5407. </table>";
  5408. $filename = $title . ".xls";
  5409. $tail = "";
  5410. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5411. }
  5412. }
  5413. public function _print($arg_array)
  5414. {
  5415. if (isset($_SESSION['api'])) {
  5416. $user = $this->user->get_api($_SESSION['api']);
  5417. $usp = $user;
  5418. $fgshop = "";
  5419. $sid = "";
  5420. $wid = "";
  5421. $wtype = "";
  5422. $usersp = explode('|', trim($user['shop'], '|'));
  5423. $userwh = explode('|', trim($user['warehouse'], '|'));
  5424. foreach ($usersp as $value) {
  5425. $fgshop .= " shop = " . $value . " or";
  5426. $sid .= " id = " . $value . " or";
  5427. }
  5428. foreach ($userwh as $value) {
  5429. $wid .= " id = " . $value . " or";
  5430. $wtype .= " type = " . $value . " or";
  5431. }
  5432. }
  5433. $post = $this->input->post(NULL, TRUE);
  5434. if (isset($post['tmsku'])) {
  5435. $tmsku = $this->input->post('tmsku', true);
  5436. if (is_numeric($tmsku)) {
  5437. $yyh = $this->whlabellabel->get_label($tmsku);
  5438. } else {
  5439. $yyh = $this->whlabellabel->get_sku($tmsku);
  5440. }
  5441. if ($yyh) {
  5442. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5443. exit;
  5444. } else {
  5445. echo json_encode(array('success' => false));
  5446. exit;
  5447. }
  5448. }
  5449. $classid = $this->classid->sku();
  5450. $pm = $classid;
  5451. $scsku = $classid;
  5452. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5453. if (isset($post['warehouse'])) {
  5454. if ($post['warehouse']) {
  5455. $list = array();
  5456. $num = "";
  5457. $title = "";
  5458. $features = "";
  5459. $order = 0;
  5460. $post['shop'] = '';
  5461. $brand = $this->input->post('brand', true);
  5462. if ($brand != '0,') {
  5463. $b = $this->brand->read(rtrim($brand, ','));
  5464. if ($b) {
  5465. $post['shop'] = str_replace('|', ',', $b['shop']);
  5466. }
  5467. }
  5468. $post['details'] = $this->input->post('details', true); //打印数量
  5469. $xbqnum = $this->input->post('xbqnum', true);
  5470. $post['purchase'] = $this->input->post('purchase', true);
  5471. $post['warehouse'] = $this->input->post('warehouse', true);
  5472. $post['purchase'] = $this->input->post('purchase', true);
  5473. $post['retreatwarehouse'] = $post['warehouse'];
  5474. $post['cpbz'] = $this->input->post('cpbz', true);
  5475. $post['state'] = 9;
  5476. $category = $this->input->post('category', true);
  5477. $list['category'] = $category;
  5478. $list['hairtype'] = $this->input->post('hairtype', true);
  5479. $list['grade'] = $this->input->post('grade', true);
  5480. $size = $this->input->post('size', true);
  5481. $list['size'] = rtrim($size, ',');
  5482. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5483. $list['extension'] = $this->input->post('extension', true);
  5484. if ($category == 1297) {
  5485. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5486. }
  5487. if ($category == 1702) {
  5488. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5489. $list['syother'] = $this->input->post('syother', true);
  5490. }
  5491. if ($category == 133) {
  5492. $list['fittype'] = $this->input->post('fittype', true);
  5493. $list['acother'] = $this->input->post('acother', true);
  5494. }
  5495. $list['color'] = $this->input->post('color', true);
  5496. $list['lowe'] = $this->input->post('lowe', true);
  5497. if ($category == 127) {
  5498. $list['type'] = $this->input->post('type', true);
  5499. $list['headroad'] = $this->input->post('headroad', true);
  5500. $list['density'] = $this->input->post('density', true);
  5501. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5502. $list['lacesize'] = $this->input->post('lacesize', true);
  5503. }
  5504. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5505. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5506. }
  5507. if ($category == 128) {
  5508. $list['lacetype'] = $this->input->post('lacetype', true);
  5509. $list['haircap'] = $this->input->post('haircap', true);
  5510. $list['density'] = $this->input->post('density', true);
  5511. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5512. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5513. $list['wigother'] = $this->input->post('wigother', true);
  5514. $list['wigother1'] = $this->input->post('wigother1', true);
  5515. $list['wigother2'] = $this->input->post('wigother2', true);
  5516. }
  5517. if ($category == 129) {
  5518. $list['wide'] = $this->input->post('wide', true);
  5519. }
  5520. if ($category == 131) {
  5521. $list['gifttype'] = $this->input->post('gifttype', true);
  5522. $list['giftother'] = $this->input->post('giftother', true);
  5523. }
  5524. if ($category == 134) {
  5525. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5526. }
  5527. if ($category == 1297) {
  5528. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5529. $list['sywigother'] = $this->input->post('sywigother', true);
  5530. }
  5531. if ($category == 130 || $category == 133 || $category == 1702) {
  5532. $list['items'] = $this->input->post('items', true);
  5533. $list['weight'] = $this->input->post('weight', true);
  5534. }
  5535. if ($category == 1702) {
  5536. $list['syhairther'] = $this->input->post('syhairther', true);
  5537. }
  5538. foreach ($list as $k => $v) {
  5539. if ($v != 0) {
  5540. $num .= $v;
  5541. $features .= $v . '-';
  5542. $post[$k] = $v;
  5543. $typeclass = $this->typeclass->read($v);
  5544. if (isset($pm[$typeclass['classid']])) {
  5545. if (stripos($typeclass['zh'], '|') !== false) {
  5546. $exzh = explode('|', $typeclass['zh']);
  5547. $pm[$typeclass['classid']] = $exzh[0];
  5548. } else {
  5549. $pm[$typeclass['classid']] = $typeclass['zh'];
  5550. }
  5551. }
  5552. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5553. if ($k != 'size') {
  5554. $title .= $typeclass['title'] . " ";
  5555. }
  5556. }
  5557. }
  5558. $typeclass = $this->typeclass->read($list['size']);
  5559. $title .= $typeclass['title'];
  5560. $time = time();
  5561. $post['title'] = rtrim($title, ' ');
  5562. $post['number'] = $num;
  5563. $post['features'] = '-' . $features;
  5564. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5565. $featurespp = explode('-', trim($featurespp, '-'));
  5566. if (isset($featurespp[5])) {
  5567. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5568. } else {
  5569. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5570. }
  5571. $post['enter'] = $time;
  5572. $post['time'] = $time; //操作时间
  5573. $scsku = implode("-", $scsku);
  5574. $zh = implode(" ", $pm);
  5575. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5576. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5577. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5578. $post['sku'] = $bqsku;
  5579. $label = time() . rand(0, 9);
  5580. $post['label'] = $label;
  5581. $cpid = $this->whlabellabel->find_count();
  5582. $post['cpid'] = $cpid + 1;
  5583. $cpid = $post['cpid'];
  5584. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5585. //if($whlabelbarcode)
  5586. //{
  5587. //$post['label'] = $whlabelbarcode['label'];
  5588. //if(!$this->whlabellabel->insert($post))
  5589. //{
  5590. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5591. //}
  5592. //}
  5593. //else
  5594. //{
  5595. $this->db->trans_begin();
  5596. $this->whlabellabel->insert($post);
  5597. //$this->whlabelbarcode->insert($post);
  5598. if ($this->db->trans_status() === TRUE) {
  5599. $this->db->trans_commit();
  5600. } else {
  5601. $this->db->trans_rollback();
  5602. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5603. exit;
  5604. }
  5605. //}
  5606. $warehouse_name = "";
  5607. $warehouse = $post['warehouse'];
  5608. if($warehouse == 12){
  5609. $warehouse_name = "特殊库存库";
  5610. }
  5611. // if($warehouse == 13){
  5612. // $warehouse_name = "许昌仓";
  5613. // }
  5614. // if($warehouse == 5){
  5615. // $warehouse_name = "美国店";
  5616. // }
  5617. // if($warehouse == 16){
  5618. // $warehouse_name = "定制头套仓";
  5619. // }
  5620. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5621. if(!empty($warehouse_name)){
  5622. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5623. }
  5624. $purchase = $this->purchase->read($post['purchase']);
  5625. 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));
  5626. exit; //特殊仓目前不需要仓库选项
  5627. }
  5628. }
  5629. if (isset($_SESSION['api'])) {
  5630. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5631. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5632. $this->data['wlshop'] = $wlshop;
  5633. $this->data['warehouse'] = $warehouse;
  5634. }
  5635. $whlabelwz = $this->whlabelwz->find_all();
  5636. $this->data['whlabelwz'] = $whlabelwz;
  5637. $this->_Template('whlabel_print', $this->data);
  5638. }
  5639. public function _usaprint($arg_array)
  5640. {
  5641. if (isset($_SESSION['api'])) {
  5642. $user = $this->user->get_api($_SESSION['api']);
  5643. $usp = $user;
  5644. $fgshop = "";
  5645. $sid = "";
  5646. $wid = "";
  5647. $wtype = "";
  5648. $usersp = explode('|', trim($user['shop'], '|'));
  5649. $userwh = explode('|', trim($user['warehouse'], '|'));
  5650. foreach ($usersp as $value) {
  5651. $fgshop .= " shop = " . $value . " or";
  5652. $sid .= " id = " . $value . " or";
  5653. }
  5654. foreach ($userwh as $value) {
  5655. $wid .= " id = " . $value . " or";
  5656. $wtype .= " type = " . $value . " or";
  5657. }
  5658. }
  5659. $post = $this->input->post(NULL, TRUE);
  5660. if (isset($post['tmsku'])) {
  5661. $tmsku = $this->input->post('tmsku', true);
  5662. if (is_numeric($tmsku)) {
  5663. $yyh = $this->whlabellabel->get_label($tmsku);
  5664. } else {
  5665. $yyh = $this->whlabellabel->get_sku($tmsku);
  5666. }
  5667. if ($yyh) {
  5668. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5669. exit;
  5670. } else {
  5671. echo json_encode(array('success' => false));
  5672. exit;
  5673. }
  5674. }
  5675. $classid = $this->classid->sku();
  5676. $pm = $classid;
  5677. $scsku = $classid;
  5678. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5679. if (isset($post['warehouse'])) {
  5680. if ($post['warehouse']) {
  5681. $list = array();
  5682. $num = "";
  5683. $title = "";
  5684. $features = "";
  5685. $order = 0;
  5686. $post['shop'] = '';
  5687. $brand = $this->input->post('brand', true);
  5688. if ($brand != '0,') {
  5689. $b = $this->brand->read(rtrim($brand, ','));
  5690. if ($b) {
  5691. $post['shop'] = str_replace('|', ',', $b['shop']);
  5692. }
  5693. }
  5694. $post['details'] = $this->input->post('details', true); //打印数量
  5695. $xbqnum = $this->input->post('xbqnum', true);
  5696. $post['purchase'] = $this->input->post('purchase', true);
  5697. $post['warehouse'] = $this->input->post('warehouse', true);
  5698. $post['purchase'] = $this->input->post('purchase', true);
  5699. $post['retreatwarehouse'] = $post['warehouse'];
  5700. $post['cpbz'] = $this->input->post('cpbz', true);
  5701. $post['state'] = 9;
  5702. $category = $this->input->post('category', true);
  5703. $list['category'] = $category;
  5704. $list['hairtype'] = $this->input->post('hairtype', true);
  5705. $list['grade'] = $this->input->post('grade', true);
  5706. $size = $this->input->post('size', true);
  5707. $list['size'] = rtrim($size, ',');
  5708. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5709. $list['extension'] = $this->input->post('extension', true);
  5710. if ($category == 1297) {
  5711. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5712. }
  5713. if ($category == 1702) {
  5714. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5715. $list['syother'] = $this->input->post('syother', true);
  5716. }
  5717. if ($category == 133) {
  5718. $list['fittype'] = $this->input->post('fittype', true);
  5719. $list['acother'] = $this->input->post('acother', true);
  5720. }
  5721. $list['color'] = $this->input->post('color', true);
  5722. $list['lowe'] = $this->input->post('lowe', true);
  5723. if ($category == 127) {
  5724. $list['type'] = $this->input->post('type', true);
  5725. $list['headroad'] = $this->input->post('headroad', true);
  5726. $list['density'] = $this->input->post('density', true);
  5727. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5728. $list['lacesize'] = $this->input->post('lacesize', true);
  5729. }
  5730. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5731. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5732. }
  5733. if ($category == 128) {
  5734. $list['lacetype'] = $this->input->post('lacetype', true);
  5735. $list['haircap'] = $this->input->post('haircap', true);
  5736. $list['density'] = $this->input->post('density', true);
  5737. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5738. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5739. $list['wigother'] = $this->input->post('wigother', true);
  5740. $list['wigother1'] = $this->input->post('wigother1', true);
  5741. $list['wigother2'] = $this->input->post('wigother2', true);
  5742. }
  5743. if ($category == 129) {
  5744. $list['wide'] = $this->input->post('wide', true);
  5745. }
  5746. if ($category == 131) {
  5747. $list['gifttype'] = $this->input->post('gifttype', true);
  5748. $list['giftother'] = $this->input->post('giftother', true);
  5749. }
  5750. if ($category == 134) {
  5751. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5752. }
  5753. if ($category == 1297) {
  5754. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5755. $list['sywigother'] = $this->input->post('sywigother', true);
  5756. }
  5757. if ($category == 130 || $category == 133 || $category == 1702) {
  5758. $list['items'] = $this->input->post('items', true);
  5759. $list['weight'] = $this->input->post('weight', true);
  5760. }
  5761. if ($category == 1702) {
  5762. $list['syhairther'] = $this->input->post('syhairther', true);
  5763. }
  5764. foreach ($list as $k => $v) {
  5765. if ($v != 0) {
  5766. $num .= $v;
  5767. $features .= $v . '-';
  5768. $post[$k] = $v;
  5769. $typeclass = $this->typeclass->read($v);
  5770. if (isset($pm[$typeclass['classid']])) {
  5771. if (stripos($typeclass['zh'], '|') !== false) {
  5772. $exzh = explode('|', $typeclass['zh']);
  5773. $pm[$typeclass['classid']] = $exzh[0];
  5774. } else {
  5775. $pm[$typeclass['classid']] = $typeclass['zh'];
  5776. }
  5777. }
  5778. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5779. if ($k != 'size') {
  5780. $title .= $typeclass['title'] . " ";
  5781. }
  5782. }
  5783. }
  5784. $typeclass = $this->typeclass->read($list['size']);
  5785. $title .= $typeclass['title'];
  5786. $time = time();
  5787. $post['title'] = rtrim($title, ' ');
  5788. $post['number'] = $num;
  5789. $post['features'] = '-' . $features;
  5790. $fp = $this->whlabel->get_features($post['features']);
  5791. if (!$fp) {
  5792. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5793. exit;
  5794. }
  5795. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5796. $featurespp = explode('-', trim($featurespp, '-'));
  5797. if (isset($featurespp[5])) {
  5798. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5799. } else {
  5800. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5801. }
  5802. $post['enter'] = $time;
  5803. $post['time'] = $time; //操作时间
  5804. $scsku = implode("-", $scsku);
  5805. $zh = implode(" ", $pm);
  5806. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5807. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5808. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5809. $post['sku'] = $fp['sku'];
  5810. $post['label'] = $fp['sku'];
  5811. $cpid = $this->whlabellabel->find_count();
  5812. $post['cpid'] = $cpid + 1;
  5813. $cpid = $post['cpid'];
  5814. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5815. //if($whlabelbarcode)
  5816. //{
  5817. //$post['label'] = $whlabelbarcode['label'];
  5818. //if(!$this->whlabellabel->insert($post))
  5819. //{
  5820. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5821. //}
  5822. //}
  5823. //else
  5824. //{
  5825. $this->db->trans_begin();
  5826. $this->whlabellabel->insert($post);
  5827. //$this->whlabelbarcode->insert($post);
  5828. if ($this->db->trans_status() === TRUE) {
  5829. $this->db->trans_commit();
  5830. } else {
  5831. $this->db->trans_rollback();
  5832. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5833. exit;
  5834. }
  5835. //}
  5836. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5837. $purchase = $this->purchase->read($post['purchase']);
  5838. 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));
  5839. exit; //特殊仓目前不需要仓库选项
  5840. }
  5841. }
  5842. if (isset($_SESSION['api'])) {
  5843. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5844. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5845. $this->data['wlshop'] = $wlshop;
  5846. $this->data['warehouse'] = $warehouse;
  5847. }
  5848. $whlabelwz = $this->whlabelwz->find_all();
  5849. $this->data['whlabelwz'] = $whlabelwz;
  5850. $this->_Template('whlabel_usaprint', $this->data);
  5851. }
  5852. public function _printrk($arg_array)
  5853. {
  5854. $prc = array();
  5855. $purchase = $this->purchase->find_all();
  5856. foreach ($purchase as $k => $v) {
  5857. $prc[$v['id']] = $v['title'];
  5858. }
  5859. $post = $this->input->post(NULL, TRUE);
  5860. if (isset($post['page'])) {
  5861. $page = $this->input->post('page', true);
  5862. $perpage = $this->input->post('perpage', true);
  5863. $sku = $this->input->post('sku', true);
  5864. $bs = $this->input->post('bs', true);
  5865. $number = $this->input->post('number', true);
  5866. $warehouse = $this->input->post('warehouse', true);
  5867. $purchase = $this->input->post('purchase', true);
  5868. $orderinfo = $this->input->post('orderinfo', true);
  5869. $waybill = $this->input->post('waybill', true);
  5870. $category = $this->input->post('category', true);
  5871. $size = $this->input->post('size', true);
  5872. $grade = $this->input->post('grade', true);
  5873. $color = $this->input->post('color', true);
  5874. $lowe = $this->input->post('lowe', true);
  5875. $state = $this->input->post('state', true);
  5876. $label = $this->input->post('label', true);
  5877. $timetk = $this->input->post('ktime', true);
  5878. $timetj = $this->input->post('jtime', true);
  5879. $timetk = strtotime($timetk);
  5880. $timetj = strtotime($timetj);
  5881. $where = "1=1 ";
  5882. if ($timetk && $timetj) {
  5883. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5884. }
  5885. if ($sku) {
  5886. $where .= " and sku = '$sku'";
  5887. }
  5888. if ($bs != '') {
  5889. $where .= " and bs = '$bs'";
  5890. }
  5891. if ($number) {
  5892. $where .= " and number = '$number'";
  5893. }
  5894. if ($warehouse) {
  5895. $where .= " and warehouse = '$warehouse'";
  5896. }
  5897. if ($purchase) {
  5898. $where .= " and purchase = '$purchase'";
  5899. }
  5900. if ($orderinfo) {
  5901. $where .= " and orderinfo = '$orderinfo'";
  5902. }
  5903. if ($waybill) {
  5904. $where .= " and waybill = '$waybill'";
  5905. }
  5906. if ($category) {
  5907. $where .= " and features like '%-$category-%'";
  5908. }
  5909. if ($size) {
  5910. $where .= " and features like '%-$size-%'";
  5911. }
  5912. if ($grade) {
  5913. $where .= " and features like '%-$grade-%'";
  5914. }
  5915. if ($color) {
  5916. $where .= " and features like '%-$color-%'";
  5917. }
  5918. if ($lowe) {
  5919. $where .= " and features like '%-$lowe-%'";
  5920. }
  5921. if ($label) {
  5922. $where .= " and label = '$label'";
  5923. }
  5924. if ($state || $state == 0) {
  5925. $where .= " and state = '$state'";
  5926. }
  5927. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5928. //数据排序
  5929. $order_str = "enter desc";
  5930. if (empty($page)) {
  5931. $start = 0;
  5932. $perpage = 1;
  5933. } else {
  5934. $start = ($page - 1) * $perpage;
  5935. }
  5936. //取得信息列表
  5937. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5938. foreach ($info_list as $key => $value) {
  5939. $warehouse = $this->warehouse->read($value['warehouse']);
  5940. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5941. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5942. if ($value['state'] == 0) {
  5943. $info_list[$key]['state'] = "在库";
  5944. } else if ($value['state'] == 1) {
  5945. $info_list[$key]['state'] = "出库";
  5946. } else if ($value['state'] == 2) {
  5947. $info_list[$key]['state'] = "退库";
  5948. } else if ($value['state'] == 3) {
  5949. $info_list[$key]['state'] = "调拨中";
  5950. } else if ($value['state'] == 4) {
  5951. $info_list[$key]['state'] = "再加工";
  5952. } else if ($value['state'] == 5) {
  5953. $info_list[$key]['state'] = "维修中";
  5954. } else if ($value['state'] == 6) {
  5955. $info_list[$key]['state'] = "盘亏";
  5956. } else if ($value['state'] == 7) {
  5957. $info_list[$key]['state'] = "更换标签";
  5958. } else if ($value['state'] == 8) {
  5959. $info_list[$key]['state'] = "其它";
  5960. } else if ($value['state'] == 9) {
  5961. $info_list[$key]['state'] = "预设";
  5962. } else if ($value['state'] == 10) {
  5963. $info_list[$key]['state'] = "美店零售";
  5964. }
  5965. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5966. }
  5967. $total = $this->$ck->find_count($where);
  5968. $pagenum = ceil($total / $perpage);
  5969. $over = $total - ($start + $perpage);
  5970. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5971. echo json_encode($rows);
  5972. exit;
  5973. }
  5974. if (isset($post['tmsku'])) {
  5975. $time = time();
  5976. $tmsku = $this->input->post('tmsku', true);
  5977. //$post['shop'] = $this->input->post('shop',true);
  5978. $num = $this->input->post('num', true);
  5979. $rktype = $this->input->post('rktype', true);
  5980. if ($num > 200) {
  5981. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5982. exit;
  5983. }
  5984. if (!$rktype) {
  5985. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5986. }
  5987. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5988. /**
  5989. $wz = array();
  5990. foreach ($rk as $key=>$value)
  5991. {
  5992. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5993. }
  5994. if(count($wz) > 1)
  5995. {
  5996. $wz = array_values($wz);
  5997. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5998. }
  5999. **/
  6000. if (isset($rk[0]['purchase'])) {
  6001. $rk = $rk[0];
  6002. $j = 0;
  6003. $post['purchase'] = $rk['purchase'];
  6004. $post['warehouse'] = $rk['warehouse'];
  6005. $post['retreatwarehouse'] = $rk['warehouse'];
  6006. $post['sku'] = $rk['sku'];
  6007. $post['number'] = $rk['number'];
  6008. $post['features'] = $rk['features'];
  6009. $post['title'] = $rk['title'];
  6010. $post['enter'] = $time;
  6011. $post['time'] = $time;
  6012. $post['bs'] = 1;
  6013. $post['shop'] = $rk['shop'];
  6014. $post['details'] = $rk['details'];
  6015. $post['cpid'] = $rk['cpid'];
  6016. $post['cpbz'] = $rk['cpbz'];
  6017. //$post['rktype'] = $rktype;
  6018. $warehouse = $this->warehouse->read($rk['warehouse']);
  6019. if ($warehouse['bdck'] == '') {
  6020. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6021. exit;
  6022. } else {
  6023. $bdck = $warehouse['bdck'];
  6024. }
  6025. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6026. if (isset($pdwz['details'])) {
  6027. if ($pdwz['details'] != $post['details']) {
  6028. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6029. exit;
  6030. }
  6031. }
  6032. $post['featurespp'] = $rk['featurespp'];
  6033. if ($post['warehouse'] == '5') {
  6034. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6035. if ($yza) {
  6036. if ($post['features'] != $yza[0]['features']) {
  6037. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6038. exit;
  6039. }
  6040. }
  6041. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6042. if ($yzb) {
  6043. if ($post['sku'] != $yzb[0]['sku']) {
  6044. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6045. exit;
  6046. }
  6047. }
  6048. }
  6049. for ($i = 0; $i < $num; $i++) {
  6050. $post['label'] = time() . rand(100, 999) . $i;
  6051. if ($this->$bdck->insert($post)) {
  6052. $j++;
  6053. }
  6054. }
  6055. /**
  6056. if($post['warehouse'] != 12)
  6057. {
  6058. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6059. }
  6060. **/
  6061. if ($j == $num) {
  6062. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6063. exit;
  6064. } else {
  6065. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6066. exit;
  6067. }
  6068. } else {
  6069. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6070. exit;
  6071. }
  6072. }
  6073. $this->_Template('whlabel_printrk', $this->data);
  6074. }
  6075. public function _printxzrk($arg_array)
  6076. {
  6077. $post = $this->input->post(NULL, TRUE);
  6078. if (isset($post['wzid'])) {
  6079. $time = time();
  6080. $id = $this->input->post('wzid', true);
  6081. //$post['shop'] = $this->input->post('shop',true);
  6082. $num = 1;
  6083. $rk = $this->whlabellabel->read($id);
  6084. if (isset($rk['purchase'])) {
  6085. $x = 0;
  6086. $post['purchase'] = $rk['purchase'];
  6087. $post['warehouse'] = $rk['warehouse'];
  6088. $post['retreatwarehouse'] = $rk['warehouse'];
  6089. $post['sku'] = $rk['sku'];
  6090. $post['number'] = $rk['number'];
  6091. $post['features'] = $rk['features'];
  6092. $post['title'] = $rk['title'];
  6093. $post['enter'] = $time;
  6094. $post['time'] = $time;
  6095. $post['bs'] = 1;
  6096. $post['shop'] = $rk['shop'];
  6097. $post['details'] = $rk['details'];
  6098. $post['cpid'] = $rk['cpid'];
  6099. $post['cpbz'] = $rk['cpbz'];
  6100. $warehouse = $this->warehouse->read($rk['warehouse']);
  6101. if ($warehouse['bdck'] == '') {
  6102. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6103. exit;
  6104. } else {
  6105. $bdck = $warehouse['bdck'];
  6106. }
  6107. $post['featurespp'] = $rk['featurespp'];
  6108. $this->db->trans_begin();
  6109. for ($i = 0; $i < $num; $i++) {
  6110. $post['label'] = time() . rand(100, 999) . $i;
  6111. $this->$bdck->insert($post);
  6112. }
  6113. /**
  6114. if($post['warehouse'] != 12)
  6115. {
  6116. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6117. }
  6118. **/
  6119. if ($this->db->trans_status() === TRUE) {
  6120. $this->db->trans_commit();
  6121. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6122. exit;
  6123. } else {
  6124. $this->db->trans_rollback();
  6125. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6126. exit;
  6127. }
  6128. } else {
  6129. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6130. exit;
  6131. }
  6132. }
  6133. }
  6134. public function _printck($arg_array)
  6135. {
  6136. $prc = array();
  6137. $purchase = $this->purchase->find_all();
  6138. foreach ($purchase as $k => $v) {
  6139. $prc[$v['id']] = $v['title'];
  6140. }
  6141. $post = $this->input->post(NULL, TRUE);
  6142. if (isset($post['page'])) {
  6143. $page = $this->input->post('page', true);
  6144. $perpage = $this->input->post('perpage', true);
  6145. $sku = $this->input->post('sku', true);
  6146. $bs = $this->input->post('bs', true);
  6147. $number = $this->input->post('number', true);
  6148. $warehouse = $this->input->post('warehouse', true);
  6149. $purchase = $this->input->post('purchase', true);
  6150. $orderinfo = $this->input->post('orderinfo', true);
  6151. $waybill = $this->input->post('waybill', true);
  6152. $category = $this->input->post('category', true);
  6153. $size = $this->input->post('size', true);
  6154. $grade = $this->input->post('grade', true);
  6155. $color = $this->input->post('color', true);
  6156. $lowe = $this->input->post('lowe', true);
  6157. $state = $this->input->post('state', true);
  6158. $label = $this->input->post('label', true);
  6159. $timetk = $this->input->post('ktime', true);
  6160. $timetj = $this->input->post('jtime', true);
  6161. $timetk = strtotime($timetk);
  6162. $timetj = strtotime($timetj);
  6163. $where = "state=1 ";
  6164. if ($timetk && $timetj) {
  6165. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6166. }
  6167. if ($sku) {
  6168. $where .= " and sku = '$sku'";
  6169. }
  6170. if ($bs != '') {
  6171. $where .= " and bs = '$bs'";
  6172. }
  6173. if ($number) {
  6174. $where .= " and number = '$number'";
  6175. }
  6176. if ($warehouse) {
  6177. $where .= " and warehouse = '$warehouse'";
  6178. }
  6179. if ($purchase) {
  6180. $where .= " and purchase = '$purchase'";
  6181. }
  6182. if ($orderinfo) {
  6183. $where .= " and orderinfo = '$orderinfo'";
  6184. }
  6185. if ($waybill) {
  6186. $where .= " and waybill = '$waybill'";
  6187. }
  6188. if ($category) {
  6189. $where .= " and features like '%-$category-%'";
  6190. }
  6191. if ($size) {
  6192. $where .= " and features like '%-$size-%'";
  6193. }
  6194. if ($grade) {
  6195. $where .= " and features like '%-$grade-%'";
  6196. }
  6197. if ($color) {
  6198. $where .= " and features like '%-$color-%'";
  6199. }
  6200. if ($lowe) {
  6201. $where .= " and features like '%-$lowe-%'";
  6202. }
  6203. if ($label) {
  6204. $where .= " and label = '$label'";
  6205. }
  6206. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6207. //数据排序
  6208. $order_str = "outk desc";
  6209. if (empty($page)) {
  6210. $start = 0;
  6211. $perpage = 1;
  6212. } else {
  6213. $start = ($page - 1) * $perpage;
  6214. }
  6215. //取得信息列表
  6216. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6217. foreach ($info_list as $key => $value) {
  6218. $warehouse = $this->warehouse->read($value['warehouse']);
  6219. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6220. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6221. if ($value['state'] == 0) {
  6222. $info_list[$key]['state'] = "在库";
  6223. } else if ($value['state'] == 1) {
  6224. $info_list[$key]['state'] = "出库";
  6225. } else if ($value['state'] == 2) {
  6226. $info_list[$key]['state'] = "退库";
  6227. } else if ($value['state'] == 3) {
  6228. $info_list[$key]['state'] = "调拨中";
  6229. } else if ($value['state'] == 4) {
  6230. $info_list[$key]['state'] = "再加工";
  6231. } else if ($value['state'] == 5) {
  6232. $info_list[$key]['state'] = "维修中";
  6233. } else if ($value['state'] == 6) {
  6234. $info_list[$key]['state'] = "盘亏";
  6235. } else if ($value['state'] == 7) {
  6236. $info_list[$key]['state'] = "更换标签";
  6237. } else if ($value['state'] == 8) {
  6238. $info_list[$key]['state'] = "其它";
  6239. } else if ($value['state'] == 9) {
  6240. $info_list[$key]['state'] = "预设";
  6241. } else if ($value['state'] == 10) {
  6242. $info_list[$key]['state'] = "美店零售";
  6243. }
  6244. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6245. }
  6246. $total = $this->$ck->find_count($where);
  6247. $pagenum = ceil($total / $perpage);
  6248. $over = $total - ($start + $perpage);
  6249. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6250. echo json_encode($rows);
  6251. exit;
  6252. }
  6253. if (isset($post['tmsku'])) {
  6254. $time = time();
  6255. $tmsku = $this->input->post('tmsku', true);
  6256. //$post['shop'] = $this->input->post('shop',true);
  6257. $num = $this->input->post('num', true);
  6258. $cktype = $this->input->post('cktype', true);
  6259. $label = $this->whlabellabel->get_label($tmsku);
  6260. if (!$cktype) {
  6261. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6262. }
  6263. if (!isset($label['warehouse'])) {
  6264. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6265. exit;
  6266. }
  6267. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6268. if (stripos($label['features'], '-126-') !== false) {
  6269. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6270. } else {
  6271. $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 = ''");
  6272. }
  6273. $j = 0;
  6274. if (count($ck) >= $num) {
  6275. for ($i = 0; $i < $num; $i++) {
  6276. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6277. {
  6278. $j++;
  6279. }
  6280. }
  6281. if ($j == $num) {
  6282. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6283. exit;
  6284. } else {
  6285. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6286. exit;
  6287. }
  6288. } else {
  6289. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6290. exit;
  6291. }
  6292. }
  6293. if(isset($_SESSION['api']))
  6294. {
  6295. $user = $this->user->get_api($_SESSION['api']);
  6296. if(in_array($user['power'],[1,27])){
  6297. $vip = 1;
  6298. }
  6299. }
  6300. else
  6301. {
  6302. $vip = 0;
  6303. header('Location: /');exit;
  6304. }
  6305. $this->data['vip'] = $vip;
  6306. $this->_Template('whlabel_printck', $this->data);
  6307. }
  6308. public function _printexcel()
  6309. {
  6310. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6311. $config['upload_path'] = '.' . $dir;
  6312. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6313. $config['allowed_types'] = 'xls|xlsx|csv';
  6314. $config['max_size'] = 10240;
  6315. $this->load->library('upload', $config);
  6316. $this->upload->initialize($config);
  6317. if ($this->upload->do_upload('userfile')) {
  6318. $full_path = $dir . $this->upload->data('file_name');
  6319. $fileName = '.' . $full_path;
  6320. if (!file_exists($fileName)) {
  6321. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6322. exit;
  6323. } else {
  6324. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6325. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6326. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6327. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6328. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6329. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6330. ++$column; //如果列数大于26行
  6331. $list = array();
  6332. for ($i = 2; $i <= $row; $i++) // 行数循环
  6333. {
  6334. $data = array();
  6335. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6336. {
  6337. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6338. }
  6339. $list[] = $data;
  6340. }
  6341. }
  6342. $ed = array();
  6343. $i = 0;
  6344. $j = 0;
  6345. $dcdata = array();
  6346. $yc = '';
  6347. $cmf_arr = array_column($list, '1');
  6348. array_multisort($cmf_arr, SORT_ASC, $list);
  6349. foreach ($list as $key => $value) {
  6350. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6351. if ($typeclass) {
  6352. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6353. } else {
  6354. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6355. $i++;
  6356. continue;
  6357. }
  6358. }
  6359. if ($i > 0) {
  6360. $yc = $i . '条异常';
  6361. }
  6362. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6363. exit;
  6364. }
  6365. }
  6366. public function _uck()
  6367. {
  6368. if (isset($_GET['excel'])) {
  6369. $tc = array();
  6370. $typeclass = $this->typeclass->find_all();
  6371. foreach ($typeclass as $v) {
  6372. $tc[$v['id']] = $v['zh'];
  6373. }
  6374. $data = array();
  6375. $t = array();
  6376. $rq = '';
  6377. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6378. $ts = $ts / (24 * 3600);
  6379. for ($i = 0; $i < $ts; $i++) {
  6380. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6381. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6382. }
  6383. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6384. foreach ($info_list as $k => $v) {
  6385. $features = explode('-', trim($v['features'], '-'));
  6386. if (!isset($features[3]) || !isset($features[4])) {
  6387. continue;
  6388. }
  6389. $data[$k][0] = $tc[$features[0]]; //类型
  6390. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6391. $data[$k][2] = $tc[$features[4]]; //曲度
  6392. $data[$k][3] = '';
  6393. if (isset($data[$k][1])) {
  6394. $data[$k][3] .= $data[$k][1];
  6395. }
  6396. if (isset($data[$k][2])) {
  6397. $data[$k][3] .= $data[$k][2];
  6398. }
  6399. if (isset($features[5])) {
  6400. $data[$k][3] .= $tc[$features[5]];
  6401. }
  6402. if (isset($features[2])) {
  6403. $data[$k][3] .= $tc[$features[2]];
  6404. }
  6405. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6406. $data[$k][4] = $v['sku'];
  6407. $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())) . '))'); //月初库存
  6408. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6409. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6410. $ztrq = '';
  6411. $ztsl = '';
  6412. if (count($zt) > 0) {
  6413. foreach ($zt as $vv) {
  6414. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6415. $ztsl .= $vv['num'] . '<br>';
  6416. }
  6417. }
  6418. $data[$k][] = trim($ztsl, '<br>');
  6419. $data[$k][] = trim($ztrq, '<br>');
  6420. $byck = 0;
  6421. foreach ($t as $vv) {
  6422. $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));
  6423. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6424. $byck += $sl;
  6425. }
  6426. $data[$k][] = ($byck > 0) ? $byck : '';
  6427. }
  6428. $title = "详情 " . date("Y-m-d", time());
  6429. $titlename = "<table border=1>
  6430. <tr align='center'>
  6431. <td>类别</td>
  6432. <td>颜色</td>
  6433. <td>曲度</td>
  6434. <td>名称</td>
  6435. <td>SKU</td>
  6436. <td>月初库存</td>
  6437. <td>剩余库存</td>
  6438. <td>在途数量</td>
  6439. <td>预达日期</td>" .
  6440. $rq
  6441. . "<td>本月出库</td></tr>
  6442. </table>";
  6443. $filename = $title . ".xls";
  6444. $tail = "";
  6445. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6446. }
  6447. }
  6448. public function _whlabelexcelzh()
  6449. {
  6450. if (isset($_GET['excel'])) {
  6451. $where = "sku != 'Preset'";
  6452. //数据排序
  6453. $order_str = "id desc";
  6454. if (empty($page)) {
  6455. $start = 0;
  6456. $perpage = 1;
  6457. } else {
  6458. $start = ($page - 1) * $perpage;
  6459. }
  6460. $category = $this->input->get('category', true);
  6461. $warehouse = $this->input->get('warehouse', true);
  6462. $excelid = $this->input->get('sid', true);
  6463. if ($category) {
  6464. $where .= " and features like '%-$category-%'";
  6465. }
  6466. if ($warehouse) {
  6467. $where .= " and warehouse = '$warehouse'";
  6468. }
  6469. $xzid = '';
  6470. if ($excelid) {
  6471. $excelid = explode(',', trim($excelid, ','));
  6472. foreach ($excelid as $key => $value) {
  6473. $xzid .= " id = " . $value . " or";
  6474. }
  6475. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6476. }
  6477. //取得信息列表
  6478. /**
  6479. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6480. $rows = array();$list = array();
  6481. foreach ($info_list as $key=>$value)
  6482. {
  6483. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6484. }
  6485. **/
  6486. $list = array();
  6487. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6488. foreach ($rows as $key => $value) {
  6489. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6490. $zh = '';
  6491. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6492. foreach ($zt as $v) {
  6493. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6494. }
  6495. $zt = array_sum(array_column($zt, 'num'));
  6496. $number = $value['number'];
  6497. $ftime = time() - 15 * 24 * 3600;
  6498. $warehouse = $this->warehouse->read($value['warehouse']);
  6499. $rows[$key]['warehouse'] = $warehouse['title'];
  6500. $rows[$key]['number'] = $c;
  6501. $rows[$key]['features'] = $zh;
  6502. $rows[$key]['hb'] = $c + $zt;
  6503. }
  6504. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6505. $titlename = "<table border=1>
  6506. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6507. <tr align='center'>
  6508. <td>仓库</td>
  6509. <td>SKU</td>
  6510. <td>产品</td>
  6511. <td>库存数量</td>
  6512. <td>在途数量及预达日期</td>
  6513. <td>在途+库存数量</td>
  6514. </tr>
  6515. </table>";
  6516. $filename = $title . ".xls";
  6517. $tail = "";
  6518. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6519. }
  6520. if (isset($_GET['excel'])) {
  6521. $warehouse = $this->input->get('warehouse', true);
  6522. $sku = $this->input->get('sku', true);
  6523. $cz = $this->input->get('cz', true);
  6524. $text = $this->input->post('text', true);
  6525. $xztime = $this->input->get('xztime', true);
  6526. $timetk = $this->input->get('timetk', true);
  6527. $timetj = $this->input->get('timetj', true);
  6528. $timetk = strtotime($timetk);
  6529. $timetj = strtotime($timetj);
  6530. $where = "time = '0' ";
  6531. if ($warehouse) {
  6532. $where .= " and warehouse = '$warehouse'";
  6533. }
  6534. if ($sku) {
  6535. $where .= " and sku = '$sku'";
  6536. }
  6537. if ($text) {
  6538. $where .= " and text like '%$text%'";
  6539. }
  6540. if ($cz != '') {
  6541. $where .= " and cz = '$cz'";
  6542. }
  6543. if ($timetk && $timetj) {
  6544. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6545. }
  6546. //数据排序
  6547. $order_str = $xztime . " desc";
  6548. //取得信息列表
  6549. $zh = array();
  6550. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6551. foreach ($info_list as $v) {
  6552. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6553. $warehouse = $this->warehouse->read($v['warehouse']);
  6554. $v['warehouse'] = $warehouse['title'];
  6555. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6556. $v['stime'] = date('Y-m-d', $v['stime']);
  6557. if (isset($zh[$v['features']])) {
  6558. $zh[$v['features']]['num'] += $v['num'];
  6559. } else {
  6560. $zh[$v['features']] = $v;
  6561. }
  6562. $zh[$v['features']]['features'] = $c;
  6563. }
  6564. $title = "在途数据" . date('Y-m-d', time());
  6565. $titlename = "<table border=1>
  6566. <tr align='center'>
  6567. <td>仓库</td>
  6568. <td>SKU</td>
  6569. <td>名称</td>
  6570. <td>在途数量</td>
  6571. <td>库存数量</td>
  6572. <td>添加在途日期</td>
  6573. <td>预达日期</td>
  6574. <td>备注</td>
  6575. </tr>
  6576. </table>";
  6577. $filename = $title . ".xls";
  6578. $tail = "";
  6579. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6580. }
  6581. }
  6582. public function _fc()
  6583. {
  6584. $vip = 0;
  6585. if (isset($_SESSION['api'])) {
  6586. $user = $this->user->get_api($_SESSION['api']);
  6587. if ($user['vip'] == 1) {
  6588. $vip = 1;
  6589. }
  6590. } else {
  6591. header('Location: /');
  6592. exit;
  6593. }
  6594. $post = $this->input->post(NULL, TRUE);
  6595. if (isset($post['page'])) {
  6596. $page = $this->input->post('page', true);
  6597. $perpage = $this->input->post('perpage', true);
  6598. $category = $this->input->post('category', true);
  6599. $size = $this->input->post('size', true);
  6600. $grade = $this->input->post('grade', true);
  6601. $color = $this->input->post('color', true);
  6602. $lowe = $this->input->post('lowe', true);
  6603. $sku = $this->input->post('sku');
  6604. $title = $this->input->post('title');
  6605. $warehouse = $this->input->post('warehouse', true);
  6606. $usa = $this->input->post('usa', true);
  6607. $purchase = $this->input->post('purchase', true);
  6608. $lacetype = $this->input->post('lacetype', true);
  6609. $haircap = $this->input->post('haircap', true);
  6610. $density = $this->input->post('density', true);
  6611. $details = $this->input->post('details', true);
  6612. $state = $this->input->post('state', true);
  6613. $ktime = $this->input->post('ktime', true);
  6614. $jtime = $this->input->post('jtime', true);
  6615. $ktime = strtotime($ktime);
  6616. $jtime = strtotime($jtime);
  6617. $where = "state = '11'";
  6618. $gj = "";
  6619. $ck = "";
  6620. if ($lacetype) {
  6621. $where .= " and features like '%-$lacetype-%'";
  6622. }
  6623. if ($category) {
  6624. $where .= " and features like '%-$category-%'";
  6625. }
  6626. if ($size) {
  6627. $where .= " and features like '%-$size-%'";
  6628. }
  6629. if ($grade) {
  6630. $where .= " and features like '%-$grade-%'";
  6631. }
  6632. if ($color) {
  6633. $where .= " and features like '%-$color-%'";
  6634. }
  6635. if ($lowe) {
  6636. $where .= " and features like '%-$lowe-%'";
  6637. }
  6638. if ($haircap) {
  6639. $where .= " and features like '%-$haircap-%'";
  6640. }
  6641. if ($density) {
  6642. $where .= " and features like '%-$density-%'";
  6643. }
  6644. if ($usa) {
  6645. if (!$warehouse) {
  6646. $where .= " and (warehouse = '5' or warehouse = '8')";
  6647. }
  6648. }
  6649. if ($warehouse) {
  6650. $where .= " and warehouse = '$warehouse'";
  6651. }
  6652. if ($details) {
  6653. $where .= " and details = '$details'";
  6654. }
  6655. if ($purchase) {
  6656. $where .= " and purchase = '$purchase'";
  6657. }
  6658. if ($state) {
  6659. $where .= " and state = '$state'";
  6660. }
  6661. if ($ktime && $jtime) {
  6662. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6663. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6664. }
  6665. //数据排序
  6666. $order_str = "id desc";
  6667. if (empty($page)) {
  6668. $start = 0;
  6669. $perpage = 1;
  6670. } else {
  6671. $start = ($page - 1) * $perpage;
  6672. }
  6673. if ($sku) {
  6674. $sku = trim($sku, ' ');
  6675. $sku = trim($sku, ' ');
  6676. $where .= " and sku like '%$sku%'";
  6677. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6678. } else if ($title) {
  6679. $title = trim($title, ' ');
  6680. $title = trim($title, ' ');
  6681. $where .= " and title like '%$title%'";
  6682. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6683. } else {
  6684. //$where .= " and time > '$ktime' and time < '$jtime'";
  6685. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6686. }
  6687. //取得信息列表
  6688. $rows = array();
  6689. $list = array();
  6690. foreach ($info_list as $key => $value) {
  6691. $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'] . '"');
  6692. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6693. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6694. $warehouse = $this->warehouse->read($value['warehouse']);
  6695. $info_list[$key]['warehouse'] = $warehouse['title'];
  6696. $info_list[$key]['number'] = $g;
  6697. $info_list[$key]['features'] = $x;
  6698. $info_list[$key]['x'] = $s;
  6699. }
  6700. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6701. $pagenum = ceil($total / $perpage);
  6702. $over = $total - ($start + $perpage);
  6703. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6704. echo json_encode($rows);
  6705. exit;
  6706. }
  6707. $this->data['vip'] = $vip;
  6708. $this->_Template('whlabel_fc', $this->data);
  6709. }
  6710. public function _fcmb()
  6711. {
  6712. $where = "sku != 'Preset'";
  6713. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6714. foreach ($rows as $k => $v) {
  6715. $warehouse = $this->warehouse->read($v['warehouse']);
  6716. $rows[$k]['warehouse'] = $warehouse['title'];
  6717. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6718. $rows[$k]['t'] = '';
  6719. $rows[$k]['n'] = '';
  6720. }
  6721. $title = "封货产品数据导入模板";
  6722. $titlename = "<table border=1>
  6723. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6724. <tr align='center'>
  6725. <td>仓库</td>
  6726. <td>SKU</td>
  6727. <td>产品</td>
  6728. <td>封存产品总数量</td>
  6729. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6730. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6731. </tr>
  6732. </table>";
  6733. $filename = $title . ".xls";
  6734. $tail = "";
  6735. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6736. }
  6737. public function _fcexcel()
  6738. {
  6739. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6740. $config['upload_path'] = '.' . $dir;
  6741. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6742. $config['allowed_types'] = 'xls|xlsx|csv';
  6743. $config['max_size'] = 10240;
  6744. $this->load->library('upload', $config);
  6745. $this->upload->initialize($config);
  6746. if ($this->upload->do_upload('userfile')) {
  6747. $full_path = $dir . $this->upload->data('file_name');
  6748. $fileName = '.' . $full_path;
  6749. if (!file_exists($fileName)) {
  6750. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6751. exit;
  6752. } else {
  6753. libxml_use_internal_errors(true);
  6754. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6755. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6756. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6757. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6758. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6759. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6760. ++$column; //如果列数大于26行
  6761. $list = array();
  6762. for ($i = 2; $i <= $row; $i++) // 行数循环
  6763. {
  6764. $data = array();
  6765. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6766. {
  6767. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6768. }
  6769. $list[] = $data;
  6770. }
  6771. }
  6772. $i = 0;
  6773. $j = 0;
  6774. $ed = array();
  6775. foreach ($list as $key => $value) {
  6776. $time = time();
  6777. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6778. continue;
  6779. }
  6780. $warehouse = $this->warehouse->get_title($value['0']);
  6781. $sku = $value['1'];
  6782. $type = $value['4']; //调整方式0扣减1删除
  6783. $num = $value['5']; //调整数量
  6784. //$text = $value['4'];//扣减说明
  6785. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6786. if (!$d) //如果没有这个SKU
  6787. {
  6788. $ed[] = array($sku . '-库存中不存在此SKU');
  6789. $j++;
  6790. continue;
  6791. }
  6792. if (!isset($warehouse['id'])) {
  6793. $ed[] = array($sku . '-仓库名错误!');
  6794. $j++;
  6795. continue;
  6796. }
  6797. if ($type == 1 || $type == 2) //扣减库存
  6798. {
  6799. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6800. if (count($data) < abs($num)) {
  6801. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6802. $j++;
  6803. continue;
  6804. }
  6805. if ($type == 1) //转入库存
  6806. {
  6807. for ($i = 0; $i < abs($num); $i++) {
  6808. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6809. }
  6810. } else if ($type == 2) //删除
  6811. {
  6812. for ($i = 0; $i < abs($num); $i++) {
  6813. $this->whlabel->remove($data[$i]['id']);
  6814. }
  6815. }
  6816. } else if ($type == 0) //增加库存
  6817. {
  6818. $post['sku'] = $d['sku'];
  6819. $post['shop'] = '';
  6820. $post['warehouse'] = $warehouse['id'];
  6821. $post['purchase'] = $d['purchase'];
  6822. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6823. $post['state'] = 11;
  6824. $post['title'] = $d['title'];
  6825. $post['number'] = $d['number'];
  6826. $post['features'] = $d['features'];
  6827. $post['enter'] = $time;
  6828. $post['time'] = $time; //操作时间
  6829. for ($i = 0; $i < $num; $i++) {
  6830. $post['label'] = time() . rand(100, 999) . $i;
  6831. $this->whlabel->insert($post);
  6832. }
  6833. }
  6834. sleep(1); //防止入库时间一样,需要延迟1秒
  6835. }
  6836. if ($j > 0) {
  6837. $tt = date('Ymd', time());
  6838. $title = '库存导入错误信息-' . $tt;
  6839. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6840. $tail = "\n";
  6841. $filename = $title . ".xls";
  6842. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6843. $dir = '/data/excel/' . $time . '/';
  6844. $file_name = 'error_' . $time . rand(1000, 9999);
  6845. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6846. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6847. fwrite($myfile, $ecl);
  6848. fclose($myfile);
  6849. $error = $dir . $file_name . '.xls';
  6850. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6851. exit;
  6852. } else {
  6853. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6854. exit;
  6855. }
  6856. }
  6857. }
  6858. public function _fcjxc($arg_array)
  6859. {
  6860. if (isset($_GET['excel'])) {
  6861. $category = $this->input->get('category', true);
  6862. $size = $this->input->get('size', true);
  6863. $grade = $this->input->get('grade', true);
  6864. $color = $this->input->get('color', true);
  6865. $lowe = $this->input->get('lowe', true);
  6866. $sku = $this->input->get('sku');
  6867. $title = $this->input->get('title');
  6868. $warehouse = $arg_array[0];
  6869. $usa = $this->input->get('usa', true);
  6870. $purchase = $this->input->get('purchase', true);
  6871. $lacetype = $this->input->get('lacetype', true);
  6872. $haircap = $this->input->get('haircap', true);
  6873. $density = $this->input->get('density', true);
  6874. $title = $this->input->get('title', true);
  6875. $state = $this->input->get('state', true);
  6876. $ktime = $this->input->get('ktime', true);
  6877. $jtime = $this->input->get('jtime', true);
  6878. $where = "state=11";
  6879. $gj = "";
  6880. $ck = "";
  6881. if ($lacetype) {
  6882. $where .= " and features like '%-$lacetype-%'";
  6883. }
  6884. if ($category) {
  6885. $where .= " and features like '%-$category-%'";
  6886. }
  6887. if ($size) {
  6888. $where .= " and features like '%-$size-%'";
  6889. }
  6890. if ($grade) {
  6891. $where .= " and features like '%-$grade-%'";
  6892. }
  6893. if ($color) {
  6894. $where .= " and features like '%-$color-%'";
  6895. }
  6896. if ($lowe) {
  6897. $where .= " and features like '%-$lowe-%'";
  6898. }
  6899. if ($haircap) {
  6900. $where .= " and features like '%-$haircap-%'";
  6901. }
  6902. if ($density) {
  6903. $where .= " and features like '%-$density-%'";
  6904. }
  6905. if ($usa) {
  6906. if (!$warehouse) {
  6907. $where .= " and (warehouse = '5' or warehouse = '8')";
  6908. }
  6909. }
  6910. if ($warehouse) {
  6911. $where .= " and warehouse = '$warehouse'";
  6912. }
  6913. if ($purchase) {
  6914. $where .= " and purchase = '$purchase'";
  6915. }
  6916. if ($state) {
  6917. $where .= " and state = '$state'";
  6918. }
  6919. $order_str = "id desc";
  6920. if ($sku) {
  6921. $sku = trim($sku, ' ');
  6922. $sku = trim($sku, ' ');
  6923. $where .= " and sku like '%$sku%'";
  6924. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6925. } else if ($title) {
  6926. $title = trim($title, ' ');
  6927. $title = trim($title, ' ');
  6928. $where .= " and title like '%$title%'";
  6929. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6930. } else {
  6931. //$where .= " and time > '$ktime' and time < '$jtime'";
  6932. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6933. }
  6934. //取得信息列表
  6935. $rows = array();
  6936. $list = array();
  6937. foreach ($info_list as $key => $value) {
  6938. $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'] . '"');
  6939. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6940. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6941. $rows[$key] = $value;
  6942. $warehouse = $this->warehouse->read($value['warehouse']);
  6943. $rows[$key]['warehouse'] = $warehouse['title'];
  6944. $rows[$key]['features'] = $g;
  6945. $rows[$key]['a'] = $x;
  6946. $rows[$key]['b'] = $s;
  6947. }
  6948. $title = "总统计表";
  6949. $titlename = "<table border=1>
  6950. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6951. <tr align='center'>
  6952. <td>仓库</td>
  6953. <td>SKU</td>
  6954. <td>产品名称</td>
  6955. <td>录入总量</td>
  6956. <td>取出总量</td>
  6957. <td>剩余总量</td>
  6958. </tr>
  6959. </table>";
  6960. $filename = $title . ".xls";
  6961. $tail = "";
  6962. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6963. }
  6964. $vip = 0;
  6965. if (isset($_SESSION['api'])) {
  6966. $user = $this->user->get_api($_SESSION['api']);
  6967. if ($user['vip'] == 1) {
  6968. $vip = 1;
  6969. }
  6970. } else {
  6971. header('Location: /');
  6972. exit;
  6973. }
  6974. $post = $this->input->post(NULL, TRUE);
  6975. if (isset($post['page'])) {
  6976. $page = $this->input->post('page', true);
  6977. $perpage = $this->input->post('perpage', true);
  6978. $category = $this->input->post('category', true);
  6979. $size = $this->input->post('size', true);
  6980. $grade = $this->input->post('grade', true);
  6981. $color = $this->input->post('color', true);
  6982. $lowe = $this->input->post('lowe', true);
  6983. $sku = $this->input->post('sku');
  6984. $title = $this->input->post('title');
  6985. $warehouse = $arg_array[0];
  6986. $usa = $this->input->post('usa', true);
  6987. $purchase = $this->input->post('purchase', true);
  6988. $lacetype = $this->input->post('lacetype', true);
  6989. $haircap = $this->input->post('haircap', true);
  6990. $density = $this->input->post('density', true);
  6991. $title = $this->input->post('title', true);
  6992. $state = $this->input->post('state', true);
  6993. $ktime = $this->input->post('ktime', true);
  6994. $jtime = $this->input->post('jtime', true);
  6995. $ktime = strtotime($ktime);
  6996. $jtime = strtotime($jtime);
  6997. $where = "state=11";
  6998. $gj = "";
  6999. $ck = "";
  7000. if ($lacetype) {
  7001. $where .= " and features like '%-$lacetype-%'";
  7002. }
  7003. if ($category) {
  7004. $where .= " and features like '%-$category-%'";
  7005. }
  7006. if ($size) {
  7007. $where .= " and features like '%-$size-%'";
  7008. }
  7009. if ($grade) {
  7010. $where .= " and features like '%-$grade-%'";
  7011. }
  7012. if ($color) {
  7013. $where .= " and features like '%-$color-%'";
  7014. }
  7015. if ($lowe) {
  7016. $where .= " and features like '%-$lowe-%'";
  7017. }
  7018. if ($haircap) {
  7019. $where .= " and features like '%-$haircap-%'";
  7020. }
  7021. if ($density) {
  7022. $where .= " and features like '%-$density-%'";
  7023. }
  7024. if ($usa) {
  7025. if (!$warehouse) {
  7026. $where .= " and (warehouse = '5' or warehouse = '8')";
  7027. }
  7028. }
  7029. if ($warehouse) {
  7030. $where .= " and warehouse = '$warehouse'";
  7031. }
  7032. if ($purchase) {
  7033. $where .= " and purchase = '$purchase'";
  7034. }
  7035. if ($state) {
  7036. $where .= " and state = '$state'";
  7037. }
  7038. if ($ktime && $jtime) {
  7039. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7040. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7041. }
  7042. //数据排序
  7043. $order_str = "id desc";
  7044. $xs = 0;
  7045. $rows = array();
  7046. $list = array();
  7047. if (empty($page)) {
  7048. $start = 0;
  7049. $perpage = 1;
  7050. } else {
  7051. $start = ($page - 1) * $perpage;
  7052. }
  7053. if ($sku || $title) {
  7054. if ($title) {
  7055. $title = trim($title, ' ');
  7056. $title = trim($title, ' ');
  7057. $where .= " and title like '%$title%'";
  7058. } else {
  7059. $sku = trim($sku, ' ');
  7060. $sku = trim($sku, ' ');
  7061. $where .= " and sku like '%$sku%'";
  7062. }
  7063. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7064. foreach ($info_list as $key => $value) {
  7065. $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'] . '"');
  7066. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7067. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7068. $rows[$key] = $value;
  7069. $warehouse = $this->warehouse->read($value['warehouse']);
  7070. $rows[$key]['warehouse'] = $warehouse['title'];
  7071. $rows[$key]['features'] = $g;
  7072. $rows[$key]['a'] = $x;
  7073. $rows[$key]['b'] = $s;
  7074. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7075. $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天销量
  7076. $yj = $c / ($xl / 30);
  7077. if ($yj < 7) {
  7078. $rows[$key]['y'] = round($yj) . '天销量';
  7079. } else {
  7080. $rows[$key]['y'] = '正常';
  7081. }
  7082. }
  7083. } else {
  7084. //$where .= " and time > '$ktime' and time < '$jtime'";
  7085. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7086. foreach ($info_list as $key => $value) {
  7087. $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'] . '"');
  7088. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7089. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7090. $zs[$key] = $value;
  7091. $warehouse = $this->warehouse->read($value['warehouse']);
  7092. $zs[$key]['warehouse'] = $warehouse['title'];
  7093. $zs[$key]['features'] = $g;
  7094. $zs[$key]['a'] = $x;
  7095. $zs[$key]['b'] = $s;
  7096. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7097. $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天销量
  7098. $yj = $c / ($xl / 30);
  7099. if ($yj < 7) {
  7100. $zs[$key]['y'] = round($yj) . '天销量';
  7101. $rows[$key] = $zs[$key];
  7102. }
  7103. }
  7104. }
  7105. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7106. $pagenum = ceil($total / $perpage);
  7107. $over = $total - ($start + $perpage);
  7108. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7109. echo json_encode($rows);
  7110. exit;
  7111. }
  7112. $this->data['arg_array'] = $arg_array[0];
  7113. $this->_Template('whlabel_fcjxc', $this->data);
  7114. }
  7115. public function _0kcdel()
  7116. {
  7117. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7118. $config['upload_path'] = '.' . $dir;
  7119. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7120. $config['allowed_types'] = 'xls|xlsx|csv';
  7121. $config['max_size'] = 10240;
  7122. $this->load->library('upload', $config);
  7123. $this->upload->initialize($config);
  7124. if ($this->upload->do_upload('userfile')) {
  7125. $full_path = $dir . $this->upload->data('file_name');
  7126. $fileName = '.' . $full_path;
  7127. if (!file_exists($fileName)) {
  7128. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7129. exit;
  7130. } else {
  7131. require_once "./data/excel/PHPExcel/IOFactory.php";
  7132. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7133. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7134. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7135. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7136. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7137. ++$column; //如果列数大于26行
  7138. $list = array();
  7139. for ($i = 2; $i <= $row; $i++) // 行数循环
  7140. {
  7141. $data = array();
  7142. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7143. {
  7144. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7145. }
  7146. $list[] = $data;
  7147. }
  7148. }
  7149. $i = 0;
  7150. $j = 0;
  7151. $ed = array();
  7152. foreach ($list as $key => $value) {
  7153. $time = time();
  7154. if ($value['0'] == "" || $value['1'] == "") {
  7155. continue;
  7156. }
  7157. $warehouse = $this->warehouse->get_title($value['0']);
  7158. $sku = $value['1'];
  7159. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7160. if (!$d) //如果没有这个SKU
  7161. {
  7162. $ed[] = array($sku . '-库存中不存在此SKU');
  7163. $j++;
  7164. continue;
  7165. }
  7166. if (!isset($warehouse['id'])) {
  7167. $ed[] = array($sku . '-仓库名错误!');
  7168. $j++;
  7169. continue;
  7170. }
  7171. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7172. if ($z < 1) {
  7173. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7174. foreach ($z as $v) {
  7175. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7176. if (count($zt) > 0) {
  7177. $ed[] = array($sku . '-有在途库存无法删除!');
  7178. $j++;
  7179. continue;
  7180. }
  7181. $this->whlabel->remove($v['id']);
  7182. }
  7183. } else {
  7184. $ed[] = array($sku . '-非0库存!');
  7185. $j++;
  7186. continue;
  7187. }
  7188. }
  7189. if ($j > 0) {
  7190. $tt = date('Ymd', time());
  7191. $title = '删除0库存错误信息-' . $tt;
  7192. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7193. $tail = "\n";
  7194. $filename = $title . ".xls";
  7195. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7196. $dir = '/data/excel/' . $time . '/';
  7197. $file_name = 'error_' . $time . rand(1000, 9999);
  7198. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7199. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7200. fwrite($myfile, $ecl);
  7201. fclose($myfile);
  7202. $error = $dir . $file_name . '.xls';
  7203. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7204. exit;
  7205. } else {
  7206. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7207. exit;
  7208. }
  7209. }
  7210. }
  7211. public function _gbhtype()
  7212. {
  7213. $post = $this->input->post(NULL, TRUE);
  7214. if (isset($post['s'])) {
  7215. $n = $this->input->post('n');
  7216. $d = $this->input->post('s');
  7217. if (!$d) {
  7218. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7219. exit;
  7220. }
  7221. $d = explode(',', trim($d, ','));
  7222. $t = $this->whlabel_type->read($n);
  7223. //循环删除记录
  7224. foreach ($d as $v) {
  7225. $u = $this->whlabel->read($v);
  7226. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7227. foreach ($data as $val) {
  7228. $this->whlabel->save(array('type' => $n), $val['id']);
  7229. }
  7230. }
  7231. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7232. }
  7233. }
  7234. //出库、退库导出
  7235. public function _dccrtype()
  7236. {
  7237. $classid = $this->classid->sku();
  7238. $pm = $classid;
  7239. $typeclass = array();
  7240. $tc = $this->typeclass->find_all();
  7241. foreach ($tc as $v) {
  7242. $typeclass[$v['id']] = $v;
  7243. }
  7244. $prc = array();
  7245. $purchase = $this->purchase->find_all();
  7246. foreach ($purchase as $k => $v) {
  7247. $prc[$v['id']] = $v['title'];
  7248. }
  7249. if (isset($_GET['sid'])) {
  7250. $wh = array();
  7251. $w = $this->warehouse->find_all('1=1', 'id,title');
  7252. foreach ($w as $v) {
  7253. $wh[$v['id']] = $v['title'];
  7254. }
  7255. $type = $this->input->get('excel', true);
  7256. $category = $this->input->get('category', true);
  7257. $size = $this->input->get('size', true);
  7258. $grade = $this->input->get('grade', true);
  7259. $color = $this->input->get('color', true);
  7260. $lowe = $this->input->get('lowe', true);
  7261. $sku = $this->input->get('sku', true);
  7262. $warehouse = $this->input->get('warehouse', true);
  7263. $lacetype = $this->input->get('lacetype', true);
  7264. $lacecolor = $this->input->get('lacecolor', true);
  7265. $density = $this->input->get('density', true);
  7266. $haircap = $this->input->get('haircap', true);
  7267. $purchase = $this->input->get('purchase', true);
  7268. $title = $this->input->get('title', true);
  7269. $state = $this->input->get('state', true);
  7270. $sid = $this->input->get('sid', true);
  7271. $ktime = $this->input->get('ktime', true);
  7272. $jtime = $this->input->get('jtime', true);
  7273. $ktime = strtotime($ktime);
  7274. $jtime = strtotime($jtime);
  7275. $where = "1=1";
  7276. $gj = "";
  7277. $ck = "";
  7278. if ($category) {
  7279. $where .= " and features like '%-$category-%'";
  7280. }
  7281. if ($size) {
  7282. $where .= " and features like '%-$size-%'";
  7283. }
  7284. if ($grade) {
  7285. $where .= " and features like '%-$grade-%'";
  7286. }
  7287. if ($color) {
  7288. $where .= " and features like '%-$color-%'";
  7289. }
  7290. if ($lowe) {
  7291. $where .= " and features like '%-$lowe-%'";
  7292. }
  7293. if ($warehouse) {
  7294. $where .= " and warehouse = '$warehouse'";
  7295. }
  7296. if ($purchase) {
  7297. $where .= " and purchase = '$purchase'";
  7298. }
  7299. if ($state) {
  7300. $where .= " and state = '$state'";
  7301. }
  7302. if ($lacetype) {
  7303. $where .= " and features like '%-$lacetype-%'";
  7304. }
  7305. if ($lacecolor) {
  7306. $where .= " and features like '%-$lacecolor-%'";
  7307. }
  7308. if ($density) {
  7309. $where .= " and features like '%-$density-%'";
  7310. }
  7311. if ($haircap) {
  7312. $where .= " and features like '%-$haircap-%'";
  7313. }
  7314. if ($title) {
  7315. $title = trim($title, ' ');
  7316. $title = trim($title, ' ');
  7317. $where .= " and title like '%$title%'";
  7318. }
  7319. if ($sku) {
  7320. $sku = trim($sku, ' ');
  7321. $sku = trim($sku, ' ');
  7322. $where .= " and sku like '%$sku%'";
  7323. }
  7324. if ($ktime && $jtime) {
  7325. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7326. }
  7327. $sidwhere = '';
  7328. if ($sid) {
  7329. $sd = "";
  7330. $s = explode(',', trim($sid, ','));
  7331. foreach ($s as $value) {
  7332. $sd .= " id = " . $value . " or";
  7333. }
  7334. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7335. }
  7336. //数据排序
  7337. $order_str = "time desc";
  7338. if (empty($page)) {
  7339. $start = 0;
  7340. $perpage = 1;
  7341. } else {
  7342. $start = ($page - 1) * $perpage;
  7343. }
  7344. $wh = array();
  7345. $w = $this->warehouse->find_all('1=1', 'id,title');
  7346. foreach ($w as $v) {
  7347. $wh[$v['id']] = $v['title'];
  7348. }
  7349. $wt = array();
  7350. $whlabel_type = $this->whlabel_type->find_all();
  7351. foreach ($whlabel_type as $v) {
  7352. $wt[$v['id']] = $v['title'];
  7353. }
  7354. $classid = $this->classid->sku();
  7355. $list = array();
  7356. $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');
  7357. foreach ($rows_r as $key => $value) {
  7358. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7359. $pm = $classid;
  7360. $jm = $classid;
  7361. $rows_r[$key]['enter'] = '入库';
  7362. $rows_r[$key]['time'] = $value['enter'];
  7363. if ($value['rktype'] == 1) {
  7364. $rows_r[$key]['rktype'] = '采购入库';
  7365. } else if ($value['rktype'] == 2) {
  7366. $rows_r[$key]['rktype'] = '盘盈调整';
  7367. } else if ($value['rktype'] == 3) {
  7368. $rows_r[$key]['rktype'] = '其他调整入库';
  7369. } else if ($value['rktype'] == 4) {
  7370. $rows_r[$key]['rktype'] = '其他调整入库';
  7371. } else if ($value['rktype'] == 5) {
  7372. $rows_r[$key]['rktype'] = '退库入库';
  7373. } else if ($value['rktype'] == 6) {
  7374. $rows_r[$key]['rktype'] = '退货可用入库';
  7375. } else if ($value['rktype'] == 7) {
  7376. $rows_r[$key]['rktype'] = '形态转换入库';
  7377. } else {
  7378. $rows_r[$key]['rktype'] = '';
  7379. }
  7380. $features = explode('-', trim($value['features'], '-'));
  7381. foreach ($features as $v) {
  7382. if (isset($typeclass[$v])) {
  7383. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7384. $pm[$typeclass[$v]['classid']] = $zh[0];
  7385. }
  7386. if (isset($typeclass[$v])) {
  7387. if (isset($jm[$typeclass[$v]['classid']])) {
  7388. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7389. }
  7390. }
  7391. }
  7392. $zh = implode(" ", $pm);
  7393. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7394. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7395. $rows_r[$key]['zh'] = $zh;
  7396. $jm = array_filter($jm);
  7397. $rows_r[$key]['features'] = implode("-", $jm);
  7398. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7399. }
  7400. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  7401. foreach ($rows_c as $key => $value) {
  7402. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7403. $pm = $classid;
  7404. $jm = $classid;
  7405. $rows_c[$key]['time'] = $value['outk'];
  7406. $rows_c[$key]['outk'] = '出库';
  7407. if ($value['cktype'] == 1) {
  7408. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7409. } else if ($value['cktype'] == 2) {
  7410. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7411. } else if ($value['cktype'] == 3) {
  7412. $rows_c[$key]['cktype'] = '盘亏调整';
  7413. } else if ($value['cktype'] == 4) {
  7414. $rows_c[$key]['cktype'] = '其他调整出库';
  7415. } else if ($value['cktype'] == 5) {
  7416. $rows_c[$key]['cktype'] = '形态转换出库';
  7417. } else {
  7418. $rows_c[$key]['cktype'] = '';
  7419. }
  7420. unset($rows_c[$key]['state']);
  7421. $features = explode('-', trim($value['features'], '-'));
  7422. foreach ($features as $v) {
  7423. if (isset($typeclass[$v])) {
  7424. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7425. $pm[$typeclass[$v]['classid']] = $zh[0];
  7426. }
  7427. if (isset($typeclass[$v])) {
  7428. if (isset($jm[$typeclass[$v]['classid']])) {
  7429. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7430. }
  7431. }
  7432. }
  7433. $zh = implode(" ", $pm);
  7434. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7435. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7436. $rows_c[$key]['zh'] = $zh;
  7437. $jm = array_filter($jm);
  7438. $rows_c[$key]['features'] = implode("-", $jm);
  7439. $rows_c[$key]['number'] = 1;
  7440. }
  7441. $merged = $rows_r;
  7442. foreach ($rows_c as $key => $value) {
  7443. if (isset($merged[$key])) {
  7444. $merged[] = $value;
  7445. } else {
  7446. $merged[$key] = $value;
  7447. }
  7448. }
  7449. usort($merged, function ($a, $b) {
  7450. return $a['time'] - $b['time'];
  7451. });
  7452. foreach ($merged as $key => $value) {
  7453. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7454. }
  7455. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7456. $titlename = "<table border=1>
  7457. <tr align='center'>
  7458. <td>仓库</td>
  7459. <td>SKU</td>
  7460. <td>商品名称</td>
  7461. <td>仓库品名</td>
  7462. <td>料号</td>
  7463. <td>时间</td>
  7464. <td>操作</td>
  7465. <td>类型</td>
  7466. <td>数量</td>
  7467. <td>备注</td>
  7468. </tr>
  7469. </table>";
  7470. $filename = $title . ".xlsx";
  7471. $tail = "";
  7472. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7473. }
  7474. }
  7475. /*************************************处理exceljs导出****************************************************/
  7476. public function _excelrjs(){
  7477. if (isset($_GET['excel'])) {
  7478. $category = $this->input->get('category', true);
  7479. $size = $this->input->get('size', true);
  7480. $grade = $this->input->get('grade', true);
  7481. $color = $this->input->get('color', true);
  7482. $lowe = $this->input->get('lowe', true);
  7483. $sku = $this->input->get('sku', true);
  7484. $warehouse = $this->input->get('warehouse', true);
  7485. $purchase = $this->input->get('purchase', true);
  7486. $ktime = $this->input->get('ktime', true);
  7487. $jtime = $this->input->get('jtime', true);
  7488. $ktime = strtotime($ktime);
  7489. $jtime = strtotime($jtime);
  7490. $where = "1=1";
  7491. $gj = "";
  7492. $ck = "";
  7493. if ($category) {
  7494. $where .= " and features like '%-$category-%'";
  7495. }
  7496. if ($size) {
  7497. $where .= " and features like '%-$size-%'";
  7498. }
  7499. if ($grade) {
  7500. $where .= " and features like '%-$grade-%'";
  7501. }
  7502. if ($color) {
  7503. $where .= " and features like '%-$color-%'";
  7504. }
  7505. if ($lowe) {
  7506. $where .= " and features like '%-$lowe-%'";
  7507. }
  7508. if ($warehouse) {
  7509. $where .= " and warehouse = '$warehouse'";
  7510. }
  7511. if ($purchase) {
  7512. $where .= " and purchase = '$purchase'";
  7513. }
  7514. if ($sku) {
  7515. $where .= " and sku = '$sku'";
  7516. }
  7517. if ($ktime && $jtime) {
  7518. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7519. }
  7520. //数据排序
  7521. $order_str = "id desc";
  7522. if (empty($page)) {
  7523. $start = 0;
  7524. $perpage = 1;
  7525. } else {
  7526. $start = ($page - 1) * $perpage;
  7527. }
  7528. $list = array();
  7529. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7530. foreach ($rows as $value) {
  7531. $ck = $this->warehouse->read($value['warehouse']);
  7532. $warehouse = $ck['title'];
  7533. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7534. $retreatwarehouse = $tkck['title'];
  7535. $gy = $this->purchase->read($value['purchase']);
  7536. $purchase = $gy['title'];
  7537. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7538. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7539. }
  7540. // $list = [
  7541. // [
  7542. // 'warehouse'=>"许昌仓",
  7543. // 'sku'=>"123456",
  7544. // 'title'=>"商品名称",
  7545. // 'time'=>"2021-01-01 12:00:00",
  7546. // 'number'=>"121-111121"
  7547. // ],
  7548. // [
  7549. // 'warehouse'=>"美仓",
  7550. // 'sku'=>"353456",
  7551. // 'title'=>"商品名称1",
  7552. // 'time'=>"2021-01-01 12:01:00",
  7553. // 'number'=>"121-1333121"
  7554. // ],
  7555. // ];
  7556. if(empty($list)){
  7557. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7558. }else{
  7559. $final_list = [];
  7560. foreach($list as $v){
  7561. $final_list[] = array_values($v);
  7562. }
  7563. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7564. array_unshift($final_list,[
  7565. "仓库","SKU","商品名称","时间","数量"
  7566. ]);
  7567. array_unshift($final_list,[
  7568. $title,"","","",""
  7569. ]);
  7570. exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
  7571. }
  7572. }
  7573. }
  7574. //出库、退库导出
  7575. public function _excelctjs()
  7576. {
  7577. $classid = $this->classid->sku();
  7578. $pm = $classid;
  7579. $typeclass = array();
  7580. $tc = $this->typeclass->find_all();
  7581. foreach ($tc as $v) {
  7582. $typeclass[$v['id']] = $v;
  7583. }
  7584. $prc = array();
  7585. $purchase = $this->purchase->find_all();
  7586. foreach ($purchase as $k => $v) {
  7587. $prc[$v['id']] = $v['title'];
  7588. }
  7589. if (isset($_GET['excel'])) {
  7590. $wh = array();
  7591. $w = $this->warehouse->find_all('1=1', 'id,title');
  7592. foreach ($w as $v) {
  7593. $wh[$v['id']] = $v['title'];
  7594. }
  7595. $type = $this->input->get('excel', true);
  7596. $category = $this->input->get('category', true);
  7597. $size = $this->input->get('size', true);
  7598. $grade = $this->input->get('grade', true);
  7599. $color = $this->input->get('color', true);
  7600. $lowe = $this->input->get('lowe', true);
  7601. $sku = $this->input->get('sku', true);
  7602. $title = $this->input->get('title', true);
  7603. $warehouse = $this->input->get('warehouse', true);
  7604. $purchase = $this->input->get('purchase', true);
  7605. $lacetype = $this->input->get('lacetype', true);
  7606. $haircap = $this->input->get('haircap', true);
  7607. $lacecolor = $this->input->get('lacecolor', true);
  7608. $density = $this->input->get('density', true);
  7609. $details = $this->input->get('details', true);
  7610. $state = $this->input->get('state', true);
  7611. $shop = $this->input->get('shop', true);
  7612. $hairnumber = $this->input->get('hairnumber', true);
  7613. $type_leixi = $this->input->get('type', true);
  7614. $cpbz = $this->input->get('cpbz', true);
  7615. $sm = $this->input->get('sm', true);
  7616. $sid = $this->input->get('sid', true);
  7617. $ktime = $this->input->get('ktime', true);
  7618. $jtime = $this->input->get('jtime', true);
  7619. $ktime = strtotime($ktime);
  7620. $jtime = strtotime($jtime);
  7621. //$where = " 1=1 ";
  7622. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7623. $where = " sku != '' ";
  7624. $gj = "";
  7625. $ck = "";
  7626. if ($category) {
  7627. $where .= " and features like '%-$category-%'";
  7628. }
  7629. if ($size) {
  7630. $where .= " and features like '%-$size-%'";
  7631. }
  7632. if ($grade) {
  7633. $where .= " and features like '%-$grade-%'";
  7634. }
  7635. if ($color) {
  7636. $where .= " and features like '%-$color-%'";
  7637. }
  7638. if ($lowe) {
  7639. $where .= " and features like '%-$lowe-%'";
  7640. }
  7641. if ($warehouse) {
  7642. $where .= " and warehouse = '$warehouse'";
  7643. }
  7644. if ($purchase) {
  7645. $where .= " and purchase = '$purchase'";
  7646. }
  7647. if ($state) {
  7648. $where .= " and state = '$state'";
  7649. }
  7650. if ($lacetype) {
  7651. $where .= " and features like '%-$lacetype-%'";
  7652. }
  7653. if ($lacecolor) {
  7654. $where .= " and features like '%-$lacecolor-%'";
  7655. }
  7656. if ($density) {
  7657. $where .= " and features like '%-$density-%'";
  7658. }
  7659. if ($haircap) {
  7660. $where .= " and features like '%-$haircap-%'";
  7661. }
  7662. if ($details) {
  7663. $where .= " and details = '$details'";
  7664. }
  7665. if ($shop) {
  7666. $where .= " and shop like '%$shop%'";
  7667. }
  7668. if ($title) {
  7669. $title = trim($title, ' ');
  7670. $title = trim($title, ' ');
  7671. $where .= " and title like '%$title%'";
  7672. }
  7673. if (!empty($hairnumber)) {
  7674. $where .= " and features like '%-128-%' ";
  7675. if ($hairnumber < 0) {
  7676. $class_list = $this->typeclass->find_all('classid = 43');
  7677. foreach ($class_list as $v) {
  7678. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7679. }
  7680. } else {
  7681. $where .= " and features like '%-$hairnumber-%'";
  7682. }
  7683. }
  7684. if ($type_leixi) {
  7685. $where .= " and type = '$type_leixi'";
  7686. }
  7687. if ($cpbz) {
  7688. $where .= " and cpbz like '%$cpbz%' ";
  7689. }
  7690. if ($sm) {
  7691. $where .= " and sm like '%$sm%' ";
  7692. }
  7693. if ($sku) {
  7694. $sku = trim($sku, ' ');
  7695. $sku = trim($sku, ' ');
  7696. $where .= " and sku like '%$sku%'";
  7697. }
  7698. if ($ktime && $jtime) {
  7699. if ($type == 1) {
  7700. $tl = '出库';
  7701. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7702. } else if ($type == 2) {
  7703. $tl = '退库';
  7704. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7705. } else if ($type == 3) {
  7706. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7707. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7708. } else if ($type == 4) {
  7709. $tl = '出库+零售';
  7710. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7711. } else if ($type == 5) {
  7712. $tl = '零售';
  7713. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7714. }
  7715. }
  7716. $sidwhere = '';
  7717. if ($sid) {
  7718. $sd = "";
  7719. $s = explode(',', trim($sid, ','));
  7720. foreach ($s as $value) {
  7721. $sd .= " id = " . $value . " or";
  7722. }
  7723. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7724. }
  7725. //数据排序
  7726. $order_str = "time desc";
  7727. if (empty($page)) {
  7728. $start = 0;
  7729. $perpage = 1;
  7730. } else {
  7731. $start = ($page - 1) * $perpage;
  7732. }
  7733. //取得信息列表
  7734. if ($type != 3 && $type != 5) {
  7735. if ($type == 1 || $type == 4) {
  7736. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7737. foreach ($info_list as $key => $value) {
  7738. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7739. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7740. $warehouse = $this->warehouse->read($value['warehouse']);
  7741. $info_list[$key]['warehouse'] = $warehouse['title'];
  7742. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7743. $features = explode('-', trim($features, '-'));
  7744. $pm = $classid;
  7745. foreach ($features as $k => $v) {
  7746. if ($v != 0) {
  7747. if (!isset($typeclass[$v])) {
  7748. continue;
  7749. }
  7750. if (isset($pm[$typeclass[$v]['classid']])) {
  7751. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7752. $tz = explode('|', $typeclass[$v]['zh']);
  7753. $pm[$typeclass[$v]['classid']] = $tz[0];
  7754. } else {
  7755. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7756. }
  7757. }
  7758. }
  7759. }
  7760. $zh = implode(" ", $pm);
  7761. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7762. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7763. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7764. $info_list[$key]['features'] = $zh;
  7765. }
  7766. $final_list = [];
  7767. foreach($info_list as $k=>$v){
  7768. $number = "";
  7769. if(!empty($v['orderinfo'])){
  7770. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7771. if(!empty($tmp_info['number'])){
  7772. $number = $tmp_info['number'];
  7773. }
  7774. }
  7775. $final_list[] = [
  7776. 'warehouse'=>$v['warehouse'],
  7777. 'purchase'=>$v['purchase'],
  7778. 'sku'=>$v['sku'],
  7779. 'title'=>$v['title'],
  7780. 'features'=>$v['features'],
  7781. 'label'=>$v['label'],
  7782. 'orderinfo'=>$v['orderinfo'],
  7783. 'number'=>$number,
  7784. 'waybill'=>$v['waybill'],
  7785. 'outk'=>$v['outk'],
  7786. ];
  7787. }
  7788. } else {
  7789. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7790. foreach ($info_list as $key => $value) {
  7791. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7792. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7793. $warehouse = $this->warehouse->read($value['warehouse']);
  7794. $info_list[$key]['warehouse'] = $warehouse['title'];
  7795. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7796. $features = explode('-', trim($features, '-'));
  7797. $pm = $classid;
  7798. foreach ($features as $k => $v) {
  7799. if ($v != 0) {
  7800. if (!isset($typeclass[$v])) {
  7801. continue;
  7802. }
  7803. if (isset($pm[$typeclass[$v]['classid']])) {
  7804. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7805. $tz = explode('|', $typeclass[$v]['zh']);
  7806. $pm[$typeclass[$v]['classid']] = $tz[0];
  7807. } else {
  7808. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7809. }
  7810. }
  7811. }
  7812. }
  7813. $zh = implode(" ", $pm);
  7814. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7815. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7816. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7817. $info_list[$key]['features'] = $zh;
  7818. }
  7819. $final_list = [];
  7820. foreach($info_list as $k=>$v){
  7821. $number = "";
  7822. if(!empty($v['orderinfo'])){
  7823. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7824. if(!empty($tmp_info['number'])){
  7825. $number = $tmp_info['number'];
  7826. }
  7827. }
  7828. $final_list[] = [
  7829. 'warehouse'=>$v['warehouse'],
  7830. 'purchase'=>$v['purchase'],
  7831. 'sku'=>$v['sku'],
  7832. 'title'=>$v['title'],
  7833. 'features'=>$v['features'],
  7834. 'label'=>$v['label'],
  7835. 'orderinfo'=>$v['orderinfo'],
  7836. 'number'=>$number,
  7837. 'waybill'=>$v['waybill'],
  7838. 'retreat'=>$v['retreat'],
  7839. ];
  7840. }
  7841. }
  7842. if(empty($final_list)){
  7843. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7844. }else{
  7845. // $final_list = [];
  7846. // foreach($list as $v){
  7847. // $final_list[] = array_values($v);
  7848. // }
  7849. $end_list = [];
  7850. foreach($final_list as $v){
  7851. $end_list[] = array_values($v);
  7852. }
  7853. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  7854. array_unshift($end_list,[
  7855. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  7856. ]);
  7857. array_unshift($end_list,[
  7858. $title,"","","",""
  7859. ]);
  7860. exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $end_list,'title'=>$title)));
  7861. }
  7862. // $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  7863. // $titlename = "<table border=1>
  7864. // <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  7865. // <tr align='center'>
  7866. // <td>仓库</td>
  7867. // <td>供应商</td>
  7868. // <td>SKU</td>
  7869. // <td>商品名称</td>
  7870. // <td>商品中文</td>
  7871. // <td>标签</td>
  7872. // <td>订单号</td>
  7873. // <td>订单编码</td>
  7874. // <td>运单号</td>
  7875. // <td>" . $tl . "时间(中国时间)</td>
  7876. // </tr>
  7877. // </table>";
  7878. // $filename = $title . ".xls";
  7879. // $tail = "";
  7880. // $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  7881. } else if ($type == 5) {
  7882. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  7883. foreach ($info_list as $key => $value) {
  7884. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7885. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7886. $warehouse = $this->warehouse->read($value['warehouse']);
  7887. $info_list[$key]['warehouse'] = $warehouse['title'];
  7888. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7889. $features = explode('-', trim($features, '-'));
  7890. $pm = $classid;
  7891. foreach ($features as $k => $v) {
  7892. if ($v != 0) {
  7893. if (!isset($typeclass[$v])) {
  7894. continue;
  7895. }
  7896. if (isset($pm[$typeclass[$v]['classid']])) {
  7897. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7898. $tz = explode('|', $typeclass[$v]['zh']);
  7899. $pm[$typeclass[$v]['classid']] = $tz[0];
  7900. } else {
  7901. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7902. }
  7903. }
  7904. }
  7905. }
  7906. $zh = implode(" ", $pm);
  7907. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7908. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7909. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7910. $info_list[$key]['features'] = $zh;
  7911. }
  7912. if(empty($info_list)){
  7913. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7914. }else{
  7915. $final_list = [];
  7916. foreach($info_list as $v){
  7917. $final_list[] = array_values($v);
  7918. }
  7919. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  7920. array_unshift($final_list,[
  7921. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  7922. ]);
  7923. array_unshift($final_list,[
  7924. $title,"","","",""
  7925. ]);
  7926. exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
  7927. }
  7928. // $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  7929. // $titlename = "<table border=1>
  7930. // <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7931. // <tr align='center'>
  7932. // <td>仓库</td>
  7933. // <td>供应商</td>
  7934. // <td>SKU</td>
  7935. // <td>商品名称</td>
  7936. // <td>商品中文</td>
  7937. // <td>标签</td>
  7938. // <td>" . $tl . "时间(中国时间)</td>
  7939. // </tr>
  7940. // </table>";
  7941. // $filename = $title . ".xls";
  7942. // $tail = "";
  7943. // $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  7944. } else {
  7945. /**
  7946. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  7947. $rows = array();$list = array();
  7948. foreach ($info_list as $key=>$value)
  7949. {
  7950. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  7951. }
  7952. **/
  7953. $wh = array();
  7954. $w = $this->warehouse->find_all('1=1', 'id,title');
  7955. foreach ($w as $v) {
  7956. $wh[$v['id']] = $v['title'];
  7957. }
  7958. $wt = array();
  7959. $whlabel_type = $this->whlabel_type->find_all();
  7960. foreach ($whlabel_type as $v) {
  7961. $wt[$v['id']] = $v['title'];
  7962. }
  7963. $classid = $this->classid->sku();
  7964. $list = array();
  7965. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  7966. foreach ($rows as $key => $value) {
  7967. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7968. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7969. $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');
  7970. $details = array();
  7971. $cpid = array();
  7972. $cpbz = array();
  7973. $c = 0;
  7974. $g = 0;
  7975. $x = 0;
  7976. $t = 0;
  7977. $s = 0;
  7978. $q = 0;
  7979. foreach ($sd as $k => $v) {
  7980. if ($v['state'] == 0) {
  7981. $c++;
  7982. }
  7983. if ($v['state'] != 9) {
  7984. $g++;
  7985. }
  7986. if ($v['outk'] > 1) {
  7987. $x++;
  7988. }
  7989. if ($v['retreat'] > 0) {
  7990. $t++;
  7991. }
  7992. if ($v['state'] == 8) {
  7993. $s++;
  7994. }
  7995. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  7996. $q++;
  7997. }
  7998. $details[$v['details']] = $v['details'];
  7999. if ($v['cpid'] != 0) {
  8000. $cpid[$v['cpid']] = $v['cpid'];
  8001. }
  8002. if ($v['cpbz'] != '') {
  8003. $cpbz[$v['cpbz']] = $v['cpbz'];
  8004. }
  8005. }
  8006. if (isset($wt[$value['type']])) {
  8007. $rows[$key]['type'] = $wt[$value['type']];
  8008. } else {
  8009. $rows[$key]['type'] = '未设置';
  8010. }
  8011. $rows[$key]['details'] = implode("、", $details);
  8012. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8013. $ftime = time() - 15 * 24 * 3600;
  8014. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8015. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8016. $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);
  8017. $rows[$key]['c'] = $c;
  8018. $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);
  8019. $rows[$key]['t'] = $t;
  8020. $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'] . '"');
  8021. $rows[$key]['z'] = $z;
  8022. // $jm = $classid;
  8023. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8024. $features = explode('-', trim($features, '-'));
  8025. // $pm = $classid;
  8026. // foreach ($features as $k => $v) {
  8027. // if ($v != 0) {
  8028. // if (!isset($typeclass[$v])) {
  8029. // continue;
  8030. // }
  8031. // if (isset($pm[$typeclass[$v]['classid']])) {
  8032. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8033. // $tz = explode('|', $typeclass[$v]['zh']);
  8034. // $pm[$typeclass[$v]['classid']] = $tz[0];
  8035. // } else {
  8036. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8037. // }
  8038. // if (isset($jm[$typeclass[$v]['classid']])) {
  8039. // if ($typeclass[$v]['jm']) {
  8040. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8041. // }
  8042. // }
  8043. // }
  8044. // }
  8045. // }
  8046. // $zh = implode(" ", $pm);
  8047. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8048. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8049. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8050. // $rows[$key]['features'] = $zh;
  8051. // $jm = array_filter($jm); //去除空值
  8052. // $jm = implode("-", $jm);
  8053. // $rows[$key]['jm'] = $jm;
  8054. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8055. }
  8056. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8057. // echo "<pre>";
  8058. // print_r($tmp_list);
  8059. // die;
  8060. $final_list =[];
  8061. foreach($tmp_list as $k=>$v){
  8062. $final_list[] = [
  8063. "warehouse"=>$v['warehouse'],
  8064. "purchase"=>$v['purchase'],
  8065. "details"=>$v['details'],
  8066. "cpid"=>$v['cpid'],
  8067. "sku"=>$v['sku'],
  8068. "title"=>$v['title'],
  8069. "features"=>$v['pm'],
  8070. "cpbz"=>$v['cpbz'],
  8071. "sm"=>$v['sm'],
  8072. "type"=>$v['type'],
  8073. "g"=>$v["g"],
  8074. "c"=>$v["c"],
  8075. "x"=>$v["x"],
  8076. "t"=>$v["t"],
  8077. "z"=>$v["z"],
  8078. "jm"=>$v["jm"],
  8079. "weight"=>$v["weight"],
  8080. "asd"=>$v["asd"],
  8081. ];
  8082. }
  8083. if(empty($final_list)){
  8084. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8085. }else{
  8086. $end_list = [];
  8087. foreach($final_list as $v){
  8088. $end_list[] = array_values($v);
  8089. }
  8090. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8091. array_unshift($end_list,[
  8092. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8093. ]);
  8094. array_unshift($end_list,[
  8095. $title,"","","",""
  8096. ]);
  8097. exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $end_list,'title'=>$title)));
  8098. }
  8099. // $titlename = "<table border=1>
  8100. // <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  8101. // <tr align='center'>
  8102. // <td>仓库</td>
  8103. // <td>供应商</td>
  8104. // <td>位置</td>
  8105. // <td>库存编码</td>
  8106. // <td>SKU</td>
  8107. // <td>商品名称</td>
  8108. // <td>商品中文</td>
  8109. // <td>产品备注</td>
  8110. // <td>说明</td>
  8111. // <td>类型</td>
  8112. // <td>入库总量</td>
  8113. // <td>库存数量</td>
  8114. // <td>销售数量</td>
  8115. // <td>退货数量</td>
  8116. // <td>占单数量</td>
  8117. // <td>料号</td>
  8118. // <td>重量</td>
  8119. // <td>类目</td>
  8120. // </tr>
  8121. // </table>";
  8122. // $filename = $title . ".xls";
  8123. // $tail = "";
  8124. // $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  8125. }
  8126. }
  8127. }
  8128. //出库+入库数据整合
  8129. public function _excelcrjs()
  8130. {
  8131. if (isset($_GET['excel'])) {
  8132. $type = $this->input->get('excel', true);
  8133. $category = $this->input->get('category', true);
  8134. $size = $this->input->get('size', true);
  8135. $grade = $this->input->get('grade', true);
  8136. $color = $this->input->get('color', true);
  8137. $lowe = $this->input->get('lowe', true);
  8138. $sku = $this->input->get('sku', true);
  8139. $warehouse = $this->input->get('warehouse', true);
  8140. $purchase = $this->input->get('purchase', true);
  8141. $state = $this->input->get('state', true);
  8142. $sid = $this->input->get('sid', true);
  8143. $ktime = $this->input->get('ktime', true);
  8144. $jtime = $this->input->get('jtime', true);
  8145. $ktime = strtotime($ktime);
  8146. $jtime = strtotime($jtime);
  8147. $where = "1=1";
  8148. $gj = "";
  8149. $ck = "";
  8150. if ($category) {
  8151. $where .= " and features like '%-$category-%'";
  8152. }
  8153. if ($size) {
  8154. $where .= " and features like '%-$size-%'";
  8155. }
  8156. if ($grade) {
  8157. $where .= " and features like '%-$grade-%'";
  8158. }
  8159. if ($color) {
  8160. $where .= " and features like '%-$color-%'";
  8161. }
  8162. if ($lowe) {
  8163. $where .= " and features like '%-$lowe-%'";
  8164. }
  8165. if ($warehouse) {
  8166. $where .= " and warehouse = '$warehouse'";
  8167. }
  8168. if ($purchase) {
  8169. $where .= " and purchase = '$purchase'";
  8170. }
  8171. if ($state) {
  8172. $where .= " and state = '$state'";
  8173. }
  8174. if ($sku) {
  8175. $where .= " and sku like '%$sku%'";
  8176. }
  8177. if ($ktime && $jtime) {
  8178. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8179. }
  8180. $sidwhere = '';
  8181. if ($sid) {
  8182. $sd = "";
  8183. $s = explode(',', trim($sid, ','));
  8184. foreach ($s as $value) {
  8185. $sd .= " id = " . $value . " or";
  8186. }
  8187. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  8188. }
  8189. //取得信息列表
  8190. $timeread = $ktime;
  8191. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  8192. $timelist = array();
  8193. for ($i = 0; $i < $timenum; $i++) {
  8194. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  8195. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  8196. }
  8197. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  8198. //echo "<pre>";
  8199. //print_r($info_list);
  8200. //exit();
  8201. $rows = array();
  8202. $list = array();
  8203. foreach ($info_list as $key => $value) {
  8204. $thistime = $timelist;
  8205. if (isset($rows[strtolower($value['sku'])])) {
  8206. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  8207. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  8208. }
  8209. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  8210. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  8211. }
  8212. } else {
  8213. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  8214. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  8215. }
  8216. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  8217. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  8218. }
  8219. $rows[strtolower($value['sku'])] = $thistime;
  8220. }
  8221. }
  8222. if(empty($rows)){
  8223. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8224. }else{
  8225. $final_list = [];
  8226. foreach($rows as $v){
  8227. $final_list[] = array_values($v);
  8228. }
  8229. $title = date("Y-m-d H:i:s"). "详情";
  8230. $first_line = [];
  8231. $first_line[] = "SKU";
  8232. $send_line = [];
  8233. $send_line = $title;
  8234. foreach ($timelist as $k => $v) {
  8235. $first_line[] = $k . "出库";
  8236. $first_line[] = $k . "入库";
  8237. $send_line[] = "";
  8238. $semd_line[] = "";
  8239. }
  8240. array_unshift($final_list,$first_line);
  8241. array_unshift($final_list,$send_line);
  8242. exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
  8243. }
  8244. // $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  8245. // <head>
  8246. // <!--[if gte mso 9]><xml>
  8247. // <x:ExcelWorkbook>
  8248. // <x:ExcelWorksheets>
  8249. // <x:ExcelWorksheet>
  8250. // <x:Name>EXCEL</x:Name>
  8251. // <x:WorksheetOptions>
  8252. // <x:Print>
  8253. // <x:ValidPrinterInfo />
  8254. // </x:Print>
  8255. // </x:WorksheetOptions>
  8256. // </x:ExcelWorksheet>
  8257. // </x:ExcelWorksheets>
  8258. // </x:ExcelWorkbook>
  8259. // </xml>
  8260. // <![endif]-->
  8261. // </head><body>";
  8262. // $str .= "<table border=1><tr><td>SKU</td>";
  8263. // foreach ($timelist as $k => $v) {
  8264. // $str .= "<td>" . $k . "出库</td>";
  8265. // $str .= "<td>" . $k . "入库</td>";
  8266. // }
  8267. // $str .= "</tr></table>";
  8268. // $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  8269. // foreach ($rows as $key => $val) {
  8270. // $str .= "<tr><td>" . strtoupper($key) . "</td>";
  8271. // foreach ($val as $k => $v) {
  8272. // $str .= "<td>" . $val[$k]['c'] . "</td>";
  8273. // if ($val[$k]['r'] > 0) {
  8274. // $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  8275. // } else {
  8276. // $str .= "<td>" . $val[$k]['r'] . "</td>";
  8277. // }
  8278. // }
  8279. // $str .= "</tr>";
  8280. // }
  8281. // $str .= "</table>";
  8282. // $str .= "</body></html>";
  8283. // header("Content-Type: application/vnd.ms-excel; name='excel'");
  8284. // header("Content-type: application/octet-stream");
  8285. // header("Content-Disposition: attachment; filename=" . time() . '.xls');
  8286. // header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  8287. // header("Pragma: no-cache");
  8288. // header("Expires: 0");
  8289. // exit($str);
  8290. }
  8291. }
  8292. }