Whlabel.php 339 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. $this->load->_model("Model_whlabelscbf","whlabelscbf");
  49. }
  50. //定义方法的调用规则 获取URI第二段值
  51. public function _remap($arg, $arg_array)
  52. {
  53. if ($arg == 'existence') //在库标签
  54. {
  55. $this->_existence();
  56. } else if ($arg == 'cpbqdc') //在库标签
  57. {
  58. $this->_cpbqdc();
  59. } else if ($arg == 'type') //进销存浏览
  60. {
  61. $this->_type();
  62. }else if ($arg == 'typev1') //进销存浏览
  63. {
  64. $this->_typev1();
  65. } else if ($arg == 'typedy') //进销存浏览店员页面
  66. {
  67. $this->_typedy($arg_array);
  68. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  69. {
  70. $this->_typedy_ck($arg_array);
  71. } else if ($arg == 'typeck') {
  72. $this->_typeck($arg_array);
  73. } else if ($arg == 'whlabeckdc') {
  74. $this->_whlabeckdc($arg_array);
  75. } else if ($arg == 'usatype') //美仓进销存浏览
  76. {
  77. $this->_usatype();
  78. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  79. {
  80. $this->_usatypeapp();
  81. } else if ($arg == 'enteradd') //入库操作
  82. {
  83. $this->_enteradd();
  84. } else if ($arg == 'enteredit') //修改
  85. {
  86. $this->_enteredit($arg_array);
  87. } else if ($arg == 'enter') //入库浏览
  88. {
  89. $this->_enter();
  90. } else if ($arg == 'out') //出库浏览
  91. {
  92. $this->_out();
  93. } else if ($arg == 'label') //出库标签浏览
  94. {
  95. $this->_label();
  96. } else if ($arg == 'outorder') //独立站出库订单
  97. {
  98. $this->_outorder();
  99. } else if ($arg == 'soutorder') //速卖通出库订单
  100. {
  101. $this->_soutorder();
  102. } else if ($arg == 'toutorder') //TT出库订单
  103. {
  104. $this->_toutorder();
  105. }else if ($arg == 'aoutorder') //amz出库订单
  106. {
  107. $this->_aoutorder();
  108. } else if ($arg == 'retreat') //退库订单
  109. {
  110. $this->_retreat();
  111. } else if ($arg == 'retreatlk') //退库订单
  112. {
  113. $this->_retreatlk();
  114. } else if ($arg == 'change') //更换标签
  115. {
  116. $this->_change();
  117. } else if ($arg == 'del') //删除
  118. {
  119. $this->_del();
  120. } else if ($arg == 'exceljxc') //进销存信息导出
  121. {
  122. $this->_exceljxc();
  123. } else if ($arg == 'excelr') //入库信息导出
  124. {
  125. $this->_excelr();
  126. } else if ($arg == 'excelct') //出库、退库信息导出
  127. {
  128. $this->_excelct();
  129. } else if ($arg == 'dccrtype') //根据出入库类型导出
  130. {
  131. $this->_dccrtype();
  132. } else if ($arg == 'excelcr') //出库、退库信息导出
  133. {
  134. $this->_excelcr();
  135. } else if ($arg == 'kcyz') //库存验证
  136. {
  137. $this->_kcyz();
  138. } else if ($arg == 'kj') //库存扣减
  139. {
  140. $this->_kj($arg_array);
  141. } else if ($arg == 'presetout') //预设库存导入
  142. {
  143. $this->_presetout($arg_array);
  144. } else if ($arg == 'presetedit') //预设库存导入
  145. {
  146. $this->_presetedit($arg_array);
  147. }else if ($arg == 'presetedittwo') //预设库存导入
  148. {
  149. $this->_presetedittwo($arg_array);
  150. } else if ($arg == 'summary') //汇总导出
  151. {
  152. $this->_summary($arg_array);
  153. } else if ($arg == 'manifest') //usps发货清单
  154. {
  155. $this->_manifest();
  156. } else if ($arg == 'abnormal') //占单异常
  157. {
  158. $this->_abnormal();
  159. } else if ($arg == 'error') //0库存SKU
  160. {
  161. $this->_error();
  162. } else if ($arg == 'errorexcel') //0库存SKU导出
  163. {
  164. $this->_errorexcel();
  165. } else if ($arg == 'db') {
  166. $this->_db();
  167. } else if ($arg == 'dbrk') {
  168. $this->_dbrk();
  169. } else if ($arg == 'whlabelczdc') {
  170. $this->_whlabelczdc();
  171. } else if ($arg == 'print') {
  172. $this->_print($arg_array);
  173. } else if ($arg == 'usaprint') {
  174. $this->_usaprint($arg_array);
  175. } else if ($arg == 'printck') {
  176. $this->_printck($arg_array);
  177. } else if ($arg == 'printrk') {
  178. $this->_printrk($arg_array);
  179. } else if ($arg == 'printxzrk') {
  180. $this->_printxzrk($arg_array);
  181. } else if ($arg == 'printexcel') {
  182. $this->_printexcel($arg_array);
  183. } else if ($arg == 'uck') {
  184. $this->_uck();
  185. } else if ($arg == 'whlabelexcelzh') {
  186. $this->_whlabelexcelzh();
  187. } else if ($arg == 'fc') {
  188. $this->_fc();
  189. } else if ($arg == 'fcmb') {
  190. $this->_fcmb();
  191. } else if ($arg == 'fcexcel') {
  192. $this->_fcexcel();
  193. } else if ($arg == 'fcjxc') {
  194. $this->_fcjxc($arg_array);
  195. } else if ($arg == '0kcdel') {
  196. $this->_0kcdel(); //导表删除0库存
  197. } else if ($arg == 'gbhtype') {
  198. $this->_gbhtype(); //更改备货状态
  199. } else if($arg == 'excelrjs'){
  200. $this->_excelrjs();
  201. } else if($arg == 'excelctjs'){
  202. $this->_excelctjs();
  203. }else if ($arg == 'exceljxcjs') //进销存信息导出
  204. {
  205. $this->_exceljxcjs();
  206. } else if ($arg == 'summaryjs') //汇总导出
  207. {
  208. $this->_summaryjs($arg_array);
  209. }else if($arg == 'uckjs'){
  210. $this->_uckjs();
  211. }else if ($arg == 'whlabelexcelzhjs') {
  212. $this->_whlabelexcelzhjs();
  213. }else if($arg == 'dccrtypejs'){
  214. $this->_dccrtypejs();
  215. }else if($arg == 'errorexceljs'){
  216. $this->_errorexceljs();
  217. }else if($arg == "w_t_cs"){
  218. $this->_w_t_cs(); //首页
  219. }else {
  220. $this->_index();
  221. }
  222. }
  223. public function _w_t_cs(){
  224. $vip = 0;
  225. if (isset($_SESSION['api'])) {
  226. $user = $this->user->get_api($_SESSION['api']);
  227. $fgshop = "";
  228. $sid = "";
  229. $usersp = explode('|', trim($user['shop'], '|'));
  230. foreach ($usersp as $value) {
  231. $fgshop .= " shop = " . $value . " or";
  232. $sid .= " id = " . $value . " or";
  233. }
  234. if ($user['vip'] == 1) {
  235. $vip = 1;
  236. }
  237. } else {
  238. header('Location: /');
  239. exit;
  240. }
  241. $prc = array();
  242. $purchase = $this->purchase->find_all();
  243. foreach ($purchase as $k => $v) {
  244. $prc[$v['id']] = $v['title'];
  245. }
  246. $company = array();
  247. $ct = $this->company->find_all();
  248. foreach ($ct as $k => $v) {
  249. $company[$v['id']] = $v['title'];
  250. }
  251. $sp = array();
  252. $s = $this->shop->find_all('1=1', 'id,shopname');
  253. foreach ($s as $v) {
  254. $sp[$v['id']] = $v['shopname'];
  255. }
  256. $wh = array();
  257. $w = $this->warehouse->find_all('1=1', 'id,title');
  258. foreach ($w as $v) {
  259. $wh[$v['id']] = $v['title'];
  260. }
  261. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  262. $this->data['shop'] = $wlshop;
  263. $this->data['vip'] = $vip;
  264. $this->_Template('whlabel_typejs', $this->data);
  265. }
  266. //管理
  267. public function _index()
  268. {
  269. $post = $this->input->post(NULL, TRUE);
  270. if (isset($post['page'])) {
  271. $page = $this->input->post('page', true);
  272. $perpage = $this->input->post('perpage', true);
  273. $sku = $this->input->post('sku', true);
  274. $number = $this->input->post('number', true);
  275. $warehouse = $this->input->post('warehouse', true);
  276. $purchase = $this->input->post('purchase', true);
  277. $orderinfo = $this->input->post('orderinfo', true);
  278. $waybill = $this->input->post('waybill', true);
  279. $category = $this->input->post('category', true);
  280. $size = $this->input->post('size', true);
  281. $grade = $this->input->post('grade', true);
  282. $color = $this->input->post('color', true);
  283. $lowe = $this->input->post('lowe', true);
  284. $state = $this->input->post('state', true);
  285. $label = $this->input->post('label', true);
  286. $timetk = $this->input->post('timetkk', true);
  287. $timetj = $this->input->post('timetjj', true);
  288. $timetk = strtotime($timetk);
  289. $timetj = strtotime($timetj);
  290. $where = "1=1 ";
  291. if ($timetk && $timetj) {
  292. $where .= " and time > '$timetk' and time < '$timetj'";
  293. }
  294. if ($sku) {
  295. $where .= " and sku = '$sku'";
  296. }
  297. if ($number) {
  298. $where .= " and number = '$number'";
  299. }
  300. if ($warehouse) {
  301. $where .= " and warehouse = '$warehouse'";
  302. }
  303. if ($purchase) {
  304. $where .= " and purchase = '$purchase'";
  305. }
  306. if ($orderinfo) {
  307. $where .= " and orderinfo = '$orderinfo'";
  308. }
  309. if ($waybill) {
  310. $where .= " and waybill = '$waybill'";
  311. }
  312. if ($category) {
  313. $where .= " and features like '%-$category-%'";
  314. }
  315. if ($size) {
  316. $where .= " and features like '%-$size-%'";
  317. }
  318. if ($grade) {
  319. $where .= " and features like '%-$grade-%'";
  320. }
  321. if ($color) {
  322. $where .= " and features like '%-$color-%'";
  323. }
  324. if ($lowe) {
  325. $where .= " and features like '%-$lowe-%'";
  326. }
  327. if ($label) {
  328. $where .= " and label = '$label'";
  329. }
  330. if ($state != '') {
  331. $where .= " and state = '$state'";
  332. }
  333. //数据排序
  334. $order_str = "time desc";
  335. if (empty($page)) {
  336. $start = 0;
  337. $perpage = 1;
  338. } else {
  339. $start = ($page - 1) * $perpage;
  340. }
  341. //取得信息列表
  342. $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);
  343. foreach ($info_list as $key => $value) {
  344. $warehouse = $this->warehouse->read($value['warehouse']);
  345. $info_list[$key]['warehouse'] = $warehouse['title'];
  346. $purchase = $this->purchase->read($value['purchase']);
  347. $info_list[$key]['purchase'] = $purchase['title'];
  348. if ($value['enter'] != 0) {
  349. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  350. } else {
  351. $info_list[$key]['enter'] = "";
  352. }
  353. if ($value['outk'] != 0) {
  354. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  355. } else {
  356. $info_list[$key]['outk'] = "";
  357. }
  358. if ($value['printing'] != 0) {
  359. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  360. } else {
  361. $info_list[$key]['printing'] = "";
  362. }
  363. if ($value['orderinfo'] == 0) {
  364. $info_list[$key]['orderinfo'] = "";
  365. }
  366. if ($value['waybill'] == 0) {
  367. $info_list[$key]['waybill'] = "";
  368. }
  369. if ($value['state'] == 0) {
  370. $info_list[$key]['state'] = "在库";
  371. } else if ($value['state'] == 1) {
  372. $info_list[$key]['state'] = "出库";
  373. } else if ($value['state'] == 2) {
  374. $info_list[$key]['state'] = "退库";
  375. } else if ($value['state'] == 3) {
  376. $info_list[$key]['state'] = "调拨中";
  377. } else if ($value['state'] == 4) {
  378. $info_list[$key]['state'] = "再加工";
  379. } else if ($value['state'] == 5) {
  380. $info_list[$key]['state'] = "维修中";
  381. } else if ($value['state'] == 6) {
  382. $info_list[$key]['state'] = "盘亏";
  383. } else if ($value['state'] == 7) {
  384. $info_list[$key]['state'] = "更换标签";
  385. } else if ($value['state'] == 8) {
  386. $info_list[$key]['state'] = "其它";
  387. } else if ($value['state'] == 9) {
  388. $info_list[$key]['state'] = "预设";
  389. } else if ($value['state'] == 10) {
  390. $info_list[$key]['state'] = "美店零售";
  391. }
  392. if ($value['text'] == "") {
  393. $info_list[$key]['text'] = "";
  394. }
  395. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  396. }
  397. $total = $this->whlabel->find_count($where);
  398. $pagenum = ceil($total / $perpage);
  399. $over = $total - ($start + $perpage);
  400. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  401. echo json_encode($rows);
  402. exit;
  403. }
  404. if (isset($post['outsku'])) {
  405. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  406. $cz = $this->input->post('cz', true);
  407. if ($cz == '1') {
  408. $sku = $this->input->post('outsku', true);
  409. if ($sku) {
  410. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  411. if (count($data) < 1) {
  412. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  413. exit;
  414. }
  415. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  416. echo json_encode(array('success' => true));
  417. exit;
  418. }
  419. } else {
  420. $sku = $this->input->post('outsku', true);
  421. if ($sku) {
  422. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  423. if (count($data) < 1) {
  424. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  425. exit;
  426. }
  427. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  428. echo json_encode(array('success' => true));
  429. exit;
  430. }
  431. }
  432. }
  433. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  434. $this->_Template('whlabel', $this->data);
  435. }
  436. //在库标签
  437. public function _existence()
  438. {
  439. $post = $this->input->post(NULL, TRUE);
  440. if (isset($post['s'])) {
  441. $id_arr = $this->input->post('s');
  442. $id_arr = explode(',', $id_arr);
  443. if (!$id_arr) {
  444. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  445. exit;
  446. }
  447. //循环删除记录
  448. foreach ($id_arr as $v) {
  449. $sid = $this->whlabel->read($v);
  450. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  451. if ($count > 0) {
  452. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  453. exit;
  454. }
  455. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  456. if (count($zt) > 0) {
  457. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  458. exit;
  459. }
  460. $this->whlabel->remove($v);
  461. }
  462. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  463. exit;
  464. }
  465. if (isset($post['page'])) {
  466. $page = $this->input->post('page', true);
  467. $perpage = $this->input->post('perpage', true);
  468. $warehouse = $this->input->post('warehouse', true);
  469. $label = $this->input->post('label', true);
  470. $where = "1=1 and state = 0";
  471. if ($warehouse) {
  472. $where .= " and warehouse = '$warehouse'";
  473. }
  474. if ($label) {
  475. $where .= " and label = '$label'";
  476. }
  477. //数据排序
  478. $order_str = "time asc";
  479. if (empty($page)) {
  480. $start = 0;
  481. $perpage = 1;
  482. } else {
  483. $start = ($page - 1) * $perpage;
  484. }
  485. //取得信息列表
  486. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  487. foreach ($info_list as $key => $value) {
  488. if ($value['enter'] != 0) {
  489. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  490. } else {
  491. $info_list[$key]['enter'] = "";
  492. }
  493. if ($value['printing'] != 0) {
  494. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  495. } else {
  496. $info_list[$key]['printing'] = "";
  497. }
  498. }
  499. $total = $this->whlabel->find_count($where);
  500. $pagenum = ceil($total / $perpage);
  501. $over = $total - ($start + $perpage);
  502. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  503. echo json_encode($rows);
  504. exit;
  505. }
  506. $this->_Template('whlabel_existence', $this->data);
  507. }
  508. //进销存浏览
  509. public function _typedy($arg_array)
  510. {
  511. $prc = array();
  512. $purchase = $this->purchase->find_all();
  513. foreach ($purchase as $k => $v) {
  514. $prc[$v['id']] = $v['title'];
  515. }
  516. $post = $this->input->post(NULL, TRUE);
  517. if (isset($post['page'])) {
  518. $page = $this->input->post('page', true);
  519. $perpage = $this->input->post('perpage', true);
  520. $category = $this->input->post('category', true);
  521. $size = $this->input->post('size', true);
  522. $grade = $this->input->post('grade', true);
  523. $color = $this->input->post('color', true);
  524. $lowe = $this->input->post('lowe', true);
  525. $sku = $this->input->post('sku');
  526. $title = $this->input->post('title');
  527. $warehouse = $this->input->post('warehouse', true);
  528. $usa = $this->input->post('usa', true);
  529. $purchase = $this->input->post('purchase', true);
  530. $lacetype = $this->input->post('lacetype', true);
  531. $haircap = $this->input->post('haircap', true);
  532. $density = $this->input->post('density', true);
  533. $details = $this->input->post('details', true);
  534. $state = $this->input->post('state', true);
  535. $lacecolor = $this->input->post('lacecolor', true);
  536. $hairnumber = $this->input->post('hairnumber', true);
  537. $cklx = $this->input->post('cklx', true);
  538. $ktime = $this->input->post('ktime', true);
  539. $jtime = $this->input->post('jtime', true);
  540. $sm = $this->input->post('sm', true);
  541. $cpbz = $this->input->post('cpbz', true);
  542. $type = $this->input->post('type', true);
  543. $ktime = strtotime($ktime);
  544. $jtime = strtotime($jtime);
  545. $where = "1=1";
  546. $gj = "";
  547. $ck = "";
  548. if ($usa) {
  549. if (!$warehouse) {
  550. $where .= " and (warehouse = '5' or warehouse = '8')";
  551. }
  552. }
  553. if ($warehouse) {
  554. $where .= " and warehouse = '$warehouse'";
  555. }
  556. if ($details) {
  557. $where .= " and details = '$details'";
  558. }
  559. if ($purchase) {
  560. $where .= " and purchase = '$purchase'";
  561. }
  562. if (isset($state)) {
  563. if($state >-1){
  564. $where .= " and state = '$state'";
  565. }
  566. }
  567. if ($lacetype) {
  568. $where .= " and features like '%-$lacetype-%'";
  569. }
  570. if ($category) {
  571. $where .= " and features like '%-$category-%'";
  572. }
  573. if ($size) {
  574. $where .= " and features like '%-$size-%'";
  575. }
  576. if ($grade) {
  577. $where .= " and features like '%-$grade-%'";
  578. }
  579. if ($color) {
  580. $where .= " and features like '%-$color-%'";
  581. }
  582. if ($lowe) {
  583. $where .= " and features like '%-$lowe-%'";
  584. }
  585. if ($haircap) {
  586. $where .= " and features like '%-$haircap-%'";
  587. }
  588. if ($density) {
  589. $where .= " and features like '%-$density-%'";
  590. }
  591. if ($lacecolor) {
  592. $where .= " and features like '%-$lacecolor-%'";
  593. }
  594. if($sm){
  595. $where .= " and sm like '%".$sm."%'";
  596. }
  597. if($cpbz){
  598. $where .= " and cpbz like '%".$cpbz."%'";
  599. }
  600. if($type){
  601. $where .= " and type = ".$type."";
  602. }
  603. if (!empty($hairnumber)) {
  604. $where .= " and features like '%-128-%' ";
  605. if ($hairnumber < 0) {
  606. $class_list = $this->typeclass->find_all('classid = 43');
  607. foreach ($class_list as $v) {
  608. $where .= " and features not like '%-" . $v['id'] . "-%'";
  609. }
  610. } else {
  611. $where .= " and features like '%-$hairnumber-%'";
  612. }
  613. }
  614. $where_add = '';
  615. if ($cklx) {
  616. $shop = $this->shop->read($cklx);
  617. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  618. }
  619. if ($ktime && $jtime) {
  620. $gj = " and enter > '$ktime' and enter < '$jtime'";
  621. $ck = " and outk > '$ktime' and outk < '$jtime'";
  622. }
  623. //数据排序
  624. $order_str = "id desc";
  625. if (empty($page)) {
  626. $start = 0;
  627. $perpage = 1;
  628. } else {
  629. $start = ($page - 1) * $perpage;
  630. }
  631. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  632. if ($sku) {
  633. $sku = trim($sku, ' ');
  634. $sku = trim($sku, ' ');
  635. $where .= " and sku like '%$sku%'";
  636. $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);
  637. } else if ($title) {
  638. $title = trim($title, ' ');
  639. $title = trim($title, ' ');
  640. $where .= " and title like '%$title%'";
  641. $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);
  642. } else {
  643. //$where .= " and time > '$ktime' and time < '$jtime'";
  644. $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);
  645. }
  646. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  647. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  648. foreach ($info_list as $k => $v) {
  649. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  650. unset($info_list[$k]['pm']);
  651. unset($info_list[$k]['jm']);
  652. unset($info_list[$k]['bm']);
  653. }
  654. //取得信息列表
  655. $rows = array();
  656. $list = array();
  657. foreach ($info_list as $key => $value) {
  658. $warehouse = $this->warehouse->read($value['warehouse']);
  659. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  660. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  661. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  662. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  663. $info_list[$key]['label'] = $value['sm'];
  664. $number = $value['number'];
  665. $ftime = time() - 15 * 24 * 3600;
  666. $info_list[$key]['warehouse'] = $warehouse['title'];
  667. $info_list[$key]['features'] = count($c);
  668. $z = count($z); //查看订单号
  669. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  670. $ztdata = '';
  671. if (count($zt) > 0) {
  672. foreach ($zt as $vv) {
  673. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  674. }
  675. }
  676. $info_list[$key]['number'] = $ztdata;
  677. $info_list[$key]['sm'] = $z;
  678. $details = array();
  679. $cpid = array();
  680. foreach ($c as $k => $v) {
  681. $details[$v['details']] = $v['details'];
  682. if ($v['cpid'] != 0) {
  683. $cpid[$v['cpid']] = $v['cpid'];
  684. }
  685. }
  686. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  687. if ($value['shop'] != '') {
  688. $shop = explode(',', trim($value['shop'], ','));
  689. $shop = $this->shop->read($shop[0]);
  690. $info_list[$key]['shop'] = $shop['shopname'];
  691. }
  692. }
  693. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  694. $pagenum = ceil($total / $perpage);
  695. $over = $total - ($start + $perpage);
  696. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  697. echo json_encode($rows);
  698. exit;
  699. }
  700. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  701. $this->_Template('whlabel_typedy', $this->data);
  702. }
  703. //进销存浏览
  704. public function _typedy_ck($arg_array)
  705. {
  706. $prc = array();
  707. $purchase = $this->purchase->find_all();
  708. foreach ($purchase as $k => $v) {
  709. $prc[$v['id']] = $v['title'];
  710. }
  711. $post = $this->input->post(NULL, TRUE);
  712. if (isset($post['page'])) {
  713. $page = $this->input->post('page', true);
  714. $perpage = $this->input->post('perpage', true);
  715. $category = $this->input->post('category', true);
  716. $size = $this->input->post('size', true);
  717. $grade = $this->input->post('grade', true);
  718. $color = $this->input->post('color', true);
  719. $lowe = $this->input->post('lowe', true);
  720. $sku = $this->input->post('sku');
  721. $title = $this->input->post('title');
  722. $warehouse = $this->input->post('warehouse', true);
  723. $usa = $this->input->post('usa', true);
  724. $purchase = $this->input->post('purchase', true);
  725. $lacetype = $this->input->post('lacetype', true);
  726. $haircap = $this->input->post('haircap', true);
  727. $density = $this->input->post('density', true);
  728. $details = $this->input->post('details', true);
  729. $state = $this->input->post('state', true);
  730. $lacecolor = $this->input->post('lacecolor', true);
  731. $cklx = $this->input->post('cklx', true);
  732. $ktime = $this->input->post('ktime', true);
  733. $jtime = $this->input->post('jtime', true);
  734. $ktime = strtotime($ktime);
  735. $jtime = strtotime($jtime);
  736. $where = "1=1";
  737. $gj = "";
  738. $ck = "";
  739. if ($lacetype) {
  740. $where .= " and features like '%-$lacetype-%'";
  741. }
  742. if ($category) {
  743. $where .= " and features like '%-$category-%'";
  744. }
  745. if ($size) {
  746. $where .= " and features like '%-$size-%'";
  747. }
  748. if ($grade) {
  749. $where .= " and features like '%-$grade-%'";
  750. }
  751. if ($color) {
  752. $where .= " and features like '%-$color-%'";
  753. }
  754. if ($lowe) {
  755. $where .= " and features like '%-$lowe-%'";
  756. }
  757. if ($haircap) {
  758. $where .= " and features like '%-$haircap-%'";
  759. }
  760. if ($density) {
  761. $where .= " and features like '%-$density-%'";
  762. }
  763. if ($lacecolor) {
  764. $where .= " and features like '%-$lacecolor-%'";
  765. }
  766. if ($usa) {
  767. if (!$warehouse) {
  768. $where .= " and (warehouse = '5' or warehouse = '8')";
  769. }
  770. }
  771. if ($warehouse) {
  772. $where .= " and warehouse = '$warehouse'";
  773. }
  774. if ($details) {
  775. $where .= " and details = '$details'";
  776. }
  777. if ($purchase) {
  778. $where .= " and purchase = '$purchase'";
  779. }
  780. if ($state) {
  781. $where .= " and state = '$state'";
  782. }
  783. $where_add = '';
  784. if ($cklx) {
  785. $shop = $this->shop->read($cklx);
  786. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  787. }
  788. if ($ktime && $jtime) {
  789. $gj = " and enter > '$ktime' and enter < '$jtime'";
  790. $ck = " and outk > '$ktime' and outk < '$jtime'";
  791. }
  792. //数据排序
  793. $order_str = "id desc";
  794. if (empty($page)) {
  795. $start = 0;
  796. $perpage = 1;
  797. } else {
  798. $start = ($page - 1) * $perpage;
  799. }
  800. if ($sku) {
  801. $sku = trim($sku, ' ');
  802. $sku = trim($sku, ' ');
  803. $where .= " and sku like '%$sku%'";
  804. $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);
  805. } else if ($title) {
  806. $title = trim($title, ' ');
  807. $title = trim($title, ' ');
  808. $where .= " and title like '%$title%'";
  809. $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);
  810. } else {
  811. //$where .= " and time > '$ktime' and time < '$jtime'";
  812. $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);
  813. }
  814. //取得信息列表
  815. $rows = array();
  816. $list = array();
  817. foreach ($info_list as $key => $value) {
  818. $warehouse = $this->warehouse->read($value['warehouse']);
  819. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  820. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  821. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  822. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  823. $ftime = time() - 15 * 24 * 3600;
  824. $info_list[$key]['warehouse'] = $warehouse['title'];
  825. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  826. //$z = count($z);//查看订单号
  827. //$info_list[$key]['zd'] = $z;
  828. $details = array();
  829. $cpid = array();
  830. foreach ($c as $k => $v) {
  831. $details[$v['details']] = $v['details'];
  832. if ($v['cpid'] != 0) {
  833. $cpid[$v['cpid']] = $v['cpid'];
  834. }
  835. }
  836. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  837. if ($value['shop'] != '') {
  838. $shop = explode(',', trim($value['shop'], ','));
  839. $shop = $this->shop->read($shop[0]);
  840. $info_list[$key]['shop'] = $shop['shopname'];
  841. }
  842. }
  843. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  844. $pagenum = ceil($total / $perpage);
  845. $over = $total - ($start + $perpage);
  846. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  847. echo json_encode($rows);
  848. exit;
  849. }
  850. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  851. $this->_Template('whlabel_typedy_ck', $this->data);
  852. }
  853. public function _typeck($arg_array)
  854. {
  855. $prc = array();
  856. $purchase = $this->purchase->find_all();
  857. foreach ($purchase as $k => $v) {
  858. $prc[$v['id']] = $v['title'];
  859. }
  860. $post = $this->input->post(NULL, TRUE);
  861. if (isset($post['page'])) {
  862. $page = $this->input->post('page', true);
  863. $perpage = $this->input->post('perpage', true);
  864. $category = $this->input->post('category', true);
  865. $size = $this->input->post('size', true);
  866. $grade = $this->input->post('grade', true);
  867. $color = $this->input->post('color', true);
  868. $lacecolor = $this->input->post('lacecolor', true);
  869. $lowe = $this->input->post('lowe', true);
  870. $sku = $this->input->post('sku');
  871. $title = $this->input->post('title');
  872. $warehouse = 13;
  873. $usa = $this->input->post('usa', true);
  874. $purchase = $this->input->post('purchase', true);
  875. $lacetype = $this->input->post('lacetype', true);
  876. $haircap = $this->input->post('haircap', true);
  877. $density = $this->input->post('density', true);
  878. $details = $this->input->post('details', true);
  879. $state = $this->input->post('state', true);
  880. $ktime = $this->input->post('ktime', true);
  881. $jtime = $this->input->post('jtime', true);
  882. $ktime = strtotime($ktime);
  883. $jtime = strtotime($jtime);
  884. $where = "1=1";
  885. $gj = "";
  886. $ck = "";
  887. if ($lacetype) {
  888. $where .= " and features like '%-$lacetype-%'";
  889. }
  890. if ($category) {
  891. $where .= " and features like '%-$category-%'";
  892. }
  893. if ($size) {
  894. $where .= " and features like '%-$size-%'";
  895. }
  896. if ($grade) {
  897. $where .= " and features like '%-$grade-%'";
  898. }
  899. if ($color) {
  900. $where .= " and features like '%-$color-%'";
  901. }
  902. if ($lacecolor) {
  903. $where .= " and features like '%-$lacecolor-%'";
  904. }
  905. if ($lowe) {
  906. $where .= " and features like '%-$lowe-%'";
  907. }
  908. if ($haircap) {
  909. $where .= " and features like '%-$haircap-%'";
  910. }
  911. if ($density) {
  912. $where .= " and features like '%-$density-%'";
  913. }
  914. if ($warehouse) {
  915. $where .= " and warehouse = '$warehouse'";
  916. }
  917. if ($details) {
  918. $where .= " and details = '$details'";
  919. }
  920. if ($purchase) {
  921. $where .= " and purchase = '$purchase'";
  922. }
  923. if ($state) {
  924. $where .= " and state = '$state'";
  925. }
  926. if ($ktime && $jtime) {
  927. $gj = " and enter > '$ktime' and enter < '$jtime'";
  928. $ck = " and outk > '$ktime' and outk < '$jtime'";
  929. }
  930. //数据排序
  931. $order_str = "id desc";
  932. if (empty($page)) {
  933. $start = 0;
  934. $perpage = 1;
  935. } else {
  936. $start = ($page - 1) * $perpage;
  937. }
  938. if ($sku) {
  939. $sku = trim($sku, ' ');
  940. $sku = trim($sku, ' ');
  941. $where .= " and sku like '%$sku%'";
  942. } else if ($title) {
  943. $title = trim($title, ' ');
  944. $title = trim($title, ' ');
  945. $where .= " and title like '%$title%'";
  946. }
  947. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  948. //取得信息列表
  949. $t = array();
  950. $typeclass = $this->typeclass->find_all();
  951. foreach ($typeclass as $v) {
  952. $t[$v['id']] = $v;
  953. }
  954. $rows = array();
  955. $list = array();
  956. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  957. foreach ($info_list as $key => $value) {
  958. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  959. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  960. $warehouse = $this->warehouse->read($value['warehouse']);
  961. $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');
  962. $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'] . '"');
  963. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  964. $number = $value['number'];
  965. $ftime = time() - 15 * 24 * 3600;
  966. $z = count($z); //查看订单号
  967. $info_list[$key]['warehouse'] = $warehouse['title'];
  968. $info_list[$key]['features'] = count($c);
  969. $info_list[$key]['number'] = $z;
  970. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  971. $details = array();
  972. $cpid = array();
  973. foreach ($c as $k => $v) {
  974. $details[$v['details']] = $v['details'];
  975. if ($v['cpid'] != 0) {
  976. $cpid[$v['cpid']] = $v['cpid'];
  977. }
  978. }
  979. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  980. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  981. unset($info_list[$key]['pm']);
  982. unset($info_list[$key]['jm']);
  983. unset($info_list[$key]['bm']);
  984. }
  985. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  986. $pagenum = ceil($total / $perpage);
  987. $over = $total - ($start + $perpage);
  988. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  989. echo json_encode($rows);
  990. exit;
  991. }
  992. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  993. $this->_Template('whlabel_typeck', $this->data);
  994. }
  995. //进销存导出
  996. public function _whlabeckdc()
  997. {
  998. $prc = array();
  999. $purchase = $this->purchase->find_all();
  1000. foreach ($purchase as $k => $v) {
  1001. $prc[$v['id']] = $v['title'];
  1002. }
  1003. if (isset($_GET['excel'])) {
  1004. $where = "sku != 'Preset'";
  1005. //数据排序
  1006. $order_str = "id desc";
  1007. if (empty($page)) {
  1008. $start = 0;
  1009. $perpage = 1;
  1010. } else {
  1011. $start = ($page - 1) * $perpage;
  1012. }
  1013. $category = $this->input->get('category', true);
  1014. $color = $this->input->get('color', true);
  1015. $lowe = $this->input->get('lowe', true);
  1016. $lacetype = $this->input->get('lacetype', true);
  1017. $size = $this->input->get('size', true);
  1018. $density = $this->input->get('density', true);
  1019. $haircap = $this->input->get('haircap', true);
  1020. $sku = $this->input->get('sku', true);
  1021. $details = $this->input->get('details', true);
  1022. $warehouse = 13;
  1023. $excelid = $this->input->get('sid', true);
  1024. if ($category) {
  1025. $where .= " and features like '%-$category-%'";
  1026. }
  1027. if ($color) {
  1028. $where .= " and features like '%-$color-%'";
  1029. }
  1030. if ($lowe) {
  1031. $where .= " and features like '%-$lowe-%'";
  1032. }
  1033. if ($lacetype) {
  1034. $where .= " and features like '%-$lacetype-%'";
  1035. }
  1036. if ($size) {
  1037. $where .= " and features like '%-$size-%'";
  1038. }
  1039. if ($density) {
  1040. $where .= " and features like '%-$density-%'";
  1041. }
  1042. if ($haircap) {
  1043. $where .= " and features like '%-$haircap-%'";
  1044. }
  1045. if ($warehouse) {
  1046. $where .= " and warehouse = '$warehouse'";
  1047. }
  1048. if ($sku) {
  1049. $where .= " and sku like '%$sku%'";
  1050. }
  1051. if ($details) {
  1052. $where .= " and details = '$details'";
  1053. }
  1054. $xzid = '';
  1055. if ($excelid) {
  1056. $excelid = explode(',', trim($excelid, ','));
  1057. foreach ($excelid as $key => $value) {
  1058. $xzid .= " id = " . $value . " or";
  1059. }
  1060. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1061. }
  1062. //取得信息列表
  1063. /**
  1064. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1065. $rows = array();$list = array();
  1066. foreach ($info_list as $key=>$value)
  1067. {
  1068. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1069. }
  1070. **/
  1071. $wh = array();
  1072. $w = $this->warehouse->find_all('1=1', 'id,title');
  1073. foreach ($w as $v) {
  1074. $wh[$v['id']] = $v['title'];
  1075. }
  1076. $tc = array();
  1077. $tcdata = array();
  1078. $list = array();
  1079. $classid = $this->classid->sku();
  1080. $tcall = $this->typeclass->find_all();
  1081. $typeclass = array();
  1082. foreach ($tcall as $v)
  1083. {
  1084. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1085. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1086. }
  1087. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1088. foreach ($rows as $key => $value) {
  1089. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1090. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1091. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1092. $rows[$key]['cpbz'] = $u9_info['bm'];
  1093. $rows[$key]['cs'] = $u9_info['jm'];
  1094. if(empty($value['details'])){
  1095. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1096. }else{
  1097. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1098. }
  1099. $details = array();
  1100. $cpid = array();
  1101. $cpbz = array();
  1102. $c = 0;
  1103. $g = 0;
  1104. $x = 0;
  1105. $t = 0;
  1106. $s = 0;
  1107. $q = 0;
  1108. foreach ($sd as $k => $v) {
  1109. if ($v['state'] == 0) {
  1110. $c++;
  1111. }
  1112. if ($v['state'] != 9) {
  1113. $g++;
  1114. }
  1115. if ($v['state'] == 1) {
  1116. $x++;
  1117. }
  1118. if ($v['state'] == 2) {
  1119. $t++;
  1120. }
  1121. if ($v['state'] == 8) {
  1122. $s++;
  1123. }
  1124. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1125. $q++;
  1126. }
  1127. $details[$v['details']] = $v['details'];
  1128. if ($v['cpid'] != 0) {
  1129. $cpid[$v['cpid']] = $v['cpid'];
  1130. }
  1131. if ($v['cpbz'] != '') {
  1132. $cpbz[$v['cpbz']] = $v['cpbz'];
  1133. }
  1134. }
  1135. $rows[$key]['details'] = implode("、", $details);
  1136. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1137. $number = $value['number'];
  1138. $ftime = time() - 15 * 24 * 3600;
  1139. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1140. $rows[$key]['number'] = $g;
  1141. $rows[$key]['features'] = $c;
  1142. $rows[$key]['x'] = $x;
  1143. $rows[$key]['t'] = $t;
  1144. $rows[$key]['s'] = $s;
  1145. $rows[$key]['q'] = $q;
  1146. $rows[$key]['wzsl'] = count($details);
  1147. //cpbzs
  1148. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1149. $unique_arr = array_unique($tmp_cpbzs);
  1150. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1151. }
  1152. $title = "进销存统计表" . date('Y-m-d', time());
  1153. $titlename = "<table border=1>
  1154. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1155. <tr align='center'>
  1156. <td>仓库</td>
  1157. <td>供应商</td>
  1158. <td>位置</td>
  1159. <td>库存编码</td>
  1160. <td>SKU</td>
  1161. <td>用友编码</td>
  1162. <td>用友料号</td>
  1163. <td>产品英文名</td>
  1164. <td>产品中文名</td>
  1165. <td>备注</td>
  1166. <td>入库总量</td>
  1167. <td>库存数量</td>
  1168. <td>销售数量</td>
  1169. <td>退货数量</td>
  1170. <td>删除数量</td>
  1171. <td>其它操作</td>
  1172. <td>位置数量</td>
  1173. </tr>
  1174. </table>";
  1175. $filename = $title . ".xls";
  1176. $tail = "";
  1177. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1178. }
  1179. }
  1180. public function _type()
  1181. {
  1182. $vip = 0;
  1183. if (isset($_SESSION['api'])) {
  1184. $user = $this->user->get_api($_SESSION['api']);
  1185. $fgshop = "";
  1186. $sid = "";
  1187. $usersp = explode('|', trim($user['shop'], '|'));
  1188. foreach ($usersp as $value) {
  1189. $fgshop .= " shop = " . $value . " or";
  1190. $sid .= " id = " . $value . " or";
  1191. }
  1192. if ($user['vip'] == 1) {
  1193. $vip = 1;
  1194. }
  1195. } else {
  1196. header('Location: /');
  1197. exit;
  1198. }
  1199. $prc = array();
  1200. $purchase = $this->purchase->find_all();
  1201. foreach ($purchase as $k => $v) {
  1202. $prc[$v['id']] = $v['title'];
  1203. }
  1204. $company = array();
  1205. $ct = $this->company->find_all();
  1206. foreach ($ct as $k => $v) {
  1207. $company[$v['id']] = $v['title'];
  1208. }
  1209. $sp = array();
  1210. $s = $this->shop->find_all('1=1', 'id,shopname');
  1211. foreach ($s as $v) {
  1212. $sp[$v['id']] = $v['shopname'];
  1213. }
  1214. $wh = array();
  1215. $w = $this->warehouse->find_all('1=1', 'id,title');
  1216. foreach ($w as $v) {
  1217. $wh[$v['id']] = $v['title'];
  1218. }
  1219. $post = $this->input->post(NULL, TRUE);
  1220. if (isset($post['page'])) {
  1221. $page = $this->input->post('page', true);
  1222. $perpage = $this->input->post('perpage', true);
  1223. $category = $this->input->post('category', true);
  1224. $size = $this->input->post('size', true);
  1225. $grade = $this->input->post('grade', true);
  1226. $color = $this->input->post('color', true);
  1227. $lowe = $this->input->post('lowe', true);
  1228. $sku = $this->input->post('sku');
  1229. $title = $this->input->post('title');
  1230. $warehouse = $this->input->post('warehouse', true);
  1231. $usa = $this->input->post('usa', true);
  1232. $purchase = $this->input->post('purchase', true);
  1233. $lacetype = $this->input->post('lacetype', true);
  1234. $haircap = $this->input->post('haircap', true);
  1235. $density = $this->input->post('density', true);
  1236. $details = $this->input->post('details', true);
  1237. $state = $this->input->post('state', true);
  1238. $shop = $this->input->post('shop', true);
  1239. $lacecolor = $this->input->post('lacecolor', true);
  1240. $hairnumber = $this->input->post('hairnumber', true);
  1241. $type = $this->input->post('type', true);
  1242. $ktime = $this->input->post('ktime', true);
  1243. $jtime = $this->input->post('jtime', true);
  1244. $ktime = strtotime($ktime);
  1245. $jtime = strtotime($jtime);
  1246. $cpbz = $this->input->post('cpbz', true);
  1247. $sm = $this->input->post('sm', true);
  1248. $where = "1=1";
  1249. $gj = "";
  1250. $ck = "";
  1251. if ($usa) {
  1252. if (!$warehouse) {
  1253. $where .= " and (warehouse = '5' or warehouse = '8')";
  1254. }
  1255. }
  1256. if ($warehouse) {
  1257. $where .= " and warehouse = '$warehouse'";
  1258. }
  1259. if ($details) {
  1260. $where .= " and details = '$details'";
  1261. }
  1262. if ($purchase) {
  1263. $where .= " and purchase = '$purchase'";
  1264. }
  1265. if ($state) {
  1266. $where .= " and state = '$state'";
  1267. }
  1268. if ($shop) {
  1269. $where .= " and shop like '%$shop%'";
  1270. }
  1271. if ($type) {
  1272. $where .= " and type = '$type'";
  1273. }
  1274. if ($ktime && $jtime) {
  1275. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1276. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1277. }
  1278. if ($cpbz) {
  1279. $where .= " and cpbz like '%$cpbz%' ";
  1280. }
  1281. if ($sm) {
  1282. $where .= " and sm like '%$sm%' ";
  1283. }
  1284. if ($lacecolor) {
  1285. $where .= " and features like '%-$lacecolor-%'";
  1286. }
  1287. if ($lacetype) {
  1288. $where .= " and features like '%-$lacetype-%'";
  1289. }
  1290. if ($category) {
  1291. $where .= " and features like '%-$category-%'";
  1292. }
  1293. if ($size) {
  1294. $where .= " and features like '%-$size-%'";
  1295. }
  1296. if ($grade) {
  1297. $where .= " and features like '%-$grade-%'";
  1298. }
  1299. if ($color) {
  1300. $where .= " and features like '%-$color-%'";
  1301. }
  1302. if ($lowe) {
  1303. $where .= " and features like '%-$lowe-%'";
  1304. }
  1305. if ($haircap) {
  1306. $where .= " and features like '%-$haircap-%'";
  1307. }
  1308. if ($density) {
  1309. $where .= " and features like '%-$density-%'";
  1310. }
  1311. if (!empty($hairnumber)) {
  1312. $where .= " and features like '%-128-%' ";
  1313. if ($hairnumber < 0) {
  1314. $class_list = $this->typeclass->find_all('classid = 43');
  1315. foreach ($class_list as $v) {
  1316. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1317. }
  1318. } else {
  1319. $where .= " and features like '%-$hairnumber-%'";
  1320. }
  1321. }
  1322. //数据排序
  1323. $order_str = "id desc";
  1324. if (empty($page)) {
  1325. $start = 0;
  1326. $perpage = 1;
  1327. } else {
  1328. $start = ($page - 1) * $perpage;
  1329. }
  1330. $fjnr = '';
  1331. if ($sku) {
  1332. $sku = trim($sku, ' ');
  1333. $sku = trim($sku, ' ');
  1334. $fjnr .= " and sku like '%$sku%'";
  1335. }
  1336. if ($title) {
  1337. $title = trim($title, ' ');
  1338. $title = trim($title, ' ');
  1339. $fjnr .= " and title like '%$title%'";
  1340. }
  1341. $wt = array();
  1342. $whlabel_type = $this->whlabel_type->find_all();
  1343. foreach ($whlabel_type as $v) {
  1344. $wt[$v['id']] = $v['title'];
  1345. }
  1346. //$where .= " and time > '$ktime' and time < '$jtime'";
  1347. $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
  1348. //取得信息列表
  1349. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1350. $rows = array();
  1351. $list = array();
  1352. foreach ($info_list as $key => $value) {
  1353. if (isset($wt[$value['type']])) {
  1354. $info_list[$key]['type'] = $wt[$value['type']];
  1355. } else {
  1356. $info_list[$key]['type'] = '未设置';
  1357. }
  1358. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1359. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1360. $ztdata = '';
  1361. if (count($zt) > 0) {
  1362. foreach ($zt as $vv) {
  1363. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1364. }
  1365. }
  1366. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1367. $cdata = array_filter($qbdata, function ($item) {
  1368. return $item['state'] < 1;
  1369. });
  1370. $c = array_sum(array_column($cdata, 'jnum'));
  1371. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1373. });
  1374. $g = array_sum(array_column($gdata, 'jnum'));
  1375. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1376. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1377. });
  1378. $x = array_sum(array_column($xdata, 'jnum'));
  1379. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1380. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1381. });
  1382. $t = array_sum(array_column($tdata, 'jnum'));
  1383. // $zdata = array_filter($qbdata, function ($item) {
  1384. // return $item['zd'] != "" && $item['state'] < 1;
  1385. // });
  1386. // $z = array_sum(array_column($zdata, 'jnum'));
  1387. $zdata = array_filter($qbdata, function ($item) {
  1388. return $item['zd'] != "" && $item['state'] < 1;
  1389. });
  1390. $z = array_sum(array_column($zdata, 'jnum'));
  1391. //$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');
  1392. //$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'].'"');
  1393. //$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'].'"');
  1394. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1395. //$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'].'"');
  1396. $details = array();
  1397. $cpid = array();
  1398. $od = array();
  1399. $odid = '';
  1400. $companytitle = '';
  1401. $shop_list = [];
  1402. foreach ($qbdata as $v) {
  1403. if ($v['zd'] != "" && $v['state'] < 1) {
  1404. if (!isset($od[$v['zd']])) {
  1405. $od[$v['zd']] = 1; //所有数据sku
  1406. } else {
  1407. $od[$v['zd']] = $od[$v['zd']] + 1;
  1408. }
  1409. }
  1410. if($v['state'] == 0){
  1411. $details[$v['details']] = $v['details'];
  1412. }
  1413. if ($v['state'] < 1) {
  1414. //$details[$v['details']] = $v['details'];
  1415. if ($v['cpid'] != 0) {
  1416. $cpid[$v['cpid']] = $v['cpid'];
  1417. }
  1418. }
  1419. if($v['state'] == 0){
  1420. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1421. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1422. }
  1423. if ($v['shop'] != '') {
  1424. $shop = explode(',', trim($v['shop'], ','));
  1425. foreach ($shop as $vv) {
  1426. if (!in_array($vv, $shop_list)) {
  1427. $shop_list[] = $vv;
  1428. }
  1429. }
  1430. }
  1431. }
  1432. }
  1433. foreach ($od as $k => $vv) {
  1434. $odid .= $k . '数量' . $vv;
  1435. }
  1436. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1437. $info_list[$key]['label'] = $value['sm'];
  1438. $number = $value['number'];
  1439. $ftime = time() - 15 * 24 * 3600;
  1440. $z = $z . '(' . $odid . ')'; //查看订单号
  1441. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1442. $info_list[$key]['features'] = $c;
  1443. $info_list[$key]['number'] = $ztdata;
  1444. $info_list[$key]['sm'] = $g;
  1445. $info_list[$key]['x'] = $x;
  1446. $info_list[$key]['t'] = $t;
  1447. $info_list[$key]['z'] = $z;
  1448. /**
  1449. foreach ($cdata as $k=>$v)
  1450. {
  1451. $details[$v['details']] = $v['details'];
  1452. if($v['cpid'] != 0)
  1453. {
  1454. $cpid[$v['cpid']] = $v['cpid'];
  1455. }
  1456. }
  1457. **/
  1458. $info_list[$key]['shop'] = '';
  1459. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1460. // if ($value['shop'] != '') {
  1461. // $shop = explode(',', trim($value['shop'], ','));
  1462. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1463. // }
  1464. $shop_list = array_unique($shop_list);
  1465. $shop_str = '';
  1466. foreach ($shop_list as $v) {
  1467. if(isset($sp[$v])){
  1468. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1469. }
  1470. }
  1471. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1472. /**
  1473. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1474. if(isset($companytitle[0]))
  1475. {
  1476. foreach ($companytitle as $k=>$v)
  1477. {
  1478. if($v['companytitle'] != '')
  1479. {
  1480. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1481. }
  1482. }
  1483. }
  1484. **/
  1485. }
  1486. $final_all_list = [];
  1487. foreach ($info_list as $k => $v) {
  1488. $final_all_list[] = [
  1489. 'id' => $v['id'],
  1490. "warehouse" => $v["warehouse"],
  1491. "purchase" => $v["purchase"],
  1492. "sku" => $v["sku"],
  1493. "title" => $v["title"] . "<br/>" . $v["pm"],
  1494. "details" => $v["details"],
  1495. "shop" => $v["shop"],
  1496. "cpbz" => $v["cpbz"],
  1497. 'label' => $v['label'],
  1498. "type" => $v["type"],
  1499. "features" => $v["features"],
  1500. "number" => $v["number"],
  1501. "sm" => $v["sm"],
  1502. "x" => $v["x"],
  1503. "t" => $v["t"],
  1504. "z" => $v["z"]
  1505. ];
  1506. }
  1507. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1508. $pagenum = ceil($total / $perpage);
  1509. $over = $total - ($start + $perpage);
  1510. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1511. echo json_encode($rows);
  1512. exit;
  1513. }
  1514. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1515. $this->data['shop'] = $wlshop;
  1516. $this->data['vip'] = $vip;
  1517. $this->_Template('whlabel_type', $this->data);
  1518. }
  1519. /**
  1520. * _type 优化版 v1
  1521. * 优化点:
  1522. * 1. 循环内 N+1 查询改为批量预取(方案 A),SQL 从 2+2P 降到固定 4 条
  1523. * 2. 总数统计改为只 COUNT 不传输明细字段(方案 C)
  1524. * 3. 批量 qbdata 查询去掉 features like 条件,走组合键 IN 精确匹配
  1525. * 4. 批量 transport 查询加 ORDER BY stime 保证顺序与原来一致
  1526. */
  1527. public function _typev1()
  1528. {
  1529. $vip = 0;
  1530. if (isset($_SESSION['api'])) {
  1531. $user = $this->user->get_api($_SESSION['api']);
  1532. $fgshop = "";
  1533. $sid = "";
  1534. $usersp = explode('|', trim($user['shop'], '|'));
  1535. foreach ($usersp as $value) {
  1536. $fgshop .= " shop = " . $value . " or";
  1537. $sid .= " id = " . $value . " or";
  1538. }
  1539. if ($user['vip'] == 1) {
  1540. $vip = 1;
  1541. }
  1542. } else {
  1543. header('Location: /');
  1544. exit;
  1545. }
  1546. $prc = array();
  1547. $purchase = $this->purchase->find_all();
  1548. foreach ($purchase as $k => $v) {
  1549. $prc[$v['id']] = $v['title'];
  1550. }
  1551. $company = array();
  1552. $ct = $this->company->find_all();
  1553. foreach ($ct as $k => $v) {
  1554. $company[$v['id']] = $v['title'];
  1555. }
  1556. $sp = array();
  1557. $s = $this->shop->find_all('1=1', 'id,shopname');
  1558. foreach ($s as $v) {
  1559. $sp[$v['id']] = $v['shopname'];
  1560. }
  1561. $wh = array();
  1562. $w = $this->warehouse->find_all('1=1', 'id,title');
  1563. foreach ($w as $v) {
  1564. $wh[$v['id']] = $v['title'];
  1565. }
  1566. $post = $this->input->post(NULL, TRUE);
  1567. if (isset($post['page'])) {
  1568. $page = $this->input->post('page', true);
  1569. $perpage = $this->input->post('perpage', true);
  1570. $category = $this->input->post('category', true);
  1571. $size = $this->input->post('size', true);
  1572. $grade = $this->input->post('grade', true);
  1573. $color = $this->input->post('color', true);
  1574. $lowe = $this->input->post('lowe', true);
  1575. $sku = $this->input->post('sku');
  1576. $title = $this->input->post('title');
  1577. $warehouse = $this->input->post('warehouse', true);
  1578. $usa = $this->input->post('usa', true);
  1579. $purchase = $this->input->post('purchase', true);
  1580. $lacetype = $this->input->post('lacetype', true);
  1581. $haircap = $this->input->post('haircap', true);
  1582. $density = $this->input->post('density', true);
  1583. $details = $this->input->post('details', true);
  1584. $state = $this->input->post('state', true);
  1585. $shop = $this->input->post('shop', true);
  1586. $lacecolor = $this->input->post('lacecolor', true);
  1587. $hairnumber = $this->input->post('hairnumber', true);
  1588. $type = $this->input->post('type', true);
  1589. $ktime = $this->input->post('ktime', true);
  1590. $jtime = $this->input->post('jtime', true);
  1591. $ktime = strtotime($ktime);
  1592. $jtime = strtotime($jtime);
  1593. $cpbz = $this->input->post('cpbz', true);
  1594. $sm = $this->input->post('sm', true);
  1595. $where = "1=1";
  1596. // $where_no_features 用于批量预取,去掉 features like 条件,靠组合键精确匹配
  1597. $where_no_features = "1=1";
  1598. if ($usa) {
  1599. if (!$warehouse) {
  1600. $where .= " and (warehouse = '5' or warehouse = '8')";
  1601. $where_no_features .= " and (warehouse = '5' or warehouse = '8')";
  1602. }
  1603. }
  1604. if ($warehouse) {
  1605. $where .= " and warehouse = '$warehouse'";
  1606. $where_no_features .= " and warehouse = '$warehouse'";
  1607. }
  1608. if ($details) {
  1609. $where .= " and details = '$details'";
  1610. $where_no_features .= " and details = '$details'";
  1611. }
  1612. if ($purchase) {
  1613. $where .= " and purchase = '$purchase'";
  1614. $where_no_features .= " and purchase = '$purchase'";
  1615. }
  1616. if ($state) {
  1617. $where .= " and state = '$state'";
  1618. $where_no_features .= " and state = '$state'";
  1619. }
  1620. if ($shop) {
  1621. $where .= " and shop like '%$shop%'";
  1622. $where_no_features .= " and shop like '%$shop%'";
  1623. }
  1624. if ($type) {
  1625. $where .= " and type = '$type'";
  1626. $where_no_features .= " and type = '$type'";
  1627. }
  1628. if ($cpbz) {
  1629. $where .= " and cpbz like '%$cpbz%' ";
  1630. $where_no_features .= " and cpbz like '%$cpbz%' ";
  1631. }
  1632. if ($sm) {
  1633. $where .= " and sm like '%$sm%' ";
  1634. $where_no_features .= " and sm like '%$sm%' ";
  1635. }
  1636. // features like 条件只加入 $where(列表分组用),不加入 $where_no_features
  1637. if ($lacecolor) {
  1638. $where .= " and features like '%-$lacecolor-%'";
  1639. }
  1640. if ($lacetype) {
  1641. $where .= " and features like '%-$lacetype-%'";
  1642. }
  1643. if ($category) {
  1644. $where .= " and features like '%-$category-%'";
  1645. }
  1646. if ($size) {
  1647. $where .= " and features like '%-$size-%'";
  1648. }
  1649. if ($grade) {
  1650. $where .= " and features like '%-$grade-%'";
  1651. }
  1652. if ($color) {
  1653. $where .= " and features like '%-$color-%'";
  1654. }
  1655. if ($lowe) {
  1656. $where .= " and features like '%-$lowe-%'";
  1657. }
  1658. if ($haircap) {
  1659. $where .= " and features like '%-$haircap-%'";
  1660. }
  1661. if ($density) {
  1662. $where .= " and features like '%-$density-%'";
  1663. }
  1664. if (!empty($hairnumber)) {
  1665. $where .= " and features like '%-128-%' ";
  1666. if ($hairnumber < 0) {
  1667. $class_list = $this->typeclass->find_all('classid = 43');
  1668. foreach ($class_list as $v) {
  1669. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1670. }
  1671. } else {
  1672. $where .= " and features like '%-$hairnumber-%'";
  1673. }
  1674. }
  1675. //数据排序
  1676. $order_str = "id desc";
  1677. if (empty($page)) {
  1678. $start = 0;
  1679. $perpage = 1;
  1680. } else {
  1681. $start = ($page - 1) * $perpage;
  1682. }
  1683. $fjnr = '';
  1684. if ($sku) {
  1685. $sku = trim($sku, ' ');
  1686. $sku = trim($sku, ' ');
  1687. $fjnr .= " and sku like '%$sku%'";
  1688. }
  1689. if ($title) {
  1690. $title = trim($title, ' ');
  1691. $title = trim($title, ' ');
  1692. $fjnr .= " and title like '%$title%'";
  1693. }
  1694. $wt = array();
  1695. $whlabel_type = $this->whlabel_type->find_all();
  1696. foreach ($whlabel_type as $v) {
  1697. $wt[$v['id']] = $v['title'];
  1698. }
  1699. // 列表分组(与原来完全一致)
  1700. $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);
  1701. //取得信息列表
  1702. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1703. // ========== 优化方案 A:批量预取 whlabel 组数据和 transport 数据 ==========
  1704. $keys = array();
  1705. foreach ($info_list as $v) {
  1706. $keys[] = "('" . addslashes($v['sku']) . "','" . addslashes($v['purchase'])
  1707. . "','" . addslashes($v['features']) . "','" . addslashes($v['warehouse']) . "')";
  1708. }
  1709. // 组合键函数,用于 PHP 端按分组索引
  1710. $comboKey = function ($r) {
  1711. return $r['sku'] . '|' . $r['purchase'] . '|' . $r['features'] . '|' . $r['warehouse'];
  1712. };
  1713. // 批量拉取 whlabel 组数据(使用 $where_no_features,不带 features like,靠 IN 元组精确匹配)
  1714. $all_qb = array();
  1715. if (!empty($keys)) {
  1716. $keyInSql = implode(',', $keys);
  1717. $qbAll = $this->whlabel->find_all(
  1718. $where_no_features . " and (sku,purchase,features,warehouse) IN (" . $keyInSql . ")"
  1719. );
  1720. foreach ($qbAll as $r) {
  1721. $all_qb[$comboKey($r)][] = $r;
  1722. }
  1723. }
  1724. // 批量拉取 transport 在途数据(3 列元组: sku,warehouse,features,与 IN 左侧列顺序一致)
  1725. $all_zt = array();
  1726. if (!empty($info_list)) {
  1727. $ztKeys = array();
  1728. foreach ($info_list as $v) {
  1729. $ztKeys[] = "('" . addslashes($v['sku']) . "','"
  1730. . addslashes($v['warehouse']) . "','"
  1731. . addslashes($v['features']) . "')";
  1732. }
  1733. $ztInSql = implode(',', $ztKeys);
  1734. $ztAll = $this->whlabeltransport->find_all(
  1735. "cz = '0' and (sku,warehouse,features) IN (" . $ztInSql . ")",
  1736. '*',
  1737. 'stime'
  1738. );
  1739. foreach ($ztAll as $r) {
  1740. $ck = $r['sku'] . '|' . $r['warehouse'] . '|' . $r['features'];
  1741. $all_zt[$ck][] = $r;
  1742. }
  1743. }
  1744. $rows = array();
  1745. $list = array();
  1746. foreach ($info_list as $key => $value) {
  1747. if (isset($wt[$value['type']])) {
  1748. $info_list[$key]['type'] = $wt[$value['type']];
  1749. } else {
  1750. $info_list[$key]['type'] = '未设置';
  1751. }
  1752. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1753. // transport 在途数据:从预取数组中取
  1754. $ztCk = $value['sku'] . '|' . $value['warehouse'] . '|' . $value['features'];
  1755. $zt = isset($all_zt[$ztCk]) ? $all_zt[$ztCk] : array();
  1756. $ztdata = '';
  1757. if (count($zt) > 0) {
  1758. foreach ($zt as $vv) {
  1759. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1760. }
  1761. }
  1762. // whlabel 组数据:从预取数组中取
  1763. $qbCk = $comboKey($value);
  1764. $qbdata = isset($all_qb[$qbCk]) ? $all_qb[$qbCk] : array();
  1765. $cdata = array_filter($qbdata, function ($item) {
  1766. return $item['state'] < 1;
  1767. });
  1768. $c = array_sum(array_column($cdata, 'jnum'));
  1769. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1770. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1771. });
  1772. $g = array_sum(array_column($gdata, 'jnum'));
  1773. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1774. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1775. });
  1776. $x = array_sum(array_column($xdata, 'jnum'));
  1777. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1778. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1779. });
  1780. $t = array_sum(array_column($tdata, 'jnum'));
  1781. $zdata = array_filter($qbdata, function ($item) {
  1782. return $item['zd'] != "" && $item['state'] < 1;
  1783. });
  1784. $z = array_sum(array_column($zdata, 'jnum'));
  1785. $detailsArr = array();
  1786. $cpid = array();
  1787. $od = array();
  1788. $odid = '';
  1789. $companytitle = '';
  1790. $shop_list = [];
  1791. foreach ($qbdata as $v) {
  1792. if ($v['zd'] != "" && $v['state'] < 1) {
  1793. if (!isset($od[$v['zd']])) {
  1794. $od[$v['zd']] = 1;
  1795. } else {
  1796. $od[$v['zd']] = $od[$v['zd']] + 1;
  1797. }
  1798. }
  1799. if ($v['state'] == 0) {
  1800. $detailsArr[$v['details']] = $v['details'];
  1801. }
  1802. if ($v['state'] < 1) {
  1803. if ($v['cpid'] != 0) {
  1804. $cpid[$v['cpid']] = $v['cpid'];
  1805. }
  1806. }
  1807. if ($v['state'] == 0) {
  1808. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1809. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1810. }
  1811. if ($v['shop'] != '') {
  1812. $shopArr = explode(',', trim($v['shop'], ','));
  1813. foreach ($shopArr as $vv) {
  1814. if (!in_array($vv, $shop_list)) {
  1815. $shop_list[] = $vv;
  1816. }
  1817. }
  1818. }
  1819. }
  1820. }
  1821. foreach ($od as $k => $vv) {
  1822. $odid .= $k . '数量' . $vv;
  1823. }
  1824. $info_list[$key]['cpbz'] = $value['cpbz'];
  1825. $info_list[$key]['label'] = $value['sm'];
  1826. $number = $value['number'];
  1827. $z = $z . '(' . $odid . ')';
  1828. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1829. $info_list[$key]['features'] = $c;
  1830. $info_list[$key]['number'] = $ztdata;
  1831. $info_list[$key]['sm'] = $g;
  1832. $info_list[$key]['x'] = $x;
  1833. $info_list[$key]['t'] = $t;
  1834. $info_list[$key]['z'] = $z;
  1835. $info_list[$key]['shop'] = '';
  1836. $info_list[$key]['details'] = ($cpid) ? implode(" ", $detailsArr) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $detailsArr);
  1837. $shop_list = array_unique($shop_list);
  1838. $shop_str = '';
  1839. foreach ($shop_list as $v) {
  1840. if (isset($sp[$v])) {
  1841. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1842. }
  1843. }
  1844. $info_list[$key]['shop'] = $shop_str . $companytitle;
  1845. }
  1846. $final_all_list = [];
  1847. foreach ($info_list as $k => $v) {
  1848. $final_all_list[] = [
  1849. 'id' => $v['id'],
  1850. "warehouse" => $v["warehouse"],
  1851. "purchase" => $v["purchase"],
  1852. "sku" => $v["sku"],
  1853. "title" => $v["title"] . "<br/>" . $v["pm"],
  1854. "details" => $v["details"],
  1855. "shop" => $v["shop"],
  1856. "cpbz" => $v["cpbz"],
  1857. 'label' => $v['label'],
  1858. "type" => $v["type"],
  1859. "features" => $v["features"],
  1860. "number" => $v["number"],
  1861. "sm" => $v["sm"],
  1862. "x" => $v["x"],
  1863. "t" => $v["t"],
  1864. "z" => $v["z"]
  1865. ];
  1866. }
  1867. // ========== 优化方案 C:总数统计只 COUNT,不传明细字段 ==========
  1868. // 原实现: count(find_pc(..., 'id,warehouse,sku,title,features,number')),传输了大量明细字段
  1869. // 优化为: SELECT COUNT(*) FROM (SELECT 1 FROM whlabel WHERE ... GROUP BY ...) t,只传一个数字
  1870. $countSql = "SELECT COUNT(*) AS cnt FROM (SELECT 1 FROM crowd_whlabel WHERE " . $where . $fjnr . " GROUP BY sku,purchase,features,warehouse) t";
  1871. $countResult = $this->whlabel->query($countSql)->result_array();
  1872. $total = isset($countResult[0]['cnt']) ? (int)$countResult[0]['cnt'] : 0;
  1873. $pagenum = ceil($total / $perpage);
  1874. $over = $total - ($start + $perpage);
  1875. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1876. echo json_encode($rows);
  1877. exit;
  1878. }
  1879. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1880. $this->data['shop'] = $wlshop;
  1881. $this->data['vip'] = $vip;
  1882. $this->_Template('whlabel_typev1', $this->data);
  1883. }
  1884. //美仓进销存浏览
  1885. public function _usatype()
  1886. {
  1887. if (isset($_SESSION['api'])) {
  1888. $user = $this->user->get_api($_SESSION['api']);
  1889. $usp = $user;
  1890. $fgshop = "";
  1891. $sid = "";
  1892. $wid = "";
  1893. $wtype = "";
  1894. $userwh = explode('|', trim($user['warehouse'], '|'));
  1895. foreach ($userwh as $value) {
  1896. $wid .= " id = " . $value . " or";
  1897. $wtype .= " type = " . $value . " or";
  1898. }
  1899. }
  1900. $prc = array();
  1901. $purchase = $this->purchase->find_all();
  1902. foreach ($purchase as $k => $v) {
  1903. $prc[$v['id']] = $v['title'];
  1904. }
  1905. $post = $this->input->post(NULL, TRUE);
  1906. if (isset($post['page'])) {
  1907. $page = $this->input->post('page', true);
  1908. $perpage = $this->input->post('perpage', true);
  1909. $category = $this->input->post('category', true);
  1910. $size = $this->input->post('size', true);
  1911. $grade = $this->input->post('grade', true);
  1912. $color = $this->input->post('color', true);
  1913. $lowe = $this->input->post('lowe', true);
  1914. $sku = $this->input->post('sku');
  1915. $title = $this->input->post('title');
  1916. $warehouse = $this->input->post('warehouse', true);
  1917. $usa = $this->input->post('usa', true);
  1918. $purchase = $this->input->post('purchase', true);
  1919. $lacetype = $this->input->post('lacetype', true);
  1920. $haircap = $this->input->post('haircap', true);
  1921. $density = $this->input->post('density', true);
  1922. $details = $this->input->post('details', true);
  1923. $state = $this->input->post('state', true);
  1924. $lacecolor = $this->input->post('lacecolor', true);
  1925. $cklx = $this->input->post('cklx', true);
  1926. $ktime = $this->input->post('ktime', true);
  1927. $jtime = $this->input->post('jtime', true);
  1928. $ktime = strtotime($ktime);
  1929. $jtime = strtotime($jtime);
  1930. $where = "1=1";
  1931. $gj = "";
  1932. $ck = "";
  1933. if ($lacetype) {
  1934. $where .= " and features like '%-$lacetype-%'";
  1935. }
  1936. if ($category) {
  1937. $where .= " and features like '%-$category-%'";
  1938. }
  1939. if ($size) {
  1940. $where .= " and features like '%-$size-%'";
  1941. }
  1942. if ($grade) {
  1943. $where .= " and features like '%-$grade-%'";
  1944. }
  1945. if ($color) {
  1946. $where .= " and features like '%-$color-%'";
  1947. }
  1948. if ($lowe) {
  1949. $where .= " and features like '%-$lowe-%'";
  1950. }
  1951. if ($haircap) {
  1952. $where .= " and features like '%-$haircap-%'";
  1953. }
  1954. if ($density) {
  1955. $where .= " and features like '%-$density-%'";
  1956. }
  1957. if ($lacecolor) {
  1958. $where .= " and features like '%-$lacecolor-%'";
  1959. }
  1960. if ($usa) {
  1961. if (!$warehouse) {
  1962. $where .= " and (warehouse = '5' or warehouse = '8')";
  1963. }
  1964. }
  1965. if ($warehouse) {
  1966. $where .= " and warehouse = '$warehouse'";
  1967. }
  1968. if ($details) {
  1969. $where .= " and details = '$details'";
  1970. }
  1971. if ($purchase) {
  1972. $where .= " and purchase = '$purchase'";
  1973. }
  1974. if ($state) {
  1975. $where .= " and state = '$state'";
  1976. }
  1977. $where_add = '';
  1978. if ($cklx) {
  1979. $shop = $this->shop->read($cklx);
  1980. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1981. }
  1982. if ($ktime && $jtime) {
  1983. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1984. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1985. }
  1986. //数据排序
  1987. $order_str = "id desc";
  1988. if (empty($page)) {
  1989. $start = 0;
  1990. $perpage = 1;
  1991. } else {
  1992. $start = ($page - 1) * $perpage;
  1993. }
  1994. if ($sku) {
  1995. $sku = trim($sku, ' ');
  1996. $sku = trim($sku, ' ');
  1997. $where .= " and sku like '%$sku%'";
  1998. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1999. } else if ($title) {
  2000. $title = trim($title, ' ');
  2001. $title = trim($title, ' ');
  2002. $where .= " and title like '%$title%'";
  2003. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2004. } else {
  2005. //$where .= " and time > '$ktime' and time < '$jtime'";
  2006. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2007. }
  2008. //取得信息列表
  2009. $rows = array();
  2010. $list = array();
  2011. foreach ($info_list as $key => $value) {
  2012. $warehouse = $this->warehouse->read($value['warehouse']);
  2013. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2014. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2015. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2016. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2017. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2018. $od = array();
  2019. $odid = '';
  2020. foreach ($z as $v) {
  2021. if (!isset($od[$v['zd']])) {
  2022. $od[$v['zd']] = 1; //所有数据sku
  2023. } else {
  2024. $od[$v['zd']] = $od[$v['zd']] + 1;
  2025. }
  2026. }
  2027. foreach ($od as $k => $vv) {
  2028. $odid .= $k . '数量' . $vv . ' ';
  2029. }
  2030. $z = count($z) . '(' . $odid . ')'; //查看订单号
  2031. $info_list[$key]['features'] = $c;
  2032. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  2033. $ztdata = '';
  2034. if (count($zt) > 0) {
  2035. foreach ($zt as $vv) {
  2036. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  2037. }
  2038. }
  2039. $info_list[$key]['warehouse'] = $ztdata;
  2040. $info_list[$key]['g'] = $g;
  2041. $info_list[$key]['x'] = $x;
  2042. $info_list[$key]['t'] = $t;
  2043. $info_list[$key]['z'] = $z;
  2044. }
  2045. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  2046. $pagenum = ceil($total / $perpage);
  2047. $over = $total - ($start + $perpage);
  2048. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  2049. echo json_encode($rows);
  2050. exit;
  2051. }
  2052. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  2053. $this->data['warehouse'] = $warehouse;
  2054. $this->_Template('whlabel_typeusa', $this->data);
  2055. }
  2056. //美仓进销存浏览
  2057. public function _usatypeapp()
  2058. {
  2059. $post = $this->input->post(NULL, TRUE);
  2060. if (isset($post['page'])) {
  2061. $page = $this->input->post('page', true);
  2062. $perpage = $this->input->post('perpage', true);
  2063. $sku = $this->input->post('sku', true);
  2064. $warehouse = 5;
  2065. $title = $this->input->post('title', true);
  2066. $state = $this->input->post('state', true);
  2067. $ktime = $this->input->post('ktime', true);
  2068. $jtime = $this->input->post('jtime', true);
  2069. $ktime = strtotime($ktime);
  2070. $jtime = strtotime($jtime);
  2071. $where = "1=1";
  2072. $gj = "";
  2073. $ck = "";
  2074. if ($title) {
  2075. $st = explode(' ', trim($title, ' '));
  2076. foreach ($st as $v) {
  2077. $where .= " and title like '%$v%'";
  2078. }
  2079. }
  2080. if ($warehouse) {
  2081. $where .= " and warehouse = '$warehouse'";
  2082. }
  2083. if ($state) {
  2084. $where .= " and state = '$state'";
  2085. }
  2086. if ($sku) {
  2087. $where .= " and sku like '%$sku%'";
  2088. }
  2089. if ($ktime && $jtime) {
  2090. $gj = " and enter > '$ktime' and enter < '$jtime'";
  2091. $ck = " and outk > '$ktime' and outk < '$jtime'";
  2092. }
  2093. //数据排序
  2094. $order_str = "id desc";
  2095. if (empty($page)) {
  2096. $start = 0;
  2097. $perpage = 1;
  2098. } else {
  2099. $start = ($page - 1) * $perpage;
  2100. }
  2101. //取得信息列表
  2102. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  2103. $rows = array();
  2104. $list = array();
  2105. foreach ($info_list as $key => $value) {
  2106. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  2107. }
  2108. $rowsdq = array_slice($rows, $start, $perpage);
  2109. foreach ($rowsdq as $value) {
  2110. $warehouse = $this->warehouse->read($value['warehouse']);
  2111. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  2112. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  2113. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2114. $od = array();
  2115. $odid = '';
  2116. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  2117. }
  2118. $total = count($rows);
  2119. $pagenum = ceil($total / $perpage);
  2120. $over = $total - ($start + $perpage);
  2121. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2122. echo json_encode($rows);
  2123. exit;
  2124. }
  2125. $this->_Template('phone/p_usatypeapp', $this->data);
  2126. }
  2127. //入库操作
  2128. public function _enteradd()
  2129. {
  2130. $dt = 0;
  2131. if (isset($_SESSION['api'])) {
  2132. $user = $this->user->get_api($_SESSION['api']);
  2133. $usp = $user;
  2134. $fgshop = "";
  2135. $sid = "";
  2136. $user = explode('|', trim($user['shop'], '|'));
  2137. foreach ($user as $value) {
  2138. $fgshop .= " shop = " . $value . " or";
  2139. $sid .= " id = " . $value . " or";
  2140. }
  2141. }
  2142. $tc = $this->typeclass->find_all();
  2143. $typeclass = array();
  2144. foreach ($tc as $v) {
  2145. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  2146. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  2147. }
  2148. $post = $this->input->post(NULL, TRUE);
  2149. if (isset($post['sku'])) {
  2150. $list = array();
  2151. $num = "";
  2152. $title = "";
  2153. $features = "";
  2154. $order = $this->input->post('order', true);
  2155. $shop = $this->input->post('shop', true);
  2156. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2157. $sku = $this->input->post('sku', true);
  2158. $post['sm'] = $this->input->post('sm', true);
  2159. $post['warehouse'] = $this->input->post('warehouse', true);
  2160. $post['purchase'] = $this->input->post('purchase', true);
  2161. $post['retreatwarehouse'] = $post['warehouse'];
  2162. $post['state'] = $this->input->post('state', true);
  2163. $post['rktype'] = $this->input->post('rktype', true);
  2164. $post['text'] = $this->input->post('text', true);
  2165. $category = $this->input->post('category', true);
  2166. $list['category'] = $category;
  2167. $list['hairtype'] = $this->input->post('hairtype', true);
  2168. $list['grade'] = $this->input->post('grade', true);
  2169. $size = $this->input->post('size', true);
  2170. $xzsku = $this->input->post('xzsku', true);
  2171. $list['size'] = rtrim($size, ',');
  2172. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2173. $list['extension'] = $this->input->post('extension', true);
  2174. if ($category == 1297) {
  2175. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2176. }
  2177. if ($category == 1702) {
  2178. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2179. $list['syother'] = $this->input->post('syother', true);
  2180. }
  2181. if ($category == 133) {
  2182. $list['fittype'] = $this->input->post('fittype', true);
  2183. $list['acother'] = $this->input->post('acother', true);
  2184. }
  2185. $list['color'] = $this->input->post('color', true);
  2186. $list['lowe'] = $this->input->post('lowe', true);
  2187. if (!$post['purchase']) {
  2188. $post['purchase'] = 1;
  2189. }
  2190. if ($category == 127) {
  2191. $list['type'] = $this->input->post('type', true);
  2192. $list['headroad'] = $this->input->post('headroad', true);
  2193. $list['density'] = $this->input->post('density', true);
  2194. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2195. $list['lacesize'] = $this->input->post('lacesize', true);
  2196. }
  2197. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2198. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2199. }
  2200. if ($category == 128) {
  2201. $list['lacetype'] = $this->input->post('lacetype', true);
  2202. $list['haircap'] = $this->input->post('haircap', true);
  2203. $list['density'] = $this->input->post('density', true);
  2204. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2205. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2206. $list['wigother'] = $this->input->post('wigother', true);
  2207. $list['wigother1'] = $this->input->post('wigother1', true);
  2208. $list['wigother2'] = $this->input->post('wigother2', true);
  2209. $list['product_related'] = $this->input->post('product_related', true);
  2210. }
  2211. if ($category == 129) {
  2212. $list['wide'] = $this->input->post('wide', true);
  2213. }
  2214. if ($category == 131) {
  2215. $list['gifttype'] = $this->input->post('gifttype', true);
  2216. $list['giftother'] = $this->input->post('giftother', true);
  2217. }
  2218. if ($category == 134) {
  2219. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2220. }
  2221. if ($category == 1297) {
  2222. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2223. $list['sywigother'] = $this->input->post('sywigother', true);
  2224. }
  2225. if ($category == 130 || $category == 133 || $category == 1702) {
  2226. $list['items'] = $this->input->post('items', true);
  2227. $list['weight'] = $this->input->post('weight', true);
  2228. }
  2229. if($category == 130){
  2230. $list['jfother'] = $this->input->post('jfother', true);
  2231. }
  2232. if ($category == 1702) {
  2233. $list['syhairther'] = $this->input->post('syhairther', true);
  2234. }
  2235. $classid = $this->classid->sku();
  2236. $scsku = $classid;
  2237. $pm = $classid;
  2238. foreach ($list as $k => $v) {
  2239. if ($v != 0) {
  2240. $num .= $v;
  2241. $features .= $v . '-';
  2242. $post[$k] = $v;
  2243. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2244. if ($k != 'size') {
  2245. $title .= $typeclass[$v]['title'] . " ";
  2246. }
  2247. if (isset($pm[$typeclass[$v]['classid']])) {
  2248. if ($typeclass[$v]['title'] == '9A') {
  2249. $pm[$typeclass[$v]['classid']] = '9A';
  2250. } else if ($typeclass[$v]['title'] == '10A') {
  2251. $pm[$typeclass[$v]['classid']] = '10A';
  2252. } else {
  2253. $clzh = $typeclass[$v]['zh'];
  2254. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2255. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2256. $clzh = $clzh[0];
  2257. }
  2258. $pm[$typeclass[$v]['classid']] = $clzh;
  2259. }
  2260. }
  2261. }
  2262. }
  2263. $zh = implode(" ", $pm);
  2264. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2265. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2266. if ($list['size']) {
  2267. $typeclass = $this->typeclass->read($list['size']);
  2268. $title .= $typeclass['title'];
  2269. }
  2270. $time = time();
  2271. if ($xzsku) {
  2272. $scsku = implode("-", $scsku);
  2273. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2274. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2275. $post['sku'] = trim($scsku, ' ');
  2276. } else {
  2277. $post['sku'] = $sku;
  2278. }
  2279. //$post['sku'] = trim($sku,' ');
  2280. $post['title'] = rtrim($title, ' ');
  2281. $post['number'] = $num;
  2282. $post['features'] = '-' . $features;
  2283. $post['enter'] = $time;
  2284. $post['time'] = $time; //操作时间
  2285. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2286. if ($yza) {
  2287. if ($post['features'] != $yza[0]['features']) {
  2288. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2289. exit;
  2290. }
  2291. }
  2292. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2293. if ($yzb) {
  2294. if ($post['sku'] != $yzb[0]['sku']) {
  2295. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2296. exit;
  2297. }
  2298. }
  2299. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2300. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2301. exit;
  2302. }
  2303. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2304. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2305. exit;
  2306. }
  2307. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2308. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2309. exit;
  2310. }
  2311. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2312. if (isset($yz[0]['type'])) {
  2313. $post['type'] = $yz[0]['type'];
  2314. }
  2315. if ($post['state'] == 9) //如果选择预设库存
  2316. {
  2317. $this->whlabel->insert($post);
  2318. } else {
  2319. /**
  2320. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2321. if($ljg == 1)
  2322. {
  2323. for($i=0;$i<$order;$i++)
  2324. {
  2325. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2326. $this->whlabel->insert($post);
  2327. }
  2328. }
  2329. **/
  2330. //if($post['warehouse'] == '5')
  2331. //{
  2332. //}
  2333. $yydata = $post;
  2334. $yydata['zh'] = $zh;
  2335. /**
  2336. $wl = $this->apiyy->get_cjlp($yydata);
  2337. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2338. {
  2339. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2340. }
  2341. if($wl['Data'][0]['m_isSucess'] != 1)
  2342. {
  2343. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2344. }
  2345. **/
  2346. for ($i = 0; $i < $order; $i++) {
  2347. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2348. $this->whlabel->insert($post);
  2349. }
  2350. }
  2351. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2352. exit;
  2353. }
  2354. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2355. $this->data['wlshop'] = $wlshop;
  2356. $this->_Template('whlabel_enteradd', $this->data);
  2357. }
  2358. //修改产品
  2359. public function _enteredit($arg_array)
  2360. {
  2361. $dt = 0;
  2362. if (isset($_SESSION['api'])) {
  2363. $user = $this->user->get_api($_SESSION['api']);
  2364. $usp = $user;
  2365. $fgshop = "";
  2366. $sid = "";
  2367. $user = explode('|', trim($user['shop'], '|'));
  2368. foreach ($user as $value) {
  2369. $fgshop .= " shop = " . $value . " or";
  2370. $sid .= " id = " . $value . " or";
  2371. }
  2372. }
  2373. $post = $this->input->post(NULL, TRUE);
  2374. if (isset($post['sku'])) {
  2375. $list = array();
  2376. $num = "";
  2377. $title = "";
  2378. $features = "";
  2379. $id = $this->input->post('id', true);
  2380. $order = $this->input->post('order', true);
  2381. $shop = $this->input->post('shop', true);
  2382. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2383. $post['sku'] = $this->input->post('sku', true);
  2384. $post['sm'] = $this->input->post('sm', true);
  2385. $post['warehouse'] = $this->input->post('warehouse', true);
  2386. $post['purchase'] = $this->input->post('purchase', true);
  2387. $post['retreatwarehouse'] = $post['warehouse'];
  2388. $category = $this->input->post('category', true);
  2389. $list['category'] = $category;
  2390. $list['hairtype'] = $this->input->post('hairtype', true);
  2391. $list['grade'] = $this->input->post('grade', true);
  2392. $size = $this->input->post('size', true);
  2393. $list['size'] = rtrim($size, ',');
  2394. $post['rktype'] = $this->input->post('rktype', true);
  2395. $post['text'] = $this->input->post('text', true);
  2396. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2397. $list['extension'] = $this->input->post('extension', true);
  2398. if ($category == 1297) {
  2399. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2400. }
  2401. if ($category == 1702) {
  2402. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2403. $list['syother'] = $this->input->post('syother', true);
  2404. }
  2405. if ($category == 133) {
  2406. $list['fittype'] = $this->input->post('fittype', true);
  2407. $list['acother'] = $this->input->post('acother', true);
  2408. }
  2409. $list['color'] = $this->input->post('color', true);
  2410. $list['lowe'] = $this->input->post('lowe', true);
  2411. if (!$post['purchase']) {
  2412. $post['purchase'] = 1;
  2413. }
  2414. if ($category == 127) {
  2415. $list['type'] = $this->input->post('type', true);
  2416. $list['headroad'] = $this->input->post('headroad', true);
  2417. $list['density'] = $this->input->post('density', true);
  2418. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2419. $list['lacesize'] = $this->input->post('lacesize', true);
  2420. }
  2421. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2422. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2423. }
  2424. if ($category == 128) {
  2425. $list['lacetype'] = $this->input->post('lacetype', true);
  2426. $list['haircap'] = $this->input->post('haircap', true);
  2427. $list['density'] = $this->input->post('density', true);
  2428. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2429. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2430. $list['wigother'] = $this->input->post('wigother', true);
  2431. $list['wigother1'] = $this->input->post('wigother1', true);
  2432. $list['wigother2'] = $this->input->post('wigother2', true);
  2433. $list['product_related'] = $this->input->post('product_related', true);
  2434. }
  2435. if ($category == 129) {
  2436. $list['wide'] = $this->input->post('wide', true);
  2437. }
  2438. if ($category == 131) {
  2439. $list['gifttype'] = $this->input->post('gifttype', true);
  2440. $list['giftother'] = $this->input->post('giftother', true);
  2441. }
  2442. if ($category == 134) {
  2443. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2444. }
  2445. if ($category == 1297) {
  2446. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2447. $list['sywigother'] = $this->input->post('sywigother', true);
  2448. }
  2449. if ($category == 130 || $category == 133 || $category == 1702) {
  2450. $list['items'] = $this->input->post('items', true);
  2451. $list['weight'] = $this->input->post('weight', true);
  2452. }
  2453. if($category == 130){
  2454. $list['jfother'] = $this->input->post('jfother', true);
  2455. }
  2456. if ($category == 1702) {
  2457. $list['syhairther'] = $this->input->post('syhairther', true);
  2458. }
  2459. foreach ($list as $k => $v) {
  2460. if ($v != 0) {
  2461. $num .= $v;
  2462. $features .= $v . '-';
  2463. $typeclass = $this->typeclass->read($v);
  2464. if ($k != 'size') {
  2465. $title .= $typeclass['title'] . " ";
  2466. }
  2467. }
  2468. }
  2469. $typeclass = $this->typeclass->read($list['size']);
  2470. $title .= $typeclass['title'];
  2471. $time = time();
  2472. $post['title'] = rtrim($title, ' ');
  2473. $post['number'] = $num;
  2474. $post['features'] = '-' . $features;
  2475. $post['time'] = $time; //操作时间
  2476. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2477. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2478. exit;
  2479. }
  2480. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2481. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2482. exit;
  2483. }
  2484. $uid = $this->whlabel->read($id);
  2485. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2486. if ($datanum > 0) {
  2487. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2488. exit;
  2489. }
  2490. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2491. {
  2492. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2493. if ($yza) {
  2494. if ($post['features'] != $yza[0]['features']) {
  2495. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2496. exit;
  2497. }
  2498. }
  2499. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2500. if ($yzb) {
  2501. if ($post['sku'] != $yzb[0]['sku']) {
  2502. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2503. exit;
  2504. }
  2505. }
  2506. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2507. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2508. exit;
  2509. }
  2510. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2511. foreach ($data as $v) {
  2512. $post['id'] = $v['id'];
  2513. $this->whlabel->save($post, $v['id']);
  2514. }
  2515. } else {
  2516. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2517. if ($data > 0) {
  2518. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2519. exit;
  2520. } else {
  2521. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2522. foreach ($data as $v) {
  2523. $post['id'] = $v['id'];
  2524. $this->whlabel->save($post, $v['id']);
  2525. }
  2526. }
  2527. }
  2528. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2529. exit;
  2530. }
  2531. $uid = $this->whlabel->read($arg_array[0]);
  2532. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2533. $this->data['enter'] = $uid;
  2534. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2535. $this->data['wlshop'] = $wlshop;
  2536. $this->_Template('whlabel_enteredit', $this->data);
  2537. }
  2538. //入库浏览
  2539. public function _enter()
  2540. {
  2541. $post = $this->input->post(NULL, TRUE);
  2542. if (isset($post['s'])) {
  2543. $id_arr = $this->input->post('s');
  2544. $id_arr = explode(',', $id_arr);
  2545. if (!$id_arr) {
  2546. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2547. exit;
  2548. }
  2549. //循环删除记录
  2550. foreach ($id_arr as $v) {
  2551. $sid = $this->whlabel->read($v);
  2552. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2553. if ($count > 0) {
  2554. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2555. exit;
  2556. }
  2557. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2558. foreach ($info_list as $va) {
  2559. $this->whlabel->remove($va['id']);
  2560. }
  2561. }
  2562. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2563. exit;
  2564. }
  2565. $sp = array();
  2566. $s = $this->shop->find_all('1=1', 'id,shopname');
  2567. foreach ($s as $v) {
  2568. $sp[$v['id']] = $v['shopname'];
  2569. }
  2570. $wh = array();
  2571. $w = $this->warehouse->find_all('1=1', 'id,title');
  2572. foreach ($w as $v) {
  2573. $wh[$v['id']] = $v['title'];
  2574. }
  2575. if (isset($post['page'])) {
  2576. $page = $this->input->post('page', true);
  2577. $perpage = $this->input->post('perpage', true);
  2578. $category = $this->input->post('category', true);
  2579. $size = $this->input->post('size', true);
  2580. $grade = $this->input->post('grade', true);
  2581. $color = $this->input->post('color', true);
  2582. $lowe = $this->input->post('lowe', true);
  2583. $sku = $this->input->post('sku', true);
  2584. $warehouse = $this->input->post('warehouse', true);
  2585. $purchase = $this->input->post('purchase', true);
  2586. $ktime = $this->input->post('ktime', true);
  2587. $jtime = $this->input->post('jtime', true);
  2588. $ktime = strtotime($ktime);
  2589. $jtime = strtotime($jtime);
  2590. $where = "1=1";
  2591. $gj = "";
  2592. $ck = "";
  2593. if ($category) {
  2594. $where .= " and features like '%-$category-%'";
  2595. }
  2596. if ($size) {
  2597. $where .= " and features like '%-$size-%'";
  2598. }
  2599. if ($grade) {
  2600. $where .= " and features like '%-$grade-%'";
  2601. }
  2602. if ($color) {
  2603. $where .= " and features like '%-$color-%'";
  2604. }
  2605. if ($lowe) {
  2606. $where .= " and features like '%-$lowe-%'";
  2607. }
  2608. if ($warehouse) {
  2609. $where .= " and warehouse = '$warehouse'";
  2610. }
  2611. if ($purchase) {
  2612. $where .= " and purchase = '$purchase'";
  2613. }
  2614. if ($sku) {
  2615. $where .= " and sku like '%$sku%'";
  2616. }
  2617. if ($ktime && $jtime) {
  2618. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2619. }
  2620. //数据排序
  2621. $order_str = "enter desc";
  2622. if (empty($page)) {
  2623. $start = 0;
  2624. $perpage = 1;
  2625. } else {
  2626. $start = ($page - 1) * $perpage;
  2627. }
  2628. //取得信息列表
  2629. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2630. foreach ($info_list as $k => $v) {
  2631. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2632. if ($v['shop'] == '') {
  2633. $s = '通用';
  2634. } else {
  2635. $info_list[$k]['shop'] = '';
  2636. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2637. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2638. }
  2639. }
  2640. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2641. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2642. $info_list[$k]['g'] = $g;
  2643. }
  2644. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2645. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2646. $pagenum = ceil($total / $perpage);
  2647. $over = $total - ($start + $perpage);
  2648. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2649. echo json_encode($rows);
  2650. exit;
  2651. }
  2652. $this->_Template('whlabel_enter', $this->data);
  2653. }
  2654. //出库浏览
  2655. public function _out()
  2656. {
  2657. $post = $this->input->post(NULL, TRUE);
  2658. if (isset($post['page'])) {
  2659. $page = $this->input->post('page', true);
  2660. $perpage = $this->input->post('perpage', true);
  2661. $category = $this->input->post('category', true);
  2662. $size = $this->input->post('size', true);
  2663. $grade = $this->input->post('grade', true);
  2664. $color = $this->input->post('color', true);
  2665. $lowe = $this->input->post('lowe', true);
  2666. $sku = $this->input->post('sku', true);
  2667. $warehouse = $this->input->post('warehouse', true);
  2668. $purchase = $this->input->post('purchase', true);
  2669. $state = $this->input->post('state', true);
  2670. $ktime = $this->input->post('ktime', true);
  2671. $jtime = $this->input->post('jtime', true);
  2672. $ktime = strtotime($ktime);
  2673. $jtime = strtotime($jtime);
  2674. $where = "state=3";
  2675. $gj = "";
  2676. $ck = "";
  2677. if ($category) {
  2678. $where .= " and features like '%-$category-%'";
  2679. }
  2680. if ($size) {
  2681. $where .= " and features like '%-$size-%'";
  2682. }
  2683. if ($grade) {
  2684. $where .= " and features like '%-$grade-%'";
  2685. }
  2686. if ($color) {
  2687. $where .= " and features like '%-$color-%'";
  2688. }
  2689. if ($lowe) {
  2690. $where .= " and features like '%-$lowe-%'";
  2691. }
  2692. if ($state) {
  2693. $where .= " and state = '$state'";
  2694. }
  2695. if ($warehouse) {
  2696. $where .= " and warehouse = '$warehouse'";
  2697. }
  2698. if ($purchase) {
  2699. $where .= " and purchase = '$purchase'";
  2700. }
  2701. if ($sku) {
  2702. $where .= " and sku = '$sku'";
  2703. }
  2704. if ($ktime && $jtime) {
  2705. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2706. }
  2707. //数据排序
  2708. $order_str = "id desc";
  2709. if (empty($page)) {
  2710. $start = 0;
  2711. $perpage = 1;
  2712. } else {
  2713. $start = ($page - 1) * $perpage;
  2714. }
  2715. //取得信息列表
  2716. $info_list = $this->whlabel->find_all($where, 'sku');
  2717. $rows = array();
  2718. $list = array();
  2719. foreach ($info_list as $key => $value) {
  2720. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2721. }
  2722. $rows = array_unique($rows); //删除重复记录
  2723. foreach ($rows as $key => $value) {
  2724. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2725. $ck = $this->warehouse->read($data['warehouse']);
  2726. $warehouse = $ck['title'];
  2727. $gy = $this->purchase->read($data['purchase']);
  2728. $purchase = $gy['purchase'];
  2729. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2730. $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);
  2731. }
  2732. $total = count($list);
  2733. $pagenum = ceil($total / $perpage);
  2734. $over = $total - ($start + $perpage);
  2735. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2736. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2737. echo json_encode($rows);
  2738. exit;
  2739. }
  2740. $this->_Template('whlabel_out', $this->data);
  2741. }
  2742. //出库标签浏览
  2743. public function _label()
  2744. {
  2745. $post = $this->input->post(NULL, TRUE);
  2746. if (isset($post['page'])) {
  2747. $page = $this->input->post('page', true);
  2748. $perpage = $this->input->post('perpage', true);
  2749. $sku = $this->input->post('sku', true);
  2750. $warehouse = $this->input->post('warehouse', true);
  2751. $purchase = $this->input->post('purchase', true);
  2752. $orderinfo = $this->input->post('orderinfo', true);
  2753. $waybill = $this->input->post('waybill', true);
  2754. $category = $this->input->post('category', true);
  2755. $size = $this->input->post('size', true);
  2756. $grade = $this->input->post('grade', true);
  2757. $color = $this->input->post('color', true);
  2758. $lowe = $this->input->post('lowe', true);
  2759. $where = "state=1";
  2760. if ($sku) {
  2761. $where .= " and sku = '$sku'";
  2762. }
  2763. if ($warehouse) {
  2764. $where .= " and warehouse = '$warehouse'";
  2765. }
  2766. if ($purchase) {
  2767. $where .= " and purchase = '$purchase'";
  2768. }
  2769. if ($orderinfo) {
  2770. $where .= " and orderinfo = '$orderinfo'";
  2771. }
  2772. if ($waybill) {
  2773. $where .= " and waybill = '$waybill'";
  2774. }
  2775. if ($category) {
  2776. $where .= " and features like '%-$category-%'";
  2777. }
  2778. if ($size) {
  2779. $where .= " and features like '%-$size-%'";
  2780. }
  2781. if ($grade) {
  2782. $where .= " and features like '%-$grade-%'";
  2783. }
  2784. if ($color) {
  2785. $where .= " and features like '%-$color-%'";
  2786. }
  2787. if ($lowe) {
  2788. $where .= " and features like '%-$lowe-%'";
  2789. }
  2790. //数据排序
  2791. $order_str = "outk desc";
  2792. if (empty($page)) {
  2793. $start = 0;
  2794. $perpage = 1;
  2795. } else {
  2796. $start = ($page - 1) * $perpage;
  2797. }
  2798. //取得信息列表
  2799. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2800. foreach ($info_list as $key => $value) {
  2801. $warehouse = $this->warehouse->read($value['warehouse']);
  2802. $info_list[$key]['warehouse'] = $warehouse['title'];
  2803. $purchase = $this->purchase->read($value['purchase']);
  2804. $info_list[$key]['purchase'] = $purchase['title'];
  2805. if ($value['outk'] != 0) {
  2806. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2807. } else {
  2808. $info_list[$key]['outk'] = "";
  2809. }
  2810. if ($value['orderinfo'] == 0) {
  2811. $info_list[$key]['orderinfo'] = "";
  2812. }
  2813. if ($value['waybill'] == 0) {
  2814. $info_list[$key]['waybill'] = "";
  2815. }
  2816. }
  2817. $total = $this->whlabel->find_count($where);
  2818. $pagenum = ceil($total / $perpage);
  2819. $over = $total - ($start + $perpage);
  2820. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2821. echo json_encode($rows);
  2822. exit;
  2823. }
  2824. $this->_Template('whlabel_label', $this->data);
  2825. }
  2826. //独立站出库订单
  2827. public function _outorder()
  2828. {
  2829. if (isset($_SESSION['api'])) {
  2830. $user = $this->user->get_api($_SESSION['api']);
  2831. $usp = $user;
  2832. $fgshop = "";
  2833. $sid = "";
  2834. $user = explode('|', trim($user['shop'], '|'));
  2835. foreach ($user as $value) {
  2836. $fgshop .= " shop = " . $value . " or";
  2837. $sid .= " id = " . $value . " or";
  2838. }
  2839. } else {
  2840. echo "请重新登录";
  2841. }
  2842. $post = $this->input->post(NULL, TRUE);
  2843. if (isset($post['page'])) {
  2844. $page = $this->input->post('page', true);
  2845. $perpage = $this->input->post('perpage', true);
  2846. $warehouse = $this->input->post('warehouse', true);
  2847. $xztime = $this->input->post('xztime', true);
  2848. $timetk = $this->input->post('timetkk', true);
  2849. $timetj = $this->input->post('timetjj', true);
  2850. $shop = $this->input->post('shop', true);
  2851. $source = $this->input->post('source', true);
  2852. $orderinfo = $this->input->post('orderinfo', true);
  2853. $number = $this->input->post('number', true);
  2854. $sfxh = $this->input->post('sfxh', true);
  2855. $express = $this->input->post('express', true);
  2856. $waybill = $this->input->post('waybill', true);
  2857. $library = $this->input->post('library', true);
  2858. $country = $this->input->post('country', true);
  2859. $so = $this->input->post('so', true);
  2860. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2861. $print = $this->input->post('print', true);
  2862. $state = $this->input->post('state', true);
  2863. $orderurl = $this->input->post('orderurl', true);
  2864. $productid = $this->input->post('productid', true);
  2865. $timetk = strtotime($timetk);
  2866. $timetj = strtotime($timetj);
  2867. /**
  2868. $sj = $this->input->post('sj',true);
  2869. if($sj)
  2870. {
  2871. $sj = $this->input->post('sj',true);
  2872. }
  2873. else
  2874. {
  2875. $sj = "fullorder";
  2876. }
  2877. **/
  2878. $sj = "fullorder";
  2879. $where = "1=1";
  2880. if ($warehouse) {
  2881. $where .= " and type = '$warehouse'";
  2882. }
  2883. if ($timetk && $timetj) {
  2884. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2885. }
  2886. if ($orderinfo) {
  2887. $where .= " and orderinfo = '$orderinfo'";
  2888. }
  2889. if ($number) {
  2890. $where .= " and number = '$number'";
  2891. }
  2892. if ($express) {
  2893. $where .= " and express = '$express'";
  2894. }
  2895. if ($waybill) {
  2896. $where .= " and waybill = '$waybill'";
  2897. }
  2898. if ($library) {
  2899. $where .= " and library = '$library'";
  2900. }
  2901. if ($print) {
  2902. $where .= " and print = '$print'";
  2903. }
  2904. if ($libraryconfirm) {
  2905. $where .= " and libraryconfirm = '$libraryconfirm'";
  2906. }
  2907. if ($state) {
  2908. $where .= " and state = '$state'";
  2909. }
  2910. if ($shop) {
  2911. $where .= " and shop = '$shop'";
  2912. }
  2913. if ($country) {
  2914. $where .= " and country = '$country'";
  2915. }
  2916. if ($sfxh != '') {
  2917. $where .= " and sfxh = '$sfxh'";
  2918. }
  2919. if ($so) {
  2920. $where .= " and shipremarks like '%$so%'";
  2921. }
  2922. if ($source) {
  2923. if ($source == '2d') {
  2924. $where .= " and source >= '2'";
  2925. } else {
  2926. $where .= " and source = '$source'";
  2927. }
  2928. }
  2929. if (isset($_SESSION['api'])) {
  2930. foreach ($user as $value) {
  2931. $fgshop .= " shop = " . $value . " or";
  2932. }
  2933. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2934. }
  2935. if ($orderurl) {
  2936. $url = $this->orderurl->read($orderurl);
  2937. $where .= " and link like '%" . $url['url'] . "%'";
  2938. }
  2939. if($productid){
  2940. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2941. }
  2942. //数据排序
  2943. $order_str = "librarytime desc";
  2944. if (empty($page)) {
  2945. $start = 0;
  2946. $perpage = 1;
  2947. } else {
  2948. $start = ($page - 1) * $perpage;
  2949. }
  2950. //取得信息列表
  2951. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2952. //格式化数据
  2953. foreach ($info_list as $key => $value) {
  2954. $shop = $this->shop->read($value['shop']);
  2955. $info_list[$key]['shop'] = $shop['shopname'];
  2956. $express = $this->express->read($value['express']);
  2957. $info_list[$key]['express'] = $express['servicename'];
  2958. $warehouse = $this->warehouse->read($value['type']);
  2959. $info_list[$key]['type'] = $warehouse['title'];
  2960. if ($value['librarytime'] == '0') {
  2961. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2962. } else {
  2963. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2964. }
  2965. }
  2966. $total = $this->$sj->find_count($where);
  2967. $pagenum = ceil($total / $perpage);
  2968. $over = $total - ($start + $perpage);
  2969. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2970. echo json_encode($rows);
  2971. exit;
  2972. }
  2973. $this->data['express'] = $this->express->find_all();
  2974. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2975. $this->data['wlshop'] = $wlshop;
  2976. $user = $this->user->get_api($_SESSION['api']);
  2977. $powerid = $this->power->read($user['power']);
  2978. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2979. $pid = '';
  2980. foreach ($powertext as $v) {
  2981. $pid .= " id = " . $v . " or";
  2982. }
  2983. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2984. $this->data['fullorderexcel'] = $fullorderexcel;
  2985. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2986. $this->data['orderurl'] = $orderurl;
  2987. $this->_Template('whlabel_outorder', $this->data);
  2988. }
  2989. //tt出库
  2990. public function _toutorder()
  2991. {
  2992. $fgshop = "";
  2993. $sid = "";
  2994. if (isset($_SESSION['api'])) {
  2995. $user = $this->user->get_api($_SESSION['api']);
  2996. $usp = $user;
  2997. $user = explode('|', trim($user['shop'], '|'));
  2998. foreach ($user as $value) {
  2999. $fgshop .= " shop = " . $value . " or";
  3000. $sid .= " id = " . $value . " or";
  3001. }
  3002. } else {
  3003. echo "请重新登录";
  3004. die;
  3005. }
  3006. $post = $this->input->post(NULL, TRUE);
  3007. if (isset($post['page'])) {
  3008. $page = $this->input->post('page', true);
  3009. $perpage = $this->input->post('perpage', true);
  3010. $warehouse = $this->input->post('warehouse', true);
  3011. $xztime = $this->input->post('xztime', true);
  3012. $timetk = $this->input->post('timetkk', true);
  3013. $timetj = $this->input->post('timetjj', true);
  3014. $shop = $this->input->post('shop', true);
  3015. $source = $this->input->post('source', true);
  3016. $orderinfo = $this->input->post('orderinfo', true);
  3017. $number = $this->input->post('number', true);
  3018. $sfxh = $this->input->post('sfxh', true);
  3019. $express = $this->input->post('express', true);
  3020. $waybill = $this->input->post('waybill', true);
  3021. $library = $this->input->post('library', true);
  3022. $country = $this->input->post('country', true);
  3023. $so = $this->input->post('so', true);
  3024. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3025. $print = $this->input->post('print', true);
  3026. $state = $this->input->post('state', true);
  3027. $orderurl = $this->input->post('orderurl', true);
  3028. $timetk = strtotime($timetk);
  3029. $timetj = strtotime($timetj);
  3030. /**
  3031. $sj = $this->input->post('sj',true);
  3032. if($sj)
  3033. {
  3034. $sj = $this->input->post('sj',true);
  3035. }
  3036. else
  3037. {
  3038. $sj = "fullorder";
  3039. }
  3040. **/
  3041. $sj = "fullordertt";
  3042. $where = "1=1";
  3043. if ($warehouse) {
  3044. $where .= " and type = '$warehouse'";
  3045. }
  3046. if ($timetk && $timetj) {
  3047. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3048. }
  3049. if ($orderinfo) {
  3050. $where .= " and orderinfo = '$orderinfo'";
  3051. }
  3052. if ($number) {
  3053. $where .= " and number = '$number'";
  3054. }
  3055. if ($express) {
  3056. $where .= " and express = '$express'";
  3057. }
  3058. if ($waybill) {
  3059. $where .= " and waybill = '$waybill'";
  3060. }
  3061. if ($library) {
  3062. $where .= " and library = '$library'";
  3063. }
  3064. if ($print) {
  3065. $where .= " and print = '$print'";
  3066. }
  3067. if ($libraryconfirm) {
  3068. $where .= " and libraryconfirm = '$libraryconfirm'";
  3069. }
  3070. if ($state) {
  3071. $where .= " and state = '$state'";
  3072. }
  3073. if ($shop) {
  3074. $where .= " and shop = '$shop'";
  3075. }
  3076. if ($country) {
  3077. $where .= " and country = '$country'";
  3078. }
  3079. if ($sfxh != '') {
  3080. $where .= " and sfxh = '$sfxh'";
  3081. }
  3082. if ($so) {
  3083. $where .= " and shipremarks like '%$so%'";
  3084. }
  3085. if ($source) {
  3086. if ($source == '2d') {
  3087. $where .= " and source >= '2'";
  3088. } else {
  3089. $where .= " and source = '$source'";
  3090. }
  3091. }
  3092. if (isset($_SESSION['api'])) {
  3093. foreach ($user as $value) {
  3094. $fgshop .= " shop = " . $value . " or";
  3095. }
  3096. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3097. }
  3098. if ($orderurl) {
  3099. $url = $this->orderurl->read($orderurl);
  3100. $where .= " and link like '%" . $url['url'] . "%'";
  3101. }
  3102. //数据排序
  3103. $order_str = "librarytime desc";
  3104. if (empty($page)) {
  3105. $start = 0;
  3106. $perpage = 1;
  3107. } else {
  3108. $start = ($page - 1) * $perpage;
  3109. }
  3110. //取得信息列表
  3111. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3112. //格式化数据
  3113. foreach ($info_list as $key => $value) {
  3114. $shop = $this->shop->read($value['shop']);
  3115. $info_list[$key]['shop'] = $shop['shopname'];
  3116. $express = $this->express->read($value['express']);
  3117. $info_list[$key]['express'] = $express['servicename'];
  3118. $warehouse = $this->warehouse->read($value['type']);
  3119. $info_list[$key]['type'] = $warehouse['title'];
  3120. if ($value['librarytime'] == '0') {
  3121. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3122. } else {
  3123. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3124. }
  3125. }
  3126. $total = $this->$sj->find_count($where);
  3127. $pagenum = ceil($total / $perpage);
  3128. $over = $total - ($start + $perpage);
  3129. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3130. echo json_encode($rows);
  3131. exit;
  3132. }
  3133. $this->data['express'] = $this->express->find_all();
  3134. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3135. $this->data['wlshop'] = $wlshop;
  3136. $user = $this->user->get_api($_SESSION['api']);
  3137. $powerid = $this->power->read($user['power']);
  3138. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3139. $pid = '';
  3140. foreach ($powertext as $v) {
  3141. $pid .= " id = " . $v . " or";
  3142. }
  3143. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3144. $this->data['fullorderexcel'] = $fullorderexcel;
  3145. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3146. $this->data['orderurl'] = $orderurl;
  3147. $this->_Template('whlabel_toutorder', $this->data);
  3148. }
  3149. //tt出库
  3150. public function _aoutorder()
  3151. {
  3152. if (isset($_SESSION['api'])) {
  3153. $user = $this->user->get_api($_SESSION['api']);
  3154. $usp = $user;
  3155. $fgshop = "";
  3156. $sid = "";
  3157. $user = explode('|', trim($user['shop'], '|'));
  3158. foreach ($user as $value) {
  3159. $fgshop .= " shop = " . $value . " or";
  3160. $sid .= " id = " . $value . " or";
  3161. }
  3162. } else {
  3163. echo "请重新登录";
  3164. }
  3165. $post = $this->input->post(NULL, TRUE);
  3166. if (isset($post['page'])) {
  3167. $page = $this->input->post('page', true);
  3168. $perpage = $this->input->post('perpage', true);
  3169. $warehouse = $this->input->post('warehouse', true);
  3170. $xztime = $this->input->post('xztime', true);
  3171. $timetk = $this->input->post('timetkk', true);
  3172. $timetj = $this->input->post('timetjj', true);
  3173. $shop = $this->input->post('shop', true);
  3174. $source = $this->input->post('source', true);
  3175. $orderinfo = $this->input->post('orderinfo', true);
  3176. $number = $this->input->post('number', true);
  3177. $sfxh = $this->input->post('sfxh', true);
  3178. $express = $this->input->post('express', true);
  3179. $waybill = $this->input->post('waybill', true);
  3180. $library = $this->input->post('library', true);
  3181. $country = $this->input->post('country', true);
  3182. $so = $this->input->post('so', true);
  3183. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3184. $print = $this->input->post('print', true);
  3185. $state = $this->input->post('state', true);
  3186. $orderurl = $this->input->post('orderurl', true);
  3187. $timetk = strtotime($timetk);
  3188. $timetj = strtotime($timetj);
  3189. /**
  3190. $sj = $this->input->post('sj',true);
  3191. if($sj)
  3192. {
  3193. $sj = $this->input->post('sj',true);
  3194. }
  3195. else
  3196. {
  3197. $sj = "fullorder";
  3198. }
  3199. **/
  3200. $sj = "fullorderamz";
  3201. $where = "1=1";
  3202. if ($warehouse) {
  3203. $where .= " and type = '$warehouse'";
  3204. }
  3205. if ($timetk && $timetj) {
  3206. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3207. }
  3208. if ($orderinfo) {
  3209. $where .= " and orderinfo = '$orderinfo'";
  3210. }
  3211. if ($number) {
  3212. $where .= " and number = '$number'";
  3213. }
  3214. if ($express) {
  3215. $where .= " and express = '$express'";
  3216. }
  3217. if ($waybill) {
  3218. $where .= " and waybill = '$waybill'";
  3219. }
  3220. if ($library) {
  3221. $where .= " and library = '$library'";
  3222. }
  3223. if ($print) {
  3224. $where .= " and print = '$print'";
  3225. }
  3226. if ($libraryconfirm) {
  3227. $where .= " and libraryconfirm = '$libraryconfirm'";
  3228. }
  3229. if ($state) {
  3230. $where .= " and state = '$state'";
  3231. }
  3232. if ($shop) {
  3233. $where .= " and shop = '$shop'";
  3234. }
  3235. if ($country) {
  3236. $where .= " and country = '$country'";
  3237. }
  3238. if ($sfxh != '') {
  3239. $where .= " and sfxh = '$sfxh'";
  3240. }
  3241. if ($so) {
  3242. $where .= " and shipremarks like '%$so%'";
  3243. }
  3244. if ($source) {
  3245. if ($source == '2d') {
  3246. $where .= " and source >= '2'";
  3247. } else {
  3248. $where .= " and source = '$source'";
  3249. }
  3250. }
  3251. if (isset($_SESSION['api'])) {
  3252. foreach ($user as $value) {
  3253. $fgshop .= " shop = " . $value . " or";
  3254. }
  3255. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3256. }
  3257. if ($orderurl) {
  3258. $url = $this->orderurl->read($orderurl);
  3259. $where .= " and link like '%" . $url['url'] . "%'";
  3260. }
  3261. //数据排序
  3262. $order_str = "librarytime desc";
  3263. if (empty($page)) {
  3264. $start = 0;
  3265. $perpage = 1;
  3266. } else {
  3267. $start = ($page - 1) * $perpage;
  3268. }
  3269. //取得信息列表
  3270. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3271. //格式化数据
  3272. foreach ($info_list as $key => $value) {
  3273. $shop = $this->shop->read($value['shop']);
  3274. $info_list[$key]['shop'] = $shop['shopname'];
  3275. $express = $this->express->read($value['express']);
  3276. $info_list[$key]['express'] = $express['servicename'];
  3277. $warehouse = $this->warehouse->read($value['type']);
  3278. $info_list[$key]['type'] = $warehouse['title'];
  3279. if ($value['librarytime'] == '0') {
  3280. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3281. } else {
  3282. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3283. }
  3284. }
  3285. $total = $this->$sj->find_count($where);
  3286. $pagenum = ceil($total / $perpage);
  3287. $over = $total - ($start + $perpage);
  3288. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3289. echo json_encode($rows);
  3290. exit;
  3291. }
  3292. $this->data['express'] = $this->express->find_all();
  3293. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3294. $this->data['wlshop'] = $wlshop;
  3295. $user = $this->user->get_api($_SESSION['api']);
  3296. $powerid = $this->power->read($user['power']);
  3297. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3298. $pid = '';
  3299. foreach ($powertext as $v) {
  3300. $pid .= " id = " . $v . " or";
  3301. }
  3302. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3303. $this->data['fullorderexcel'] = $fullorderexcel;
  3304. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3305. $this->data['orderurl'] = $orderurl;
  3306. $this->_Template('whlabel_aoutorder', $this->data);
  3307. }
  3308. //速卖通出库订单
  3309. public function _soutorder()
  3310. {
  3311. if (isset($_SESSION['api'])) {
  3312. $user = $this->user->get_api($_SESSION['api']);
  3313. $usp = $user;
  3314. $fgshop = "";
  3315. $sid = "";
  3316. $user = explode('|', trim($user['shop'], '|'));
  3317. foreach ($user as $value) {
  3318. $sid .= " id = " . $value . " or";
  3319. }
  3320. }
  3321. $post = $this->input->post(NULL, TRUE);
  3322. if (isset($post['page'])) {
  3323. $page = $this->input->post('page', true);
  3324. $perpage = $this->input->post('perpage', true);
  3325. $warehouse = $this->input->post('warehouse', true);
  3326. $xztime = $this->input->post('xztime', true);
  3327. $timetk = $this->input->post('timetkk', true);
  3328. $timetj = $this->input->post('timetjj', true);
  3329. $shop = $this->input->post('shop', true);
  3330. $source = $this->input->post('source', true);
  3331. $orderinfo = $this->input->post('orderinfo', true);
  3332. $number = $this->input->post('number', true);
  3333. $express = $this->input->post('express', true);
  3334. $waybill = $this->input->post('waybill', true);
  3335. $library = $this->input->post('library', true);
  3336. $country = $this->input->post('country', true);
  3337. $sfxh = $this->input->post('sfxh', true);
  3338. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3339. $print = $this->input->post('print', true);
  3340. $state = $this->input->post('state', true);
  3341. $so = $this->input->post('so', true);
  3342. $timetk = strtotime($timetk);
  3343. $timetj = strtotime($timetj);
  3344. /**
  3345. $sj = $this->input->post('sj',true);
  3346. if($sj)
  3347. {
  3348. $sj = $this->input->post('sj',true);
  3349. }
  3350. else
  3351. {
  3352. $sj = "fullorder";
  3353. }
  3354. **/
  3355. $sj = "fullordersmt";
  3356. $where = "1=1";
  3357. if ($warehouse) {
  3358. $where .= " and type = '$warehouse'";
  3359. }
  3360. if ($timetk && $timetj) {
  3361. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3362. }
  3363. if ($orderinfo) {
  3364. $where .= " and orderinfo = '$orderinfo'";
  3365. }
  3366. if ($number) {
  3367. $where .= " and number = '$number'";
  3368. }
  3369. if ($express) {
  3370. $where .= " and express = '$express'";
  3371. }
  3372. if ($waybill) {
  3373. $where .= " and waybill = '$waybill'";
  3374. }
  3375. if ($library) {
  3376. $where .= " and library = '$library'";
  3377. }
  3378. if ($print) {
  3379. $where .= " and print = '$print'";
  3380. }
  3381. if ($libraryconfirm) {
  3382. $where .= " and libraryconfirm = '$libraryconfirm'";
  3383. }
  3384. if ($state) {
  3385. $where .= " and state = '$state'";
  3386. }
  3387. if ($shop) {
  3388. $where .= " and shop = '$shop'";
  3389. }
  3390. if ($sfxh != '') {
  3391. $where .= " and sfxh = '$sfxh'";
  3392. }
  3393. if ($so) {
  3394. $where .= " and shipremarks like '%$so%'";
  3395. }
  3396. if ($source) {
  3397. $where .= " and source = '$source'";
  3398. }
  3399. if ($country) {
  3400. $where .= " and country = '$country'";
  3401. } else {
  3402. if (isset($_SESSION['api'])) {
  3403. foreach ($user as $value) {
  3404. $fgshop .= " shop = " . $value . " or";
  3405. }
  3406. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3407. }
  3408. }
  3409. //数据排序
  3410. $order_str = "librarytime desc";
  3411. if (empty($page)) {
  3412. $start = 0;
  3413. $perpage = 1;
  3414. } else {
  3415. $start = ($page - 1) * $perpage;
  3416. }
  3417. //取得信息列表
  3418. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3419. //格式化数据
  3420. foreach ($info_list as $key => $value) {
  3421. $shop = $this->shop->read($value['shop']);
  3422. $info_list[$key]['shop'] = $shop['shopname'];
  3423. $express = $this->express->read($value['express']);
  3424. $info_list[$key]['express'] = $express['servicename'];
  3425. $warehouse = $this->warehouse->read($value['type']);
  3426. $info_list[$key]['type'] = $warehouse['title'];
  3427. if ($value['librarytime'] == '0') {
  3428. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3429. } else {
  3430. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3431. }
  3432. }
  3433. $total = $this->$sj->find_count($where);
  3434. $pagenum = ceil($total / $perpage);
  3435. $over = $total - ($start + $perpage);
  3436. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3437. echo json_encode($rows);
  3438. exit;
  3439. }
  3440. $this->data['express'] = $this->express->find_all();
  3441. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3442. $this->data['wlshop'] = $wlshop;
  3443. $user = $this->user->get_api($_SESSION['api']);
  3444. $powerid = $this->power->read($user['power']);
  3445. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3446. $pid = '';
  3447. foreach ($powertext as $v) {
  3448. $pid .= " id = " . $v . " or";
  3449. }
  3450. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3451. $this->data['fullorderexcel'] = $fullorderexcel;
  3452. $this->_Template('whlabel_soutorder', $this->data);
  3453. }
  3454. //订单退库
  3455. public function _retreat()
  3456. {
  3457. $post = $this->input->post(NULL, TRUE);
  3458. if (isset($post['page'])) {
  3459. $page = $this->input->post('page', true);
  3460. $perpage = $this->input->post('perpage', true);
  3461. $warehouse = $this->input->post('warehouse', true);
  3462. $timetk = $this->input->post('timetk', true);
  3463. $timetj = $this->input->post('timetj', true);
  3464. $shop = $this->input->post('shop', true);
  3465. $source = $this->input->post('source', true);
  3466. $state = $this->input->post('state', true);
  3467. $review = $this->input->post('review', true);
  3468. $state = $this->input->post('state', true);
  3469. $express = $this->input->post('express', true);
  3470. $orderinfo = $this->input->post('orderinfo', true);
  3471. $user = $this->input->post('user', true);
  3472. $name = $this->input->post('name', true);
  3473. $waybill = $this->input->post('waybill', true);
  3474. $timetk = strtotime($timetk);
  3475. $timetj = strtotime($timetj);
  3476. $where = "(state=206 or state=210) and mergeid = 0";
  3477. if ($warehouse) {
  3478. $where .= " and state = '$warehouse'";
  3479. }
  3480. if ($timetk && $timetj) {
  3481. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3482. }
  3483. if ($shop) {
  3484. $where .= " and shop = '$shop'";
  3485. }
  3486. if ($source) {
  3487. $where .= " and source = '$source'";
  3488. }
  3489. if ($state) {
  3490. $where .= " and state = '$state'";
  3491. }
  3492. if ($review) {
  3493. $where .= " and review = '$review'";
  3494. }
  3495. if ($state) {
  3496. $where .= " and state = '$state'";
  3497. }
  3498. if ($express) {
  3499. $where .= " and express = '$express'";
  3500. }
  3501. if ($orderinfo) {
  3502. $where .= " and orderinfo = '$orderinfo'";
  3503. }
  3504. if ($user) {
  3505. $where .= " and user = '$user'";
  3506. }
  3507. if ($name) {
  3508. $where .= " and name = '$name'";
  3509. }
  3510. if ($waybill) {
  3511. $where .= " and waybill = '$waybill'";
  3512. }
  3513. //数据排序
  3514. $order_str = "id desc";
  3515. if (empty($page)) {
  3516. $start = 0;
  3517. $perpage = 1;
  3518. } else {
  3519. $start = ($page - 1) * $perpage;
  3520. }
  3521. //取得信息列表
  3522. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3523. //格式化数据
  3524. foreach ($info_list as $key => $value) {
  3525. $shop = $this->shop->read($value['shop']);
  3526. $info_list[$key]['shop'] = $shop['shopname'];
  3527. $warehouse = $this->warehouse->read($value['warehouse']);
  3528. $info_list[$key]['warehouse'] = $warehouse['title'];
  3529. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3530. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3531. if ($value['waybill'] == 0) {
  3532. $info_list[$key]['waybill'] = "";
  3533. }
  3534. $express = $this->express->read($value['express']);
  3535. $info_list[$key]['express'] = $express['title'];
  3536. $typeclass = $this->typeclass->read($value['state']);
  3537. $info_list[$key]['state'] = $typeclass['title'];
  3538. }
  3539. $total = $this->fullorder->find_count($where);
  3540. $pagenum = ceil($total / $perpage);
  3541. $over = $total - ($start + $perpage);
  3542. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3543. echo json_encode($rows);
  3544. exit;
  3545. }
  3546. $this->data['express'] = $this->express->find_all();
  3547. $this->_Template('whlabel_retreat', $this->data);
  3548. }
  3549. //退库标签浏览
  3550. public function _retreatlk()
  3551. {
  3552. $post = $this->input->post(NULL, TRUE);
  3553. if (isset($post['page'])) {
  3554. $page = $this->input->post('page', true);
  3555. $perpage = $this->input->post('perpage', true);
  3556. $timetk = $this->input->post('timetk', true);
  3557. $timetj = $this->input->post('timetj', true);
  3558. $sku = $this->input->post('sku', true);
  3559. $warehouse = $this->input->post('warehouse', true);
  3560. $purchase = $this->input->post('purchase', true);
  3561. $orderinfo = $this->input->post('orderinfo', true);
  3562. $waybill = $this->input->post('waybill', true);
  3563. $category = $this->input->post('category', true);
  3564. $size = $this->input->post('size', true);
  3565. $grade = $this->input->post('grade', true);
  3566. $color = $this->input->post('color', true);
  3567. $lowe = $this->input->post('lowe', true);
  3568. $state = $this->input->post('state', true);
  3569. $timetk = strtotime($timetk);
  3570. $timetj = strtotime($timetj);
  3571. $where = "state=2";
  3572. if ($timetk && $timetj) {
  3573. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3574. }
  3575. if ($sku) {
  3576. $where .= " and sku = '$sku'";
  3577. }
  3578. if ($warehouse) {
  3579. $where .= " and warehouse = '$warehouse'";
  3580. }
  3581. if ($purchase) {
  3582. $where .= " and purchase = '$purchase'";
  3583. }
  3584. if ($orderinfo) {
  3585. $where .= " and orderinfo = '$orderinfo'";
  3586. }
  3587. if ($waybill) {
  3588. $where .= " and waybill = '$waybill'";
  3589. }
  3590. if ($category) {
  3591. $where .= " and features like '%-$category-%'";
  3592. }
  3593. if ($size) {
  3594. $where .= " and features like '%-$size-%'";
  3595. }
  3596. if ($grade) {
  3597. $where .= " and features like '%-$grade-%'";
  3598. }
  3599. if ($color) {
  3600. $where .= " and features like '%-$color-%'";
  3601. }
  3602. if ($lowe) {
  3603. $where .= " and features like '%-$lowe-%'";
  3604. }
  3605. //数据排序
  3606. $order_str = "time desc";
  3607. if (empty($page)) {
  3608. $start = 0;
  3609. $perpage = 1;
  3610. } else {
  3611. $start = ($page - 1) * $perpage;
  3612. }
  3613. //取得信息列表
  3614. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3615. foreach ($info_list as $key => $value) {
  3616. $warehouse = $this->warehouse->read($value['warehouse']);
  3617. $info_list[$key]['warehouse'] = $warehouse['title'];
  3618. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3619. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3620. $purchase = $this->purchase->read($value['purchase']);
  3621. $info_list[$key]['purchase'] = $purchase['title'];
  3622. if ($value['outk'] != 0) {
  3623. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3624. } else {
  3625. $info_list[$key]['outk'] = "";
  3626. }
  3627. if ($value['retreat'] != 0) {
  3628. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3629. } else {
  3630. $info_list[$key]['retreat'] = "";
  3631. }
  3632. if ($value['orderinfo'] == 0) {
  3633. $info_list[$key]['orderinfo'] = "";
  3634. }
  3635. if ($value['waybill'] == 0) {
  3636. $info_list[$key]['waybill'] = "";
  3637. }
  3638. }
  3639. $total = $this->whlabel->find_count($where);
  3640. $pagenum = ceil($total / $perpage);
  3641. $over = $total - ($start + $perpage);
  3642. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3643. echo json_encode($rows);
  3644. exit;
  3645. }
  3646. $this->_Template('whlabel_retreatlk', $this->data);
  3647. }
  3648. //更换标签及浏览
  3649. public function _change()
  3650. {
  3651. $post = $this->input->post(NULL, TRUE);
  3652. if (isset($post['page'])) {
  3653. $page = $this->input->post('page', true);
  3654. $perpage = $this->input->post('perpage', true);
  3655. $timetk = $this->input->post('timetk', true);
  3656. $timetj = $this->input->post('timetj', true);
  3657. $label = $this->input->post('label', true);
  3658. $oldlabel = $this->input->post('oldlabel', true);
  3659. $timetk = strtotime($timetk);
  3660. $timetj = strtotime($timetj);
  3661. $where = "state=10 ";
  3662. if ($timetk && $timetj) {
  3663. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3664. }
  3665. if ($label) {
  3666. $where .= " and label = '$label'";
  3667. }
  3668. if ($oldlabel) {
  3669. $where .= " and oldlabel = '$oldlabel'";
  3670. }
  3671. //数据排序
  3672. $order_str = "time asc";
  3673. if (empty($page)) {
  3674. $start = 0;
  3675. $perpage = 1;
  3676. } else {
  3677. $start = ($page - 1) * $perpage;
  3678. }
  3679. //取得信息列表
  3680. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3681. foreach ($info_list as $key => $value) {
  3682. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3683. }
  3684. $total = $this->whlabel->find_count($where);
  3685. $pagenum = ceil($total / $perpage);
  3686. $over = $total - ($start + $perpage);
  3687. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3688. echo json_encode($rows);
  3689. exit;
  3690. }
  3691. $this->_Template('whlabel_change', $this->data);
  3692. }
  3693. //产品标签
  3694. public function _cpbqdc()
  3695. {
  3696. if (isset($_GET['excel'])) {
  3697. $where = "1=1";
  3698. //数据排序
  3699. $order_str = "id desc";
  3700. if (empty($page)) {
  3701. $start = 0;
  3702. $perpage = 1;
  3703. } else {
  3704. $start = ($page - 1) * $perpage;
  3705. }
  3706. $warehouse = $this->input->get('warehouse', true);
  3707. $state = $this->input->get('state', true);
  3708. $timetk = $this->input->get('timetkk', true);
  3709. $timetj = $this->input->get('timetjj', true);
  3710. $timetk = strtotime($timetk);
  3711. $timetj = strtotime($timetj);
  3712. if ($warehouse) {
  3713. $where .= " and warehouse = '$warehouse'";
  3714. }
  3715. if ($state || $state == 0) {
  3716. $where .= " and state = '$state'";
  3717. }
  3718. if ($timetk && $timetj) {
  3719. $where .= " and time > '$timetk' and time < '$timetj'";
  3720. }
  3721. //取得信息列表
  3722. $info_list = $this->whlabel->find_all($where, '*');
  3723. $rows = array();
  3724. $list = array();
  3725. foreach ($info_list as $key => $value) {
  3726. $rows[$value['time']] = $value; //所有数据sku
  3727. }
  3728. foreach ($rows as $value) {
  3729. $warehouse = $this->warehouse->read($value['warehouse']);
  3730. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3731. $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);
  3732. }
  3733. $title = "产品标签统计表";
  3734. $titlename = "<table border=1>
  3735. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3736. <tr align='center'>
  3737. <td>仓库</td>
  3738. <td>SKU</td>
  3739. <td>产品</td>
  3740. <td>入库时间</td>
  3741. <td>操作时间</td>
  3742. <td>备注</td>
  3743. <td>数量</td>
  3744. </tr>
  3745. </table>";
  3746. $filename = $title . ".xls";
  3747. $tail = "";
  3748. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3749. }
  3750. }
  3751. //进销存导出
  3752. public function _exceljxc()
  3753. {
  3754. $classid = $this->classid->sku();
  3755. $pm = $classid;
  3756. $typeclass = array();
  3757. $tc = $this->typeclass->find_all();
  3758. foreach ($tc as $v) {
  3759. $typeclass[$v['id']] = $v;
  3760. }
  3761. $prc = array();
  3762. $purchase = $this->purchase->find_all();
  3763. foreach ($purchase as $k => $v) {
  3764. $prc[$v['id']] = $v['title'];
  3765. }
  3766. if (isset($_GET['excel'])) {
  3767. $where = "sku != 'Preset'";
  3768. //数据排序
  3769. $order_str = "id desc";
  3770. if (empty($page)) {
  3771. $start = 0;
  3772. $perpage = 1;
  3773. } else {
  3774. $start = ($page - 1) * $perpage;
  3775. }
  3776. $category = $this->input->get('category', true);
  3777. $warehouse = $this->input->get('warehouse', true);
  3778. $excelid = $this->input->get('sid', true);
  3779. if ($category) {
  3780. $where .= " and features like '%-$category-%'";
  3781. }
  3782. if ($warehouse) {
  3783. $where .= " and warehouse = '$warehouse'";
  3784. }
  3785. $xzid = '';
  3786. if ($excelid) {
  3787. $excelid = explode(',', trim($excelid, ','));
  3788. foreach ($excelid as $key => $value) {
  3789. $xzid .= " id = " . $value . " or";
  3790. }
  3791. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3792. }
  3793. //取得信息列表
  3794. /**
  3795. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3796. $rows = array();$list = array();
  3797. foreach ($info_list as $key=>$value)
  3798. {
  3799. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3800. }
  3801. **/
  3802. $wt = array();
  3803. $whlabel_type = $this->whlabel_type->find_all();
  3804. foreach ($whlabel_type as $v) {
  3805. $wt[$v['id']] = $v['title'];
  3806. }
  3807. $wh = array();
  3808. $w = $this->warehouse->find_all('1=1', 'id,title');
  3809. foreach ($w as $v) {
  3810. $wh[$v['id']] = $v['title'];
  3811. }
  3812. $list = array();
  3813. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3814. foreach ($rows as $key => $value) {
  3815. if (isset($wt[$value['type']])) {
  3816. $rows[$key]['type'] = $wt[$value['type']];
  3817. } else {
  3818. $rows[$key]['type'] = '未设置';
  3819. }
  3820. $bm = '03';
  3821. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3822. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3823. $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');
  3824. $details = array();
  3825. $cpid = array();
  3826. $cpbz = array();
  3827. $c = 0;
  3828. $g = 0;
  3829. $x = 0;
  3830. $t = 0;
  3831. $s = 0;
  3832. $q = 0;
  3833. foreach ($sd as $k => $v) {
  3834. if ($v['state'] == 0) {
  3835. $c++;
  3836. if ($v['cpid'] != 0) {
  3837. $cpid[$v['cpid']] = $v['cpid'];
  3838. }
  3839. if ($v['cpbz'] != '') {
  3840. $cpbz[$v['cpbz']] = $v['cpbz'];
  3841. }
  3842. }
  3843. if ($v['state'] != 9) {
  3844. $g++;
  3845. }
  3846. if ($v['state'] == 1) {
  3847. $x++;
  3848. }
  3849. if ($v['state'] == 2) {
  3850. $t++;
  3851. }
  3852. if ($v['state'] == 8) {
  3853. $s++;
  3854. }
  3855. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3856. $q++;
  3857. }
  3858. $details[$v['details']] = $v['details'];
  3859. }
  3860. $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'] . '"');
  3861. $rows[$key]['details'] = implode("、", $details);
  3862. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3863. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3864. $number = $value['number'];
  3865. $ftime = time() - 15 * 24 * 3600;
  3866. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3867. $rows[$key]['number'] = $g;
  3868. $rows[$key]['c'] = $c;
  3869. $rows[$key]['x'] = $x;
  3870. $rows[$key]['t'] = $t;
  3871. $rows[$key]['s'] = $s;
  3872. $rows[$key]['q'] = $q;
  3873. $rows[$key]['z'] = $z;
  3874. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3875. $features = explode('-', trim($features, '-'));
  3876. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3877. // $pm = $classid;
  3878. // $jm = $classid;
  3879. // foreach($features as $k=>$v)
  3880. // {
  3881. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3882. // {
  3883. // if($typeclass[$v]['bm'] != '')
  3884. // {
  3885. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3886. // }
  3887. // }
  3888. // if($v != 0)
  3889. // {
  3890. // if(!isset($typeclass[$v]))
  3891. // {
  3892. // continue;
  3893. // }
  3894. // if(isset($pm[$typeclass[$v]['classid']]))
  3895. // {
  3896. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3897. // {
  3898. // $tz = explode('|',$typeclass[$v]['zh']);
  3899. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3900. // }
  3901. // else
  3902. // {
  3903. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3904. // }
  3905. // }
  3906. // if(isset($jm[$typeclass[$v]['classid']]))
  3907. // {
  3908. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3909. // }
  3910. // }
  3911. // }
  3912. // $jm = array_filter($jm);
  3913. // $rows[$key]['bs'] = implode("-",$jm);
  3914. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3915. // $zh = implode(" ",$pm);
  3916. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3917. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3918. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3919. // $rows[$key]['features'] = $zh;
  3920. }
  3921. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3922. $final_list = [];
  3923. foreach ($list as $k => $v) {
  3924. if (empty($v['sku'])) {
  3925. continue;
  3926. }
  3927. $final_list[] = [
  3928. "warehouse" => $v["warehouse"],
  3929. "purchase" => $v["purchase"],
  3930. "details" => $v["details"],
  3931. "cpid" => $v["cpid"],
  3932. "dbcontent" => $v["dbcontent"],
  3933. "sku" => $v["sku"],
  3934. "cs" => $v["bm"],
  3935. "bs" => $v["jm"],
  3936. "title" => $v["title"],
  3937. "features" => $v["pm"],
  3938. "cpbz" => $v["cpbz"],
  3939. "sm" => $v["sm"],
  3940. "type" => $v["type"],
  3941. "number" => $v["number"],
  3942. "c" => $v["c"],
  3943. "x" => $v["x"],
  3944. "t" => $v["t"],
  3945. "s" => $v["s"],
  3946. "q" => $v["q"],
  3947. "z" => $v["z"],
  3948. "weight" => $v['weight'],
  3949. ];
  3950. }
  3951. $title = "总进销存统计表";
  3952. $titlename = "<table border=1>
  3953. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3954. <tr align='center'>
  3955. <td>仓库</td>
  3956. <td>供应商</td>
  3957. <td>位置</td>
  3958. <td>库存编码</td>
  3959. <td>类目</td>
  3960. <td>SKU</td>
  3961. <td>用友编码</td>
  3962. <td>用友料号</td>
  3963. <td>商品名称</td>
  3964. <td>商品中文</td>
  3965. <td>产品备注</td>
  3966. <td>库位负责人</td>
  3967. <td>类型</td>
  3968. <td>入库总量</td>
  3969. <td>库存数量</td>
  3970. <td>销售数量</td>
  3971. <td>退货数量</td>
  3972. <td>删除数量</td>
  3973. <td>其它操作</td>
  3974. <td>占单数量</td>
  3975. <td>重量(g)</td>
  3976. </tr>
  3977. </table>";
  3978. $filename = $title . ".xls";
  3979. $tail = "";
  3980. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3981. }
  3982. }
  3983. //入库导出
  3984. public function _excelr()
  3985. {
  3986. if (isset($_GET['excel'])) {
  3987. $category = $this->input->get('category', true);
  3988. $size = $this->input->get('size', true);
  3989. $grade = $this->input->get('grade', true);
  3990. $color = $this->input->get('color', true);
  3991. $lowe = $this->input->get('lowe', true);
  3992. $sku = $this->input->get('sku', true);
  3993. $warehouse = $this->input->get('warehouse', true);
  3994. $purchase = $this->input->get('purchase', true);
  3995. $ktime = $this->input->get('ktime', true);
  3996. $jtime = $this->input->get('jtime', true);
  3997. $rktype = $this->input->get('rktype',true);
  3998. $ktime = strtotime($ktime);
  3999. $jtime = strtotime($jtime);
  4000. $where = "1=1";
  4001. $gj = "";
  4002. $ck = "";
  4003. if ($category) {
  4004. $where .= " and features like '%-$category-%'";
  4005. }
  4006. if ($size) {
  4007. $where .= " and features like '%-$size-%'";
  4008. }
  4009. if ($grade) {
  4010. $where .= " and features like '%-$grade-%'";
  4011. }
  4012. if ($color) {
  4013. $where .= " and features like '%-$color-%'";
  4014. }
  4015. if ($lowe) {
  4016. $where .= " and features like '%-$lowe-%'";
  4017. }
  4018. if ($warehouse) {
  4019. $where .= " and warehouse = '$warehouse'";
  4020. }
  4021. if ($purchase) {
  4022. $where .= " and purchase = '$purchase'";
  4023. }
  4024. if ($sku) {
  4025. $where .= " and sku = '$sku'";
  4026. }
  4027. if($rktype){
  4028. $where .= " and rktype = '$rktype' ";
  4029. }
  4030. if ($ktime && $jtime) {
  4031. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4032. }
  4033. //数据排序
  4034. $order_str = "id desc";
  4035. if (empty($page)) {
  4036. $start = 0;
  4037. $perpage = 1;
  4038. } else {
  4039. $start = ($page - 1) * $perpage;
  4040. }
  4041. $list = array();
  4042. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4043. $three_month = strtotime('-3 months');
  4044. $rows_d = $this->whlabelscbf->find_pc($where." and del_time > ".$three_month, 'enter,sku,warehouse', '*', $order_str);
  4045. $rows_d = array_map(function ($item) {
  4046. unset($item['del_time']); // 删除 age 字段
  4047. return $item;
  4048. }, $rows_d);
  4049. $rows = array_merge($rows, $rows_d);
  4050. foreach ($rows as $value) {
  4051. $ck = $this->warehouse->read($value['warehouse']);
  4052. $warehouse = $ck['title'];
  4053. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4054. $retreatwarehouse = $tkck['title'];
  4055. $gy = $this->purchase->read($value['purchase']);
  4056. $purchase = $gy['title'];
  4057. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4058. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4059. }
  4060. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4061. $titlename = "<table border=1>
  4062. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4063. <tr align='center'>
  4064. <td>仓库</td>
  4065. <td>SKU</td>
  4066. <td>产品</td>
  4067. <td>时间</td>
  4068. <td>数量</td>
  4069. </tr>
  4070. </table>";
  4071. $filename = $title . ".xls";
  4072. $tail = "";
  4073. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4074. }
  4075. }
  4076. //出库、退库导出
  4077. public function _excelct()
  4078. {
  4079. $classid = $this->classid->sku();
  4080. $pm = $classid;
  4081. $typeclass = array();
  4082. $tc = $this->typeclass->find_all();
  4083. foreach ($tc as $v) {
  4084. $typeclass[$v['id']] = $v;
  4085. }
  4086. $prc = array();
  4087. $purchase = $this->purchase->find_all();
  4088. foreach ($purchase as $k => $v) {
  4089. $prc[$v['id']] = $v['title'];
  4090. }
  4091. if (isset($_GET['excel'])) {
  4092. $wh = array();
  4093. $w = $this->warehouse->find_all('1=1', 'id,title');
  4094. foreach ($w as $v) {
  4095. $wh[$v['id']] = $v['title'];
  4096. }
  4097. $type = $this->input->get('excel', true);
  4098. $category = $this->input->get('category', true);
  4099. $size = $this->input->get('size', true);
  4100. $grade = $this->input->get('grade', true);
  4101. $color = $this->input->get('color', true);
  4102. $lowe = $this->input->get('lowe', true);
  4103. $sku = $this->input->get('sku', true);
  4104. $title = $this->input->get('title', true);
  4105. $warehouse = $this->input->get('warehouse', true);
  4106. $purchase = $this->input->get('purchase', true);
  4107. $lacetype = $this->input->get('lacetype', true);
  4108. $haircap = $this->input->get('haircap', true);
  4109. $lacecolor = $this->input->get('lacecolor', true);
  4110. $density = $this->input->get('density', true);
  4111. $details = $this->input->get('details', true);
  4112. $state = $this->input->get('state', true);
  4113. $shop = $this->input->get('shop', true);
  4114. $hairnumber = $this->input->get('hairnumber', true);
  4115. $type_leixi = $this->input->get('type', true);
  4116. $cpbz = $this->input->get('cpbz', true);
  4117. $sm = $this->input->get('sm', true);
  4118. $sid = $this->input->get('sid', true);
  4119. $ktime = $this->input->get('ktime', true);
  4120. $jtime = $this->input->get('jtime', true);
  4121. $ktime = strtotime($ktime);
  4122. $jtime = strtotime($jtime);
  4123. //$where = " 1=1 ";
  4124. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4125. $where = " sku != '' ";
  4126. $gj = "";
  4127. $ck = "";
  4128. if ($category) {
  4129. $where .= " and features like '%-$category-%'";
  4130. }
  4131. if ($size) {
  4132. $where .= " and features like '%-$size-%'";
  4133. }
  4134. if ($grade) {
  4135. $where .= " and features like '%-$grade-%'";
  4136. }
  4137. if ($color) {
  4138. $where .= " and features like '%-$color-%'";
  4139. }
  4140. if ($lowe) {
  4141. $where .= " and features like '%-$lowe-%'";
  4142. }
  4143. if ($warehouse) {
  4144. $where .= " and warehouse = '$warehouse'";
  4145. }
  4146. if ($purchase) {
  4147. $where .= " and purchase = '$purchase'";
  4148. }
  4149. if ($state) {
  4150. $where .= " and state = '$state'";
  4151. }
  4152. if ($lacetype) {
  4153. $where .= " and features like '%-$lacetype-%'";
  4154. }
  4155. if ($lacecolor) {
  4156. $where .= " and features like '%-$lacecolor-%'";
  4157. }
  4158. if ($density) {
  4159. $where .= " and features like '%-$density-%'";
  4160. }
  4161. if ($haircap) {
  4162. $where .= " and features like '%-$haircap-%'";
  4163. }
  4164. if ($details) {
  4165. $where .= " and details = '$details'";
  4166. }
  4167. if ($shop) {
  4168. $where .= " and shop like '%$shop%'";
  4169. }
  4170. if ($title) {
  4171. $title = trim($title, ' ');
  4172. $title = trim($title, ' ');
  4173. $where .= " and title like '%$title%'";
  4174. }
  4175. if (!empty($hairnumber)) {
  4176. $where .= " and features like '%-128-%' ";
  4177. if ($hairnumber < 0) {
  4178. $class_list = $this->typeclass->find_all('classid = 43');
  4179. foreach ($class_list as $v) {
  4180. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4181. }
  4182. } else {
  4183. $where .= " and features like '%-$hairnumber-%'";
  4184. }
  4185. }
  4186. if ($type_leixi) {
  4187. $where .= " and type = '$type_leixi'";
  4188. }
  4189. if ($cpbz) {
  4190. $where .= " and cpbz like '%$cpbz%' ";
  4191. }
  4192. if ($sm) {
  4193. $where .= " and sm like '%$sm%' ";
  4194. }
  4195. if ($sku) {
  4196. $sku = trim($sku, ' ');
  4197. $sku = trim($sku, ' ');
  4198. $where .= " and sku like '%$sku%'";
  4199. }
  4200. if ($ktime && $jtime) {
  4201. if ($type == 1) {
  4202. $tl = '出库';
  4203. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4204. } else if ($type == 2) {
  4205. $tl = '退库';
  4206. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4207. } else if ($type == 3) {
  4208. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4209. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4210. } else if ($type == 4) {
  4211. $tl = '出库+零售';
  4212. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4213. } else if ($type == 5) {
  4214. $tl = '零售';
  4215. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4216. }
  4217. }
  4218. $sidwhere = '';
  4219. if ($sid) {
  4220. $sd = "";
  4221. $s = explode(',', trim($sid, ','));
  4222. foreach ($s as $value) {
  4223. $sd .= " id = " . $value . " or";
  4224. }
  4225. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4226. }
  4227. //数据排序
  4228. $order_str = "time desc";
  4229. if (empty($page)) {
  4230. $start = 0;
  4231. $perpage = 1;
  4232. } else {
  4233. $start = ($page - 1) * $perpage;
  4234. }
  4235. //取得信息列表
  4236. if ($type != 3 && $type != 5) {
  4237. if ($type == 1 || $type == 4) {
  4238. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4239. foreach ($info_list as $key => $value) {
  4240. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4241. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4242. $warehouse = $this->warehouse->read($value['warehouse']);
  4243. $info_list[$key]['warehouse'] = $warehouse['title'];
  4244. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4245. $features = explode('-', trim($features, '-'));
  4246. $pm = $classid;
  4247. foreach ($features as $k => $v) {
  4248. if ($v != 0) {
  4249. if (!isset($typeclass[$v])) {
  4250. continue;
  4251. }
  4252. if (isset($pm[$typeclass[$v]['classid']])) {
  4253. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4254. $tz = explode('|', $typeclass[$v]['zh']);
  4255. $pm[$typeclass[$v]['classid']] = $tz[0];
  4256. } else {
  4257. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4258. }
  4259. }
  4260. }
  4261. }
  4262. $zh = implode(" ", $pm);
  4263. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4264. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4265. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4266. $info_list[$key]['features'] = $zh;
  4267. }
  4268. $final_list = [];
  4269. foreach($info_list as $k=>$v){
  4270. $number = "";
  4271. if(!empty($v['orderinfo'])){
  4272. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4273. if(!empty($tmp_info['number'])){
  4274. $number = $tmp_info['number'];
  4275. }
  4276. }
  4277. $final_list[] = [
  4278. 'warehouse'=>$v['warehouse'],
  4279. 'purchase'=>$v['purchase'],
  4280. 'sku'=>$v['sku'],
  4281. 'title'=>$v['title'],
  4282. 'features'=>$v['features'],
  4283. 'label'=>$v['label'],
  4284. 'orderinfo'=>$v['orderinfo'],
  4285. 'number'=>$number,
  4286. 'waybill'=>$v['waybill'],
  4287. 'outk'=>$v['outk'],
  4288. ];
  4289. }
  4290. } else {
  4291. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4292. foreach ($info_list as $key => $value) {
  4293. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4294. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4295. $warehouse = $this->warehouse->read($value['warehouse']);
  4296. $info_list[$key]['warehouse'] = $warehouse['title'];
  4297. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4298. $features = explode('-', trim($features, '-'));
  4299. $pm = $classid;
  4300. foreach ($features as $k => $v) {
  4301. if ($v != 0) {
  4302. if (!isset($typeclass[$v])) {
  4303. continue;
  4304. }
  4305. if (isset($pm[$typeclass[$v]['classid']])) {
  4306. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4307. $tz = explode('|', $typeclass[$v]['zh']);
  4308. $pm[$typeclass[$v]['classid']] = $tz[0];
  4309. } else {
  4310. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4311. }
  4312. }
  4313. }
  4314. }
  4315. $zh = implode(" ", $pm);
  4316. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4317. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4318. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4319. $info_list[$key]['features'] = $zh;
  4320. }
  4321. $final_list = [];
  4322. foreach($info_list as $k=>$v){
  4323. $number = "";
  4324. if(!empty($v['orderinfo'])){
  4325. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4326. if(!empty($tmp_info['number'])){
  4327. $number = $tmp_info['number'];
  4328. }
  4329. }
  4330. $final_list[] = [
  4331. 'warehouse'=>$v['warehouse'],
  4332. 'purchase'=>$v['purchase'],
  4333. 'sku'=>$v['sku'],
  4334. 'title'=>$v['title'],
  4335. 'features'=>$v['features'],
  4336. 'label'=>$v['label'],
  4337. 'orderinfo'=>$v['orderinfo'],
  4338. 'number'=>$number,
  4339. 'waybill'=>$v['waybill'],
  4340. 'retreat'=>$v['retreat'],
  4341. ];
  4342. }
  4343. }
  4344. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4345. $titlename = "<table border=1>
  4346. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4347. <tr align='center'>
  4348. <td>仓库</td>
  4349. <td>供应商</td>
  4350. <td>SKU</td>
  4351. <td>商品名称</td>
  4352. <td>商品中文</td>
  4353. <td>标签</td>
  4354. <td>订单号</td>
  4355. <td>订单编码</td>
  4356. <td>运单号</td>
  4357. <td>" . $tl . "时间(中国时间)</td>
  4358. </tr>
  4359. </table>";
  4360. $filename = $title . ".xls";
  4361. $tail = "";
  4362. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4363. } else if ($type == 5) {
  4364. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4365. foreach ($info_list as $key => $value) {
  4366. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4367. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4368. $warehouse = $this->warehouse->read($value['warehouse']);
  4369. $info_list[$key]['warehouse'] = $warehouse['title'];
  4370. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4371. $features = explode('-', trim($features, '-'));
  4372. $pm = $classid;
  4373. foreach ($features as $k => $v) {
  4374. if ($v != 0) {
  4375. if (!isset($typeclass[$v])) {
  4376. continue;
  4377. }
  4378. if (isset($pm[$typeclass[$v]['classid']])) {
  4379. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4380. $tz = explode('|', $typeclass[$v]['zh']);
  4381. $pm[$typeclass[$v]['classid']] = $tz[0];
  4382. } else {
  4383. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4384. }
  4385. }
  4386. }
  4387. }
  4388. $zh = implode(" ", $pm);
  4389. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4390. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4391. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4392. $info_list[$key]['features'] = $zh;
  4393. }
  4394. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4395. $titlename = "<table border=1>
  4396. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4397. <tr align='center'>
  4398. <td>仓库</td>
  4399. <td>供应商</td>
  4400. <td>SKU</td>
  4401. <td>商品名称</td>
  4402. <td>商品中文</td>
  4403. <td>标签</td>
  4404. <td>" . $tl . "时间(中国时间)</td>
  4405. </tr>
  4406. </table>";
  4407. $filename = $title . ".xls";
  4408. $tail = "";
  4409. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4410. } else {
  4411. /**
  4412. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4413. $rows = array();$list = array();
  4414. foreach ($info_list as $key=>$value)
  4415. {
  4416. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4417. }
  4418. **/
  4419. $wh = array();
  4420. $w = $this->warehouse->find_all('1=1', 'id,title');
  4421. foreach ($w as $v) {
  4422. $wh[$v['id']] = $v['title'];
  4423. }
  4424. $wt = array();
  4425. $whlabel_type = $this->whlabel_type->find_all();
  4426. foreach ($whlabel_type as $v) {
  4427. $wt[$v['id']] = $v['title'];
  4428. }
  4429. $classid = $this->classid->sku();
  4430. $list = array();
  4431. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4432. foreach ($rows as $key => $value) {
  4433. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4434. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4435. $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');
  4436. $details = array();
  4437. $cpid = array();
  4438. $cpbz = array();
  4439. $c = 0;
  4440. $g = 0;
  4441. $x = 0;
  4442. $t = 0;
  4443. $s = 0;
  4444. $q = 0;
  4445. foreach ($sd as $k => $v) {
  4446. if ($v['state'] == 0) {
  4447. $c++;
  4448. }
  4449. if ($v['state'] != 9) {
  4450. $g++;
  4451. }
  4452. if ($v['outk'] > 1) {
  4453. $x++;
  4454. }
  4455. if ($v['retreat'] > 0) {
  4456. $t++;
  4457. }
  4458. if ($v['state'] == 8) {
  4459. $s++;
  4460. }
  4461. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4462. $q++;
  4463. }
  4464. $details[$v['details']] = $v['details'];
  4465. if($v['state'] == 0){
  4466. if ($v['cpid'] != 0) {
  4467. $cpid[$v['cpid']] = $v['cpid'];
  4468. }
  4469. if ($v['cpbz'] != '') {
  4470. $cpbz[$v['cpbz']] = $v['cpbz'];
  4471. }
  4472. }
  4473. }
  4474. if (isset($wt[$value['type']])) {
  4475. $rows[$key]['type'] = $wt[$value['type']];
  4476. } else {
  4477. $rows[$key]['type'] = '未设置';
  4478. }
  4479. $rows[$key]['details'] = implode("、", $details);
  4480. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4481. $ftime = time() - 15 * 24 * 3600;
  4482. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4483. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4484. $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);
  4485. $rows[$key]['c'] = $c;
  4486. $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);
  4487. $rows[$key]['t'] = $t;
  4488. $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'] . '"');
  4489. $rows[$key]['z'] = $z;
  4490. // $jm = $classid;
  4491. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4492. $features = explode('-', trim($features, '-'));
  4493. // $pm = $classid;
  4494. // foreach ($features as $k => $v) {
  4495. // if ($v != 0) {
  4496. // if (!isset($typeclass[$v])) {
  4497. // continue;
  4498. // }
  4499. // if (isset($pm[$typeclass[$v]['classid']])) {
  4500. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4501. // $tz = explode('|', $typeclass[$v]['zh']);
  4502. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4503. // } else {
  4504. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4505. // }
  4506. // if (isset($jm[$typeclass[$v]['classid']])) {
  4507. // if ($typeclass[$v]['jm']) {
  4508. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4509. // }
  4510. // }
  4511. // }
  4512. // }
  4513. // }
  4514. // $zh = implode(" ", $pm);
  4515. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4516. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4517. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4518. // $rows[$key]['features'] = $zh;
  4519. // $jm = array_filter($jm); //去除空值
  4520. // $jm = implode("-", $jm);
  4521. // $rows[$key]['jm'] = $jm;
  4522. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4523. }
  4524. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4525. // echo "<pre>";
  4526. // print_r($tmp_list);
  4527. // die;
  4528. $final_list =[];
  4529. foreach($tmp_list as $k=>$v){
  4530. $final_list[] = [
  4531. "warehouse"=>$v['warehouse'],
  4532. "purchase"=>$v['purchase'],
  4533. "details"=>trim($v['details'],'、'),
  4534. "cpid"=>$v['cpid'],
  4535. "sku"=>$v['sku'],
  4536. "title"=>$v['title'],
  4537. "features"=>$v['pm'],
  4538. "cpbz"=>$v['cpbz'],
  4539. "sm"=>$v['sm'],
  4540. "type"=>$v['type'],
  4541. "g"=>$v["g"],
  4542. "c"=>$v["c"],
  4543. "x"=>$v["x"],
  4544. "t"=>$v["t"],
  4545. "z"=>$v["z"],
  4546. "jm"=>$v["jm"],
  4547. "weight"=>$v["weight"],
  4548. "asd"=>$v["asd"],
  4549. ];
  4550. }
  4551. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4552. $titlename = "<table border=1>
  4553. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4554. <tr align='center'>
  4555. <td>仓库</td>
  4556. <td>供应商</td>
  4557. <td>位置</td>
  4558. <td>库存编码</td>
  4559. <td>SKU</td>
  4560. <td>商品名称</td>
  4561. <td>商品中文</td>
  4562. <td>产品备注</td>
  4563. <td>说明</td>
  4564. <td>类型</td>
  4565. <td>入库总量</td>
  4566. <td>库存数量</td>
  4567. <td>销售数量</td>
  4568. <td>退货数量</td>
  4569. <td>占单数量</td>
  4570. <td>料号</td>
  4571. <td>重量</td>
  4572. <td>类目</td>
  4573. </tr>
  4574. </table>";
  4575. $filename = $title . ".xls";
  4576. $tail = "";
  4577. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4578. }
  4579. }
  4580. }
  4581. //出库+入库数据整合
  4582. public function _excelcr()
  4583. {
  4584. if (isset($_GET['excel'])) {
  4585. $type = $this->input->get('excel', true);
  4586. $category = $this->input->get('category', true);
  4587. $size = $this->input->get('size', true);
  4588. $grade = $this->input->get('grade', true);
  4589. $color = $this->input->get('color', true);
  4590. $lowe = $this->input->get('lowe', true);
  4591. $sku = $this->input->get('sku', true);
  4592. $warehouse = $this->input->get('warehouse', true);
  4593. $purchase = $this->input->get('purchase', true);
  4594. $state = $this->input->get('state', true);
  4595. $sid = $this->input->get('sid', true);
  4596. $ktime = $this->input->get('ktime', true);
  4597. $jtime = $this->input->get('jtime', true);
  4598. $ktime = strtotime($ktime);
  4599. $jtime = strtotime($jtime);
  4600. $where = "1=1";
  4601. $gj = "";
  4602. $ck = "";
  4603. if ($category) {
  4604. $where .= " and features like '%-$category-%'";
  4605. }
  4606. if ($size) {
  4607. $where .= " and features like '%-$size-%'";
  4608. }
  4609. if ($grade) {
  4610. $where .= " and features like '%-$grade-%'";
  4611. }
  4612. if ($color) {
  4613. $where .= " and features like '%-$color-%'";
  4614. }
  4615. if ($lowe) {
  4616. $where .= " and features like '%-$lowe-%'";
  4617. }
  4618. if ($warehouse) {
  4619. $where .= " and warehouse = '$warehouse'";
  4620. }
  4621. if ($purchase) {
  4622. $where .= " and purchase = '$purchase'";
  4623. }
  4624. if ($state) {
  4625. $where .= " and state = '$state'";
  4626. }
  4627. if ($sku) {
  4628. $where .= " and sku like '%$sku%'";
  4629. }
  4630. if ($ktime && $jtime) {
  4631. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4632. }
  4633. $sidwhere = '';
  4634. if ($sid) {
  4635. $sd = "";
  4636. $s = explode(',', trim($sid, ','));
  4637. foreach ($s as $value) {
  4638. $sd .= " id = " . $value . " or";
  4639. }
  4640. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4641. }
  4642. //取得信息列表
  4643. $timeread = $ktime;
  4644. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4645. $timelist = array();
  4646. for ($i = 0; $i < $timenum; $i++) {
  4647. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4648. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4649. }
  4650. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4651. //echo "<pre>";
  4652. //print_r($info_list);
  4653. //exit();
  4654. $rows = array();
  4655. $list = array();
  4656. foreach ($info_list as $key => $value) {
  4657. $thistime = $timelist;
  4658. if (isset($rows[strtolower($value['sku'])])) {
  4659. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4660. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4661. }
  4662. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4663. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4664. }
  4665. } else {
  4666. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4667. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4668. }
  4669. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4670. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4671. }
  4672. $rows[strtolower($value['sku'])] = $thistime;
  4673. }
  4674. }
  4675. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4676. <head>
  4677. <!--[if gte mso 9]><xml>
  4678. <x:ExcelWorkbook>
  4679. <x:ExcelWorksheets>
  4680. <x:ExcelWorksheet>
  4681. <x:Name>EXCEL</x:Name>
  4682. <x:WorksheetOptions>
  4683. <x:Print>
  4684. <x:ValidPrinterInfo />
  4685. </x:Print>
  4686. </x:WorksheetOptions>
  4687. </x:ExcelWorksheet>
  4688. </x:ExcelWorksheets>
  4689. </x:ExcelWorkbook>
  4690. </xml>
  4691. <![endif]-->
  4692. </head><body>";
  4693. $str .= "<table border=1><tr><td>SKU</td>";
  4694. foreach ($timelist as $k => $v) {
  4695. $str .= "<td>" . $k . "出库</td>";
  4696. $str .= "<td>" . $k . "入库</td>";
  4697. }
  4698. $str .= "</tr></table>";
  4699. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4700. foreach ($rows as $key => $val) {
  4701. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4702. foreach ($val as $k => $v) {
  4703. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4704. if ($val[$k]['r'] > 0) {
  4705. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4706. } else {
  4707. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4708. }
  4709. }
  4710. $str .= "</tr>";
  4711. }
  4712. $str .= "</table>";
  4713. $str .= "</body></html>";
  4714. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4715. header("Content-type: application/octet-stream");
  4716. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4717. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4718. header("Pragma: no-cache");
  4719. header("Expires: 0");
  4720. exit($str);
  4721. }
  4722. }
  4723. //数量调整模板导出
  4724. public function _presetout()
  4725. {
  4726. if (isset($_GET['excel'])) {
  4727. $where = "sku != 'Preset' and purchase != 0";
  4728. //数据排序
  4729. $order_str = "id desc";
  4730. if (empty($page)) {
  4731. $start = 0;
  4732. $perpage = 1;
  4733. } else {
  4734. $start = ($page - 1) * $perpage;
  4735. }
  4736. //取得信息列表
  4737. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4738. $rows = array();
  4739. $list = array();
  4740. foreach ($info_list as $value) {
  4741. $warehouse = $this->warehouse->read($value['warehouse']);
  4742. $number = $value['number'];
  4743. $ftime = time() - 15 * 24 * 3600;
  4744. $purchase = $this->purchase->read($value['purchase']);
  4745. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4746. }
  4747. $title = "库存模板";
  4748. $titlename = "<table border=1>
  4749. <tr align='center'>
  4750. <td>仓库</td>
  4751. <td>供应商编码</td>
  4752. <td>SKU</td>
  4753. <td>增减数量(正数或负数)</td>
  4754. <td>增减备注</td>
  4755. <td>库位</td>
  4756. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4757. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4758. </tr>
  4759. </table>";
  4760. $filename = $title . ".xls";
  4761. $tail = "";
  4762. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4763. }
  4764. }
  4765. //数量调整模板导入
  4766. public function _presetedit()
  4767. {
  4768. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4769. $config['upload_path'] = '.' . $dir;
  4770. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4771. $config['allowed_types'] = 'xls|xlsx|csv';
  4772. $config['max_size'] = 10240;
  4773. $this->load->library('upload', $config);
  4774. $this->upload->initialize($config);
  4775. if ($this->upload->do_upload('userfile')) {
  4776. $full_path = $dir . $this->upload->data('file_name');
  4777. $fileName = '.' . $full_path;
  4778. if (!file_exists($fileName)) {
  4779. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4780. exit;
  4781. } else {
  4782. require_once "./data/excel/PHPExcel/IOFactory.php";
  4783. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4784. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4785. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4786. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4787. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4788. ++$column; //如果列数大于26行
  4789. $list = array();
  4790. for ($i = 2; $i <= $row; $i++) // 行数循环
  4791. {
  4792. $data = array();
  4793. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4794. {
  4795. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4796. }
  4797. $list[] = $data;
  4798. }
  4799. }
  4800. $i = 0;
  4801. $j = 0;
  4802. $ed = array();
  4803. foreach ($list as $key => $value) {
  4804. $time = time();
  4805. if ($value['0'] == "") {
  4806. continue;
  4807. }
  4808. $warehouse = $this->warehouse->get_title($value['0']);
  4809. $purchase = $this->purchase->get_bm($value['1']);
  4810. $sku = $value['2'];
  4811. $num = $value['3']; //调整数量
  4812. $text = $value['4']; //扣减说明
  4813. $type = $value['5']; //调整方式0扣减1删除
  4814. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4815. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4816. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4817. if (!$purchase) //如果没有这个SKU
  4818. {
  4819. $ed[] = array($purchase . '-不存在此供应商编码');
  4820. $j++;
  4821. continue;
  4822. }
  4823. if (!$d) //如果没有这个SKU
  4824. {
  4825. $ed[] = array($sku . '-库存中不存在此SKU');
  4826. $j++;
  4827. continue;
  4828. }
  4829. if (!isset($warehouse['id'])) {
  4830. $ed[] = array($sku . '-仓库名错误!');
  4831. $j++;
  4832. continue;
  4833. }
  4834. if ($type != '0' && $type != '1') {
  4835. $ed[] = array($sku . '-扣减方式填写错误!');
  4836. $j++;
  4837. continue;
  4838. }
  4839. if ($num < 0) //扣减库存
  4840. {
  4841. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4842. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4843. $j++;
  4844. continue;
  4845. }
  4846. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4847. if (count($data) < abs($num)) {
  4848. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4849. $j++;
  4850. continue;
  4851. }
  4852. if ($type == 0) //如果扣减方式为 扣减库存
  4853. {
  4854. for ($i = 0; $i < abs($num); $i++) {
  4855. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4856. }
  4857. } else if ($type == 1) {
  4858. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4859. if (count($zt) > 0) {
  4860. $ed[] = array($sku . '-有在途库存无法删除!');
  4861. $j++;
  4862. continue;
  4863. }
  4864. for ($i = 0; $i < abs($num); $i++) {
  4865. $this->whlabel->remove($data[$i]['id']);
  4866. }
  4867. }
  4868. } else if ($num > 0) //增加库存
  4869. {
  4870. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4871. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4872. $j++;
  4873. continue;
  4874. }
  4875. $post['sku'] = $d['sku'];
  4876. $post['shop'] = $d['shop'];
  4877. $post['warehouse'] = $warehouse['id'];
  4878. $post['purchase'] = $purchase['id'];
  4879. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4880. $post['state'] = 0;
  4881. $post['title'] = $d['title'];
  4882. $post['number'] = $d['number'];
  4883. $post['features'] = $d['features'];
  4884. $post['enter'] = $time;
  4885. $post['time'] = $time; //操作时间
  4886. $post['rktype'] = $rktype;
  4887. for ($i = 0; $i < $num; $i++) {
  4888. $post['label'] = time() . rand(100, 999) . $i;
  4889. $this->whlabel->insert($post);
  4890. }
  4891. }
  4892. sleep(1); //防止入库时间一样,需要延迟1秒
  4893. }
  4894. if ($j > 0) {
  4895. $tt = date('Ymd', time());
  4896. $title = '库存导入错误信息-' . $tt;
  4897. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4898. $tail = "\n";
  4899. $filename = $title . ".xls";
  4900. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4901. $dir = '/data/excel/' . $time . '/';
  4902. $file_name = 'error_' . $time . rand(1000, 9999);
  4903. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4904. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4905. fwrite($myfile, $ecl);
  4906. fclose($myfile);
  4907. $error = $dir . $file_name . '.xls';
  4908. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4909. exit;
  4910. } else {
  4911. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4912. exit;
  4913. }
  4914. }
  4915. }
  4916. public function _presetedittwo(){
  4917. $data = $this->input->post(NULL, TRUE);
  4918. if(empty($list)){
  4919. $raw_data = $this->input->raw_input_stream;
  4920. // 解码 JSON
  4921. $data = json_decode($raw_data, true);
  4922. }
  4923. if(empty($data)){
  4924. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4925. exit;
  4926. }
  4927. $list = [];
  4928. if(isset($data['list'])){
  4929. $list = $data['list'];
  4930. }
  4931. $i = 0;
  4932. $j = 0;
  4933. $ed = array();
  4934. foreach ($list as $key => $value) {
  4935. $time = time();
  4936. if ($value['0'] == "") {
  4937. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4938. $j++;
  4939. continue;
  4940. }
  4941. $warehouse = $this->warehouse->get_title($value['0']);
  4942. if(empty($warehouse)){
  4943. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4944. $j++;
  4945. continue;
  4946. }
  4947. $purchase = $this->purchase->get_bm($value['1']);
  4948. $sku = $value['2'];
  4949. $num = $value['3']; //调整数量
  4950. $text = $value['4']; //扣减说明
  4951. $type = 0; //调整方式0扣减1删除
  4952. $details = empty($value['5'])?'':$value['5']; //库位
  4953. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4954. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4955. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4956. if (!$purchase) //如果没有这个SKU
  4957. {
  4958. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4959. $j++;
  4960. continue;
  4961. }
  4962. if (!$d) //如果没有这个SKU
  4963. {
  4964. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4965. $j++;
  4966. continue;
  4967. }
  4968. if (!isset($warehouse['id'])) {
  4969. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4970. $j++;
  4971. continue;
  4972. }
  4973. if ($type != '0' && $type != '1') {
  4974. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4975. $j++;
  4976. continue;
  4977. }
  4978. if ($num < 0) //扣减库存
  4979. {
  4980. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4981. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4982. $j++;
  4983. continue;
  4984. }
  4985. if(!empty($details)){
  4986. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  4987. }else{
  4988. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  4989. }
  4990. if (count($data) < abs($num)) {
  4991. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  4992. $j++;
  4993. continue;
  4994. }
  4995. if ($type == 0) //如果扣减方式为 扣减库存
  4996. {
  4997. for ($i = 0; $i < abs($num); $i++) {
  4998. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4999. }
  5000. } else if ($type == 1) {
  5001. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  5002. if (count($zt) > 0) {
  5003. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  5004. $j++;
  5005. continue;
  5006. }
  5007. for ($i = 0; $i < abs($num); $i++) {
  5008. $this->whlabel->remove($data[$i]['id']);
  5009. }
  5010. }
  5011. } else if ($num > 0) //增加库存
  5012. {
  5013. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5014. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5015. $j++;
  5016. continue;
  5017. }
  5018. if(empty($details)){
  5019. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5020. if(empty($tmp_info)){
  5021. $details = '';
  5022. }else{
  5023. $details = $tmp_info['details'];
  5024. }
  5025. }else{
  5026. if($details == 'DZ001'){
  5027. }else{
  5028. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5029. if(empty($tmp_info)){
  5030. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5031. $j++;
  5032. continue;
  5033. }
  5034. }
  5035. }
  5036. $post['sku'] = $d['sku'];
  5037. $post['shop'] = $d['shop'];
  5038. $post['warehouse'] = $warehouse['id'];
  5039. $post['purchase'] = $purchase['id'];
  5040. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5041. $post['state'] = 0;
  5042. $post['title'] = $d['title'];
  5043. $post['number'] = $d['number'];
  5044. $post['features'] = $d['features'];
  5045. $post['details'] = $details;
  5046. $post['enter'] = $time;
  5047. $post['time'] = $time; //操作时间
  5048. $post['rktype'] = $rktype;
  5049. $post['sku_master_id'] = $d['sku_master_id'];
  5050. $post['sku_shop_id'] = $d['sku_shop_id'];
  5051. for ($i = 0; $i < $num; $i++) {
  5052. $post['label'] = time() . rand(100, 999) . $i;
  5053. $this->whlabel->insert($post);
  5054. }
  5055. }
  5056. sleep(1); //防止入库时间一样,需要延迟1秒
  5057. }
  5058. if ($j > 0) {
  5059. $tt = date('Ymd', time());
  5060. $title = '库存导入错误信息-' . $tt;
  5061. $error = $title . '.xls';
  5062. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5063. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5064. exit;
  5065. } else {
  5066. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5067. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5068. exit;
  5069. }
  5070. }
  5071. //笛卡儿积
  5072. function cp($ps, $sets, $list)
  5073. {
  5074. $result = array();
  5075. $j = 0;
  5076. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5077. if ($i == 0) {
  5078. $result = $sets[$i];
  5079. }
  5080. $tmp = array();
  5081. foreach ($result as $res) {
  5082. foreach ($sets[$i + 1] as $set) {
  5083. $tmp[] = $res . ',' . $set;
  5084. }
  5085. }
  5086. $result = $tmp;
  5087. }
  5088. $this->db->trans_begin();
  5089. foreach ($result as $v) {
  5090. $post = array();
  5091. $title = "";
  5092. $num = "";
  5093. $data = explode(',', $v);
  5094. for ($i = 0; $i < count($list); $i++) {
  5095. $post[$list[$i]] = $data[$i];
  5096. $typeclass = $this->typeclass->read($data[$i]);
  5097. $title = $title . $typeclass['title'] . " ";
  5098. if ($data[$i] != 0) {
  5099. $num .= $data[$i]; //所有数据ID拼接
  5100. }
  5101. }
  5102. foreach ($ps as $kp => $vp) {
  5103. $post[$kp] = $vp;
  5104. }
  5105. $post['number'] = $num;
  5106. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5107. if ($info_list) {
  5108. $j++;
  5109. } else {
  5110. $skunum = $this->whlabel->find_count();
  5111. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5112. $post['title'] = rtrim($title, ' ');
  5113. $this->whlabel->insert($post);
  5114. }
  5115. }
  5116. if ($this->db->trans_status() === FALSE) {
  5117. $this->db->trans_commit();
  5118. return NULL;
  5119. } else {
  5120. $this->db->trans_commit();
  5121. return $j;
  5122. }
  5123. }
  5124. public function _kj($arg_array)
  5125. {
  5126. if (isset($_POST['sku'])) {
  5127. $time = time();
  5128. $sku = $this->input->post('sku', true);
  5129. $warehouse = $this->input->post('warehouse', true);
  5130. $num = $this->input->post('num', true);
  5131. $text = $this->input->post('text', true);
  5132. $purchase = $this->input->post('purchase', true);
  5133. $cktype = $this->input->post('cktype', true);
  5134. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5135. if ($cktype != 1 && $text == '') {
  5136. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5137. exit;
  5138. }
  5139. if ($num > count($order)) {
  5140. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5141. exit;
  5142. } else {
  5143. for ($i = 0; $i < $num; $i++) {
  5144. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5145. }
  5146. }
  5147. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5148. exit;
  5149. }
  5150. $uid = $this->whlabel->read($arg_array[0]);
  5151. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5152. $this->data['data'] = $uid;
  5153. $this->_Template('whlabel_kj', $this->data);
  5154. }
  5155. public function _summary($arg_array)
  5156. {
  5157. $prc = array();
  5158. $purchase = $this->purchase->find_all();
  5159. foreach ($purchase as $k => $v) {
  5160. $prc[$v['id']] = $v['title'];
  5161. }
  5162. if (isset($_GET['excel'])) {
  5163. $ktime = $this->input->get('ktime', true);
  5164. $jtime = $this->input->get('jtime', true);
  5165. $ktime = strtotime($ktime);
  5166. $jtime = strtotime($jtime);
  5167. $where = "1=1";
  5168. if ($ktime && $jtime) {
  5169. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5170. }
  5171. //数据排序
  5172. $order_str = "time desc";
  5173. if (empty($page)) {
  5174. $start = 0;
  5175. $perpage = 1;
  5176. } else {
  5177. $start = ($page - 1) * $perpage;
  5178. }
  5179. //取得信息列表
  5180. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5181. foreach ($info_list as $key => $value) {
  5182. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5183. $warehouse = $this->warehouse->read($value['warehouse']);
  5184. $info_list[$key]['warehouse'] = $warehouse['title'];
  5185. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid,status');
  5186. $details = array();
  5187. $cpid = array();
  5188. foreach ($x as $k => $v) {
  5189. if($v['status'] == 0){
  5190. if ($v['details'] != '') {
  5191. $details[$v['details']] = $v['details'];
  5192. }
  5193. if ($v['cpid'] != 0) {
  5194. $cpid[$v['cpid']] = $v['cpid'];
  5195. }
  5196. }
  5197. }
  5198. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5199. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5200. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5201. $info_list[$key]['s'] = $s;
  5202. $info_list[$key]['x'] = count($x);
  5203. }
  5204. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5205. $titlename = "<table border=1>
  5206. <tr align='center'>
  5207. <td>仓库</td>
  5208. <td>供应商</td>
  5209. <td>出库位置</td>
  5210. <td>出库编码</td>
  5211. <td>SKU</td>
  5212. <td>产品名</td>
  5213. <td>总剩余库存</td>
  5214. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5215. </tr>
  5216. </table>";
  5217. $filename = $title . ".xls";
  5218. $tail = "";
  5219. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5220. }
  5221. }
  5222. //usps发货清单
  5223. public function _manifest()
  5224. {
  5225. if (isset($_POST['manifest'])) {
  5226. $wltext = $this->input->post('wltext', true);
  5227. $time = time() - 16 * 3600;
  5228. $ptime = strtotime(date('Y-m-d', $time));
  5229. $waybill = array();
  5230. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5231. foreach ($fullorder as $v) {
  5232. $waybill[$v['waybill']] = $v['waybill'];
  5233. }
  5234. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5235. foreach ($fullordersmt as $v) {
  5236. $waybill[$v['waybill']] = $v['waybill'];
  5237. }
  5238. $wltext = explode(';', $wltext);
  5239. foreach ($wltext as $v) {
  5240. if (isset($waybill[$v])) {
  5241. unset($waybill[$v]);
  5242. }
  5243. }
  5244. $data = $this->usps->get_manifest($waybill);
  5245. if (isset($data['Description'])) {
  5246. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5247. exit;
  5248. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5249. $bctime = date('Ymd', time());
  5250. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5251. echo json_encode(array('msg' => $pdf, 'success' => true));
  5252. exit;
  5253. } else {
  5254. echo json_encode(array('msg' => $data, 'success' => false));
  5255. exit;
  5256. }
  5257. }
  5258. }
  5259. public function _pdf($pdf, $title, $bctime)
  5260. {
  5261. $pdf_path = './data/pdf/' . $bctime . '/';
  5262. $file_base64 = $pdf;
  5263. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5264. $file_base64 = base64_decode($file_base64);
  5265. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5266. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5267. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5268. }
  5269. /**
  5270. *
  5271. *
  5272. *
  5273. 进销存占单异常索引
  5274. *
  5275. *
  5276. *
  5277. **/
  5278. public function _abnormal()
  5279. {
  5280. $post = $this->input->post(NULL, TRUE);
  5281. if (isset($post['page'])) {
  5282. $page = $this->input->post('page', true);
  5283. $perpage = $this->input->post('perpage', true);
  5284. $sku = $this->input->post('sku', true);
  5285. $where = "1=1";
  5286. //数据排序
  5287. $order_str = "id desc";
  5288. if (empty($page)) {
  5289. $start = 0;
  5290. $perpage = 1;
  5291. } else {
  5292. $start = ($page - 1) * $perpage;
  5293. }
  5294. //取得信息列表
  5295. $info_list = $this->whlabel->find_all($where, '*');
  5296. $rows = array();
  5297. $list = array();
  5298. foreach ($info_list as $key => $value) {
  5299. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5300. }
  5301. foreach ($rows as $value) {
  5302. $warehouse = $this->warehouse->read($value['warehouse']);
  5303. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5304. $number = $value['number'];
  5305. $ftime = time() - 15 * 24 * 3600;
  5306. if ($value['shop'] != '') {
  5307. $shop = $value['shop'];
  5308. $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');
  5309. $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');
  5310. $order = array_merge($orderdlz, $ordersmt);
  5311. $od = 0;
  5312. $a = '';
  5313. $orid = '';
  5314. foreach ($order as $v) {
  5315. $or = explode('|', ltrim($v['whlabel'], '|'));
  5316. for ($i = 0; $i < count($or); $i++) {
  5317. $orod = explode('-', $or[$i]);
  5318. if ($orod[0] == $number) {
  5319. $od += $orod[1];
  5320. }
  5321. }
  5322. $orid .= $v['number'] . '-';
  5323. }
  5324. } else {
  5325. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5326. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5327. $order = array_merge($orderdlz, $ordersmt);
  5328. $od = 0;
  5329. $a = '';
  5330. $orid = '';
  5331. $qt = array();
  5332. foreach ($order as $v) {
  5333. $or = explode('|', ltrim($v['whlabel'], '|'));
  5334. for ($i = 0; $i < count($or); $i++) {
  5335. $orod = explode('-', $or[$i]);
  5336. if ($orod[0] == $number) {
  5337. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5338. if ($czzs > 0) {
  5339. if (isset($qt[$v['shop']])) {
  5340. if ($qt[$v['shop']] < $orod[1]) {
  5341. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5342. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5343. } else {
  5344. $qt[$v['shop']] -= $orod[1];
  5345. }
  5346. } else {
  5347. $qt[$v['shop']] = $czzs;
  5348. }
  5349. } else {
  5350. $od += $orod[1];
  5351. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5352. }
  5353. }
  5354. }
  5355. }
  5356. }
  5357. $z = $od . '(' . $orid . ')'; //查看订单号
  5358. //$z = $od;
  5359. if ($od > $c) {
  5360. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5361. }
  5362. }
  5363. $listdata = array_slice($list, $start, $perpage);
  5364. $total = count($list);
  5365. $pagenum = ceil($total / $perpage);
  5366. $over = $total - ($start + $perpage);
  5367. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5368. echo json_encode($rows);
  5369. exit;
  5370. }
  5371. $this->_Template('whlabel_abnormal', $this->data);
  5372. }
  5373. /**
  5374. *
  5375. *
  5376. *
  5377. 进销存占单异常索引
  5378. *
  5379. *
  5380. *
  5381. **/
  5382. public function _error()
  5383. {
  5384. $post = $this->input->post(NULL, TRUE);
  5385. if (isset($post['page'])) {
  5386. $page = $this->input->post('page', true);
  5387. $perpage = $this->input->post('perpage', true);
  5388. $sku = $this->input->post('sku', true);
  5389. $warehouse = $this->input->post('warehouse', true);
  5390. $ktime = $this->input->post('ktime', true);
  5391. $jtime = $this->input->post('jtime', true);
  5392. $ktime = strtotime($ktime);
  5393. $jtime = strtotime($jtime);
  5394. $where = "sku != 'Preset'";
  5395. $gj = '';
  5396. if ($sku) {
  5397. $where .= " and sku like '%$sku%'";
  5398. } else {
  5399. if ($ktime && $jtime) {
  5400. $gj = " and time > '$ktime' and time < '$jtime'";
  5401. }
  5402. }
  5403. if ($warehouse) {
  5404. $where .= " and warehouse = '$warehouse'";
  5405. }
  5406. //数据排序
  5407. $order_str = "id desc";
  5408. if (empty($page)) {
  5409. $start = 0;
  5410. $perpage = 1;
  5411. } else {
  5412. $start = ($page - 1) * $perpage;
  5413. }
  5414. //取得信息列表
  5415. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5416. $rows = array();
  5417. $list = array();
  5418. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5419. // foreach ($info_list as $value)
  5420. // {
  5421. // $warehouse = $this->warehouse->read($value['warehouse']);
  5422. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5423. // $number = $value['number'];$ftime = time()-15*24*3600;
  5424. // if($c < 1)
  5425. // {
  5426. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5427. // }
  5428. // }
  5429. $warehouse_list = $this->warehouse->find_all();
  5430. $warehouse_list = array_column($warehouse_list, null, 'id');
  5431. foreach ($info_list as $value) {
  5432. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5433. 'title' => "",
  5434. ];
  5435. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5436. $number = $value['number'];
  5437. $ftime = time() - 15 * 24 * 3600;
  5438. if ($c < 1) {
  5439. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5440. }
  5441. }
  5442. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5443. // $query = $this->db->query($sql);
  5444. // $info_list = $query->result_array();
  5445. // $sql_two = "select title,id from crowd_warehouse";
  5446. // $query_two = $this->db->query($sql_two);
  5447. // $warehouse_list = $query_two->result_array();
  5448. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5449. // foreach ($info_list as $value)
  5450. // {
  5451. // if(isset($warehouse_arr[$value['warehouse']])){
  5452. // $warehouse = $warehouse_arr[$value['warehouse']];
  5453. // }else{
  5454. // $warehouse = [
  5455. // 'id'=>0,
  5456. // 'title'=>"异常",
  5457. // ];
  5458. // }
  5459. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5460. // $number = $value['number'];$ftime = time()-15*24*3600;
  5461. // if($c < 1)
  5462. // {
  5463. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5464. // }
  5465. // }
  5466. $listdata = array_slice($list, $start, $perpage);
  5467. $total = count($list);
  5468. $pagenum = ceil($total / $perpage);
  5469. $over = $total - ($start + $perpage);
  5470. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5471. echo json_encode($rows);
  5472. exit;
  5473. }
  5474. if (isset($post['s'])) {
  5475. $id_arr = $this->input->post('s');
  5476. $id_arr = explode(',', trim($id_arr, ','));
  5477. if (!$id_arr) {
  5478. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5479. exit;
  5480. }
  5481. //循环删除记录
  5482. foreach ($id_arr as $v) {
  5483. $dd = $this->whlabel->read($v);
  5484. if (!isset($dd['id'])) {
  5485. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5486. exit;
  5487. }
  5488. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5489. if (isset($zt[0])) {
  5490. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5491. exit;
  5492. }
  5493. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5494. foreach ($deldd as $vv) {
  5495. $tmp_info = $vv;
  5496. $tmp_info['del_time'] = time();
  5497. $this->db->insert('whlabelscbf',$tmp_info);
  5498. $this->whlabel->remove($vv['id']);
  5499. }
  5500. }
  5501. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5502. exit;
  5503. }
  5504. $this->_Template('whlabel_error', $this->data);
  5505. }
  5506. public function _errorexcel()
  5507. {
  5508. $post = $this->input->post(NULL, TRUE);
  5509. if (isset($_GET['page'])) {
  5510. $page = $this->input->get('page', true);
  5511. $perpage = $this->input->get('perpage', true);
  5512. $sku = $this->input->get('sku', true);
  5513. $warehouse = $this->input->get('warehouse', true);
  5514. $ktime = $this->input->get('ktime', true);
  5515. $jtime = $this->input->get('jtime', true);
  5516. $ktime = strtotime($ktime);
  5517. $jtime = strtotime($jtime);
  5518. $where = "sku != 'Preset'";
  5519. $gj = '';
  5520. if ($sku) {
  5521. $where .= " and sku like '%$sku%'";
  5522. } else {
  5523. if ($ktime && $jtime) {
  5524. $gj = " and time > '$ktime' and time < '$jtime'";
  5525. }
  5526. }
  5527. if ($warehouse) {
  5528. $where .= " and warehouse = '$warehouse'";
  5529. }
  5530. //数据排序
  5531. $order_str = "id desc";
  5532. if (empty($page)) {
  5533. $start = 0;
  5534. $perpage = 1;
  5535. } else {
  5536. $start = ($page - 1) * $perpage;
  5537. }
  5538. //取得信息列表
  5539. $rows = array();
  5540. $list = array();
  5541. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5542. foreach ($info_list as $value) {
  5543. $warehouse = $this->warehouse->read($value['warehouse']);
  5544. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5545. $number = $value['number'];
  5546. $ftime = time() - 15 * 24 * 3600;
  5547. if ($c < 1) {
  5548. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5549. }
  5550. }
  5551. $title = "0库存汇总";
  5552. $titlename = "<table border=1>
  5553. <tr align='center'>
  5554. <td>仓库</td>
  5555. <td>SKU</td>
  5556. <td>产品</td>
  5557. <td>当前库存</td>
  5558. </tr>
  5559. </table>";
  5560. $filename = $title . ".xls";
  5561. $tail = "";
  5562. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5563. }
  5564. }
  5565. /**
  5566. *
  5567. *
  5568. * 占单
  5569. *
  5570. *
  5571. **/
  5572. public function _kcyz()
  5573. {
  5574. $post = $this->input->post(NULL, TRUE);
  5575. if (isset($post['warehouse'])) {
  5576. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5577. exit; //不再使用
  5578. $warehouse = $this->input->post('warehouse', true);
  5579. $whlabel = $this->input->post('whlabel', true);
  5580. $id = $this->input->post('id', true);
  5581. $shop = $this->input->post('shop', true);
  5582. $number = $this->input->post('number', true);
  5583. if (!$whlabel || $whlabel == '|') {
  5584. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5585. exit;
  5586. }
  5587. $pp = explode('|', trim($whlabel, '|'));
  5588. $x = 0;
  5589. $save = array();
  5590. foreach ($pp as $va) {
  5591. $num = explode('-', $va);
  5592. if ($number) {
  5593. $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 = '')"); //通用
  5594. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5595. } else {
  5596. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5597. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5598. }
  5599. $x++;
  5600. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5601. $save[] = $x - 1;
  5602. continue; //提前先加X不然出错,所以要减1
  5603. }
  5604. }
  5605. if (isset($save[0])) {
  5606. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5607. exit;
  5608. } else {
  5609. echo json_encode(array('success' => true));
  5610. exit;
  5611. }
  5612. }
  5613. }
  5614. public function _db()
  5615. {
  5616. $post = $this->input->post(NULL, TRUE);
  5617. if (isset($post['page'])) {
  5618. $page = $this->input->post('page', true);
  5619. $perpage = $this->input->post('perpage', true);
  5620. $sku = $this->input->post('sku', true);
  5621. $number = $this->input->post('number', true);
  5622. $warehouse = $this->input->post('warehouse', true);
  5623. $purchase = $this->input->post('purchase', true);
  5624. $orderinfo = $this->input->post('orderinfo', true);
  5625. $waybill = $this->input->post('waybill', true);
  5626. $category = $this->input->post('category', true);
  5627. $size = $this->input->post('size', true);
  5628. $grade = $this->input->post('grade', true);
  5629. $color = $this->input->post('color', true);
  5630. $lowe = $this->input->post('lowe', true);
  5631. $state = $this->input->post('state', true);
  5632. $label = $this->input->post('label', true);
  5633. $timetk = $this->input->post('timetkk', true);
  5634. $timetj = $this->input->post('timetjj', true);
  5635. $timetk = strtotime($timetk);
  5636. $timetj = strtotime($timetj);
  5637. $where = "dbtime > 0";
  5638. if ($timetk && $timetj) {
  5639. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5640. }
  5641. if ($sku) {
  5642. $where .= " and sku = '$sku'";
  5643. }
  5644. if ($warehouse) {
  5645. $where .= " and warehouse = '$warehouse'";
  5646. if ($warehouse == 12) {
  5647. $w = 'specialstock';
  5648. } else {
  5649. $w = 'whlabel';
  5650. }
  5651. }
  5652. if ($purchase) {
  5653. $where .= " and purchase = '$purchase'";
  5654. }
  5655. if ($category) {
  5656. $where .= " and features like '%-$category-%'";
  5657. }
  5658. if ($size) {
  5659. $where .= " and features like '%-$size-%'";
  5660. }
  5661. if ($grade) {
  5662. $where .= " and features like '%-$grade-%'";
  5663. }
  5664. if ($color) {
  5665. $where .= " and features like '%-$color-%'";
  5666. }
  5667. if ($lowe) {
  5668. $where .= " and features like '%-$lowe-%'";
  5669. }
  5670. if ($state != '') {
  5671. $where .= " and state = '$state'";
  5672. }
  5673. //数据排序
  5674. $order_str = "dbtime desc";
  5675. if (empty($page)) {
  5676. $start = 0;
  5677. $perpage = 1;
  5678. } else {
  5679. $start = ($page - 1) * $perpage;
  5680. }
  5681. //取得信息列表
  5682. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5683. foreach ($info_list as $key => $value) {
  5684. $warehouse = $this->$w->read($value['warehouse']);
  5685. $info_list[$key]['warehouse'] = $warehouse['title'];
  5686. $purchase = $this->purchase->read($value['purchase']);
  5687. $info_list[$key]['purchase'] = $purchase['title'];
  5688. if ($value['enter'] != 0) {
  5689. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5690. } else {
  5691. $info_list[$key]['enter'] = "";
  5692. }
  5693. if ($value['dbtime'] != 0) {
  5694. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5695. } else {
  5696. $info_list[$key]['dbtime'] = "";
  5697. }
  5698. if ($value['state'] == 0) {
  5699. $info_list[$key]['state'] = "在库";
  5700. } else if ($value['state'] == 1) {
  5701. $info_list[$key]['state'] = "出库";
  5702. } else if ($value['state'] == 2) {
  5703. $info_list[$key]['state'] = "退库";
  5704. } else if ($value['state'] == 3) {
  5705. $info_list[$key]['state'] = "调拨中";
  5706. } else if ($value['state'] == 4) {
  5707. $info_list[$key]['state'] = "再加工";
  5708. } else if ($value['state'] == 5) {
  5709. $info_list[$key]['state'] = "维修中";
  5710. } else if ($value['state'] == 6) {
  5711. $info_list[$key]['state'] = "盘亏";
  5712. } else if ($value['state'] == 7) {
  5713. $info_list[$key]['state'] = "更换标签";
  5714. } else if ($value['state'] == 8) {
  5715. $info_list[$key]['state'] = "其它";
  5716. } else if ($value['state'] == 9) {
  5717. $info_list[$key]['state'] = "预设";
  5718. }
  5719. }
  5720. $total = $this->whlabel->find_count($where);
  5721. $pagenum = ceil($total / $perpage);
  5722. $over = $total - ($start + $perpage);
  5723. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5724. echo json_encode($rows);
  5725. exit;
  5726. }
  5727. if (isset($post['outsku'])) {
  5728. $time = time();
  5729. $cz = $this->input->post('cz', true);
  5730. $label = $this->input->post('outsku', true);
  5731. $sl = $this->input->post('sl', true);
  5732. $num = $this->input->post('num', true);
  5733. //$warehouse = $this->input->post('warehouse',true);
  5734. if (!$sl) {
  5735. $sl = 1;
  5736. }
  5737. if (!$warehouse) {
  5738. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5739. exit;
  5740. }
  5741. $dblabel = $this->whlabellabel->get_label($label);
  5742. if ($dblabel) {
  5743. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5744. if (count($data) < 1) {
  5745. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5746. exit;
  5747. }
  5748. if (count($data) < $num) {
  5749. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5750. exit;
  5751. }
  5752. for ($i = 0; $i < $sl; $i++) {
  5753. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5754. }
  5755. echo json_encode(array('success' => true));
  5756. exit;
  5757. } else {
  5758. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5759. exit;
  5760. }
  5761. }
  5762. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5763. $this->_Template('whlabel_db', $this->data);
  5764. }
  5765. public function _dbrk()
  5766. {
  5767. $post = $this->input->post(NULL, TRUE);
  5768. if (isset($post['page'])) {
  5769. $page = $this->input->post('page', true);
  5770. $perpage = $this->input->post('perpage', true);
  5771. $sku = $this->input->post('sku', true);
  5772. $number = $this->input->post('number', true);
  5773. $warehouse = $this->input->post('warehouse', true);
  5774. $purchase = $this->input->post('purchase', true);
  5775. $orderinfo = $this->input->post('orderinfo', true);
  5776. $waybill = $this->input->post('waybill', true);
  5777. $category = $this->input->post('category', true);
  5778. $size = $this->input->post('size', true);
  5779. $grade = $this->input->post('grade', true);
  5780. $color = $this->input->post('color', true);
  5781. $lowe = $this->input->post('lowe', true);
  5782. $state = $this->input->post('state', true);
  5783. $label = $this->input->post('label', true);
  5784. $ctime = $this->input->post('ctime', true);
  5785. $timetk = $this->input->post('timetkk', true);
  5786. $timetj = $this->input->post('timetjj', true);
  5787. $timetk = strtotime($timetk);
  5788. $timetj = strtotime($timetj);
  5789. $where = "dbtime > 0";
  5790. if ($timetk && $timetj) {
  5791. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5792. }
  5793. if ($sku) {
  5794. $where .= " and sku = '$sku'";
  5795. }
  5796. if ($warehouse) {
  5797. $where .= " and warehouse = '$warehouse'";
  5798. }
  5799. if ($purchase) {
  5800. $where .= " and purchase = '$purchase'";
  5801. }
  5802. if ($category) {
  5803. $where .= " and features like '%-$category-%'";
  5804. }
  5805. if ($size) {
  5806. $where .= " and features like '%-$size-%'";
  5807. }
  5808. if ($grade) {
  5809. $where .= " and features like '%-$grade-%'";
  5810. }
  5811. if ($color) {
  5812. $where .= " and features like '%-$color-%'";
  5813. }
  5814. if ($lowe) {
  5815. $where .= " and features like '%-$lowe-%'";
  5816. }
  5817. if ($state != '') {
  5818. $where .= " and state = '$state'";
  5819. }
  5820. //数据排序
  5821. $order_str = "dbtime desc";
  5822. if (empty($page)) {
  5823. $start = 0;
  5824. $perpage = 1;
  5825. } else {
  5826. $start = ($page - 1) * $perpage;
  5827. }
  5828. //取得信息列表
  5829. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5830. foreach ($info_list as $key => $value) {
  5831. $warehouse = $this->warehouse->read($value['warehouse']);
  5832. $info_list[$key]['warehouse'] = $warehouse['title'];
  5833. $purchase = $this->purchase->read($value['purchase']);
  5834. $info_list[$key]['purchase'] = $purchase['title'];
  5835. if ($value['enter'] != 0) {
  5836. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5837. } else {
  5838. $info_list[$key]['enter'] = "";
  5839. }
  5840. if ($value['dbtime'] != 0) {
  5841. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5842. } else {
  5843. $info_list[$key]['dbtime'] = "";
  5844. }
  5845. if ($value['state'] == 0) {
  5846. $info_list[$key]['state'] = "在库";
  5847. } else if ($value['state'] == 1) {
  5848. $info_list[$key]['state'] = "出库";
  5849. } else if ($value['state'] == 2) {
  5850. $info_list[$key]['state'] = "退库";
  5851. } else if ($value['state'] == 3) {
  5852. $info_list[$key]['state'] = "调拨中";
  5853. } else if ($value['state'] == 4) {
  5854. $info_list[$key]['state'] = "再加工";
  5855. } else if ($value['state'] == 5) {
  5856. $info_list[$key]['state'] = "维修中";
  5857. } else if ($value['state'] == 6) {
  5858. $info_list[$key]['state'] = "盘亏";
  5859. } else if ($value['state'] == 7) {
  5860. $info_list[$key]['state'] = "更换标签";
  5861. } else if ($value['state'] == 8) {
  5862. $info_list[$key]['state'] = "其它";
  5863. } else if ($value['state'] == 9) {
  5864. $info_list[$key]['state'] = "预设";
  5865. }
  5866. }
  5867. $total = $this->whlabel->find_count($where);
  5868. $pagenum = ceil($total / $perpage);
  5869. $over = $total - ($start + $perpage);
  5870. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5871. echo json_encode($rows);
  5872. exit;
  5873. }
  5874. if (isset($post['rsku'])) {
  5875. $cz = $this->input->post('cz', true);
  5876. $label = $this->input->post('rsku', true);
  5877. $sl = $this->input->post('sl', true);
  5878. $warehouse = $this->input->post('warehouse', true);
  5879. if (!$sl) {
  5880. $sl = 1;
  5881. }
  5882. if (!$warehouse) {
  5883. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5884. exit;
  5885. }
  5886. $dblabel = $this->whlabellabel->get_label($label);
  5887. if ($dblabel) {
  5888. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5889. if (count($data) < 1) {
  5890. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5891. exit;
  5892. }
  5893. if ($sl > count($data)) {
  5894. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5895. exit;
  5896. }
  5897. $time = time();
  5898. for ($i = 0; $i < $sl; $i++) {
  5899. $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']);
  5900. }
  5901. echo json_encode(array('success' => true));
  5902. exit;
  5903. } else {
  5904. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5905. exit;
  5906. }
  5907. }
  5908. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5909. $this->_Template('whlabel_dbrk', $this->data);
  5910. }
  5911. public function _whlabelczdc()
  5912. {
  5913. if (isset($_GET['excel'])) {
  5914. //数据排序
  5915. $order_str = "id desc";
  5916. if (empty($page)) {
  5917. $start = 0;
  5918. $perpage = 1;
  5919. } else {
  5920. $start = ($page - 1) * $perpage;
  5921. }
  5922. $state = $this->input->get('state', true);
  5923. $sku = $this->input->get('sku', true);
  5924. $ctime = $this->input->get('ctime', true);
  5925. $category = $this->input->get('category', true);
  5926. $size = $this->input->get('size', true);
  5927. $grade = $this->input->get('grade', true);
  5928. $color = $this->input->get('color', true);
  5929. $lowe = $this->input->get('lowe', true);
  5930. $timetk = $this->input->get('timetkk', true);
  5931. $timetj = $this->input->get('timetjj', true);
  5932. $timetk = strtotime($timetk);
  5933. $timetj = strtotime($timetj);
  5934. $where = "dbtime > 0";
  5935. if ($timetk && $timetj) {
  5936. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5937. }
  5938. if ($category) {
  5939. $where .= " and features like '%-$category-%'";
  5940. }
  5941. if ($size) {
  5942. $where .= " and features like '%-$size-%'";
  5943. }
  5944. if ($grade) {
  5945. $where .= " and features like '%-$grade-%'";
  5946. }
  5947. if ($color) {
  5948. $where .= " and features like '%-$color-%'";
  5949. }
  5950. if ($lowe) {
  5951. $where .= " and features like '%-$lowe-%'";
  5952. }
  5953. //取得信息列表
  5954. $info_list = $this->whlabel->find_all($where, '*');
  5955. $rows = array();
  5956. $list = array();
  5957. foreach ($info_list as $key => $value) {
  5958. $rows[$value['sku']] = $value; //所有数据sku
  5959. }
  5960. foreach ($rows as $value) {
  5961. $warehouse = $this->warehouse->read($value['warehouse']);
  5962. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5963. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5964. if ($value['orderinfo'] == 0) {
  5965. $info_list[$key]['orderinfo'] = "";
  5966. }
  5967. if ($value['waybill'] == 0) {
  5968. $info_list[$key]['waybill'] = "";
  5969. }
  5970. if ($value['state'] == 0) {
  5971. $value['state'] = "在库";
  5972. } else if ($value['state'] == 3) {
  5973. $value['state'] = "调拨中";
  5974. }
  5975. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5976. }
  5977. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5978. $titlename = "<table border=1>
  5979. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5980. <tr align='center'>
  5981. <td>SKU</td>
  5982. <td>产品</td>
  5983. <td>调拨数量</td>
  5984. <td>入库数量</td>
  5985. </tr>
  5986. </table>";
  5987. $filename = $title . ".xls";
  5988. $tail = "";
  5989. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5990. }
  5991. }
  5992. public function _print($arg_array)
  5993. {
  5994. if (isset($_SESSION['api'])) {
  5995. $user = $this->user->get_api($_SESSION['api']);
  5996. $usp = $user;
  5997. $fgshop = "";
  5998. $sid = "";
  5999. $wid = "";
  6000. $wtype = "";
  6001. $usersp = explode('|', trim($user['shop'], '|'));
  6002. $userwh = explode('|', trim($user['warehouse'], '|'));
  6003. foreach ($usersp as $value) {
  6004. $fgshop .= " shop = " . $value . " or";
  6005. $sid .= " id = " . $value . " or";
  6006. }
  6007. foreach ($userwh as $value) {
  6008. $wid .= " id = " . $value . " or";
  6009. $wtype .= " type = " . $value . " or";
  6010. }
  6011. }
  6012. $post = $this->input->post(NULL, TRUE);
  6013. if (isset($post['tmsku'])) {
  6014. $tmsku = $this->input->post('tmsku', true);
  6015. if (is_numeric($tmsku)) {
  6016. $yyh = $this->whlabellabel->get_label($tmsku);
  6017. } else {
  6018. $yyh = $this->whlabellabel->get_sku($tmsku);
  6019. if(empty($yyh)){
  6020. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6021. if($r['code'] == -1 ){
  6022. echo json_encode(array('success' => false));
  6023. exit;
  6024. }else{
  6025. echo json_encode(array('features' => $r['data'], 'success' => true));
  6026. exit;
  6027. }
  6028. }
  6029. }
  6030. if ($yyh) {
  6031. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6032. exit;
  6033. } else {
  6034. echo json_encode(array('success' => false));
  6035. exit;
  6036. }
  6037. }
  6038. $classid = $this->classid->sku();
  6039. $pm = $classid;
  6040. $scsku = $classid;
  6041. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6042. if (isset($post['warehouse'])) {
  6043. if ($post['warehouse']) {
  6044. $list = array();
  6045. $num = "";
  6046. $title = "";
  6047. $features = "";
  6048. $order = 0;
  6049. $post['shop'] = '';
  6050. $brand = $this->input->post('brand', true);
  6051. if ($brand != '0,') {
  6052. $b = $this->brand->read(rtrim($brand, ','));
  6053. if ($b) {
  6054. $post['shop'] = str_replace('|', ',', $b['shop']);
  6055. }
  6056. }
  6057. $post['details'] = $this->input->post('details', true); //打印数量
  6058. $xbqnum = $this->input->post('xbqnum', true);
  6059. $post['purchase'] = $this->input->post('purchase', true);
  6060. $post['warehouse'] = $this->input->post('warehouse', true);
  6061. $post['purchase'] = $this->input->post('purchase', true);
  6062. $post['retreatwarehouse'] = $post['warehouse'];
  6063. $post['cpbz'] = $this->input->post('cpbz', true);
  6064. $post['state'] = 9;
  6065. $category = $this->input->post('category', true);
  6066. $list['category'] = $category;
  6067. $list['hairtype'] = $this->input->post('hairtype', true);
  6068. $list['grade'] = $this->input->post('grade', true);
  6069. $size = $this->input->post('size', true);
  6070. $list['size'] = rtrim($size, ',');
  6071. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6072. $list['extension'] = $this->input->post('extension', true);
  6073. if ($category == 1297) {
  6074. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6075. }
  6076. if ($category == 1702) {
  6077. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6078. $list['syother'] = $this->input->post('syother', true);
  6079. }
  6080. if ($category == 133) {
  6081. $list['fittype'] = $this->input->post('fittype', true);
  6082. $list['acother'] = $this->input->post('acother', true);
  6083. }
  6084. $list['color'] = $this->input->post('color', true);
  6085. $list['lowe'] = $this->input->post('lowe', true);
  6086. if ($category == 127) {
  6087. $list['type'] = $this->input->post('type', true);
  6088. $list['headroad'] = $this->input->post('headroad', true);
  6089. $list['density'] = $this->input->post('density', true);
  6090. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6091. $list['lacesize'] = $this->input->post('lacesize', true);
  6092. }
  6093. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6094. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6095. }
  6096. if ($category == 128) {
  6097. $list['lacetype'] = $this->input->post('lacetype', true);
  6098. $list['haircap'] = $this->input->post('haircap', true);
  6099. $list['density'] = $this->input->post('density', true);
  6100. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6101. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6102. $list['wigother'] = $this->input->post('wigother', true);
  6103. $list['wigother1'] = $this->input->post('wigother1', true);
  6104. $list['wigother2'] = $this->input->post('wigother2', true);
  6105. $list['product_related'] = $this->input->post('product_related', true);
  6106. }
  6107. if ($category == 129) {
  6108. $list['wide'] = $this->input->post('wide', true);
  6109. }
  6110. if ($category == 131) {
  6111. $list['gifttype'] = $this->input->post('gifttype', true);
  6112. $list['giftother'] = $this->input->post('giftother', true);
  6113. }
  6114. if ($category == 134) {
  6115. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6116. }
  6117. if ($category == 1297) {
  6118. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6119. $list['sywigother'] = $this->input->post('sywigother', true);
  6120. }
  6121. if ($category == 130 || $category == 133 || $category == 1702) {
  6122. $list['items'] = $this->input->post('items', true);
  6123. $list['weight'] = $this->input->post('weight', true);
  6124. }
  6125. if ($category == 1702) {
  6126. $list['syhairther'] = $this->input->post('syhairther', true);
  6127. }
  6128. if($category == 130){
  6129. $list['jfother'] = $this->input->post('jfother', true);
  6130. }
  6131. foreach ($list as $k => $v) {
  6132. if ($v != 0) {
  6133. $num .= $v;
  6134. $features .= $v . '-';
  6135. $post[$k] = $v;
  6136. $typeclass = $this->typeclass->read($v);
  6137. if (isset($pm[$typeclass['classid']])) {
  6138. if (stripos($typeclass['zh'], '|') !== false) {
  6139. $exzh = explode('|', $typeclass['zh']);
  6140. $pm[$typeclass['classid']] = $exzh[0];
  6141. } else {
  6142. $pm[$typeclass['classid']] = $typeclass['zh'];
  6143. }
  6144. }
  6145. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6146. if ($k != 'size') {
  6147. $title .= $typeclass['title'] . " ";
  6148. }
  6149. }
  6150. }
  6151. $typeclass = $this->typeclass->read($list['size']);
  6152. $title .= $typeclass['title'];
  6153. $time = time();
  6154. $post['title'] = rtrim($title, ' ');
  6155. $post['number'] = $num;
  6156. $post['features'] = '-' . $features;
  6157. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6158. $featurespp = explode('-', trim($featurespp, '-'));
  6159. if (isset($featurespp[5])) {
  6160. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6161. } else {
  6162. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6163. }
  6164. $post['enter'] = $time;
  6165. $post['time'] = $time; //操作时间
  6166. $scsku = implode("-", $scsku);
  6167. $zh = implode(" ", $pm);
  6168. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6169. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6170. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6171. $post['sku'] = $bqsku;
  6172. $label = time() . rand(0, 9);
  6173. $post['label'] = $label;
  6174. $cpid = $this->whlabellabel->find_count();
  6175. $post['cpid'] = $cpid + 1;
  6176. $cpid = $post['cpid'];
  6177. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6178. //if($whlabelbarcode)
  6179. //{
  6180. //$post['label'] = $whlabelbarcode['label'];
  6181. //if(!$this->whlabellabel->insert($post))
  6182. //{
  6183. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6184. //}
  6185. //}
  6186. //else
  6187. //{
  6188. $this->db->trans_begin();
  6189. $this->whlabellabel->insert($post);
  6190. //$this->whlabelbarcode->insert($post);
  6191. if ($this->db->trans_status() === TRUE) {
  6192. $this->db->trans_commit();
  6193. } else {
  6194. $this->db->trans_rollback();
  6195. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6196. exit;
  6197. }
  6198. //}
  6199. $warehouse_name = "";
  6200. $warehouse = $post['warehouse'];
  6201. if($warehouse == 12){
  6202. $warehouse_name = "特殊库存库";
  6203. }
  6204. // if($warehouse == 13){
  6205. // $warehouse_name = "许昌仓";
  6206. // }
  6207. // if($warehouse == 5){
  6208. // $warehouse_name = "美国店";
  6209. // }
  6210. // if($warehouse == 16){
  6211. // $warehouse_name = "定制头套仓";
  6212. // }
  6213. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6214. if(!empty($warehouse_name)){
  6215. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6216. }
  6217. $purchase = $this->purchase->read($post['purchase']);
  6218. 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));
  6219. exit; //特殊仓目前不需要仓库选项
  6220. }
  6221. }
  6222. if (isset($_SESSION['api'])) {
  6223. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6224. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6225. $this->data['wlshop'] = $wlshop;
  6226. $this->data['warehouse'] = $warehouse;
  6227. }
  6228. $whlabelwz = $this->whlabelwz->find_all();
  6229. $this->data['whlabelwz'] = $whlabelwz;
  6230. $this->_Template('whlabel_print', $this->data);
  6231. }
  6232. public function _usaprint($arg_array)
  6233. {
  6234. if (isset($_SESSION['api'])) {
  6235. $user = $this->user->get_api($_SESSION['api']);
  6236. $usp = $user;
  6237. $fgshop = "";
  6238. $sid = "";
  6239. $wid = "";
  6240. $wtype = "";
  6241. $usersp = explode('|', trim($user['shop'], '|'));
  6242. $userwh = explode('|', trim($user['warehouse'], '|'));
  6243. foreach ($usersp as $value) {
  6244. $fgshop .= " shop = " . $value . " or";
  6245. $sid .= " id = " . $value . " or";
  6246. }
  6247. foreach ($userwh as $value) {
  6248. $wid .= " id = " . $value . " or";
  6249. $wtype .= " type = " . $value . " or";
  6250. }
  6251. }
  6252. $post = $this->input->post(NULL, TRUE);
  6253. if (isset($post['tmsku'])) {
  6254. $tmsku = $this->input->post('tmsku', true);
  6255. if (is_numeric($tmsku)) {
  6256. $yyh = $this->whlabellabel->get_label($tmsku);
  6257. } else {
  6258. $yyh = $this->whlabellabel->get_sku($tmsku);
  6259. }
  6260. if ($yyh) {
  6261. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6262. exit;
  6263. } else {
  6264. echo json_encode(array('success' => false));
  6265. exit;
  6266. }
  6267. }
  6268. $classid = $this->classid->sku();
  6269. $pm = $classid;
  6270. $scsku = $classid;
  6271. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6272. if (isset($post['warehouse'])) {
  6273. if ($post['warehouse']) {
  6274. $list = array();
  6275. $num = "";
  6276. $title = "";
  6277. $features = "";
  6278. $order = 0;
  6279. $post['shop'] = '';
  6280. $brand = $this->input->post('brand', true);
  6281. if ($brand != '0,') {
  6282. $b = $this->brand->read(rtrim($brand, ','));
  6283. if ($b) {
  6284. $post['shop'] = str_replace('|', ',', $b['shop']);
  6285. }
  6286. }
  6287. $post['details'] = $this->input->post('details', true); //打印数量
  6288. $xbqnum = $this->input->post('xbqnum', true);
  6289. $post['purchase'] = $this->input->post('purchase', true);
  6290. $post['warehouse'] = $this->input->post('warehouse', true);
  6291. $post['purchase'] = $this->input->post('purchase', true);
  6292. $post['retreatwarehouse'] = $post['warehouse'];
  6293. $post['cpbz'] = $this->input->post('cpbz', true);
  6294. $post['state'] = 9;
  6295. $category = $this->input->post('category', true);
  6296. $list['category'] = $category;
  6297. $list['hairtype'] = $this->input->post('hairtype', true);
  6298. $list['grade'] = $this->input->post('grade', true);
  6299. $size = $this->input->post('size', true);
  6300. $list['size'] = rtrim($size, ',');
  6301. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6302. $list['extension'] = $this->input->post('extension', true);
  6303. if ($category == 1297) {
  6304. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6305. }
  6306. if ($category == 1702) {
  6307. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6308. $list['syother'] = $this->input->post('syother', true);
  6309. }
  6310. if ($category == 133) {
  6311. $list['fittype'] = $this->input->post('fittype', true);
  6312. $list['acother'] = $this->input->post('acother', true);
  6313. }
  6314. $list['color'] = $this->input->post('color', true);
  6315. $list['lowe'] = $this->input->post('lowe', true);
  6316. if ($category == 127) {
  6317. $list['type'] = $this->input->post('type', true);
  6318. $list['headroad'] = $this->input->post('headroad', true);
  6319. $list['density'] = $this->input->post('density', true);
  6320. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6321. $list['lacesize'] = $this->input->post('lacesize', true);
  6322. }
  6323. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6324. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6325. }
  6326. if ($category == 128) {
  6327. $list['lacetype'] = $this->input->post('lacetype', true);
  6328. $list['haircap'] = $this->input->post('haircap', true);
  6329. $list['density'] = $this->input->post('density', true);
  6330. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6331. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6332. $list['wigother'] = $this->input->post('wigother', true);
  6333. $list['wigother1'] = $this->input->post('wigother1', true);
  6334. $list['wigother2'] = $this->input->post('wigother2', true);
  6335. $list['product_related'] = $this->input->post('product_related', true);
  6336. }
  6337. if ($category == 129) {
  6338. $list['wide'] = $this->input->post('wide', true);
  6339. }
  6340. if ($category == 131) {
  6341. $list['gifttype'] = $this->input->post('gifttype', true);
  6342. $list['giftother'] = $this->input->post('giftother', true);
  6343. }
  6344. if ($category == 134) {
  6345. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6346. }
  6347. if ($category == 1297) {
  6348. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6349. $list['sywigother'] = $this->input->post('sywigother', true);
  6350. }
  6351. if ($category == 130 || $category == 133 || $category == 1702) {
  6352. $list['items'] = $this->input->post('items', true);
  6353. $list['weight'] = $this->input->post('weight', true);
  6354. }
  6355. if ($category == 1702) {
  6356. $list['syhairther'] = $this->input->post('syhairther', true);
  6357. }
  6358. foreach ($list as $k => $v) {
  6359. if ($v != 0) {
  6360. $num .= $v;
  6361. $features .= $v . '-';
  6362. $post[$k] = $v;
  6363. $typeclass = $this->typeclass->read($v);
  6364. if (isset($pm[$typeclass['classid']])) {
  6365. if (stripos($typeclass['zh'], '|') !== false) {
  6366. $exzh = explode('|', $typeclass['zh']);
  6367. $pm[$typeclass['classid']] = $exzh[0];
  6368. } else {
  6369. $pm[$typeclass['classid']] = $typeclass['zh'];
  6370. }
  6371. }
  6372. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6373. if ($k != 'size') {
  6374. $title .= $typeclass['title'] . " ";
  6375. }
  6376. }
  6377. }
  6378. $typeclass = $this->typeclass->read($list['size']);
  6379. $title .= $typeclass['title'];
  6380. $time = time();
  6381. $post['title'] = rtrim($title, ' ');
  6382. $post['number'] = $num;
  6383. $post['features'] = '-' . $features;
  6384. $fp = $this->whlabel->get_features($post['features']);
  6385. if (!$fp) {
  6386. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6387. exit;
  6388. }
  6389. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6390. $featurespp = explode('-', trim($featurespp, '-'));
  6391. if (isset($featurespp[5])) {
  6392. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6393. } else {
  6394. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6395. }
  6396. $post['enter'] = $time;
  6397. $post['time'] = $time; //操作时间
  6398. $scsku = implode("-", $scsku);
  6399. $zh = implode(" ", $pm);
  6400. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6401. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6402. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6403. $post['sku'] = $fp['sku'];
  6404. $post['label'] = $fp['sku'];
  6405. $cpid = $this->whlabellabel->find_count();
  6406. $post['cpid'] = $cpid + 1;
  6407. $cpid = $post['cpid'];
  6408. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6409. //if($whlabelbarcode)
  6410. //{
  6411. //$post['label'] = $whlabelbarcode['label'];
  6412. //if(!$this->whlabellabel->insert($post))
  6413. //{
  6414. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6415. //}
  6416. //}
  6417. //else
  6418. //{
  6419. $this->db->trans_begin();
  6420. $this->whlabellabel->insert($post);
  6421. //$this->whlabelbarcode->insert($post);
  6422. if ($this->db->trans_status() === TRUE) {
  6423. $this->db->trans_commit();
  6424. } else {
  6425. $this->db->trans_rollback();
  6426. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6427. exit;
  6428. }
  6429. //}
  6430. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6431. $purchase = $this->purchase->read($post['purchase']);
  6432. 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));
  6433. exit; //特殊仓目前不需要仓库选项
  6434. }
  6435. }
  6436. if (isset($_SESSION['api'])) {
  6437. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6438. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6439. $this->data['wlshop'] = $wlshop;
  6440. $this->data['warehouse'] = $warehouse;
  6441. }
  6442. $whlabelwz = $this->whlabelwz->find_all();
  6443. $this->data['whlabelwz'] = $whlabelwz;
  6444. $this->_Template('whlabel_usaprint', $this->data);
  6445. }
  6446. public function _printrk($arg_array)
  6447. {
  6448. $prc = array();
  6449. $purchase = $this->purchase->find_all();
  6450. foreach ($purchase as $k => $v) {
  6451. $prc[$v['id']] = $v['title'];
  6452. }
  6453. $post = $this->input->post(NULL, TRUE);
  6454. if (isset($post['page'])) {
  6455. $page = $this->input->post('page', true);
  6456. $perpage = $this->input->post('perpage', true);
  6457. $sku = $this->input->post('sku', true);
  6458. $bs = $this->input->post('bs', true);
  6459. $number = $this->input->post('number', true);
  6460. $warehouse = $this->input->post('warehouse', true);
  6461. $purchase = $this->input->post('purchase', true);
  6462. $orderinfo = $this->input->post('orderinfo', true);
  6463. $waybill = $this->input->post('waybill', true);
  6464. $category = $this->input->post('category', true);
  6465. $size = $this->input->post('size', true);
  6466. $grade = $this->input->post('grade', true);
  6467. $color = $this->input->post('color', true);
  6468. $lowe = $this->input->post('lowe', true);
  6469. $state = $this->input->post('state', true);
  6470. $label = $this->input->post('label', true);
  6471. $timetk = $this->input->post('ktime', true);
  6472. $timetj = $this->input->post('jtime', true);
  6473. $timetk = strtotime($timetk);
  6474. $timetj = strtotime($timetj);
  6475. $where = "1=1 ";
  6476. if ($timetk && $timetj) {
  6477. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6478. }
  6479. if ($sku) {
  6480. $where .= " and sku = '$sku'";
  6481. }
  6482. if ($bs != '') {
  6483. $where .= " and bs = '$bs'";
  6484. }
  6485. if ($number) {
  6486. $where .= " and number = '$number'";
  6487. }
  6488. if ($warehouse) {
  6489. $where .= " and warehouse = '$warehouse'";
  6490. }
  6491. if ($purchase) {
  6492. $where .= " and purchase = '$purchase'";
  6493. }
  6494. if ($orderinfo) {
  6495. $where .= " and orderinfo = '$orderinfo'";
  6496. }
  6497. if ($waybill) {
  6498. $where .= " and waybill = '$waybill'";
  6499. }
  6500. if ($category) {
  6501. $where .= " and features like '%-$category-%'";
  6502. }
  6503. if ($size) {
  6504. $where .= " and features like '%-$size-%'";
  6505. }
  6506. if ($grade) {
  6507. $where .= " and features like '%-$grade-%'";
  6508. }
  6509. if ($color) {
  6510. $where .= " and features like '%-$color-%'";
  6511. }
  6512. if ($lowe) {
  6513. $where .= " and features like '%-$lowe-%'";
  6514. }
  6515. if ($label) {
  6516. $where .= " and label = '$label'";
  6517. }
  6518. if ($state || $state == 0) {
  6519. $where .= " and state = '$state'";
  6520. }
  6521. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6522. //数据排序
  6523. $order_str = "enter desc";
  6524. if (empty($page)) {
  6525. $start = 0;
  6526. $perpage = 1;
  6527. } else {
  6528. $start = ($page - 1) * $perpage;
  6529. }
  6530. //取得信息列表
  6531. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6532. foreach ($info_list as $key => $value) {
  6533. $warehouse = $this->warehouse->read($value['warehouse']);
  6534. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6535. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6536. if ($value['state'] == 0) {
  6537. $info_list[$key]['state'] = "在库";
  6538. } else if ($value['state'] == 1) {
  6539. $info_list[$key]['state'] = "出库";
  6540. } else if ($value['state'] == 2) {
  6541. $info_list[$key]['state'] = "退库";
  6542. } else if ($value['state'] == 3) {
  6543. $info_list[$key]['state'] = "调拨中";
  6544. } else if ($value['state'] == 4) {
  6545. $info_list[$key]['state'] = "再加工";
  6546. } else if ($value['state'] == 5) {
  6547. $info_list[$key]['state'] = "维修中";
  6548. } else if ($value['state'] == 6) {
  6549. $info_list[$key]['state'] = "盘亏";
  6550. } else if ($value['state'] == 7) {
  6551. $info_list[$key]['state'] = "更换标签";
  6552. } else if ($value['state'] == 8) {
  6553. $info_list[$key]['state'] = "其它";
  6554. } else if ($value['state'] == 9) {
  6555. $info_list[$key]['state'] = "预设";
  6556. } else if ($value['state'] == 10) {
  6557. $info_list[$key]['state'] = "美店零售";
  6558. }
  6559. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6560. }
  6561. $total = $this->$ck->find_count($where);
  6562. $pagenum = ceil($total / $perpage);
  6563. $over = $total - ($start + $perpage);
  6564. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6565. echo json_encode($rows);
  6566. exit;
  6567. }
  6568. if (isset($post['tmsku'])) {
  6569. $time = time();
  6570. $tmsku = $this->input->post('tmsku', true);
  6571. //$post['shop'] = $this->input->post('shop',true);
  6572. $num = $this->input->post('num', true);
  6573. $rktype = $this->input->post('rktype', true);
  6574. if ($num > 200) {
  6575. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6576. exit;
  6577. }
  6578. if (!$rktype) {
  6579. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6580. }
  6581. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6582. /**
  6583. $wz = array();
  6584. foreach ($rk as $key=>$value)
  6585. {
  6586. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6587. }
  6588. if(count($wz) > 1)
  6589. {
  6590. $wz = array_values($wz);
  6591. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6592. }
  6593. **/
  6594. if (isset($rk[0]['purchase'])) {
  6595. $rk = $rk[0];
  6596. $j = 0;
  6597. $post['purchase'] = $rk['purchase'];
  6598. $post['warehouse'] = $rk['warehouse'];
  6599. $post['retreatwarehouse'] = $rk['warehouse'];
  6600. $post['sku'] = $rk['sku'];
  6601. $post['number'] = $rk['number'];
  6602. $post['features'] = $rk['features'];
  6603. $post['title'] = $rk['title'];
  6604. $post['enter'] = $time;
  6605. $post['time'] = $time;
  6606. $post['bs'] = 1;
  6607. $post['shop'] = $rk['shop'];
  6608. $post['details'] = $rk['details'];
  6609. $post['cpid'] = $rk['cpid'];
  6610. $post['cpbz'] = $rk['cpbz'];
  6611. $post['rktype'] = $rktype;
  6612. $warehouse = $this->warehouse->read($rk['warehouse']);
  6613. if ($warehouse['bdck'] == '') {
  6614. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6615. exit;
  6616. } else {
  6617. $bdck = $warehouse['bdck'];
  6618. }
  6619. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6620. if (isset($pdwz['details'])) {
  6621. if ($pdwz['details'] != $post['details']) {
  6622. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6623. }else{
  6624. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6625. exit;
  6626. }
  6627. }
  6628. }
  6629. $post['featurespp'] = $rk['featurespp'];
  6630. if ($post['warehouse'] == '5') {
  6631. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6632. if ($yza) {
  6633. if ($post['features'] != $yza[0]['features']) {
  6634. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6635. exit;
  6636. }
  6637. }
  6638. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6639. if ($yzb) {
  6640. if ($post['sku'] != $yzb[0]['sku']) {
  6641. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6642. exit;
  6643. }
  6644. }
  6645. }
  6646. for ($i = 0; $i < $num; $i++) {
  6647. $post['label'] = time() . rand(100, 999) . $i;
  6648. if ($this->$bdck->insert($post)) {
  6649. $j++;
  6650. }
  6651. }
  6652. /**
  6653. if($post['warehouse'] != 12)
  6654. {
  6655. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6656. }
  6657. **/
  6658. $this->whlabelscanlog->insert([
  6659. 'shop'=>$rk['shop'],
  6660. 'type'=>1,
  6661. 'purchase'=>$rk['purchase'],
  6662. 'sku'=>$rk['sku'],
  6663. 'features'=>$rk['features'],
  6664. 'title'=>$rk['title'],
  6665. 'label'=>$rk['label'],
  6666. 'warehouse'=>$rk['warehouse'],
  6667. 'wlid'=>$rk['id'],
  6668. 'num'=>$num,
  6669. 'addtime'=>time()
  6670. ]);
  6671. if ($j == $num) {
  6672. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6673. exit;
  6674. } else {
  6675. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6676. exit;
  6677. }
  6678. } else {
  6679. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6680. exit;
  6681. }
  6682. }
  6683. $this->_Template('whlabel_printrk', $this->data);
  6684. }
  6685. public function _printxzrk($arg_array)
  6686. {
  6687. $post = $this->input->post(NULL, TRUE);
  6688. if (isset($post['wzid'])) {
  6689. $time = time();
  6690. $id = $this->input->post('wzid', true);
  6691. //$post['shop'] = $this->input->post('shop',true);
  6692. $num = 1;
  6693. $rk = $this->whlabellabel->read($id);
  6694. if (isset($rk['purchase'])) {
  6695. $x = 0;
  6696. $post['purchase'] = $rk['purchase'];
  6697. $post['warehouse'] = $rk['warehouse'];
  6698. $post['retreatwarehouse'] = $rk['warehouse'];
  6699. $post['sku'] = $rk['sku'];
  6700. $post['number'] = $rk['number'];
  6701. $post['features'] = $rk['features'];
  6702. $post['title'] = $rk['title'];
  6703. $post['enter'] = $time;
  6704. $post['time'] = $time;
  6705. $post['bs'] = 1;
  6706. $post['shop'] = $rk['shop'];
  6707. $post['details'] = $rk['details'];
  6708. $post['cpid'] = $rk['cpid'];
  6709. $post['cpbz'] = $rk['cpbz'];
  6710. $warehouse = $this->warehouse->read($rk['warehouse']);
  6711. if ($warehouse['bdck'] == '') {
  6712. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6713. exit;
  6714. } else {
  6715. $bdck = $warehouse['bdck'];
  6716. }
  6717. $post['featurespp'] = $rk['featurespp'];
  6718. $this->db->trans_begin();
  6719. for ($i = 0; $i < $num; $i++) {
  6720. $post['label'] = time() . rand(100, 999) . $i;
  6721. $this->$bdck->insert($post);
  6722. }
  6723. /**
  6724. if($post['warehouse'] != 12)
  6725. {
  6726. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6727. }
  6728. **/
  6729. if ($this->db->trans_status() === TRUE) {
  6730. $this->db->trans_commit();
  6731. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6732. exit;
  6733. } else {
  6734. $this->db->trans_rollback();
  6735. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6736. exit;
  6737. }
  6738. } else {
  6739. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6740. exit;
  6741. }
  6742. }
  6743. }
  6744. public function _printck($arg_array)
  6745. {
  6746. $prc = array();
  6747. $purchase = $this->purchase->find_all();
  6748. foreach ($purchase as $k => $v) {
  6749. $prc[$v['id']] = $v['title'];
  6750. }
  6751. $post = $this->input->post(NULL, TRUE);
  6752. if (isset($post['page'])) {
  6753. $page = $this->input->post('page', true);
  6754. $perpage = $this->input->post('perpage', true);
  6755. $sku = $this->input->post('sku', true);
  6756. $bs = $this->input->post('bs', true);
  6757. $number = $this->input->post('number', true);
  6758. $warehouse = $this->input->post('warehouse', true);
  6759. $purchase = $this->input->post('purchase', true);
  6760. $orderinfo = $this->input->post('orderinfo', true);
  6761. $waybill = $this->input->post('waybill', true);
  6762. $category = $this->input->post('category', true);
  6763. $size = $this->input->post('size', true);
  6764. $grade = $this->input->post('grade', true);
  6765. $color = $this->input->post('color', true);
  6766. $lowe = $this->input->post('lowe', true);
  6767. $state = $this->input->post('state', true);
  6768. $label = $this->input->post('label', true);
  6769. $timetk = $this->input->post('ktime', true);
  6770. $timetj = $this->input->post('jtime', true);
  6771. $timetk = strtotime($timetk);
  6772. $timetj = strtotime($timetj);
  6773. $where = "state=1 ";
  6774. if ($timetk && $timetj) {
  6775. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6776. }
  6777. if ($sku) {
  6778. $where .= " and sku = '$sku'";
  6779. }
  6780. if ($bs != '') {
  6781. $where .= " and bs = '$bs'";
  6782. }
  6783. if ($number) {
  6784. $where .= " and number = '$number'";
  6785. }
  6786. if ($warehouse) {
  6787. $where .= " and warehouse = '$warehouse'";
  6788. }
  6789. if ($purchase) {
  6790. $where .= " and purchase = '$purchase'";
  6791. }
  6792. if ($orderinfo) {
  6793. $where .= " and orderinfo = '$orderinfo'";
  6794. }
  6795. if ($waybill) {
  6796. $where .= " and waybill = '$waybill'";
  6797. }
  6798. if ($category) {
  6799. $where .= " and features like '%-$category-%'";
  6800. }
  6801. if ($size) {
  6802. $where .= " and features like '%-$size-%'";
  6803. }
  6804. if ($grade) {
  6805. $where .= " and features like '%-$grade-%'";
  6806. }
  6807. if ($color) {
  6808. $where .= " and features like '%-$color-%'";
  6809. }
  6810. if ($lowe) {
  6811. $where .= " and features like '%-$lowe-%'";
  6812. }
  6813. if ($label) {
  6814. $where .= " and label = '$label'";
  6815. }
  6816. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6817. //数据排序
  6818. $order_str = "outk desc";
  6819. if (empty($page)) {
  6820. $start = 0;
  6821. $perpage = 1;
  6822. } else {
  6823. $start = ($page - 1) * $perpage;
  6824. }
  6825. //取得信息列表
  6826. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6827. foreach ($info_list as $key => $value) {
  6828. $warehouse = $this->warehouse->read($value['warehouse']);
  6829. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6830. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6831. if ($value['state'] == 0) {
  6832. $info_list[$key]['state'] = "在库";
  6833. } else if ($value['state'] == 1) {
  6834. $info_list[$key]['state'] = "出库";
  6835. } else if ($value['state'] == 2) {
  6836. $info_list[$key]['state'] = "退库";
  6837. } else if ($value['state'] == 3) {
  6838. $info_list[$key]['state'] = "调拨中";
  6839. } else if ($value['state'] == 4) {
  6840. $info_list[$key]['state'] = "再加工";
  6841. } else if ($value['state'] == 5) {
  6842. $info_list[$key]['state'] = "维修中";
  6843. } else if ($value['state'] == 6) {
  6844. $info_list[$key]['state'] = "盘亏";
  6845. } else if ($value['state'] == 7) {
  6846. $info_list[$key]['state'] = "更换标签";
  6847. } else if ($value['state'] == 8) {
  6848. $info_list[$key]['state'] = "其它";
  6849. } else if ($value['state'] == 9) {
  6850. $info_list[$key]['state'] = "预设";
  6851. } else if ($value['state'] == 10) {
  6852. $info_list[$key]['state'] = "美店零售";
  6853. }
  6854. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6855. }
  6856. $total = $this->$ck->find_count($where);
  6857. $pagenum = ceil($total / $perpage);
  6858. $over = $total - ($start + $perpage);
  6859. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6860. echo json_encode($rows);
  6861. exit;
  6862. }
  6863. if (isset($post['tmsku'])) {
  6864. $time = time();
  6865. $tmsku = $this->input->post('tmsku', true);
  6866. //$post['shop'] = $this->input->post('shop',true);
  6867. $num = $this->input->post('num', true);
  6868. $cktype = $this->input->post('cktype', true);
  6869. $label = $this->whlabellabel->get_label($tmsku);
  6870. if (!$cktype) {
  6871. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6872. }
  6873. if (!isset($label['warehouse'])) {
  6874. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6875. exit;
  6876. }
  6877. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6878. $extra_where = "";
  6879. if(!empty($label['details'])){
  6880. $extra_where .= " and details = '" . $label['details'] . "'";
  6881. }
  6882. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6883. if (stripos($label['features'], '-126-') !== false) {
  6884. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6885. } else {
  6886. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and purchase = '" . $label['purchase'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6887. }
  6888. $j = 0;
  6889. if (count($ck) >= $num) {
  6890. for ($i = 0; $i < $num; $i++) {
  6891. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6892. {
  6893. $j++;
  6894. }
  6895. }
  6896. $this->whlabelscanlog->insert([
  6897. 'shop'=>$label['shop'],
  6898. 'type'=>2,
  6899. 'purchase'=>$label['purchase'],
  6900. 'sku'=>$label['sku'],
  6901. 'features'=>$label['features'],
  6902. 'title'=>$label['title'],
  6903. 'label'=>$label['label'],
  6904. 'warehouse'=>$label['warehouse'],
  6905. 'wlid'=>$label['id'],
  6906. 'num'=>$num,
  6907. 'addtime'=>time()
  6908. ]);
  6909. if ($j == $num) {
  6910. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6911. exit;
  6912. } else {
  6913. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6914. exit;
  6915. }
  6916. } else {
  6917. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6918. exit;
  6919. }
  6920. }
  6921. if(isset($_SESSION['api']))
  6922. {
  6923. $user = $this->user->get_api($_SESSION['api']);
  6924. if(in_array($user['power'],[1,27])){
  6925. $vip = 1;
  6926. }
  6927. }
  6928. else
  6929. {
  6930. $vip = 0;
  6931. header('Location: /');exit;
  6932. }
  6933. $this->data['vip'] = $vip;
  6934. $this->_Template('whlabel_printck', $this->data);
  6935. }
  6936. public function _printexcel()
  6937. {
  6938. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6939. $config['upload_path'] = '.' . $dir;
  6940. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6941. $config['allowed_types'] = 'xls|xlsx|csv';
  6942. $config['max_size'] = 10240;
  6943. $this->load->library('upload', $config);
  6944. $this->upload->initialize($config);
  6945. if ($this->upload->do_upload('userfile')) {
  6946. $full_path = $dir . $this->upload->data('file_name');
  6947. $fileName = '.' . $full_path;
  6948. if (!file_exists($fileName)) {
  6949. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6950. exit;
  6951. } else {
  6952. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6953. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6954. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6955. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6956. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6957. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6958. ++$column; //如果列数大于26行
  6959. $list = array();
  6960. for ($i = 2; $i <= $row; $i++) // 行数循环
  6961. {
  6962. $data = array();
  6963. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6964. {
  6965. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6966. }
  6967. $list[] = $data;
  6968. }
  6969. }
  6970. $ed = array();
  6971. $i = 0;
  6972. $j = 0;
  6973. $dcdata = array();
  6974. $yc = '';
  6975. $cmf_arr = array_column($list, '1');
  6976. array_multisort($cmf_arr, SORT_ASC, $list);
  6977. foreach ($list as $key => $value) {
  6978. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6979. if ($typeclass) {
  6980. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6981. } else {
  6982. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6983. $i++;
  6984. continue;
  6985. }
  6986. }
  6987. if ($i > 0) {
  6988. $yc = $i . '条异常';
  6989. }
  6990. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6991. exit;
  6992. }
  6993. }
  6994. public function _uck()
  6995. {
  6996. if (isset($_GET['excel'])) {
  6997. $tc = array();
  6998. $typeclass = $this->typeclass->find_all();
  6999. foreach ($typeclass as $v) {
  7000. $tc[$v['id']] = $v['zh'];
  7001. }
  7002. $data = array();
  7003. $t = array();
  7004. $rq = '';
  7005. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  7006. $ts = $ts / (24 * 3600);
  7007. for ($i = 0; $i < $ts; $i++) {
  7008. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  7009. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  7010. }
  7011. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  7012. foreach ($info_list as $k => $v) {
  7013. $features = explode('-', trim($v['features'], '-'));
  7014. if (!isset($features[3]) || !isset($features[4])) {
  7015. continue;
  7016. }
  7017. $data[$k][0] = $tc[$features[0]]; //类型
  7018. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7019. $data[$k][2] = $tc[$features[4]]; //曲度
  7020. $data[$k][3] = '';
  7021. if (isset($data[$k][1])) {
  7022. $data[$k][3] .= $data[$k][1];
  7023. }
  7024. if (isset($data[$k][2])) {
  7025. $data[$k][3] .= $data[$k][2];
  7026. }
  7027. if (isset($features[5])) {
  7028. $data[$k][3] .= $tc[$features[5]];
  7029. }
  7030. if (isset($features[2])) {
  7031. $data[$k][3] .= $tc[$features[2]];
  7032. }
  7033. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7034. $data[$k][4] = $v['sku'];
  7035. $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())) . '))'); //月初库存
  7036. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7037. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7038. $ztrq = '';
  7039. $ztsl = '';
  7040. if (count($zt) > 0) {
  7041. foreach ($zt as $vv) {
  7042. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7043. $ztsl .= $vv['num'] . '<br>';
  7044. }
  7045. }
  7046. $data[$k][] = trim($ztsl, '<br>');
  7047. $data[$k][] = trim($ztrq, '<br>');
  7048. $byck = 0;
  7049. foreach ($t as $vv) {
  7050. $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));
  7051. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7052. $byck += $sl;
  7053. }
  7054. $data[$k][] = ($byck > 0) ? $byck : '';
  7055. }
  7056. $title = "详情 " . date("Y-m-d", time());
  7057. $titlename = "<table border=1>
  7058. <tr align='center'>
  7059. <td>类别</td>
  7060. <td>颜色</td>
  7061. <td>曲度</td>
  7062. <td>名称</td>
  7063. <td>SKU</td>
  7064. <td>月初库存</td>
  7065. <td>剩余库存</td>
  7066. <td>在途数量</td>
  7067. <td>预达日期</td>" .
  7068. $rq
  7069. . "<td>本月出库</td></tr>
  7070. </table>";
  7071. $filename = $title . ".xls";
  7072. $tail = "";
  7073. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7074. }
  7075. }
  7076. //梦体发现 用数字粘贴 会出现遗产给的数据
  7077. public function _whlabelexcelzh_ztsh()
  7078. {
  7079. if (isset($_GET['excel'])) {
  7080. $where = "sku != 'Preset'";
  7081. //数据排序
  7082. $order_str = "id desc";
  7083. if (empty($page)) {
  7084. $start = 0;
  7085. $perpage = 1;
  7086. } else {
  7087. $start = ($page - 1) * $perpage;
  7088. }
  7089. $category = $this->input->get('category', true);
  7090. $warehouse = $this->input->get('warehouse', true);
  7091. $excelid = $this->input->get('sid', true);
  7092. if ($category) {
  7093. $where .= " and features like '%-$category-%'";
  7094. }
  7095. if ($warehouse) {
  7096. $where .= " and warehouse = '$warehouse'";
  7097. }
  7098. $xzid = '';
  7099. if ($excelid) {
  7100. $excelid = explode(',', trim($excelid, ','));
  7101. foreach ($excelid as $key => $value) {
  7102. $xzid .= " id = " . $value . " or";
  7103. }
  7104. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7105. }
  7106. //取得信息列表
  7107. /**
  7108. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7109. $rows = array();$list = array();
  7110. foreach ($info_list as $key=>$value)
  7111. {
  7112. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7113. }
  7114. **/
  7115. $list = array();
  7116. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7117. foreach ($rows as $key => $value) {
  7118. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7119. $zh = '';
  7120. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7121. foreach ($zt as $v) {
  7122. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7123. }
  7124. $zt = array_sum(array_column($zt, 'num'));
  7125. $number = $value['number'];
  7126. $ftime = time() - 15 * 24 * 3600;
  7127. $warehouse = $this->warehouse->read($value['warehouse']);
  7128. $rows[$key]['warehouse'] = $warehouse['title'];
  7129. $rows[$key]['number'] = $c;
  7130. $rows[$key]['features'] = $zh;
  7131. $rows[$key]['hb'] = $c + $zt;
  7132. }
  7133. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7134. $titlename = "<table border=1>
  7135. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7136. <tr align='center'>
  7137. <td>仓库</td>
  7138. <td>SKU</td>
  7139. <td>产品</td>
  7140. <td>库存数量</td>
  7141. <td>在途数量及预达日期</td>
  7142. <td>在途+库存数量</td>
  7143. </tr>
  7144. </table>";
  7145. $filename = $title . ".xls";
  7146. $tail = "";
  7147. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7148. }
  7149. if (isset($_GET['excel'])) {
  7150. $warehouse = $this->input->get('warehouse', true);
  7151. $sku = $this->input->get('sku', true);
  7152. $cz = $this->input->get('cz', true);
  7153. $text = $this->input->post('text', true);
  7154. $xztime = $this->input->get('xztime', true);
  7155. $timetk = $this->input->get('timetk', true);
  7156. $timetj = $this->input->get('timetj', true);
  7157. $timetk = strtotime($timetk);
  7158. $timetj = strtotime($timetj);
  7159. $where = "time = '0' ";
  7160. if ($warehouse) {
  7161. $where .= " and warehouse = '$warehouse'";
  7162. }
  7163. if ($sku) {
  7164. $where .= " and sku = '$sku'";
  7165. }
  7166. if ($text) {
  7167. $where .= " and text like '%$text%'";
  7168. }
  7169. if ($cz != '') {
  7170. $where .= " and cz = '$cz'";
  7171. }
  7172. if ($timetk && $timetj) {
  7173. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7174. }
  7175. //数据排序
  7176. $order_str = $xztime . " desc";
  7177. //取得信息列表
  7178. $zh = array();
  7179. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7180. foreach ($info_list as $v) {
  7181. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7182. $warehouse = $this->warehouse->read($v['warehouse']);
  7183. $v['warehouse'] = $warehouse['title'];
  7184. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7185. $v['stime'] = date('Y-m-d', $v['stime']);
  7186. if (isset($zh[$v['features']])) {
  7187. $zh[$v['features']]['num'] += $v['num'];
  7188. } else {
  7189. $zh[$v['features']] = $v;
  7190. }
  7191. $zh[$v['features']]['features'] = $c;
  7192. }
  7193. $title = "在途数据" . date('Y-m-d', time());
  7194. $titlename = "<table border=1>
  7195. <tr align='center'>
  7196. <td>仓库</td>
  7197. <td>SKU</td>
  7198. <td>名称</td>
  7199. <td>在途数量</td>
  7200. <td>库存数量</td>
  7201. <td>添加在途日期</td>
  7202. <td>预达日期</td>
  7203. <td>备注</td>
  7204. </tr>
  7205. </table>";
  7206. $filename = $title . ".xls";
  7207. $tail = "";
  7208. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7209. }
  7210. }
  7211. //用XML(SpreadsheetML)格式导出excel,逻辑与_whlabelexcelzh一致,仅输出格式不同
  7212. public function _whlabelexcelzh()
  7213. {
  7214. //$colwidths:按表头顺序设置各列宽度(单位≈字符数);$wrapcols:需要自动换行的列下标(从0开始)
  7215. $excelxml = function ($info_list, $headers, $numkeys, $filename, $colwidths = array(), $wrapcols = array()) {
  7216. $str = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  7217. $str .= '<?mso-application progid="Excel.Sheet"?>' . "\n";
  7218. $str .= '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . "\n";
  7219. $str .= '<Styles>' . "\n";
  7220. $str .= '<Style ss:ID="wrap"><Alignment ss:Vertical="Center" ss:WrapText="1"/></Style>' . "\n";
  7221. $str .= '</Styles>' . "\n";
  7222. $str .= '<Worksheet ss:Name="Sheet1">' . "\n";
  7223. $str .= '<Table>' . "\n";
  7224. foreach ($colwidths as $w) {
  7225. $str .= '<Column ss:Width="' . $w . '"/>' . "\n";
  7226. }
  7227. $str .= '<Row>' . "\n";
  7228. foreach ($headers as $h) {
  7229. $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($h, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7230. }
  7231. $str .= '</Row>' . "\n";
  7232. foreach ($info_list as $row) {
  7233. $str .= '<Row>' . "\n";
  7234. $j = 0;
  7235. foreach ($row as $ke => $va) {
  7236. $va = (string)$va;
  7237. $va = str_replace('<br>', "\n", $va);
  7238. $wrapattr = in_array($j, $wrapcols) ? ' ss:StyleID="wrap"' : '';
  7239. if ($va === '') {
  7240. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String"></Data></Cell>' . "\n";
  7241. } else if (in_array($ke, $numkeys) && is_numeric($va)) {
  7242. $str .= '<Cell' . $wrapattr . '><Data ss:Type="Number">' . $va . '</Data></Cell>' . "\n";
  7243. } else {
  7244. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String">' . htmlspecialchars($va, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7245. }
  7246. $j++;
  7247. }
  7248. $str .= '</Row>' . "\n";
  7249. }
  7250. $str .= '</Table>' . "\n";
  7251. $str .= '</Worksheet>' . "\n";
  7252. $str .= '</Workbook>' . "\n";
  7253. while (ob_get_level()) {
  7254. ob_end_clean();
  7255. }
  7256. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  7257. header("Content-Disposition: attachment; filename=" . $filename);
  7258. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7259. header("Pragma: no-cache");
  7260. header("Expires: 0");
  7261. echo $str;
  7262. exit();
  7263. };
  7264. if (isset($_GET['excel'])) {
  7265. $where = "sku != 'Preset'";
  7266. //数据排序
  7267. $order_str = "id desc";
  7268. if (empty($page)) {
  7269. $start = 0;
  7270. $perpage = 1;
  7271. } else {
  7272. $start = ($page - 1) * $perpage;
  7273. }
  7274. $category = $this->input->get('category', true);
  7275. $warehouse = $this->input->get('warehouse', true);
  7276. $excelid = $this->input->get('sid', true);
  7277. if ($category) {
  7278. $where .= " and features like '%-$category-%'";
  7279. }
  7280. if ($warehouse) {
  7281. $where .= " and warehouse = '$warehouse'";
  7282. }
  7283. $xzid = '';
  7284. if ($excelid) {
  7285. $excelid = explode(',', trim($excelid, ','));
  7286. foreach ($excelid as $key => $value) {
  7287. $xzid .= " id = " . $value . " or";
  7288. }
  7289. $xzid = " and (" . rtrim($xzid, 'or') . ");";
  7290. }
  7291. $list = array();
  7292. $rows = $this->whlabel->find_pc($where, 'sku,title,features,warehouse', 'warehouse,sku,title,number,features');
  7293. foreach ($rows as $key => $value) {
  7294. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7295. $zh = '';
  7296. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7297. foreach ($zt as $v) {
  7298. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7299. }
  7300. $zt = array_sum(array_column($zt, 'num'));
  7301. $number = $value['number'];
  7302. $ftime = time() - 15 * 24 * 3600;
  7303. $warehouse = $this->warehouse->read($value['warehouse']);
  7304. //按表头顺序输出:仓库 | SKU | 产品 | 库存数量 | 在途数量及预达日期 | 在途+库存数量
  7305. $rows[$key] = array(
  7306. 'warehouse' => ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $value['warehouse'],
  7307. 'sku' => $value['sku'],
  7308. 'title' => isset($value['title']) ? $value['title'] : '',
  7309. 'number' => $c,
  7310. 'features' => $zh,
  7311. 'hb' => $c + $zt,
  7312. );
  7313. }
  7314. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7315. $filename = $title . ".xls";
  7316. $headers = array('仓库', 'SKU', '产品', '库存数量', '在途数量及预达日期', '在途+库存数量');
  7317. $numkeys = array('number', 'hb');
  7318. //列宽与表头一一对应(单位≈字符数);SKU(1)、产品(2)、在途列(4)超宽自动换行
  7319. $colwidths = array(80, 300,450, 50, 120, 80);
  7320. $wrapcols = array(1, 2, 4);
  7321. $excelxml($rows, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7322. }
  7323. if (isset($_GET['excel'])) {
  7324. $warehouse = $this->input->get('warehouse', true);
  7325. $sku = $this->input->get('sku', true);
  7326. $cz = $this->input->get('cz', true);
  7327. $text = $this->input->post('text', true);
  7328. $xztime = $this->input->get('xztime', true);
  7329. $timetk = $this->input->get('timetk', true);
  7330. $timetj = $this->input->get('timetj', true);
  7331. $timetk = strtotime($timetk);
  7332. $timetj = strtotime($timetj);
  7333. $where = "time = '0' ";
  7334. if ($warehouse) {
  7335. $where .= " and warehouse = '$warehouse'";
  7336. }
  7337. if ($sku) {
  7338. $where .= " and sku = '$sku'";
  7339. }
  7340. if ($text) {
  7341. $where .= " and text like '%$text%'";
  7342. }
  7343. if ($cz != '') {
  7344. $where .= " and cz = '$cz'";
  7345. }
  7346. if ($timetk && $timetj) {
  7347. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7348. }
  7349. //数据排序
  7350. $order_str = $xztime . " desc";
  7351. //取得信息列表
  7352. $zh = array();
  7353. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7354. foreach ($info_list as $v) {
  7355. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7356. $warehouse = $this->warehouse->read($v['warehouse']);
  7357. $v['warehouse'] = ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $v['warehouse'];
  7358. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7359. $v['stime'] = date('Y-m-d', $v['stime']);
  7360. if (isset($zh[$v['features']])) {
  7361. $zh[$v['features']]['num'] += $v['num'];
  7362. } else {
  7363. $zh[$v['features']] = $v;
  7364. }
  7365. $zh[$v['features']]['features'] = $c;
  7366. }
  7367. $title = "在途数据" . date('Y-m-d', time());
  7368. $filename = $title . ".xls";
  7369. $headers = array('仓库', 'SKU', '名称', '在途数量', '库存数量', '添加在途日期', '预达日期', '备注');
  7370. $numkeys = array('num', 'features');
  7371. //列宽与表头一一对应(单位≈字符数);SKU(1)、名称(2)、备注(7)超宽自动换行
  7372. $colwidths = array(18, 20, 50, 12, 12, 20, 12, 40);
  7373. $wrapcols = array(1, 2, 7);
  7374. $excelxml($zh, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7375. }
  7376. }
  7377. public function _fc()
  7378. {
  7379. $vip = 0;
  7380. if (isset($_SESSION['api'])) {
  7381. $user = $this->user->get_api($_SESSION['api']);
  7382. if ($user['vip'] == 1) {
  7383. $vip = 1;
  7384. }
  7385. } else {
  7386. header('Location: /');
  7387. exit;
  7388. }
  7389. $post = $this->input->post(NULL, TRUE);
  7390. if (isset($post['page'])) {
  7391. $page = $this->input->post('page', true);
  7392. $perpage = $this->input->post('perpage', true);
  7393. $category = $this->input->post('category', true);
  7394. $size = $this->input->post('size', true);
  7395. $grade = $this->input->post('grade', true);
  7396. $color = $this->input->post('color', true);
  7397. $lowe = $this->input->post('lowe', true);
  7398. $sku = $this->input->post('sku');
  7399. $title = $this->input->post('title');
  7400. $warehouse = $this->input->post('warehouse', true);
  7401. $usa = $this->input->post('usa', true);
  7402. $purchase = $this->input->post('purchase', true);
  7403. $lacetype = $this->input->post('lacetype', true);
  7404. $haircap = $this->input->post('haircap', true);
  7405. $density = $this->input->post('density', true);
  7406. $details = $this->input->post('details', true);
  7407. $state = $this->input->post('state', true);
  7408. $ktime = $this->input->post('ktime', true);
  7409. $jtime = $this->input->post('jtime', true);
  7410. $ktime = strtotime($ktime);
  7411. $jtime = strtotime($jtime);
  7412. $where = "state = '11'";
  7413. $gj = "";
  7414. $ck = "";
  7415. if ($lacetype) {
  7416. $where .= " and features like '%-$lacetype-%'";
  7417. }
  7418. if ($category) {
  7419. $where .= " and features like '%-$category-%'";
  7420. }
  7421. if ($size) {
  7422. $where .= " and features like '%-$size-%'";
  7423. }
  7424. if ($grade) {
  7425. $where .= " and features like '%-$grade-%'";
  7426. }
  7427. if ($color) {
  7428. $where .= " and features like '%-$color-%'";
  7429. }
  7430. if ($lowe) {
  7431. $where .= " and features like '%-$lowe-%'";
  7432. }
  7433. if ($haircap) {
  7434. $where .= " and features like '%-$haircap-%'";
  7435. }
  7436. if ($density) {
  7437. $where .= " and features like '%-$density-%'";
  7438. }
  7439. if ($usa) {
  7440. if (!$warehouse) {
  7441. $where .= " and (warehouse = '5' or warehouse = '8')";
  7442. }
  7443. }
  7444. if ($warehouse) {
  7445. $where .= " and warehouse = '$warehouse'";
  7446. }
  7447. if ($details) {
  7448. $where .= " and details = '$details'";
  7449. }
  7450. if ($purchase) {
  7451. $where .= " and purchase = '$purchase'";
  7452. }
  7453. if ($state) {
  7454. $where .= " and state = '$state'";
  7455. }
  7456. if ($ktime && $jtime) {
  7457. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7458. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7459. }
  7460. //数据排序
  7461. $order_str = "id desc";
  7462. if (empty($page)) {
  7463. $start = 0;
  7464. $perpage = 1;
  7465. } else {
  7466. $start = ($page - 1) * $perpage;
  7467. }
  7468. if ($sku) {
  7469. $sku = trim($sku, ' ');
  7470. $sku = trim($sku, ' ');
  7471. $where .= " and sku like '%$sku%'";
  7472. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7473. } else if ($title) {
  7474. $title = trim($title, ' ');
  7475. $title = trim($title, ' ');
  7476. $where .= " and title like '%$title%'";
  7477. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7478. } else {
  7479. //$where .= " and time > '$ktime' and time < '$jtime'";
  7480. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7481. }
  7482. //取得信息列表
  7483. $rows = array();
  7484. $list = array();
  7485. foreach ($info_list as $key => $value) {
  7486. $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'] . '"');
  7487. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7488. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7489. $warehouse = $this->warehouse->read($value['warehouse']);
  7490. $info_list[$key]['warehouse'] = $warehouse['title'];
  7491. $info_list[$key]['number'] = $g;
  7492. $info_list[$key]['features'] = $x;
  7493. $info_list[$key]['x'] = $s;
  7494. }
  7495. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7496. $pagenum = ceil($total / $perpage);
  7497. $over = $total - ($start + $perpage);
  7498. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7499. echo json_encode($rows);
  7500. exit;
  7501. }
  7502. $this->data['vip'] = $vip;
  7503. $this->_Template('whlabel_fc', $this->data);
  7504. }
  7505. public function _fcmb()
  7506. {
  7507. $where = "sku != 'Preset'";
  7508. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7509. foreach ($rows as $k => $v) {
  7510. $warehouse = $this->warehouse->read($v['warehouse']);
  7511. $rows[$k]['warehouse'] = $warehouse['title'];
  7512. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7513. $rows[$k]['t'] = '';
  7514. $rows[$k]['n'] = '';
  7515. }
  7516. $title = "封货产品数据导入模板";
  7517. $titlename = "<table border=1>
  7518. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7519. <tr align='center'>
  7520. <td>仓库</td>
  7521. <td>SKU</td>
  7522. <td>产品</td>
  7523. <td>封存产品总数量</td>
  7524. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7525. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7526. </tr>
  7527. </table>";
  7528. $filename = $title . ".xls";
  7529. $tail = "";
  7530. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7531. }
  7532. public function _fcexcel()
  7533. {
  7534. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7535. $config['upload_path'] = '.' . $dir;
  7536. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7537. $config['allowed_types'] = 'xls|xlsx|csv';
  7538. $config['max_size'] = 10240;
  7539. $this->load->library('upload', $config);
  7540. $this->upload->initialize($config);
  7541. if ($this->upload->do_upload('userfile')) {
  7542. $full_path = $dir . $this->upload->data('file_name');
  7543. $fileName = '.' . $full_path;
  7544. if (!file_exists($fileName)) {
  7545. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7546. exit;
  7547. } else {
  7548. libxml_use_internal_errors(true);
  7549. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7550. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7551. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7552. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7553. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7554. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7555. ++$column; //如果列数大于26行
  7556. $list = array();
  7557. for ($i = 2; $i <= $row; $i++) // 行数循环
  7558. {
  7559. $data = array();
  7560. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7561. {
  7562. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7563. }
  7564. $list[] = $data;
  7565. }
  7566. }
  7567. $i = 0;
  7568. $j = 0;
  7569. $ed = array();
  7570. foreach ($list as $key => $value) {
  7571. $time = time();
  7572. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7573. continue;
  7574. }
  7575. $warehouse = $this->warehouse->get_title($value['0']);
  7576. $sku = $value['1'];
  7577. $type = $value['4']; //调整方式0扣减1删除
  7578. $num = $value['5']; //调整数量
  7579. //$text = $value['4'];//扣减说明
  7580. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7581. if (!$d) //如果没有这个SKU
  7582. {
  7583. $ed[] = array($sku . '-库存中不存在此SKU');
  7584. $j++;
  7585. continue;
  7586. }
  7587. if (!isset($warehouse['id'])) {
  7588. $ed[] = array($sku . '-仓库名错误!');
  7589. $j++;
  7590. continue;
  7591. }
  7592. if ($type == 1 || $type == 2) //扣减库存
  7593. {
  7594. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7595. if (count($data) < abs($num)) {
  7596. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7597. $j++;
  7598. continue;
  7599. }
  7600. if ($type == 1) //转入库存
  7601. {
  7602. for ($i = 0; $i < abs($num); $i++) {
  7603. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7604. }
  7605. } else if ($type == 2) //删除
  7606. {
  7607. for ($i = 0; $i < abs($num); $i++) {
  7608. $this->whlabel->remove($data[$i]['id']);
  7609. }
  7610. }
  7611. } else if ($type == 0) //增加库存
  7612. {
  7613. $post['sku'] = $d['sku'];
  7614. $post['shop'] = '';
  7615. $post['warehouse'] = $warehouse['id'];
  7616. $post['purchase'] = $d['purchase'];
  7617. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7618. $post['state'] = 11;
  7619. $post['title'] = $d['title'];
  7620. $post['number'] = $d['number'];
  7621. $post['features'] = $d['features'];
  7622. $post['enter'] = $time;
  7623. $post['time'] = $time; //操作时间
  7624. for ($i = 0; $i < $num; $i++) {
  7625. $post['label'] = time() . rand(100, 999) . $i;
  7626. $this->whlabel->insert($post);
  7627. }
  7628. }
  7629. sleep(1); //防止入库时间一样,需要延迟1秒
  7630. }
  7631. if ($j > 0) {
  7632. $tt = date('Ymd', time());
  7633. $title = '库存导入错误信息-' . $tt;
  7634. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7635. $tail = "\n";
  7636. $filename = $title . ".xls";
  7637. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7638. $dir = '/data/excel/' . $time . '/';
  7639. $file_name = 'error_' . $time . rand(1000, 9999);
  7640. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7641. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7642. fwrite($myfile, $ecl);
  7643. fclose($myfile);
  7644. $error = $dir . $file_name . '.xls';
  7645. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7646. exit;
  7647. } else {
  7648. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7649. exit;
  7650. }
  7651. }
  7652. }
  7653. public function _fcjxc($arg_array)
  7654. {
  7655. if (isset($_GET['excel'])) {
  7656. $category = $this->input->get('category', true);
  7657. $size = $this->input->get('size', true);
  7658. $grade = $this->input->get('grade', true);
  7659. $color = $this->input->get('color', true);
  7660. $lowe = $this->input->get('lowe', true);
  7661. $sku = $this->input->get('sku');
  7662. $title = $this->input->get('title');
  7663. $warehouse = $arg_array[0];
  7664. $usa = $this->input->get('usa', true);
  7665. $purchase = $this->input->get('purchase', true);
  7666. $lacetype = $this->input->get('lacetype', true);
  7667. $haircap = $this->input->get('haircap', true);
  7668. $density = $this->input->get('density', true);
  7669. $title = $this->input->get('title', true);
  7670. $state = $this->input->get('state', true);
  7671. $ktime = $this->input->get('ktime', true);
  7672. $jtime = $this->input->get('jtime', true);
  7673. $where = "state=11";
  7674. $gj = "";
  7675. $ck = "";
  7676. if ($lacetype) {
  7677. $where .= " and features like '%-$lacetype-%'";
  7678. }
  7679. if ($category) {
  7680. $where .= " and features like '%-$category-%'";
  7681. }
  7682. if ($size) {
  7683. $where .= " and features like '%-$size-%'";
  7684. }
  7685. if ($grade) {
  7686. $where .= " and features like '%-$grade-%'";
  7687. }
  7688. if ($color) {
  7689. $where .= " and features like '%-$color-%'";
  7690. }
  7691. if ($lowe) {
  7692. $where .= " and features like '%-$lowe-%'";
  7693. }
  7694. if ($haircap) {
  7695. $where .= " and features like '%-$haircap-%'";
  7696. }
  7697. if ($density) {
  7698. $where .= " and features like '%-$density-%'";
  7699. }
  7700. if ($usa) {
  7701. if (!$warehouse) {
  7702. $where .= " and (warehouse = '5' or warehouse = '8')";
  7703. }
  7704. }
  7705. if ($warehouse) {
  7706. $where .= " and warehouse = '$warehouse'";
  7707. }
  7708. if ($purchase) {
  7709. $where .= " and purchase = '$purchase'";
  7710. }
  7711. if ($state) {
  7712. $where .= " and state = '$state'";
  7713. }
  7714. $order_str = "id desc";
  7715. if ($sku) {
  7716. $sku = trim($sku, ' ');
  7717. $sku = trim($sku, ' ');
  7718. $where .= " and sku like '%$sku%'";
  7719. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7720. } else if ($title) {
  7721. $title = trim($title, ' ');
  7722. $title = trim($title, ' ');
  7723. $where .= " and title like '%$title%'";
  7724. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7725. } else {
  7726. //$where .= " and time > '$ktime' and time < '$jtime'";
  7727. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7728. }
  7729. //取得信息列表
  7730. $rows = array();
  7731. $list = array();
  7732. foreach ($info_list as $key => $value) {
  7733. $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'] . '"');
  7734. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7735. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7736. $rows[$key] = $value;
  7737. $warehouse = $this->warehouse->read($value['warehouse']);
  7738. $rows[$key]['warehouse'] = $warehouse['title'];
  7739. $rows[$key]['features'] = $g;
  7740. $rows[$key]['a'] = $x;
  7741. $rows[$key]['b'] = $s;
  7742. }
  7743. $title = "总统计表";
  7744. $titlename = "<table border=1>
  7745. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7746. <tr align='center'>
  7747. <td>仓库</td>
  7748. <td>SKU</td>
  7749. <td>产品名称</td>
  7750. <td>录入总量</td>
  7751. <td>取出总量</td>
  7752. <td>剩余总量</td>
  7753. </tr>
  7754. </table>";
  7755. $filename = $title . ".xls";
  7756. $tail = "";
  7757. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7758. }
  7759. $vip = 0;
  7760. if (isset($_SESSION['api'])) {
  7761. $user = $this->user->get_api($_SESSION['api']);
  7762. if ($user['vip'] == 1) {
  7763. $vip = 1;
  7764. }
  7765. } else {
  7766. header('Location: /');
  7767. exit;
  7768. }
  7769. $post = $this->input->post(NULL, TRUE);
  7770. if (isset($post['page'])) {
  7771. $page = $this->input->post('page', true);
  7772. $perpage = $this->input->post('perpage', true);
  7773. $category = $this->input->post('category', true);
  7774. $size = $this->input->post('size', true);
  7775. $grade = $this->input->post('grade', true);
  7776. $color = $this->input->post('color', true);
  7777. $lowe = $this->input->post('lowe', true);
  7778. $sku = $this->input->post('sku');
  7779. $title = $this->input->post('title');
  7780. $warehouse = $arg_array[0];
  7781. $usa = $this->input->post('usa', true);
  7782. $purchase = $this->input->post('purchase', true);
  7783. $lacetype = $this->input->post('lacetype', true);
  7784. $haircap = $this->input->post('haircap', true);
  7785. $density = $this->input->post('density', true);
  7786. $title = $this->input->post('title', true);
  7787. $state = $this->input->post('state', true);
  7788. $ktime = $this->input->post('ktime', true);
  7789. $jtime = $this->input->post('jtime', true);
  7790. $ktime = strtotime($ktime);
  7791. $jtime = strtotime($jtime);
  7792. $where = "state=11";
  7793. $gj = "";
  7794. $ck = "";
  7795. if ($lacetype) {
  7796. $where .= " and features like '%-$lacetype-%'";
  7797. }
  7798. if ($category) {
  7799. $where .= " and features like '%-$category-%'";
  7800. }
  7801. if ($size) {
  7802. $where .= " and features like '%-$size-%'";
  7803. }
  7804. if ($grade) {
  7805. $where .= " and features like '%-$grade-%'";
  7806. }
  7807. if ($color) {
  7808. $where .= " and features like '%-$color-%'";
  7809. }
  7810. if ($lowe) {
  7811. $where .= " and features like '%-$lowe-%'";
  7812. }
  7813. if ($haircap) {
  7814. $where .= " and features like '%-$haircap-%'";
  7815. }
  7816. if ($density) {
  7817. $where .= " and features like '%-$density-%'";
  7818. }
  7819. if ($usa) {
  7820. if (!$warehouse) {
  7821. $where .= " and (warehouse = '5' or warehouse = '8')";
  7822. }
  7823. }
  7824. if ($warehouse) {
  7825. $where .= " and warehouse = '$warehouse'";
  7826. }
  7827. if ($purchase) {
  7828. $where .= " and purchase = '$purchase'";
  7829. }
  7830. if ($state) {
  7831. $where .= " and state = '$state'";
  7832. }
  7833. if ($ktime && $jtime) {
  7834. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7835. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7836. }
  7837. //数据排序
  7838. $order_str = "id desc";
  7839. $xs = 0;
  7840. $rows = array();
  7841. $list = array();
  7842. if (empty($page)) {
  7843. $start = 0;
  7844. $perpage = 1;
  7845. } else {
  7846. $start = ($page - 1) * $perpage;
  7847. }
  7848. if ($sku || $title) {
  7849. if ($title) {
  7850. $title = trim($title, ' ');
  7851. $title = trim($title, ' ');
  7852. $where .= " and title like '%$title%'";
  7853. } else {
  7854. $sku = trim($sku, ' ');
  7855. $sku = trim($sku, ' ');
  7856. $where .= " and sku like '%$sku%'";
  7857. }
  7858. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7859. foreach ($info_list as $key => $value) {
  7860. $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'] . '"');
  7861. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7862. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7863. $rows[$key] = $value;
  7864. $warehouse = $this->warehouse->read($value['warehouse']);
  7865. $rows[$key]['warehouse'] = $warehouse['title'];
  7866. $rows[$key]['features'] = $g;
  7867. $rows[$key]['a'] = $x;
  7868. $rows[$key]['b'] = $s;
  7869. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7870. $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天销量
  7871. $yj = $c / ($xl / 30);
  7872. if ($yj < 7) {
  7873. $rows[$key]['y'] = round($yj) . '天销量';
  7874. } else {
  7875. $rows[$key]['y'] = '正常';
  7876. }
  7877. }
  7878. } else {
  7879. //$where .= " and time > '$ktime' and time < '$jtime'";
  7880. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7881. foreach ($info_list as $key => $value) {
  7882. $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'] . '"');
  7883. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7884. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7885. $zs[$key] = $value;
  7886. $warehouse = $this->warehouse->read($value['warehouse']);
  7887. $zs[$key]['warehouse'] = $warehouse['title'];
  7888. $zs[$key]['features'] = $g;
  7889. $zs[$key]['a'] = $x;
  7890. $zs[$key]['b'] = $s;
  7891. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7892. $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天销量
  7893. $yj = $c / ($xl / 30);
  7894. if ($yj < 7) {
  7895. $zs[$key]['y'] = round($yj) . '天销量';
  7896. $rows[$key] = $zs[$key];
  7897. }
  7898. }
  7899. }
  7900. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7901. $pagenum = ceil($total / $perpage);
  7902. $over = $total - ($start + $perpage);
  7903. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7904. echo json_encode($rows);
  7905. exit;
  7906. }
  7907. $this->data['arg_array'] = $arg_array[0];
  7908. $this->_Template('whlabel_fcjxc', $this->data);
  7909. }
  7910. public function _0kcdel()
  7911. {
  7912. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7913. $config['upload_path'] = '.' . $dir;
  7914. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7915. $config['allowed_types'] = 'xls|xlsx|csv';
  7916. $config['max_size'] = 10240;
  7917. $this->load->library('upload', $config);
  7918. $this->upload->initialize($config);
  7919. if ($this->upload->do_upload('userfile')) {
  7920. $full_path = $dir . $this->upload->data('file_name');
  7921. $fileName = '.' . $full_path;
  7922. if (!file_exists($fileName)) {
  7923. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7924. exit;
  7925. } else {
  7926. require_once "./data/excel/PHPExcel/IOFactory.php";
  7927. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7928. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7929. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7930. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7931. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7932. ++$column; //如果列数大于26行
  7933. $list = array();
  7934. for ($i = 2; $i <= $row; $i++) // 行数循环
  7935. {
  7936. $data = array();
  7937. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7938. {
  7939. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7940. }
  7941. $list[] = $data;
  7942. }
  7943. }
  7944. $i = 0;
  7945. $j = 0;
  7946. $ed = array();
  7947. foreach ($list as $key => $value) {
  7948. $time = time();
  7949. if ($value['0'] == "" || $value['1'] == "") {
  7950. continue;
  7951. }
  7952. $warehouse = $this->warehouse->get_title($value['0']);
  7953. $sku = $value['1'];
  7954. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7955. if (!$d) //如果没有这个SKU
  7956. {
  7957. $ed[] = array($sku . '-库存中不存在此SKU');
  7958. $j++;
  7959. continue;
  7960. }
  7961. if (!isset($warehouse['id'])) {
  7962. $ed[] = array($sku . '-仓库名错误!');
  7963. $j++;
  7964. continue;
  7965. }
  7966. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7967. if ($z < 1) {
  7968. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7969. foreach ($z as $v) {
  7970. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7971. if (count($zt) > 0) {
  7972. $ed[] = array($sku . '-有在途库存无法删除!');
  7973. $j++;
  7974. continue;
  7975. }
  7976. $tmp_info = $v;
  7977. $tmp_info['del_time'] = time();
  7978. $this->db->insert('whlabelscbf',$tmp_info);
  7979. $this->whlabel->remove($v['id']);
  7980. }
  7981. } else {
  7982. $ed[] = array($sku . '-非0库存!');
  7983. $j++;
  7984. continue;
  7985. }
  7986. }
  7987. if ($j > 0) {
  7988. $tt = date('Ymd', time());
  7989. $title = '删除0库存错误信息-' . $tt;
  7990. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7991. $tail = "\n";
  7992. $filename = $title . ".xls";
  7993. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7994. $dir = '/data/excel/' . $time . '/';
  7995. $file_name = 'error_' . $time . rand(1000, 9999);
  7996. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7997. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7998. fwrite($myfile, $ecl);
  7999. fclose($myfile);
  8000. $error = $dir . $file_name . '.xls';
  8001. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  8002. exit;
  8003. } else {
  8004. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  8005. exit;
  8006. }
  8007. }
  8008. }
  8009. public function _gbhtype()
  8010. {
  8011. $post = $this->input->post(NULL, TRUE);
  8012. if (isset($post['s'])) {
  8013. $n = $this->input->post('n');
  8014. $d = $this->input->post('s');
  8015. if (!$d) {
  8016. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  8017. exit;
  8018. }
  8019. $d = explode(',', trim($d, ','));
  8020. $t = $this->whlabel_type->read($n);
  8021. //循环删除记录
  8022. foreach ($d as $v) {
  8023. $u = $this->whlabel->read($v);
  8024. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  8025. foreach ($data as $val) {
  8026. $this->whlabel->save(array('type' => $n), $val['id']);
  8027. }
  8028. }
  8029. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  8030. }
  8031. }
  8032. //出库、退库导出
  8033. public function _dccrtype()
  8034. {
  8035. $classid = $this->classid->sku();
  8036. $pm = $classid;
  8037. $typeclass = array();
  8038. $tc = $this->typeclass->find_all();
  8039. foreach ($tc as $v) {
  8040. $typeclass[$v['id']] = $v;
  8041. }
  8042. $prc = array();
  8043. $purchase = $this->purchase->find_all();
  8044. foreach ($purchase as $k => $v) {
  8045. $prc[$v['id']] = $v['title'];
  8046. }
  8047. if (isset($_GET['sid'])) {
  8048. $wh = array();
  8049. $w = $this->warehouse->find_all('1=1', 'id,title');
  8050. foreach ($w as $v) {
  8051. $wh[$v['id']] = $v['title'];
  8052. }
  8053. $type = $this->input->get('excel', true);
  8054. $category = $this->input->get('category', true);
  8055. $size = $this->input->get('size', true);
  8056. $grade = $this->input->get('grade', true);
  8057. $color = $this->input->get('color', true);
  8058. $lowe = $this->input->get('lowe', true);
  8059. $sku = $this->input->get('sku', true);
  8060. $warehouse = $this->input->get('warehouse', true);
  8061. $lacetype = $this->input->get('lacetype', true);
  8062. $lacecolor = $this->input->get('lacecolor', true);
  8063. $density = $this->input->get('density', true);
  8064. $haircap = $this->input->get('haircap', true);
  8065. $purchase = $this->input->get('purchase', true);
  8066. $title = $this->input->get('title', true);
  8067. $state = $this->input->get('state', true);
  8068. $sid = $this->input->get('sid', true);
  8069. $ktime = $this->input->get('ktime', true);
  8070. $jtime = $this->input->get('jtime', true);
  8071. $ktime = strtotime($ktime);
  8072. $jtime = strtotime($jtime);
  8073. $where = "1=1";
  8074. $gj = "";
  8075. $ck = "";
  8076. if ($category) {
  8077. $where .= " and features like '%-$category-%'";
  8078. }
  8079. if ($size) {
  8080. $where .= " and features like '%-$size-%'";
  8081. }
  8082. if ($grade) {
  8083. $where .= " and features like '%-$grade-%'";
  8084. }
  8085. if ($color) {
  8086. $where .= " and features like '%-$color-%'";
  8087. }
  8088. if ($lowe) {
  8089. $where .= " and features like '%-$lowe-%'";
  8090. }
  8091. if ($warehouse) {
  8092. $where .= " and warehouse = '$warehouse'";
  8093. }
  8094. if ($purchase) {
  8095. $where .= " and purchase = '$purchase'";
  8096. }
  8097. if ($state) {
  8098. $where .= " and state = '$state'";
  8099. }
  8100. if ($lacetype) {
  8101. $where .= " and features like '%-$lacetype-%'";
  8102. }
  8103. if ($lacecolor) {
  8104. $where .= " and features like '%-$lacecolor-%'";
  8105. }
  8106. if ($density) {
  8107. $where .= " and features like '%-$density-%'";
  8108. }
  8109. if ($haircap) {
  8110. $where .= " and features like '%-$haircap-%'";
  8111. }
  8112. if ($title) {
  8113. $title = trim($title, ' ');
  8114. $title = trim($title, ' ');
  8115. $where .= " and title like '%$title%'";
  8116. }
  8117. if ($sku) {
  8118. $sku = trim($sku, ' ');
  8119. $sku = trim($sku, ' ');
  8120. $where .= " and sku like '%$sku%'";
  8121. }
  8122. if ($ktime && $jtime) {
  8123. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8124. }
  8125. $sidwhere = '';
  8126. if ($sid) {
  8127. $sd = "";
  8128. $s = explode(',', trim($sid, ','));
  8129. foreach ($s as $value) {
  8130. $sd .= " id = " . $value . " or";
  8131. }
  8132. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8133. }
  8134. //数据排序
  8135. $order_str = "time desc";
  8136. if (empty($page)) {
  8137. $start = 0;
  8138. $perpage = 1;
  8139. } else {
  8140. $start = ($page - 1) * $perpage;
  8141. }
  8142. $wh = array();
  8143. $w = $this->warehouse->find_all('1=1', 'id,title');
  8144. foreach ($w as $v) {
  8145. $wh[$v['id']] = $v['title'];
  8146. }
  8147. $wt = array();
  8148. $whlabel_type = $this->whlabel_type->find_all();
  8149. foreach ($whlabel_type as $v) {
  8150. $wt[$v['id']] = $v['title'];
  8151. }
  8152. $classid = $this->classid->sku();
  8153. $list = array();
  8154. $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');
  8155. foreach ($rows_r as $key => $value) {
  8156. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8157. $pm = $classid;
  8158. $jm = $classid;
  8159. $rows_r[$key]['enter'] = '入库';
  8160. $rows_r[$key]['time'] = $value['enter'];
  8161. if ($value['rktype'] == 1) {
  8162. $rows_r[$key]['rktype'] = '采购入库';
  8163. } else if ($value['rktype'] == 2) {
  8164. $rows_r[$key]['rktype'] = '盘盈调整';
  8165. } else if ($value['rktype'] == 3) {
  8166. $rows_r[$key]['rktype'] = '其他调整入库';
  8167. } else if ($value['rktype'] == 4) {
  8168. $rows_r[$key]['rktype'] = '其他调整入库';
  8169. } else if ($value['rktype'] == 5) {
  8170. $rows_r[$key]['rktype'] = '退库入库';
  8171. } else if ($value['rktype'] == 6) {
  8172. $rows_r[$key]['rktype'] = '退货可用入库';
  8173. } else if ($value['rktype'] == 7) {
  8174. $rows_r[$key]['rktype'] = '形态转换入库';
  8175. } else {
  8176. $rows_r[$key]['rktype'] = '';
  8177. }
  8178. $features = explode('-', trim($value['features'], '-'));
  8179. foreach ($features as $v) {
  8180. if (isset($typeclass[$v])) {
  8181. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8182. $pm[$typeclass[$v]['classid']] = $zh[0];
  8183. }
  8184. if (isset($typeclass[$v])) {
  8185. if (isset($jm[$typeclass[$v]['classid']])) {
  8186. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8187. }
  8188. }
  8189. }
  8190. $zh = implode(" ", $pm);
  8191. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8192. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8193. $rows_r[$key]['zh'] = $zh;
  8194. $jm = array_filter($jm);
  8195. $rows_r[$key]['features'] = implode("-", $jm);
  8196. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8197. }
  8198. $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');
  8199. foreach ($rows_c as $key => $value) {
  8200. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8201. $pm = $classid;
  8202. $jm = $classid;
  8203. $rows_c[$key]['time'] = $value['outk'];
  8204. $rows_c[$key]['outk'] = '出库';
  8205. if ($value['cktype'] == 1) {
  8206. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8207. } else if ($value['cktype'] == 2) {
  8208. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8209. } else if ($value['cktype'] == 3) {
  8210. $rows_c[$key]['cktype'] = '盘亏调整';
  8211. } else if ($value['cktype'] == 4) {
  8212. $rows_c[$key]['cktype'] = '其他调整出库';
  8213. } else if ($value['cktype'] == 5) {
  8214. $rows_c[$key]['cktype'] = '形态转换出库';
  8215. } else {
  8216. $rows_c[$key]['cktype'] = '';
  8217. }
  8218. unset($rows_c[$key]['state']);
  8219. $features = explode('-', trim($value['features'], '-'));
  8220. foreach ($features as $v) {
  8221. if (isset($typeclass[$v])) {
  8222. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8223. $pm[$typeclass[$v]['classid']] = $zh[0];
  8224. }
  8225. if (isset($typeclass[$v])) {
  8226. if (isset($jm[$typeclass[$v]['classid']])) {
  8227. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8228. }
  8229. }
  8230. }
  8231. $zh = implode(" ", $pm);
  8232. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8233. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8234. $rows_c[$key]['zh'] = $zh;
  8235. $jm = array_filter($jm);
  8236. $rows_c[$key]['features'] = implode("-", $jm);
  8237. $rows_c[$key]['number'] = 1;
  8238. }
  8239. $merged = $rows_r;
  8240. foreach ($rows_c as $key => $value) {
  8241. if (isset($merged[$key])) {
  8242. $merged[] = $value;
  8243. } else {
  8244. $merged[$key] = $value;
  8245. }
  8246. }
  8247. usort($merged, function ($a, $b) {
  8248. return $a['time'] - $b['time'];
  8249. });
  8250. foreach ($merged as $key => $value) {
  8251. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8252. }
  8253. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8254. $titlename = "<table border=1>
  8255. <tr align='center'>
  8256. <td>仓库</td>
  8257. <td>SKU</td>
  8258. <td>商品名称</td>
  8259. <td>仓库品名</td>
  8260. <td>料号</td>
  8261. <td>时间</td>
  8262. <td>操作</td>
  8263. <td>类型</td>
  8264. <td>数量</td>
  8265. <td>备注</td>
  8266. </tr>
  8267. </table>";
  8268. $filename = $title . ".xlsx";
  8269. $tail = "";
  8270. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8271. }
  8272. }
  8273. /*************************************处理exceljs导出****************************************************/
  8274. public function _excelrjs(){
  8275. if (isset($_GET['excel'])) {
  8276. $category = $this->input->get('category', true);
  8277. $size = $this->input->get('size', true);
  8278. $grade = $this->input->get('grade', true);
  8279. $color = $this->input->get('color', true);
  8280. $lowe = $this->input->get('lowe', true);
  8281. $sku = $this->input->get('sku', true);
  8282. $warehouse = $this->input->get('warehouse', true);
  8283. $purchase = $this->input->get('purchase', true);
  8284. $ktime = $this->input->get('ktime', true);
  8285. $jtime = $this->input->get('jtime', true);
  8286. $ktime = strtotime($ktime);
  8287. $jtime = strtotime($jtime);
  8288. $where = "1=1";
  8289. $gj = "";
  8290. $ck = "";
  8291. if ($category) {
  8292. $where .= " and features like '%-$category-%'";
  8293. }
  8294. if ($size) {
  8295. $where .= " and features like '%-$size-%'";
  8296. }
  8297. if ($grade) {
  8298. $where .= " and features like '%-$grade-%'";
  8299. }
  8300. if ($color) {
  8301. $where .= " and features like '%-$color-%'";
  8302. }
  8303. if ($lowe) {
  8304. $where .= " and features like '%-$lowe-%'";
  8305. }
  8306. if ($warehouse) {
  8307. $where .= " and warehouse = '$warehouse'";
  8308. }
  8309. if ($purchase) {
  8310. $where .= " and purchase = '$purchase'";
  8311. }
  8312. if ($sku) {
  8313. $where .= " and sku = '$sku'";
  8314. }
  8315. if ($ktime && $jtime) {
  8316. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8317. }
  8318. //数据排序
  8319. $order_str = "id desc";
  8320. if (empty($page)) {
  8321. $start = 0;
  8322. $perpage = 1;
  8323. } else {
  8324. $start = ($page - 1) * $perpage;
  8325. }
  8326. $list = array();
  8327. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8328. foreach ($rows as $value) {
  8329. $ck = $this->warehouse->read($value['warehouse']);
  8330. $warehouse = $ck['title'];
  8331. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8332. $retreatwarehouse = $tkck['title'];
  8333. $gy = $this->purchase->read($value['purchase']);
  8334. $purchase = $gy['title'];
  8335. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8336. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8337. }
  8338. if(empty($list)){
  8339. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8340. }else{
  8341. $final_list = [];
  8342. foreach($list as $v){
  8343. $final_list[] = array_values($v);
  8344. }
  8345. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8346. array_unshift($final_list,[
  8347. "仓库","SKU","商品名称","时间","数量"
  8348. ]);
  8349. array_unshift($final_list,[
  8350. $title,"","","",""
  8351. ]);
  8352. $merges = [
  8353. [
  8354. "s"=>["r"=>0,"c"=>0],
  8355. "e"=>["r"=>0,"c"=>4]
  8356. ]
  8357. ];
  8358. $cols = [
  8359. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8360. ];
  8361. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8362. }
  8363. }
  8364. }
  8365. //出库、退库导出
  8366. public function _excelctjs()
  8367. {
  8368. $classid = $this->classid->sku();
  8369. $pm = $classid;
  8370. $typeclass = array();
  8371. $tc = $this->typeclass->find_all();
  8372. foreach ($tc as $v) {
  8373. $typeclass[$v['id']] = $v;
  8374. }
  8375. $prc = array();
  8376. $purchase = $this->purchase->find_all();
  8377. foreach ($purchase as $k => $v) {
  8378. $prc[$v['id']] = $v['title'];
  8379. }
  8380. if (isset($_GET['excel'])) {
  8381. $wh = array();
  8382. $w = $this->warehouse->find_all('1=1', 'id,title');
  8383. foreach ($w as $v) {
  8384. $wh[$v['id']] = $v['title'];
  8385. }
  8386. $type = $this->input->get('excel', true);
  8387. $category = $this->input->get('category', true);
  8388. $size = $this->input->get('size', true);
  8389. $grade = $this->input->get('grade', true);
  8390. $color = $this->input->get('color', true);
  8391. $lowe = $this->input->get('lowe', true);
  8392. $sku = $this->input->get('sku', true);
  8393. $title = $this->input->get('title', true);
  8394. $warehouse = $this->input->get('warehouse', true);
  8395. $purchase = $this->input->get('purchase', true);
  8396. $lacetype = $this->input->get('lacetype', true);
  8397. $haircap = $this->input->get('haircap', true);
  8398. $lacecolor = $this->input->get('lacecolor', true);
  8399. $density = $this->input->get('density', true);
  8400. $details = $this->input->get('details', true);
  8401. $state = $this->input->get('state', true);
  8402. $shop = $this->input->get('shop', true);
  8403. $hairnumber = $this->input->get('hairnumber', true);
  8404. $type_leixi = $this->input->get('type', true);
  8405. $cpbz = $this->input->get('cpbz', true);
  8406. $sm = $this->input->get('sm', true);
  8407. $sid = $this->input->get('sid', true);
  8408. $ktime = $this->input->get('ktime', true);
  8409. $jtime = $this->input->get('jtime', true);
  8410. $ktime = strtotime($ktime);
  8411. $jtime = strtotime($jtime);
  8412. //$where = " 1=1 ";
  8413. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8414. $where = " sku != '' ";
  8415. $gj = "";
  8416. $ck = "";
  8417. if ($category) {
  8418. $where .= " and features like '%-$category-%'";
  8419. }
  8420. if ($size) {
  8421. $where .= " and features like '%-$size-%'";
  8422. }
  8423. if ($grade) {
  8424. $where .= " and features like '%-$grade-%'";
  8425. }
  8426. if ($color) {
  8427. $where .= " and features like '%-$color-%'";
  8428. }
  8429. if ($lowe) {
  8430. $where .= " and features like '%-$lowe-%'";
  8431. }
  8432. if ($warehouse) {
  8433. $where .= " and warehouse = '$warehouse'";
  8434. }
  8435. if ($purchase) {
  8436. $where .= " and purchase = '$purchase'";
  8437. }
  8438. if ($state) {
  8439. $where .= " and state = '$state'";
  8440. }
  8441. if ($lacetype) {
  8442. $where .= " and features like '%-$lacetype-%'";
  8443. }
  8444. if ($lacecolor) {
  8445. $where .= " and features like '%-$lacecolor-%'";
  8446. }
  8447. if ($density) {
  8448. $where .= " and features like '%-$density-%'";
  8449. }
  8450. if ($haircap) {
  8451. $where .= " and features like '%-$haircap-%'";
  8452. }
  8453. if ($details) {
  8454. $where .= " and details = '$details'";
  8455. }
  8456. if ($shop) {
  8457. $where .= " and shop like '%$shop%'";
  8458. }
  8459. if ($title) {
  8460. $title = trim($title, ' ');
  8461. $title = trim($title, ' ');
  8462. $where .= " and title like '%$title%'";
  8463. }
  8464. if (!empty($hairnumber)) {
  8465. $where .= " and features like '%-128-%' ";
  8466. if ($hairnumber < 0) {
  8467. $class_list = $this->typeclass->find_all('classid = 43');
  8468. foreach ($class_list as $v) {
  8469. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8470. }
  8471. } else {
  8472. $where .= " and features like '%-$hairnumber-%'";
  8473. }
  8474. }
  8475. if ($type_leixi) {
  8476. $where .= " and type = '$type_leixi'";
  8477. }
  8478. if ($cpbz) {
  8479. $where .= " and cpbz like '%$cpbz%' ";
  8480. }
  8481. if ($sm) {
  8482. $where .= " and sm like '%$sm%' ";
  8483. }
  8484. if ($sku) {
  8485. $sku = trim($sku, ' ');
  8486. $sku = trim($sku, ' ');
  8487. $where .= " and sku like '%$sku%'";
  8488. }
  8489. if ($ktime && $jtime) {
  8490. if ($type == 1) {
  8491. $tl = '出库';
  8492. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8493. } else if ($type == 2) {
  8494. $tl = '退库';
  8495. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8496. } else if ($type == 3) {
  8497. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8498. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8499. } else if ($type == 4) {
  8500. $tl = '出库+零售';
  8501. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8502. } else if ($type == 5) {
  8503. $tl = '零售';
  8504. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8505. }
  8506. }
  8507. $sidwhere = '';
  8508. if ($sid) {
  8509. $sd = "";
  8510. $s = explode(',', trim($sid, ','));
  8511. foreach ($s as $value) {
  8512. $sd .= " id = " . $value . " or";
  8513. }
  8514. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8515. }
  8516. //数据排序
  8517. $order_str = "time desc";
  8518. if (empty($page)) {
  8519. $start = 0;
  8520. $perpage = 1;
  8521. } else {
  8522. $start = ($page - 1) * $perpage;
  8523. }
  8524. //取得信息列表
  8525. if ($type != 3 && $type != 5) {
  8526. if ($type == 1 || $type == 4) {
  8527. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8528. foreach ($info_list as $key => $value) {
  8529. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8530. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8531. $warehouse = $this->warehouse->read($value['warehouse']);
  8532. $info_list[$key]['warehouse'] = $warehouse['title'];
  8533. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8534. $features = explode('-', trim($features, '-'));
  8535. $pm = $classid;
  8536. foreach ($features as $k => $v) {
  8537. if ($v != 0) {
  8538. if (!isset($typeclass[$v])) {
  8539. continue;
  8540. }
  8541. if (isset($pm[$typeclass[$v]['classid']])) {
  8542. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8543. $tz = explode('|', $typeclass[$v]['zh']);
  8544. $pm[$typeclass[$v]['classid']] = $tz[0];
  8545. } else {
  8546. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8547. }
  8548. }
  8549. }
  8550. }
  8551. $zh = implode(" ", $pm);
  8552. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8553. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8554. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8555. $info_list[$key]['features'] = $zh;
  8556. }
  8557. $final_list = [];
  8558. foreach($info_list as $k=>$v){
  8559. $number = "";
  8560. if(!empty($v['orderinfo'])){
  8561. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8562. if(!empty($tmp_info['number'])){
  8563. $number = $tmp_info['number'];
  8564. }
  8565. }
  8566. $final_list[] = [
  8567. 'warehouse'=>$v['warehouse'],
  8568. 'purchase'=>$v['purchase'],
  8569. 'sku'=>$v['sku'],
  8570. 'title'=>$v['title'],
  8571. 'features'=>$v['features'],
  8572. 'label'=>$v['label'],
  8573. 'orderinfo'=>$v['orderinfo'],
  8574. 'number'=>$number,
  8575. 'waybill'=>$v['waybill'],
  8576. 'outk'=>$v['outk'],
  8577. ];
  8578. }
  8579. } else {
  8580. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8581. foreach ($info_list as $key => $value) {
  8582. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8583. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8584. $warehouse = $this->warehouse->read($value['warehouse']);
  8585. $info_list[$key]['warehouse'] = $warehouse['title'];
  8586. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8587. $features = explode('-', trim($features, '-'));
  8588. $pm = $classid;
  8589. foreach ($features as $k => $v) {
  8590. if ($v != 0) {
  8591. if (!isset($typeclass[$v])) {
  8592. continue;
  8593. }
  8594. if (isset($pm[$typeclass[$v]['classid']])) {
  8595. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8596. $tz = explode('|', $typeclass[$v]['zh']);
  8597. $pm[$typeclass[$v]['classid']] = $tz[0];
  8598. } else {
  8599. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8600. }
  8601. }
  8602. }
  8603. }
  8604. $zh = implode(" ", $pm);
  8605. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8606. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8607. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8608. $info_list[$key]['features'] = $zh;
  8609. }
  8610. $final_list = [];
  8611. foreach($info_list as $k=>$v){
  8612. $number = "";
  8613. if(!empty($v['orderinfo'])){
  8614. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8615. if(!empty($tmp_info['number'])){
  8616. $number = $tmp_info['number'];
  8617. }
  8618. }
  8619. $final_list[] = [
  8620. 'warehouse'=>$v['warehouse'],
  8621. 'purchase'=>$v['purchase'],
  8622. 'sku'=>$v['sku'],
  8623. 'title'=>$v['title'],
  8624. 'features'=>$v['features'],
  8625. 'label'=>$v['label'],
  8626. 'orderinfo'=>$v['orderinfo'],
  8627. 'number'=>$number,
  8628. 'waybill'=>$v['waybill'],
  8629. 'retreat'=>$v['retreat'],
  8630. ];
  8631. }
  8632. }
  8633. if(empty($final_list)){
  8634. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8635. }else{
  8636. $end_list = [];
  8637. foreach($final_list as $v){
  8638. $end_list[] = array_values($v);
  8639. }
  8640. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8641. array_unshift($end_list,[
  8642. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8643. ]);
  8644. array_unshift($end_list,[
  8645. $title,"","","","","","","","",""
  8646. ]);
  8647. $merges = [
  8648. [
  8649. "s"=>["r"=>0,"c"=>0],
  8650. "e"=>["r"=>0,"c"=>9]
  8651. ]
  8652. ];
  8653. $cols = [
  8654. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8655. ];
  8656. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8657. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8658. ] )));
  8659. }
  8660. } else if ($type == 5) {
  8661. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8662. foreach ($info_list as $key => $value) {
  8663. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8664. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8665. $warehouse = $this->warehouse->read($value['warehouse']);
  8666. $info_list[$key]['warehouse'] = $warehouse['title'];
  8667. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8668. $features = explode('-', trim($features, '-'));
  8669. $pm = $classid;
  8670. foreach ($features as $k => $v) {
  8671. if ($v != 0) {
  8672. if (!isset($typeclass[$v])) {
  8673. continue;
  8674. }
  8675. if (isset($pm[$typeclass[$v]['classid']])) {
  8676. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8677. $tz = explode('|', $typeclass[$v]['zh']);
  8678. $pm[$typeclass[$v]['classid']] = $tz[0];
  8679. } else {
  8680. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8681. }
  8682. }
  8683. }
  8684. }
  8685. $zh = implode(" ", $pm);
  8686. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8687. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8688. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8689. $info_list[$key]['features'] = $zh;
  8690. }
  8691. if(empty($info_list)){
  8692. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8693. }else{
  8694. $final_list = [];
  8695. foreach($info_list as $v){
  8696. $final_list[] = array_values($v);
  8697. }
  8698. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8699. array_unshift($final_list,[
  8700. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8701. ]);
  8702. array_unshift($final_list,[
  8703. $title,"","","","","","",
  8704. ]);
  8705. $merges = [
  8706. [
  8707. "s"=>["r"=>0,"c"=>0],
  8708. "e"=>["r"=>0,"c"=>6]
  8709. ]
  8710. ];
  8711. $cols = [
  8712. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8713. ];
  8714. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8715. }
  8716. } else {
  8717. $wh = array();
  8718. $w = $this->warehouse->find_all('1=1', 'id,title');
  8719. foreach ($w as $v) {
  8720. $wh[$v['id']] = $v['title'];
  8721. }
  8722. $wt = array();
  8723. $whlabel_type = $this->whlabel_type->find_all();
  8724. foreach ($whlabel_type as $v) {
  8725. $wt[$v['id']] = $v['title'];
  8726. }
  8727. $classid = $this->classid->sku();
  8728. $list = array();
  8729. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8730. foreach ($rows as $key => $value) {
  8731. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8732. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8733. $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');
  8734. $details = array();
  8735. $cpid = array();
  8736. $cpbz = array();
  8737. $c = 0;
  8738. $g = 0;
  8739. $x = 0;
  8740. $t = 0;
  8741. $s = 0;
  8742. $q = 0;
  8743. foreach ($sd as $k => $v) {
  8744. if ($v['state'] == 0) {
  8745. $c++;
  8746. }
  8747. if ($v['state'] != 9) {
  8748. $g++;
  8749. }
  8750. if ($v['outk'] > 1) {
  8751. $x++;
  8752. }
  8753. if ($v['retreat'] > 0) {
  8754. $t++;
  8755. }
  8756. if ($v['state'] == 8) {
  8757. $s++;
  8758. }
  8759. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8760. $q++;
  8761. }
  8762. $details[$v['details']] = $v['details'];
  8763. if ($v['cpid'] != 0) {
  8764. $cpid[$v['cpid']] = $v['cpid'];
  8765. }
  8766. if ($v['cpbz'] != '') {
  8767. $cpbz[$v['cpbz']] = $v['cpbz'];
  8768. }
  8769. }
  8770. if (isset($wt[$value['type']])) {
  8771. $rows[$key]['type'] = $wt[$value['type']];
  8772. } else {
  8773. $rows[$key]['type'] = '未设置';
  8774. }
  8775. $rows[$key]['details'] = implode("、", $details);
  8776. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8777. $ftime = time() - 15 * 24 * 3600;
  8778. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8779. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8780. $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);
  8781. $rows[$key]['c'] = $c;
  8782. $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);
  8783. $rows[$key]['t'] = $t;
  8784. $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'] . '"');
  8785. $rows[$key]['z'] = $z;
  8786. // $jm = $classid;
  8787. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8788. $features = explode('-', trim($features, '-'));
  8789. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8790. }
  8791. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8792. $final_list =[];
  8793. foreach($tmp_list as $k=>$v){
  8794. $final_list[] = [
  8795. "warehouse"=>$v['warehouse'],
  8796. "purchase"=>$v['purchase'],
  8797. "details"=>$v['details'],
  8798. "cpid"=>$v['cpid'],
  8799. "sku"=>$v['sku'],
  8800. "title"=>$v['title'],
  8801. "features"=>$v['pm'],
  8802. "cpbz"=>$v['cpbz'],
  8803. "sm"=>$v['sm'],
  8804. "type"=>$v['type'],
  8805. "g"=>$v["g"],
  8806. "c"=>$v["c"],
  8807. "x"=>$v["x"],
  8808. "t"=>$v["t"],
  8809. "z"=>$v["z"],
  8810. "jm"=>$v["jm"],
  8811. "weight"=>$v["weight"],
  8812. "asd"=>$v["asd"],
  8813. ];
  8814. }
  8815. if(empty($final_list)){
  8816. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8817. }else{
  8818. $end_list = [];
  8819. foreach($final_list as $v){
  8820. $end_list[] = array_values($v);
  8821. }
  8822. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8823. array_unshift($end_list,[
  8824. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8825. ]);
  8826. array_unshift($end_list,[
  8827. $title,"","","","","","","","","","","","","","","","","",""
  8828. ]);
  8829. $merges = [
  8830. [
  8831. "s"=>["r"=>0,"c"=>0],
  8832. "e"=>["r"=>0,"c"=>6]
  8833. ]
  8834. ];
  8835. $cols = [
  8836. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8837. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8838. ];
  8839. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8840. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8841. ])));
  8842. }
  8843. }
  8844. }
  8845. }
  8846. public function _exceljxcjs(){
  8847. $classid = $this->classid->sku();
  8848. $pm = $classid;
  8849. $typeclass = array();
  8850. $tc = $this->typeclass->find_all();
  8851. foreach ($tc as $v) {
  8852. $typeclass[$v['id']] = $v;
  8853. }
  8854. $prc = array();
  8855. $purchase = $this->purchase->find_all();
  8856. foreach ($purchase as $k => $v) {
  8857. $prc[$v['id']] = $v['title'];
  8858. }
  8859. if(!isset($_GET['excel'])){
  8860. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8861. }
  8862. $where = "sku != 'Preset'";
  8863. //数据排序
  8864. $order_str = "id desc";
  8865. if (empty($page)) {
  8866. $start = 0;
  8867. $perpage = 1;
  8868. } else {
  8869. $start = ($page - 1) * $perpage;
  8870. }
  8871. $category = $this->input->get('category', true);
  8872. $warehouse = $this->input->get('warehouse', true);
  8873. $excelid = $this->input->get('sid', true);
  8874. if ($category) {
  8875. $where .= " and features like '%-$category-%'";
  8876. }
  8877. if ($warehouse) {
  8878. $where .= " and warehouse = '$warehouse'";
  8879. }
  8880. $xzid = '';
  8881. if ($excelid) {
  8882. $excelid = explode(',', trim($excelid, ','));
  8883. foreach ($excelid as $key => $value) {
  8884. $xzid .= " id = " . $value . " or";
  8885. }
  8886. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8887. }
  8888. $wt = array();
  8889. $whlabel_type = $this->whlabel_type->find_all();
  8890. foreach ($whlabel_type as $v) {
  8891. $wt[$v['id']] = $v['title'];
  8892. }
  8893. $wh = array();
  8894. $w = $this->warehouse->find_all('1=1', 'id,title');
  8895. foreach ($w as $v) {
  8896. $wh[$v['id']] = $v['title'];
  8897. }
  8898. $list = array();
  8899. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8900. foreach ($rows as $key => $value) {
  8901. if (isset($wt[$value['type']])) {
  8902. $rows[$key]['type'] = $wt[$value['type']];
  8903. } else {
  8904. $rows[$key]['type'] = '未设置';
  8905. }
  8906. $bm = '03';
  8907. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8908. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8909. $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');
  8910. $details = array();
  8911. $cpid = array();
  8912. $cpbz = array();
  8913. $c = 0;
  8914. $g = 0;
  8915. $x = 0;
  8916. $t = 0;
  8917. $s = 0;
  8918. $q = 0;
  8919. foreach ($sd as $k => $v) {
  8920. if ($v['state'] == 0) {
  8921. $c++;
  8922. if ($v['cpid'] != 0) {
  8923. $cpid[$v['cpid']] = $v['cpid'];
  8924. }
  8925. if ($v['cpbz'] != '') {
  8926. $cpbz[$v['cpbz']] = $v['cpbz'];
  8927. }
  8928. }
  8929. if ($v['state'] != 9) {
  8930. $g++;
  8931. }
  8932. if ($v['state'] == 1) {
  8933. $x++;
  8934. }
  8935. if ($v['state'] == 2) {
  8936. $t++;
  8937. }
  8938. if ($v['state'] == 8) {
  8939. $s++;
  8940. }
  8941. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8942. $q++;
  8943. }
  8944. $details[$v['details']] = $v['details'];
  8945. }
  8946. $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'] . '"');
  8947. $rows[$key]['details'] = implode("、", $details);
  8948. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8949. $number = $value['number'];
  8950. $ftime = time() - 15 * 24 * 3600;
  8951. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8952. $rows[$key]['number'] = $g;
  8953. $rows[$key]['c'] = $c;
  8954. $rows[$key]['x'] = $x;
  8955. $rows[$key]['t'] = $t;
  8956. $rows[$key]['s'] = $s;
  8957. $rows[$key]['q'] = $q;
  8958. $rows[$key]['z'] = $z;
  8959. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8960. $features = explode('-', trim($features, '-'));
  8961. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8962. }
  8963. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8964. $final_list = [];
  8965. foreach ($list as $k => $v) {
  8966. if (empty($v['sku'])) {
  8967. continue;
  8968. }
  8969. $final_list[] = [
  8970. $v["warehouse"],
  8971. $v["purchase"],
  8972. $v["details"],
  8973. $v["cpid"],
  8974. $v["dbcontent"],
  8975. $v["sku"],
  8976. $v["bm"],
  8977. $v["jm"],
  8978. $v["title"],
  8979. $v["pm"],
  8980. $v["cpbz"],
  8981. $v["sm"],
  8982. $v["type"],
  8983. $v["number"],
  8984. $v["c"],
  8985. $v["x"],
  8986. $v["t"],
  8987. $v["s"],
  8988. $v["q"],
  8989. $v["z"],
  8990. $v['weight'],
  8991. ];
  8992. }
  8993. if(empty($final_list)){
  8994. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8995. }
  8996. $title = "总进销存统计表";
  8997. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8998. $merges = [
  8999. [
  9000. "s"=>["r"=>0,"c"=>0],
  9001. "e"=>["r"=>0,"c"=>21]
  9002. ]
  9003. ];
  9004. $cols = [
  9005. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  9006. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9007. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9008. ];
  9009. array_unshift($final_list, $first_row);
  9010. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  9011. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9012. }
  9013. public function _summaryjs($arg_array)
  9014. {
  9015. $prc = array();
  9016. $purchase = $this->purchase->find_all();
  9017. foreach ($purchase as $k => $v) {
  9018. $prc[$v['id']] = $v['title'];
  9019. }
  9020. if (isset($_GET['excel'])) {
  9021. $ktime = $this->input->get('ktime', true);
  9022. $jtime = $this->input->get('jtime', true);
  9023. $ktime = strtotime($ktime);
  9024. $jtime = strtotime($jtime);
  9025. $where = "1=1";
  9026. if ($ktime && $jtime) {
  9027. $where .= " and outk > '$ktime' and outk < '$jtime'";
  9028. }
  9029. //数据排序
  9030. $order_str = "time desc";
  9031. if (empty($page)) {
  9032. $start = 0;
  9033. $perpage = 1;
  9034. } else {
  9035. $start = ($page - 1) * $perpage;
  9036. }
  9037. //取得信息列表
  9038. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  9039. foreach ($info_list as $key => $value) {
  9040. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  9041. $warehouse = $this->warehouse->read($value['warehouse']);
  9042. $info_list[$key]['warehouse'] = $warehouse['title'];
  9043. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  9044. $details = array();
  9045. $cpid = array();
  9046. foreach ($x as $k => $v) {
  9047. if ($v['details'] != '') {
  9048. $details[$v['details']] = $v['details'];
  9049. }
  9050. if ($v['cpid'] != 0) {
  9051. $cpid[$v['cpid']] = $v['cpid'];
  9052. }
  9053. }
  9054. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  9055. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9056. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  9057. $info_list[$key]['s'] = $s;
  9058. $info_list[$key]['x'] = count($x);
  9059. }
  9060. if(empty($info_list)){
  9061. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9062. }
  9063. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  9064. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  9065. $merges = [
  9066. [
  9067. "s"=>["r"=>0,"c"=>0],
  9068. "e"=>["r"=>0,"c"=>7]
  9069. ]
  9070. ];
  9071. $cols = [
  9072. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  9073. ];
  9074. $final_list = [];
  9075. foreach($info_list as $k => $v){
  9076. $final_list[] = array_values($v);
  9077. }
  9078. array_unshift($final_list, $first_row);
  9079. array_unshift($final_list,[
  9080. $title,"","","","","","","","",
  9081. ]);
  9082. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9083. $titlename = "<table border=1>
  9084. <tr align='center'>
  9085. <td>仓库</td>
  9086. <td>供应商</td>
  9087. <td>出库位置</td>
  9088. <td>出库编码</td>
  9089. <td>SKU</td>
  9090. <td>产品名</td>
  9091. <td>总剩余库存</td>
  9092. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  9093. </tr>
  9094. </table>";
  9095. $filename = $title . ".xls";
  9096. $tail = "";
  9097. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  9098. }
  9099. }
  9100. public function _uckjs()
  9101. {
  9102. if (isset($_GET['excel'])) {
  9103. $tc = array();
  9104. $typeclass = $this->typeclass->find_all();
  9105. foreach ($typeclass as $v) {
  9106. $tc[$v['id']] = $v['zh'];
  9107. }
  9108. $first_row = [
  9109. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  9110. ];
  9111. $t = array();
  9112. $rq = '';
  9113. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  9114. $ts = $ts / (24 * 3600);
  9115. for ($i = 0; $i < $ts; $i++) {
  9116. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9117. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9118. }
  9119. $day_len = count($t);
  9120. $first_row[] = "本月出库";
  9121. $merges = [
  9122. ];
  9123. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  9124. $excel_key = 1;
  9125. $final_list = [];
  9126. foreach ($info_list as $k => $v) {
  9127. $features = explode('-', trim($v['features'], '-'));
  9128. if (!isset($features[3]) || !isset($features[4])) {
  9129. continue;
  9130. }
  9131. $tmp = [];
  9132. $tmp[0] = $tc[$features[0]]; //类型
  9133. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  9134. $tmp[2] = $tc[$features[4]]; //曲度
  9135. $tmp[3] = '';
  9136. if (isset($data[$k][1])) {
  9137. $tmp[3] .=$tmp[1];
  9138. }
  9139. if (isset($data[$k][2])) {
  9140. $tmp[3] .= $tmp[2];
  9141. }
  9142. if (isset($features[5])) {
  9143. $tmp[3] .= $tc[$features[5]];
  9144. }
  9145. if (isset($features[2])) {
  9146. $tmp[3] .= $tc[$features[2]];
  9147. }
  9148. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  9149. $tmp[4] = $v['sku'];
  9150. $tmp[5] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and (state = 0 or (state = 1 and outk > ' . strtotime(date("Y-m", time())) . '))'); //月初库存
  9151. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  9152. $tmp[7] ="";
  9153. $tmp[8] ="";
  9154. $byck = 0;
  9155. foreach ($t as $vv) {
  9156. $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));
  9157. $tmp[] = ($sl > 0) ? $sl : '';
  9158. $byck += $sl;
  9159. }
  9160. $tmp[] = ($byck > 0) ? $byck : '';
  9161. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  9162. // $ztrq = '';
  9163. // $ztsl = '';
  9164. // if (count($zt) > 0) {
  9165. // foreach ($zt as $vv) {
  9166. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  9167. // $ztsl .= $vv['num'] . '<br>';
  9168. // }
  9169. // }
  9170. if(empty($zt)){
  9171. $final_list[] = $tmp;
  9172. $excel_key = $excel_key + 1;
  9173. }else{
  9174. $len = count($zt);
  9175. if($len == 1){
  9176. $tmp[7] = $zt[0]['num'] ;
  9177. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  9178. $final_list[] = $tmp;
  9179. $excel_key = $excel_key + 1;
  9180. }else{
  9181. foreach($zt as $vv){
  9182. $tmp[7] = "";
  9183. $tmp[8] = "";
  9184. $tmp[7] = $vv['num'];
  9185. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9186. $final_list[] = $tmp;
  9187. }
  9188. $merges[] = [
  9189. "s"=>["r"=>$excel_key,"c"=>0],
  9190. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9191. ];
  9192. $merges[] = [
  9193. "s"=>["r"=>$excel_key,"c"=>1],
  9194. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9195. ];
  9196. $merges[] = [
  9197. "s"=>["r"=>$excel_key,"c"=>2],
  9198. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9199. ];
  9200. $merges[] = [
  9201. "s"=>["r"=>$excel_key,"c"=>3],
  9202. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9203. ];
  9204. $merges[] = [
  9205. "s"=>["r"=>$excel_key,"c"=>4],
  9206. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9207. ];
  9208. $merges[] = [
  9209. "s"=>["r"=>$excel_key,"c"=>5],
  9210. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9211. ];
  9212. $merges[] = [
  9213. "s"=>["r"=>$excel_key,"c"=>6],
  9214. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9215. ];
  9216. for($i=1;$i<=$day_len;$i++){
  9217. $merges[] = [
  9218. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9219. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9220. ];
  9221. }
  9222. $merges[] = [
  9223. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9224. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9225. ];
  9226. $excel_key = $excel_key + $len;
  9227. }
  9228. }
  9229. }
  9230. $title = "详情 " . date("Y-m-d", time());
  9231. if(empty($final_list)){
  9232. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9233. }
  9234. $cols = [
  9235. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9236. ];
  9237. array_unshift($final_list, $first_row);
  9238. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9239. }
  9240. }
  9241. public function _whlabelexcelzhjs(){
  9242. if(empty($_GET['excel'])){
  9243. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9244. }
  9245. $where = "sku != 'Preset' and sku != '' ";
  9246. //数据排序
  9247. $order_str = "id desc";
  9248. if (empty($page)) {
  9249. $start = 0;
  9250. $perpage = 1;
  9251. } else {
  9252. $start = ($page - 1) * $perpage;
  9253. }
  9254. $category = $this->input->get('category', true);
  9255. $warehouse = $this->input->get('warehouse', true);
  9256. $excelid = $this->input->get('sid', true);
  9257. if ($category) {
  9258. $where .= " and features like '%-$category-%'";
  9259. }
  9260. if ($warehouse) {
  9261. $where .= " and warehouse = '$warehouse'";
  9262. }
  9263. $xzid = '';
  9264. if ($excelid) {
  9265. $excelid = explode(',', trim($excelid, ','));
  9266. foreach ($excelid as $key => $value) {
  9267. $xzid .= " id = " . $value . " or";
  9268. }
  9269. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9270. }
  9271. $merges = [
  9272. [
  9273. "s"=>["r"=>0,"c"=>0],
  9274. "e"=>["r"=>0,"c"=>6]
  9275. ]
  9276. ];
  9277. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9278. $excel_index = 2;
  9279. $final_list = [];
  9280. foreach ($rows as $key => $value) {
  9281. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9282. $zh = '';
  9283. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9284. // foreach ($zt_list as $v) {
  9285. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9286. // }
  9287. $zt = array_sum(array_column($zt_list, 'num'));
  9288. $number = $value['number'];
  9289. $ftime = time() - 15 * 24 * 3600;
  9290. $warehouse = $this->warehouse->read($value['warehouse']);
  9291. // $rows[$key]['warehouse'] = $warehouse['title'];
  9292. // $rows[$key]['number'] = $c;
  9293. // $rows[$key]['features'] = $zh;
  9294. //$rows[$key]['hb'] = $c + $zt;
  9295. $tmp = [];
  9296. $tmp[0] = $warehouse['title'];
  9297. $tmp[1] = $value['sku'];
  9298. $tmp[2] = $value['title'];
  9299. $tmp[3] = $c;
  9300. $tmp[4] = "";
  9301. $tmp[5] = $c + $zt;
  9302. if(empty($zt_list)){
  9303. $tmp[4] = "";
  9304. $final_list[] = $tmp;
  9305. $excel_index = $excel_index + 1;
  9306. }else{
  9307. if(count($zt_list) == 1){
  9308. $tmp[4] = "";
  9309. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9310. $final_list[] = $tmp;
  9311. $excel_index = $excel_index + 1;
  9312. }else{
  9313. $len = count($zt_list);
  9314. foreach ($zt_list as $v){
  9315. $tmp[4] = "";
  9316. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9317. $final_list[] = $tmp;
  9318. }
  9319. $merges[] = [
  9320. "s"=>["r"=>$excel_index,"c"=>0],
  9321. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9322. ];
  9323. $merges[] = [
  9324. "s"=>["r"=>$excel_index,"c"=>1],
  9325. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9326. ];
  9327. $merges[] = [
  9328. "s"=>["r"=>$excel_index,"c"=>2],
  9329. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9330. ];
  9331. $merges[] = [
  9332. "s"=>["r"=>$excel_index,"c"=>3],
  9333. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9334. ];
  9335. $merges[] = [
  9336. "s"=>["r"=>$excel_index,"c"=>5],
  9337. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9338. ];
  9339. $excel_index = $excel_index + $len;
  9340. }
  9341. }
  9342. }
  9343. $first_row = [
  9344. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9345. ];
  9346. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9347. if(empty($final_list)){
  9348. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9349. }
  9350. $cols = [
  9351. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9352. ];
  9353. array_unshift($final_list, $first_row);
  9354. array_unshift($final_list, [
  9355. $title,"","","","",""
  9356. ]);
  9357. $end_list = [];
  9358. foreach ($final_list as $key => $value) {
  9359. $end_list[] = array_values($value);
  9360. }
  9361. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9362. }
  9363. //出库、退库导出
  9364. public function _dccrtypejs()
  9365. {
  9366. $classid = $this->classid->sku();
  9367. $pm = $classid;
  9368. $typeclass = array();
  9369. $tc = $this->typeclass->find_all();
  9370. foreach ($tc as $v) {
  9371. $typeclass[$v['id']] = $v;
  9372. }
  9373. $prc = array();
  9374. $purchase = $this->purchase->find_all();
  9375. foreach ($purchase as $k => $v) {
  9376. $prc[$v['id']] = $v['title'];
  9377. }
  9378. if (isset($_GET['sid'])) {
  9379. $wh = array();
  9380. $w = $this->warehouse->find_all('1=1', 'id,title');
  9381. foreach ($w as $v) {
  9382. $wh[$v['id']] = $v['title'];
  9383. }
  9384. $type = $this->input->get('excel', true);
  9385. $category = $this->input->get('category', true);
  9386. $size = $this->input->get('size', true);
  9387. $grade = $this->input->get('grade', true);
  9388. $color = $this->input->get('color', true);
  9389. $lowe = $this->input->get('lowe', true);
  9390. $sku = $this->input->get('sku', true);
  9391. $warehouse = $this->input->get('warehouse', true);
  9392. $lacetype = $this->input->get('lacetype', true);
  9393. $lacecolor = $this->input->get('lacecolor', true);
  9394. $density = $this->input->get('density', true);
  9395. $haircap = $this->input->get('haircap', true);
  9396. $purchase = $this->input->get('purchase', true);
  9397. $title = $this->input->get('title', true);
  9398. $state = $this->input->get('state', true);
  9399. $sid = $this->input->get('sid', true);
  9400. $ktime = $this->input->get('ktime', true);
  9401. $jtime = $this->input->get('jtime', true);
  9402. $ktime = strtotime($ktime);
  9403. $jtime = strtotime($jtime);
  9404. $where = "1=1";
  9405. $gj = "";
  9406. $ck = "";
  9407. if ($category) {
  9408. $where .= " and features like '%-$category-%'";
  9409. }
  9410. if ($size) {
  9411. $where .= " and features like '%-$size-%'";
  9412. }
  9413. if ($grade) {
  9414. $where .= " and features like '%-$grade-%'";
  9415. }
  9416. if ($color) {
  9417. $where .= " and features like '%-$color-%'";
  9418. }
  9419. if ($lowe) {
  9420. $where .= " and features like '%-$lowe-%'";
  9421. }
  9422. if ($warehouse) {
  9423. $where .= " and warehouse = '$warehouse'";
  9424. }
  9425. if ($purchase) {
  9426. $where .= " and purchase = '$purchase'";
  9427. }
  9428. if ($state) {
  9429. $where .= " and state = '$state'";
  9430. }
  9431. if ($lacetype) {
  9432. $where .= " and features like '%-$lacetype-%'";
  9433. }
  9434. if ($lacecolor) {
  9435. $where .= " and features like '%-$lacecolor-%'";
  9436. }
  9437. if ($density) {
  9438. $where .= " and features like '%-$density-%'";
  9439. }
  9440. if ($haircap) {
  9441. $where .= " and features like '%-$haircap-%'";
  9442. }
  9443. if ($title) {
  9444. $title = trim($title, ' ');
  9445. $title = trim($title, ' ');
  9446. $where .= " and title like '%$title%'";
  9447. }
  9448. if ($sku) {
  9449. $sku = trim($sku, ' ');
  9450. $sku = trim($sku, ' ');
  9451. $where .= " and sku like '%$sku%'";
  9452. }
  9453. if ($ktime && $jtime) {
  9454. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9455. }
  9456. $sidwhere = '';
  9457. if ($sid) {
  9458. $sd = "";
  9459. $s = explode(',', trim($sid, ','));
  9460. foreach ($s as $value) {
  9461. $sd .= " id = " . $value . " or";
  9462. }
  9463. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9464. }
  9465. //数据排序
  9466. $order_str = "time desc";
  9467. if (empty($page)) {
  9468. $start = 0;
  9469. $perpage = 1;
  9470. } else {
  9471. $start = ($page - 1) * $perpage;
  9472. }
  9473. $wh = array();
  9474. $w = $this->warehouse->find_all('1=1', 'id,title');
  9475. foreach ($w as $v) {
  9476. $wh[$v['id']] = $v['title'];
  9477. }
  9478. $wt = array();
  9479. $whlabel_type = $this->whlabel_type->find_all();
  9480. foreach ($whlabel_type as $v) {
  9481. $wt[$v['id']] = $v['title'];
  9482. }
  9483. $classid = $this->classid->sku();
  9484. $list = array();
  9485. $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');
  9486. foreach ($rows_r as $key => $value) {
  9487. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9488. $pm = $classid;
  9489. $jm = $classid;
  9490. $rows_r[$key]['enter'] = '入库';
  9491. $rows_r[$key]['time'] = $value['enter'];
  9492. if ($value['rktype'] == 1) {
  9493. $rows_r[$key]['rktype'] = '采购入库';
  9494. } else if ($value['rktype'] == 2) {
  9495. $rows_r[$key]['rktype'] = '盘盈调整';
  9496. } else if ($value['rktype'] == 3) {
  9497. $rows_r[$key]['rktype'] = '其他调整入库';
  9498. } else if ($value['rktype'] == 4) {
  9499. $rows_r[$key]['rktype'] = '其他调整入库';
  9500. } else if ($value['rktype'] == 5) {
  9501. $rows_r[$key]['rktype'] = '退库入库';
  9502. } else if ($value['rktype'] == 6) {
  9503. $rows_r[$key]['rktype'] = '退货可用入库';
  9504. } else if ($value['rktype'] == 7) {
  9505. $rows_r[$key]['rktype'] = '形态转换入库';
  9506. } else {
  9507. $rows_r[$key]['rktype'] = '';
  9508. }
  9509. $features = explode('-', trim($value['features'], '-'));
  9510. foreach ($features as $v) {
  9511. if (isset($typeclass[$v])) {
  9512. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9513. $pm[$typeclass[$v]['classid']] = $zh[0];
  9514. }
  9515. if (isset($typeclass[$v])) {
  9516. if (isset($jm[$typeclass[$v]['classid']])) {
  9517. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9518. }
  9519. }
  9520. }
  9521. $zh = implode(" ", $pm);
  9522. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9523. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9524. $rows_r[$key]['zh'] = $zh;
  9525. $jm = array_filter($jm);
  9526. $rows_r[$key]['features'] = implode("-", $jm);
  9527. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9528. }
  9529. $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');
  9530. foreach ($rows_c as $key => $value) {
  9531. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9532. $pm = $classid;
  9533. $jm = $classid;
  9534. $rows_c[$key]['time'] = $value['outk'];
  9535. $rows_c[$key]['outk'] = '出库';
  9536. if ($value['cktype'] == 1) {
  9537. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9538. } else if ($value['cktype'] == 2) {
  9539. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9540. } else if ($value['cktype'] == 3) {
  9541. $rows_c[$key]['cktype'] = '盘亏调整';
  9542. } else if ($value['cktype'] == 4) {
  9543. $rows_c[$key]['cktype'] = '其他调整出库';
  9544. } else if ($value['cktype'] == 5) {
  9545. $rows_c[$key]['cktype'] = '形态转换出库';
  9546. } else {
  9547. $rows_c[$key]['cktype'] = '';
  9548. }
  9549. unset($rows_c[$key]['state']);
  9550. $features = explode('-', trim($value['features'], '-'));
  9551. foreach ($features as $v) {
  9552. if (isset($typeclass[$v])) {
  9553. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9554. $pm[$typeclass[$v]['classid']] = $zh[0];
  9555. }
  9556. if (isset($typeclass[$v])) {
  9557. if (isset($jm[$typeclass[$v]['classid']])) {
  9558. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9559. }
  9560. }
  9561. }
  9562. $zh = implode(" ", $pm);
  9563. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9564. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9565. $rows_c[$key]['zh'] = $zh;
  9566. $jm = array_filter($jm);
  9567. $rows_c[$key]['features'] = implode("-", $jm);
  9568. $rows_c[$key]['number'] = 1;
  9569. }
  9570. $merged = $rows_r;
  9571. foreach ($rows_c as $key => $value) {
  9572. if (isset($merged[$key])) {
  9573. $merged[] = $value;
  9574. } else {
  9575. $merged[$key] = $value;
  9576. }
  9577. }
  9578. usort($merged, function ($a, $b) {
  9579. return $a['time'] - $b['time'];
  9580. });
  9581. foreach ($merged as $key => $value) {
  9582. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9583. }
  9584. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9585. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9586. $cols = [
  9587. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9588. ];
  9589. $final_list= [];
  9590. foreach($merged as $key => $value){
  9591. $final_list[] = array_values($value) ;
  9592. }
  9593. if(empty($merged)){
  9594. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9595. }
  9596. array_unshift($final_list, $first_row);
  9597. $end_list = [];
  9598. foreach ($final_list as $key => $value) {
  9599. $end_list[] = array_values($value);
  9600. }
  9601. $merges = [];
  9602. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9603. }
  9604. }
  9605. public function _errorexceljs()
  9606. {
  9607. $post = $this->input->post(NULL, TRUE);
  9608. if (isset($_GET['page'])) {
  9609. $page = $this->input->get('page', true);
  9610. $perpage = $this->input->get('perpage', true);
  9611. $sku = $this->input->get('sku', true);
  9612. $warehouse = $this->input->get('warehouse', true);
  9613. $ktime = $this->input->get('ktime', true);
  9614. $jtime = $this->input->get('jtime', true);
  9615. $ktime = strtotime($ktime);
  9616. $jtime = strtotime($jtime);
  9617. $where = "sku != 'Preset'";
  9618. $gj = '';
  9619. if ($sku) {
  9620. $where .= " and sku like '%$sku%'";
  9621. } else {
  9622. if ($ktime && $jtime) {
  9623. $gj = " and time > '$ktime' and time < '$jtime'";
  9624. }
  9625. }
  9626. if ($warehouse) {
  9627. $where .= " and warehouse = '$warehouse'";
  9628. }
  9629. //数据排序
  9630. $order_str = "id desc";
  9631. if (empty($page)) {
  9632. $start = 0;
  9633. $perpage = 1;
  9634. } else {
  9635. $start = ($page - 1) * $perpage;
  9636. }
  9637. //取得信息列表
  9638. $rows = array();
  9639. $list = array();
  9640. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9641. foreach ($info_list as $value) {
  9642. $warehouse = $this->warehouse->read($value['warehouse']);
  9643. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9644. $number = $value['number'];
  9645. $ftime = time() - 15 * 24 * 3600;
  9646. if ($c < 1) {
  9647. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9648. }
  9649. }
  9650. $title = "0库存汇总";
  9651. $first_row = ["仓库","SKU","产品","当前库存"];
  9652. $cols = [
  9653. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9654. ];
  9655. $final_list= [];
  9656. foreach($list as $key => $value){
  9657. $final_list[] = array_values($value) ;
  9658. }
  9659. if(empty($final_list)){
  9660. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9661. }
  9662. array_unshift($final_list, $first_row);
  9663. $merges = [];
  9664. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9665. }
  9666. }
  9667. }