Whlabel.php 339 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. }else if ($arg == 'typev1') //进销存浏览
  62. {
  63. $this->_typev1();
  64. } else if ($arg == 'typedy') //进销存浏览店员页面
  65. {
  66. $this->_typedy($arg_array);
  67. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  68. {
  69. $this->_typedy_ck($arg_array);
  70. } else if ($arg == 'typeck') {
  71. $this->_typeck($arg_array);
  72. } else if ($arg == 'whlabeckdc') {
  73. $this->_whlabeckdc($arg_array);
  74. } else if ($arg == 'usatype') //美仓进销存浏览
  75. {
  76. $this->_usatype();
  77. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  78. {
  79. $this->_usatypeapp();
  80. } else if ($arg == 'enteradd') //入库操作
  81. {
  82. $this->_enteradd();
  83. } else if ($arg == 'enteredit') //修改
  84. {
  85. $this->_enteredit($arg_array);
  86. } else if ($arg == 'enter') //入库浏览
  87. {
  88. $this->_enter();
  89. } else if ($arg == 'out') //出库浏览
  90. {
  91. $this->_out();
  92. } else if ($arg == 'label') //出库标签浏览
  93. {
  94. $this->_label();
  95. } else if ($arg == 'outorder') //独立站出库订单
  96. {
  97. $this->_outorder();
  98. } else if ($arg == 'soutorder') //速卖通出库订单
  99. {
  100. $this->_soutorder();
  101. } else if ($arg == 'toutorder') //TT出库订单
  102. {
  103. $this->_toutorder();
  104. }else if ($arg == 'aoutorder') //amz出库订单
  105. {
  106. $this->_aoutorder();
  107. } else if ($arg == 'retreat') //退库订单
  108. {
  109. $this->_retreat();
  110. } else if ($arg == 'retreatlk') //退库订单
  111. {
  112. $this->_retreatlk();
  113. } else if ($arg == 'change') //更换标签
  114. {
  115. $this->_change();
  116. } else if ($arg == 'del') //删除
  117. {
  118. $this->_del();
  119. } else if ($arg == 'exceljxc') //进销存信息导出
  120. {
  121. $this->_exceljxc();
  122. } else if ($arg == 'excelr') //入库信息导出
  123. {
  124. $this->_excelr();
  125. } else if ($arg == 'excelct') //出库、退库信息导出
  126. {
  127. $this->_excelct();
  128. } else if ($arg == 'dccrtype') //根据出入库类型导出
  129. {
  130. $this->_dccrtype();
  131. } else if ($arg == 'excelcr') //出库、退库信息导出
  132. {
  133. $this->_excelcr();
  134. } else if ($arg == 'kcyz') //库存验证
  135. {
  136. $this->_kcyz();
  137. } else if ($arg == 'kj') //库存扣减
  138. {
  139. $this->_kj($arg_array);
  140. } else if ($arg == 'presetout') //预设库存导入
  141. {
  142. $this->_presetout($arg_array);
  143. } else if ($arg == 'presetedit') //预设库存导入
  144. {
  145. $this->_presetedit($arg_array);
  146. }else if ($arg == 'presetedittwo') //预设库存导入
  147. {
  148. $this->_presetedittwo($arg_array);
  149. } else if ($arg == 'summary') //汇总导出
  150. {
  151. $this->_summary($arg_array);
  152. } else if ($arg == 'manifest') //usps发货清单
  153. {
  154. $this->_manifest();
  155. } else if ($arg == 'abnormal') //占单异常
  156. {
  157. $this->_abnormal();
  158. } else if ($arg == 'error') //0库存SKU
  159. {
  160. $this->_error();
  161. } else if ($arg == 'errorexcel') //0库存SKU导出
  162. {
  163. $this->_errorexcel();
  164. } else if ($arg == 'db') {
  165. $this->_db();
  166. } else if ($arg == 'dbrk') {
  167. $this->_dbrk();
  168. } else if ($arg == 'whlabelczdc') {
  169. $this->_whlabelczdc();
  170. } else if ($arg == 'print') {
  171. $this->_print($arg_array);
  172. } else if ($arg == 'usaprint') {
  173. $this->_usaprint($arg_array);
  174. } else if ($arg == 'printck') {
  175. $this->_printck($arg_array);
  176. } else if ($arg == 'printrk') {
  177. $this->_printrk($arg_array);
  178. } else if ($arg == 'printxzrk') {
  179. $this->_printxzrk($arg_array);
  180. } else if ($arg == 'printexcel') {
  181. $this->_printexcel($arg_array);
  182. } else if ($arg == 'uck') {
  183. $this->_uck();
  184. } else if ($arg == 'whlabelexcelzh') {
  185. $this->_whlabelexcelzh();
  186. } else if ($arg == 'fc') {
  187. $this->_fc();
  188. } else if ($arg == 'fcmb') {
  189. $this->_fcmb();
  190. } else if ($arg == 'fcexcel') {
  191. $this->_fcexcel();
  192. } else if ($arg == 'fcjxc') {
  193. $this->_fcjxc($arg_array);
  194. } else if ($arg == '0kcdel') {
  195. $this->_0kcdel(); //导表删除0库存
  196. } else if ($arg == 'gbhtype') {
  197. $this->_gbhtype(); //更改备货状态
  198. } else if($arg == 'excelrjs'){
  199. $this->_excelrjs();
  200. } else if($arg == 'excelctjs'){
  201. $this->_excelctjs();
  202. }else if ($arg == 'exceljxcjs') //进销存信息导出
  203. {
  204. $this->_exceljxcjs();
  205. } else if ($arg == 'summaryjs') //汇总导出
  206. {
  207. $this->_summaryjs($arg_array);
  208. }else if($arg == 'uckjs'){
  209. $this->_uckjs();
  210. }else if ($arg == 'whlabelexcelzhjs') {
  211. $this->_whlabelexcelzhjs();
  212. }else if($arg == 'dccrtypejs'){
  213. $this->_dccrtypejs();
  214. }else if($arg == 'errorexceljs'){
  215. $this->_errorexceljs();
  216. }else if($arg == "w_t_cs"){
  217. $this->_w_t_cs(); //首页
  218. }else {
  219. $this->_index();
  220. }
  221. }
  222. public function _w_t_cs(){
  223. $vip = 0;
  224. if (isset($_SESSION['api'])) {
  225. $user = $this->user->get_api($_SESSION['api']);
  226. $fgshop = "";
  227. $sid = "";
  228. $usersp = explode('|', trim($user['shop'], '|'));
  229. foreach ($usersp as $value) {
  230. $fgshop .= " shop = " . $value . " or";
  231. $sid .= " id = " . $value . " or";
  232. }
  233. if ($user['vip'] == 1) {
  234. $vip = 1;
  235. }
  236. } else {
  237. header('Location: /');
  238. exit;
  239. }
  240. $prc = array();
  241. $purchase = $this->purchase->find_all();
  242. foreach ($purchase as $k => $v) {
  243. $prc[$v['id']] = $v['title'];
  244. }
  245. $company = array();
  246. $ct = $this->company->find_all();
  247. foreach ($ct as $k => $v) {
  248. $company[$v['id']] = $v['title'];
  249. }
  250. $sp = array();
  251. $s = $this->shop->find_all('1=1', 'id,shopname');
  252. foreach ($s as $v) {
  253. $sp[$v['id']] = $v['shopname'];
  254. }
  255. $wh = array();
  256. $w = $this->warehouse->find_all('1=1', 'id,title');
  257. foreach ($w as $v) {
  258. $wh[$v['id']] = $v['title'];
  259. }
  260. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  261. $this->data['shop'] = $wlshop;
  262. $this->data['vip'] = $vip;
  263. $this->_Template('whlabel_typejs', $this->data);
  264. }
  265. //管理
  266. public function _index()
  267. {
  268. $post = $this->input->post(NULL, TRUE);
  269. if (isset($post['page'])) {
  270. $page = $this->input->post('page', true);
  271. $perpage = $this->input->post('perpage', true);
  272. $sku = $this->input->post('sku', true);
  273. $number = $this->input->post('number', true);
  274. $warehouse = $this->input->post('warehouse', true);
  275. $purchase = $this->input->post('purchase', true);
  276. $orderinfo = $this->input->post('orderinfo', true);
  277. $waybill = $this->input->post('waybill', true);
  278. $category = $this->input->post('category', true);
  279. $size = $this->input->post('size', true);
  280. $grade = $this->input->post('grade', true);
  281. $color = $this->input->post('color', true);
  282. $lowe = $this->input->post('lowe', true);
  283. $state = $this->input->post('state', true);
  284. $label = $this->input->post('label', true);
  285. $timetk = $this->input->post('timetkk', true);
  286. $timetj = $this->input->post('timetjj', true);
  287. $timetk = strtotime($timetk);
  288. $timetj = strtotime($timetj);
  289. $where = "1=1 ";
  290. if ($timetk && $timetj) {
  291. $where .= " and time > '$timetk' and time < '$timetj'";
  292. }
  293. if ($sku) {
  294. $where .= " and sku = '$sku'";
  295. }
  296. if ($number) {
  297. $where .= " and number = '$number'";
  298. }
  299. if ($warehouse) {
  300. $where .= " and warehouse = '$warehouse'";
  301. }
  302. if ($purchase) {
  303. $where .= " and purchase = '$purchase'";
  304. }
  305. if ($orderinfo) {
  306. $where .= " and orderinfo = '$orderinfo'";
  307. }
  308. if ($waybill) {
  309. $where .= " and waybill = '$waybill'";
  310. }
  311. if ($category) {
  312. $where .= " and features like '%-$category-%'";
  313. }
  314. if ($size) {
  315. $where .= " and features like '%-$size-%'";
  316. }
  317. if ($grade) {
  318. $where .= " and features like '%-$grade-%'";
  319. }
  320. if ($color) {
  321. $where .= " and features like '%-$color-%'";
  322. }
  323. if ($lowe) {
  324. $where .= " and features like '%-$lowe-%'";
  325. }
  326. if ($label) {
  327. $where .= " and label = '$label'";
  328. }
  329. if ($state != '') {
  330. $where .= " and state = '$state'";
  331. }
  332. //数据排序
  333. $order_str = "time desc";
  334. if (empty($page)) {
  335. $start = 0;
  336. $perpage = 1;
  337. } else {
  338. $start = ($page - 1) * $perpage;
  339. }
  340. //取得信息列表
  341. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  342. foreach ($info_list as $key => $value) {
  343. $warehouse = $this->warehouse->read($value['warehouse']);
  344. $info_list[$key]['warehouse'] = $warehouse['title'];
  345. $purchase = $this->purchase->read($value['purchase']);
  346. $info_list[$key]['purchase'] = $purchase['title'];
  347. if ($value['enter'] != 0) {
  348. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  349. } else {
  350. $info_list[$key]['enter'] = "";
  351. }
  352. if ($value['outk'] != 0) {
  353. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  354. } else {
  355. $info_list[$key]['outk'] = "";
  356. }
  357. if ($value['printing'] != 0) {
  358. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  359. } else {
  360. $info_list[$key]['printing'] = "";
  361. }
  362. if ($value['orderinfo'] == 0) {
  363. $info_list[$key]['orderinfo'] = "";
  364. }
  365. if ($value['waybill'] == 0) {
  366. $info_list[$key]['waybill'] = "";
  367. }
  368. if ($value['state'] == 0) {
  369. $info_list[$key]['state'] = "在库";
  370. } else if ($value['state'] == 1) {
  371. $info_list[$key]['state'] = "出库";
  372. } else if ($value['state'] == 2) {
  373. $info_list[$key]['state'] = "退库";
  374. } else if ($value['state'] == 3) {
  375. $info_list[$key]['state'] = "调拨中";
  376. } else if ($value['state'] == 4) {
  377. $info_list[$key]['state'] = "再加工";
  378. } else if ($value['state'] == 5) {
  379. $info_list[$key]['state'] = "维修中";
  380. } else if ($value['state'] == 6) {
  381. $info_list[$key]['state'] = "盘亏";
  382. } else if ($value['state'] == 7) {
  383. $info_list[$key]['state'] = "更换标签";
  384. } else if ($value['state'] == 8) {
  385. $info_list[$key]['state'] = "其它";
  386. } else if ($value['state'] == 9) {
  387. $info_list[$key]['state'] = "预设";
  388. } else if ($value['state'] == 10) {
  389. $info_list[$key]['state'] = "美店零售";
  390. }
  391. if ($value['text'] == "") {
  392. $info_list[$key]['text'] = "";
  393. }
  394. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  395. }
  396. $total = $this->whlabel->find_count($where);
  397. $pagenum = ceil($total / $perpage);
  398. $over = $total - ($start + $perpage);
  399. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  400. echo json_encode($rows);
  401. exit;
  402. }
  403. if (isset($post['outsku'])) {
  404. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  405. $cz = $this->input->post('cz', true);
  406. if ($cz == '1') {
  407. $sku = $this->input->post('outsku', true);
  408. if ($sku) {
  409. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  410. if (count($data) < 1) {
  411. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  412. exit;
  413. }
  414. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  415. echo json_encode(array('success' => true));
  416. exit;
  417. }
  418. } else {
  419. $sku = $this->input->post('outsku', true);
  420. if ($sku) {
  421. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  422. if (count($data) < 1) {
  423. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  424. exit;
  425. }
  426. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  427. echo json_encode(array('success' => true));
  428. exit;
  429. }
  430. }
  431. }
  432. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  433. $this->_Template('whlabel', $this->data);
  434. }
  435. //在库标签
  436. public function _existence()
  437. {
  438. $post = $this->input->post(NULL, TRUE);
  439. if (isset($post['s'])) {
  440. $id_arr = $this->input->post('s');
  441. $id_arr = explode(',', $id_arr);
  442. if (!$id_arr) {
  443. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  444. exit;
  445. }
  446. //循环删除记录
  447. foreach ($id_arr as $v) {
  448. $sid = $this->whlabel->read($v);
  449. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  450. if ($count > 0) {
  451. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  452. exit;
  453. }
  454. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  455. if (count($zt) > 0) {
  456. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  457. exit;
  458. }
  459. $this->whlabel->remove($v);
  460. }
  461. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  462. exit;
  463. }
  464. if (isset($post['page'])) {
  465. $page = $this->input->post('page', true);
  466. $perpage = $this->input->post('perpage', true);
  467. $warehouse = $this->input->post('warehouse', true);
  468. $label = $this->input->post('label', true);
  469. $where = "1=1 and state = 0";
  470. if ($warehouse) {
  471. $where .= " and warehouse = '$warehouse'";
  472. }
  473. if ($label) {
  474. $where .= " and label = '$label'";
  475. }
  476. //数据排序
  477. $order_str = "time asc";
  478. if (empty($page)) {
  479. $start = 0;
  480. $perpage = 1;
  481. } else {
  482. $start = ($page - 1) * $perpage;
  483. }
  484. //取得信息列表
  485. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  486. foreach ($info_list as $key => $value) {
  487. if ($value['enter'] != 0) {
  488. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  489. } else {
  490. $info_list[$key]['enter'] = "";
  491. }
  492. if ($value['printing'] != 0) {
  493. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  494. } else {
  495. $info_list[$key]['printing'] = "";
  496. }
  497. }
  498. $total = $this->whlabel->find_count($where);
  499. $pagenum = ceil($total / $perpage);
  500. $over = $total - ($start + $perpage);
  501. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  502. echo json_encode($rows);
  503. exit;
  504. }
  505. $this->_Template('whlabel_existence', $this->data);
  506. }
  507. //进销存浏览
  508. public function _typedy($arg_array)
  509. {
  510. $prc = array();
  511. $purchase = $this->purchase->find_all();
  512. foreach ($purchase as $k => $v) {
  513. $prc[$v['id']] = $v['title'];
  514. }
  515. $post = $this->input->post(NULL, TRUE);
  516. if (isset($post['page'])) {
  517. $page = $this->input->post('page', true);
  518. $perpage = $this->input->post('perpage', true);
  519. $category = $this->input->post('category', true);
  520. $size = $this->input->post('size', true);
  521. $grade = $this->input->post('grade', true);
  522. $color = $this->input->post('color', true);
  523. $lowe = $this->input->post('lowe', true);
  524. $sku = $this->input->post('sku');
  525. $title = $this->input->post('title');
  526. $warehouse = $this->input->post('warehouse', true);
  527. $usa = $this->input->post('usa', true);
  528. $purchase = $this->input->post('purchase', true);
  529. $lacetype = $this->input->post('lacetype', true);
  530. $haircap = $this->input->post('haircap', true);
  531. $density = $this->input->post('density', true);
  532. $details = $this->input->post('details', true);
  533. $state = $this->input->post('state', true);
  534. $lacecolor = $this->input->post('lacecolor', true);
  535. $hairnumber = $this->input->post('hairnumber', true);
  536. $cklx = $this->input->post('cklx', true);
  537. $ktime = $this->input->post('ktime', true);
  538. $jtime = $this->input->post('jtime', true);
  539. $sm = $this->input->post('sm', true);
  540. $cpbz = $this->input->post('cpbz', true);
  541. $type = $this->input->post('type', true);
  542. $ktime = strtotime($ktime);
  543. $jtime = strtotime($jtime);
  544. $where = "1=1";
  545. $gj = "";
  546. $ck = "";
  547. if ($usa) {
  548. if (!$warehouse) {
  549. $where .= " and (warehouse = '5' or warehouse = '8')";
  550. }
  551. }
  552. if ($warehouse) {
  553. $where .= " and warehouse = '$warehouse'";
  554. }
  555. if ($details) {
  556. $where .= " and details = '$details'";
  557. }
  558. if ($purchase) {
  559. $where .= " and purchase = '$purchase'";
  560. }
  561. if (isset($state)) {
  562. if($state >-1){
  563. $where .= " and state = '$state'";
  564. }
  565. }
  566. if ($lacetype) {
  567. $where .= " and features like '%-$lacetype-%'";
  568. }
  569. if ($category) {
  570. $where .= " and features like '%-$category-%'";
  571. }
  572. if ($size) {
  573. $where .= " and features like '%-$size-%'";
  574. }
  575. if ($grade) {
  576. $where .= " and features like '%-$grade-%'";
  577. }
  578. if ($color) {
  579. $where .= " and features like '%-$color-%'";
  580. }
  581. if ($lowe) {
  582. $where .= " and features like '%-$lowe-%'";
  583. }
  584. if ($haircap) {
  585. $where .= " and features like '%-$haircap-%'";
  586. }
  587. if ($density) {
  588. $where .= " and features like '%-$density-%'";
  589. }
  590. if ($lacecolor) {
  591. $where .= " and features like '%-$lacecolor-%'";
  592. }
  593. if($sm){
  594. $where .= " and sm like '%".$sm."%'";
  595. }
  596. if($cpbz){
  597. $where .= " and cpbz like '%".$cpbz."%'";
  598. }
  599. if($type){
  600. $where .= " and type = ".$type."";
  601. }
  602. if (!empty($hairnumber)) {
  603. $where .= " and features like '%-128-%' ";
  604. if ($hairnumber < 0) {
  605. $class_list = $this->typeclass->find_all('classid = 43');
  606. foreach ($class_list as $v) {
  607. $where .= " and features not like '%-" . $v['id'] . "-%'";
  608. }
  609. } else {
  610. $where .= " and features like '%-$hairnumber-%'";
  611. }
  612. }
  613. $where_add = '';
  614. if ($cklx) {
  615. $shop = $this->shop->read($cklx);
  616. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  617. }
  618. if ($ktime && $jtime) {
  619. $gj = " and enter > '$ktime' and enter < '$jtime'";
  620. $ck = " and outk > '$ktime' and outk < '$jtime'";
  621. }
  622. //数据排序
  623. $order_str = "id desc";
  624. if (empty($page)) {
  625. $start = 0;
  626. $perpage = 1;
  627. } else {
  628. $start = ($page - 1) * $perpage;
  629. }
  630. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  631. if ($sku) {
  632. $sku = trim($sku, ' ');
  633. $sku = trim($sku, ' ');
  634. $where .= " and sku like '%$sku%'";
  635. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  636. } else if ($title) {
  637. $title = trim($title, ' ');
  638. $title = trim($title, ' ');
  639. $where .= " and title like '%$title%'";
  640. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  641. } else {
  642. //$where .= " and time > '$ktime' and time < '$jtime'";
  643. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  644. }
  645. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  646. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  647. foreach ($info_list as $k => $v) {
  648. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  649. unset($info_list[$k]['pm']);
  650. unset($info_list[$k]['jm']);
  651. unset($info_list[$k]['bm']);
  652. }
  653. //取得信息列表
  654. $rows = array();
  655. $list = array();
  656. foreach ($info_list as $key => $value) {
  657. $warehouse = $this->warehouse->read($value['warehouse']);
  658. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  659. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  660. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  661. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  662. $info_list[$key]['label'] = $value['sm'];
  663. $number = $value['number'];
  664. $ftime = time() - 15 * 24 * 3600;
  665. $info_list[$key]['warehouse'] = $warehouse['title'];
  666. $info_list[$key]['features'] = count($c);
  667. $z = count($z); //查看订单号
  668. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  669. $ztdata = '';
  670. if (count($zt) > 0) {
  671. foreach ($zt as $vv) {
  672. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  673. }
  674. }
  675. $info_list[$key]['number'] = $ztdata;
  676. $info_list[$key]['sm'] = $z;
  677. $details = array();
  678. $cpid = array();
  679. foreach ($c as $k => $v) {
  680. $details[$v['details']] = $v['details'];
  681. if ($v['cpid'] != 0) {
  682. $cpid[$v['cpid']] = $v['cpid'];
  683. }
  684. }
  685. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  686. if ($value['shop'] != '') {
  687. $shop = explode(',', trim($value['shop'], ','));
  688. $shop = $this->shop->read($shop[0]);
  689. $info_list[$key]['shop'] = $shop['shopname'];
  690. }
  691. }
  692. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  693. $pagenum = ceil($total / $perpage);
  694. $over = $total - ($start + $perpage);
  695. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  696. echo json_encode($rows);
  697. exit;
  698. }
  699. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  700. $this->_Template('whlabel_typedy', $this->data);
  701. }
  702. //进销存浏览
  703. public function _typedy_ck($arg_array)
  704. {
  705. $prc = array();
  706. $purchase = $this->purchase->find_all();
  707. foreach ($purchase as $k => $v) {
  708. $prc[$v['id']] = $v['title'];
  709. }
  710. $post = $this->input->post(NULL, TRUE);
  711. if (isset($post['page'])) {
  712. $page = $this->input->post('page', true);
  713. $perpage = $this->input->post('perpage', true);
  714. $category = $this->input->post('category', true);
  715. $size = $this->input->post('size', true);
  716. $grade = $this->input->post('grade', true);
  717. $color = $this->input->post('color', true);
  718. $lowe = $this->input->post('lowe', true);
  719. $sku = $this->input->post('sku');
  720. $title = $this->input->post('title');
  721. $warehouse = $this->input->post('warehouse', true);
  722. $usa = $this->input->post('usa', true);
  723. $purchase = $this->input->post('purchase', true);
  724. $lacetype = $this->input->post('lacetype', true);
  725. $haircap = $this->input->post('haircap', true);
  726. $density = $this->input->post('density', true);
  727. $details = $this->input->post('details', true);
  728. $state = $this->input->post('state', true);
  729. $lacecolor = $this->input->post('lacecolor', true);
  730. $cklx = $this->input->post('cklx', true);
  731. $ktime = $this->input->post('ktime', true);
  732. $jtime = $this->input->post('jtime', true);
  733. $ktime = strtotime($ktime);
  734. $jtime = strtotime($jtime);
  735. $where = "1=1";
  736. $gj = "";
  737. $ck = "";
  738. if ($lacetype) {
  739. $where .= " and features like '%-$lacetype-%'";
  740. }
  741. if ($category) {
  742. $where .= " and features like '%-$category-%'";
  743. }
  744. if ($size) {
  745. $where .= " and features like '%-$size-%'";
  746. }
  747. if ($grade) {
  748. $where .= " and features like '%-$grade-%'";
  749. }
  750. if ($color) {
  751. $where .= " and features like '%-$color-%'";
  752. }
  753. if ($lowe) {
  754. $where .= " and features like '%-$lowe-%'";
  755. }
  756. if ($haircap) {
  757. $where .= " and features like '%-$haircap-%'";
  758. }
  759. if ($density) {
  760. $where .= " and features like '%-$density-%'";
  761. }
  762. if ($lacecolor) {
  763. $where .= " and features like '%-$lacecolor-%'";
  764. }
  765. if ($usa) {
  766. if (!$warehouse) {
  767. $where .= " and (warehouse = '5' or warehouse = '8')";
  768. }
  769. }
  770. if ($warehouse) {
  771. $where .= " and warehouse = '$warehouse'";
  772. }
  773. if ($details) {
  774. $where .= " and details = '$details'";
  775. }
  776. if ($purchase) {
  777. $where .= " and purchase = '$purchase'";
  778. }
  779. if ($state) {
  780. $where .= " and state = '$state'";
  781. }
  782. $where_add = '';
  783. if ($cklx) {
  784. $shop = $this->shop->read($cklx);
  785. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  786. }
  787. if ($ktime && $jtime) {
  788. $gj = " and enter > '$ktime' and enter < '$jtime'";
  789. $ck = " and outk > '$ktime' and outk < '$jtime'";
  790. }
  791. //数据排序
  792. $order_str = "id desc";
  793. if (empty($page)) {
  794. $start = 0;
  795. $perpage = 1;
  796. } else {
  797. $start = ($page - 1) * $perpage;
  798. }
  799. if ($sku) {
  800. $sku = trim($sku, ' ');
  801. $sku = trim($sku, ' ');
  802. $where .= " and sku like '%$sku%'";
  803. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  804. } else if ($title) {
  805. $title = trim($title, ' ');
  806. $title = trim($title, ' ');
  807. $where .= " and title like '%$title%'";
  808. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  809. } else {
  810. //$where .= " and time > '$ktime' and time < '$jtime'";
  811. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  812. }
  813. //取得信息列表
  814. $rows = array();
  815. $list = array();
  816. foreach ($info_list as $key => $value) {
  817. $warehouse = $this->warehouse->read($value['warehouse']);
  818. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  819. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  820. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  821. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  822. $ftime = time() - 15 * 24 * 3600;
  823. $info_list[$key]['warehouse'] = $warehouse['title'];
  824. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  825. //$z = count($z);//查看订单号
  826. //$info_list[$key]['zd'] = $z;
  827. $details = array();
  828. $cpid = array();
  829. foreach ($c as $k => $v) {
  830. $details[$v['details']] = $v['details'];
  831. if ($v['cpid'] != 0) {
  832. $cpid[$v['cpid']] = $v['cpid'];
  833. }
  834. }
  835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  836. if ($value['shop'] != '') {
  837. $shop = explode(',', trim($value['shop'], ','));
  838. $shop = $this->shop->read($shop[0]);
  839. $info_list[$key]['shop'] = $shop['shopname'];
  840. }
  841. }
  842. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  843. $pagenum = ceil($total / $perpage);
  844. $over = $total - ($start + $perpage);
  845. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  846. echo json_encode($rows);
  847. exit;
  848. }
  849. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  850. $this->_Template('whlabel_typedy_ck', $this->data);
  851. }
  852. public function _typeck($arg_array)
  853. {
  854. $prc = array();
  855. $purchase = $this->purchase->find_all();
  856. foreach ($purchase as $k => $v) {
  857. $prc[$v['id']] = $v['title'];
  858. }
  859. $post = $this->input->post(NULL, TRUE);
  860. if (isset($post['page'])) {
  861. $page = $this->input->post('page', true);
  862. $perpage = $this->input->post('perpage', true);
  863. $category = $this->input->post('category', true);
  864. $size = $this->input->post('size', true);
  865. $grade = $this->input->post('grade', true);
  866. $color = $this->input->post('color', true);
  867. $lacecolor = $this->input->post('lacecolor', true);
  868. $lowe = $this->input->post('lowe', true);
  869. $sku = $this->input->post('sku');
  870. $title = $this->input->post('title');
  871. $warehouse = 13;
  872. $usa = $this->input->post('usa', true);
  873. $purchase = $this->input->post('purchase', true);
  874. $lacetype = $this->input->post('lacetype', true);
  875. $haircap = $this->input->post('haircap', true);
  876. $density = $this->input->post('density', true);
  877. $details = $this->input->post('details', true);
  878. $state = $this->input->post('state', true);
  879. $ktime = $this->input->post('ktime', true);
  880. $jtime = $this->input->post('jtime', true);
  881. $ktime = strtotime($ktime);
  882. $jtime = strtotime($jtime);
  883. $where = "1=1";
  884. $gj = "";
  885. $ck = "";
  886. if ($lacetype) {
  887. $where .= " and features like '%-$lacetype-%'";
  888. }
  889. if ($category) {
  890. $where .= " and features like '%-$category-%'";
  891. }
  892. if ($size) {
  893. $where .= " and features like '%-$size-%'";
  894. }
  895. if ($grade) {
  896. $where .= " and features like '%-$grade-%'";
  897. }
  898. if ($color) {
  899. $where .= " and features like '%-$color-%'";
  900. }
  901. if ($lacecolor) {
  902. $where .= " and features like '%-$lacecolor-%'";
  903. }
  904. if ($lowe) {
  905. $where .= " and features like '%-$lowe-%'";
  906. }
  907. if ($haircap) {
  908. $where .= " and features like '%-$haircap-%'";
  909. }
  910. if ($density) {
  911. $where .= " and features like '%-$density-%'";
  912. }
  913. if ($warehouse) {
  914. $where .= " and warehouse = '$warehouse'";
  915. }
  916. if ($details) {
  917. $where .= " and details = '$details'";
  918. }
  919. if ($purchase) {
  920. $where .= " and purchase = '$purchase'";
  921. }
  922. if ($state) {
  923. $where .= " and state = '$state'";
  924. }
  925. if ($ktime && $jtime) {
  926. $gj = " and enter > '$ktime' and enter < '$jtime'";
  927. $ck = " and outk > '$ktime' and outk < '$jtime'";
  928. }
  929. //数据排序
  930. $order_str = "id desc";
  931. if (empty($page)) {
  932. $start = 0;
  933. $perpage = 1;
  934. } else {
  935. $start = ($page - 1) * $perpage;
  936. }
  937. if ($sku) {
  938. $sku = trim($sku, ' ');
  939. $sku = trim($sku, ' ');
  940. $where .= " and sku like '%$sku%'";
  941. } else if ($title) {
  942. $title = trim($title, ' ');
  943. $title = trim($title, ' ');
  944. $where .= " and title like '%$title%'";
  945. }
  946. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  947. //取得信息列表
  948. $t = array();
  949. $typeclass = $this->typeclass->find_all();
  950. foreach ($typeclass as $v) {
  951. $t[$v['id']] = $v;
  952. }
  953. $rows = array();
  954. $list = array();
  955. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  956. foreach ($info_list as $key => $value) {
  957. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  958. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  959. $warehouse = $this->warehouse->read($value['warehouse']);
  960. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  961. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  962. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  963. $number = $value['number'];
  964. $ftime = time() - 15 * 24 * 3600;
  965. $z = count($z); //查看订单号
  966. $info_list[$key]['warehouse'] = $warehouse['title'];
  967. $info_list[$key]['features'] = count($c);
  968. $info_list[$key]['number'] = $z;
  969. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  970. $details = array();
  971. $cpid = array();
  972. foreach ($c as $k => $v) {
  973. $details[$v['details']] = $v['details'];
  974. if ($v['cpid'] != 0) {
  975. $cpid[$v['cpid']] = $v['cpid'];
  976. }
  977. }
  978. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  979. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  980. unset($info_list[$key]['pm']);
  981. unset($info_list[$key]['jm']);
  982. unset($info_list[$key]['bm']);
  983. }
  984. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  985. $pagenum = ceil($total / $perpage);
  986. $over = $total - ($start + $perpage);
  987. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  988. echo json_encode($rows);
  989. exit;
  990. }
  991. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  992. $this->_Template('whlabel_typeck', $this->data);
  993. }
  994. //进销存导出
  995. public function _whlabeckdc()
  996. {
  997. $prc = array();
  998. $purchase = $this->purchase->find_all();
  999. foreach ($purchase as $k => $v) {
  1000. $prc[$v['id']] = $v['title'];
  1001. }
  1002. if (isset($_GET['excel'])) {
  1003. $where = "sku != 'Preset'";
  1004. //数据排序
  1005. $order_str = "id desc";
  1006. if (empty($page)) {
  1007. $start = 0;
  1008. $perpage = 1;
  1009. } else {
  1010. $start = ($page - 1) * $perpage;
  1011. }
  1012. $category = $this->input->get('category', true);
  1013. $color = $this->input->get('color', true);
  1014. $lowe = $this->input->get('lowe', true);
  1015. $lacetype = $this->input->get('lacetype', true);
  1016. $size = $this->input->get('size', true);
  1017. $density = $this->input->get('density', true);
  1018. $haircap = $this->input->get('haircap', true);
  1019. $sku = $this->input->get('sku', true);
  1020. $details = $this->input->get('details', true);
  1021. $warehouse = 13;
  1022. $excelid = $this->input->get('sid', true);
  1023. if ($category) {
  1024. $where .= " and features like '%-$category-%'";
  1025. }
  1026. if ($color) {
  1027. $where .= " and features like '%-$color-%'";
  1028. }
  1029. if ($lowe) {
  1030. $where .= " and features like '%-$lowe-%'";
  1031. }
  1032. if ($lacetype) {
  1033. $where .= " and features like '%-$lacetype-%'";
  1034. }
  1035. if ($size) {
  1036. $where .= " and features like '%-$size-%'";
  1037. }
  1038. if ($density) {
  1039. $where .= " and features like '%-$density-%'";
  1040. }
  1041. if ($haircap) {
  1042. $where .= " and features like '%-$haircap-%'";
  1043. }
  1044. if ($warehouse) {
  1045. $where .= " and warehouse = '$warehouse'";
  1046. }
  1047. if ($sku) {
  1048. $where .= " and sku like '%$sku%'";
  1049. }
  1050. if ($details) {
  1051. $where .= " and details = '$details'";
  1052. }
  1053. $xzid = '';
  1054. if ($excelid) {
  1055. $excelid = explode(',', trim($excelid, ','));
  1056. foreach ($excelid as $key => $value) {
  1057. $xzid .= " id = " . $value . " or";
  1058. }
  1059. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1060. }
  1061. //取得信息列表
  1062. /**
  1063. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1064. $rows = array();$list = array();
  1065. foreach ($info_list as $key=>$value)
  1066. {
  1067. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1068. }
  1069. **/
  1070. $wh = array();
  1071. $w = $this->warehouse->find_all('1=1', 'id,title');
  1072. foreach ($w as $v) {
  1073. $wh[$v['id']] = $v['title'];
  1074. }
  1075. $tc = array();
  1076. $tcdata = array();
  1077. $list = array();
  1078. $classid = $this->classid->sku();
  1079. $tcall = $this->typeclass->find_all();
  1080. $typeclass = array();
  1081. foreach ($tcall as $v)
  1082. {
  1083. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1084. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1085. }
  1086. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1087. foreach ($rows as $key => $value) {
  1088. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1089. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1090. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1091. $rows[$key]['cpbz'] = $u9_info['bm'];
  1092. $rows[$key]['cs'] = $u9_info['jm'];
  1093. if(empty($value['details'])){
  1094. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1095. }else{
  1096. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1097. }
  1098. $details = array();
  1099. $cpid = array();
  1100. $cpbz = array();
  1101. $c = 0;
  1102. $g = 0;
  1103. $x = 0;
  1104. $t = 0;
  1105. $s = 0;
  1106. $q = 0;
  1107. foreach ($sd as $k => $v) {
  1108. if ($v['state'] == 0) {
  1109. $c++;
  1110. }
  1111. if ($v['state'] != 9) {
  1112. $g++;
  1113. }
  1114. if ($v['state'] == 1) {
  1115. $x++;
  1116. }
  1117. if ($v['state'] == 2) {
  1118. $t++;
  1119. }
  1120. if ($v['state'] == 8) {
  1121. $s++;
  1122. }
  1123. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1124. $q++;
  1125. }
  1126. $details[$v['details']] = $v['details'];
  1127. if ($v['cpid'] != 0) {
  1128. $cpid[$v['cpid']] = $v['cpid'];
  1129. }
  1130. if ($v['cpbz'] != '') {
  1131. $cpbz[$v['cpbz']] = $v['cpbz'];
  1132. }
  1133. }
  1134. $rows[$key]['details'] = implode("、", $details);
  1135. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1136. $number = $value['number'];
  1137. $ftime = time() - 15 * 24 * 3600;
  1138. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1139. $rows[$key]['number'] = $g;
  1140. $rows[$key]['features'] = $c;
  1141. $rows[$key]['x'] = $x;
  1142. $rows[$key]['t'] = $t;
  1143. $rows[$key]['s'] = $s;
  1144. $rows[$key]['q'] = $q;
  1145. $rows[$key]['wzsl'] = count($details);
  1146. //cpbzs
  1147. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1148. $unique_arr = array_unique($tmp_cpbzs);
  1149. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1150. }
  1151. $title = "进销存统计表" . date('Y-m-d', time());
  1152. $titlename = "<table border=1>
  1153. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1154. <tr align='center'>
  1155. <td>仓库</td>
  1156. <td>供应商</td>
  1157. <td>位置</td>
  1158. <td>库存编码</td>
  1159. <td>SKU</td>
  1160. <td>用友编码</td>
  1161. <td>用友料号</td>
  1162. <td>产品英文名</td>
  1163. <td>产品中文名</td>
  1164. <td>备注</td>
  1165. <td>入库总量</td>
  1166. <td>库存数量</td>
  1167. <td>销售数量</td>
  1168. <td>退货数量</td>
  1169. <td>删除数量</td>
  1170. <td>其它操作</td>
  1171. <td>位置数量</td>
  1172. </tr>
  1173. </table>";
  1174. $filename = $title . ".xls";
  1175. $tail = "";
  1176. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1177. }
  1178. }
  1179. public function _type()
  1180. {
  1181. $vip = 0;
  1182. if (isset($_SESSION['api'])) {
  1183. $user = $this->user->get_api($_SESSION['api']);
  1184. $fgshop = "";
  1185. $sid = "";
  1186. $usersp = explode('|', trim($user['shop'], '|'));
  1187. foreach ($usersp as $value) {
  1188. $fgshop .= " shop = " . $value . " or";
  1189. $sid .= " id = " . $value . " or";
  1190. }
  1191. if ($user['vip'] == 1) {
  1192. $vip = 1;
  1193. }
  1194. } else {
  1195. header('Location: /');
  1196. exit;
  1197. }
  1198. $prc = array();
  1199. $purchase = $this->purchase->find_all();
  1200. foreach ($purchase as $k => $v) {
  1201. $prc[$v['id']] = $v['title'];
  1202. }
  1203. $company = array();
  1204. $ct = $this->company->find_all();
  1205. foreach ($ct as $k => $v) {
  1206. $company[$v['id']] = $v['title'];
  1207. }
  1208. $sp = array();
  1209. $s = $this->shop->find_all('1=1', 'id,shopname');
  1210. foreach ($s as $v) {
  1211. $sp[$v['id']] = $v['shopname'];
  1212. }
  1213. $wh = array();
  1214. $w = $this->warehouse->find_all('1=1', 'id,title');
  1215. foreach ($w as $v) {
  1216. $wh[$v['id']] = $v['title'];
  1217. }
  1218. $post = $this->input->post(NULL, TRUE);
  1219. if (isset($post['page'])) {
  1220. $page = $this->input->post('page', true);
  1221. $perpage = $this->input->post('perpage', true);
  1222. $category = $this->input->post('category', true);
  1223. $size = $this->input->post('size', true);
  1224. $grade = $this->input->post('grade', true);
  1225. $color = $this->input->post('color', true);
  1226. $lowe = $this->input->post('lowe', true);
  1227. $sku = $this->input->post('sku');
  1228. $title = $this->input->post('title');
  1229. $warehouse = $this->input->post('warehouse', true);
  1230. $usa = $this->input->post('usa', true);
  1231. $purchase = $this->input->post('purchase', true);
  1232. $lacetype = $this->input->post('lacetype', true);
  1233. $haircap = $this->input->post('haircap', true);
  1234. $density = $this->input->post('density', true);
  1235. $details = $this->input->post('details', true);
  1236. $state = $this->input->post('state', true);
  1237. $shop = $this->input->post('shop', true);
  1238. $lacecolor = $this->input->post('lacecolor', true);
  1239. $hairnumber = $this->input->post('hairnumber', true);
  1240. $type = $this->input->post('type', true);
  1241. $ktime = $this->input->post('ktime', true);
  1242. $jtime = $this->input->post('jtime', true);
  1243. $ktime = strtotime($ktime);
  1244. $jtime = strtotime($jtime);
  1245. $cpbz = $this->input->post('cpbz', true);
  1246. $sm = $this->input->post('sm', true);
  1247. $where = "1=1";
  1248. $gj = "";
  1249. $ck = "";
  1250. if ($usa) {
  1251. if (!$warehouse) {
  1252. $where .= " and (warehouse = '5' or warehouse = '8')";
  1253. }
  1254. }
  1255. if ($warehouse) {
  1256. $where .= " and warehouse = '$warehouse'";
  1257. }
  1258. if ($details) {
  1259. $where .= " and details = '$details'";
  1260. }
  1261. if ($purchase) {
  1262. $where .= " and purchase = '$purchase'";
  1263. }
  1264. if ($state) {
  1265. $where .= " and state = '$state'";
  1266. }
  1267. if ($shop) {
  1268. $where .= " and shop like '%$shop%'";
  1269. }
  1270. if ($type) {
  1271. $where .= " and type = '$type'";
  1272. }
  1273. if ($ktime && $jtime) {
  1274. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1275. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1276. }
  1277. if ($cpbz) {
  1278. $where .= " and cpbz like '%$cpbz%' ";
  1279. }
  1280. if ($sm) {
  1281. $where .= " and sm like '%$sm%' ";
  1282. }
  1283. if ($lacecolor) {
  1284. $where .= " and features like '%-$lacecolor-%'";
  1285. }
  1286. if ($lacetype) {
  1287. $where .= " and features like '%-$lacetype-%'";
  1288. }
  1289. if ($category) {
  1290. $where .= " and features like '%-$category-%'";
  1291. }
  1292. if ($size) {
  1293. $where .= " and features like '%-$size-%'";
  1294. }
  1295. if ($grade) {
  1296. $where .= " and features like '%-$grade-%'";
  1297. }
  1298. if ($color) {
  1299. $where .= " and features like '%-$color-%'";
  1300. }
  1301. if ($lowe) {
  1302. $where .= " and features like '%-$lowe-%'";
  1303. }
  1304. if ($haircap) {
  1305. $where .= " and features like '%-$haircap-%'";
  1306. }
  1307. if ($density) {
  1308. $where .= " and features like '%-$density-%'";
  1309. }
  1310. if (!empty($hairnumber)) {
  1311. $where .= " and features like '%-128-%' ";
  1312. if ($hairnumber < 0) {
  1313. $class_list = $this->typeclass->find_all('classid = 43');
  1314. foreach ($class_list as $v) {
  1315. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1316. }
  1317. } else {
  1318. $where .= " and features like '%-$hairnumber-%'";
  1319. }
  1320. }
  1321. //数据排序
  1322. $order_str = "id desc";
  1323. if (empty($page)) {
  1324. $start = 0;
  1325. $perpage = 1;
  1326. } else {
  1327. $start = ($page - 1) * $perpage;
  1328. }
  1329. $fjnr = '';
  1330. if ($sku) {
  1331. $sku = trim($sku, ' ');
  1332. $sku = trim($sku, ' ');
  1333. $fjnr .= " and sku like '%$sku%'";
  1334. }
  1335. if ($title) {
  1336. $title = trim($title, ' ');
  1337. $title = trim($title, ' ');
  1338. $fjnr .= " and title like '%$title%'";
  1339. }
  1340. $wt = array();
  1341. $whlabel_type = $this->whlabel_type->find_all();
  1342. foreach ($whlabel_type as $v) {
  1343. $wt[$v['id']] = $v['title'];
  1344. }
  1345. //$where .= " and time > '$ktime' and time < '$jtime'";
  1346. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1347. //取得信息列表
  1348. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1349. $rows = array();
  1350. $list = array();
  1351. foreach ($info_list as $key => $value) {
  1352. if (isset($wt[$value['type']])) {
  1353. $info_list[$key]['type'] = $wt[$value['type']];
  1354. } else {
  1355. $info_list[$key]['type'] = '未设置';
  1356. }
  1357. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1358. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1359. $ztdata = '';
  1360. if (count($zt) > 0) {
  1361. foreach ($zt as $vv) {
  1362. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1363. }
  1364. }
  1365. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1366. $cdata = array_filter($qbdata, function ($item) {
  1367. return $item['state'] < 1;
  1368. });
  1369. $c = array_sum(array_column($cdata, 'jnum'));
  1370. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1371. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1372. });
  1373. $g = array_sum(array_column($gdata, 'jnum'));
  1374. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1375. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1376. });
  1377. $x = array_sum(array_column($xdata, 'jnum'));
  1378. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1379. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1380. });
  1381. $t = array_sum(array_column($tdata, 'jnum'));
  1382. // $zdata = array_filter($qbdata, function ($item) {
  1383. // return $item['zd'] != "" && $item['state'] < 1;
  1384. // });
  1385. // $z = array_sum(array_column($zdata, 'jnum'));
  1386. $zdata = array_filter($qbdata, function ($item) {
  1387. return $item['zd'] != "" && $item['state'] < 1;
  1388. });
  1389. $z = array_sum(array_column($zdata, 'jnum'));
  1390. //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1391. //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1392. //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1393. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1394. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1395. $details = array();
  1396. $cpid = array();
  1397. $od = array();
  1398. $odid = '';
  1399. $companytitle = '';
  1400. $shop_list = [];
  1401. foreach ($qbdata as $v) {
  1402. if ($v['zd'] != "" && $v['state'] < 1) {
  1403. if (!isset($od[$v['zd']])) {
  1404. $od[$v['zd']] = 1; //所有数据sku
  1405. } else {
  1406. $od[$v['zd']] = $od[$v['zd']] + 1;
  1407. }
  1408. }
  1409. if($v['state'] == 0){
  1410. $details[$v['details']] = $v['details'];
  1411. }
  1412. if ($v['state'] < 1) {
  1413. //$details[$v['details']] = $v['details'];
  1414. if ($v['cpid'] != 0) {
  1415. $cpid[$v['cpid']] = $v['cpid'];
  1416. }
  1417. }
  1418. if($v['state'] == 0){
  1419. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1420. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1421. }
  1422. if ($v['shop'] != '') {
  1423. $shop = explode(',', trim($v['shop'], ','));
  1424. foreach ($shop as $vv) {
  1425. if (!in_array($vv, $shop_list)) {
  1426. $shop_list[] = $vv;
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. foreach ($od as $k => $vv) {
  1433. $odid .= $k . '数量' . $vv;
  1434. }
  1435. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1436. $info_list[$key]['label'] = $value['sm'];
  1437. $number = $value['number'];
  1438. $ftime = time() - 15 * 24 * 3600;
  1439. $z = $z . '(' . $odid . ')'; //查看订单号
  1440. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1441. $info_list[$key]['features'] = $c;
  1442. $info_list[$key]['number'] = $ztdata;
  1443. $info_list[$key]['sm'] = $g;
  1444. $info_list[$key]['x'] = $x;
  1445. $info_list[$key]['t'] = $t;
  1446. $info_list[$key]['z'] = $z;
  1447. /**
  1448. foreach ($cdata as $k=>$v)
  1449. {
  1450. $details[$v['details']] = $v['details'];
  1451. if($v['cpid'] != 0)
  1452. {
  1453. $cpid[$v['cpid']] = $v['cpid'];
  1454. }
  1455. }
  1456. **/
  1457. $info_list[$key]['shop'] = '';
  1458. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1459. // if ($value['shop'] != '') {
  1460. // $shop = explode(',', trim($value['shop'], ','));
  1461. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1462. // }
  1463. $shop_list = array_unique($shop_list);
  1464. $shop_str = '';
  1465. foreach ($shop_list as $v) {
  1466. if(isset($sp[$v])){
  1467. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1468. }
  1469. }
  1470. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1471. /**
  1472. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1473. if(isset($companytitle[0]))
  1474. {
  1475. foreach ($companytitle as $k=>$v)
  1476. {
  1477. if($v['companytitle'] != '')
  1478. {
  1479. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1480. }
  1481. }
  1482. }
  1483. **/
  1484. }
  1485. $final_all_list = [];
  1486. foreach ($info_list as $k => $v) {
  1487. $final_all_list[] = [
  1488. 'id' => $v['id'],
  1489. "warehouse" => $v["warehouse"],
  1490. "purchase" => $v["purchase"],
  1491. "sku" => $v["sku"],
  1492. "title" => $v["title"] . "<br/>" . $v["pm"],
  1493. "details" => $v["details"],
  1494. "shop" => $v["shop"],
  1495. "cpbz" => $v["cpbz"],
  1496. 'label' => $v['label'],
  1497. "type" => $v["type"],
  1498. "features" => $v["features"],
  1499. "number" => $v["number"],
  1500. "sm" => $v["sm"],
  1501. "x" => $v["x"],
  1502. "t" => $v["t"],
  1503. "z" => $v["z"]
  1504. ];
  1505. }
  1506. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1507. $pagenum = ceil($total / $perpage);
  1508. $over = $total - ($start + $perpage);
  1509. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1510. echo json_encode($rows);
  1511. exit;
  1512. }
  1513. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1514. $this->data['shop'] = $wlshop;
  1515. $this->data['vip'] = $vip;
  1516. $this->_Template('whlabel_type', $this->data);
  1517. }
  1518. /**
  1519. * _type 优化版 v1
  1520. * 优化点:
  1521. * 1. 循环内 N+1 查询改为批量预取(方案 A),SQL 从 2+2P 降到固定 4 条
  1522. * 2. 总数统计改为只 COUNT 不传输明细字段(方案 C)
  1523. * 3. 批量 qbdata 查询去掉 features like 条件,走组合键 IN 精确匹配
  1524. * 4. 批量 transport 查询加 ORDER BY stime 保证顺序与原来一致
  1525. */
  1526. public function _typev1()
  1527. {
  1528. $vip = 0;
  1529. if (isset($_SESSION['api'])) {
  1530. $user = $this->user->get_api($_SESSION['api']);
  1531. $fgshop = "";
  1532. $sid = "";
  1533. $usersp = explode('|', trim($user['shop'], '|'));
  1534. foreach ($usersp as $value) {
  1535. $fgshop .= " shop = " . $value . " or";
  1536. $sid .= " id = " . $value . " or";
  1537. }
  1538. if ($user['vip'] == 1) {
  1539. $vip = 1;
  1540. }
  1541. } else {
  1542. header('Location: /');
  1543. exit;
  1544. }
  1545. $prc = array();
  1546. $purchase = $this->purchase->find_all();
  1547. foreach ($purchase as $k => $v) {
  1548. $prc[$v['id']] = $v['title'];
  1549. }
  1550. $company = array();
  1551. $ct = $this->company->find_all();
  1552. foreach ($ct as $k => $v) {
  1553. $company[$v['id']] = $v['title'];
  1554. }
  1555. $sp = array();
  1556. $s = $this->shop->find_all('1=1', 'id,shopname');
  1557. foreach ($s as $v) {
  1558. $sp[$v['id']] = $v['shopname'];
  1559. }
  1560. $wh = array();
  1561. $w = $this->warehouse->find_all('1=1', 'id,title');
  1562. foreach ($w as $v) {
  1563. $wh[$v['id']] = $v['title'];
  1564. }
  1565. $post = $this->input->post(NULL, TRUE);
  1566. if (isset($post['page'])) {
  1567. $page = $this->input->post('page', true);
  1568. $perpage = $this->input->post('perpage', true);
  1569. $category = $this->input->post('category', true);
  1570. $size = $this->input->post('size', true);
  1571. $grade = $this->input->post('grade', true);
  1572. $color = $this->input->post('color', true);
  1573. $lowe = $this->input->post('lowe', true);
  1574. $sku = $this->input->post('sku');
  1575. $title = $this->input->post('title');
  1576. $warehouse = $this->input->post('warehouse', true);
  1577. $usa = $this->input->post('usa', true);
  1578. $purchase = $this->input->post('purchase', true);
  1579. $lacetype = $this->input->post('lacetype', true);
  1580. $haircap = $this->input->post('haircap', true);
  1581. $density = $this->input->post('density', true);
  1582. $details = $this->input->post('details', true);
  1583. $state = $this->input->post('state', true);
  1584. $shop = $this->input->post('shop', true);
  1585. $lacecolor = $this->input->post('lacecolor', true);
  1586. $hairnumber = $this->input->post('hairnumber', true);
  1587. $type = $this->input->post('type', true);
  1588. $ktime = $this->input->post('ktime', true);
  1589. $jtime = $this->input->post('jtime', true);
  1590. $ktime = strtotime($ktime);
  1591. $jtime = strtotime($jtime);
  1592. $cpbz = $this->input->post('cpbz', true);
  1593. $sm = $this->input->post('sm', true);
  1594. $where = "1=1";
  1595. // $where_no_features 用于批量预取,去掉 features like 条件,靠组合键精确匹配
  1596. $where_no_features = "1=1";
  1597. if ($usa) {
  1598. if (!$warehouse) {
  1599. $where .= " and (warehouse = '5' or warehouse = '8')";
  1600. $where_no_features .= " and (warehouse = '5' or warehouse = '8')";
  1601. }
  1602. }
  1603. if ($warehouse) {
  1604. $where .= " and warehouse = '$warehouse'";
  1605. $where_no_features .= " and warehouse = '$warehouse'";
  1606. }
  1607. if ($details) {
  1608. $where .= " and details = '$details'";
  1609. $where_no_features .= " and details = '$details'";
  1610. }
  1611. if ($purchase) {
  1612. $where .= " and purchase = '$purchase'";
  1613. $where_no_features .= " and purchase = '$purchase'";
  1614. }
  1615. if ($state) {
  1616. $where .= " and state = '$state'";
  1617. $where_no_features .= " and state = '$state'";
  1618. }
  1619. if ($shop) {
  1620. $where .= " and shop like '%$shop%'";
  1621. $where_no_features .= " and shop like '%$shop%'";
  1622. }
  1623. if ($type) {
  1624. $where .= " and type = '$type'";
  1625. $where_no_features .= " and type = '$type'";
  1626. }
  1627. if ($cpbz) {
  1628. $where .= " and cpbz like '%$cpbz%' ";
  1629. $where_no_features .= " and cpbz like '%$cpbz%' ";
  1630. }
  1631. if ($sm) {
  1632. $where .= " and sm like '%$sm%' ";
  1633. $where_no_features .= " and sm like '%$sm%' ";
  1634. }
  1635. // features like 条件只加入 $where(列表分组用),不加入 $where_no_features
  1636. if ($lacecolor) {
  1637. $where .= " and features like '%-$lacecolor-%'";
  1638. }
  1639. if ($lacetype) {
  1640. $where .= " and features like '%-$lacetype-%'";
  1641. }
  1642. if ($category) {
  1643. $where .= " and features like '%-$category-%'";
  1644. }
  1645. if ($size) {
  1646. $where .= " and features like '%-$size-%'";
  1647. }
  1648. if ($grade) {
  1649. $where .= " and features like '%-$grade-%'";
  1650. }
  1651. if ($color) {
  1652. $where .= " and features like '%-$color-%'";
  1653. }
  1654. if ($lowe) {
  1655. $where .= " and features like '%-$lowe-%'";
  1656. }
  1657. if ($haircap) {
  1658. $where .= " and features like '%-$haircap-%'";
  1659. }
  1660. if ($density) {
  1661. $where .= " and features like '%-$density-%'";
  1662. }
  1663. if (!empty($hairnumber)) {
  1664. $where .= " and features like '%-128-%' ";
  1665. if ($hairnumber < 0) {
  1666. $class_list = $this->typeclass->find_all('classid = 43');
  1667. foreach ($class_list as $v) {
  1668. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1669. }
  1670. } else {
  1671. $where .= " and features like '%-$hairnumber-%'";
  1672. }
  1673. }
  1674. //数据排序
  1675. $order_str = "id desc";
  1676. if (empty($page)) {
  1677. $start = 0;
  1678. $perpage = 1;
  1679. } else {
  1680. $start = ($page - 1) * $perpage;
  1681. }
  1682. $fjnr = '';
  1683. if ($sku) {
  1684. $sku = trim($sku, ' ');
  1685. $sku = trim($sku, ' ');
  1686. $fjnr .= " and sku like '%$sku%'";
  1687. }
  1688. if ($title) {
  1689. $title = trim($title, ' ');
  1690. $title = trim($title, ' ');
  1691. $fjnr .= " and title like '%$title%'";
  1692. }
  1693. $wt = array();
  1694. $whlabel_type = $this->whlabel_type->find_all();
  1695. foreach ($whlabel_type as $v) {
  1696. $wt[$v['id']] = $v['title'];
  1697. }
  1698. // 列表分组(与原来完全一致)
  1699. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage);
  1700. //取得信息列表
  1701. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1702. // ========== 优化方案 A:批量预取 whlabel 组数据和 transport 数据 ==========
  1703. $keys = array();
  1704. foreach ($info_list as $v) {
  1705. $keys[] = "('" . addslashes($v['sku']) . "','" . addslashes($v['purchase'])
  1706. . "','" . addslashes($v['features']) . "','" . addslashes($v['warehouse']) . "')";
  1707. }
  1708. // 组合键函数,用于 PHP 端按分组索引
  1709. $comboKey = function ($r) {
  1710. return $r['sku'] . '|' . $r['purchase'] . '|' . $r['features'] . '|' . $r['warehouse'];
  1711. };
  1712. // 批量拉取 whlabel 组数据(使用 $where_no_features,不带 features like,靠 IN 元组精确匹配)
  1713. $all_qb = array();
  1714. if (!empty($keys)) {
  1715. $keyInSql = implode(',', $keys);
  1716. $qbAll = $this->whlabel->find_all(
  1717. $where_no_features . " and (sku,purchase,features,warehouse) IN (" . $keyInSql . ")"
  1718. );
  1719. foreach ($qbAll as $r) {
  1720. $all_qb[$comboKey($r)][] = $r;
  1721. }
  1722. }
  1723. // 批量拉取 transport 在途数据(3 列元组: sku,warehouse,features,与 IN 左侧列顺序一致)
  1724. $all_zt = array();
  1725. if (!empty($info_list)) {
  1726. $ztKeys = array();
  1727. foreach ($info_list as $v) {
  1728. $ztKeys[] = "('" . addslashes($v['sku']) . "','"
  1729. . addslashes($v['warehouse']) . "','"
  1730. . addslashes($v['features']) . "')";
  1731. }
  1732. $ztInSql = implode(',', $ztKeys);
  1733. $ztAll = $this->whlabeltransport->find_all(
  1734. "cz = '0' and (sku,warehouse,features) IN (" . $ztInSql . ")",
  1735. '*',
  1736. 'stime'
  1737. );
  1738. foreach ($ztAll as $r) {
  1739. $ck = $r['sku'] . '|' . $r['warehouse'] . '|' . $r['features'];
  1740. $all_zt[$ck][] = $r;
  1741. }
  1742. }
  1743. $rows = array();
  1744. $list = array();
  1745. foreach ($info_list as $key => $value) {
  1746. if (isset($wt[$value['type']])) {
  1747. $info_list[$key]['type'] = $wt[$value['type']];
  1748. } else {
  1749. $info_list[$key]['type'] = '未设置';
  1750. }
  1751. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1752. // transport 在途数据:从预取数组中取
  1753. $ztCk = $value['sku'] . '|' . $value['warehouse'] . '|' . $value['features'];
  1754. $zt = isset($all_zt[$ztCk]) ? $all_zt[$ztCk] : array();
  1755. $ztdata = '';
  1756. if (count($zt) > 0) {
  1757. foreach ($zt as $vv) {
  1758. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1759. }
  1760. }
  1761. // whlabel 组数据:从预取数组中取
  1762. $qbCk = $comboKey($value);
  1763. $qbdata = isset($all_qb[$qbCk]) ? $all_qb[$qbCk] : array();
  1764. $cdata = array_filter($qbdata, function ($item) {
  1765. return $item['state'] < 1;
  1766. });
  1767. $c = array_sum(array_column($cdata, 'jnum'));
  1768. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1769. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1770. });
  1771. $g = array_sum(array_column($gdata, 'jnum'));
  1772. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1773. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1774. });
  1775. $x = array_sum(array_column($xdata, 'jnum'));
  1776. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1777. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1778. });
  1779. $t = array_sum(array_column($tdata, 'jnum'));
  1780. $zdata = array_filter($qbdata, function ($item) {
  1781. return $item['zd'] != "" && $item['state'] < 1;
  1782. });
  1783. $z = array_sum(array_column($zdata, 'jnum'));
  1784. $detailsArr = array();
  1785. $cpid = array();
  1786. $od = array();
  1787. $odid = '';
  1788. $companytitle = '';
  1789. $shop_list = [];
  1790. foreach ($qbdata as $v) {
  1791. if ($v['zd'] != "" && $v['state'] < 1) {
  1792. if (!isset($od[$v['zd']])) {
  1793. $od[$v['zd']] = 1;
  1794. } else {
  1795. $od[$v['zd']] = $od[$v['zd']] + 1;
  1796. }
  1797. }
  1798. if ($v['state'] == 0) {
  1799. $detailsArr[$v['details']] = $v['details'];
  1800. }
  1801. if ($v['state'] < 1) {
  1802. if ($v['cpid'] != 0) {
  1803. $cpid[$v['cpid']] = $v['cpid'];
  1804. }
  1805. }
  1806. if ($v['state'] == 0) {
  1807. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1808. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1809. }
  1810. if ($v['shop'] != '') {
  1811. $shopArr = explode(',', trim($v['shop'], ','));
  1812. foreach ($shopArr as $vv) {
  1813. if (!in_array($vv, $shop_list)) {
  1814. $shop_list[] = $vv;
  1815. }
  1816. }
  1817. }
  1818. }
  1819. }
  1820. foreach ($od as $k => $vv) {
  1821. $odid .= $k . '数量' . $vv;
  1822. }
  1823. $info_list[$key]['cpbz'] = $value['cpbz'];
  1824. $info_list[$key]['label'] = $value['sm'];
  1825. $number = $value['number'];
  1826. $z = $z . '(' . $odid . ')';
  1827. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1828. $info_list[$key]['features'] = $c;
  1829. $info_list[$key]['number'] = $ztdata;
  1830. $info_list[$key]['sm'] = $g;
  1831. $info_list[$key]['x'] = $x;
  1832. $info_list[$key]['t'] = $t;
  1833. $info_list[$key]['z'] = $z;
  1834. $info_list[$key]['shop'] = '';
  1835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $detailsArr) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $detailsArr);
  1836. $shop_list = array_unique($shop_list);
  1837. $shop_str = '';
  1838. foreach ($shop_list as $v) {
  1839. if (isset($sp[$v])) {
  1840. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1841. }
  1842. }
  1843. $info_list[$key]['shop'] = $shop_str . $companytitle;
  1844. }
  1845. $final_all_list = [];
  1846. foreach ($info_list as $k => $v) {
  1847. $final_all_list[] = [
  1848. 'id' => $v['id'],
  1849. "warehouse" => $v["warehouse"],
  1850. "purchase" => $v["purchase"],
  1851. "sku" => $v["sku"],
  1852. "title" => $v["title"] . "<br/>" . $v["pm"],
  1853. "details" => $v["details"],
  1854. "shop" => $v["shop"],
  1855. "cpbz" => $v["cpbz"],
  1856. 'label' => $v['label'],
  1857. "type" => $v["type"],
  1858. "features" => $v["features"],
  1859. "number" => $v["number"],
  1860. "sm" => $v["sm"],
  1861. "x" => $v["x"],
  1862. "t" => $v["t"],
  1863. "z" => $v["z"]
  1864. ];
  1865. }
  1866. // ========== 优化方案 C:总数统计只 COUNT,不传明细字段 ==========
  1867. // 原实现: count(find_pc(..., 'id,warehouse,sku,title,features,number')),传输了大量明细字段
  1868. // 优化为: SELECT COUNT(*) FROM (SELECT 1 FROM whlabel WHERE ... GROUP BY ...) t,只传一个数字
  1869. $countSql = "SELECT COUNT(*) AS cnt FROM (SELECT 1 FROM crowd_whlabel WHERE " . $where . $fjnr . " GROUP BY sku,purchase,features,warehouse) t";
  1870. $countResult = $this->whlabel->query($countSql)->result_array();
  1871. $total = isset($countResult[0]['cnt']) ? (int)$countResult[0]['cnt'] : 0;
  1872. $pagenum = ceil($total / $perpage);
  1873. $over = $total - ($start + $perpage);
  1874. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1875. echo json_encode($rows);
  1876. exit;
  1877. }
  1878. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1879. $this->data['shop'] = $wlshop;
  1880. $this->data['vip'] = $vip;
  1881. $this->_Template('whlabel_typev1', $this->data);
  1882. }
  1883. //美仓进销存浏览
  1884. public function _usatype()
  1885. {
  1886. if (isset($_SESSION['api'])) {
  1887. $user = $this->user->get_api($_SESSION['api']);
  1888. $usp = $user;
  1889. $fgshop = "";
  1890. $sid = "";
  1891. $wid = "";
  1892. $wtype = "";
  1893. $userwh = explode('|', trim($user['warehouse'], '|'));
  1894. foreach ($userwh as $value) {
  1895. $wid .= " id = " . $value . " or";
  1896. $wtype .= " type = " . $value . " or";
  1897. }
  1898. }
  1899. $prc = array();
  1900. $purchase = $this->purchase->find_all();
  1901. foreach ($purchase as $k => $v) {
  1902. $prc[$v['id']] = $v['title'];
  1903. }
  1904. $post = $this->input->post(NULL, TRUE);
  1905. if (isset($post['page'])) {
  1906. $page = $this->input->post('page', true);
  1907. $perpage = $this->input->post('perpage', true);
  1908. $category = $this->input->post('category', true);
  1909. $size = $this->input->post('size', true);
  1910. $grade = $this->input->post('grade', true);
  1911. $color = $this->input->post('color', true);
  1912. $lowe = $this->input->post('lowe', true);
  1913. $sku = $this->input->post('sku');
  1914. $title = $this->input->post('title');
  1915. $warehouse = $this->input->post('warehouse', true);
  1916. $usa = $this->input->post('usa', true);
  1917. $purchase = $this->input->post('purchase', true);
  1918. $lacetype = $this->input->post('lacetype', true);
  1919. $haircap = $this->input->post('haircap', true);
  1920. $density = $this->input->post('density', true);
  1921. $details = $this->input->post('details', true);
  1922. $state = $this->input->post('state', true);
  1923. $lacecolor = $this->input->post('lacecolor', true);
  1924. $cklx = $this->input->post('cklx', true);
  1925. $ktime = $this->input->post('ktime', true);
  1926. $jtime = $this->input->post('jtime', true);
  1927. $ktime = strtotime($ktime);
  1928. $jtime = strtotime($jtime);
  1929. $where = "1=1";
  1930. $gj = "";
  1931. $ck = "";
  1932. if ($lacetype) {
  1933. $where .= " and features like '%-$lacetype-%'";
  1934. }
  1935. if ($category) {
  1936. $where .= " and features like '%-$category-%'";
  1937. }
  1938. if ($size) {
  1939. $where .= " and features like '%-$size-%'";
  1940. }
  1941. if ($grade) {
  1942. $where .= " and features like '%-$grade-%'";
  1943. }
  1944. if ($color) {
  1945. $where .= " and features like '%-$color-%'";
  1946. }
  1947. if ($lowe) {
  1948. $where .= " and features like '%-$lowe-%'";
  1949. }
  1950. if ($haircap) {
  1951. $where .= " and features like '%-$haircap-%'";
  1952. }
  1953. if ($density) {
  1954. $where .= " and features like '%-$density-%'";
  1955. }
  1956. if ($lacecolor) {
  1957. $where .= " and features like '%-$lacecolor-%'";
  1958. }
  1959. if ($usa) {
  1960. if (!$warehouse) {
  1961. $where .= " and (warehouse = '5' or warehouse = '8')";
  1962. }
  1963. }
  1964. if ($warehouse) {
  1965. $where .= " and warehouse = '$warehouse'";
  1966. }
  1967. if ($details) {
  1968. $where .= " and details = '$details'";
  1969. }
  1970. if ($purchase) {
  1971. $where .= " and purchase = '$purchase'";
  1972. }
  1973. if ($state) {
  1974. $where .= " and state = '$state'";
  1975. }
  1976. $where_add = '';
  1977. if ($cklx) {
  1978. $shop = $this->shop->read($cklx);
  1979. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1980. }
  1981. if ($ktime && $jtime) {
  1982. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1983. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1984. }
  1985. //数据排序
  1986. $order_str = "id desc";
  1987. if (empty($page)) {
  1988. $start = 0;
  1989. $perpage = 1;
  1990. } else {
  1991. $start = ($page - 1) * $perpage;
  1992. }
  1993. if ($sku) {
  1994. $sku = trim($sku, ' ');
  1995. $sku = trim($sku, ' ');
  1996. $where .= " and sku like '%$sku%'";
  1997. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1998. } else if ($title) {
  1999. $title = trim($title, ' ');
  2000. $title = trim($title, ' ');
  2001. $where .= " and title like '%$title%'";
  2002. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2003. } else {
  2004. //$where .= " and time > '$ktime' and time < '$jtime'";
  2005. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2006. }
  2007. //取得信息列表
  2008. $rows = array();
  2009. $list = array();
  2010. foreach ($info_list as $key => $value) {
  2011. $warehouse = $this->warehouse->read($value['warehouse']);
  2012. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2013. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2014. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2015. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2016. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2017. $od = array();
  2018. $odid = '';
  2019. foreach ($z as $v) {
  2020. if (!isset($od[$v['zd']])) {
  2021. $od[$v['zd']] = 1; //所有数据sku
  2022. } else {
  2023. $od[$v['zd']] = $od[$v['zd']] + 1;
  2024. }
  2025. }
  2026. foreach ($od as $k => $vv) {
  2027. $odid .= $k . '数量' . $vv . ' ';
  2028. }
  2029. $z = count($z) . '(' . $odid . ')'; //查看订单号
  2030. $info_list[$key]['features'] = $c;
  2031. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  2032. $ztdata = '';
  2033. if (count($zt) > 0) {
  2034. foreach ($zt as $vv) {
  2035. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  2036. }
  2037. }
  2038. $info_list[$key]['warehouse'] = $ztdata;
  2039. $info_list[$key]['g'] = $g;
  2040. $info_list[$key]['x'] = $x;
  2041. $info_list[$key]['t'] = $t;
  2042. $info_list[$key]['z'] = $z;
  2043. }
  2044. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  2045. $pagenum = ceil($total / $perpage);
  2046. $over = $total - ($start + $perpage);
  2047. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  2048. echo json_encode($rows);
  2049. exit;
  2050. }
  2051. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  2052. $this->data['warehouse'] = $warehouse;
  2053. $this->_Template('whlabel_typeusa', $this->data);
  2054. }
  2055. //美仓进销存浏览
  2056. public function _usatypeapp()
  2057. {
  2058. $post = $this->input->post(NULL, TRUE);
  2059. if (isset($post['page'])) {
  2060. $page = $this->input->post('page', true);
  2061. $perpage = $this->input->post('perpage', true);
  2062. $sku = $this->input->post('sku', true);
  2063. $warehouse = 5;
  2064. $title = $this->input->post('title', true);
  2065. $state = $this->input->post('state', true);
  2066. $ktime = $this->input->post('ktime', true);
  2067. $jtime = $this->input->post('jtime', true);
  2068. $ktime = strtotime($ktime);
  2069. $jtime = strtotime($jtime);
  2070. $where = "1=1";
  2071. $gj = "";
  2072. $ck = "";
  2073. if ($title) {
  2074. $st = explode(' ', trim($title, ' '));
  2075. foreach ($st as $v) {
  2076. $where .= " and title like '%$v%'";
  2077. }
  2078. }
  2079. if ($warehouse) {
  2080. $where .= " and warehouse = '$warehouse'";
  2081. }
  2082. if ($state) {
  2083. $where .= " and state = '$state'";
  2084. }
  2085. if ($sku) {
  2086. $where .= " and sku like '%$sku%'";
  2087. }
  2088. if ($ktime && $jtime) {
  2089. $gj = " and enter > '$ktime' and enter < '$jtime'";
  2090. $ck = " and outk > '$ktime' and outk < '$jtime'";
  2091. }
  2092. //数据排序
  2093. $order_str = "id desc";
  2094. if (empty($page)) {
  2095. $start = 0;
  2096. $perpage = 1;
  2097. } else {
  2098. $start = ($page - 1) * $perpage;
  2099. }
  2100. //取得信息列表
  2101. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  2102. $rows = array();
  2103. $list = array();
  2104. foreach ($info_list as $key => $value) {
  2105. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  2106. }
  2107. $rowsdq = array_slice($rows, $start, $perpage);
  2108. foreach ($rowsdq as $value) {
  2109. $warehouse = $this->warehouse->read($value['warehouse']);
  2110. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  2111. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  2112. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2113. $od = array();
  2114. $odid = '';
  2115. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  2116. }
  2117. $total = count($rows);
  2118. $pagenum = ceil($total / $perpage);
  2119. $over = $total - ($start + $perpage);
  2120. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2121. echo json_encode($rows);
  2122. exit;
  2123. }
  2124. $this->_Template('phone/p_usatypeapp', $this->data);
  2125. }
  2126. //入库操作
  2127. public function _enteradd()
  2128. {
  2129. $dt = 0;
  2130. if (isset($_SESSION['api'])) {
  2131. $user = $this->user->get_api($_SESSION['api']);
  2132. $usp = $user;
  2133. $fgshop = "";
  2134. $sid = "";
  2135. $user = explode('|', trim($user['shop'], '|'));
  2136. foreach ($user as $value) {
  2137. $fgshop .= " shop = " . $value . " or";
  2138. $sid .= " id = " . $value . " or";
  2139. }
  2140. }
  2141. $tc = $this->typeclass->find_all();
  2142. $typeclass = array();
  2143. foreach ($tc as $v) {
  2144. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  2145. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  2146. }
  2147. $post = $this->input->post(NULL, TRUE);
  2148. if (isset($post['sku'])) {
  2149. $list = array();
  2150. $num = "";
  2151. $title = "";
  2152. $features = "";
  2153. $order = $this->input->post('order', true);
  2154. $shop = $this->input->post('shop', true);
  2155. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2156. $sku = $this->input->post('sku', true);
  2157. $post['sm'] = $this->input->post('sm', true);
  2158. $post['warehouse'] = $this->input->post('warehouse', true);
  2159. $post['purchase'] = $this->input->post('purchase', true);
  2160. $post['retreatwarehouse'] = $post['warehouse'];
  2161. $post['state'] = $this->input->post('state', true);
  2162. $post['rktype'] = $this->input->post('rktype', true);
  2163. $post['text'] = $this->input->post('text', true);
  2164. $category = $this->input->post('category', true);
  2165. $list['category'] = $category;
  2166. $list['hairtype'] = $this->input->post('hairtype', true);
  2167. $list['grade'] = $this->input->post('grade', true);
  2168. $size = $this->input->post('size', true);
  2169. $xzsku = $this->input->post('xzsku', true);
  2170. $list['size'] = rtrim($size, ',');
  2171. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2172. $list['extension'] = $this->input->post('extension', true);
  2173. if ($category == 1297) {
  2174. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2175. }
  2176. if ($category == 1702) {
  2177. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2178. $list['syother'] = $this->input->post('syother', true);
  2179. }
  2180. if ($category == 133) {
  2181. $list['fittype'] = $this->input->post('fittype', true);
  2182. $list['acother'] = $this->input->post('acother', true);
  2183. }
  2184. $list['color'] = $this->input->post('color', true);
  2185. $list['lowe'] = $this->input->post('lowe', true);
  2186. if (!$post['purchase']) {
  2187. $post['purchase'] = 1;
  2188. }
  2189. if ($category == 127) {
  2190. $list['type'] = $this->input->post('type', true);
  2191. $list['headroad'] = $this->input->post('headroad', true);
  2192. $list['density'] = $this->input->post('density', true);
  2193. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2194. $list['lacesize'] = $this->input->post('lacesize', true);
  2195. }
  2196. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2197. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2198. }
  2199. if ($category == 128) {
  2200. $list['lacetype'] = $this->input->post('lacetype', true);
  2201. $list['haircap'] = $this->input->post('haircap', true);
  2202. $list['density'] = $this->input->post('density', true);
  2203. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2204. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2205. $list['wigother'] = $this->input->post('wigother', true);
  2206. $list['wigother1'] = $this->input->post('wigother1', true);
  2207. $list['wigother2'] = $this->input->post('wigother2', true);
  2208. $list['product_related'] = $this->input->post('product_related', true);
  2209. }
  2210. if ($category == 129) {
  2211. $list['wide'] = $this->input->post('wide', true);
  2212. }
  2213. if ($category == 131) {
  2214. $list['gifttype'] = $this->input->post('gifttype', true);
  2215. $list['giftother'] = $this->input->post('giftother', true);
  2216. }
  2217. if ($category == 134) {
  2218. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2219. }
  2220. if ($category == 1297) {
  2221. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2222. $list['sywigother'] = $this->input->post('sywigother', true);
  2223. }
  2224. if ($category == 130 || $category == 133 || $category == 1702) {
  2225. $list['items'] = $this->input->post('items', true);
  2226. $list['weight'] = $this->input->post('weight', true);
  2227. }
  2228. if($category == 130){
  2229. $list['jfother'] = $this->input->post('jfother', true);
  2230. }
  2231. if ($category == 1702) {
  2232. $list['syhairther'] = $this->input->post('syhairther', true);
  2233. }
  2234. $classid = $this->classid->sku();
  2235. $scsku = $classid;
  2236. $pm = $classid;
  2237. foreach ($list as $k => $v) {
  2238. if ($v != 0) {
  2239. $num .= $v;
  2240. $features .= $v . '-';
  2241. $post[$k] = $v;
  2242. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2243. if ($k != 'size') {
  2244. $title .= $typeclass[$v]['title'] . " ";
  2245. }
  2246. if (isset($pm[$typeclass[$v]['classid']])) {
  2247. if ($typeclass[$v]['title'] == '9A') {
  2248. $pm[$typeclass[$v]['classid']] = '9A';
  2249. } else if ($typeclass[$v]['title'] == '10A') {
  2250. $pm[$typeclass[$v]['classid']] = '10A';
  2251. } else {
  2252. $clzh = $typeclass[$v]['zh'];
  2253. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2254. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2255. $clzh = $clzh[0];
  2256. }
  2257. $pm[$typeclass[$v]['classid']] = $clzh;
  2258. }
  2259. }
  2260. }
  2261. }
  2262. $zh = implode(" ", $pm);
  2263. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2264. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2265. if ($list['size']) {
  2266. $typeclass = $this->typeclass->read($list['size']);
  2267. $title .= $typeclass['title'];
  2268. }
  2269. $time = time();
  2270. if ($xzsku) {
  2271. $scsku = implode("-", $scsku);
  2272. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2273. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2274. $post['sku'] = trim($scsku, ' ');
  2275. } else {
  2276. $post['sku'] = $sku;
  2277. }
  2278. //$post['sku'] = trim($sku,' ');
  2279. $post['title'] = rtrim($title, ' ');
  2280. $post['number'] = $num;
  2281. $post['features'] = '-' . $features;
  2282. $post['enter'] = $time;
  2283. $post['time'] = $time; //操作时间
  2284. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2285. if ($yza) {
  2286. if ($post['features'] != $yza[0]['features']) {
  2287. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2288. exit;
  2289. }
  2290. }
  2291. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2292. if ($yzb) {
  2293. if ($post['sku'] != $yzb[0]['sku']) {
  2294. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2295. exit;
  2296. }
  2297. }
  2298. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2299. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2300. exit;
  2301. }
  2302. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2303. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2304. exit;
  2305. }
  2306. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2307. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2308. exit;
  2309. }
  2310. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2311. if (isset($yz[0]['type'])) {
  2312. $post['type'] = $yz[0]['type'];
  2313. }
  2314. if ($post['state'] == 9) //如果选择预设库存
  2315. {
  2316. $this->whlabel->insert($post);
  2317. } else {
  2318. /**
  2319. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2320. if($ljg == 1)
  2321. {
  2322. for($i=0;$i<$order;$i++)
  2323. {
  2324. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2325. $this->whlabel->insert($post);
  2326. }
  2327. }
  2328. **/
  2329. //if($post['warehouse'] == '5')
  2330. //{
  2331. //}
  2332. $yydata = $post;
  2333. $yydata['zh'] = $zh;
  2334. /**
  2335. $wl = $this->apiyy->get_cjlp($yydata);
  2336. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2337. {
  2338. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2339. }
  2340. if($wl['Data'][0]['m_isSucess'] != 1)
  2341. {
  2342. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2343. }
  2344. **/
  2345. for ($i = 0; $i < $order; $i++) {
  2346. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2347. $this->whlabel->insert($post);
  2348. }
  2349. }
  2350. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2351. exit;
  2352. }
  2353. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2354. $this->data['wlshop'] = $wlshop;
  2355. $this->_Template('whlabel_enteradd', $this->data);
  2356. }
  2357. //修改产品
  2358. public function _enteredit($arg_array)
  2359. {
  2360. $dt = 0;
  2361. if (isset($_SESSION['api'])) {
  2362. $user = $this->user->get_api($_SESSION['api']);
  2363. $usp = $user;
  2364. $fgshop = "";
  2365. $sid = "";
  2366. $user = explode('|', trim($user['shop'], '|'));
  2367. foreach ($user as $value) {
  2368. $fgshop .= " shop = " . $value . " or";
  2369. $sid .= " id = " . $value . " or";
  2370. }
  2371. }
  2372. $post = $this->input->post(NULL, TRUE);
  2373. if (isset($post['sku'])) {
  2374. $list = array();
  2375. $num = "";
  2376. $title = "";
  2377. $features = "";
  2378. $id = $this->input->post('id', true);
  2379. $order = $this->input->post('order', true);
  2380. $shop = $this->input->post('shop', true);
  2381. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2382. $post['sku'] = $this->input->post('sku', true);
  2383. $post['sm'] = $this->input->post('sm', true);
  2384. $post['warehouse'] = $this->input->post('warehouse', true);
  2385. $post['purchase'] = $this->input->post('purchase', true);
  2386. $post['retreatwarehouse'] = $post['warehouse'];
  2387. $category = $this->input->post('category', true);
  2388. $list['category'] = $category;
  2389. $list['hairtype'] = $this->input->post('hairtype', true);
  2390. $list['grade'] = $this->input->post('grade', true);
  2391. $size = $this->input->post('size', true);
  2392. $list['size'] = rtrim($size, ',');
  2393. $post['rktype'] = $this->input->post('rktype', true);
  2394. $post['text'] = $this->input->post('text', true);
  2395. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2396. $list['extension'] = $this->input->post('extension', true);
  2397. if ($category == 1297) {
  2398. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2399. }
  2400. if ($category == 1702) {
  2401. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2402. $list['syother'] = $this->input->post('syother', true);
  2403. }
  2404. if ($category == 133) {
  2405. $list['fittype'] = $this->input->post('fittype', true);
  2406. $list['acother'] = $this->input->post('acother', true);
  2407. }
  2408. $list['color'] = $this->input->post('color', true);
  2409. $list['lowe'] = $this->input->post('lowe', true);
  2410. if (!$post['purchase']) {
  2411. $post['purchase'] = 1;
  2412. }
  2413. if ($category == 127) {
  2414. $list['type'] = $this->input->post('type', true);
  2415. $list['headroad'] = $this->input->post('headroad', true);
  2416. $list['density'] = $this->input->post('density', true);
  2417. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2418. $list['lacesize'] = $this->input->post('lacesize', true);
  2419. }
  2420. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2421. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2422. }
  2423. if ($category == 128) {
  2424. $list['lacetype'] = $this->input->post('lacetype', true);
  2425. $list['haircap'] = $this->input->post('haircap', true);
  2426. $list['density'] = $this->input->post('density', true);
  2427. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2428. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2429. $list['wigother'] = $this->input->post('wigother', true);
  2430. $list['wigother1'] = $this->input->post('wigother1', true);
  2431. $list['wigother2'] = $this->input->post('wigother2', true);
  2432. $list['product_related'] = $this->input->post('product_related', true);
  2433. }
  2434. if ($category == 129) {
  2435. $list['wide'] = $this->input->post('wide', true);
  2436. }
  2437. if ($category == 131) {
  2438. $list['gifttype'] = $this->input->post('gifttype', true);
  2439. $list['giftother'] = $this->input->post('giftother', true);
  2440. }
  2441. if ($category == 134) {
  2442. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2443. }
  2444. if ($category == 1297) {
  2445. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2446. $list['sywigother'] = $this->input->post('sywigother', true);
  2447. }
  2448. if ($category == 130 || $category == 133 || $category == 1702) {
  2449. $list['items'] = $this->input->post('items', true);
  2450. $list['weight'] = $this->input->post('weight', true);
  2451. }
  2452. if($category == 130){
  2453. $list['jfother'] = $this->input->post('jfother', true);
  2454. }
  2455. if ($category == 1702) {
  2456. $list['syhairther'] = $this->input->post('syhairther', true);
  2457. }
  2458. foreach ($list as $k => $v) {
  2459. if ($v != 0) {
  2460. $num .= $v;
  2461. $features .= $v . '-';
  2462. $typeclass = $this->typeclass->read($v);
  2463. if ($k != 'size') {
  2464. $title .= $typeclass['title'] . " ";
  2465. }
  2466. }
  2467. }
  2468. $typeclass = $this->typeclass->read($list['size']);
  2469. $title .= $typeclass['title'];
  2470. $time = time();
  2471. $post['title'] = rtrim($title, ' ');
  2472. $post['number'] = $num;
  2473. $post['features'] = '-' . $features;
  2474. $post['time'] = $time; //操作时间
  2475. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2476. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2477. exit;
  2478. }
  2479. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2480. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2481. exit;
  2482. }
  2483. $uid = $this->whlabel->read($id);
  2484. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2485. if ($datanum > 0) {
  2486. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2487. exit;
  2488. }
  2489. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2490. {
  2491. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2492. if ($yza) {
  2493. if ($post['features'] != $yza[0]['features']) {
  2494. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2495. exit;
  2496. }
  2497. }
  2498. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2499. if ($yzb) {
  2500. if ($post['sku'] != $yzb[0]['sku']) {
  2501. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2502. exit;
  2503. }
  2504. }
  2505. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2506. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2507. exit;
  2508. }
  2509. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2510. foreach ($data as $v) {
  2511. $post['id'] = $v['id'];
  2512. $this->whlabel->save($post, $v['id']);
  2513. }
  2514. } else {
  2515. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2516. if ($data > 0) {
  2517. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2518. exit;
  2519. } else {
  2520. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2521. foreach ($data as $v) {
  2522. $post['id'] = $v['id'];
  2523. $this->whlabel->save($post, $v['id']);
  2524. }
  2525. }
  2526. }
  2527. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2528. exit;
  2529. }
  2530. $uid = $this->whlabel->read($arg_array[0]);
  2531. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2532. $this->data['enter'] = $uid;
  2533. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2534. $this->data['wlshop'] = $wlshop;
  2535. $this->_Template('whlabel_enteredit', $this->data);
  2536. }
  2537. //入库浏览
  2538. public function _enter()
  2539. {
  2540. $post = $this->input->post(NULL, TRUE);
  2541. if (isset($post['s'])) {
  2542. $id_arr = $this->input->post('s');
  2543. $id_arr = explode(',', $id_arr);
  2544. if (!$id_arr) {
  2545. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2546. exit;
  2547. }
  2548. //循环删除记录
  2549. foreach ($id_arr as $v) {
  2550. $sid = $this->whlabel->read($v);
  2551. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2552. if ($count > 0) {
  2553. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2554. exit;
  2555. }
  2556. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2557. foreach ($info_list as $va) {
  2558. $this->whlabel->remove($va['id']);
  2559. }
  2560. }
  2561. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2562. exit;
  2563. }
  2564. $sp = array();
  2565. $s = $this->shop->find_all('1=1', 'id,shopname');
  2566. foreach ($s as $v) {
  2567. $sp[$v['id']] = $v['shopname'];
  2568. }
  2569. $wh = array();
  2570. $w = $this->warehouse->find_all('1=1', 'id,title');
  2571. foreach ($w as $v) {
  2572. $wh[$v['id']] = $v['title'];
  2573. }
  2574. if (isset($post['page'])) {
  2575. $page = $this->input->post('page', true);
  2576. $perpage = $this->input->post('perpage', true);
  2577. $category = $this->input->post('category', true);
  2578. $size = $this->input->post('size', true);
  2579. $grade = $this->input->post('grade', true);
  2580. $color = $this->input->post('color', true);
  2581. $lowe = $this->input->post('lowe', true);
  2582. $sku = $this->input->post('sku', true);
  2583. $warehouse = $this->input->post('warehouse', true);
  2584. $purchase = $this->input->post('purchase', true);
  2585. $ktime = $this->input->post('ktime', true);
  2586. $jtime = $this->input->post('jtime', true);
  2587. $ktime = strtotime($ktime);
  2588. $jtime = strtotime($jtime);
  2589. $where = "1=1";
  2590. $gj = "";
  2591. $ck = "";
  2592. if ($category) {
  2593. $where .= " and features like '%-$category-%'";
  2594. }
  2595. if ($size) {
  2596. $where .= " and features like '%-$size-%'";
  2597. }
  2598. if ($grade) {
  2599. $where .= " and features like '%-$grade-%'";
  2600. }
  2601. if ($color) {
  2602. $where .= " and features like '%-$color-%'";
  2603. }
  2604. if ($lowe) {
  2605. $where .= " and features like '%-$lowe-%'";
  2606. }
  2607. if ($warehouse) {
  2608. $where .= " and warehouse = '$warehouse'";
  2609. }
  2610. if ($purchase) {
  2611. $where .= " and purchase = '$purchase'";
  2612. }
  2613. if ($sku) {
  2614. $where .= " and sku like '%$sku%'";
  2615. }
  2616. if ($ktime && $jtime) {
  2617. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2618. }
  2619. //数据排序
  2620. $order_str = "enter desc";
  2621. if (empty($page)) {
  2622. $start = 0;
  2623. $perpage = 1;
  2624. } else {
  2625. $start = ($page - 1) * $perpage;
  2626. }
  2627. //取得信息列表
  2628. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2629. foreach ($info_list as $k => $v) {
  2630. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2631. if ($v['shop'] == '') {
  2632. $s = '通用';
  2633. } else {
  2634. $info_list[$k]['shop'] = '';
  2635. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2636. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2637. }
  2638. }
  2639. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2640. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2641. $info_list[$k]['g'] = $g;
  2642. }
  2643. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2644. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2645. $pagenum = ceil($total / $perpage);
  2646. $over = $total - ($start + $perpage);
  2647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2648. echo json_encode($rows);
  2649. exit;
  2650. }
  2651. $this->_Template('whlabel_enter', $this->data);
  2652. }
  2653. //出库浏览
  2654. public function _out()
  2655. {
  2656. $post = $this->input->post(NULL, TRUE);
  2657. if (isset($post['page'])) {
  2658. $page = $this->input->post('page', true);
  2659. $perpage = $this->input->post('perpage', true);
  2660. $category = $this->input->post('category', true);
  2661. $size = $this->input->post('size', true);
  2662. $grade = $this->input->post('grade', true);
  2663. $color = $this->input->post('color', true);
  2664. $lowe = $this->input->post('lowe', true);
  2665. $sku = $this->input->post('sku', true);
  2666. $warehouse = $this->input->post('warehouse', true);
  2667. $purchase = $this->input->post('purchase', true);
  2668. $state = $this->input->post('state', true);
  2669. $ktime = $this->input->post('ktime', true);
  2670. $jtime = $this->input->post('jtime', true);
  2671. $ktime = strtotime($ktime);
  2672. $jtime = strtotime($jtime);
  2673. $where = "state=3";
  2674. $gj = "";
  2675. $ck = "";
  2676. if ($category) {
  2677. $where .= " and features like '%-$category-%'";
  2678. }
  2679. if ($size) {
  2680. $where .= " and features like '%-$size-%'";
  2681. }
  2682. if ($grade) {
  2683. $where .= " and features like '%-$grade-%'";
  2684. }
  2685. if ($color) {
  2686. $where .= " and features like '%-$color-%'";
  2687. }
  2688. if ($lowe) {
  2689. $where .= " and features like '%-$lowe-%'";
  2690. }
  2691. if ($state) {
  2692. $where .= " and state = '$state'";
  2693. }
  2694. if ($warehouse) {
  2695. $where .= " and warehouse = '$warehouse'";
  2696. }
  2697. if ($purchase) {
  2698. $where .= " and purchase = '$purchase'";
  2699. }
  2700. if ($sku) {
  2701. $where .= " and sku = '$sku'";
  2702. }
  2703. if ($ktime && $jtime) {
  2704. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2705. }
  2706. //数据排序
  2707. $order_str = "id desc";
  2708. if (empty($page)) {
  2709. $start = 0;
  2710. $perpage = 1;
  2711. } else {
  2712. $start = ($page - 1) * $perpage;
  2713. }
  2714. //取得信息列表
  2715. $info_list = $this->whlabel->find_all($where, 'sku');
  2716. $rows = array();
  2717. $list = array();
  2718. foreach ($info_list as $key => $value) {
  2719. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2720. }
  2721. $rows = array_unique($rows); //删除重复记录
  2722. foreach ($rows as $key => $value) {
  2723. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2724. $ck = $this->warehouse->read($data['warehouse']);
  2725. $warehouse = $ck['title'];
  2726. $gy = $this->purchase->read($data['purchase']);
  2727. $purchase = $gy['purchase'];
  2728. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2729. $list[] = array('id' => $data['id'], 'warehouse' => $warehouse, 'purchase' => $purchase, 'sku' => $data['sku'], 'title' => $data['title'], 'time' => date('Y-m-d H:i:s', $data['enter']), 'number' => $g);
  2730. }
  2731. $total = count($list);
  2732. $pagenum = ceil($total / $perpage);
  2733. $over = $total - ($start + $perpage);
  2734. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2735. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2736. echo json_encode($rows);
  2737. exit;
  2738. }
  2739. $this->_Template('whlabel_out', $this->data);
  2740. }
  2741. //出库标签浏览
  2742. public function _label()
  2743. {
  2744. $post = $this->input->post(NULL, TRUE);
  2745. if (isset($post['page'])) {
  2746. $page = $this->input->post('page', true);
  2747. $perpage = $this->input->post('perpage', true);
  2748. $sku = $this->input->post('sku', true);
  2749. $warehouse = $this->input->post('warehouse', true);
  2750. $purchase = $this->input->post('purchase', true);
  2751. $orderinfo = $this->input->post('orderinfo', true);
  2752. $waybill = $this->input->post('waybill', true);
  2753. $category = $this->input->post('category', true);
  2754. $size = $this->input->post('size', true);
  2755. $grade = $this->input->post('grade', true);
  2756. $color = $this->input->post('color', true);
  2757. $lowe = $this->input->post('lowe', true);
  2758. $where = "state=1";
  2759. if ($sku) {
  2760. $where .= " and sku = '$sku'";
  2761. }
  2762. if ($warehouse) {
  2763. $where .= " and warehouse = '$warehouse'";
  2764. }
  2765. if ($purchase) {
  2766. $where .= " and purchase = '$purchase'";
  2767. }
  2768. if ($orderinfo) {
  2769. $where .= " and orderinfo = '$orderinfo'";
  2770. }
  2771. if ($waybill) {
  2772. $where .= " and waybill = '$waybill'";
  2773. }
  2774. if ($category) {
  2775. $where .= " and features like '%-$category-%'";
  2776. }
  2777. if ($size) {
  2778. $where .= " and features like '%-$size-%'";
  2779. }
  2780. if ($grade) {
  2781. $where .= " and features like '%-$grade-%'";
  2782. }
  2783. if ($color) {
  2784. $where .= " and features like '%-$color-%'";
  2785. }
  2786. if ($lowe) {
  2787. $where .= " and features like '%-$lowe-%'";
  2788. }
  2789. //数据排序
  2790. $order_str = "outk desc";
  2791. if (empty($page)) {
  2792. $start = 0;
  2793. $perpage = 1;
  2794. } else {
  2795. $start = ($page - 1) * $perpage;
  2796. }
  2797. //取得信息列表
  2798. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2799. foreach ($info_list as $key => $value) {
  2800. $warehouse = $this->warehouse->read($value['warehouse']);
  2801. $info_list[$key]['warehouse'] = $warehouse['title'];
  2802. $purchase = $this->purchase->read($value['purchase']);
  2803. $info_list[$key]['purchase'] = $purchase['title'];
  2804. if ($value['outk'] != 0) {
  2805. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2806. } else {
  2807. $info_list[$key]['outk'] = "";
  2808. }
  2809. if ($value['orderinfo'] == 0) {
  2810. $info_list[$key]['orderinfo'] = "";
  2811. }
  2812. if ($value['waybill'] == 0) {
  2813. $info_list[$key]['waybill'] = "";
  2814. }
  2815. }
  2816. $total = $this->whlabel->find_count($where);
  2817. $pagenum = ceil($total / $perpage);
  2818. $over = $total - ($start + $perpage);
  2819. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2820. echo json_encode($rows);
  2821. exit;
  2822. }
  2823. $this->_Template('whlabel_label', $this->data);
  2824. }
  2825. //独立站出库订单
  2826. public function _outorder()
  2827. {
  2828. if (isset($_SESSION['api'])) {
  2829. $user = $this->user->get_api($_SESSION['api']);
  2830. $usp = $user;
  2831. $fgshop = "";
  2832. $sid = "";
  2833. $user = explode('|', trim($user['shop'], '|'));
  2834. foreach ($user as $value) {
  2835. $fgshop .= " shop = " . $value . " or";
  2836. $sid .= " id = " . $value . " or";
  2837. }
  2838. } else {
  2839. echo "请重新登录";
  2840. }
  2841. $post = $this->input->post(NULL, TRUE);
  2842. if (isset($post['page'])) {
  2843. $page = $this->input->post('page', true);
  2844. $perpage = $this->input->post('perpage', true);
  2845. $warehouse = $this->input->post('warehouse', true);
  2846. $xztime = $this->input->post('xztime', true);
  2847. $timetk = $this->input->post('timetkk', true);
  2848. $timetj = $this->input->post('timetjj', true);
  2849. $shop = $this->input->post('shop', true);
  2850. $source = $this->input->post('source', true);
  2851. $orderinfo = $this->input->post('orderinfo', true);
  2852. $number = $this->input->post('number', true);
  2853. $sfxh = $this->input->post('sfxh', true);
  2854. $express = $this->input->post('express', true);
  2855. $waybill = $this->input->post('waybill', true);
  2856. $library = $this->input->post('library', true);
  2857. $country = $this->input->post('country', true);
  2858. $so = $this->input->post('so', true);
  2859. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2860. $print = $this->input->post('print', true);
  2861. $state = $this->input->post('state', true);
  2862. $orderurl = $this->input->post('orderurl', true);
  2863. $productid = $this->input->post('productid', true);
  2864. $timetk = strtotime($timetk);
  2865. $timetj = strtotime($timetj);
  2866. /**
  2867. $sj = $this->input->post('sj',true);
  2868. if($sj)
  2869. {
  2870. $sj = $this->input->post('sj',true);
  2871. }
  2872. else
  2873. {
  2874. $sj = "fullorder";
  2875. }
  2876. **/
  2877. $sj = "fullorder";
  2878. $where = "1=1";
  2879. if ($warehouse) {
  2880. $where .= " and type = '$warehouse'";
  2881. }
  2882. if ($timetk && $timetj) {
  2883. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2884. }
  2885. if ($orderinfo) {
  2886. $where .= " and orderinfo = '$orderinfo'";
  2887. }
  2888. if ($number) {
  2889. $where .= " and number = '$number'";
  2890. }
  2891. if ($express) {
  2892. $where .= " and express = '$express'";
  2893. }
  2894. if ($waybill) {
  2895. $where .= " and waybill = '$waybill'";
  2896. }
  2897. if ($library) {
  2898. $where .= " and library = '$library'";
  2899. }
  2900. if ($print) {
  2901. $where .= " and print = '$print'";
  2902. }
  2903. if ($libraryconfirm) {
  2904. $where .= " and libraryconfirm = '$libraryconfirm'";
  2905. }
  2906. if ($state) {
  2907. $where .= " and state = '$state'";
  2908. }
  2909. if ($shop) {
  2910. $where .= " and shop = '$shop'";
  2911. }
  2912. if ($country) {
  2913. $where .= " and country = '$country'";
  2914. }
  2915. if ($sfxh != '') {
  2916. $where .= " and sfxh = '$sfxh'";
  2917. }
  2918. if ($so) {
  2919. $where .= " and shipremarks like '%$so%'";
  2920. }
  2921. if ($source) {
  2922. if ($source == '2d') {
  2923. $where .= " and source >= '2'";
  2924. } else {
  2925. $where .= " and source = '$source'";
  2926. }
  2927. }
  2928. if (isset($_SESSION['api'])) {
  2929. foreach ($user as $value) {
  2930. $fgshop .= " shop = " . $value . " or";
  2931. }
  2932. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2933. }
  2934. if ($orderurl) {
  2935. $url = $this->orderurl->read($orderurl);
  2936. $where .= " and link like '%" . $url['url'] . "%'";
  2937. }
  2938. if($productid){
  2939. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2940. }
  2941. //数据排序
  2942. $order_str = "librarytime desc";
  2943. if (empty($page)) {
  2944. $start = 0;
  2945. $perpage = 1;
  2946. } else {
  2947. $start = ($page - 1) * $perpage;
  2948. }
  2949. //取得信息列表
  2950. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2951. //格式化数据
  2952. foreach ($info_list as $key => $value) {
  2953. $shop = $this->shop->read($value['shop']);
  2954. $info_list[$key]['shop'] = $shop['shopname'];
  2955. $express = $this->express->read($value['express']);
  2956. $info_list[$key]['express'] = $express['servicename'];
  2957. $warehouse = $this->warehouse->read($value['type']);
  2958. $info_list[$key]['type'] = $warehouse['title'];
  2959. if ($value['librarytime'] == '0') {
  2960. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2961. } else {
  2962. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2963. }
  2964. }
  2965. $total = $this->$sj->find_count($where);
  2966. $pagenum = ceil($total / $perpage);
  2967. $over = $total - ($start + $perpage);
  2968. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2969. echo json_encode($rows);
  2970. exit;
  2971. }
  2972. $this->data['express'] = $this->express->find_all();
  2973. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2974. $this->data['wlshop'] = $wlshop;
  2975. $user = $this->user->get_api($_SESSION['api']);
  2976. $powerid = $this->power->read($user['power']);
  2977. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2978. $pid = '';
  2979. foreach ($powertext as $v) {
  2980. $pid .= " id = " . $v . " or";
  2981. }
  2982. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2983. $this->data['fullorderexcel'] = $fullorderexcel;
  2984. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2985. $this->data['orderurl'] = $orderurl;
  2986. $this->_Template('whlabel_outorder', $this->data);
  2987. }
  2988. //tt出库
  2989. public function _toutorder()
  2990. {
  2991. $fgshop = "";
  2992. $sid = "";
  2993. if (isset($_SESSION['api'])) {
  2994. $user = $this->user->get_api($_SESSION['api']);
  2995. $usp = $user;
  2996. $user = explode('|', trim($user['shop'], '|'));
  2997. foreach ($user as $value) {
  2998. $fgshop .= " shop = " . $value . " or";
  2999. $sid .= " id = " . $value . " or";
  3000. }
  3001. } else {
  3002. echo "请重新登录";
  3003. die;
  3004. }
  3005. $post = $this->input->post(NULL, TRUE);
  3006. if (isset($post['page'])) {
  3007. $page = $this->input->post('page', true);
  3008. $perpage = $this->input->post('perpage', true);
  3009. $warehouse = $this->input->post('warehouse', true);
  3010. $xztime = $this->input->post('xztime', true);
  3011. $timetk = $this->input->post('timetkk', true);
  3012. $timetj = $this->input->post('timetjj', true);
  3013. $shop = $this->input->post('shop', true);
  3014. $source = $this->input->post('source', true);
  3015. $orderinfo = $this->input->post('orderinfo', true);
  3016. $number = $this->input->post('number', true);
  3017. $sfxh = $this->input->post('sfxh', true);
  3018. $express = $this->input->post('express', true);
  3019. $waybill = $this->input->post('waybill', true);
  3020. $library = $this->input->post('library', true);
  3021. $country = $this->input->post('country', true);
  3022. $so = $this->input->post('so', true);
  3023. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3024. $print = $this->input->post('print', true);
  3025. $state = $this->input->post('state', true);
  3026. $orderurl = $this->input->post('orderurl', true);
  3027. $timetk = strtotime($timetk);
  3028. $timetj = strtotime($timetj);
  3029. /**
  3030. $sj = $this->input->post('sj',true);
  3031. if($sj)
  3032. {
  3033. $sj = $this->input->post('sj',true);
  3034. }
  3035. else
  3036. {
  3037. $sj = "fullorder";
  3038. }
  3039. **/
  3040. $sj = "fullordertt";
  3041. $where = "1=1";
  3042. if ($warehouse) {
  3043. $where .= " and type = '$warehouse'";
  3044. }
  3045. if ($timetk && $timetj) {
  3046. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3047. }
  3048. if ($orderinfo) {
  3049. $where .= " and orderinfo = '$orderinfo'";
  3050. }
  3051. if ($number) {
  3052. $where .= " and number = '$number'";
  3053. }
  3054. if ($express) {
  3055. $where .= " and express = '$express'";
  3056. }
  3057. if ($waybill) {
  3058. $where .= " and waybill = '$waybill'";
  3059. }
  3060. if ($library) {
  3061. $where .= " and library = '$library'";
  3062. }
  3063. if ($print) {
  3064. $where .= " and print = '$print'";
  3065. }
  3066. if ($libraryconfirm) {
  3067. $where .= " and libraryconfirm = '$libraryconfirm'";
  3068. }
  3069. if ($state) {
  3070. $where .= " and state = '$state'";
  3071. }
  3072. if ($shop) {
  3073. $where .= " and shop = '$shop'";
  3074. }
  3075. if ($country) {
  3076. $where .= " and country = '$country'";
  3077. }
  3078. if ($sfxh != '') {
  3079. $where .= " and sfxh = '$sfxh'";
  3080. }
  3081. if ($so) {
  3082. $where .= " and shipremarks like '%$so%'";
  3083. }
  3084. if ($source) {
  3085. if ($source == '2d') {
  3086. $where .= " and source >= '2'";
  3087. } else {
  3088. $where .= " and source = '$source'";
  3089. }
  3090. }
  3091. if (isset($_SESSION['api'])) {
  3092. foreach ($user as $value) {
  3093. $fgshop .= " shop = " . $value . " or";
  3094. }
  3095. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3096. }
  3097. if ($orderurl) {
  3098. $url = $this->orderurl->read($orderurl);
  3099. $where .= " and link like '%" . $url['url'] . "%'";
  3100. }
  3101. //数据排序
  3102. $order_str = "librarytime desc";
  3103. if (empty($page)) {
  3104. $start = 0;
  3105. $perpage = 1;
  3106. } else {
  3107. $start = ($page - 1) * $perpage;
  3108. }
  3109. //取得信息列表
  3110. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3111. //格式化数据
  3112. foreach ($info_list as $key => $value) {
  3113. $shop = $this->shop->read($value['shop']);
  3114. $info_list[$key]['shop'] = $shop['shopname'];
  3115. $express = $this->express->read($value['express']);
  3116. $info_list[$key]['express'] = $express['servicename'];
  3117. $warehouse = $this->warehouse->read($value['type']);
  3118. $info_list[$key]['type'] = $warehouse['title'];
  3119. if ($value['librarytime'] == '0') {
  3120. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3121. } else {
  3122. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3123. }
  3124. }
  3125. $total = $this->$sj->find_count($where);
  3126. $pagenum = ceil($total / $perpage);
  3127. $over = $total - ($start + $perpage);
  3128. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3129. echo json_encode($rows);
  3130. exit;
  3131. }
  3132. $this->data['express'] = $this->express->find_all();
  3133. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3134. $this->data['wlshop'] = $wlshop;
  3135. $user = $this->user->get_api($_SESSION['api']);
  3136. $powerid = $this->power->read($user['power']);
  3137. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3138. $pid = '';
  3139. foreach ($powertext as $v) {
  3140. $pid .= " id = " . $v . " or";
  3141. }
  3142. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3143. $this->data['fullorderexcel'] = $fullorderexcel;
  3144. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3145. $this->data['orderurl'] = $orderurl;
  3146. $this->_Template('whlabel_toutorder', $this->data);
  3147. }
  3148. //tt出库
  3149. public function _aoutorder()
  3150. {
  3151. if (isset($_SESSION['api'])) {
  3152. $user = $this->user->get_api($_SESSION['api']);
  3153. $usp = $user;
  3154. $fgshop = "";
  3155. $sid = "";
  3156. $user = explode('|', trim($user['shop'], '|'));
  3157. foreach ($user as $value) {
  3158. $fgshop .= " shop = " . $value . " or";
  3159. $sid .= " id = " . $value . " or";
  3160. }
  3161. } else {
  3162. echo "请重新登录";
  3163. }
  3164. $post = $this->input->post(NULL, TRUE);
  3165. if (isset($post['page'])) {
  3166. $page = $this->input->post('page', true);
  3167. $perpage = $this->input->post('perpage', true);
  3168. $warehouse = $this->input->post('warehouse', true);
  3169. $xztime = $this->input->post('xztime', true);
  3170. $timetk = $this->input->post('timetkk', true);
  3171. $timetj = $this->input->post('timetjj', true);
  3172. $shop = $this->input->post('shop', true);
  3173. $source = $this->input->post('source', true);
  3174. $orderinfo = $this->input->post('orderinfo', true);
  3175. $number = $this->input->post('number', true);
  3176. $sfxh = $this->input->post('sfxh', true);
  3177. $express = $this->input->post('express', true);
  3178. $waybill = $this->input->post('waybill', true);
  3179. $library = $this->input->post('library', true);
  3180. $country = $this->input->post('country', true);
  3181. $so = $this->input->post('so', true);
  3182. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3183. $print = $this->input->post('print', true);
  3184. $state = $this->input->post('state', true);
  3185. $orderurl = $this->input->post('orderurl', true);
  3186. $timetk = strtotime($timetk);
  3187. $timetj = strtotime($timetj);
  3188. /**
  3189. $sj = $this->input->post('sj',true);
  3190. if($sj)
  3191. {
  3192. $sj = $this->input->post('sj',true);
  3193. }
  3194. else
  3195. {
  3196. $sj = "fullorder";
  3197. }
  3198. **/
  3199. $sj = "fullorderamz";
  3200. $where = "1=1";
  3201. if ($warehouse) {
  3202. $where .= " and type = '$warehouse'";
  3203. }
  3204. if ($timetk && $timetj) {
  3205. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3206. }
  3207. if ($orderinfo) {
  3208. $where .= " and orderinfo = '$orderinfo'";
  3209. }
  3210. if ($number) {
  3211. $where .= " and number = '$number'";
  3212. }
  3213. if ($express) {
  3214. $where .= " and express = '$express'";
  3215. }
  3216. if ($waybill) {
  3217. $where .= " and waybill = '$waybill'";
  3218. }
  3219. if ($library) {
  3220. $where .= " and library = '$library'";
  3221. }
  3222. if ($print) {
  3223. $where .= " and print = '$print'";
  3224. }
  3225. if ($libraryconfirm) {
  3226. $where .= " and libraryconfirm = '$libraryconfirm'";
  3227. }
  3228. if ($state) {
  3229. $where .= " and state = '$state'";
  3230. }
  3231. if ($shop) {
  3232. $where .= " and shop = '$shop'";
  3233. }
  3234. if ($country) {
  3235. $where .= " and country = '$country'";
  3236. }
  3237. if ($sfxh != '') {
  3238. $where .= " and sfxh = '$sfxh'";
  3239. }
  3240. if ($so) {
  3241. $where .= " and shipremarks like '%$so%'";
  3242. }
  3243. if ($source) {
  3244. if ($source == '2d') {
  3245. $where .= " and source >= '2'";
  3246. } else {
  3247. $where .= " and source = '$source'";
  3248. }
  3249. }
  3250. if (isset($_SESSION['api'])) {
  3251. foreach ($user as $value) {
  3252. $fgshop .= " shop = " . $value . " or";
  3253. }
  3254. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3255. }
  3256. if ($orderurl) {
  3257. $url = $this->orderurl->read($orderurl);
  3258. $where .= " and link like '%" . $url['url'] . "%'";
  3259. }
  3260. //数据排序
  3261. $order_str = "librarytime desc";
  3262. if (empty($page)) {
  3263. $start = 0;
  3264. $perpage = 1;
  3265. } else {
  3266. $start = ($page - 1) * $perpage;
  3267. }
  3268. //取得信息列表
  3269. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3270. //格式化数据
  3271. foreach ($info_list as $key => $value) {
  3272. $shop = $this->shop->read($value['shop']);
  3273. $info_list[$key]['shop'] = $shop['shopname'];
  3274. $express = $this->express->read($value['express']);
  3275. $info_list[$key]['express'] = $express['servicename'];
  3276. $warehouse = $this->warehouse->read($value['type']);
  3277. $info_list[$key]['type'] = $warehouse['title'];
  3278. if ($value['librarytime'] == '0') {
  3279. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3280. } else {
  3281. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3282. }
  3283. }
  3284. $total = $this->$sj->find_count($where);
  3285. $pagenum = ceil($total / $perpage);
  3286. $over = $total - ($start + $perpage);
  3287. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3288. echo json_encode($rows);
  3289. exit;
  3290. }
  3291. $this->data['express'] = $this->express->find_all();
  3292. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3293. $this->data['wlshop'] = $wlshop;
  3294. $user = $this->user->get_api($_SESSION['api']);
  3295. $powerid = $this->power->read($user['power']);
  3296. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3297. $pid = '';
  3298. foreach ($powertext as $v) {
  3299. $pid .= " id = " . $v . " or";
  3300. }
  3301. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3302. $this->data['fullorderexcel'] = $fullorderexcel;
  3303. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3304. $this->data['orderurl'] = $orderurl;
  3305. $this->_Template('whlabel_aoutorder', $this->data);
  3306. }
  3307. //速卖通出库订单
  3308. public function _soutorder()
  3309. {
  3310. if (isset($_SESSION['api'])) {
  3311. $user = $this->user->get_api($_SESSION['api']);
  3312. $usp = $user;
  3313. $fgshop = "";
  3314. $sid = "";
  3315. $user = explode('|', trim($user['shop'], '|'));
  3316. foreach ($user as $value) {
  3317. $sid .= " id = " . $value . " or";
  3318. }
  3319. }
  3320. $post = $this->input->post(NULL, TRUE);
  3321. if (isset($post['page'])) {
  3322. $page = $this->input->post('page', true);
  3323. $perpage = $this->input->post('perpage', true);
  3324. $warehouse = $this->input->post('warehouse', true);
  3325. $xztime = $this->input->post('xztime', true);
  3326. $timetk = $this->input->post('timetkk', true);
  3327. $timetj = $this->input->post('timetjj', true);
  3328. $shop = $this->input->post('shop', true);
  3329. $source = $this->input->post('source', true);
  3330. $orderinfo = $this->input->post('orderinfo', true);
  3331. $number = $this->input->post('number', true);
  3332. $express = $this->input->post('express', true);
  3333. $waybill = $this->input->post('waybill', true);
  3334. $library = $this->input->post('library', true);
  3335. $country = $this->input->post('country', true);
  3336. $sfxh = $this->input->post('sfxh', true);
  3337. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3338. $print = $this->input->post('print', true);
  3339. $state = $this->input->post('state', true);
  3340. $so = $this->input->post('so', true);
  3341. $timetk = strtotime($timetk);
  3342. $timetj = strtotime($timetj);
  3343. /**
  3344. $sj = $this->input->post('sj',true);
  3345. if($sj)
  3346. {
  3347. $sj = $this->input->post('sj',true);
  3348. }
  3349. else
  3350. {
  3351. $sj = "fullorder";
  3352. }
  3353. **/
  3354. $sj = "fullordersmt";
  3355. $where = "1=1";
  3356. if ($warehouse) {
  3357. $where .= " and type = '$warehouse'";
  3358. }
  3359. if ($timetk && $timetj) {
  3360. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3361. }
  3362. if ($orderinfo) {
  3363. $where .= " and orderinfo = '$orderinfo'";
  3364. }
  3365. if ($number) {
  3366. $where .= " and number = '$number'";
  3367. }
  3368. if ($express) {
  3369. $where .= " and express = '$express'";
  3370. }
  3371. if ($waybill) {
  3372. $where .= " and waybill = '$waybill'";
  3373. }
  3374. if ($library) {
  3375. $where .= " and library = '$library'";
  3376. }
  3377. if ($print) {
  3378. $where .= " and print = '$print'";
  3379. }
  3380. if ($libraryconfirm) {
  3381. $where .= " and libraryconfirm = '$libraryconfirm'";
  3382. }
  3383. if ($state) {
  3384. $where .= " and state = '$state'";
  3385. }
  3386. if ($shop) {
  3387. $where .= " and shop = '$shop'";
  3388. }
  3389. if ($sfxh != '') {
  3390. $where .= " and sfxh = '$sfxh'";
  3391. }
  3392. if ($so) {
  3393. $where .= " and shipremarks like '%$so%'";
  3394. }
  3395. if ($source) {
  3396. $where .= " and source = '$source'";
  3397. }
  3398. if ($country) {
  3399. $where .= " and country = '$country'";
  3400. } else {
  3401. if (isset($_SESSION['api'])) {
  3402. foreach ($user as $value) {
  3403. $fgshop .= " shop = " . $value . " or";
  3404. }
  3405. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3406. }
  3407. }
  3408. //数据排序
  3409. $order_str = "librarytime desc";
  3410. if (empty($page)) {
  3411. $start = 0;
  3412. $perpage = 1;
  3413. } else {
  3414. $start = ($page - 1) * $perpage;
  3415. }
  3416. //取得信息列表
  3417. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3418. //格式化数据
  3419. foreach ($info_list as $key => $value) {
  3420. $shop = $this->shop->read($value['shop']);
  3421. $info_list[$key]['shop'] = $shop['shopname'];
  3422. $express = $this->express->read($value['express']);
  3423. $info_list[$key]['express'] = $express['servicename'];
  3424. $warehouse = $this->warehouse->read($value['type']);
  3425. $info_list[$key]['type'] = $warehouse['title'];
  3426. if ($value['librarytime'] == '0') {
  3427. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3428. } else {
  3429. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3430. }
  3431. }
  3432. $total = $this->$sj->find_count($where);
  3433. $pagenum = ceil($total / $perpage);
  3434. $over = $total - ($start + $perpage);
  3435. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3436. echo json_encode($rows);
  3437. exit;
  3438. }
  3439. $this->data['express'] = $this->express->find_all();
  3440. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3441. $this->data['wlshop'] = $wlshop;
  3442. $user = $this->user->get_api($_SESSION['api']);
  3443. $powerid = $this->power->read($user['power']);
  3444. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3445. $pid = '';
  3446. foreach ($powertext as $v) {
  3447. $pid .= " id = " . $v . " or";
  3448. }
  3449. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3450. $this->data['fullorderexcel'] = $fullorderexcel;
  3451. $this->_Template('whlabel_soutorder', $this->data);
  3452. }
  3453. //订单退库
  3454. public function _retreat()
  3455. {
  3456. $post = $this->input->post(NULL, TRUE);
  3457. if (isset($post['page'])) {
  3458. $page = $this->input->post('page', true);
  3459. $perpage = $this->input->post('perpage', true);
  3460. $warehouse = $this->input->post('warehouse', true);
  3461. $timetk = $this->input->post('timetk', true);
  3462. $timetj = $this->input->post('timetj', true);
  3463. $shop = $this->input->post('shop', true);
  3464. $source = $this->input->post('source', true);
  3465. $state = $this->input->post('state', true);
  3466. $review = $this->input->post('review', true);
  3467. $state = $this->input->post('state', true);
  3468. $express = $this->input->post('express', true);
  3469. $orderinfo = $this->input->post('orderinfo', true);
  3470. $user = $this->input->post('user', true);
  3471. $name = $this->input->post('name', true);
  3472. $waybill = $this->input->post('waybill', true);
  3473. $timetk = strtotime($timetk);
  3474. $timetj = strtotime($timetj);
  3475. $where = "(state=206 or state=210) and mergeid = 0";
  3476. if ($warehouse) {
  3477. $where .= " and state = '$warehouse'";
  3478. }
  3479. if ($timetk && $timetj) {
  3480. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3481. }
  3482. if ($shop) {
  3483. $where .= " and shop = '$shop'";
  3484. }
  3485. if ($source) {
  3486. $where .= " and source = '$source'";
  3487. }
  3488. if ($state) {
  3489. $where .= " and state = '$state'";
  3490. }
  3491. if ($review) {
  3492. $where .= " and review = '$review'";
  3493. }
  3494. if ($state) {
  3495. $where .= " and state = '$state'";
  3496. }
  3497. if ($express) {
  3498. $where .= " and express = '$express'";
  3499. }
  3500. if ($orderinfo) {
  3501. $where .= " and orderinfo = '$orderinfo'";
  3502. }
  3503. if ($user) {
  3504. $where .= " and user = '$user'";
  3505. }
  3506. if ($name) {
  3507. $where .= " and name = '$name'";
  3508. }
  3509. if ($waybill) {
  3510. $where .= " and waybill = '$waybill'";
  3511. }
  3512. //数据排序
  3513. $order_str = "id desc";
  3514. if (empty($page)) {
  3515. $start = 0;
  3516. $perpage = 1;
  3517. } else {
  3518. $start = ($page - 1) * $perpage;
  3519. }
  3520. //取得信息列表
  3521. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3522. //格式化数据
  3523. foreach ($info_list as $key => $value) {
  3524. $shop = $this->shop->read($value['shop']);
  3525. $info_list[$key]['shop'] = $shop['shopname'];
  3526. $warehouse = $this->warehouse->read($value['warehouse']);
  3527. $info_list[$key]['warehouse'] = $warehouse['title'];
  3528. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3529. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3530. if ($value['waybill'] == 0) {
  3531. $info_list[$key]['waybill'] = "";
  3532. }
  3533. $express = $this->express->read($value['express']);
  3534. $info_list[$key]['express'] = $express['title'];
  3535. $typeclass = $this->typeclass->read($value['state']);
  3536. $info_list[$key]['state'] = $typeclass['title'];
  3537. }
  3538. $total = $this->fullorder->find_count($where);
  3539. $pagenum = ceil($total / $perpage);
  3540. $over = $total - ($start + $perpage);
  3541. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3542. echo json_encode($rows);
  3543. exit;
  3544. }
  3545. $this->data['express'] = $this->express->find_all();
  3546. $this->_Template('whlabel_retreat', $this->data);
  3547. }
  3548. //退库标签浏览
  3549. public function _retreatlk()
  3550. {
  3551. $post = $this->input->post(NULL, TRUE);
  3552. if (isset($post['page'])) {
  3553. $page = $this->input->post('page', true);
  3554. $perpage = $this->input->post('perpage', true);
  3555. $timetk = $this->input->post('timetk', true);
  3556. $timetj = $this->input->post('timetj', true);
  3557. $sku = $this->input->post('sku', true);
  3558. $warehouse = $this->input->post('warehouse', true);
  3559. $purchase = $this->input->post('purchase', true);
  3560. $orderinfo = $this->input->post('orderinfo', true);
  3561. $waybill = $this->input->post('waybill', true);
  3562. $category = $this->input->post('category', true);
  3563. $size = $this->input->post('size', true);
  3564. $grade = $this->input->post('grade', true);
  3565. $color = $this->input->post('color', true);
  3566. $lowe = $this->input->post('lowe', true);
  3567. $state = $this->input->post('state', true);
  3568. $timetk = strtotime($timetk);
  3569. $timetj = strtotime($timetj);
  3570. $where = "state=2";
  3571. if ($timetk && $timetj) {
  3572. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3573. }
  3574. if ($sku) {
  3575. $where .= " and sku = '$sku'";
  3576. }
  3577. if ($warehouse) {
  3578. $where .= " and warehouse = '$warehouse'";
  3579. }
  3580. if ($purchase) {
  3581. $where .= " and purchase = '$purchase'";
  3582. }
  3583. if ($orderinfo) {
  3584. $where .= " and orderinfo = '$orderinfo'";
  3585. }
  3586. if ($waybill) {
  3587. $where .= " and waybill = '$waybill'";
  3588. }
  3589. if ($category) {
  3590. $where .= " and features like '%-$category-%'";
  3591. }
  3592. if ($size) {
  3593. $where .= " and features like '%-$size-%'";
  3594. }
  3595. if ($grade) {
  3596. $where .= " and features like '%-$grade-%'";
  3597. }
  3598. if ($color) {
  3599. $where .= " and features like '%-$color-%'";
  3600. }
  3601. if ($lowe) {
  3602. $where .= " and features like '%-$lowe-%'";
  3603. }
  3604. //数据排序
  3605. $order_str = "time desc";
  3606. if (empty($page)) {
  3607. $start = 0;
  3608. $perpage = 1;
  3609. } else {
  3610. $start = ($page - 1) * $perpage;
  3611. }
  3612. //取得信息列表
  3613. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3614. foreach ($info_list as $key => $value) {
  3615. $warehouse = $this->warehouse->read($value['warehouse']);
  3616. $info_list[$key]['warehouse'] = $warehouse['title'];
  3617. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3618. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3619. $purchase = $this->purchase->read($value['purchase']);
  3620. $info_list[$key]['purchase'] = $purchase['title'];
  3621. if ($value['outk'] != 0) {
  3622. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3623. } else {
  3624. $info_list[$key]['outk'] = "";
  3625. }
  3626. if ($value['retreat'] != 0) {
  3627. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3628. } else {
  3629. $info_list[$key]['retreat'] = "";
  3630. }
  3631. if ($value['orderinfo'] == 0) {
  3632. $info_list[$key]['orderinfo'] = "";
  3633. }
  3634. if ($value['waybill'] == 0) {
  3635. $info_list[$key]['waybill'] = "";
  3636. }
  3637. }
  3638. $total = $this->whlabel->find_count($where);
  3639. $pagenum = ceil($total / $perpage);
  3640. $over = $total - ($start + $perpage);
  3641. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3642. echo json_encode($rows);
  3643. exit;
  3644. }
  3645. $this->_Template('whlabel_retreatlk', $this->data);
  3646. }
  3647. //更换标签及浏览
  3648. public function _change()
  3649. {
  3650. $post = $this->input->post(NULL, TRUE);
  3651. if (isset($post['page'])) {
  3652. $page = $this->input->post('page', true);
  3653. $perpage = $this->input->post('perpage', true);
  3654. $timetk = $this->input->post('timetk', true);
  3655. $timetj = $this->input->post('timetj', true);
  3656. $label = $this->input->post('label', true);
  3657. $oldlabel = $this->input->post('oldlabel', true);
  3658. $timetk = strtotime($timetk);
  3659. $timetj = strtotime($timetj);
  3660. $where = "state=10 ";
  3661. if ($timetk && $timetj) {
  3662. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3663. }
  3664. if ($label) {
  3665. $where .= " and label = '$label'";
  3666. }
  3667. if ($oldlabel) {
  3668. $where .= " and oldlabel = '$oldlabel'";
  3669. }
  3670. //数据排序
  3671. $order_str = "time asc";
  3672. if (empty($page)) {
  3673. $start = 0;
  3674. $perpage = 1;
  3675. } else {
  3676. $start = ($page - 1) * $perpage;
  3677. }
  3678. //取得信息列表
  3679. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3680. foreach ($info_list as $key => $value) {
  3681. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3682. }
  3683. $total = $this->whlabel->find_count($where);
  3684. $pagenum = ceil($total / $perpage);
  3685. $over = $total - ($start + $perpage);
  3686. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3687. echo json_encode($rows);
  3688. exit;
  3689. }
  3690. $this->_Template('whlabel_change', $this->data);
  3691. }
  3692. //产品标签
  3693. public function _cpbqdc()
  3694. {
  3695. if (isset($_GET['excel'])) {
  3696. $where = "1=1";
  3697. //数据排序
  3698. $order_str = "id desc";
  3699. if (empty($page)) {
  3700. $start = 0;
  3701. $perpage = 1;
  3702. } else {
  3703. $start = ($page - 1) * $perpage;
  3704. }
  3705. $warehouse = $this->input->get('warehouse', true);
  3706. $state = $this->input->get('state', true);
  3707. $timetk = $this->input->get('timetkk', true);
  3708. $timetj = $this->input->get('timetjj', true);
  3709. $timetk = strtotime($timetk);
  3710. $timetj = strtotime($timetj);
  3711. if ($warehouse) {
  3712. $where .= " and warehouse = '$warehouse'";
  3713. }
  3714. if ($state || $state == 0) {
  3715. $where .= " and state = '$state'";
  3716. }
  3717. if ($timetk && $timetj) {
  3718. $where .= " and time > '$timetk' and time < '$timetj'";
  3719. }
  3720. //取得信息列表
  3721. $info_list = $this->whlabel->find_all($where, '*');
  3722. $rows = array();
  3723. $list = array();
  3724. foreach ($info_list as $key => $value) {
  3725. $rows[$value['time']] = $value; //所有数据sku
  3726. }
  3727. foreach ($rows as $value) {
  3728. $warehouse = $this->warehouse->read($value['warehouse']);
  3729. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3730. $list[] = array($warehouse['title'], $value['sku'], $value['title'], date('Y-m-d H:i:s', $value['enter']), date('Y-m-d H:i:s', $value['time']), $value['text'], $s);
  3731. }
  3732. $title = "产品标签统计表";
  3733. $titlename = "<table border=1>
  3734. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3735. <tr align='center'>
  3736. <td>仓库</td>
  3737. <td>SKU</td>
  3738. <td>产品</td>
  3739. <td>入库时间</td>
  3740. <td>操作时间</td>
  3741. <td>备注</td>
  3742. <td>数量</td>
  3743. </tr>
  3744. </table>";
  3745. $filename = $title . ".xls";
  3746. $tail = "";
  3747. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3748. }
  3749. }
  3750. //进销存导出
  3751. public function _exceljxc()
  3752. {
  3753. $classid = $this->classid->sku();
  3754. $pm = $classid;
  3755. $typeclass = array();
  3756. $tc = $this->typeclass->find_all();
  3757. foreach ($tc as $v) {
  3758. $typeclass[$v['id']] = $v;
  3759. }
  3760. $prc = array();
  3761. $purchase = $this->purchase->find_all();
  3762. foreach ($purchase as $k => $v) {
  3763. $prc[$v['id']] = $v['title'];
  3764. }
  3765. if (isset($_GET['excel'])) {
  3766. $where = "sku != 'Preset'";
  3767. //数据排序
  3768. $order_str = "id desc";
  3769. if (empty($page)) {
  3770. $start = 0;
  3771. $perpage = 1;
  3772. } else {
  3773. $start = ($page - 1) * $perpage;
  3774. }
  3775. $category = $this->input->get('category', true);
  3776. $warehouse = $this->input->get('warehouse', true);
  3777. $excelid = $this->input->get('sid', true);
  3778. if ($category) {
  3779. $where .= " and features like '%-$category-%'";
  3780. }
  3781. if ($warehouse) {
  3782. $where .= " and warehouse = '$warehouse'";
  3783. }
  3784. $xzid = '';
  3785. if ($excelid) {
  3786. $excelid = explode(',', trim($excelid, ','));
  3787. foreach ($excelid as $key => $value) {
  3788. $xzid .= " id = " . $value . " or";
  3789. }
  3790. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3791. }
  3792. //取得信息列表
  3793. /**
  3794. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3795. $rows = array();$list = array();
  3796. foreach ($info_list as $key=>$value)
  3797. {
  3798. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3799. }
  3800. **/
  3801. $wt = array();
  3802. $whlabel_type = $this->whlabel_type->find_all();
  3803. foreach ($whlabel_type as $v) {
  3804. $wt[$v['id']] = $v['title'];
  3805. }
  3806. $wh = array();
  3807. $w = $this->warehouse->find_all('1=1', 'id,title');
  3808. foreach ($w as $v) {
  3809. $wh[$v['id']] = $v['title'];
  3810. }
  3811. $list = array();
  3812. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3813. foreach ($rows as $key => $value) {
  3814. if (isset($wt[$value['type']])) {
  3815. $rows[$key]['type'] = $wt[$value['type']];
  3816. } else {
  3817. $rows[$key]['type'] = '未设置';
  3818. }
  3819. $bm = '03';
  3820. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3821. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3822. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  3823. $details = array();
  3824. $cpid = array();
  3825. $cpbz = array();
  3826. $c = 0;
  3827. $g = 0;
  3828. $x = 0;
  3829. $t = 0;
  3830. $s = 0;
  3831. $q = 0;
  3832. foreach ($sd as $k => $v) {
  3833. if ($v['state'] == 0) {
  3834. $c++;
  3835. if ($v['cpid'] != 0) {
  3836. $cpid[$v['cpid']] = $v['cpid'];
  3837. }
  3838. if ($v['cpbz'] != '') {
  3839. $cpbz[$v['cpbz']] = $v['cpbz'];
  3840. }
  3841. }
  3842. if ($v['state'] != 9) {
  3843. $g++;
  3844. }
  3845. if ($v['state'] == 1) {
  3846. $x++;
  3847. }
  3848. if ($v['state'] == 2) {
  3849. $t++;
  3850. }
  3851. if ($v['state'] == 8) {
  3852. $s++;
  3853. }
  3854. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3855. $q++;
  3856. }
  3857. $details[$v['details']] = $v['details'];
  3858. }
  3859. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  3860. $rows[$key]['details'] = implode("、", $details);
  3861. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3862. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3863. $number = $value['number'];
  3864. $ftime = time() - 15 * 24 * 3600;
  3865. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3866. $rows[$key]['number'] = $g;
  3867. $rows[$key]['c'] = $c;
  3868. $rows[$key]['x'] = $x;
  3869. $rows[$key]['t'] = $t;
  3870. $rows[$key]['s'] = $s;
  3871. $rows[$key]['q'] = $q;
  3872. $rows[$key]['z'] = $z;
  3873. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3874. $features = explode('-', trim($features, '-'));
  3875. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3876. // $pm = $classid;
  3877. // $jm = $classid;
  3878. // foreach($features as $k=>$v)
  3879. // {
  3880. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3881. // {
  3882. // if($typeclass[$v]['bm'] != '')
  3883. // {
  3884. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3885. // }
  3886. // }
  3887. // if($v != 0)
  3888. // {
  3889. // if(!isset($typeclass[$v]))
  3890. // {
  3891. // continue;
  3892. // }
  3893. // if(isset($pm[$typeclass[$v]['classid']]))
  3894. // {
  3895. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3896. // {
  3897. // $tz = explode('|',$typeclass[$v]['zh']);
  3898. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3899. // }
  3900. // else
  3901. // {
  3902. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3903. // }
  3904. // }
  3905. // if(isset($jm[$typeclass[$v]['classid']]))
  3906. // {
  3907. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3908. // }
  3909. // }
  3910. // }
  3911. // $jm = array_filter($jm);
  3912. // $rows[$key]['bs'] = implode("-",$jm);
  3913. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3914. // $zh = implode(" ",$pm);
  3915. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3916. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3917. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3918. // $rows[$key]['features'] = $zh;
  3919. }
  3920. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3921. $final_list = [];
  3922. foreach ($list as $k => $v) {
  3923. if (empty($v['sku'])) {
  3924. continue;
  3925. }
  3926. $final_list[] = [
  3927. "warehouse" => $v["warehouse"],
  3928. "purchase" => $v["purchase"],
  3929. "details" => $v["details"],
  3930. "cpid" => $v["cpid"],
  3931. "dbcontent" => $v["dbcontent"],
  3932. "sku" => $v["sku"],
  3933. "cs" => $v["bm"],
  3934. "bs" => $v["jm"],
  3935. "title" => $v["title"],
  3936. "features" => $v["pm"],
  3937. "cpbz" => $v["cpbz"],
  3938. "sm" => $v["sm"],
  3939. "type" => $v["type"],
  3940. "number" => $v["number"],
  3941. "c" => $v["c"],
  3942. "x" => $v["x"],
  3943. "t" => $v["t"],
  3944. "s" => $v["s"],
  3945. "q" => $v["q"],
  3946. "z" => $v["z"],
  3947. "weight" => $v['weight'],
  3948. ];
  3949. }
  3950. $title = "总进销存统计表";
  3951. $titlename = "<table border=1>
  3952. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3953. <tr align='center'>
  3954. <td>仓库</td>
  3955. <td>供应商</td>
  3956. <td>位置</td>
  3957. <td>库存编码</td>
  3958. <td>类目</td>
  3959. <td>SKU</td>
  3960. <td>用友编码</td>
  3961. <td>用友料号</td>
  3962. <td>商品名称</td>
  3963. <td>商品中文</td>
  3964. <td>产品备注</td>
  3965. <td>库位负责人</td>
  3966. <td>类型</td>
  3967. <td>入库总量</td>
  3968. <td>库存数量</td>
  3969. <td>销售数量</td>
  3970. <td>退货数量</td>
  3971. <td>删除数量</td>
  3972. <td>其它操作</td>
  3973. <td>占单数量</td>
  3974. <td>重量(g)</td>
  3975. </tr>
  3976. </table>";
  3977. $filename = $title . ".xls";
  3978. $tail = "";
  3979. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3980. }
  3981. }
  3982. //入库导出
  3983. public function _excelr()
  3984. {
  3985. if (isset($_GET['excel'])) {
  3986. $category = $this->input->get('category', true);
  3987. $size = $this->input->get('size', true);
  3988. $grade = $this->input->get('grade', true);
  3989. $color = $this->input->get('color', true);
  3990. $lowe = $this->input->get('lowe', true);
  3991. $sku = $this->input->get('sku', true);
  3992. $warehouse = $this->input->get('warehouse', true);
  3993. $purchase = $this->input->get('purchase', true);
  3994. $ktime = $this->input->get('ktime', true);
  3995. $jtime = $this->input->get('jtime', true);
  3996. $rktype = $this->input->get('rktype',true);
  3997. $ktime = strtotime($ktime);
  3998. $jtime = strtotime($jtime);
  3999. $where = "1=1";
  4000. $gj = "";
  4001. $ck = "";
  4002. if ($category) {
  4003. $where .= " and features like '%-$category-%'";
  4004. }
  4005. if ($size) {
  4006. $where .= " and features like '%-$size-%'";
  4007. }
  4008. if ($grade) {
  4009. $where .= " and features like '%-$grade-%'";
  4010. }
  4011. if ($color) {
  4012. $where .= " and features like '%-$color-%'";
  4013. }
  4014. if ($lowe) {
  4015. $where .= " and features like '%-$lowe-%'";
  4016. }
  4017. if ($warehouse) {
  4018. $where .= " and warehouse = '$warehouse'";
  4019. }
  4020. if ($purchase) {
  4021. $where .= " and purchase = '$purchase'";
  4022. }
  4023. if ($sku) {
  4024. $where .= " and sku = '$sku'";
  4025. }
  4026. if($rktype){
  4027. $where .= " and rktype = '$rktype' ";
  4028. }
  4029. if ($ktime && $jtime) {
  4030. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4031. }
  4032. //数据排序
  4033. $order_str = "id desc";
  4034. if (empty($page)) {
  4035. $start = 0;
  4036. $perpage = 1;
  4037. } else {
  4038. $start = ($page - 1) * $perpage;
  4039. }
  4040. $list = array();
  4041. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4042. foreach ($rows as $value) {
  4043. $ck = $this->warehouse->read($value['warehouse']);
  4044. $warehouse = $ck['title'];
  4045. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4046. $retreatwarehouse = $tkck['title'];
  4047. $gy = $this->purchase->read($value['purchase']);
  4048. $purchase = $gy['title'];
  4049. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4050. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4051. }
  4052. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4053. $titlename = "<table border=1>
  4054. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4055. <tr align='center'>
  4056. <td>仓库</td>
  4057. <td>SKU</td>
  4058. <td>产品</td>
  4059. <td>时间</td>
  4060. <td>数量</td>
  4061. </tr>
  4062. </table>";
  4063. $filename = $title . ".xls";
  4064. $tail = "";
  4065. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4066. }
  4067. }
  4068. //出库、退库导出
  4069. public function _excelct()
  4070. {
  4071. $classid = $this->classid->sku();
  4072. $pm = $classid;
  4073. $typeclass = array();
  4074. $tc = $this->typeclass->find_all();
  4075. foreach ($tc as $v) {
  4076. $typeclass[$v['id']] = $v;
  4077. }
  4078. $prc = array();
  4079. $purchase = $this->purchase->find_all();
  4080. foreach ($purchase as $k => $v) {
  4081. $prc[$v['id']] = $v['title'];
  4082. }
  4083. if (isset($_GET['excel'])) {
  4084. $wh = array();
  4085. $w = $this->warehouse->find_all('1=1', 'id,title');
  4086. foreach ($w as $v) {
  4087. $wh[$v['id']] = $v['title'];
  4088. }
  4089. $type = $this->input->get('excel', true);
  4090. $category = $this->input->get('category', true);
  4091. $size = $this->input->get('size', true);
  4092. $grade = $this->input->get('grade', true);
  4093. $color = $this->input->get('color', true);
  4094. $lowe = $this->input->get('lowe', true);
  4095. $sku = $this->input->get('sku', true);
  4096. $title = $this->input->get('title', true);
  4097. $warehouse = $this->input->get('warehouse', true);
  4098. $purchase = $this->input->get('purchase', true);
  4099. $lacetype = $this->input->get('lacetype', true);
  4100. $haircap = $this->input->get('haircap', true);
  4101. $lacecolor = $this->input->get('lacecolor', true);
  4102. $density = $this->input->get('density', true);
  4103. $details = $this->input->get('details', true);
  4104. $state = $this->input->get('state', true);
  4105. $shop = $this->input->get('shop', true);
  4106. $hairnumber = $this->input->get('hairnumber', true);
  4107. $type_leixi = $this->input->get('type', true);
  4108. $cpbz = $this->input->get('cpbz', true);
  4109. $sm = $this->input->get('sm', true);
  4110. $sid = $this->input->get('sid', true);
  4111. $ktime = $this->input->get('ktime', true);
  4112. $jtime = $this->input->get('jtime', true);
  4113. $ktime = strtotime($ktime);
  4114. $jtime = strtotime($jtime);
  4115. //$where = " 1=1 ";
  4116. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4117. $where = " sku != '' ";
  4118. $gj = "";
  4119. $ck = "";
  4120. if ($category) {
  4121. $where .= " and features like '%-$category-%'";
  4122. }
  4123. if ($size) {
  4124. $where .= " and features like '%-$size-%'";
  4125. }
  4126. if ($grade) {
  4127. $where .= " and features like '%-$grade-%'";
  4128. }
  4129. if ($color) {
  4130. $where .= " and features like '%-$color-%'";
  4131. }
  4132. if ($lowe) {
  4133. $where .= " and features like '%-$lowe-%'";
  4134. }
  4135. if ($warehouse) {
  4136. $where .= " and warehouse = '$warehouse'";
  4137. }
  4138. if ($purchase) {
  4139. $where .= " and purchase = '$purchase'";
  4140. }
  4141. if ($state) {
  4142. $where .= " and state = '$state'";
  4143. }
  4144. if ($lacetype) {
  4145. $where .= " and features like '%-$lacetype-%'";
  4146. }
  4147. if ($lacecolor) {
  4148. $where .= " and features like '%-$lacecolor-%'";
  4149. }
  4150. if ($density) {
  4151. $where .= " and features like '%-$density-%'";
  4152. }
  4153. if ($haircap) {
  4154. $where .= " and features like '%-$haircap-%'";
  4155. }
  4156. if ($details) {
  4157. $where .= " and details = '$details'";
  4158. }
  4159. if ($shop) {
  4160. $where .= " and shop like '%$shop%'";
  4161. }
  4162. if ($title) {
  4163. $title = trim($title, ' ');
  4164. $title = trim($title, ' ');
  4165. $where .= " and title like '%$title%'";
  4166. }
  4167. if (!empty($hairnumber)) {
  4168. $where .= " and features like '%-128-%' ";
  4169. if ($hairnumber < 0) {
  4170. $class_list = $this->typeclass->find_all('classid = 43');
  4171. foreach ($class_list as $v) {
  4172. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4173. }
  4174. } else {
  4175. $where .= " and features like '%-$hairnumber-%'";
  4176. }
  4177. }
  4178. if ($type_leixi) {
  4179. $where .= " and type = '$type_leixi'";
  4180. }
  4181. if ($cpbz) {
  4182. $where .= " and cpbz like '%$cpbz%' ";
  4183. }
  4184. if ($sm) {
  4185. $where .= " and sm like '%$sm%' ";
  4186. }
  4187. if ($sku) {
  4188. $sku = trim($sku, ' ');
  4189. $sku = trim($sku, ' ');
  4190. $where .= " and sku like '%$sku%'";
  4191. }
  4192. if ($ktime && $jtime) {
  4193. if ($type == 1) {
  4194. $tl = '出库';
  4195. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4196. } else if ($type == 2) {
  4197. $tl = '退库';
  4198. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4199. } else if ($type == 3) {
  4200. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4201. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4202. } else if ($type == 4) {
  4203. $tl = '出库+零售';
  4204. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4205. } else if ($type == 5) {
  4206. $tl = '零售';
  4207. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4208. }
  4209. }
  4210. $sidwhere = '';
  4211. if ($sid) {
  4212. $sd = "";
  4213. $s = explode(',', trim($sid, ','));
  4214. foreach ($s as $value) {
  4215. $sd .= " id = " . $value . " or";
  4216. }
  4217. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4218. }
  4219. //数据排序
  4220. $order_str = "time desc";
  4221. if (empty($page)) {
  4222. $start = 0;
  4223. $perpage = 1;
  4224. } else {
  4225. $start = ($page - 1) * $perpage;
  4226. }
  4227. //取得信息列表
  4228. if ($type != 3 && $type != 5) {
  4229. if ($type == 1 || $type == 4) {
  4230. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4231. foreach ($info_list as $key => $value) {
  4232. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4233. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4234. $warehouse = $this->warehouse->read($value['warehouse']);
  4235. $info_list[$key]['warehouse'] = $warehouse['title'];
  4236. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4237. $features = explode('-', trim($features, '-'));
  4238. $pm = $classid;
  4239. foreach ($features as $k => $v) {
  4240. if ($v != 0) {
  4241. if (!isset($typeclass[$v])) {
  4242. continue;
  4243. }
  4244. if (isset($pm[$typeclass[$v]['classid']])) {
  4245. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4246. $tz = explode('|', $typeclass[$v]['zh']);
  4247. $pm[$typeclass[$v]['classid']] = $tz[0];
  4248. } else {
  4249. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4250. }
  4251. }
  4252. }
  4253. }
  4254. $zh = implode(" ", $pm);
  4255. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4256. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4257. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4258. $info_list[$key]['features'] = $zh;
  4259. }
  4260. $final_list = [];
  4261. foreach($info_list as $k=>$v){
  4262. $number = "";
  4263. if(!empty($v['orderinfo'])){
  4264. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4265. if(!empty($tmp_info['number'])){
  4266. $number = $tmp_info['number'];
  4267. }
  4268. }
  4269. $final_list[] = [
  4270. 'warehouse'=>$v['warehouse'],
  4271. 'purchase'=>$v['purchase'],
  4272. 'sku'=>$v['sku'],
  4273. 'title'=>$v['title'],
  4274. 'features'=>$v['features'],
  4275. 'label'=>$v['label'],
  4276. 'orderinfo'=>$v['orderinfo'],
  4277. 'number'=>$number,
  4278. 'waybill'=>$v['waybill'],
  4279. 'outk'=>$v['outk'],
  4280. ];
  4281. }
  4282. } else {
  4283. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4284. foreach ($info_list as $key => $value) {
  4285. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4286. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4287. $warehouse = $this->warehouse->read($value['warehouse']);
  4288. $info_list[$key]['warehouse'] = $warehouse['title'];
  4289. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4290. $features = explode('-', trim($features, '-'));
  4291. $pm = $classid;
  4292. foreach ($features as $k => $v) {
  4293. if ($v != 0) {
  4294. if (!isset($typeclass[$v])) {
  4295. continue;
  4296. }
  4297. if (isset($pm[$typeclass[$v]['classid']])) {
  4298. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4299. $tz = explode('|', $typeclass[$v]['zh']);
  4300. $pm[$typeclass[$v]['classid']] = $tz[0];
  4301. } else {
  4302. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4303. }
  4304. }
  4305. }
  4306. }
  4307. $zh = implode(" ", $pm);
  4308. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4309. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4310. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4311. $info_list[$key]['features'] = $zh;
  4312. }
  4313. $final_list = [];
  4314. foreach($info_list as $k=>$v){
  4315. $number = "";
  4316. if(!empty($v['orderinfo'])){
  4317. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4318. if(!empty($tmp_info['number'])){
  4319. $number = $tmp_info['number'];
  4320. }
  4321. }
  4322. $final_list[] = [
  4323. 'warehouse'=>$v['warehouse'],
  4324. 'purchase'=>$v['purchase'],
  4325. 'sku'=>$v['sku'],
  4326. 'title'=>$v['title'],
  4327. 'features'=>$v['features'],
  4328. 'label'=>$v['label'],
  4329. 'orderinfo'=>$v['orderinfo'],
  4330. 'number'=>$number,
  4331. 'waybill'=>$v['waybill'],
  4332. 'retreat'=>$v['retreat'],
  4333. ];
  4334. }
  4335. }
  4336. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4337. $titlename = "<table border=1>
  4338. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4339. <tr align='center'>
  4340. <td>仓库</td>
  4341. <td>供应商</td>
  4342. <td>SKU</td>
  4343. <td>商品名称</td>
  4344. <td>商品中文</td>
  4345. <td>标签</td>
  4346. <td>订单号</td>
  4347. <td>订单编码</td>
  4348. <td>运单号</td>
  4349. <td>" . $tl . "时间(中国时间)</td>
  4350. </tr>
  4351. </table>";
  4352. $filename = $title . ".xls";
  4353. $tail = "";
  4354. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4355. } else if ($type == 5) {
  4356. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4357. foreach ($info_list as $key => $value) {
  4358. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4359. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4360. $warehouse = $this->warehouse->read($value['warehouse']);
  4361. $info_list[$key]['warehouse'] = $warehouse['title'];
  4362. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4363. $features = explode('-', trim($features, '-'));
  4364. $pm = $classid;
  4365. foreach ($features as $k => $v) {
  4366. if ($v != 0) {
  4367. if (!isset($typeclass[$v])) {
  4368. continue;
  4369. }
  4370. if (isset($pm[$typeclass[$v]['classid']])) {
  4371. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4372. $tz = explode('|', $typeclass[$v]['zh']);
  4373. $pm[$typeclass[$v]['classid']] = $tz[0];
  4374. } else {
  4375. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4376. }
  4377. }
  4378. }
  4379. }
  4380. $zh = implode(" ", $pm);
  4381. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4382. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4383. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4384. $info_list[$key]['features'] = $zh;
  4385. }
  4386. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4387. $titlename = "<table border=1>
  4388. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4389. <tr align='center'>
  4390. <td>仓库</td>
  4391. <td>供应商</td>
  4392. <td>SKU</td>
  4393. <td>商品名称</td>
  4394. <td>商品中文</td>
  4395. <td>标签</td>
  4396. <td>" . $tl . "时间(中国时间)</td>
  4397. </tr>
  4398. </table>";
  4399. $filename = $title . ".xls";
  4400. $tail = "";
  4401. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4402. } else {
  4403. /**
  4404. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4405. $rows = array();$list = array();
  4406. foreach ($info_list as $key=>$value)
  4407. {
  4408. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4409. }
  4410. **/
  4411. $wh = array();
  4412. $w = $this->warehouse->find_all('1=1', 'id,title');
  4413. foreach ($w as $v) {
  4414. $wh[$v['id']] = $v['title'];
  4415. }
  4416. $wt = array();
  4417. $whlabel_type = $this->whlabel_type->find_all();
  4418. foreach ($whlabel_type as $v) {
  4419. $wt[$v['id']] = $v['title'];
  4420. }
  4421. $classid = $this->classid->sku();
  4422. $list = array();
  4423. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4424. foreach ($rows as $key => $value) {
  4425. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4426. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4427. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state,outk,retreat');
  4428. $details = array();
  4429. $cpid = array();
  4430. $cpbz = array();
  4431. $c = 0;
  4432. $g = 0;
  4433. $x = 0;
  4434. $t = 0;
  4435. $s = 0;
  4436. $q = 0;
  4437. foreach ($sd as $k => $v) {
  4438. if ($v['state'] == 0) {
  4439. $c++;
  4440. }
  4441. if ($v['state'] != 9) {
  4442. $g++;
  4443. }
  4444. if ($v['outk'] > 1) {
  4445. $x++;
  4446. }
  4447. if ($v['retreat'] > 0) {
  4448. $t++;
  4449. }
  4450. if ($v['state'] == 8) {
  4451. $s++;
  4452. }
  4453. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4454. $q++;
  4455. }
  4456. $details[$v['details']] = $v['details'];
  4457. if($v['state'] == 0){
  4458. if ($v['cpid'] != 0) {
  4459. $cpid[$v['cpid']] = $v['cpid'];
  4460. }
  4461. if ($v['cpbz'] != '') {
  4462. $cpbz[$v['cpbz']] = $v['cpbz'];
  4463. }
  4464. }
  4465. }
  4466. if (isset($wt[$value['type']])) {
  4467. $rows[$key]['type'] = $wt[$value['type']];
  4468. } else {
  4469. $rows[$key]['type'] = '未设置';
  4470. }
  4471. $rows[$key]['details'] = implode("、", $details);
  4472. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4473. $ftime = time() - 15 * 24 * 3600;
  4474. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4475. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4476. $rows[$key]['g'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state != 9' . $gj);
  4477. $rows[$key]['c'] = $c;
  4478. $rows[$key]['x'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state = 1' . $ck);
  4479. $rows[$key]['t'] = $t;
  4480. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  4481. $rows[$key]['z'] = $z;
  4482. // $jm = $classid;
  4483. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4484. $features = explode('-', trim($features, '-'));
  4485. // $pm = $classid;
  4486. // foreach ($features as $k => $v) {
  4487. // if ($v != 0) {
  4488. // if (!isset($typeclass[$v])) {
  4489. // continue;
  4490. // }
  4491. // if (isset($pm[$typeclass[$v]['classid']])) {
  4492. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4493. // $tz = explode('|', $typeclass[$v]['zh']);
  4494. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4495. // } else {
  4496. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4497. // }
  4498. // if (isset($jm[$typeclass[$v]['classid']])) {
  4499. // if ($typeclass[$v]['jm']) {
  4500. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4501. // }
  4502. // }
  4503. // }
  4504. // }
  4505. // }
  4506. // $zh = implode(" ", $pm);
  4507. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4508. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4509. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4510. // $rows[$key]['features'] = $zh;
  4511. // $jm = array_filter($jm); //去除空值
  4512. // $jm = implode("-", $jm);
  4513. // $rows[$key]['jm'] = $jm;
  4514. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4515. }
  4516. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4517. // echo "<pre>";
  4518. // print_r($tmp_list);
  4519. // die;
  4520. $final_list =[];
  4521. foreach($tmp_list as $k=>$v){
  4522. $final_list[] = [
  4523. "warehouse"=>$v['warehouse'],
  4524. "purchase"=>$v['purchase'],
  4525. "details"=>trim($v['details'],'、'),
  4526. "cpid"=>$v['cpid'],
  4527. "sku"=>$v['sku'],
  4528. "title"=>$v['title'],
  4529. "features"=>$v['pm'],
  4530. "cpbz"=>$v['cpbz'],
  4531. "sm"=>$v['sm'],
  4532. "type"=>$v['type'],
  4533. "g"=>$v["g"],
  4534. "c"=>$v["c"],
  4535. "x"=>$v["x"],
  4536. "t"=>$v["t"],
  4537. "z"=>$v["z"],
  4538. "jm"=>$v["jm"],
  4539. "weight"=>$v["weight"],
  4540. "asd"=>$v["asd"],
  4541. ];
  4542. }
  4543. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4544. $titlename = "<table border=1>
  4545. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4546. <tr align='center'>
  4547. <td>仓库</td>
  4548. <td>供应商</td>
  4549. <td>位置</td>
  4550. <td>库存编码</td>
  4551. <td>SKU</td>
  4552. <td>商品名称</td>
  4553. <td>商品中文</td>
  4554. <td>产品备注</td>
  4555. <td>说明</td>
  4556. <td>类型</td>
  4557. <td>入库总量</td>
  4558. <td>库存数量</td>
  4559. <td>销售数量</td>
  4560. <td>退货数量</td>
  4561. <td>占单数量</td>
  4562. <td>料号</td>
  4563. <td>重量</td>
  4564. <td>类目</td>
  4565. </tr>
  4566. </table>";
  4567. $filename = $title . ".xls";
  4568. $tail = "";
  4569. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4570. }
  4571. }
  4572. }
  4573. //出库+入库数据整合
  4574. public function _excelcr()
  4575. {
  4576. if (isset($_GET['excel'])) {
  4577. $type = $this->input->get('excel', true);
  4578. $category = $this->input->get('category', true);
  4579. $size = $this->input->get('size', true);
  4580. $grade = $this->input->get('grade', true);
  4581. $color = $this->input->get('color', true);
  4582. $lowe = $this->input->get('lowe', true);
  4583. $sku = $this->input->get('sku', true);
  4584. $warehouse = $this->input->get('warehouse', true);
  4585. $purchase = $this->input->get('purchase', true);
  4586. $state = $this->input->get('state', true);
  4587. $sid = $this->input->get('sid', true);
  4588. $ktime = $this->input->get('ktime', true);
  4589. $jtime = $this->input->get('jtime', true);
  4590. $ktime = strtotime($ktime);
  4591. $jtime = strtotime($jtime);
  4592. $where = "1=1";
  4593. $gj = "";
  4594. $ck = "";
  4595. if ($category) {
  4596. $where .= " and features like '%-$category-%'";
  4597. }
  4598. if ($size) {
  4599. $where .= " and features like '%-$size-%'";
  4600. }
  4601. if ($grade) {
  4602. $where .= " and features like '%-$grade-%'";
  4603. }
  4604. if ($color) {
  4605. $where .= " and features like '%-$color-%'";
  4606. }
  4607. if ($lowe) {
  4608. $where .= " and features like '%-$lowe-%'";
  4609. }
  4610. if ($warehouse) {
  4611. $where .= " and warehouse = '$warehouse'";
  4612. }
  4613. if ($purchase) {
  4614. $where .= " and purchase = '$purchase'";
  4615. }
  4616. if ($state) {
  4617. $where .= " and state = '$state'";
  4618. }
  4619. if ($sku) {
  4620. $where .= " and sku like '%$sku%'";
  4621. }
  4622. if ($ktime && $jtime) {
  4623. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4624. }
  4625. $sidwhere = '';
  4626. if ($sid) {
  4627. $sd = "";
  4628. $s = explode(',', trim($sid, ','));
  4629. foreach ($s as $value) {
  4630. $sd .= " id = " . $value . " or";
  4631. }
  4632. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4633. }
  4634. //取得信息列表
  4635. $timeread = $ktime;
  4636. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4637. $timelist = array();
  4638. for ($i = 0; $i < $timenum; $i++) {
  4639. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4640. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4641. }
  4642. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4643. //echo "<pre>";
  4644. //print_r($info_list);
  4645. //exit();
  4646. $rows = array();
  4647. $list = array();
  4648. foreach ($info_list as $key => $value) {
  4649. $thistime = $timelist;
  4650. if (isset($rows[strtolower($value['sku'])])) {
  4651. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4652. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4653. }
  4654. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4655. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4656. }
  4657. } else {
  4658. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4659. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4660. }
  4661. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4662. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4663. }
  4664. $rows[strtolower($value['sku'])] = $thistime;
  4665. }
  4666. }
  4667. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4668. <head>
  4669. <!--[if gte mso 9]><xml>
  4670. <x:ExcelWorkbook>
  4671. <x:ExcelWorksheets>
  4672. <x:ExcelWorksheet>
  4673. <x:Name>EXCEL</x:Name>
  4674. <x:WorksheetOptions>
  4675. <x:Print>
  4676. <x:ValidPrinterInfo />
  4677. </x:Print>
  4678. </x:WorksheetOptions>
  4679. </x:ExcelWorksheet>
  4680. </x:ExcelWorksheets>
  4681. </x:ExcelWorkbook>
  4682. </xml>
  4683. <![endif]-->
  4684. </head><body>";
  4685. $str .= "<table border=1><tr><td>SKU</td>";
  4686. foreach ($timelist as $k => $v) {
  4687. $str .= "<td>" . $k . "出库</td>";
  4688. $str .= "<td>" . $k . "入库</td>";
  4689. }
  4690. $str .= "</tr></table>";
  4691. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4692. foreach ($rows as $key => $val) {
  4693. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4694. foreach ($val as $k => $v) {
  4695. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4696. if ($val[$k]['r'] > 0) {
  4697. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4698. } else {
  4699. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4700. }
  4701. }
  4702. $str .= "</tr>";
  4703. }
  4704. $str .= "</table>";
  4705. $str .= "</body></html>";
  4706. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4707. header("Content-type: application/octet-stream");
  4708. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4709. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4710. header("Pragma: no-cache");
  4711. header("Expires: 0");
  4712. exit($str);
  4713. }
  4714. }
  4715. //数量调整模板导出
  4716. public function _presetout()
  4717. {
  4718. if (isset($_GET['excel'])) {
  4719. $where = "sku != 'Preset' and purchase != 0";
  4720. //数据排序
  4721. $order_str = "id desc";
  4722. if (empty($page)) {
  4723. $start = 0;
  4724. $perpage = 1;
  4725. } else {
  4726. $start = ($page - 1) * $perpage;
  4727. }
  4728. //取得信息列表
  4729. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4730. $rows = array();
  4731. $list = array();
  4732. foreach ($info_list as $value) {
  4733. $warehouse = $this->warehouse->read($value['warehouse']);
  4734. $number = $value['number'];
  4735. $ftime = time() - 15 * 24 * 3600;
  4736. $purchase = $this->purchase->read($value['purchase']);
  4737. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4738. }
  4739. $title = "库存模板";
  4740. $titlename = "<table border=1>
  4741. <tr align='center'>
  4742. <td>仓库</td>
  4743. <td>供应商编码</td>
  4744. <td>SKU</td>
  4745. <td>增减数量(正数或负数)</td>
  4746. <td>增减备注</td>
  4747. <td>库位</td>
  4748. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4749. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4750. </tr>
  4751. </table>";
  4752. $filename = $title . ".xls";
  4753. $tail = "";
  4754. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4755. }
  4756. }
  4757. //数量调整模板导入
  4758. public function _presetedit()
  4759. {
  4760. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4761. $config['upload_path'] = '.' . $dir;
  4762. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4763. $config['allowed_types'] = 'xls|xlsx|csv';
  4764. $config['max_size'] = 10240;
  4765. $this->load->library('upload', $config);
  4766. $this->upload->initialize($config);
  4767. if ($this->upload->do_upload('userfile')) {
  4768. $full_path = $dir . $this->upload->data('file_name');
  4769. $fileName = '.' . $full_path;
  4770. if (!file_exists($fileName)) {
  4771. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4772. exit;
  4773. } else {
  4774. require_once "./data/excel/PHPExcel/IOFactory.php";
  4775. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4776. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4777. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4778. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4779. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4780. ++$column; //如果列数大于26行
  4781. $list = array();
  4782. for ($i = 2; $i <= $row; $i++) // 行数循环
  4783. {
  4784. $data = array();
  4785. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4786. {
  4787. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4788. }
  4789. $list[] = $data;
  4790. }
  4791. }
  4792. $i = 0;
  4793. $j = 0;
  4794. $ed = array();
  4795. foreach ($list as $key => $value) {
  4796. $time = time();
  4797. if ($value['0'] == "") {
  4798. continue;
  4799. }
  4800. $warehouse = $this->warehouse->get_title($value['0']);
  4801. $purchase = $this->purchase->get_bm($value['1']);
  4802. $sku = $value['2'];
  4803. $num = $value['3']; //调整数量
  4804. $text = $value['4']; //扣减说明
  4805. $type = $value['5']; //调整方式0扣减1删除
  4806. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4807. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4808. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4809. if (!$purchase) //如果没有这个SKU
  4810. {
  4811. $ed[] = array($purchase . '-不存在此供应商编码');
  4812. $j++;
  4813. continue;
  4814. }
  4815. if (!$d) //如果没有这个SKU
  4816. {
  4817. $ed[] = array($sku . '-库存中不存在此SKU');
  4818. $j++;
  4819. continue;
  4820. }
  4821. if (!isset($warehouse['id'])) {
  4822. $ed[] = array($sku . '-仓库名错误!');
  4823. $j++;
  4824. continue;
  4825. }
  4826. if ($type != '0' && $type != '1') {
  4827. $ed[] = array($sku . '-扣减方式填写错误!');
  4828. $j++;
  4829. continue;
  4830. }
  4831. if ($num < 0) //扣减库存
  4832. {
  4833. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4834. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4835. $j++;
  4836. continue;
  4837. }
  4838. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4839. if (count($data) < abs($num)) {
  4840. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4841. $j++;
  4842. continue;
  4843. }
  4844. if ($type == 0) //如果扣减方式为 扣减库存
  4845. {
  4846. for ($i = 0; $i < abs($num); $i++) {
  4847. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4848. }
  4849. } else if ($type == 1) {
  4850. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4851. if (count($zt) > 0) {
  4852. $ed[] = array($sku . '-有在途库存无法删除!');
  4853. $j++;
  4854. continue;
  4855. }
  4856. for ($i = 0; $i < abs($num); $i++) {
  4857. $this->whlabel->remove($data[$i]['id']);
  4858. }
  4859. }
  4860. } else if ($num > 0) //增加库存
  4861. {
  4862. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4863. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4864. $j++;
  4865. continue;
  4866. }
  4867. $post['sku'] = $d['sku'];
  4868. $post['shop'] = $d['shop'];
  4869. $post['warehouse'] = $warehouse['id'];
  4870. $post['purchase'] = $purchase['id'];
  4871. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4872. $post['state'] = 0;
  4873. $post['title'] = $d['title'];
  4874. $post['number'] = $d['number'];
  4875. $post['features'] = $d['features'];
  4876. $post['enter'] = $time;
  4877. $post['time'] = $time; //操作时间
  4878. $post['rktype'] = $rktype;
  4879. for ($i = 0; $i < $num; $i++) {
  4880. $post['label'] = time() . rand(100, 999) . $i;
  4881. $this->whlabel->insert($post);
  4882. }
  4883. }
  4884. sleep(1); //防止入库时间一样,需要延迟1秒
  4885. }
  4886. if ($j > 0) {
  4887. $tt = date('Ymd', time());
  4888. $title = '库存导入错误信息-' . $tt;
  4889. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4890. $tail = "\n";
  4891. $filename = $title . ".xls";
  4892. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4893. $dir = '/data/excel/' . $time . '/';
  4894. $file_name = 'error_' . $time . rand(1000, 9999);
  4895. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4896. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4897. fwrite($myfile, $ecl);
  4898. fclose($myfile);
  4899. $error = $dir . $file_name . '.xls';
  4900. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4901. exit;
  4902. } else {
  4903. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4904. exit;
  4905. }
  4906. }
  4907. }
  4908. public function _presetedittwo(){
  4909. $data = $this->input->post(NULL, TRUE);
  4910. if(empty($list)){
  4911. $raw_data = $this->input->raw_input_stream;
  4912. // 解码 JSON
  4913. $data = json_decode($raw_data, true);
  4914. }
  4915. if(empty($data)){
  4916. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4917. exit;
  4918. }
  4919. $list = [];
  4920. if(isset($data['list'])){
  4921. $list = $data['list'];
  4922. }
  4923. $i = 0;
  4924. $j = 0;
  4925. $ed = array();
  4926. foreach ($list as $key => $value) {
  4927. $time = time();
  4928. if ($value['0'] == "") {
  4929. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4930. $j++;
  4931. continue;
  4932. }
  4933. $warehouse = $this->warehouse->get_title($value['0']);
  4934. if(empty($warehouse)){
  4935. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4936. $j++;
  4937. continue;
  4938. }
  4939. $purchase = $this->purchase->get_bm($value['1']);
  4940. $sku = $value['2'];
  4941. $num = $value['3']; //调整数量
  4942. $text = $value['4']; //扣减说明
  4943. $type = 0; //调整方式0扣减1删除
  4944. $details = empty($value['5'])?'':$value['5']; //库位
  4945. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4946. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4947. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4948. if (!$purchase) //如果没有这个SKU
  4949. {
  4950. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4951. $j++;
  4952. continue;
  4953. }
  4954. if (!$d) //如果没有这个SKU
  4955. {
  4956. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4957. $j++;
  4958. continue;
  4959. }
  4960. if (!isset($warehouse['id'])) {
  4961. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4962. $j++;
  4963. continue;
  4964. }
  4965. if ($type != '0' && $type != '1') {
  4966. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4967. $j++;
  4968. continue;
  4969. }
  4970. if ($num < 0) //扣减库存
  4971. {
  4972. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4973. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4974. $j++;
  4975. continue;
  4976. }
  4977. if(!empty($details)){
  4978. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  4979. }else{
  4980. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  4981. }
  4982. if (count($data) < abs($num)) {
  4983. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  4984. $j++;
  4985. continue;
  4986. }
  4987. if ($type == 0) //如果扣减方式为 扣减库存
  4988. {
  4989. for ($i = 0; $i < abs($num); $i++) {
  4990. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4991. }
  4992. } else if ($type == 1) {
  4993. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4994. if (count($zt) > 0) {
  4995. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  4996. $j++;
  4997. continue;
  4998. }
  4999. for ($i = 0; $i < abs($num); $i++) {
  5000. $this->whlabel->remove($data[$i]['id']);
  5001. }
  5002. }
  5003. } else if ($num > 0) //增加库存
  5004. {
  5005. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5006. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5007. $j++;
  5008. continue;
  5009. }
  5010. if(empty($details)){
  5011. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5012. if(empty($tmp_info)){
  5013. $details = '';
  5014. }else{
  5015. $details = $tmp_info['details'];
  5016. }
  5017. }else{
  5018. if($details == 'DZ001'){
  5019. }else{
  5020. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5021. if(empty($tmp_info)){
  5022. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5023. $j++;
  5024. continue;
  5025. }
  5026. }
  5027. }
  5028. $post['sku'] = $d['sku'];
  5029. $post['shop'] = $d['shop'];
  5030. $post['warehouse'] = $warehouse['id'];
  5031. $post['purchase'] = $purchase['id'];
  5032. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5033. $post['state'] = 0;
  5034. $post['title'] = $d['title'];
  5035. $post['number'] = $d['number'];
  5036. $post['features'] = $d['features'];
  5037. $post['details'] = $details;
  5038. $post['enter'] = $time;
  5039. $post['time'] = $time; //操作时间
  5040. $post['rktype'] = $rktype;
  5041. $post['sku_master_id'] = $d['sku_master_id'];
  5042. $post['sku_shop_id'] = $d['sku_shop_id'];
  5043. for ($i = 0; $i < $num; $i++) {
  5044. $post['label'] = time() . rand(100, 999) . $i;
  5045. $this->whlabel->insert($post);
  5046. }
  5047. }
  5048. sleep(1); //防止入库时间一样,需要延迟1秒
  5049. }
  5050. if ($j > 0) {
  5051. $tt = date('Ymd', time());
  5052. $title = '库存导入错误信息-' . $tt;
  5053. $error = $title . '.xls';
  5054. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5055. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5056. exit;
  5057. } else {
  5058. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5059. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5060. exit;
  5061. }
  5062. }
  5063. //笛卡儿积
  5064. function cp($ps, $sets, $list)
  5065. {
  5066. $result = array();
  5067. $j = 0;
  5068. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5069. if ($i == 0) {
  5070. $result = $sets[$i];
  5071. }
  5072. $tmp = array();
  5073. foreach ($result as $res) {
  5074. foreach ($sets[$i + 1] as $set) {
  5075. $tmp[] = $res . ',' . $set;
  5076. }
  5077. }
  5078. $result = $tmp;
  5079. }
  5080. $this->db->trans_begin();
  5081. foreach ($result as $v) {
  5082. $post = array();
  5083. $title = "";
  5084. $num = "";
  5085. $data = explode(',', $v);
  5086. for ($i = 0; $i < count($list); $i++) {
  5087. $post[$list[$i]] = $data[$i];
  5088. $typeclass = $this->typeclass->read($data[$i]);
  5089. $title = $title . $typeclass['title'] . " ";
  5090. if ($data[$i] != 0) {
  5091. $num .= $data[$i]; //所有数据ID拼接
  5092. }
  5093. }
  5094. foreach ($ps as $kp => $vp) {
  5095. $post[$kp] = $vp;
  5096. }
  5097. $post['number'] = $num;
  5098. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5099. if ($info_list) {
  5100. $j++;
  5101. } else {
  5102. $skunum = $this->whlabel->find_count();
  5103. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5104. $post['title'] = rtrim($title, ' ');
  5105. $this->whlabel->insert($post);
  5106. }
  5107. }
  5108. if ($this->db->trans_status() === FALSE) {
  5109. $this->db->trans_commit();
  5110. return NULL;
  5111. } else {
  5112. $this->db->trans_commit();
  5113. return $j;
  5114. }
  5115. }
  5116. public function _kj($arg_array)
  5117. {
  5118. if (isset($_POST['sku'])) {
  5119. $time = time();
  5120. $sku = $this->input->post('sku', true);
  5121. $warehouse = $this->input->post('warehouse', true);
  5122. $num = $this->input->post('num', true);
  5123. $text = $this->input->post('text', true);
  5124. $purchase = $this->input->post('purchase', true);
  5125. $cktype = $this->input->post('cktype', true);
  5126. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5127. if ($cktype != 1 && $text == '') {
  5128. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5129. exit;
  5130. }
  5131. if ($num > count($order)) {
  5132. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5133. exit;
  5134. } else {
  5135. for ($i = 0; $i < $num; $i++) {
  5136. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5137. }
  5138. }
  5139. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5140. exit;
  5141. }
  5142. $uid = $this->whlabel->read($arg_array[0]);
  5143. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5144. $this->data['data'] = $uid;
  5145. $this->_Template('whlabel_kj', $this->data);
  5146. }
  5147. public function _summary($arg_array)
  5148. {
  5149. $prc = array();
  5150. $purchase = $this->purchase->find_all();
  5151. foreach ($purchase as $k => $v) {
  5152. $prc[$v['id']] = $v['title'];
  5153. }
  5154. if (isset($_GET['excel'])) {
  5155. $ktime = $this->input->get('ktime', true);
  5156. $jtime = $this->input->get('jtime', true);
  5157. $ktime = strtotime($ktime);
  5158. $jtime = strtotime($jtime);
  5159. $where = "1=1";
  5160. if ($ktime && $jtime) {
  5161. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5162. }
  5163. //数据排序
  5164. $order_str = "time desc";
  5165. if (empty($page)) {
  5166. $start = 0;
  5167. $perpage = 1;
  5168. } else {
  5169. $start = ($page - 1) * $perpage;
  5170. }
  5171. //取得信息列表
  5172. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5173. foreach ($info_list as $key => $value) {
  5174. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5175. $warehouse = $this->warehouse->read($value['warehouse']);
  5176. $info_list[$key]['warehouse'] = $warehouse['title'];
  5177. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid,status');
  5178. $details = array();
  5179. $cpid = array();
  5180. foreach ($x as $k => $v) {
  5181. if($v['status'] == 0){
  5182. if ($v['details'] != '') {
  5183. $details[$v['details']] = $v['details'];
  5184. }
  5185. if ($v['cpid'] != 0) {
  5186. $cpid[$v['cpid']] = $v['cpid'];
  5187. }
  5188. }
  5189. }
  5190. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5191. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5192. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5193. $info_list[$key]['s'] = $s;
  5194. $info_list[$key]['x'] = count($x);
  5195. }
  5196. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5197. $titlename = "<table border=1>
  5198. <tr align='center'>
  5199. <td>仓库</td>
  5200. <td>供应商</td>
  5201. <td>出库位置</td>
  5202. <td>出库编码</td>
  5203. <td>SKU</td>
  5204. <td>产品名</td>
  5205. <td>总剩余库存</td>
  5206. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5207. </tr>
  5208. </table>";
  5209. $filename = $title . ".xls";
  5210. $tail = "";
  5211. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5212. }
  5213. }
  5214. //usps发货清单
  5215. public function _manifest()
  5216. {
  5217. if (isset($_POST['manifest'])) {
  5218. $wltext = $this->input->post('wltext', true);
  5219. $time = time() - 16 * 3600;
  5220. $ptime = strtotime(date('Y-m-d', $time));
  5221. $waybill = array();
  5222. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5223. foreach ($fullorder as $v) {
  5224. $waybill[$v['waybill']] = $v['waybill'];
  5225. }
  5226. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5227. foreach ($fullordersmt as $v) {
  5228. $waybill[$v['waybill']] = $v['waybill'];
  5229. }
  5230. $wltext = explode(';', $wltext);
  5231. foreach ($wltext as $v) {
  5232. if (isset($waybill[$v])) {
  5233. unset($waybill[$v]);
  5234. }
  5235. }
  5236. $data = $this->usps->get_manifest($waybill);
  5237. if (isset($data['Description'])) {
  5238. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5239. exit;
  5240. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5241. $bctime = date('Ymd', time());
  5242. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5243. echo json_encode(array('msg' => $pdf, 'success' => true));
  5244. exit;
  5245. } else {
  5246. echo json_encode(array('msg' => $data, 'success' => false));
  5247. exit;
  5248. }
  5249. }
  5250. }
  5251. public function _pdf($pdf, $title, $bctime)
  5252. {
  5253. $pdf_path = './data/pdf/' . $bctime . '/';
  5254. $file_base64 = $pdf;
  5255. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5256. $file_base64 = base64_decode($file_base64);
  5257. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5258. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5259. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5260. }
  5261. /**
  5262. *
  5263. *
  5264. *
  5265. 进销存占单异常索引
  5266. *
  5267. *
  5268. *
  5269. **/
  5270. public function _abnormal()
  5271. {
  5272. $post = $this->input->post(NULL, TRUE);
  5273. if (isset($post['page'])) {
  5274. $page = $this->input->post('page', true);
  5275. $perpage = $this->input->post('perpage', true);
  5276. $sku = $this->input->post('sku', true);
  5277. $where = "1=1";
  5278. //数据排序
  5279. $order_str = "id desc";
  5280. if (empty($page)) {
  5281. $start = 0;
  5282. $perpage = 1;
  5283. } else {
  5284. $start = ($page - 1) * $perpage;
  5285. }
  5286. //取得信息列表
  5287. $info_list = $this->whlabel->find_all($where, '*');
  5288. $rows = array();
  5289. $list = array();
  5290. foreach ($info_list as $key => $value) {
  5291. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5292. }
  5293. foreach ($rows as $value) {
  5294. $warehouse = $this->warehouse->read($value['warehouse']);
  5295. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5296. $number = $value['number'];
  5297. $ftime = time() - 15 * 24 * 3600;
  5298. if ($value['shop'] != '') {
  5299. $shop = $value['shop'];
  5300. $orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5301. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5302. $order = array_merge($orderdlz, $ordersmt);
  5303. $od = 0;
  5304. $a = '';
  5305. $orid = '';
  5306. foreach ($order as $v) {
  5307. $or = explode('|', ltrim($v['whlabel'], '|'));
  5308. for ($i = 0; $i < count($or); $i++) {
  5309. $orod = explode('-', $or[$i]);
  5310. if ($orod[0] == $number) {
  5311. $od += $orod[1];
  5312. }
  5313. }
  5314. $orid .= $v['number'] . '-';
  5315. }
  5316. } else {
  5317. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5318. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5319. $order = array_merge($orderdlz, $ordersmt);
  5320. $od = 0;
  5321. $a = '';
  5322. $orid = '';
  5323. $qt = array();
  5324. foreach ($order as $v) {
  5325. $or = explode('|', ltrim($v['whlabel'], '|'));
  5326. for ($i = 0; $i < count($or); $i++) {
  5327. $orod = explode('-', $or[$i]);
  5328. if ($orod[0] == $number) {
  5329. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5330. if ($czzs > 0) {
  5331. if (isset($qt[$v['shop']])) {
  5332. if ($qt[$v['shop']] < $orod[1]) {
  5333. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5334. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5335. } else {
  5336. $qt[$v['shop']] -= $orod[1];
  5337. }
  5338. } else {
  5339. $qt[$v['shop']] = $czzs;
  5340. }
  5341. } else {
  5342. $od += $orod[1];
  5343. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5344. }
  5345. }
  5346. }
  5347. }
  5348. }
  5349. $z = $od . '(' . $orid . ')'; //查看订单号
  5350. //$z = $od;
  5351. if ($od > $c) {
  5352. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5353. }
  5354. }
  5355. $listdata = array_slice($list, $start, $perpage);
  5356. $total = count($list);
  5357. $pagenum = ceil($total / $perpage);
  5358. $over = $total - ($start + $perpage);
  5359. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5360. echo json_encode($rows);
  5361. exit;
  5362. }
  5363. $this->_Template('whlabel_abnormal', $this->data);
  5364. }
  5365. /**
  5366. *
  5367. *
  5368. *
  5369. 进销存占单异常索引
  5370. *
  5371. *
  5372. *
  5373. **/
  5374. public function _error()
  5375. {
  5376. $post = $this->input->post(NULL, TRUE);
  5377. if (isset($post['page'])) {
  5378. $page = $this->input->post('page', true);
  5379. $perpage = $this->input->post('perpage', true);
  5380. $sku = $this->input->post('sku', true);
  5381. $warehouse = $this->input->post('warehouse', true);
  5382. $ktime = $this->input->post('ktime', true);
  5383. $jtime = $this->input->post('jtime', true);
  5384. $ktime = strtotime($ktime);
  5385. $jtime = strtotime($jtime);
  5386. $where = "sku != 'Preset'";
  5387. $gj = '';
  5388. if ($sku) {
  5389. $where .= " and sku like '%$sku%'";
  5390. } else {
  5391. if ($ktime && $jtime) {
  5392. $gj = " and time > '$ktime' and time < '$jtime'";
  5393. }
  5394. }
  5395. if ($warehouse) {
  5396. $where .= " and warehouse = '$warehouse'";
  5397. }
  5398. //数据排序
  5399. $order_str = "id desc";
  5400. if (empty($page)) {
  5401. $start = 0;
  5402. $perpage = 1;
  5403. } else {
  5404. $start = ($page - 1) * $perpage;
  5405. }
  5406. //取得信息列表
  5407. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5408. $rows = array();
  5409. $list = array();
  5410. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5411. // foreach ($info_list as $value)
  5412. // {
  5413. // $warehouse = $this->warehouse->read($value['warehouse']);
  5414. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5415. // $number = $value['number'];$ftime = time()-15*24*3600;
  5416. // if($c < 1)
  5417. // {
  5418. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5419. // }
  5420. // }
  5421. $warehouse_list = $this->warehouse->find_all();
  5422. $warehouse_list = array_column($warehouse_list, null, 'id');
  5423. foreach ($info_list as $value) {
  5424. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5425. 'title' => "",
  5426. ];
  5427. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5428. $number = $value['number'];
  5429. $ftime = time() - 15 * 24 * 3600;
  5430. if ($c < 1) {
  5431. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5432. }
  5433. }
  5434. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5435. // $query = $this->db->query($sql);
  5436. // $info_list = $query->result_array();
  5437. // $sql_two = "select title,id from crowd_warehouse";
  5438. // $query_two = $this->db->query($sql_two);
  5439. // $warehouse_list = $query_two->result_array();
  5440. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5441. // foreach ($info_list as $value)
  5442. // {
  5443. // if(isset($warehouse_arr[$value['warehouse']])){
  5444. // $warehouse = $warehouse_arr[$value['warehouse']];
  5445. // }else{
  5446. // $warehouse = [
  5447. // 'id'=>0,
  5448. // 'title'=>"异常",
  5449. // ];
  5450. // }
  5451. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5452. // $number = $value['number'];$ftime = time()-15*24*3600;
  5453. // if($c < 1)
  5454. // {
  5455. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5456. // }
  5457. // }
  5458. $listdata = array_slice($list, $start, $perpage);
  5459. $total = count($list);
  5460. $pagenum = ceil($total / $perpage);
  5461. $over = $total - ($start + $perpage);
  5462. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5463. echo json_encode($rows);
  5464. exit;
  5465. }
  5466. if (isset($post['s'])) {
  5467. $id_arr = $this->input->post('s');
  5468. $id_arr = explode(',', trim($id_arr, ','));
  5469. if (!$id_arr) {
  5470. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5471. exit;
  5472. }
  5473. //循环删除记录
  5474. foreach ($id_arr as $v) {
  5475. $dd = $this->whlabel->read($v);
  5476. if (!isset($dd['id'])) {
  5477. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5478. exit;
  5479. }
  5480. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5481. if (isset($zt[0])) {
  5482. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5483. exit;
  5484. }
  5485. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5486. foreach ($deldd as $vv) {
  5487. $this->whlabel->remove($vv['id']);
  5488. }
  5489. }
  5490. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5491. exit;
  5492. }
  5493. $this->_Template('whlabel_error', $this->data);
  5494. }
  5495. public function _errorexcel()
  5496. {
  5497. $post = $this->input->post(NULL, TRUE);
  5498. if (isset($_GET['page'])) {
  5499. $page = $this->input->get('page', true);
  5500. $perpage = $this->input->get('perpage', true);
  5501. $sku = $this->input->get('sku', true);
  5502. $warehouse = $this->input->get('warehouse', true);
  5503. $ktime = $this->input->get('ktime', true);
  5504. $jtime = $this->input->get('jtime', true);
  5505. $ktime = strtotime($ktime);
  5506. $jtime = strtotime($jtime);
  5507. $where = "sku != 'Preset'";
  5508. $gj = '';
  5509. if ($sku) {
  5510. $where .= " and sku like '%$sku%'";
  5511. } else {
  5512. if ($ktime && $jtime) {
  5513. $gj = " and time > '$ktime' and time < '$jtime'";
  5514. }
  5515. }
  5516. if ($warehouse) {
  5517. $where .= " and warehouse = '$warehouse'";
  5518. }
  5519. //数据排序
  5520. $order_str = "id desc";
  5521. if (empty($page)) {
  5522. $start = 0;
  5523. $perpage = 1;
  5524. } else {
  5525. $start = ($page - 1) * $perpage;
  5526. }
  5527. //取得信息列表
  5528. $rows = array();
  5529. $list = array();
  5530. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5531. foreach ($info_list as $value) {
  5532. $warehouse = $this->warehouse->read($value['warehouse']);
  5533. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5534. $number = $value['number'];
  5535. $ftime = time() - 15 * 24 * 3600;
  5536. if ($c < 1) {
  5537. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5538. }
  5539. }
  5540. $title = "0库存汇总";
  5541. $titlename = "<table border=1>
  5542. <tr align='center'>
  5543. <td>仓库</td>
  5544. <td>SKU</td>
  5545. <td>产品</td>
  5546. <td>当前库存</td>
  5547. </tr>
  5548. </table>";
  5549. $filename = $title . ".xls";
  5550. $tail = "";
  5551. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5552. }
  5553. }
  5554. /**
  5555. *
  5556. *
  5557. * 占单
  5558. *
  5559. *
  5560. **/
  5561. public function _kcyz()
  5562. {
  5563. $post = $this->input->post(NULL, TRUE);
  5564. if (isset($post['warehouse'])) {
  5565. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5566. exit; //不再使用
  5567. $warehouse = $this->input->post('warehouse', true);
  5568. $whlabel = $this->input->post('whlabel', true);
  5569. $id = $this->input->post('id', true);
  5570. $shop = $this->input->post('shop', true);
  5571. $number = $this->input->post('number', true);
  5572. if (!$whlabel || $whlabel == '|') {
  5573. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5574. exit;
  5575. }
  5576. $pp = explode('|', trim($whlabel, '|'));
  5577. $x = 0;
  5578. $save = array();
  5579. foreach ($pp as $va) {
  5580. $num = explode('-', $va);
  5581. if ($number) {
  5582. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')"); //通用
  5583. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5584. } else {
  5585. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5586. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5587. }
  5588. $x++;
  5589. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5590. $save[] = $x - 1;
  5591. continue; //提前先加X不然出错,所以要减1
  5592. }
  5593. }
  5594. if (isset($save[0])) {
  5595. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5596. exit;
  5597. } else {
  5598. echo json_encode(array('success' => true));
  5599. exit;
  5600. }
  5601. }
  5602. }
  5603. public function _db()
  5604. {
  5605. $post = $this->input->post(NULL, TRUE);
  5606. if (isset($post['page'])) {
  5607. $page = $this->input->post('page', true);
  5608. $perpage = $this->input->post('perpage', true);
  5609. $sku = $this->input->post('sku', true);
  5610. $number = $this->input->post('number', true);
  5611. $warehouse = $this->input->post('warehouse', true);
  5612. $purchase = $this->input->post('purchase', true);
  5613. $orderinfo = $this->input->post('orderinfo', true);
  5614. $waybill = $this->input->post('waybill', true);
  5615. $category = $this->input->post('category', true);
  5616. $size = $this->input->post('size', true);
  5617. $grade = $this->input->post('grade', true);
  5618. $color = $this->input->post('color', true);
  5619. $lowe = $this->input->post('lowe', true);
  5620. $state = $this->input->post('state', true);
  5621. $label = $this->input->post('label', true);
  5622. $timetk = $this->input->post('timetkk', true);
  5623. $timetj = $this->input->post('timetjj', true);
  5624. $timetk = strtotime($timetk);
  5625. $timetj = strtotime($timetj);
  5626. $where = "dbtime > 0";
  5627. if ($timetk && $timetj) {
  5628. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5629. }
  5630. if ($sku) {
  5631. $where .= " and sku = '$sku'";
  5632. }
  5633. if ($warehouse) {
  5634. $where .= " and warehouse = '$warehouse'";
  5635. if ($warehouse == 12) {
  5636. $w = 'specialstock';
  5637. } else {
  5638. $w = 'whlabel';
  5639. }
  5640. }
  5641. if ($purchase) {
  5642. $where .= " and purchase = '$purchase'";
  5643. }
  5644. if ($category) {
  5645. $where .= " and features like '%-$category-%'";
  5646. }
  5647. if ($size) {
  5648. $where .= " and features like '%-$size-%'";
  5649. }
  5650. if ($grade) {
  5651. $where .= " and features like '%-$grade-%'";
  5652. }
  5653. if ($color) {
  5654. $where .= " and features like '%-$color-%'";
  5655. }
  5656. if ($lowe) {
  5657. $where .= " and features like '%-$lowe-%'";
  5658. }
  5659. if ($state != '') {
  5660. $where .= " and state = '$state'";
  5661. }
  5662. //数据排序
  5663. $order_str = "dbtime desc";
  5664. if (empty($page)) {
  5665. $start = 0;
  5666. $perpage = 1;
  5667. } else {
  5668. $start = ($page - 1) * $perpage;
  5669. }
  5670. //取得信息列表
  5671. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5672. foreach ($info_list as $key => $value) {
  5673. $warehouse = $this->$w->read($value['warehouse']);
  5674. $info_list[$key]['warehouse'] = $warehouse['title'];
  5675. $purchase = $this->purchase->read($value['purchase']);
  5676. $info_list[$key]['purchase'] = $purchase['title'];
  5677. if ($value['enter'] != 0) {
  5678. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5679. } else {
  5680. $info_list[$key]['enter'] = "";
  5681. }
  5682. if ($value['dbtime'] != 0) {
  5683. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5684. } else {
  5685. $info_list[$key]['dbtime'] = "";
  5686. }
  5687. if ($value['state'] == 0) {
  5688. $info_list[$key]['state'] = "在库";
  5689. } else if ($value['state'] == 1) {
  5690. $info_list[$key]['state'] = "出库";
  5691. } else if ($value['state'] == 2) {
  5692. $info_list[$key]['state'] = "退库";
  5693. } else if ($value['state'] == 3) {
  5694. $info_list[$key]['state'] = "调拨中";
  5695. } else if ($value['state'] == 4) {
  5696. $info_list[$key]['state'] = "再加工";
  5697. } else if ($value['state'] == 5) {
  5698. $info_list[$key]['state'] = "维修中";
  5699. } else if ($value['state'] == 6) {
  5700. $info_list[$key]['state'] = "盘亏";
  5701. } else if ($value['state'] == 7) {
  5702. $info_list[$key]['state'] = "更换标签";
  5703. } else if ($value['state'] == 8) {
  5704. $info_list[$key]['state'] = "其它";
  5705. } else if ($value['state'] == 9) {
  5706. $info_list[$key]['state'] = "预设";
  5707. }
  5708. }
  5709. $total = $this->whlabel->find_count($where);
  5710. $pagenum = ceil($total / $perpage);
  5711. $over = $total - ($start + $perpage);
  5712. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5713. echo json_encode($rows);
  5714. exit;
  5715. }
  5716. if (isset($post['outsku'])) {
  5717. $time = time();
  5718. $cz = $this->input->post('cz', true);
  5719. $label = $this->input->post('outsku', true);
  5720. $sl = $this->input->post('sl', true);
  5721. $num = $this->input->post('num', true);
  5722. //$warehouse = $this->input->post('warehouse',true);
  5723. if (!$sl) {
  5724. $sl = 1;
  5725. }
  5726. if (!$warehouse) {
  5727. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5728. exit;
  5729. }
  5730. $dblabel = $this->whlabellabel->get_label($label);
  5731. if ($dblabel) {
  5732. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5733. if (count($data) < 1) {
  5734. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5735. exit;
  5736. }
  5737. if (count($data) < $num) {
  5738. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5739. exit;
  5740. }
  5741. for ($i = 0; $i < $sl; $i++) {
  5742. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5743. }
  5744. echo json_encode(array('success' => true));
  5745. exit;
  5746. } else {
  5747. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5748. exit;
  5749. }
  5750. }
  5751. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5752. $this->_Template('whlabel_db', $this->data);
  5753. }
  5754. public function _dbrk()
  5755. {
  5756. $post = $this->input->post(NULL, TRUE);
  5757. if (isset($post['page'])) {
  5758. $page = $this->input->post('page', true);
  5759. $perpage = $this->input->post('perpage', true);
  5760. $sku = $this->input->post('sku', true);
  5761. $number = $this->input->post('number', true);
  5762. $warehouse = $this->input->post('warehouse', true);
  5763. $purchase = $this->input->post('purchase', true);
  5764. $orderinfo = $this->input->post('orderinfo', true);
  5765. $waybill = $this->input->post('waybill', true);
  5766. $category = $this->input->post('category', true);
  5767. $size = $this->input->post('size', true);
  5768. $grade = $this->input->post('grade', true);
  5769. $color = $this->input->post('color', true);
  5770. $lowe = $this->input->post('lowe', true);
  5771. $state = $this->input->post('state', true);
  5772. $label = $this->input->post('label', true);
  5773. $ctime = $this->input->post('ctime', true);
  5774. $timetk = $this->input->post('timetkk', true);
  5775. $timetj = $this->input->post('timetjj', true);
  5776. $timetk = strtotime($timetk);
  5777. $timetj = strtotime($timetj);
  5778. $where = "dbtime > 0";
  5779. if ($timetk && $timetj) {
  5780. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5781. }
  5782. if ($sku) {
  5783. $where .= " and sku = '$sku'";
  5784. }
  5785. if ($warehouse) {
  5786. $where .= " and warehouse = '$warehouse'";
  5787. }
  5788. if ($purchase) {
  5789. $where .= " and purchase = '$purchase'";
  5790. }
  5791. if ($category) {
  5792. $where .= " and features like '%-$category-%'";
  5793. }
  5794. if ($size) {
  5795. $where .= " and features like '%-$size-%'";
  5796. }
  5797. if ($grade) {
  5798. $where .= " and features like '%-$grade-%'";
  5799. }
  5800. if ($color) {
  5801. $where .= " and features like '%-$color-%'";
  5802. }
  5803. if ($lowe) {
  5804. $where .= " and features like '%-$lowe-%'";
  5805. }
  5806. if ($state != '') {
  5807. $where .= " and state = '$state'";
  5808. }
  5809. //数据排序
  5810. $order_str = "dbtime desc";
  5811. if (empty($page)) {
  5812. $start = 0;
  5813. $perpage = 1;
  5814. } else {
  5815. $start = ($page - 1) * $perpage;
  5816. }
  5817. //取得信息列表
  5818. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5819. foreach ($info_list as $key => $value) {
  5820. $warehouse = $this->warehouse->read($value['warehouse']);
  5821. $info_list[$key]['warehouse'] = $warehouse['title'];
  5822. $purchase = $this->purchase->read($value['purchase']);
  5823. $info_list[$key]['purchase'] = $purchase['title'];
  5824. if ($value['enter'] != 0) {
  5825. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5826. } else {
  5827. $info_list[$key]['enter'] = "";
  5828. }
  5829. if ($value['dbtime'] != 0) {
  5830. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5831. } else {
  5832. $info_list[$key]['dbtime'] = "";
  5833. }
  5834. if ($value['state'] == 0) {
  5835. $info_list[$key]['state'] = "在库";
  5836. } else if ($value['state'] == 1) {
  5837. $info_list[$key]['state'] = "出库";
  5838. } else if ($value['state'] == 2) {
  5839. $info_list[$key]['state'] = "退库";
  5840. } else if ($value['state'] == 3) {
  5841. $info_list[$key]['state'] = "调拨中";
  5842. } else if ($value['state'] == 4) {
  5843. $info_list[$key]['state'] = "再加工";
  5844. } else if ($value['state'] == 5) {
  5845. $info_list[$key]['state'] = "维修中";
  5846. } else if ($value['state'] == 6) {
  5847. $info_list[$key]['state'] = "盘亏";
  5848. } else if ($value['state'] == 7) {
  5849. $info_list[$key]['state'] = "更换标签";
  5850. } else if ($value['state'] == 8) {
  5851. $info_list[$key]['state'] = "其它";
  5852. } else if ($value['state'] == 9) {
  5853. $info_list[$key]['state'] = "预设";
  5854. }
  5855. }
  5856. $total = $this->whlabel->find_count($where);
  5857. $pagenum = ceil($total / $perpage);
  5858. $over = $total - ($start + $perpage);
  5859. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5860. echo json_encode($rows);
  5861. exit;
  5862. }
  5863. if (isset($post['rsku'])) {
  5864. $cz = $this->input->post('cz', true);
  5865. $label = $this->input->post('rsku', true);
  5866. $sl = $this->input->post('sl', true);
  5867. $warehouse = $this->input->post('warehouse', true);
  5868. if (!$sl) {
  5869. $sl = 1;
  5870. }
  5871. if (!$warehouse) {
  5872. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5873. exit;
  5874. }
  5875. $dblabel = $this->whlabellabel->get_label($label);
  5876. if ($dblabel) {
  5877. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5878. if (count($data) < 1) {
  5879. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5880. exit;
  5881. }
  5882. if ($sl > count($data)) {
  5883. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5884. exit;
  5885. }
  5886. $time = time();
  5887. for ($i = 0; $i < $sl; $i++) {
  5888. $this->whlabel->save(array('state' => 0, 'dbwarehouse' => $data[$i]['warehouse'], 'warehouse' => $warehouse, 'enter' => $time, 'time' => $time, 'dbcontent' => $data[$i]['dbcontent'] . $warehouse . '-' . $time . '|',), $data[$i]['id']);
  5889. }
  5890. echo json_encode(array('success' => true));
  5891. exit;
  5892. } else {
  5893. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5894. exit;
  5895. }
  5896. }
  5897. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5898. $this->_Template('whlabel_dbrk', $this->data);
  5899. }
  5900. public function _whlabelczdc()
  5901. {
  5902. if (isset($_GET['excel'])) {
  5903. //数据排序
  5904. $order_str = "id desc";
  5905. if (empty($page)) {
  5906. $start = 0;
  5907. $perpage = 1;
  5908. } else {
  5909. $start = ($page - 1) * $perpage;
  5910. }
  5911. $state = $this->input->get('state', true);
  5912. $sku = $this->input->get('sku', true);
  5913. $ctime = $this->input->get('ctime', true);
  5914. $category = $this->input->get('category', true);
  5915. $size = $this->input->get('size', true);
  5916. $grade = $this->input->get('grade', true);
  5917. $color = $this->input->get('color', true);
  5918. $lowe = $this->input->get('lowe', true);
  5919. $timetk = $this->input->get('timetkk', true);
  5920. $timetj = $this->input->get('timetjj', true);
  5921. $timetk = strtotime($timetk);
  5922. $timetj = strtotime($timetj);
  5923. $where = "dbtime > 0";
  5924. if ($timetk && $timetj) {
  5925. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5926. }
  5927. if ($category) {
  5928. $where .= " and features like '%-$category-%'";
  5929. }
  5930. if ($size) {
  5931. $where .= " and features like '%-$size-%'";
  5932. }
  5933. if ($grade) {
  5934. $where .= " and features like '%-$grade-%'";
  5935. }
  5936. if ($color) {
  5937. $where .= " and features like '%-$color-%'";
  5938. }
  5939. if ($lowe) {
  5940. $where .= " and features like '%-$lowe-%'";
  5941. }
  5942. //取得信息列表
  5943. $info_list = $this->whlabel->find_all($where, '*');
  5944. $rows = array();
  5945. $list = array();
  5946. foreach ($info_list as $key => $value) {
  5947. $rows[$value['sku']] = $value; //所有数据sku
  5948. }
  5949. foreach ($rows as $value) {
  5950. $warehouse = $this->warehouse->read($value['warehouse']);
  5951. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5952. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5953. if ($value['orderinfo'] == 0) {
  5954. $info_list[$key]['orderinfo'] = "";
  5955. }
  5956. if ($value['waybill'] == 0) {
  5957. $info_list[$key]['waybill'] = "";
  5958. }
  5959. if ($value['state'] == 0) {
  5960. $value['state'] = "在库";
  5961. } else if ($value['state'] == 3) {
  5962. $value['state'] = "调拨中";
  5963. }
  5964. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5965. }
  5966. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5967. $titlename = "<table border=1>
  5968. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5969. <tr align='center'>
  5970. <td>SKU</td>
  5971. <td>产品</td>
  5972. <td>调拨数量</td>
  5973. <td>入库数量</td>
  5974. </tr>
  5975. </table>";
  5976. $filename = $title . ".xls";
  5977. $tail = "";
  5978. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5979. }
  5980. }
  5981. public function _print($arg_array)
  5982. {
  5983. if (isset($_SESSION['api'])) {
  5984. $user = $this->user->get_api($_SESSION['api']);
  5985. $usp = $user;
  5986. $fgshop = "";
  5987. $sid = "";
  5988. $wid = "";
  5989. $wtype = "";
  5990. $usersp = explode('|', trim($user['shop'], '|'));
  5991. $userwh = explode('|', trim($user['warehouse'], '|'));
  5992. foreach ($usersp as $value) {
  5993. $fgshop .= " shop = " . $value . " or";
  5994. $sid .= " id = " . $value . " or";
  5995. }
  5996. foreach ($userwh as $value) {
  5997. $wid .= " id = " . $value . " or";
  5998. $wtype .= " type = " . $value . " or";
  5999. }
  6000. }
  6001. $post = $this->input->post(NULL, TRUE);
  6002. if (isset($post['tmsku'])) {
  6003. $tmsku = $this->input->post('tmsku', true);
  6004. if (is_numeric($tmsku)) {
  6005. $yyh = $this->whlabellabel->get_label($tmsku);
  6006. } else {
  6007. $yyh = $this->whlabellabel->get_sku($tmsku);
  6008. if(empty($yyh)){
  6009. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6010. if($r['code'] == -1 ){
  6011. echo json_encode(array('success' => false));
  6012. exit;
  6013. }else{
  6014. echo json_encode(array('features' => $r['data'], 'success' => true));
  6015. exit;
  6016. }
  6017. }
  6018. }
  6019. if ($yyh) {
  6020. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6021. exit;
  6022. } else {
  6023. echo json_encode(array('success' => false));
  6024. exit;
  6025. }
  6026. }
  6027. $classid = $this->classid->sku();
  6028. $pm = $classid;
  6029. $scsku = $classid;
  6030. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6031. if (isset($post['warehouse'])) {
  6032. if ($post['warehouse']) {
  6033. $list = array();
  6034. $num = "";
  6035. $title = "";
  6036. $features = "";
  6037. $order = 0;
  6038. $post['shop'] = '';
  6039. $brand = $this->input->post('brand', true);
  6040. if ($brand != '0,') {
  6041. $b = $this->brand->read(rtrim($brand, ','));
  6042. if ($b) {
  6043. $post['shop'] = str_replace('|', ',', $b['shop']);
  6044. }
  6045. }
  6046. $post['details'] = $this->input->post('details', true); //打印数量
  6047. $xbqnum = $this->input->post('xbqnum', true);
  6048. $post['purchase'] = $this->input->post('purchase', true);
  6049. $post['warehouse'] = $this->input->post('warehouse', true);
  6050. $post['purchase'] = $this->input->post('purchase', true);
  6051. $post['retreatwarehouse'] = $post['warehouse'];
  6052. $post['cpbz'] = $this->input->post('cpbz', true);
  6053. $post['state'] = 9;
  6054. $category = $this->input->post('category', true);
  6055. $list['category'] = $category;
  6056. $list['hairtype'] = $this->input->post('hairtype', true);
  6057. $list['grade'] = $this->input->post('grade', true);
  6058. $size = $this->input->post('size', true);
  6059. $list['size'] = rtrim($size, ',');
  6060. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6061. $list['extension'] = $this->input->post('extension', true);
  6062. if ($category == 1297) {
  6063. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6064. }
  6065. if ($category == 1702) {
  6066. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6067. $list['syother'] = $this->input->post('syother', true);
  6068. }
  6069. if ($category == 133) {
  6070. $list['fittype'] = $this->input->post('fittype', true);
  6071. $list['acother'] = $this->input->post('acother', true);
  6072. }
  6073. $list['color'] = $this->input->post('color', true);
  6074. $list['lowe'] = $this->input->post('lowe', true);
  6075. if ($category == 127) {
  6076. $list['type'] = $this->input->post('type', true);
  6077. $list['headroad'] = $this->input->post('headroad', true);
  6078. $list['density'] = $this->input->post('density', true);
  6079. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6080. $list['lacesize'] = $this->input->post('lacesize', true);
  6081. }
  6082. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6083. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6084. }
  6085. if ($category == 128) {
  6086. $list['lacetype'] = $this->input->post('lacetype', true);
  6087. $list['haircap'] = $this->input->post('haircap', true);
  6088. $list['density'] = $this->input->post('density', true);
  6089. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6090. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6091. $list['wigother'] = $this->input->post('wigother', true);
  6092. $list['wigother1'] = $this->input->post('wigother1', true);
  6093. $list['wigother2'] = $this->input->post('wigother2', true);
  6094. $list['product_related'] = $this->input->post('product_related', true);
  6095. }
  6096. if ($category == 129) {
  6097. $list['wide'] = $this->input->post('wide', true);
  6098. }
  6099. if ($category == 131) {
  6100. $list['gifttype'] = $this->input->post('gifttype', true);
  6101. $list['giftother'] = $this->input->post('giftother', true);
  6102. }
  6103. if ($category == 134) {
  6104. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6105. }
  6106. if ($category == 1297) {
  6107. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6108. $list['sywigother'] = $this->input->post('sywigother', true);
  6109. }
  6110. if ($category == 130 || $category == 133 || $category == 1702) {
  6111. $list['items'] = $this->input->post('items', true);
  6112. $list['weight'] = $this->input->post('weight', true);
  6113. }
  6114. if ($category == 1702) {
  6115. $list['syhairther'] = $this->input->post('syhairther', true);
  6116. }
  6117. if($category == 130){
  6118. $list['jfother'] = $this->input->post('jfother', true);
  6119. }
  6120. foreach ($list as $k => $v) {
  6121. if ($v != 0) {
  6122. $num .= $v;
  6123. $features .= $v . '-';
  6124. $post[$k] = $v;
  6125. $typeclass = $this->typeclass->read($v);
  6126. if (isset($pm[$typeclass['classid']])) {
  6127. if (stripos($typeclass['zh'], '|') !== false) {
  6128. $exzh = explode('|', $typeclass['zh']);
  6129. $pm[$typeclass['classid']] = $exzh[0];
  6130. } else {
  6131. $pm[$typeclass['classid']] = $typeclass['zh'];
  6132. }
  6133. }
  6134. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6135. if ($k != 'size') {
  6136. $title .= $typeclass['title'] . " ";
  6137. }
  6138. }
  6139. }
  6140. $typeclass = $this->typeclass->read($list['size']);
  6141. $title .= $typeclass['title'];
  6142. $time = time();
  6143. $post['title'] = rtrim($title, ' ');
  6144. $post['number'] = $num;
  6145. $post['features'] = '-' . $features;
  6146. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6147. $featurespp = explode('-', trim($featurespp, '-'));
  6148. if (isset($featurespp[5])) {
  6149. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6150. } else {
  6151. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6152. }
  6153. $post['enter'] = $time;
  6154. $post['time'] = $time; //操作时间
  6155. $scsku = implode("-", $scsku);
  6156. $zh = implode(" ", $pm);
  6157. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6158. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6159. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6160. $post['sku'] = $bqsku;
  6161. $label = time() . rand(0, 9);
  6162. $post['label'] = $label;
  6163. $cpid = $this->whlabellabel->find_count();
  6164. $post['cpid'] = $cpid + 1;
  6165. $cpid = $post['cpid'];
  6166. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6167. //if($whlabelbarcode)
  6168. //{
  6169. //$post['label'] = $whlabelbarcode['label'];
  6170. //if(!$this->whlabellabel->insert($post))
  6171. //{
  6172. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6173. //}
  6174. //}
  6175. //else
  6176. //{
  6177. $this->db->trans_begin();
  6178. $this->whlabellabel->insert($post);
  6179. //$this->whlabelbarcode->insert($post);
  6180. if ($this->db->trans_status() === TRUE) {
  6181. $this->db->trans_commit();
  6182. } else {
  6183. $this->db->trans_rollback();
  6184. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6185. exit;
  6186. }
  6187. //}
  6188. $warehouse_name = "";
  6189. $warehouse = $post['warehouse'];
  6190. if($warehouse == 12){
  6191. $warehouse_name = "特殊库存库";
  6192. }
  6193. // if($warehouse == 13){
  6194. // $warehouse_name = "许昌仓";
  6195. // }
  6196. // if($warehouse == 5){
  6197. // $warehouse_name = "美国店";
  6198. // }
  6199. // if($warehouse == 16){
  6200. // $warehouse_name = "定制头套仓";
  6201. // }
  6202. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6203. if(!empty($warehouse_name)){
  6204. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6205. }
  6206. $purchase = $this->purchase->read($post['purchase']);
  6207. echo json_encode(array('title' => $title, 'num' => $post['label'], 'bqsku' => $bqsku, 'xbqnum' => $xbqnum, 'zh' => str_replace('自然色 ', '', rtrim($zh, ' ')), 'details' => $details, 'purchase' => $purchase['title'], 'cpbz' => $post['cpbz'], 'usa' => 0, 'success' => true));
  6208. exit; //特殊仓目前不需要仓库选项
  6209. }
  6210. }
  6211. if (isset($_SESSION['api'])) {
  6212. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6213. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6214. $this->data['wlshop'] = $wlshop;
  6215. $this->data['warehouse'] = $warehouse;
  6216. }
  6217. $whlabelwz = $this->whlabelwz->find_all();
  6218. $this->data['whlabelwz'] = $whlabelwz;
  6219. $this->_Template('whlabel_print', $this->data);
  6220. }
  6221. public function _usaprint($arg_array)
  6222. {
  6223. if (isset($_SESSION['api'])) {
  6224. $user = $this->user->get_api($_SESSION['api']);
  6225. $usp = $user;
  6226. $fgshop = "";
  6227. $sid = "";
  6228. $wid = "";
  6229. $wtype = "";
  6230. $usersp = explode('|', trim($user['shop'], '|'));
  6231. $userwh = explode('|', trim($user['warehouse'], '|'));
  6232. foreach ($usersp as $value) {
  6233. $fgshop .= " shop = " . $value . " or";
  6234. $sid .= " id = " . $value . " or";
  6235. }
  6236. foreach ($userwh as $value) {
  6237. $wid .= " id = " . $value . " or";
  6238. $wtype .= " type = " . $value . " or";
  6239. }
  6240. }
  6241. $post = $this->input->post(NULL, TRUE);
  6242. if (isset($post['tmsku'])) {
  6243. $tmsku = $this->input->post('tmsku', true);
  6244. if (is_numeric($tmsku)) {
  6245. $yyh = $this->whlabellabel->get_label($tmsku);
  6246. } else {
  6247. $yyh = $this->whlabellabel->get_sku($tmsku);
  6248. }
  6249. if ($yyh) {
  6250. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6251. exit;
  6252. } else {
  6253. echo json_encode(array('success' => false));
  6254. exit;
  6255. }
  6256. }
  6257. $classid = $this->classid->sku();
  6258. $pm = $classid;
  6259. $scsku = $classid;
  6260. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6261. if (isset($post['warehouse'])) {
  6262. if ($post['warehouse']) {
  6263. $list = array();
  6264. $num = "";
  6265. $title = "";
  6266. $features = "";
  6267. $order = 0;
  6268. $post['shop'] = '';
  6269. $brand = $this->input->post('brand', true);
  6270. if ($brand != '0,') {
  6271. $b = $this->brand->read(rtrim($brand, ','));
  6272. if ($b) {
  6273. $post['shop'] = str_replace('|', ',', $b['shop']);
  6274. }
  6275. }
  6276. $post['details'] = $this->input->post('details', true); //打印数量
  6277. $xbqnum = $this->input->post('xbqnum', true);
  6278. $post['purchase'] = $this->input->post('purchase', true);
  6279. $post['warehouse'] = $this->input->post('warehouse', true);
  6280. $post['purchase'] = $this->input->post('purchase', true);
  6281. $post['retreatwarehouse'] = $post['warehouse'];
  6282. $post['cpbz'] = $this->input->post('cpbz', true);
  6283. $post['state'] = 9;
  6284. $category = $this->input->post('category', true);
  6285. $list['category'] = $category;
  6286. $list['hairtype'] = $this->input->post('hairtype', true);
  6287. $list['grade'] = $this->input->post('grade', true);
  6288. $size = $this->input->post('size', true);
  6289. $list['size'] = rtrim($size, ',');
  6290. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6291. $list['extension'] = $this->input->post('extension', true);
  6292. if ($category == 1297) {
  6293. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6294. }
  6295. if ($category == 1702) {
  6296. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6297. $list['syother'] = $this->input->post('syother', true);
  6298. }
  6299. if ($category == 133) {
  6300. $list['fittype'] = $this->input->post('fittype', true);
  6301. $list['acother'] = $this->input->post('acother', true);
  6302. }
  6303. $list['color'] = $this->input->post('color', true);
  6304. $list['lowe'] = $this->input->post('lowe', true);
  6305. if ($category == 127) {
  6306. $list['type'] = $this->input->post('type', true);
  6307. $list['headroad'] = $this->input->post('headroad', true);
  6308. $list['density'] = $this->input->post('density', true);
  6309. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6310. $list['lacesize'] = $this->input->post('lacesize', true);
  6311. }
  6312. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6313. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6314. }
  6315. if ($category == 128) {
  6316. $list['lacetype'] = $this->input->post('lacetype', true);
  6317. $list['haircap'] = $this->input->post('haircap', true);
  6318. $list['density'] = $this->input->post('density', true);
  6319. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6320. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6321. $list['wigother'] = $this->input->post('wigother', true);
  6322. $list['wigother1'] = $this->input->post('wigother1', true);
  6323. $list['wigother2'] = $this->input->post('wigother2', true);
  6324. $list['product_related'] = $this->input->post('product_related', true);
  6325. }
  6326. if ($category == 129) {
  6327. $list['wide'] = $this->input->post('wide', true);
  6328. }
  6329. if ($category == 131) {
  6330. $list['gifttype'] = $this->input->post('gifttype', true);
  6331. $list['giftother'] = $this->input->post('giftother', true);
  6332. }
  6333. if ($category == 134) {
  6334. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6335. }
  6336. if ($category == 1297) {
  6337. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6338. $list['sywigother'] = $this->input->post('sywigother', true);
  6339. }
  6340. if ($category == 130 || $category == 133 || $category == 1702) {
  6341. $list['items'] = $this->input->post('items', true);
  6342. $list['weight'] = $this->input->post('weight', true);
  6343. }
  6344. if ($category == 1702) {
  6345. $list['syhairther'] = $this->input->post('syhairther', true);
  6346. }
  6347. foreach ($list as $k => $v) {
  6348. if ($v != 0) {
  6349. $num .= $v;
  6350. $features .= $v . '-';
  6351. $post[$k] = $v;
  6352. $typeclass = $this->typeclass->read($v);
  6353. if (isset($pm[$typeclass['classid']])) {
  6354. if (stripos($typeclass['zh'], '|') !== false) {
  6355. $exzh = explode('|', $typeclass['zh']);
  6356. $pm[$typeclass['classid']] = $exzh[0];
  6357. } else {
  6358. $pm[$typeclass['classid']] = $typeclass['zh'];
  6359. }
  6360. }
  6361. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6362. if ($k != 'size') {
  6363. $title .= $typeclass['title'] . " ";
  6364. }
  6365. }
  6366. }
  6367. $typeclass = $this->typeclass->read($list['size']);
  6368. $title .= $typeclass['title'];
  6369. $time = time();
  6370. $post['title'] = rtrim($title, ' ');
  6371. $post['number'] = $num;
  6372. $post['features'] = '-' . $features;
  6373. $fp = $this->whlabel->get_features($post['features']);
  6374. if (!$fp) {
  6375. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6376. exit;
  6377. }
  6378. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6379. $featurespp = explode('-', trim($featurespp, '-'));
  6380. if (isset($featurespp[5])) {
  6381. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6382. } else {
  6383. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6384. }
  6385. $post['enter'] = $time;
  6386. $post['time'] = $time; //操作时间
  6387. $scsku = implode("-", $scsku);
  6388. $zh = implode(" ", $pm);
  6389. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6390. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6391. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6392. $post['sku'] = $fp['sku'];
  6393. $post['label'] = $fp['sku'];
  6394. $cpid = $this->whlabellabel->find_count();
  6395. $post['cpid'] = $cpid + 1;
  6396. $cpid = $post['cpid'];
  6397. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6398. //if($whlabelbarcode)
  6399. //{
  6400. //$post['label'] = $whlabelbarcode['label'];
  6401. //if(!$this->whlabellabel->insert($post))
  6402. //{
  6403. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6404. //}
  6405. //}
  6406. //else
  6407. //{
  6408. $this->db->trans_begin();
  6409. $this->whlabellabel->insert($post);
  6410. //$this->whlabelbarcode->insert($post);
  6411. if ($this->db->trans_status() === TRUE) {
  6412. $this->db->trans_commit();
  6413. } else {
  6414. $this->db->trans_rollback();
  6415. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6416. exit;
  6417. }
  6418. //}
  6419. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6420. $purchase = $this->purchase->read($post['purchase']);
  6421. echo json_encode(array('title' => $title, 'num' => $post['label'], 'bqsku' => $bqsku, 'xbqnum' => $xbqnum, 'zh' => str_replace('自然色 ', '', rtrim($zh, ' ')), 'details' => $details, 'purchase' => $purchase['title'], 'cpbz' => $post['cpbz'], 'usa' => 1, 'success' => true));
  6422. exit; //特殊仓目前不需要仓库选项
  6423. }
  6424. }
  6425. if (isset($_SESSION['api'])) {
  6426. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6427. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6428. $this->data['wlshop'] = $wlshop;
  6429. $this->data['warehouse'] = $warehouse;
  6430. }
  6431. $whlabelwz = $this->whlabelwz->find_all();
  6432. $this->data['whlabelwz'] = $whlabelwz;
  6433. $this->_Template('whlabel_usaprint', $this->data);
  6434. }
  6435. public function _printrk($arg_array)
  6436. {
  6437. $prc = array();
  6438. $purchase = $this->purchase->find_all();
  6439. foreach ($purchase as $k => $v) {
  6440. $prc[$v['id']] = $v['title'];
  6441. }
  6442. $post = $this->input->post(NULL, TRUE);
  6443. if (isset($post['page'])) {
  6444. $page = $this->input->post('page', true);
  6445. $perpage = $this->input->post('perpage', true);
  6446. $sku = $this->input->post('sku', true);
  6447. $bs = $this->input->post('bs', true);
  6448. $number = $this->input->post('number', true);
  6449. $warehouse = $this->input->post('warehouse', true);
  6450. $purchase = $this->input->post('purchase', true);
  6451. $orderinfo = $this->input->post('orderinfo', true);
  6452. $waybill = $this->input->post('waybill', true);
  6453. $category = $this->input->post('category', true);
  6454. $size = $this->input->post('size', true);
  6455. $grade = $this->input->post('grade', true);
  6456. $color = $this->input->post('color', true);
  6457. $lowe = $this->input->post('lowe', true);
  6458. $state = $this->input->post('state', true);
  6459. $label = $this->input->post('label', true);
  6460. $timetk = $this->input->post('ktime', true);
  6461. $timetj = $this->input->post('jtime', true);
  6462. $timetk = strtotime($timetk);
  6463. $timetj = strtotime($timetj);
  6464. $where = "1=1 ";
  6465. if ($timetk && $timetj) {
  6466. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6467. }
  6468. if ($sku) {
  6469. $where .= " and sku = '$sku'";
  6470. }
  6471. if ($bs != '') {
  6472. $where .= " and bs = '$bs'";
  6473. }
  6474. if ($number) {
  6475. $where .= " and number = '$number'";
  6476. }
  6477. if ($warehouse) {
  6478. $where .= " and warehouse = '$warehouse'";
  6479. }
  6480. if ($purchase) {
  6481. $where .= " and purchase = '$purchase'";
  6482. }
  6483. if ($orderinfo) {
  6484. $where .= " and orderinfo = '$orderinfo'";
  6485. }
  6486. if ($waybill) {
  6487. $where .= " and waybill = '$waybill'";
  6488. }
  6489. if ($category) {
  6490. $where .= " and features like '%-$category-%'";
  6491. }
  6492. if ($size) {
  6493. $where .= " and features like '%-$size-%'";
  6494. }
  6495. if ($grade) {
  6496. $where .= " and features like '%-$grade-%'";
  6497. }
  6498. if ($color) {
  6499. $where .= " and features like '%-$color-%'";
  6500. }
  6501. if ($lowe) {
  6502. $where .= " and features like '%-$lowe-%'";
  6503. }
  6504. if ($label) {
  6505. $where .= " and label = '$label'";
  6506. }
  6507. if ($state || $state == 0) {
  6508. $where .= " and state = '$state'";
  6509. }
  6510. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6511. //数据排序
  6512. $order_str = "enter desc";
  6513. if (empty($page)) {
  6514. $start = 0;
  6515. $perpage = 1;
  6516. } else {
  6517. $start = ($page - 1) * $perpage;
  6518. }
  6519. //取得信息列表
  6520. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6521. foreach ($info_list as $key => $value) {
  6522. $warehouse = $this->warehouse->read($value['warehouse']);
  6523. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6524. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6525. if ($value['state'] == 0) {
  6526. $info_list[$key]['state'] = "在库";
  6527. } else if ($value['state'] == 1) {
  6528. $info_list[$key]['state'] = "出库";
  6529. } else if ($value['state'] == 2) {
  6530. $info_list[$key]['state'] = "退库";
  6531. } else if ($value['state'] == 3) {
  6532. $info_list[$key]['state'] = "调拨中";
  6533. } else if ($value['state'] == 4) {
  6534. $info_list[$key]['state'] = "再加工";
  6535. } else if ($value['state'] == 5) {
  6536. $info_list[$key]['state'] = "维修中";
  6537. } else if ($value['state'] == 6) {
  6538. $info_list[$key]['state'] = "盘亏";
  6539. } else if ($value['state'] == 7) {
  6540. $info_list[$key]['state'] = "更换标签";
  6541. } else if ($value['state'] == 8) {
  6542. $info_list[$key]['state'] = "其它";
  6543. } else if ($value['state'] == 9) {
  6544. $info_list[$key]['state'] = "预设";
  6545. } else if ($value['state'] == 10) {
  6546. $info_list[$key]['state'] = "美店零售";
  6547. }
  6548. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6549. }
  6550. $total = $this->$ck->find_count($where);
  6551. $pagenum = ceil($total / $perpage);
  6552. $over = $total - ($start + $perpage);
  6553. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6554. echo json_encode($rows);
  6555. exit;
  6556. }
  6557. if (isset($post['tmsku'])) {
  6558. $time = time();
  6559. $tmsku = $this->input->post('tmsku', true);
  6560. //$post['shop'] = $this->input->post('shop',true);
  6561. $num = $this->input->post('num', true);
  6562. $rktype = $this->input->post('rktype', true);
  6563. if ($num > 200) {
  6564. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6565. exit;
  6566. }
  6567. if (!$rktype) {
  6568. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6569. }
  6570. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6571. /**
  6572. $wz = array();
  6573. foreach ($rk as $key=>$value)
  6574. {
  6575. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6576. }
  6577. if(count($wz) > 1)
  6578. {
  6579. $wz = array_values($wz);
  6580. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6581. }
  6582. **/
  6583. if (isset($rk[0]['purchase'])) {
  6584. $rk = $rk[0];
  6585. $j = 0;
  6586. $post['purchase'] = $rk['purchase'];
  6587. $post['warehouse'] = $rk['warehouse'];
  6588. $post['retreatwarehouse'] = $rk['warehouse'];
  6589. $post['sku'] = $rk['sku'];
  6590. $post['number'] = $rk['number'];
  6591. $post['features'] = $rk['features'];
  6592. $post['title'] = $rk['title'];
  6593. $post['enter'] = $time;
  6594. $post['time'] = $time;
  6595. $post['bs'] = 1;
  6596. $post['shop'] = $rk['shop'];
  6597. $post['details'] = $rk['details'];
  6598. $post['cpid'] = $rk['cpid'];
  6599. $post['cpbz'] = $rk['cpbz'];
  6600. $post['rktype'] = $rktype;
  6601. $warehouse = $this->warehouse->read($rk['warehouse']);
  6602. if ($warehouse['bdck'] == '') {
  6603. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6604. exit;
  6605. } else {
  6606. $bdck = $warehouse['bdck'];
  6607. }
  6608. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6609. if (isset($pdwz['details'])) {
  6610. if ($pdwz['details'] != $post['details']) {
  6611. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6612. }else{
  6613. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6614. exit;
  6615. }
  6616. }
  6617. }
  6618. $post['featurespp'] = $rk['featurespp'];
  6619. if ($post['warehouse'] == '5') {
  6620. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6621. if ($yza) {
  6622. if ($post['features'] != $yza[0]['features']) {
  6623. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6624. exit;
  6625. }
  6626. }
  6627. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6628. if ($yzb) {
  6629. if ($post['sku'] != $yzb[0]['sku']) {
  6630. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6631. exit;
  6632. }
  6633. }
  6634. }
  6635. for ($i = 0; $i < $num; $i++) {
  6636. $post['label'] = time() . rand(100, 999) . $i;
  6637. if ($this->$bdck->insert($post)) {
  6638. $j++;
  6639. }
  6640. }
  6641. /**
  6642. if($post['warehouse'] != 12)
  6643. {
  6644. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6645. }
  6646. **/
  6647. $this->whlabelscanlog->insert([
  6648. 'shop'=>$rk['shop'],
  6649. 'type'=>1,
  6650. 'purchase'=>$rk['purchase'],
  6651. 'sku'=>$rk['sku'],
  6652. 'features'=>$rk['features'],
  6653. 'title'=>$rk['title'],
  6654. 'label'=>$rk['label'],
  6655. 'warehouse'=>$rk['warehouse'],
  6656. 'wlid'=>$rk['id'],
  6657. 'num'=>$num,
  6658. 'addtime'=>time()
  6659. ]);
  6660. if ($j == $num) {
  6661. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6662. exit;
  6663. } else {
  6664. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6665. exit;
  6666. }
  6667. } else {
  6668. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6669. exit;
  6670. }
  6671. }
  6672. $this->_Template('whlabel_printrk', $this->data);
  6673. }
  6674. public function _printxzrk($arg_array)
  6675. {
  6676. $post = $this->input->post(NULL, TRUE);
  6677. if (isset($post['wzid'])) {
  6678. $time = time();
  6679. $id = $this->input->post('wzid', true);
  6680. //$post['shop'] = $this->input->post('shop',true);
  6681. $num = 1;
  6682. $rk = $this->whlabellabel->read($id);
  6683. if (isset($rk['purchase'])) {
  6684. $x = 0;
  6685. $post['purchase'] = $rk['purchase'];
  6686. $post['warehouse'] = $rk['warehouse'];
  6687. $post['retreatwarehouse'] = $rk['warehouse'];
  6688. $post['sku'] = $rk['sku'];
  6689. $post['number'] = $rk['number'];
  6690. $post['features'] = $rk['features'];
  6691. $post['title'] = $rk['title'];
  6692. $post['enter'] = $time;
  6693. $post['time'] = $time;
  6694. $post['bs'] = 1;
  6695. $post['shop'] = $rk['shop'];
  6696. $post['details'] = $rk['details'];
  6697. $post['cpid'] = $rk['cpid'];
  6698. $post['cpbz'] = $rk['cpbz'];
  6699. $warehouse = $this->warehouse->read($rk['warehouse']);
  6700. if ($warehouse['bdck'] == '') {
  6701. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6702. exit;
  6703. } else {
  6704. $bdck = $warehouse['bdck'];
  6705. }
  6706. $post['featurespp'] = $rk['featurespp'];
  6707. $this->db->trans_begin();
  6708. for ($i = 0; $i < $num; $i++) {
  6709. $post['label'] = time() . rand(100, 999) . $i;
  6710. $this->$bdck->insert($post);
  6711. }
  6712. /**
  6713. if($post['warehouse'] != 12)
  6714. {
  6715. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6716. }
  6717. **/
  6718. if ($this->db->trans_status() === TRUE) {
  6719. $this->db->trans_commit();
  6720. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6721. exit;
  6722. } else {
  6723. $this->db->trans_rollback();
  6724. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6725. exit;
  6726. }
  6727. } else {
  6728. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6729. exit;
  6730. }
  6731. }
  6732. }
  6733. public function _printck($arg_array)
  6734. {
  6735. $prc = array();
  6736. $purchase = $this->purchase->find_all();
  6737. foreach ($purchase as $k => $v) {
  6738. $prc[$v['id']] = $v['title'];
  6739. }
  6740. $post = $this->input->post(NULL, TRUE);
  6741. if (isset($post['page'])) {
  6742. $page = $this->input->post('page', true);
  6743. $perpage = $this->input->post('perpage', true);
  6744. $sku = $this->input->post('sku', true);
  6745. $bs = $this->input->post('bs', true);
  6746. $number = $this->input->post('number', true);
  6747. $warehouse = $this->input->post('warehouse', true);
  6748. $purchase = $this->input->post('purchase', true);
  6749. $orderinfo = $this->input->post('orderinfo', true);
  6750. $waybill = $this->input->post('waybill', true);
  6751. $category = $this->input->post('category', true);
  6752. $size = $this->input->post('size', true);
  6753. $grade = $this->input->post('grade', true);
  6754. $color = $this->input->post('color', true);
  6755. $lowe = $this->input->post('lowe', true);
  6756. $state = $this->input->post('state', true);
  6757. $label = $this->input->post('label', true);
  6758. $timetk = $this->input->post('ktime', true);
  6759. $timetj = $this->input->post('jtime', true);
  6760. $timetk = strtotime($timetk);
  6761. $timetj = strtotime($timetj);
  6762. $where = "state=1 ";
  6763. if ($timetk && $timetj) {
  6764. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6765. }
  6766. if ($sku) {
  6767. $where .= " and sku = '$sku'";
  6768. }
  6769. if ($bs != '') {
  6770. $where .= " and bs = '$bs'";
  6771. }
  6772. if ($number) {
  6773. $where .= " and number = '$number'";
  6774. }
  6775. if ($warehouse) {
  6776. $where .= " and warehouse = '$warehouse'";
  6777. }
  6778. if ($purchase) {
  6779. $where .= " and purchase = '$purchase'";
  6780. }
  6781. if ($orderinfo) {
  6782. $where .= " and orderinfo = '$orderinfo'";
  6783. }
  6784. if ($waybill) {
  6785. $where .= " and waybill = '$waybill'";
  6786. }
  6787. if ($category) {
  6788. $where .= " and features like '%-$category-%'";
  6789. }
  6790. if ($size) {
  6791. $where .= " and features like '%-$size-%'";
  6792. }
  6793. if ($grade) {
  6794. $where .= " and features like '%-$grade-%'";
  6795. }
  6796. if ($color) {
  6797. $where .= " and features like '%-$color-%'";
  6798. }
  6799. if ($lowe) {
  6800. $where .= " and features like '%-$lowe-%'";
  6801. }
  6802. if ($label) {
  6803. $where .= " and label = '$label'";
  6804. }
  6805. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6806. //数据排序
  6807. $order_str = "outk desc";
  6808. if (empty($page)) {
  6809. $start = 0;
  6810. $perpage = 1;
  6811. } else {
  6812. $start = ($page - 1) * $perpage;
  6813. }
  6814. //取得信息列表
  6815. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6816. foreach ($info_list as $key => $value) {
  6817. $warehouse = $this->warehouse->read($value['warehouse']);
  6818. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6819. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6820. if ($value['state'] == 0) {
  6821. $info_list[$key]['state'] = "在库";
  6822. } else if ($value['state'] == 1) {
  6823. $info_list[$key]['state'] = "出库";
  6824. } else if ($value['state'] == 2) {
  6825. $info_list[$key]['state'] = "退库";
  6826. } else if ($value['state'] == 3) {
  6827. $info_list[$key]['state'] = "调拨中";
  6828. } else if ($value['state'] == 4) {
  6829. $info_list[$key]['state'] = "再加工";
  6830. } else if ($value['state'] == 5) {
  6831. $info_list[$key]['state'] = "维修中";
  6832. } else if ($value['state'] == 6) {
  6833. $info_list[$key]['state'] = "盘亏";
  6834. } else if ($value['state'] == 7) {
  6835. $info_list[$key]['state'] = "更换标签";
  6836. } else if ($value['state'] == 8) {
  6837. $info_list[$key]['state'] = "其它";
  6838. } else if ($value['state'] == 9) {
  6839. $info_list[$key]['state'] = "预设";
  6840. } else if ($value['state'] == 10) {
  6841. $info_list[$key]['state'] = "美店零售";
  6842. }
  6843. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6844. }
  6845. $total = $this->$ck->find_count($where);
  6846. $pagenum = ceil($total / $perpage);
  6847. $over = $total - ($start + $perpage);
  6848. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6849. echo json_encode($rows);
  6850. exit;
  6851. }
  6852. if (isset($post['tmsku'])) {
  6853. $time = time();
  6854. $tmsku = $this->input->post('tmsku', true);
  6855. //$post['shop'] = $this->input->post('shop',true);
  6856. $num = $this->input->post('num', true);
  6857. $cktype = $this->input->post('cktype', true);
  6858. $label = $this->whlabellabel->get_label($tmsku);
  6859. if (!$cktype) {
  6860. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6861. }
  6862. if (!isset($label['warehouse'])) {
  6863. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6864. exit;
  6865. }
  6866. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6867. $extra_where = "";
  6868. if(!empty($label['details'])){
  6869. $extra_where .= " and details = '" . $label['details'] . "'";
  6870. }
  6871. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6872. if (stripos($label['features'], '-126-') !== false) {
  6873. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6874. } else {
  6875. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and purchase = '" . $label['purchase'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6876. }
  6877. $j = 0;
  6878. if (count($ck) >= $num) {
  6879. for ($i = 0; $i < $num; $i++) {
  6880. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6881. {
  6882. $j++;
  6883. }
  6884. }
  6885. $this->whlabelscanlog->insert([
  6886. 'shop'=>$label['shop'],
  6887. 'type'=>2,
  6888. 'purchase'=>$label['purchase'],
  6889. 'sku'=>$label['sku'],
  6890. 'features'=>$label['features'],
  6891. 'title'=>$label['title'],
  6892. 'label'=>$label['label'],
  6893. 'warehouse'=>$label['warehouse'],
  6894. 'wlid'=>$label['id'],
  6895. 'num'=>$num,
  6896. 'addtime'=>time()
  6897. ]);
  6898. if ($j == $num) {
  6899. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6900. exit;
  6901. } else {
  6902. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6903. exit;
  6904. }
  6905. } else {
  6906. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6907. exit;
  6908. }
  6909. }
  6910. if(isset($_SESSION['api']))
  6911. {
  6912. $user = $this->user->get_api($_SESSION['api']);
  6913. if(in_array($user['power'],[1,27])){
  6914. $vip = 1;
  6915. }
  6916. }
  6917. else
  6918. {
  6919. $vip = 0;
  6920. header('Location: /');exit;
  6921. }
  6922. $this->data['vip'] = $vip;
  6923. $this->_Template('whlabel_printck', $this->data);
  6924. }
  6925. public function _printexcel()
  6926. {
  6927. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6928. $config['upload_path'] = '.' . $dir;
  6929. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6930. $config['allowed_types'] = 'xls|xlsx|csv';
  6931. $config['max_size'] = 10240;
  6932. $this->load->library('upload', $config);
  6933. $this->upload->initialize($config);
  6934. if ($this->upload->do_upload('userfile')) {
  6935. $full_path = $dir . $this->upload->data('file_name');
  6936. $fileName = '.' . $full_path;
  6937. if (!file_exists($fileName)) {
  6938. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6939. exit;
  6940. } else {
  6941. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6942. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6943. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6944. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6945. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6946. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6947. ++$column; //如果列数大于26行
  6948. $list = array();
  6949. for ($i = 2; $i <= $row; $i++) // 行数循环
  6950. {
  6951. $data = array();
  6952. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6953. {
  6954. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6955. }
  6956. $list[] = $data;
  6957. }
  6958. }
  6959. $ed = array();
  6960. $i = 0;
  6961. $j = 0;
  6962. $dcdata = array();
  6963. $yc = '';
  6964. $cmf_arr = array_column($list, '1');
  6965. array_multisort($cmf_arr, SORT_ASC, $list);
  6966. foreach ($list as $key => $value) {
  6967. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6968. if ($typeclass) {
  6969. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6970. } else {
  6971. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6972. $i++;
  6973. continue;
  6974. }
  6975. }
  6976. if ($i > 0) {
  6977. $yc = $i . '条异常';
  6978. }
  6979. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6980. exit;
  6981. }
  6982. }
  6983. public function _uck()
  6984. {
  6985. if (isset($_GET['excel'])) {
  6986. $tc = array();
  6987. $typeclass = $this->typeclass->find_all();
  6988. foreach ($typeclass as $v) {
  6989. $tc[$v['id']] = $v['zh'];
  6990. }
  6991. $data = array();
  6992. $t = array();
  6993. $rq = '';
  6994. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6995. $ts = $ts / (24 * 3600);
  6996. for ($i = 0; $i < $ts; $i++) {
  6997. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6998. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6999. }
  7000. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  7001. foreach ($info_list as $k => $v) {
  7002. $features = explode('-', trim($v['features'], '-'));
  7003. if (!isset($features[3]) || !isset($features[4])) {
  7004. continue;
  7005. }
  7006. $data[$k][0] = $tc[$features[0]]; //类型
  7007. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7008. $data[$k][2] = $tc[$features[4]]; //曲度
  7009. $data[$k][3] = '';
  7010. if (isset($data[$k][1])) {
  7011. $data[$k][3] .= $data[$k][1];
  7012. }
  7013. if (isset($data[$k][2])) {
  7014. $data[$k][3] .= $data[$k][2];
  7015. }
  7016. if (isset($features[5])) {
  7017. $data[$k][3] .= $tc[$features[5]];
  7018. }
  7019. if (isset($features[2])) {
  7020. $data[$k][3] .= $tc[$features[2]];
  7021. }
  7022. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7023. $data[$k][4] = $v['sku'];
  7024. $data[$k][5] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and (state = 0 or (state = 1 and outk > ' . strtotime(date("Y-m", time())) . '))'); //月初库存
  7025. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7026. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7027. $ztrq = '';
  7028. $ztsl = '';
  7029. if (count($zt) > 0) {
  7030. foreach ($zt as $vv) {
  7031. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7032. $ztsl .= $vv['num'] . '<br>';
  7033. }
  7034. }
  7035. $data[$k][] = trim($ztsl, '<br>');
  7036. $data[$k][] = trim($ztrq, '<br>');
  7037. $byck = 0;
  7038. foreach ($t as $vv) {
  7039. $sl = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and state = 1 and outk > ' . strtotime($vv) . ' and outk < ' . (strtotime($vv) + 24 * 3600));
  7040. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7041. $byck += $sl;
  7042. }
  7043. $data[$k][] = ($byck > 0) ? $byck : '';
  7044. }
  7045. $title = "详情 " . date("Y-m-d", time());
  7046. $titlename = "<table border=1>
  7047. <tr align='center'>
  7048. <td>类别</td>
  7049. <td>颜色</td>
  7050. <td>曲度</td>
  7051. <td>名称</td>
  7052. <td>SKU</td>
  7053. <td>月初库存</td>
  7054. <td>剩余库存</td>
  7055. <td>在途数量</td>
  7056. <td>预达日期</td>" .
  7057. $rq
  7058. . "<td>本月出库</td></tr>
  7059. </table>";
  7060. $filename = $title . ".xls";
  7061. $tail = "";
  7062. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7063. }
  7064. }
  7065. //梦体发现 用数字粘贴 会出现遗产给的数据
  7066. public function _whlabelexcelzh_ztsh()
  7067. {
  7068. if (isset($_GET['excel'])) {
  7069. $where = "sku != 'Preset'";
  7070. //数据排序
  7071. $order_str = "id desc";
  7072. if (empty($page)) {
  7073. $start = 0;
  7074. $perpage = 1;
  7075. } else {
  7076. $start = ($page - 1) * $perpage;
  7077. }
  7078. $category = $this->input->get('category', true);
  7079. $warehouse = $this->input->get('warehouse', true);
  7080. $excelid = $this->input->get('sid', true);
  7081. if ($category) {
  7082. $where .= " and features like '%-$category-%'";
  7083. }
  7084. if ($warehouse) {
  7085. $where .= " and warehouse = '$warehouse'";
  7086. }
  7087. $xzid = '';
  7088. if ($excelid) {
  7089. $excelid = explode(',', trim($excelid, ','));
  7090. foreach ($excelid as $key => $value) {
  7091. $xzid .= " id = " . $value . " or";
  7092. }
  7093. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7094. }
  7095. //取得信息列表
  7096. /**
  7097. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7098. $rows = array();$list = array();
  7099. foreach ($info_list as $key=>$value)
  7100. {
  7101. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7102. }
  7103. **/
  7104. $list = array();
  7105. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7106. foreach ($rows as $key => $value) {
  7107. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7108. $zh = '';
  7109. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7110. foreach ($zt as $v) {
  7111. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7112. }
  7113. $zt = array_sum(array_column($zt, 'num'));
  7114. $number = $value['number'];
  7115. $ftime = time() - 15 * 24 * 3600;
  7116. $warehouse = $this->warehouse->read($value['warehouse']);
  7117. $rows[$key]['warehouse'] = $warehouse['title'];
  7118. $rows[$key]['number'] = $c;
  7119. $rows[$key]['features'] = $zh;
  7120. $rows[$key]['hb'] = $c + $zt;
  7121. }
  7122. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7123. $titlename = "<table border=1>
  7124. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7125. <tr align='center'>
  7126. <td>仓库</td>
  7127. <td>SKU</td>
  7128. <td>产品</td>
  7129. <td>库存数量</td>
  7130. <td>在途数量及预达日期</td>
  7131. <td>在途+库存数量</td>
  7132. </tr>
  7133. </table>";
  7134. $filename = $title . ".xls";
  7135. $tail = "";
  7136. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7137. }
  7138. if (isset($_GET['excel'])) {
  7139. $warehouse = $this->input->get('warehouse', true);
  7140. $sku = $this->input->get('sku', true);
  7141. $cz = $this->input->get('cz', true);
  7142. $text = $this->input->post('text', true);
  7143. $xztime = $this->input->get('xztime', true);
  7144. $timetk = $this->input->get('timetk', true);
  7145. $timetj = $this->input->get('timetj', true);
  7146. $timetk = strtotime($timetk);
  7147. $timetj = strtotime($timetj);
  7148. $where = "time = '0' ";
  7149. if ($warehouse) {
  7150. $where .= " and warehouse = '$warehouse'";
  7151. }
  7152. if ($sku) {
  7153. $where .= " and sku = '$sku'";
  7154. }
  7155. if ($text) {
  7156. $where .= " and text like '%$text%'";
  7157. }
  7158. if ($cz != '') {
  7159. $where .= " and cz = '$cz'";
  7160. }
  7161. if ($timetk && $timetj) {
  7162. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7163. }
  7164. //数据排序
  7165. $order_str = $xztime . " desc";
  7166. //取得信息列表
  7167. $zh = array();
  7168. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7169. foreach ($info_list as $v) {
  7170. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7171. $warehouse = $this->warehouse->read($v['warehouse']);
  7172. $v['warehouse'] = $warehouse['title'];
  7173. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7174. $v['stime'] = date('Y-m-d', $v['stime']);
  7175. if (isset($zh[$v['features']])) {
  7176. $zh[$v['features']]['num'] += $v['num'];
  7177. } else {
  7178. $zh[$v['features']] = $v;
  7179. }
  7180. $zh[$v['features']]['features'] = $c;
  7181. }
  7182. $title = "在途数据" . date('Y-m-d', time());
  7183. $titlename = "<table border=1>
  7184. <tr align='center'>
  7185. <td>仓库</td>
  7186. <td>SKU</td>
  7187. <td>名称</td>
  7188. <td>在途数量</td>
  7189. <td>库存数量</td>
  7190. <td>添加在途日期</td>
  7191. <td>预达日期</td>
  7192. <td>备注</td>
  7193. </tr>
  7194. </table>";
  7195. $filename = $title . ".xls";
  7196. $tail = "";
  7197. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7198. }
  7199. }
  7200. //用XML(SpreadsheetML)格式导出excel,逻辑与_whlabelexcelzh一致,仅输出格式不同
  7201. public function _whlabelexcelzh()
  7202. {
  7203. //$colwidths:按表头顺序设置各列宽度(单位≈字符数);$wrapcols:需要自动换行的列下标(从0开始)
  7204. $excelxml = function ($info_list, $headers, $numkeys, $filename, $colwidths = array(), $wrapcols = array()) {
  7205. $str = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  7206. $str .= '<?mso-application progid="Excel.Sheet"?>' . "\n";
  7207. $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";
  7208. $str .= '<Styles>' . "\n";
  7209. $str .= '<Style ss:ID="wrap"><Alignment ss:Vertical="Center" ss:WrapText="1"/></Style>' . "\n";
  7210. $str .= '</Styles>' . "\n";
  7211. $str .= '<Worksheet ss:Name="Sheet1">' . "\n";
  7212. $str .= '<Table>' . "\n";
  7213. foreach ($colwidths as $w) {
  7214. $str .= '<Column ss:Width="' . $w . '"/>' . "\n";
  7215. }
  7216. $str .= '<Row>' . "\n";
  7217. foreach ($headers as $h) {
  7218. $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($h, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7219. }
  7220. $str .= '</Row>' . "\n";
  7221. foreach ($info_list as $row) {
  7222. $str .= '<Row>' . "\n";
  7223. $j = 0;
  7224. foreach ($row as $ke => $va) {
  7225. $va = (string)$va;
  7226. $va = str_replace('<br>', "\n", $va);
  7227. $wrapattr = in_array($j, $wrapcols) ? ' ss:StyleID="wrap"' : '';
  7228. if ($va === '') {
  7229. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String"></Data></Cell>' . "\n";
  7230. } else if (in_array($ke, $numkeys) && is_numeric($va)) {
  7231. $str .= '<Cell' . $wrapattr . '><Data ss:Type="Number">' . $va . '</Data></Cell>' . "\n";
  7232. } else {
  7233. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String">' . htmlspecialchars($va, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7234. }
  7235. $j++;
  7236. }
  7237. $str .= '</Row>' . "\n";
  7238. }
  7239. $str .= '</Table>' . "\n";
  7240. $str .= '</Worksheet>' . "\n";
  7241. $str .= '</Workbook>' . "\n";
  7242. while (ob_get_level()) {
  7243. ob_end_clean();
  7244. }
  7245. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  7246. header("Content-Disposition: attachment; filename=" . $filename);
  7247. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7248. header("Pragma: no-cache");
  7249. header("Expires: 0");
  7250. echo $str;
  7251. exit();
  7252. };
  7253. if (isset($_GET['excel'])) {
  7254. $where = "sku != 'Preset'";
  7255. //数据排序
  7256. $order_str = "id desc";
  7257. if (empty($page)) {
  7258. $start = 0;
  7259. $perpage = 1;
  7260. } else {
  7261. $start = ($page - 1) * $perpage;
  7262. }
  7263. $category = $this->input->get('category', true);
  7264. $warehouse = $this->input->get('warehouse', true);
  7265. $excelid = $this->input->get('sid', true);
  7266. if ($category) {
  7267. $where .= " and features like '%-$category-%'";
  7268. }
  7269. if ($warehouse) {
  7270. $where .= " and warehouse = '$warehouse'";
  7271. }
  7272. $xzid = '';
  7273. if ($excelid) {
  7274. $excelid = explode(',', trim($excelid, ','));
  7275. foreach ($excelid as $key => $value) {
  7276. $xzid .= " id = " . $value . " or";
  7277. }
  7278. $xzid = " and (" . rtrim($xzid, 'or') . ");";
  7279. }
  7280. $list = array();
  7281. $rows = $this->whlabel->find_pc($where, 'sku,title,features,warehouse', 'warehouse,sku,title,number,features');
  7282. foreach ($rows as $key => $value) {
  7283. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7284. $zh = '';
  7285. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7286. foreach ($zt as $v) {
  7287. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7288. }
  7289. $zt = array_sum(array_column($zt, 'num'));
  7290. $number = $value['number'];
  7291. $ftime = time() - 15 * 24 * 3600;
  7292. $warehouse = $this->warehouse->read($value['warehouse']);
  7293. //按表头顺序输出:仓库 | SKU | 产品 | 库存数量 | 在途数量及预达日期 | 在途+库存数量
  7294. $rows[$key] = array(
  7295. 'warehouse' => ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $value['warehouse'],
  7296. 'sku' => $value['sku'],
  7297. 'title' => isset($value['title']) ? $value['title'] : '',
  7298. 'number' => $c,
  7299. 'features' => $zh,
  7300. 'hb' => $c + $zt,
  7301. );
  7302. }
  7303. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7304. $filename = $title . ".xls";
  7305. $headers = array('仓库', 'SKU', '产品', '库存数量', '在途数量及预达日期', '在途+库存数量');
  7306. $numkeys = array('number', 'hb');
  7307. //列宽与表头一一对应(单位≈字符数);SKU(1)、产品(2)、在途列(4)超宽自动换行
  7308. $colwidths = array(80, 300,450, 50, 120, 80);
  7309. $wrapcols = array(1, 2, 4);
  7310. $excelxml($rows, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7311. }
  7312. if (isset($_GET['excel'])) {
  7313. $warehouse = $this->input->get('warehouse', true);
  7314. $sku = $this->input->get('sku', true);
  7315. $cz = $this->input->get('cz', true);
  7316. $text = $this->input->post('text', true);
  7317. $xztime = $this->input->get('xztime', true);
  7318. $timetk = $this->input->get('timetk', true);
  7319. $timetj = $this->input->get('timetj', true);
  7320. $timetk = strtotime($timetk);
  7321. $timetj = strtotime($timetj);
  7322. $where = "time = '0' ";
  7323. if ($warehouse) {
  7324. $where .= " and warehouse = '$warehouse'";
  7325. }
  7326. if ($sku) {
  7327. $where .= " and sku = '$sku'";
  7328. }
  7329. if ($text) {
  7330. $where .= " and text like '%$text%'";
  7331. }
  7332. if ($cz != '') {
  7333. $where .= " and cz = '$cz'";
  7334. }
  7335. if ($timetk && $timetj) {
  7336. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7337. }
  7338. //数据排序
  7339. $order_str = $xztime . " desc";
  7340. //取得信息列表
  7341. $zh = array();
  7342. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7343. foreach ($info_list as $v) {
  7344. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7345. $warehouse = $this->warehouse->read($v['warehouse']);
  7346. $v['warehouse'] = ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $v['warehouse'];
  7347. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7348. $v['stime'] = date('Y-m-d', $v['stime']);
  7349. if (isset($zh[$v['features']])) {
  7350. $zh[$v['features']]['num'] += $v['num'];
  7351. } else {
  7352. $zh[$v['features']] = $v;
  7353. }
  7354. $zh[$v['features']]['features'] = $c;
  7355. }
  7356. $title = "在途数据" . date('Y-m-d', time());
  7357. $filename = $title . ".xls";
  7358. $headers = array('仓库', 'SKU', '名称', '在途数量', '库存数量', '添加在途日期', '预达日期', '备注');
  7359. $numkeys = array('num', 'features');
  7360. //列宽与表头一一对应(单位≈字符数);SKU(1)、名称(2)、备注(7)超宽自动换行
  7361. $colwidths = array(18, 20, 50, 12, 12, 20, 12, 40);
  7362. $wrapcols = array(1, 2, 7);
  7363. $excelxml($zh, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7364. }
  7365. }
  7366. public function _fc()
  7367. {
  7368. $vip = 0;
  7369. if (isset($_SESSION['api'])) {
  7370. $user = $this->user->get_api($_SESSION['api']);
  7371. if ($user['vip'] == 1) {
  7372. $vip = 1;
  7373. }
  7374. } else {
  7375. header('Location: /');
  7376. exit;
  7377. }
  7378. $post = $this->input->post(NULL, TRUE);
  7379. if (isset($post['page'])) {
  7380. $page = $this->input->post('page', true);
  7381. $perpage = $this->input->post('perpage', true);
  7382. $category = $this->input->post('category', true);
  7383. $size = $this->input->post('size', true);
  7384. $grade = $this->input->post('grade', true);
  7385. $color = $this->input->post('color', true);
  7386. $lowe = $this->input->post('lowe', true);
  7387. $sku = $this->input->post('sku');
  7388. $title = $this->input->post('title');
  7389. $warehouse = $this->input->post('warehouse', true);
  7390. $usa = $this->input->post('usa', true);
  7391. $purchase = $this->input->post('purchase', true);
  7392. $lacetype = $this->input->post('lacetype', true);
  7393. $haircap = $this->input->post('haircap', true);
  7394. $density = $this->input->post('density', true);
  7395. $details = $this->input->post('details', true);
  7396. $state = $this->input->post('state', true);
  7397. $ktime = $this->input->post('ktime', true);
  7398. $jtime = $this->input->post('jtime', true);
  7399. $ktime = strtotime($ktime);
  7400. $jtime = strtotime($jtime);
  7401. $where = "state = '11'";
  7402. $gj = "";
  7403. $ck = "";
  7404. if ($lacetype) {
  7405. $where .= " and features like '%-$lacetype-%'";
  7406. }
  7407. if ($category) {
  7408. $where .= " and features like '%-$category-%'";
  7409. }
  7410. if ($size) {
  7411. $where .= " and features like '%-$size-%'";
  7412. }
  7413. if ($grade) {
  7414. $where .= " and features like '%-$grade-%'";
  7415. }
  7416. if ($color) {
  7417. $where .= " and features like '%-$color-%'";
  7418. }
  7419. if ($lowe) {
  7420. $where .= " and features like '%-$lowe-%'";
  7421. }
  7422. if ($haircap) {
  7423. $where .= " and features like '%-$haircap-%'";
  7424. }
  7425. if ($density) {
  7426. $where .= " and features like '%-$density-%'";
  7427. }
  7428. if ($usa) {
  7429. if (!$warehouse) {
  7430. $where .= " and (warehouse = '5' or warehouse = '8')";
  7431. }
  7432. }
  7433. if ($warehouse) {
  7434. $where .= " and warehouse = '$warehouse'";
  7435. }
  7436. if ($details) {
  7437. $where .= " and details = '$details'";
  7438. }
  7439. if ($purchase) {
  7440. $where .= " and purchase = '$purchase'";
  7441. }
  7442. if ($state) {
  7443. $where .= " and state = '$state'";
  7444. }
  7445. if ($ktime && $jtime) {
  7446. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7447. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7448. }
  7449. //数据排序
  7450. $order_str = "id desc";
  7451. if (empty($page)) {
  7452. $start = 0;
  7453. $perpage = 1;
  7454. } else {
  7455. $start = ($page - 1) * $perpage;
  7456. }
  7457. if ($sku) {
  7458. $sku = trim($sku, ' ');
  7459. $sku = trim($sku, ' ');
  7460. $where .= " and sku like '%$sku%'";
  7461. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7462. } else if ($title) {
  7463. $title = trim($title, ' ');
  7464. $title = trim($title, ' ');
  7465. $where .= " and title like '%$title%'";
  7466. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7467. } else {
  7468. //$where .= " and time > '$ktime' and time < '$jtime'";
  7469. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7470. }
  7471. //取得信息列表
  7472. $rows = array();
  7473. $list = array();
  7474. foreach ($info_list as $key => $value) {
  7475. $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'] . '"');
  7476. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7477. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7478. $warehouse = $this->warehouse->read($value['warehouse']);
  7479. $info_list[$key]['warehouse'] = $warehouse['title'];
  7480. $info_list[$key]['number'] = $g;
  7481. $info_list[$key]['features'] = $x;
  7482. $info_list[$key]['x'] = $s;
  7483. }
  7484. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7485. $pagenum = ceil($total / $perpage);
  7486. $over = $total - ($start + $perpage);
  7487. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7488. echo json_encode($rows);
  7489. exit;
  7490. }
  7491. $this->data['vip'] = $vip;
  7492. $this->_Template('whlabel_fc', $this->data);
  7493. }
  7494. public function _fcmb()
  7495. {
  7496. $where = "sku != 'Preset'";
  7497. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7498. foreach ($rows as $k => $v) {
  7499. $warehouse = $this->warehouse->read($v['warehouse']);
  7500. $rows[$k]['warehouse'] = $warehouse['title'];
  7501. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7502. $rows[$k]['t'] = '';
  7503. $rows[$k]['n'] = '';
  7504. }
  7505. $title = "封货产品数据导入模板";
  7506. $titlename = "<table border=1>
  7507. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7508. <tr align='center'>
  7509. <td>仓库</td>
  7510. <td>SKU</td>
  7511. <td>产品</td>
  7512. <td>封存产品总数量</td>
  7513. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7514. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7515. </tr>
  7516. </table>";
  7517. $filename = $title . ".xls";
  7518. $tail = "";
  7519. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7520. }
  7521. public function _fcexcel()
  7522. {
  7523. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7524. $config['upload_path'] = '.' . $dir;
  7525. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7526. $config['allowed_types'] = 'xls|xlsx|csv';
  7527. $config['max_size'] = 10240;
  7528. $this->load->library('upload', $config);
  7529. $this->upload->initialize($config);
  7530. if ($this->upload->do_upload('userfile')) {
  7531. $full_path = $dir . $this->upload->data('file_name');
  7532. $fileName = '.' . $full_path;
  7533. if (!file_exists($fileName)) {
  7534. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7535. exit;
  7536. } else {
  7537. libxml_use_internal_errors(true);
  7538. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7539. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7540. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7541. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7542. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7543. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7544. ++$column; //如果列数大于26行
  7545. $list = array();
  7546. for ($i = 2; $i <= $row; $i++) // 行数循环
  7547. {
  7548. $data = array();
  7549. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7550. {
  7551. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7552. }
  7553. $list[] = $data;
  7554. }
  7555. }
  7556. $i = 0;
  7557. $j = 0;
  7558. $ed = array();
  7559. foreach ($list as $key => $value) {
  7560. $time = time();
  7561. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7562. continue;
  7563. }
  7564. $warehouse = $this->warehouse->get_title($value['0']);
  7565. $sku = $value['1'];
  7566. $type = $value['4']; //调整方式0扣减1删除
  7567. $num = $value['5']; //调整数量
  7568. //$text = $value['4'];//扣减说明
  7569. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7570. if (!$d) //如果没有这个SKU
  7571. {
  7572. $ed[] = array($sku . '-库存中不存在此SKU');
  7573. $j++;
  7574. continue;
  7575. }
  7576. if (!isset($warehouse['id'])) {
  7577. $ed[] = array($sku . '-仓库名错误!');
  7578. $j++;
  7579. continue;
  7580. }
  7581. if ($type == 1 || $type == 2) //扣减库存
  7582. {
  7583. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7584. if (count($data) < abs($num)) {
  7585. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7586. $j++;
  7587. continue;
  7588. }
  7589. if ($type == 1) //转入库存
  7590. {
  7591. for ($i = 0; $i < abs($num); $i++) {
  7592. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7593. }
  7594. } else if ($type == 2) //删除
  7595. {
  7596. for ($i = 0; $i < abs($num); $i++) {
  7597. $this->whlabel->remove($data[$i]['id']);
  7598. }
  7599. }
  7600. } else if ($type == 0) //增加库存
  7601. {
  7602. $post['sku'] = $d['sku'];
  7603. $post['shop'] = '';
  7604. $post['warehouse'] = $warehouse['id'];
  7605. $post['purchase'] = $d['purchase'];
  7606. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7607. $post['state'] = 11;
  7608. $post['title'] = $d['title'];
  7609. $post['number'] = $d['number'];
  7610. $post['features'] = $d['features'];
  7611. $post['enter'] = $time;
  7612. $post['time'] = $time; //操作时间
  7613. for ($i = 0; $i < $num; $i++) {
  7614. $post['label'] = time() . rand(100, 999) . $i;
  7615. $this->whlabel->insert($post);
  7616. }
  7617. }
  7618. sleep(1); //防止入库时间一样,需要延迟1秒
  7619. }
  7620. if ($j > 0) {
  7621. $tt = date('Ymd', time());
  7622. $title = '库存导入错误信息-' . $tt;
  7623. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7624. $tail = "\n";
  7625. $filename = $title . ".xls";
  7626. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7627. $dir = '/data/excel/' . $time . '/';
  7628. $file_name = 'error_' . $time . rand(1000, 9999);
  7629. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7630. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7631. fwrite($myfile, $ecl);
  7632. fclose($myfile);
  7633. $error = $dir . $file_name . '.xls';
  7634. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7635. exit;
  7636. } else {
  7637. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7638. exit;
  7639. }
  7640. }
  7641. }
  7642. public function _fcjxc($arg_array)
  7643. {
  7644. if (isset($_GET['excel'])) {
  7645. $category = $this->input->get('category', true);
  7646. $size = $this->input->get('size', true);
  7647. $grade = $this->input->get('grade', true);
  7648. $color = $this->input->get('color', true);
  7649. $lowe = $this->input->get('lowe', true);
  7650. $sku = $this->input->get('sku');
  7651. $title = $this->input->get('title');
  7652. $warehouse = $arg_array[0];
  7653. $usa = $this->input->get('usa', true);
  7654. $purchase = $this->input->get('purchase', true);
  7655. $lacetype = $this->input->get('lacetype', true);
  7656. $haircap = $this->input->get('haircap', true);
  7657. $density = $this->input->get('density', true);
  7658. $title = $this->input->get('title', true);
  7659. $state = $this->input->get('state', true);
  7660. $ktime = $this->input->get('ktime', true);
  7661. $jtime = $this->input->get('jtime', true);
  7662. $where = "state=11";
  7663. $gj = "";
  7664. $ck = "";
  7665. if ($lacetype) {
  7666. $where .= " and features like '%-$lacetype-%'";
  7667. }
  7668. if ($category) {
  7669. $where .= " and features like '%-$category-%'";
  7670. }
  7671. if ($size) {
  7672. $where .= " and features like '%-$size-%'";
  7673. }
  7674. if ($grade) {
  7675. $where .= " and features like '%-$grade-%'";
  7676. }
  7677. if ($color) {
  7678. $where .= " and features like '%-$color-%'";
  7679. }
  7680. if ($lowe) {
  7681. $where .= " and features like '%-$lowe-%'";
  7682. }
  7683. if ($haircap) {
  7684. $where .= " and features like '%-$haircap-%'";
  7685. }
  7686. if ($density) {
  7687. $where .= " and features like '%-$density-%'";
  7688. }
  7689. if ($usa) {
  7690. if (!$warehouse) {
  7691. $where .= " and (warehouse = '5' or warehouse = '8')";
  7692. }
  7693. }
  7694. if ($warehouse) {
  7695. $where .= " and warehouse = '$warehouse'";
  7696. }
  7697. if ($purchase) {
  7698. $where .= " and purchase = '$purchase'";
  7699. }
  7700. if ($state) {
  7701. $where .= " and state = '$state'";
  7702. }
  7703. $order_str = "id desc";
  7704. if ($sku) {
  7705. $sku = trim($sku, ' ');
  7706. $sku = trim($sku, ' ');
  7707. $where .= " and sku like '%$sku%'";
  7708. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7709. } else if ($title) {
  7710. $title = trim($title, ' ');
  7711. $title = trim($title, ' ');
  7712. $where .= " and title like '%$title%'";
  7713. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7714. } else {
  7715. //$where .= " and time > '$ktime' and time < '$jtime'";
  7716. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7717. }
  7718. //取得信息列表
  7719. $rows = array();
  7720. $list = array();
  7721. foreach ($info_list as $key => $value) {
  7722. $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'] . '"');
  7723. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7724. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7725. $rows[$key] = $value;
  7726. $warehouse = $this->warehouse->read($value['warehouse']);
  7727. $rows[$key]['warehouse'] = $warehouse['title'];
  7728. $rows[$key]['features'] = $g;
  7729. $rows[$key]['a'] = $x;
  7730. $rows[$key]['b'] = $s;
  7731. }
  7732. $title = "总统计表";
  7733. $titlename = "<table border=1>
  7734. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7735. <tr align='center'>
  7736. <td>仓库</td>
  7737. <td>SKU</td>
  7738. <td>产品名称</td>
  7739. <td>录入总量</td>
  7740. <td>取出总量</td>
  7741. <td>剩余总量</td>
  7742. </tr>
  7743. </table>";
  7744. $filename = $title . ".xls";
  7745. $tail = "";
  7746. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7747. }
  7748. $vip = 0;
  7749. if (isset($_SESSION['api'])) {
  7750. $user = $this->user->get_api($_SESSION['api']);
  7751. if ($user['vip'] == 1) {
  7752. $vip = 1;
  7753. }
  7754. } else {
  7755. header('Location: /');
  7756. exit;
  7757. }
  7758. $post = $this->input->post(NULL, TRUE);
  7759. if (isset($post['page'])) {
  7760. $page = $this->input->post('page', true);
  7761. $perpage = $this->input->post('perpage', true);
  7762. $category = $this->input->post('category', true);
  7763. $size = $this->input->post('size', true);
  7764. $grade = $this->input->post('grade', true);
  7765. $color = $this->input->post('color', true);
  7766. $lowe = $this->input->post('lowe', true);
  7767. $sku = $this->input->post('sku');
  7768. $title = $this->input->post('title');
  7769. $warehouse = $arg_array[0];
  7770. $usa = $this->input->post('usa', true);
  7771. $purchase = $this->input->post('purchase', true);
  7772. $lacetype = $this->input->post('lacetype', true);
  7773. $haircap = $this->input->post('haircap', true);
  7774. $density = $this->input->post('density', true);
  7775. $title = $this->input->post('title', true);
  7776. $state = $this->input->post('state', true);
  7777. $ktime = $this->input->post('ktime', true);
  7778. $jtime = $this->input->post('jtime', true);
  7779. $ktime = strtotime($ktime);
  7780. $jtime = strtotime($jtime);
  7781. $where = "state=11";
  7782. $gj = "";
  7783. $ck = "";
  7784. if ($lacetype) {
  7785. $where .= " and features like '%-$lacetype-%'";
  7786. }
  7787. if ($category) {
  7788. $where .= " and features like '%-$category-%'";
  7789. }
  7790. if ($size) {
  7791. $where .= " and features like '%-$size-%'";
  7792. }
  7793. if ($grade) {
  7794. $where .= " and features like '%-$grade-%'";
  7795. }
  7796. if ($color) {
  7797. $where .= " and features like '%-$color-%'";
  7798. }
  7799. if ($lowe) {
  7800. $where .= " and features like '%-$lowe-%'";
  7801. }
  7802. if ($haircap) {
  7803. $where .= " and features like '%-$haircap-%'";
  7804. }
  7805. if ($density) {
  7806. $where .= " and features like '%-$density-%'";
  7807. }
  7808. if ($usa) {
  7809. if (!$warehouse) {
  7810. $where .= " and (warehouse = '5' or warehouse = '8')";
  7811. }
  7812. }
  7813. if ($warehouse) {
  7814. $where .= " and warehouse = '$warehouse'";
  7815. }
  7816. if ($purchase) {
  7817. $where .= " and purchase = '$purchase'";
  7818. }
  7819. if ($state) {
  7820. $where .= " and state = '$state'";
  7821. }
  7822. if ($ktime && $jtime) {
  7823. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7824. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7825. }
  7826. //数据排序
  7827. $order_str = "id desc";
  7828. $xs = 0;
  7829. $rows = array();
  7830. $list = array();
  7831. if (empty($page)) {
  7832. $start = 0;
  7833. $perpage = 1;
  7834. } else {
  7835. $start = ($page - 1) * $perpage;
  7836. }
  7837. if ($sku || $title) {
  7838. if ($title) {
  7839. $title = trim($title, ' ');
  7840. $title = trim($title, ' ');
  7841. $where .= " and title like '%$title%'";
  7842. } else {
  7843. $sku = trim($sku, ' ');
  7844. $sku = trim($sku, ' ');
  7845. $where .= " and sku like '%$sku%'";
  7846. }
  7847. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7848. foreach ($info_list as $key => $value) {
  7849. $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'] . '"');
  7850. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7851. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7852. $rows[$key] = $value;
  7853. $warehouse = $this->warehouse->read($value['warehouse']);
  7854. $rows[$key]['warehouse'] = $warehouse['title'];
  7855. $rows[$key]['features'] = $g;
  7856. $rows[$key]['a'] = $x;
  7857. $rows[$key]['b'] = $s;
  7858. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7859. $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天销量
  7860. $yj = $c / ($xl / 30);
  7861. if ($yj < 7) {
  7862. $rows[$key]['y'] = round($yj) . '天销量';
  7863. } else {
  7864. $rows[$key]['y'] = '正常';
  7865. }
  7866. }
  7867. } else {
  7868. //$where .= " and time > '$ktime' and time < '$jtime'";
  7869. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7870. foreach ($info_list as $key => $value) {
  7871. $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'] . '"');
  7872. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7873. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7874. $zs[$key] = $value;
  7875. $warehouse = $this->warehouse->read($value['warehouse']);
  7876. $zs[$key]['warehouse'] = $warehouse['title'];
  7877. $zs[$key]['features'] = $g;
  7878. $zs[$key]['a'] = $x;
  7879. $zs[$key]['b'] = $s;
  7880. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7881. $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天销量
  7882. $yj = $c / ($xl / 30);
  7883. if ($yj < 7) {
  7884. $zs[$key]['y'] = round($yj) . '天销量';
  7885. $rows[$key] = $zs[$key];
  7886. }
  7887. }
  7888. }
  7889. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7890. $pagenum = ceil($total / $perpage);
  7891. $over = $total - ($start + $perpage);
  7892. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7893. echo json_encode($rows);
  7894. exit;
  7895. }
  7896. $this->data['arg_array'] = $arg_array[0];
  7897. $this->_Template('whlabel_fcjxc', $this->data);
  7898. }
  7899. public function _0kcdel()
  7900. {
  7901. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7902. $config['upload_path'] = '.' . $dir;
  7903. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7904. $config['allowed_types'] = 'xls|xlsx|csv';
  7905. $config['max_size'] = 10240;
  7906. $this->load->library('upload', $config);
  7907. $this->upload->initialize($config);
  7908. if ($this->upload->do_upload('userfile')) {
  7909. $full_path = $dir . $this->upload->data('file_name');
  7910. $fileName = '.' . $full_path;
  7911. if (!file_exists($fileName)) {
  7912. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7913. exit;
  7914. } else {
  7915. require_once "./data/excel/PHPExcel/IOFactory.php";
  7916. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7917. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7918. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7919. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7920. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7921. ++$column; //如果列数大于26行
  7922. $list = array();
  7923. for ($i = 2; $i <= $row; $i++) // 行数循环
  7924. {
  7925. $data = array();
  7926. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7927. {
  7928. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7929. }
  7930. $list[] = $data;
  7931. }
  7932. }
  7933. $i = 0;
  7934. $j = 0;
  7935. $ed = array();
  7936. foreach ($list as $key => $value) {
  7937. $time = time();
  7938. if ($value['0'] == "" || $value['1'] == "") {
  7939. continue;
  7940. }
  7941. $warehouse = $this->warehouse->get_title($value['0']);
  7942. $sku = $value['1'];
  7943. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7944. if (!$d) //如果没有这个SKU
  7945. {
  7946. $ed[] = array($sku . '-库存中不存在此SKU');
  7947. $j++;
  7948. continue;
  7949. }
  7950. if (!isset($warehouse['id'])) {
  7951. $ed[] = array($sku . '-仓库名错误!');
  7952. $j++;
  7953. continue;
  7954. }
  7955. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7956. if ($z < 1) {
  7957. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7958. foreach ($z as $v) {
  7959. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7960. if (count($zt) > 0) {
  7961. $ed[] = array($sku . '-有在途库存无法删除!');
  7962. $j++;
  7963. continue;
  7964. }
  7965. $this->whlabel->remove($v['id']);
  7966. }
  7967. } else {
  7968. $ed[] = array($sku . '-非0库存!');
  7969. $j++;
  7970. continue;
  7971. }
  7972. }
  7973. if ($j > 0) {
  7974. $tt = date('Ymd', time());
  7975. $title = '删除0库存错误信息-' . $tt;
  7976. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7977. $tail = "\n";
  7978. $filename = $title . ".xls";
  7979. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7980. $dir = '/data/excel/' . $time . '/';
  7981. $file_name = 'error_' . $time . rand(1000, 9999);
  7982. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7983. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7984. fwrite($myfile, $ecl);
  7985. fclose($myfile);
  7986. $error = $dir . $file_name . '.xls';
  7987. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7988. exit;
  7989. } else {
  7990. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7991. exit;
  7992. }
  7993. }
  7994. }
  7995. public function _gbhtype()
  7996. {
  7997. $post = $this->input->post(NULL, TRUE);
  7998. if (isset($post['s'])) {
  7999. $n = $this->input->post('n');
  8000. $d = $this->input->post('s');
  8001. if (!$d) {
  8002. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  8003. exit;
  8004. }
  8005. $d = explode(',', trim($d, ','));
  8006. $t = $this->whlabel_type->read($n);
  8007. //循环删除记录
  8008. foreach ($d as $v) {
  8009. $u = $this->whlabel->read($v);
  8010. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  8011. foreach ($data as $val) {
  8012. $this->whlabel->save(array('type' => $n), $val['id']);
  8013. }
  8014. }
  8015. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  8016. }
  8017. }
  8018. //出库、退库导出
  8019. public function _dccrtype()
  8020. {
  8021. $classid = $this->classid->sku();
  8022. $pm = $classid;
  8023. $typeclass = array();
  8024. $tc = $this->typeclass->find_all();
  8025. foreach ($tc as $v) {
  8026. $typeclass[$v['id']] = $v;
  8027. }
  8028. $prc = array();
  8029. $purchase = $this->purchase->find_all();
  8030. foreach ($purchase as $k => $v) {
  8031. $prc[$v['id']] = $v['title'];
  8032. }
  8033. if (isset($_GET['sid'])) {
  8034. $wh = array();
  8035. $w = $this->warehouse->find_all('1=1', 'id,title');
  8036. foreach ($w as $v) {
  8037. $wh[$v['id']] = $v['title'];
  8038. }
  8039. $type = $this->input->get('excel', true);
  8040. $category = $this->input->get('category', true);
  8041. $size = $this->input->get('size', true);
  8042. $grade = $this->input->get('grade', true);
  8043. $color = $this->input->get('color', true);
  8044. $lowe = $this->input->get('lowe', true);
  8045. $sku = $this->input->get('sku', true);
  8046. $warehouse = $this->input->get('warehouse', true);
  8047. $lacetype = $this->input->get('lacetype', true);
  8048. $lacecolor = $this->input->get('lacecolor', true);
  8049. $density = $this->input->get('density', true);
  8050. $haircap = $this->input->get('haircap', true);
  8051. $purchase = $this->input->get('purchase', true);
  8052. $title = $this->input->get('title', true);
  8053. $state = $this->input->get('state', true);
  8054. $sid = $this->input->get('sid', true);
  8055. $ktime = $this->input->get('ktime', true);
  8056. $jtime = $this->input->get('jtime', true);
  8057. $ktime = strtotime($ktime);
  8058. $jtime = strtotime($jtime);
  8059. $where = "1=1";
  8060. $gj = "";
  8061. $ck = "";
  8062. if ($category) {
  8063. $where .= " and features like '%-$category-%'";
  8064. }
  8065. if ($size) {
  8066. $where .= " and features like '%-$size-%'";
  8067. }
  8068. if ($grade) {
  8069. $where .= " and features like '%-$grade-%'";
  8070. }
  8071. if ($color) {
  8072. $where .= " and features like '%-$color-%'";
  8073. }
  8074. if ($lowe) {
  8075. $where .= " and features like '%-$lowe-%'";
  8076. }
  8077. if ($warehouse) {
  8078. $where .= " and warehouse = '$warehouse'";
  8079. }
  8080. if ($purchase) {
  8081. $where .= " and purchase = '$purchase'";
  8082. }
  8083. if ($state) {
  8084. $where .= " and state = '$state'";
  8085. }
  8086. if ($lacetype) {
  8087. $where .= " and features like '%-$lacetype-%'";
  8088. }
  8089. if ($lacecolor) {
  8090. $where .= " and features like '%-$lacecolor-%'";
  8091. }
  8092. if ($density) {
  8093. $where .= " and features like '%-$density-%'";
  8094. }
  8095. if ($haircap) {
  8096. $where .= " and features like '%-$haircap-%'";
  8097. }
  8098. if ($title) {
  8099. $title = trim($title, ' ');
  8100. $title = trim($title, ' ');
  8101. $where .= " and title like '%$title%'";
  8102. }
  8103. if ($sku) {
  8104. $sku = trim($sku, ' ');
  8105. $sku = trim($sku, ' ');
  8106. $where .= " and sku like '%$sku%'";
  8107. }
  8108. if ($ktime && $jtime) {
  8109. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8110. }
  8111. $sidwhere = '';
  8112. if ($sid) {
  8113. $sd = "";
  8114. $s = explode(',', trim($sid, ','));
  8115. foreach ($s as $value) {
  8116. $sd .= " id = " . $value . " or";
  8117. }
  8118. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8119. }
  8120. //数据排序
  8121. $order_str = "time desc";
  8122. if (empty($page)) {
  8123. $start = 0;
  8124. $perpage = 1;
  8125. } else {
  8126. $start = ($page - 1) * $perpage;
  8127. }
  8128. $wh = array();
  8129. $w = $this->warehouse->find_all('1=1', 'id,title');
  8130. foreach ($w as $v) {
  8131. $wh[$v['id']] = $v['title'];
  8132. }
  8133. $wt = array();
  8134. $whlabel_type = $this->whlabel_type->find_all();
  8135. foreach ($whlabel_type as $v) {
  8136. $wt[$v['id']] = $v['title'];
  8137. }
  8138. $classid = $this->classid->sku();
  8139. $list = array();
  8140. $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');
  8141. foreach ($rows_r as $key => $value) {
  8142. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8143. $pm = $classid;
  8144. $jm = $classid;
  8145. $rows_r[$key]['enter'] = '入库';
  8146. $rows_r[$key]['time'] = $value['enter'];
  8147. if ($value['rktype'] == 1) {
  8148. $rows_r[$key]['rktype'] = '采购入库';
  8149. } else if ($value['rktype'] == 2) {
  8150. $rows_r[$key]['rktype'] = '盘盈调整';
  8151. } else if ($value['rktype'] == 3) {
  8152. $rows_r[$key]['rktype'] = '其他调整入库';
  8153. } else if ($value['rktype'] == 4) {
  8154. $rows_r[$key]['rktype'] = '其他调整入库';
  8155. } else if ($value['rktype'] == 5) {
  8156. $rows_r[$key]['rktype'] = '退库入库';
  8157. } else if ($value['rktype'] == 6) {
  8158. $rows_r[$key]['rktype'] = '退货可用入库';
  8159. } else if ($value['rktype'] == 7) {
  8160. $rows_r[$key]['rktype'] = '形态转换入库';
  8161. } else {
  8162. $rows_r[$key]['rktype'] = '';
  8163. }
  8164. $features = explode('-', trim($value['features'], '-'));
  8165. foreach ($features as $v) {
  8166. if (isset($typeclass[$v])) {
  8167. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8168. $pm[$typeclass[$v]['classid']] = $zh[0];
  8169. }
  8170. if (isset($typeclass[$v])) {
  8171. if (isset($jm[$typeclass[$v]['classid']])) {
  8172. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8173. }
  8174. }
  8175. }
  8176. $zh = implode(" ", $pm);
  8177. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8178. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8179. $rows_r[$key]['zh'] = $zh;
  8180. $jm = array_filter($jm);
  8181. $rows_r[$key]['features'] = implode("-", $jm);
  8182. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8183. }
  8184. $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');
  8185. foreach ($rows_c as $key => $value) {
  8186. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8187. $pm = $classid;
  8188. $jm = $classid;
  8189. $rows_c[$key]['time'] = $value['outk'];
  8190. $rows_c[$key]['outk'] = '出库';
  8191. if ($value['cktype'] == 1) {
  8192. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8193. } else if ($value['cktype'] == 2) {
  8194. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8195. } else if ($value['cktype'] == 3) {
  8196. $rows_c[$key]['cktype'] = '盘亏调整';
  8197. } else if ($value['cktype'] == 4) {
  8198. $rows_c[$key]['cktype'] = '其他调整出库';
  8199. } else if ($value['cktype'] == 5) {
  8200. $rows_c[$key]['cktype'] = '形态转换出库';
  8201. } else {
  8202. $rows_c[$key]['cktype'] = '';
  8203. }
  8204. unset($rows_c[$key]['state']);
  8205. $features = explode('-', trim($value['features'], '-'));
  8206. foreach ($features as $v) {
  8207. if (isset($typeclass[$v])) {
  8208. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8209. $pm[$typeclass[$v]['classid']] = $zh[0];
  8210. }
  8211. if (isset($typeclass[$v])) {
  8212. if (isset($jm[$typeclass[$v]['classid']])) {
  8213. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8214. }
  8215. }
  8216. }
  8217. $zh = implode(" ", $pm);
  8218. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8219. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8220. $rows_c[$key]['zh'] = $zh;
  8221. $jm = array_filter($jm);
  8222. $rows_c[$key]['features'] = implode("-", $jm);
  8223. $rows_c[$key]['number'] = 1;
  8224. }
  8225. $merged = $rows_r;
  8226. foreach ($rows_c as $key => $value) {
  8227. if (isset($merged[$key])) {
  8228. $merged[] = $value;
  8229. } else {
  8230. $merged[$key] = $value;
  8231. }
  8232. }
  8233. usort($merged, function ($a, $b) {
  8234. return $a['time'] - $b['time'];
  8235. });
  8236. foreach ($merged as $key => $value) {
  8237. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8238. }
  8239. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8240. $titlename = "<table border=1>
  8241. <tr align='center'>
  8242. <td>仓库</td>
  8243. <td>SKU</td>
  8244. <td>商品名称</td>
  8245. <td>仓库品名</td>
  8246. <td>料号</td>
  8247. <td>时间</td>
  8248. <td>操作</td>
  8249. <td>类型</td>
  8250. <td>数量</td>
  8251. <td>备注</td>
  8252. </tr>
  8253. </table>";
  8254. $filename = $title . ".xlsx";
  8255. $tail = "";
  8256. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8257. }
  8258. }
  8259. /*************************************处理exceljs导出****************************************************/
  8260. public function _excelrjs(){
  8261. if (isset($_GET['excel'])) {
  8262. $category = $this->input->get('category', true);
  8263. $size = $this->input->get('size', true);
  8264. $grade = $this->input->get('grade', true);
  8265. $color = $this->input->get('color', true);
  8266. $lowe = $this->input->get('lowe', true);
  8267. $sku = $this->input->get('sku', true);
  8268. $warehouse = $this->input->get('warehouse', true);
  8269. $purchase = $this->input->get('purchase', true);
  8270. $ktime = $this->input->get('ktime', true);
  8271. $jtime = $this->input->get('jtime', true);
  8272. $ktime = strtotime($ktime);
  8273. $jtime = strtotime($jtime);
  8274. $where = "1=1";
  8275. $gj = "";
  8276. $ck = "";
  8277. if ($category) {
  8278. $where .= " and features like '%-$category-%'";
  8279. }
  8280. if ($size) {
  8281. $where .= " and features like '%-$size-%'";
  8282. }
  8283. if ($grade) {
  8284. $where .= " and features like '%-$grade-%'";
  8285. }
  8286. if ($color) {
  8287. $where .= " and features like '%-$color-%'";
  8288. }
  8289. if ($lowe) {
  8290. $where .= " and features like '%-$lowe-%'";
  8291. }
  8292. if ($warehouse) {
  8293. $where .= " and warehouse = '$warehouse'";
  8294. }
  8295. if ($purchase) {
  8296. $where .= " and purchase = '$purchase'";
  8297. }
  8298. if ($sku) {
  8299. $where .= " and sku = '$sku'";
  8300. }
  8301. if ($ktime && $jtime) {
  8302. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8303. }
  8304. //数据排序
  8305. $order_str = "id desc";
  8306. if (empty($page)) {
  8307. $start = 0;
  8308. $perpage = 1;
  8309. } else {
  8310. $start = ($page - 1) * $perpage;
  8311. }
  8312. $list = array();
  8313. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8314. foreach ($rows as $value) {
  8315. $ck = $this->warehouse->read($value['warehouse']);
  8316. $warehouse = $ck['title'];
  8317. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8318. $retreatwarehouse = $tkck['title'];
  8319. $gy = $this->purchase->read($value['purchase']);
  8320. $purchase = $gy['title'];
  8321. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8322. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8323. }
  8324. if(empty($list)){
  8325. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8326. }else{
  8327. $final_list = [];
  8328. foreach($list as $v){
  8329. $final_list[] = array_values($v);
  8330. }
  8331. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8332. array_unshift($final_list,[
  8333. "仓库","SKU","商品名称","时间","数量"
  8334. ]);
  8335. array_unshift($final_list,[
  8336. $title,"","","",""
  8337. ]);
  8338. $merges = [
  8339. [
  8340. "s"=>["r"=>0,"c"=>0],
  8341. "e"=>["r"=>0,"c"=>4]
  8342. ]
  8343. ];
  8344. $cols = [
  8345. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8346. ];
  8347. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8348. }
  8349. }
  8350. }
  8351. //出库、退库导出
  8352. public function _excelctjs()
  8353. {
  8354. $classid = $this->classid->sku();
  8355. $pm = $classid;
  8356. $typeclass = array();
  8357. $tc = $this->typeclass->find_all();
  8358. foreach ($tc as $v) {
  8359. $typeclass[$v['id']] = $v;
  8360. }
  8361. $prc = array();
  8362. $purchase = $this->purchase->find_all();
  8363. foreach ($purchase as $k => $v) {
  8364. $prc[$v['id']] = $v['title'];
  8365. }
  8366. if (isset($_GET['excel'])) {
  8367. $wh = array();
  8368. $w = $this->warehouse->find_all('1=1', 'id,title');
  8369. foreach ($w as $v) {
  8370. $wh[$v['id']] = $v['title'];
  8371. }
  8372. $type = $this->input->get('excel', true);
  8373. $category = $this->input->get('category', true);
  8374. $size = $this->input->get('size', true);
  8375. $grade = $this->input->get('grade', true);
  8376. $color = $this->input->get('color', true);
  8377. $lowe = $this->input->get('lowe', true);
  8378. $sku = $this->input->get('sku', true);
  8379. $title = $this->input->get('title', true);
  8380. $warehouse = $this->input->get('warehouse', true);
  8381. $purchase = $this->input->get('purchase', true);
  8382. $lacetype = $this->input->get('lacetype', true);
  8383. $haircap = $this->input->get('haircap', true);
  8384. $lacecolor = $this->input->get('lacecolor', true);
  8385. $density = $this->input->get('density', true);
  8386. $details = $this->input->get('details', true);
  8387. $state = $this->input->get('state', true);
  8388. $shop = $this->input->get('shop', true);
  8389. $hairnumber = $this->input->get('hairnumber', true);
  8390. $type_leixi = $this->input->get('type', true);
  8391. $cpbz = $this->input->get('cpbz', true);
  8392. $sm = $this->input->get('sm', true);
  8393. $sid = $this->input->get('sid', true);
  8394. $ktime = $this->input->get('ktime', true);
  8395. $jtime = $this->input->get('jtime', true);
  8396. $ktime = strtotime($ktime);
  8397. $jtime = strtotime($jtime);
  8398. //$where = " 1=1 ";
  8399. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8400. $where = " sku != '' ";
  8401. $gj = "";
  8402. $ck = "";
  8403. if ($category) {
  8404. $where .= " and features like '%-$category-%'";
  8405. }
  8406. if ($size) {
  8407. $where .= " and features like '%-$size-%'";
  8408. }
  8409. if ($grade) {
  8410. $where .= " and features like '%-$grade-%'";
  8411. }
  8412. if ($color) {
  8413. $where .= " and features like '%-$color-%'";
  8414. }
  8415. if ($lowe) {
  8416. $where .= " and features like '%-$lowe-%'";
  8417. }
  8418. if ($warehouse) {
  8419. $where .= " and warehouse = '$warehouse'";
  8420. }
  8421. if ($purchase) {
  8422. $where .= " and purchase = '$purchase'";
  8423. }
  8424. if ($state) {
  8425. $where .= " and state = '$state'";
  8426. }
  8427. if ($lacetype) {
  8428. $where .= " and features like '%-$lacetype-%'";
  8429. }
  8430. if ($lacecolor) {
  8431. $where .= " and features like '%-$lacecolor-%'";
  8432. }
  8433. if ($density) {
  8434. $where .= " and features like '%-$density-%'";
  8435. }
  8436. if ($haircap) {
  8437. $where .= " and features like '%-$haircap-%'";
  8438. }
  8439. if ($details) {
  8440. $where .= " and details = '$details'";
  8441. }
  8442. if ($shop) {
  8443. $where .= " and shop like '%$shop%'";
  8444. }
  8445. if ($title) {
  8446. $title = trim($title, ' ');
  8447. $title = trim($title, ' ');
  8448. $where .= " and title like '%$title%'";
  8449. }
  8450. if (!empty($hairnumber)) {
  8451. $where .= " and features like '%-128-%' ";
  8452. if ($hairnumber < 0) {
  8453. $class_list = $this->typeclass->find_all('classid = 43');
  8454. foreach ($class_list as $v) {
  8455. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8456. }
  8457. } else {
  8458. $where .= " and features like '%-$hairnumber-%'";
  8459. }
  8460. }
  8461. if ($type_leixi) {
  8462. $where .= " and type = '$type_leixi'";
  8463. }
  8464. if ($cpbz) {
  8465. $where .= " and cpbz like '%$cpbz%' ";
  8466. }
  8467. if ($sm) {
  8468. $where .= " and sm like '%$sm%' ";
  8469. }
  8470. if ($sku) {
  8471. $sku = trim($sku, ' ');
  8472. $sku = trim($sku, ' ');
  8473. $where .= " and sku like '%$sku%'";
  8474. }
  8475. if ($ktime && $jtime) {
  8476. if ($type == 1) {
  8477. $tl = '出库';
  8478. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8479. } else if ($type == 2) {
  8480. $tl = '退库';
  8481. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8482. } else if ($type == 3) {
  8483. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8484. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8485. } else if ($type == 4) {
  8486. $tl = '出库+零售';
  8487. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8488. } else if ($type == 5) {
  8489. $tl = '零售';
  8490. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8491. }
  8492. }
  8493. $sidwhere = '';
  8494. if ($sid) {
  8495. $sd = "";
  8496. $s = explode(',', trim($sid, ','));
  8497. foreach ($s as $value) {
  8498. $sd .= " id = " . $value . " or";
  8499. }
  8500. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8501. }
  8502. //数据排序
  8503. $order_str = "time desc";
  8504. if (empty($page)) {
  8505. $start = 0;
  8506. $perpage = 1;
  8507. } else {
  8508. $start = ($page - 1) * $perpage;
  8509. }
  8510. //取得信息列表
  8511. if ($type != 3 && $type != 5) {
  8512. if ($type == 1 || $type == 4) {
  8513. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8514. foreach ($info_list as $key => $value) {
  8515. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8516. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8517. $warehouse = $this->warehouse->read($value['warehouse']);
  8518. $info_list[$key]['warehouse'] = $warehouse['title'];
  8519. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8520. $features = explode('-', trim($features, '-'));
  8521. $pm = $classid;
  8522. foreach ($features as $k => $v) {
  8523. if ($v != 0) {
  8524. if (!isset($typeclass[$v])) {
  8525. continue;
  8526. }
  8527. if (isset($pm[$typeclass[$v]['classid']])) {
  8528. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8529. $tz = explode('|', $typeclass[$v]['zh']);
  8530. $pm[$typeclass[$v]['classid']] = $tz[0];
  8531. } else {
  8532. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8533. }
  8534. }
  8535. }
  8536. }
  8537. $zh = implode(" ", $pm);
  8538. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8539. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8540. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8541. $info_list[$key]['features'] = $zh;
  8542. }
  8543. $final_list = [];
  8544. foreach($info_list as $k=>$v){
  8545. $number = "";
  8546. if(!empty($v['orderinfo'])){
  8547. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8548. if(!empty($tmp_info['number'])){
  8549. $number = $tmp_info['number'];
  8550. }
  8551. }
  8552. $final_list[] = [
  8553. 'warehouse'=>$v['warehouse'],
  8554. 'purchase'=>$v['purchase'],
  8555. 'sku'=>$v['sku'],
  8556. 'title'=>$v['title'],
  8557. 'features'=>$v['features'],
  8558. 'label'=>$v['label'],
  8559. 'orderinfo'=>$v['orderinfo'],
  8560. 'number'=>$number,
  8561. 'waybill'=>$v['waybill'],
  8562. 'outk'=>$v['outk'],
  8563. ];
  8564. }
  8565. } else {
  8566. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8567. foreach ($info_list as $key => $value) {
  8568. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8569. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8570. $warehouse = $this->warehouse->read($value['warehouse']);
  8571. $info_list[$key]['warehouse'] = $warehouse['title'];
  8572. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8573. $features = explode('-', trim($features, '-'));
  8574. $pm = $classid;
  8575. foreach ($features as $k => $v) {
  8576. if ($v != 0) {
  8577. if (!isset($typeclass[$v])) {
  8578. continue;
  8579. }
  8580. if (isset($pm[$typeclass[$v]['classid']])) {
  8581. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8582. $tz = explode('|', $typeclass[$v]['zh']);
  8583. $pm[$typeclass[$v]['classid']] = $tz[0];
  8584. } else {
  8585. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8586. }
  8587. }
  8588. }
  8589. }
  8590. $zh = implode(" ", $pm);
  8591. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8592. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8593. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8594. $info_list[$key]['features'] = $zh;
  8595. }
  8596. $final_list = [];
  8597. foreach($info_list as $k=>$v){
  8598. $number = "";
  8599. if(!empty($v['orderinfo'])){
  8600. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8601. if(!empty($tmp_info['number'])){
  8602. $number = $tmp_info['number'];
  8603. }
  8604. }
  8605. $final_list[] = [
  8606. 'warehouse'=>$v['warehouse'],
  8607. 'purchase'=>$v['purchase'],
  8608. 'sku'=>$v['sku'],
  8609. 'title'=>$v['title'],
  8610. 'features'=>$v['features'],
  8611. 'label'=>$v['label'],
  8612. 'orderinfo'=>$v['orderinfo'],
  8613. 'number'=>$number,
  8614. 'waybill'=>$v['waybill'],
  8615. 'retreat'=>$v['retreat'],
  8616. ];
  8617. }
  8618. }
  8619. if(empty($final_list)){
  8620. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8621. }else{
  8622. $end_list = [];
  8623. foreach($final_list as $v){
  8624. $end_list[] = array_values($v);
  8625. }
  8626. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8627. array_unshift($end_list,[
  8628. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8629. ]);
  8630. array_unshift($end_list,[
  8631. $title,"","","","","","","","",""
  8632. ]);
  8633. $merges = [
  8634. [
  8635. "s"=>["r"=>0,"c"=>0],
  8636. "e"=>["r"=>0,"c"=>9]
  8637. ]
  8638. ];
  8639. $cols = [
  8640. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8641. ];
  8642. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8643. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8644. ] )));
  8645. }
  8646. } else if ($type == 5) {
  8647. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8648. foreach ($info_list as $key => $value) {
  8649. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8650. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8651. $warehouse = $this->warehouse->read($value['warehouse']);
  8652. $info_list[$key]['warehouse'] = $warehouse['title'];
  8653. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8654. $features = explode('-', trim($features, '-'));
  8655. $pm = $classid;
  8656. foreach ($features as $k => $v) {
  8657. if ($v != 0) {
  8658. if (!isset($typeclass[$v])) {
  8659. continue;
  8660. }
  8661. if (isset($pm[$typeclass[$v]['classid']])) {
  8662. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8663. $tz = explode('|', $typeclass[$v]['zh']);
  8664. $pm[$typeclass[$v]['classid']] = $tz[0];
  8665. } else {
  8666. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8667. }
  8668. }
  8669. }
  8670. }
  8671. $zh = implode(" ", $pm);
  8672. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8673. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8674. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8675. $info_list[$key]['features'] = $zh;
  8676. }
  8677. if(empty($info_list)){
  8678. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8679. }else{
  8680. $final_list = [];
  8681. foreach($info_list as $v){
  8682. $final_list[] = array_values($v);
  8683. }
  8684. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8685. array_unshift($final_list,[
  8686. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8687. ]);
  8688. array_unshift($final_list,[
  8689. $title,"","","","","","",
  8690. ]);
  8691. $merges = [
  8692. [
  8693. "s"=>["r"=>0,"c"=>0],
  8694. "e"=>["r"=>0,"c"=>6]
  8695. ]
  8696. ];
  8697. $cols = [
  8698. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8699. ];
  8700. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8701. }
  8702. } else {
  8703. $wh = array();
  8704. $w = $this->warehouse->find_all('1=1', 'id,title');
  8705. foreach ($w as $v) {
  8706. $wh[$v['id']] = $v['title'];
  8707. }
  8708. $wt = array();
  8709. $whlabel_type = $this->whlabel_type->find_all();
  8710. foreach ($whlabel_type as $v) {
  8711. $wt[$v['id']] = $v['title'];
  8712. }
  8713. $classid = $this->classid->sku();
  8714. $list = array();
  8715. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8716. foreach ($rows as $key => $value) {
  8717. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8718. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8719. $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');
  8720. $details = array();
  8721. $cpid = array();
  8722. $cpbz = array();
  8723. $c = 0;
  8724. $g = 0;
  8725. $x = 0;
  8726. $t = 0;
  8727. $s = 0;
  8728. $q = 0;
  8729. foreach ($sd as $k => $v) {
  8730. if ($v['state'] == 0) {
  8731. $c++;
  8732. }
  8733. if ($v['state'] != 9) {
  8734. $g++;
  8735. }
  8736. if ($v['outk'] > 1) {
  8737. $x++;
  8738. }
  8739. if ($v['retreat'] > 0) {
  8740. $t++;
  8741. }
  8742. if ($v['state'] == 8) {
  8743. $s++;
  8744. }
  8745. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8746. $q++;
  8747. }
  8748. $details[$v['details']] = $v['details'];
  8749. if ($v['cpid'] != 0) {
  8750. $cpid[$v['cpid']] = $v['cpid'];
  8751. }
  8752. if ($v['cpbz'] != '') {
  8753. $cpbz[$v['cpbz']] = $v['cpbz'];
  8754. }
  8755. }
  8756. if (isset($wt[$value['type']])) {
  8757. $rows[$key]['type'] = $wt[$value['type']];
  8758. } else {
  8759. $rows[$key]['type'] = '未设置';
  8760. }
  8761. $rows[$key]['details'] = implode("、", $details);
  8762. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8763. $ftime = time() - 15 * 24 * 3600;
  8764. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8765. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8766. $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);
  8767. $rows[$key]['c'] = $c;
  8768. $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);
  8769. $rows[$key]['t'] = $t;
  8770. $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'] . '"');
  8771. $rows[$key]['z'] = $z;
  8772. // $jm = $classid;
  8773. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8774. $features = explode('-', trim($features, '-'));
  8775. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8776. }
  8777. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8778. $final_list =[];
  8779. foreach($tmp_list as $k=>$v){
  8780. $final_list[] = [
  8781. "warehouse"=>$v['warehouse'],
  8782. "purchase"=>$v['purchase'],
  8783. "details"=>$v['details'],
  8784. "cpid"=>$v['cpid'],
  8785. "sku"=>$v['sku'],
  8786. "title"=>$v['title'],
  8787. "features"=>$v['pm'],
  8788. "cpbz"=>$v['cpbz'],
  8789. "sm"=>$v['sm'],
  8790. "type"=>$v['type'],
  8791. "g"=>$v["g"],
  8792. "c"=>$v["c"],
  8793. "x"=>$v["x"],
  8794. "t"=>$v["t"],
  8795. "z"=>$v["z"],
  8796. "jm"=>$v["jm"],
  8797. "weight"=>$v["weight"],
  8798. "asd"=>$v["asd"],
  8799. ];
  8800. }
  8801. if(empty($final_list)){
  8802. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8803. }else{
  8804. $end_list = [];
  8805. foreach($final_list as $v){
  8806. $end_list[] = array_values($v);
  8807. }
  8808. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8809. array_unshift($end_list,[
  8810. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8811. ]);
  8812. array_unshift($end_list,[
  8813. $title,"","","","","","","","","","","","","","","","","",""
  8814. ]);
  8815. $merges = [
  8816. [
  8817. "s"=>["r"=>0,"c"=>0],
  8818. "e"=>["r"=>0,"c"=>6]
  8819. ]
  8820. ];
  8821. $cols = [
  8822. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8823. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8824. ];
  8825. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8826. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8827. ])));
  8828. }
  8829. }
  8830. }
  8831. }
  8832. public function _exceljxcjs(){
  8833. $classid = $this->classid->sku();
  8834. $pm = $classid;
  8835. $typeclass = array();
  8836. $tc = $this->typeclass->find_all();
  8837. foreach ($tc as $v) {
  8838. $typeclass[$v['id']] = $v;
  8839. }
  8840. $prc = array();
  8841. $purchase = $this->purchase->find_all();
  8842. foreach ($purchase as $k => $v) {
  8843. $prc[$v['id']] = $v['title'];
  8844. }
  8845. if(!isset($_GET['excel'])){
  8846. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8847. }
  8848. $where = "sku != 'Preset'";
  8849. //数据排序
  8850. $order_str = "id desc";
  8851. if (empty($page)) {
  8852. $start = 0;
  8853. $perpage = 1;
  8854. } else {
  8855. $start = ($page - 1) * $perpage;
  8856. }
  8857. $category = $this->input->get('category', true);
  8858. $warehouse = $this->input->get('warehouse', true);
  8859. $excelid = $this->input->get('sid', true);
  8860. if ($category) {
  8861. $where .= " and features like '%-$category-%'";
  8862. }
  8863. if ($warehouse) {
  8864. $where .= " and warehouse = '$warehouse'";
  8865. }
  8866. $xzid = '';
  8867. if ($excelid) {
  8868. $excelid = explode(',', trim($excelid, ','));
  8869. foreach ($excelid as $key => $value) {
  8870. $xzid .= " id = " . $value . " or";
  8871. }
  8872. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8873. }
  8874. $wt = array();
  8875. $whlabel_type = $this->whlabel_type->find_all();
  8876. foreach ($whlabel_type as $v) {
  8877. $wt[$v['id']] = $v['title'];
  8878. }
  8879. $wh = array();
  8880. $w = $this->warehouse->find_all('1=1', 'id,title');
  8881. foreach ($w as $v) {
  8882. $wh[$v['id']] = $v['title'];
  8883. }
  8884. $list = array();
  8885. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8886. foreach ($rows as $key => $value) {
  8887. if (isset($wt[$value['type']])) {
  8888. $rows[$key]['type'] = $wt[$value['type']];
  8889. } else {
  8890. $rows[$key]['type'] = '未设置';
  8891. }
  8892. $bm = '03';
  8893. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8894. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8895. $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');
  8896. $details = array();
  8897. $cpid = array();
  8898. $cpbz = array();
  8899. $c = 0;
  8900. $g = 0;
  8901. $x = 0;
  8902. $t = 0;
  8903. $s = 0;
  8904. $q = 0;
  8905. foreach ($sd as $k => $v) {
  8906. if ($v['state'] == 0) {
  8907. $c++;
  8908. if ($v['cpid'] != 0) {
  8909. $cpid[$v['cpid']] = $v['cpid'];
  8910. }
  8911. if ($v['cpbz'] != '') {
  8912. $cpbz[$v['cpbz']] = $v['cpbz'];
  8913. }
  8914. }
  8915. if ($v['state'] != 9) {
  8916. $g++;
  8917. }
  8918. if ($v['state'] == 1) {
  8919. $x++;
  8920. }
  8921. if ($v['state'] == 2) {
  8922. $t++;
  8923. }
  8924. if ($v['state'] == 8) {
  8925. $s++;
  8926. }
  8927. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8928. $q++;
  8929. }
  8930. $details[$v['details']] = $v['details'];
  8931. }
  8932. $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'] . '"');
  8933. $rows[$key]['details'] = implode("、", $details);
  8934. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8935. $number = $value['number'];
  8936. $ftime = time() - 15 * 24 * 3600;
  8937. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8938. $rows[$key]['number'] = $g;
  8939. $rows[$key]['c'] = $c;
  8940. $rows[$key]['x'] = $x;
  8941. $rows[$key]['t'] = $t;
  8942. $rows[$key]['s'] = $s;
  8943. $rows[$key]['q'] = $q;
  8944. $rows[$key]['z'] = $z;
  8945. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8946. $features = explode('-', trim($features, '-'));
  8947. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8948. }
  8949. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8950. $final_list = [];
  8951. foreach ($list as $k => $v) {
  8952. if (empty($v['sku'])) {
  8953. continue;
  8954. }
  8955. $final_list[] = [
  8956. $v["warehouse"],
  8957. $v["purchase"],
  8958. $v["details"],
  8959. $v["cpid"],
  8960. $v["dbcontent"],
  8961. $v["sku"],
  8962. $v["bm"],
  8963. $v["jm"],
  8964. $v["title"],
  8965. $v["pm"],
  8966. $v["cpbz"],
  8967. $v["sm"],
  8968. $v["type"],
  8969. $v["number"],
  8970. $v["c"],
  8971. $v["x"],
  8972. $v["t"],
  8973. $v["s"],
  8974. $v["q"],
  8975. $v["z"],
  8976. $v['weight'],
  8977. ];
  8978. }
  8979. if(empty($final_list)){
  8980. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8981. }
  8982. $title = "总进销存统计表";
  8983. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8984. $merges = [
  8985. [
  8986. "s"=>["r"=>0,"c"=>0],
  8987. "e"=>["r"=>0,"c"=>21]
  8988. ]
  8989. ];
  8990. $cols = [
  8991. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8992. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8993. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8994. ];
  8995. array_unshift($final_list, $first_row);
  8996. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8997. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8998. }
  8999. public function _summaryjs($arg_array)
  9000. {
  9001. $prc = array();
  9002. $purchase = $this->purchase->find_all();
  9003. foreach ($purchase as $k => $v) {
  9004. $prc[$v['id']] = $v['title'];
  9005. }
  9006. if (isset($_GET['excel'])) {
  9007. $ktime = $this->input->get('ktime', true);
  9008. $jtime = $this->input->get('jtime', true);
  9009. $ktime = strtotime($ktime);
  9010. $jtime = strtotime($jtime);
  9011. $where = "1=1";
  9012. if ($ktime && $jtime) {
  9013. $where .= " and outk > '$ktime' and outk < '$jtime'";
  9014. }
  9015. //数据排序
  9016. $order_str = "time desc";
  9017. if (empty($page)) {
  9018. $start = 0;
  9019. $perpage = 1;
  9020. } else {
  9021. $start = ($page - 1) * $perpage;
  9022. }
  9023. //取得信息列表
  9024. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  9025. foreach ($info_list as $key => $value) {
  9026. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  9027. $warehouse = $this->warehouse->read($value['warehouse']);
  9028. $info_list[$key]['warehouse'] = $warehouse['title'];
  9029. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  9030. $details = array();
  9031. $cpid = array();
  9032. foreach ($x as $k => $v) {
  9033. if ($v['details'] != '') {
  9034. $details[$v['details']] = $v['details'];
  9035. }
  9036. if ($v['cpid'] != 0) {
  9037. $cpid[$v['cpid']] = $v['cpid'];
  9038. }
  9039. }
  9040. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  9041. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9042. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  9043. $info_list[$key]['s'] = $s;
  9044. $info_list[$key]['x'] = count($x);
  9045. }
  9046. if(empty($info_list)){
  9047. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9048. }
  9049. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  9050. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  9051. $merges = [
  9052. [
  9053. "s"=>["r"=>0,"c"=>0],
  9054. "e"=>["r"=>0,"c"=>7]
  9055. ]
  9056. ];
  9057. $cols = [
  9058. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  9059. ];
  9060. $final_list = [];
  9061. foreach($info_list as $k => $v){
  9062. $final_list[] = array_values($v);
  9063. }
  9064. array_unshift($final_list, $first_row);
  9065. array_unshift($final_list,[
  9066. $title,"","","","","","","","",
  9067. ]);
  9068. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9069. $titlename = "<table border=1>
  9070. <tr align='center'>
  9071. <td>仓库</td>
  9072. <td>供应商</td>
  9073. <td>出库位置</td>
  9074. <td>出库编码</td>
  9075. <td>SKU</td>
  9076. <td>产品名</td>
  9077. <td>总剩余库存</td>
  9078. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  9079. </tr>
  9080. </table>";
  9081. $filename = $title . ".xls";
  9082. $tail = "";
  9083. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  9084. }
  9085. }
  9086. public function _uckjs()
  9087. {
  9088. if (isset($_GET['excel'])) {
  9089. $tc = array();
  9090. $typeclass = $this->typeclass->find_all();
  9091. foreach ($typeclass as $v) {
  9092. $tc[$v['id']] = $v['zh'];
  9093. }
  9094. $first_row = [
  9095. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  9096. ];
  9097. $t = array();
  9098. $rq = '';
  9099. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  9100. $ts = $ts / (24 * 3600);
  9101. for ($i = 0; $i < $ts; $i++) {
  9102. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9103. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9104. }
  9105. $day_len = count($t);
  9106. $first_row[] = "本月出库";
  9107. $merges = [
  9108. ];
  9109. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  9110. $excel_key = 1;
  9111. $final_list = [];
  9112. foreach ($info_list as $k => $v) {
  9113. $features = explode('-', trim($v['features'], '-'));
  9114. if (!isset($features[3]) || !isset($features[4])) {
  9115. continue;
  9116. }
  9117. $tmp = [];
  9118. $tmp[0] = $tc[$features[0]]; //类型
  9119. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  9120. $tmp[2] = $tc[$features[4]]; //曲度
  9121. $tmp[3] = '';
  9122. if (isset($data[$k][1])) {
  9123. $tmp[3] .=$tmp[1];
  9124. }
  9125. if (isset($data[$k][2])) {
  9126. $tmp[3] .= $tmp[2];
  9127. }
  9128. if (isset($features[5])) {
  9129. $tmp[3] .= $tc[$features[5]];
  9130. }
  9131. if (isset($features[2])) {
  9132. $tmp[3] .= $tc[$features[2]];
  9133. }
  9134. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  9135. $tmp[4] = $v['sku'];
  9136. $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())) . '))'); //月初库存
  9137. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  9138. $tmp[7] ="";
  9139. $tmp[8] ="";
  9140. $byck = 0;
  9141. foreach ($t as $vv) {
  9142. $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));
  9143. $tmp[] = ($sl > 0) ? $sl : '';
  9144. $byck += $sl;
  9145. }
  9146. $tmp[] = ($byck > 0) ? $byck : '';
  9147. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  9148. // $ztrq = '';
  9149. // $ztsl = '';
  9150. // if (count($zt) > 0) {
  9151. // foreach ($zt as $vv) {
  9152. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  9153. // $ztsl .= $vv['num'] . '<br>';
  9154. // }
  9155. // }
  9156. if(empty($zt)){
  9157. $final_list[] = $tmp;
  9158. $excel_key = $excel_key + 1;
  9159. }else{
  9160. $len = count($zt);
  9161. if($len == 1){
  9162. $tmp[7] = $zt[0]['num'] ;
  9163. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  9164. $final_list[] = $tmp;
  9165. $excel_key = $excel_key + 1;
  9166. }else{
  9167. foreach($zt as $vv){
  9168. $tmp[7] = "";
  9169. $tmp[8] = "";
  9170. $tmp[7] = $vv['num'];
  9171. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9172. $final_list[] = $tmp;
  9173. }
  9174. $merges[] = [
  9175. "s"=>["r"=>$excel_key,"c"=>0],
  9176. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9177. ];
  9178. $merges[] = [
  9179. "s"=>["r"=>$excel_key,"c"=>1],
  9180. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9181. ];
  9182. $merges[] = [
  9183. "s"=>["r"=>$excel_key,"c"=>2],
  9184. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9185. ];
  9186. $merges[] = [
  9187. "s"=>["r"=>$excel_key,"c"=>3],
  9188. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9189. ];
  9190. $merges[] = [
  9191. "s"=>["r"=>$excel_key,"c"=>4],
  9192. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9193. ];
  9194. $merges[] = [
  9195. "s"=>["r"=>$excel_key,"c"=>5],
  9196. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9197. ];
  9198. $merges[] = [
  9199. "s"=>["r"=>$excel_key,"c"=>6],
  9200. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9201. ];
  9202. for($i=1;$i<=$day_len;$i++){
  9203. $merges[] = [
  9204. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9205. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9206. ];
  9207. }
  9208. $merges[] = [
  9209. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9210. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9211. ];
  9212. $excel_key = $excel_key + $len;
  9213. }
  9214. }
  9215. }
  9216. $title = "详情 " . date("Y-m-d", time());
  9217. if(empty($final_list)){
  9218. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9219. }
  9220. $cols = [
  9221. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9222. ];
  9223. array_unshift($final_list, $first_row);
  9224. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9225. }
  9226. }
  9227. public function _whlabelexcelzhjs(){
  9228. if(empty($_GET['excel'])){
  9229. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9230. }
  9231. $where = "sku != 'Preset' and sku != '' ";
  9232. //数据排序
  9233. $order_str = "id desc";
  9234. if (empty($page)) {
  9235. $start = 0;
  9236. $perpage = 1;
  9237. } else {
  9238. $start = ($page - 1) * $perpage;
  9239. }
  9240. $category = $this->input->get('category', true);
  9241. $warehouse = $this->input->get('warehouse', true);
  9242. $excelid = $this->input->get('sid', true);
  9243. if ($category) {
  9244. $where .= " and features like '%-$category-%'";
  9245. }
  9246. if ($warehouse) {
  9247. $where .= " and warehouse = '$warehouse'";
  9248. }
  9249. $xzid = '';
  9250. if ($excelid) {
  9251. $excelid = explode(',', trim($excelid, ','));
  9252. foreach ($excelid as $key => $value) {
  9253. $xzid .= " id = " . $value . " or";
  9254. }
  9255. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9256. }
  9257. $merges = [
  9258. [
  9259. "s"=>["r"=>0,"c"=>0],
  9260. "e"=>["r"=>0,"c"=>6]
  9261. ]
  9262. ];
  9263. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9264. $excel_index = 2;
  9265. $final_list = [];
  9266. foreach ($rows as $key => $value) {
  9267. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9268. $zh = '';
  9269. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9270. // foreach ($zt_list as $v) {
  9271. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9272. // }
  9273. $zt = array_sum(array_column($zt_list, 'num'));
  9274. $number = $value['number'];
  9275. $ftime = time() - 15 * 24 * 3600;
  9276. $warehouse = $this->warehouse->read($value['warehouse']);
  9277. // $rows[$key]['warehouse'] = $warehouse['title'];
  9278. // $rows[$key]['number'] = $c;
  9279. // $rows[$key]['features'] = $zh;
  9280. //$rows[$key]['hb'] = $c + $zt;
  9281. $tmp = [];
  9282. $tmp[0] = $warehouse['title'];
  9283. $tmp[1] = $value['sku'];
  9284. $tmp[2] = $value['title'];
  9285. $tmp[3] = $c;
  9286. $tmp[4] = "";
  9287. $tmp[5] = $c + $zt;
  9288. if(empty($zt_list)){
  9289. $tmp[4] = "";
  9290. $final_list[] = $tmp;
  9291. $excel_index = $excel_index + 1;
  9292. }else{
  9293. if(count($zt_list) == 1){
  9294. $tmp[4] = "";
  9295. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9296. $final_list[] = $tmp;
  9297. $excel_index = $excel_index + 1;
  9298. }else{
  9299. $len = count($zt_list);
  9300. foreach ($zt_list as $v){
  9301. $tmp[4] = "";
  9302. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9303. $final_list[] = $tmp;
  9304. }
  9305. $merges[] = [
  9306. "s"=>["r"=>$excel_index,"c"=>0],
  9307. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9308. ];
  9309. $merges[] = [
  9310. "s"=>["r"=>$excel_index,"c"=>1],
  9311. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9312. ];
  9313. $merges[] = [
  9314. "s"=>["r"=>$excel_index,"c"=>2],
  9315. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9316. ];
  9317. $merges[] = [
  9318. "s"=>["r"=>$excel_index,"c"=>3],
  9319. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9320. ];
  9321. $merges[] = [
  9322. "s"=>["r"=>$excel_index,"c"=>5],
  9323. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9324. ];
  9325. $excel_index = $excel_index + $len;
  9326. }
  9327. }
  9328. }
  9329. $first_row = [
  9330. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9331. ];
  9332. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9333. if(empty($final_list)){
  9334. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9335. }
  9336. $cols = [
  9337. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9338. ];
  9339. array_unshift($final_list, $first_row);
  9340. array_unshift($final_list, [
  9341. $title,"","","","",""
  9342. ]);
  9343. $end_list = [];
  9344. foreach ($final_list as $key => $value) {
  9345. $end_list[] = array_values($value);
  9346. }
  9347. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9348. }
  9349. //出库、退库导出
  9350. public function _dccrtypejs()
  9351. {
  9352. $classid = $this->classid->sku();
  9353. $pm = $classid;
  9354. $typeclass = array();
  9355. $tc = $this->typeclass->find_all();
  9356. foreach ($tc as $v) {
  9357. $typeclass[$v['id']] = $v;
  9358. }
  9359. $prc = array();
  9360. $purchase = $this->purchase->find_all();
  9361. foreach ($purchase as $k => $v) {
  9362. $prc[$v['id']] = $v['title'];
  9363. }
  9364. if (isset($_GET['sid'])) {
  9365. $wh = array();
  9366. $w = $this->warehouse->find_all('1=1', 'id,title');
  9367. foreach ($w as $v) {
  9368. $wh[$v['id']] = $v['title'];
  9369. }
  9370. $type = $this->input->get('excel', true);
  9371. $category = $this->input->get('category', true);
  9372. $size = $this->input->get('size', true);
  9373. $grade = $this->input->get('grade', true);
  9374. $color = $this->input->get('color', true);
  9375. $lowe = $this->input->get('lowe', true);
  9376. $sku = $this->input->get('sku', true);
  9377. $warehouse = $this->input->get('warehouse', true);
  9378. $lacetype = $this->input->get('lacetype', true);
  9379. $lacecolor = $this->input->get('lacecolor', true);
  9380. $density = $this->input->get('density', true);
  9381. $haircap = $this->input->get('haircap', true);
  9382. $purchase = $this->input->get('purchase', true);
  9383. $title = $this->input->get('title', true);
  9384. $state = $this->input->get('state', true);
  9385. $sid = $this->input->get('sid', true);
  9386. $ktime = $this->input->get('ktime', true);
  9387. $jtime = $this->input->get('jtime', true);
  9388. $ktime = strtotime($ktime);
  9389. $jtime = strtotime($jtime);
  9390. $where = "1=1";
  9391. $gj = "";
  9392. $ck = "";
  9393. if ($category) {
  9394. $where .= " and features like '%-$category-%'";
  9395. }
  9396. if ($size) {
  9397. $where .= " and features like '%-$size-%'";
  9398. }
  9399. if ($grade) {
  9400. $where .= " and features like '%-$grade-%'";
  9401. }
  9402. if ($color) {
  9403. $where .= " and features like '%-$color-%'";
  9404. }
  9405. if ($lowe) {
  9406. $where .= " and features like '%-$lowe-%'";
  9407. }
  9408. if ($warehouse) {
  9409. $where .= " and warehouse = '$warehouse'";
  9410. }
  9411. if ($purchase) {
  9412. $where .= " and purchase = '$purchase'";
  9413. }
  9414. if ($state) {
  9415. $where .= " and state = '$state'";
  9416. }
  9417. if ($lacetype) {
  9418. $where .= " and features like '%-$lacetype-%'";
  9419. }
  9420. if ($lacecolor) {
  9421. $where .= " and features like '%-$lacecolor-%'";
  9422. }
  9423. if ($density) {
  9424. $where .= " and features like '%-$density-%'";
  9425. }
  9426. if ($haircap) {
  9427. $where .= " and features like '%-$haircap-%'";
  9428. }
  9429. if ($title) {
  9430. $title = trim($title, ' ');
  9431. $title = trim($title, ' ');
  9432. $where .= " and title like '%$title%'";
  9433. }
  9434. if ($sku) {
  9435. $sku = trim($sku, ' ');
  9436. $sku = trim($sku, ' ');
  9437. $where .= " and sku like '%$sku%'";
  9438. }
  9439. if ($ktime && $jtime) {
  9440. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9441. }
  9442. $sidwhere = '';
  9443. if ($sid) {
  9444. $sd = "";
  9445. $s = explode(',', trim($sid, ','));
  9446. foreach ($s as $value) {
  9447. $sd .= " id = " . $value . " or";
  9448. }
  9449. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9450. }
  9451. //数据排序
  9452. $order_str = "time desc";
  9453. if (empty($page)) {
  9454. $start = 0;
  9455. $perpage = 1;
  9456. } else {
  9457. $start = ($page - 1) * $perpage;
  9458. }
  9459. $wh = array();
  9460. $w = $this->warehouse->find_all('1=1', 'id,title');
  9461. foreach ($w as $v) {
  9462. $wh[$v['id']] = $v['title'];
  9463. }
  9464. $wt = array();
  9465. $whlabel_type = $this->whlabel_type->find_all();
  9466. foreach ($whlabel_type as $v) {
  9467. $wt[$v['id']] = $v['title'];
  9468. }
  9469. $classid = $this->classid->sku();
  9470. $list = array();
  9471. $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');
  9472. foreach ($rows_r as $key => $value) {
  9473. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9474. $pm = $classid;
  9475. $jm = $classid;
  9476. $rows_r[$key]['enter'] = '入库';
  9477. $rows_r[$key]['time'] = $value['enter'];
  9478. if ($value['rktype'] == 1) {
  9479. $rows_r[$key]['rktype'] = '采购入库';
  9480. } else if ($value['rktype'] == 2) {
  9481. $rows_r[$key]['rktype'] = '盘盈调整';
  9482. } else if ($value['rktype'] == 3) {
  9483. $rows_r[$key]['rktype'] = '其他调整入库';
  9484. } else if ($value['rktype'] == 4) {
  9485. $rows_r[$key]['rktype'] = '其他调整入库';
  9486. } else if ($value['rktype'] == 5) {
  9487. $rows_r[$key]['rktype'] = '退库入库';
  9488. } else if ($value['rktype'] == 6) {
  9489. $rows_r[$key]['rktype'] = '退货可用入库';
  9490. } else if ($value['rktype'] == 7) {
  9491. $rows_r[$key]['rktype'] = '形态转换入库';
  9492. } else {
  9493. $rows_r[$key]['rktype'] = '';
  9494. }
  9495. $features = explode('-', trim($value['features'], '-'));
  9496. foreach ($features as $v) {
  9497. if (isset($typeclass[$v])) {
  9498. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9499. $pm[$typeclass[$v]['classid']] = $zh[0];
  9500. }
  9501. if (isset($typeclass[$v])) {
  9502. if (isset($jm[$typeclass[$v]['classid']])) {
  9503. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9504. }
  9505. }
  9506. }
  9507. $zh = implode(" ", $pm);
  9508. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9509. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9510. $rows_r[$key]['zh'] = $zh;
  9511. $jm = array_filter($jm);
  9512. $rows_r[$key]['features'] = implode("-", $jm);
  9513. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9514. }
  9515. $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');
  9516. foreach ($rows_c as $key => $value) {
  9517. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9518. $pm = $classid;
  9519. $jm = $classid;
  9520. $rows_c[$key]['time'] = $value['outk'];
  9521. $rows_c[$key]['outk'] = '出库';
  9522. if ($value['cktype'] == 1) {
  9523. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9524. } else if ($value['cktype'] == 2) {
  9525. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9526. } else if ($value['cktype'] == 3) {
  9527. $rows_c[$key]['cktype'] = '盘亏调整';
  9528. } else if ($value['cktype'] == 4) {
  9529. $rows_c[$key]['cktype'] = '其他调整出库';
  9530. } else if ($value['cktype'] == 5) {
  9531. $rows_c[$key]['cktype'] = '形态转换出库';
  9532. } else {
  9533. $rows_c[$key]['cktype'] = '';
  9534. }
  9535. unset($rows_c[$key]['state']);
  9536. $features = explode('-', trim($value['features'], '-'));
  9537. foreach ($features as $v) {
  9538. if (isset($typeclass[$v])) {
  9539. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9540. $pm[$typeclass[$v]['classid']] = $zh[0];
  9541. }
  9542. if (isset($typeclass[$v])) {
  9543. if (isset($jm[$typeclass[$v]['classid']])) {
  9544. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9545. }
  9546. }
  9547. }
  9548. $zh = implode(" ", $pm);
  9549. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9550. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9551. $rows_c[$key]['zh'] = $zh;
  9552. $jm = array_filter($jm);
  9553. $rows_c[$key]['features'] = implode("-", $jm);
  9554. $rows_c[$key]['number'] = 1;
  9555. }
  9556. $merged = $rows_r;
  9557. foreach ($rows_c as $key => $value) {
  9558. if (isset($merged[$key])) {
  9559. $merged[] = $value;
  9560. } else {
  9561. $merged[$key] = $value;
  9562. }
  9563. }
  9564. usort($merged, function ($a, $b) {
  9565. return $a['time'] - $b['time'];
  9566. });
  9567. foreach ($merged as $key => $value) {
  9568. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9569. }
  9570. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9571. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9572. $cols = [
  9573. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9574. ];
  9575. $final_list= [];
  9576. foreach($merged as $key => $value){
  9577. $final_list[] = array_values($value) ;
  9578. }
  9579. if(empty($merged)){
  9580. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9581. }
  9582. array_unshift($final_list, $first_row);
  9583. $end_list = [];
  9584. foreach ($final_list as $key => $value) {
  9585. $end_list[] = array_values($value);
  9586. }
  9587. $merges = [];
  9588. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9589. }
  9590. }
  9591. public function _errorexceljs()
  9592. {
  9593. $post = $this->input->post(NULL, TRUE);
  9594. if (isset($_GET['page'])) {
  9595. $page = $this->input->get('page', true);
  9596. $perpage = $this->input->get('perpage', true);
  9597. $sku = $this->input->get('sku', true);
  9598. $warehouse = $this->input->get('warehouse', true);
  9599. $ktime = $this->input->get('ktime', true);
  9600. $jtime = $this->input->get('jtime', true);
  9601. $ktime = strtotime($ktime);
  9602. $jtime = strtotime($jtime);
  9603. $where = "sku != 'Preset'";
  9604. $gj = '';
  9605. if ($sku) {
  9606. $where .= " and sku like '%$sku%'";
  9607. } else {
  9608. if ($ktime && $jtime) {
  9609. $gj = " and time > '$ktime' and time < '$jtime'";
  9610. }
  9611. }
  9612. if ($warehouse) {
  9613. $where .= " and warehouse = '$warehouse'";
  9614. }
  9615. //数据排序
  9616. $order_str = "id desc";
  9617. if (empty($page)) {
  9618. $start = 0;
  9619. $perpage = 1;
  9620. } else {
  9621. $start = ($page - 1) * $perpage;
  9622. }
  9623. //取得信息列表
  9624. $rows = array();
  9625. $list = array();
  9626. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9627. foreach ($info_list as $value) {
  9628. $warehouse = $this->warehouse->read($value['warehouse']);
  9629. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9630. $number = $value['number'];
  9631. $ftime = time() - 15 * 24 * 3600;
  9632. if ($c < 1) {
  9633. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9634. }
  9635. }
  9636. $title = "0库存汇总";
  9637. $first_row = ["仓库","SKU","产品","当前库存"];
  9638. $cols = [
  9639. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9640. ];
  9641. $final_list= [];
  9642. foreach($list as $key => $value){
  9643. $final_list[] = array_values($value) ;
  9644. }
  9645. if(empty($final_list)){
  9646. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9647. }
  9648. array_unshift($final_list, $first_row);
  9649. $merges = [];
  9650. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9651. }
  9652. }
  9653. }