Whlabel.php 331 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. }else if ($arg == 'typev1') //进销存浏览
  62. {
  63. $this->_typev1();
  64. } else if ($arg == 'typedy') //进销存浏览店员页面
  65. {
  66. $this->_typedy($arg_array);
  67. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  68. {
  69. $this->_typedy_ck($arg_array);
  70. } else if ($arg == 'typeck') {
  71. $this->_typeck($arg_array);
  72. } else if ($arg == 'whlabeckdc') {
  73. $this->_whlabeckdc($arg_array);
  74. } else if ($arg == 'usatype') //美仓进销存浏览
  75. {
  76. $this->_usatype();
  77. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  78. {
  79. $this->_usatypeapp();
  80. } else if ($arg == 'enteradd') //入库操作
  81. {
  82. $this->_enteradd();
  83. } else if ($arg == 'enteredit') //修改
  84. {
  85. $this->_enteredit($arg_array);
  86. } else if ($arg == 'enter') //入库浏览
  87. {
  88. $this->_enter();
  89. } else if ($arg == 'out') //出库浏览
  90. {
  91. $this->_out();
  92. } else if ($arg == 'label') //出库标签浏览
  93. {
  94. $this->_label();
  95. } else if ($arg == 'outorder') //独立站出库订单
  96. {
  97. $this->_outorder();
  98. } else if ($arg == 'soutorder') //速卖通出库订单
  99. {
  100. $this->_soutorder();
  101. } else if ($arg == 'toutorder') //TT出库订单
  102. {
  103. $this->_toutorder();
  104. }else if ($arg == 'aoutorder') //amz出库订单
  105. {
  106. $this->_aoutorder();
  107. } else if ($arg == 'retreat') //退库订单
  108. {
  109. $this->_retreat();
  110. } else if ($arg == 'retreatlk') //退库订单
  111. {
  112. $this->_retreatlk();
  113. } else if ($arg == 'change') //更换标签
  114. {
  115. $this->_change();
  116. } else if ($arg == 'del') //删除
  117. {
  118. $this->_del();
  119. } else if ($arg == 'exceljxc') //进销存信息导出
  120. {
  121. $this->_exceljxc();
  122. } else if ($arg == 'excelr') //入库信息导出
  123. {
  124. $this->_excelr();
  125. } else if ($arg == 'excelct') //出库、退库信息导出
  126. {
  127. $this->_excelct();
  128. } else if ($arg == 'dccrtype') //根据出入库类型导出
  129. {
  130. $this->_dccrtype();
  131. } else if ($arg == 'excelcr') //出库、退库信息导出
  132. {
  133. $this->_excelcr();
  134. } else if ($arg == 'kcyz') //库存验证
  135. {
  136. $this->_kcyz();
  137. } else if ($arg == 'kj') //库存扣减
  138. {
  139. $this->_kj($arg_array);
  140. } else if ($arg == 'presetout') //预设库存导入
  141. {
  142. $this->_presetout($arg_array);
  143. } else if ($arg == 'presetedit') //预设库存导入
  144. {
  145. $this->_presetedit($arg_array);
  146. }else if ($arg == 'presetedittwo') //预设库存导入
  147. {
  148. $this->_presetedittwo($arg_array);
  149. } else if ($arg == 'summary') //汇总导出
  150. {
  151. $this->_summary($arg_array);
  152. } else if ($arg == 'manifest') //usps发货清单
  153. {
  154. $this->_manifest();
  155. } else if ($arg == 'abnormal') //占单异常
  156. {
  157. $this->_abnormal();
  158. } else if ($arg == 'error') //0库存SKU
  159. {
  160. $this->_error();
  161. } else if ($arg == 'errorexcel') //0库存SKU导出
  162. {
  163. $this->_errorexcel();
  164. } else if ($arg == 'db') {
  165. $this->_db();
  166. } else if ($arg == 'dbrk') {
  167. $this->_dbrk();
  168. } else if ($arg == 'whlabelczdc') {
  169. $this->_whlabelczdc();
  170. } else if ($arg == 'print') {
  171. $this->_print($arg_array);
  172. } else if ($arg == 'usaprint') {
  173. $this->_usaprint($arg_array);
  174. } else if ($arg == 'printck') {
  175. $this->_printck($arg_array);
  176. } else if ($arg == 'printrk') {
  177. $this->_printrk($arg_array);
  178. } else if ($arg == 'printxzrk') {
  179. $this->_printxzrk($arg_array);
  180. } else if ($arg == 'printexcel') {
  181. $this->_printexcel($arg_array);
  182. } else if ($arg == 'uck') {
  183. $this->_uck();
  184. } else if ($arg == 'whlabelexcelzh') {
  185. $this->_whlabelexcelzh();
  186. } else if ($arg == 'fc') {
  187. $this->_fc();
  188. } else if ($arg == 'fcmb') {
  189. $this->_fcmb();
  190. } else if ($arg == 'fcexcel') {
  191. $this->_fcexcel();
  192. } else if ($arg == 'fcjxc') {
  193. $this->_fcjxc($arg_array);
  194. } else if ($arg == '0kcdel') {
  195. $this->_0kcdel(); //导表删除0库存
  196. } else if ($arg == 'gbhtype') {
  197. $this->_gbhtype(); //更改备货状态
  198. } else if($arg == 'excelrjs'){
  199. $this->_excelrjs();
  200. } else if($arg == 'excelctjs'){
  201. $this->_excelctjs();
  202. }else if ($arg == 'exceljxcjs') //进销存信息导出
  203. {
  204. $this->_exceljxcjs();
  205. } else if ($arg == 'summaryjs') //汇总导出
  206. {
  207. $this->_summaryjs($arg_array);
  208. }else if($arg == 'uckjs'){
  209. $this->_uckjs();
  210. }else if ($arg == 'whlabelexcelzhjs') {
  211. $this->_whlabelexcelzhjs();
  212. }else if($arg == 'dccrtypejs'){
  213. $this->_dccrtypejs();
  214. }else if($arg == 'errorexceljs'){
  215. $this->_errorexceljs();
  216. }else if($arg == "w_t_cs"){
  217. $this->_w_t_cs(); //首页
  218. }else {
  219. $this->_index();
  220. }
  221. }
  222. public function _w_t_cs(){
  223. $vip = 0;
  224. if (isset($_SESSION['api'])) {
  225. $user = $this->user->get_api($_SESSION['api']);
  226. $fgshop = "";
  227. $sid = "";
  228. $usersp = explode('|', trim($user['shop'], '|'));
  229. foreach ($usersp as $value) {
  230. $fgshop .= " shop = " . $value . " or";
  231. $sid .= " id = " . $value . " or";
  232. }
  233. if ($user['vip'] == 1) {
  234. $vip = 1;
  235. }
  236. } else {
  237. header('Location: /');
  238. exit;
  239. }
  240. $prc = array();
  241. $purchase = $this->purchase->find_all();
  242. foreach ($purchase as $k => $v) {
  243. $prc[$v['id']] = $v['title'];
  244. }
  245. $company = array();
  246. $ct = $this->company->find_all();
  247. foreach ($ct as $k => $v) {
  248. $company[$v['id']] = $v['title'];
  249. }
  250. $sp = array();
  251. $s = $this->shop->find_all('1=1', 'id,shopname');
  252. foreach ($s as $v) {
  253. $sp[$v['id']] = $v['shopname'];
  254. }
  255. $wh = array();
  256. $w = $this->warehouse->find_all('1=1', 'id,title');
  257. foreach ($w as $v) {
  258. $wh[$v['id']] = $v['title'];
  259. }
  260. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  261. $this->data['shop'] = $wlshop;
  262. $this->data['vip'] = $vip;
  263. $this->_Template('whlabel_typejs', $this->data);
  264. }
  265. //管理
  266. public function _index()
  267. {
  268. $post = $this->input->post(NULL, TRUE);
  269. if (isset($post['page'])) {
  270. $page = $this->input->post('page', true);
  271. $perpage = $this->input->post('perpage', true);
  272. $sku = $this->input->post('sku', true);
  273. $number = $this->input->post('number', true);
  274. $warehouse = $this->input->post('warehouse', true);
  275. $purchase = $this->input->post('purchase', true);
  276. $orderinfo = $this->input->post('orderinfo', true);
  277. $waybill = $this->input->post('waybill', true);
  278. $category = $this->input->post('category', true);
  279. $size = $this->input->post('size', true);
  280. $grade = $this->input->post('grade', true);
  281. $color = $this->input->post('color', true);
  282. $lowe = $this->input->post('lowe', true);
  283. $state = $this->input->post('state', true);
  284. $label = $this->input->post('label', true);
  285. $timetk = $this->input->post('timetkk', true);
  286. $timetj = $this->input->post('timetjj', true);
  287. $timetk = strtotime($timetk);
  288. $timetj = strtotime($timetj);
  289. $where = "1=1 ";
  290. if ($timetk && $timetj) {
  291. $where .= " and time > '$timetk' and time < '$timetj'";
  292. }
  293. if ($sku) {
  294. $where .= " and sku = '$sku'";
  295. }
  296. if ($number) {
  297. $where .= " and number = '$number'";
  298. }
  299. if ($warehouse) {
  300. $where .= " and warehouse = '$warehouse'";
  301. }
  302. if ($purchase) {
  303. $where .= " and purchase = '$purchase'";
  304. }
  305. if ($orderinfo) {
  306. $where .= " and orderinfo = '$orderinfo'";
  307. }
  308. if ($waybill) {
  309. $where .= " and waybill = '$waybill'";
  310. }
  311. if ($category) {
  312. $where .= " and features like '%-$category-%'";
  313. }
  314. if ($size) {
  315. $where .= " and features like '%-$size-%'";
  316. }
  317. if ($grade) {
  318. $where .= " and features like '%-$grade-%'";
  319. }
  320. if ($color) {
  321. $where .= " and features like '%-$color-%'";
  322. }
  323. if ($lowe) {
  324. $where .= " and features like '%-$lowe-%'";
  325. }
  326. if ($label) {
  327. $where .= " and label = '$label'";
  328. }
  329. if ($state != '') {
  330. $where .= " and state = '$state'";
  331. }
  332. //数据排序
  333. $order_str = "time desc";
  334. if (empty($page)) {
  335. $start = 0;
  336. $perpage = 1;
  337. } else {
  338. $start = ($page - 1) * $perpage;
  339. }
  340. //取得信息列表
  341. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  342. foreach ($info_list as $key => $value) {
  343. $warehouse = $this->warehouse->read($value['warehouse']);
  344. $info_list[$key]['warehouse'] = $warehouse['title'];
  345. $purchase = $this->purchase->read($value['purchase']);
  346. $info_list[$key]['purchase'] = $purchase['title'];
  347. if ($value['enter'] != 0) {
  348. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  349. } else {
  350. $info_list[$key]['enter'] = "";
  351. }
  352. if ($value['outk'] != 0) {
  353. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  354. } else {
  355. $info_list[$key]['outk'] = "";
  356. }
  357. if ($value['printing'] != 0) {
  358. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  359. } else {
  360. $info_list[$key]['printing'] = "";
  361. }
  362. if ($value['orderinfo'] == 0) {
  363. $info_list[$key]['orderinfo'] = "";
  364. }
  365. if ($value['waybill'] == 0) {
  366. $info_list[$key]['waybill'] = "";
  367. }
  368. if ($value['state'] == 0) {
  369. $info_list[$key]['state'] = "在库";
  370. } else if ($value['state'] == 1) {
  371. $info_list[$key]['state'] = "出库";
  372. } else if ($value['state'] == 2) {
  373. $info_list[$key]['state'] = "退库";
  374. } else if ($value['state'] == 3) {
  375. $info_list[$key]['state'] = "调拨中";
  376. } else if ($value['state'] == 4) {
  377. $info_list[$key]['state'] = "再加工";
  378. } else if ($value['state'] == 5) {
  379. $info_list[$key]['state'] = "维修中";
  380. } else if ($value['state'] == 6) {
  381. $info_list[$key]['state'] = "盘亏";
  382. } else if ($value['state'] == 7) {
  383. $info_list[$key]['state'] = "更换标签";
  384. } else if ($value['state'] == 8) {
  385. $info_list[$key]['state'] = "其它";
  386. } else if ($value['state'] == 9) {
  387. $info_list[$key]['state'] = "预设";
  388. } else if ($value['state'] == 10) {
  389. $info_list[$key]['state'] = "美店零售";
  390. }
  391. if ($value['text'] == "") {
  392. $info_list[$key]['text'] = "";
  393. }
  394. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  395. }
  396. $total = $this->whlabel->find_count($where);
  397. $pagenum = ceil($total / $perpage);
  398. $over = $total - ($start + $perpage);
  399. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  400. echo json_encode($rows);
  401. exit;
  402. }
  403. if (isset($post['outsku'])) {
  404. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  405. $cz = $this->input->post('cz', true);
  406. if ($cz == '1') {
  407. $sku = $this->input->post('outsku', true);
  408. if ($sku) {
  409. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  410. if (count($data) < 1) {
  411. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  412. exit;
  413. }
  414. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  415. echo json_encode(array('success' => true));
  416. exit;
  417. }
  418. } else {
  419. $sku = $this->input->post('outsku', true);
  420. if ($sku) {
  421. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  422. if (count($data) < 1) {
  423. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  424. exit;
  425. }
  426. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  427. echo json_encode(array('success' => true));
  428. exit;
  429. }
  430. }
  431. }
  432. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  433. $this->_Template('whlabel', $this->data);
  434. }
  435. //在库标签
  436. public function _existence()
  437. {
  438. $post = $this->input->post(NULL, TRUE);
  439. if (isset($post['s'])) {
  440. $id_arr = $this->input->post('s');
  441. $id_arr = explode(',', $id_arr);
  442. if (!$id_arr) {
  443. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  444. exit;
  445. }
  446. //循环删除记录
  447. foreach ($id_arr as $v) {
  448. $sid = $this->whlabel->read($v);
  449. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  450. if ($count > 0) {
  451. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  452. exit;
  453. }
  454. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  455. if (count($zt) > 0) {
  456. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  457. exit;
  458. }
  459. $this->whlabel->remove($v);
  460. }
  461. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  462. exit;
  463. }
  464. if (isset($post['page'])) {
  465. $page = $this->input->post('page', true);
  466. $perpage = $this->input->post('perpage', true);
  467. $warehouse = $this->input->post('warehouse', true);
  468. $label = $this->input->post('label', true);
  469. $where = "1=1 and state = 0";
  470. if ($warehouse) {
  471. $where .= " and warehouse = '$warehouse'";
  472. }
  473. if ($label) {
  474. $where .= " and label = '$label'";
  475. }
  476. //数据排序
  477. $order_str = "time asc";
  478. if (empty($page)) {
  479. $start = 0;
  480. $perpage = 1;
  481. } else {
  482. $start = ($page - 1) * $perpage;
  483. }
  484. //取得信息列表
  485. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  486. foreach ($info_list as $key => $value) {
  487. if ($value['enter'] != 0) {
  488. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  489. } else {
  490. $info_list[$key]['enter'] = "";
  491. }
  492. if ($value['printing'] != 0) {
  493. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  494. } else {
  495. $info_list[$key]['printing'] = "";
  496. }
  497. }
  498. $total = $this->whlabel->find_count($where);
  499. $pagenum = ceil($total / $perpage);
  500. $over = $total - ($start + $perpage);
  501. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  502. echo json_encode($rows);
  503. exit;
  504. }
  505. $this->_Template('whlabel_existence', $this->data);
  506. }
  507. //进销存浏览
  508. public function _typedy($arg_array)
  509. {
  510. $prc = array();
  511. $purchase = $this->purchase->find_all();
  512. foreach ($purchase as $k => $v) {
  513. $prc[$v['id']] = $v['title'];
  514. }
  515. $post = $this->input->post(NULL, TRUE);
  516. if (isset($post['page'])) {
  517. $page = $this->input->post('page', true);
  518. $perpage = $this->input->post('perpage', true);
  519. $category = $this->input->post('category', true);
  520. $size = $this->input->post('size', true);
  521. $grade = $this->input->post('grade', true);
  522. $color = $this->input->post('color', true);
  523. $lowe = $this->input->post('lowe', true);
  524. $sku = $this->input->post('sku');
  525. $title = $this->input->post('title');
  526. $warehouse = $this->input->post('warehouse', true);
  527. $usa = $this->input->post('usa', true);
  528. $purchase = $this->input->post('purchase', true);
  529. $lacetype = $this->input->post('lacetype', true);
  530. $haircap = $this->input->post('haircap', true);
  531. $density = $this->input->post('density', true);
  532. $details = $this->input->post('details', true);
  533. $state = $this->input->post('state', true);
  534. $lacecolor = $this->input->post('lacecolor', true);
  535. $hairnumber = $this->input->post('hairnumber', true);
  536. $cklx = $this->input->post('cklx', true);
  537. $ktime = $this->input->post('ktime', true);
  538. $jtime = $this->input->post('jtime', true);
  539. $sm = $this->input->post('sm', true);
  540. $cpbz = $this->input->post('cpbz', true);
  541. $type = $this->input->post('type', true);
  542. $ktime = strtotime($ktime);
  543. $jtime = strtotime($jtime);
  544. $where = "1=1";
  545. $gj = "";
  546. $ck = "";
  547. if ($usa) {
  548. if (!$warehouse) {
  549. $where .= " and (warehouse = '5' or warehouse = '8')";
  550. }
  551. }
  552. if ($warehouse) {
  553. $where .= " and warehouse = '$warehouse'";
  554. }
  555. if ($details) {
  556. $where .= " and details = '$details'";
  557. }
  558. if ($purchase) {
  559. $where .= " and purchase = '$purchase'";
  560. }
  561. if (isset($state)) {
  562. if($state >-1){
  563. $where .= " and state = '$state'";
  564. }
  565. }
  566. if ($lacetype) {
  567. $where .= " and features like '%-$lacetype-%'";
  568. }
  569. if ($category) {
  570. $where .= " and features like '%-$category-%'";
  571. }
  572. if ($size) {
  573. $where .= " and features like '%-$size-%'";
  574. }
  575. if ($grade) {
  576. $where .= " and features like '%-$grade-%'";
  577. }
  578. if ($color) {
  579. $where .= " and features like '%-$color-%'";
  580. }
  581. if ($lowe) {
  582. $where .= " and features like '%-$lowe-%'";
  583. }
  584. if ($haircap) {
  585. $where .= " and features like '%-$haircap-%'";
  586. }
  587. if ($density) {
  588. $where .= " and features like '%-$density-%'";
  589. }
  590. if ($lacecolor) {
  591. $where .= " and features like '%-$lacecolor-%'";
  592. }
  593. if($sm){
  594. $where .= " and sm like '%".$sm."%'";
  595. }
  596. if($cpbz){
  597. $where .= " and cpbz like '%".$cpbz."%'";
  598. }
  599. if($type){
  600. $where .= " and type = ".$type."";
  601. }
  602. if (!empty($hairnumber)) {
  603. $where .= " and features like '%-128-%' ";
  604. if ($hairnumber < 0) {
  605. $class_list = $this->typeclass->find_all('classid = 43');
  606. foreach ($class_list as $v) {
  607. $where .= " and features not like '%-" . $v['id'] . "-%'";
  608. }
  609. } else {
  610. $where .= " and features like '%-$hairnumber-%'";
  611. }
  612. }
  613. $where_add = '';
  614. if ($cklx) {
  615. $shop = $this->shop->read($cklx);
  616. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  617. }
  618. if ($ktime && $jtime) {
  619. $gj = " and enter > '$ktime' and enter < '$jtime'";
  620. $ck = " and outk > '$ktime' and outk < '$jtime'";
  621. }
  622. //数据排序
  623. $order_str = "id desc";
  624. if (empty($page)) {
  625. $start = 0;
  626. $perpage = 1;
  627. } else {
  628. $start = ($page - 1) * $perpage;
  629. }
  630. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  631. if ($sku) {
  632. $sku = trim($sku, ' ');
  633. $sku = trim($sku, ' ');
  634. $where .= " and sku like '%$sku%'";
  635. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  636. } else if ($title) {
  637. $title = trim($title, ' ');
  638. $title = trim($title, ' ');
  639. $where .= " and title like '%$title%'";
  640. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  641. } else {
  642. //$where .= " and time > '$ktime' and time < '$jtime'";
  643. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  644. }
  645. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  646. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  647. foreach ($info_list as $k => $v) {
  648. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  649. unset($info_list[$k]['pm']);
  650. unset($info_list[$k]['jm']);
  651. unset($info_list[$k]['bm']);
  652. }
  653. //取得信息列表
  654. $rows = array();
  655. $list = array();
  656. foreach ($info_list as $key => $value) {
  657. $warehouse = $this->warehouse->read($value['warehouse']);
  658. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  659. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  660. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  661. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  662. $info_list[$key]['label'] = $value['sm'];
  663. $number = $value['number'];
  664. $ftime = time() - 15 * 24 * 3600;
  665. $info_list[$key]['warehouse'] = $warehouse['title'];
  666. $info_list[$key]['features'] = count($c);
  667. $z = count($z); //查看订单号
  668. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  669. $ztdata = '';
  670. if (count($zt) > 0) {
  671. foreach ($zt as $vv) {
  672. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  673. }
  674. }
  675. $info_list[$key]['number'] = $ztdata;
  676. $info_list[$key]['sm'] = $z;
  677. $details = array();
  678. $cpid = array();
  679. foreach ($c as $k => $v) {
  680. $details[$v['details']] = $v['details'];
  681. if ($v['cpid'] != 0) {
  682. $cpid[$v['cpid']] = $v['cpid'];
  683. }
  684. }
  685. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  686. if ($value['shop'] != '') {
  687. $shop = explode(',', trim($value['shop'], ','));
  688. $shop = $this->shop->read($shop[0]);
  689. $info_list[$key]['shop'] = $shop['shopname'];
  690. }
  691. }
  692. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  693. $pagenum = ceil($total / $perpage);
  694. $over = $total - ($start + $perpage);
  695. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  696. echo json_encode($rows);
  697. exit;
  698. }
  699. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  700. $this->_Template('whlabel_typedy', $this->data);
  701. }
  702. //进销存浏览
  703. public function _typedy_ck($arg_array)
  704. {
  705. $prc = array();
  706. $purchase = $this->purchase->find_all();
  707. foreach ($purchase as $k => $v) {
  708. $prc[$v['id']] = $v['title'];
  709. }
  710. $post = $this->input->post(NULL, TRUE);
  711. if (isset($post['page'])) {
  712. $page = $this->input->post('page', true);
  713. $perpage = $this->input->post('perpage', true);
  714. $category = $this->input->post('category', true);
  715. $size = $this->input->post('size', true);
  716. $grade = $this->input->post('grade', true);
  717. $color = $this->input->post('color', true);
  718. $lowe = $this->input->post('lowe', true);
  719. $sku = $this->input->post('sku');
  720. $title = $this->input->post('title');
  721. $warehouse = $this->input->post('warehouse', true);
  722. $usa = $this->input->post('usa', true);
  723. $purchase = $this->input->post('purchase', true);
  724. $lacetype = $this->input->post('lacetype', true);
  725. $haircap = $this->input->post('haircap', true);
  726. $density = $this->input->post('density', true);
  727. $details = $this->input->post('details', true);
  728. $state = $this->input->post('state', true);
  729. $lacecolor = $this->input->post('lacecolor', true);
  730. $cklx = $this->input->post('cklx', true);
  731. $ktime = $this->input->post('ktime', true);
  732. $jtime = $this->input->post('jtime', true);
  733. $ktime = strtotime($ktime);
  734. $jtime = strtotime($jtime);
  735. $where = "1=1";
  736. $gj = "";
  737. $ck = "";
  738. if ($lacetype) {
  739. $where .= " and features like '%-$lacetype-%'";
  740. }
  741. if ($category) {
  742. $where .= " and features like '%-$category-%'";
  743. }
  744. if ($size) {
  745. $where .= " and features like '%-$size-%'";
  746. }
  747. if ($grade) {
  748. $where .= " and features like '%-$grade-%'";
  749. }
  750. if ($color) {
  751. $where .= " and features like '%-$color-%'";
  752. }
  753. if ($lowe) {
  754. $where .= " and features like '%-$lowe-%'";
  755. }
  756. if ($haircap) {
  757. $where .= " and features like '%-$haircap-%'";
  758. }
  759. if ($density) {
  760. $where .= " and features like '%-$density-%'";
  761. }
  762. if ($lacecolor) {
  763. $where .= " and features like '%-$lacecolor-%'";
  764. }
  765. if ($usa) {
  766. if (!$warehouse) {
  767. $where .= " and (warehouse = '5' or warehouse = '8')";
  768. }
  769. }
  770. if ($warehouse) {
  771. $where .= " and warehouse = '$warehouse'";
  772. }
  773. if ($details) {
  774. $where .= " and details = '$details'";
  775. }
  776. if ($purchase) {
  777. $where .= " and purchase = '$purchase'";
  778. }
  779. if ($state) {
  780. $where .= " and state = '$state'";
  781. }
  782. $where_add = '';
  783. if ($cklx) {
  784. $shop = $this->shop->read($cklx);
  785. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  786. }
  787. if ($ktime && $jtime) {
  788. $gj = " and enter > '$ktime' and enter < '$jtime'";
  789. $ck = " and outk > '$ktime' and outk < '$jtime'";
  790. }
  791. //数据排序
  792. $order_str = "id desc";
  793. if (empty($page)) {
  794. $start = 0;
  795. $perpage = 1;
  796. } else {
  797. $start = ($page - 1) * $perpage;
  798. }
  799. if ($sku) {
  800. $sku = trim($sku, ' ');
  801. $sku = trim($sku, ' ');
  802. $where .= " and sku like '%$sku%'";
  803. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  804. } else if ($title) {
  805. $title = trim($title, ' ');
  806. $title = trim($title, ' ');
  807. $where .= " and title like '%$title%'";
  808. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  809. } else {
  810. //$where .= " and time > '$ktime' and time < '$jtime'";
  811. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  812. }
  813. //取得信息列表
  814. $rows = array();
  815. $list = array();
  816. foreach ($info_list as $key => $value) {
  817. $warehouse = $this->warehouse->read($value['warehouse']);
  818. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  819. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  820. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  821. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  822. $ftime = time() - 15 * 24 * 3600;
  823. $info_list[$key]['warehouse'] = $warehouse['title'];
  824. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  825. //$z = count($z);//查看订单号
  826. //$info_list[$key]['zd'] = $z;
  827. $details = array();
  828. $cpid = array();
  829. foreach ($c as $k => $v) {
  830. $details[$v['details']] = $v['details'];
  831. if ($v['cpid'] != 0) {
  832. $cpid[$v['cpid']] = $v['cpid'];
  833. }
  834. }
  835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  836. if ($value['shop'] != '') {
  837. $shop = explode(',', trim($value['shop'], ','));
  838. $shop = $this->shop->read($shop[0]);
  839. $info_list[$key]['shop'] = $shop['shopname'];
  840. }
  841. }
  842. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  843. $pagenum = ceil($total / $perpage);
  844. $over = $total - ($start + $perpage);
  845. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  846. echo json_encode($rows);
  847. exit;
  848. }
  849. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  850. $this->_Template('whlabel_typedy_ck', $this->data);
  851. }
  852. public function _typeck($arg_array)
  853. {
  854. $prc = array();
  855. $purchase = $this->purchase->find_all();
  856. foreach ($purchase as $k => $v) {
  857. $prc[$v['id']] = $v['title'];
  858. }
  859. $post = $this->input->post(NULL, TRUE);
  860. if (isset($post['page'])) {
  861. $page = $this->input->post('page', true);
  862. $perpage = $this->input->post('perpage', true);
  863. $category = $this->input->post('category', true);
  864. $size = $this->input->post('size', true);
  865. $grade = $this->input->post('grade', true);
  866. $color = $this->input->post('color', true);
  867. $lacecolor = $this->input->post('lacecolor', true);
  868. $lowe = $this->input->post('lowe', true);
  869. $sku = $this->input->post('sku');
  870. $title = $this->input->post('title');
  871. $warehouse = 13;
  872. $usa = $this->input->post('usa', true);
  873. $purchase = $this->input->post('purchase', true);
  874. $lacetype = $this->input->post('lacetype', true);
  875. $haircap = $this->input->post('haircap', true);
  876. $density = $this->input->post('density', true);
  877. $details = $this->input->post('details', true);
  878. $state = $this->input->post('state', true);
  879. $ktime = $this->input->post('ktime', true);
  880. $jtime = $this->input->post('jtime', true);
  881. $ktime = strtotime($ktime);
  882. $jtime = strtotime($jtime);
  883. $where = "1=1";
  884. $gj = "";
  885. $ck = "";
  886. if ($lacetype) {
  887. $where .= " and features like '%-$lacetype-%'";
  888. }
  889. if ($category) {
  890. $where .= " and features like '%-$category-%'";
  891. }
  892. if ($size) {
  893. $where .= " and features like '%-$size-%'";
  894. }
  895. if ($grade) {
  896. $where .= " and features like '%-$grade-%'";
  897. }
  898. if ($color) {
  899. $where .= " and features like '%-$color-%'";
  900. }
  901. if ($lacecolor) {
  902. $where .= " and features like '%-$lacecolor-%'";
  903. }
  904. if ($lowe) {
  905. $where .= " and features like '%-$lowe-%'";
  906. }
  907. if ($haircap) {
  908. $where .= " and features like '%-$haircap-%'";
  909. }
  910. if ($density) {
  911. $where .= " and features like '%-$density-%'";
  912. }
  913. if ($warehouse) {
  914. $where .= " and warehouse = '$warehouse'";
  915. }
  916. if ($details) {
  917. $where .= " and details = '$details'";
  918. }
  919. if ($purchase) {
  920. $where .= " and purchase = '$purchase'";
  921. }
  922. if ($state) {
  923. $where .= " and state = '$state'";
  924. }
  925. if ($ktime && $jtime) {
  926. $gj = " and enter > '$ktime' and enter < '$jtime'";
  927. $ck = " and outk > '$ktime' and outk < '$jtime'";
  928. }
  929. //数据排序
  930. $order_str = "id desc";
  931. if (empty($page)) {
  932. $start = 0;
  933. $perpage = 1;
  934. } else {
  935. $start = ($page - 1) * $perpage;
  936. }
  937. if ($sku) {
  938. $sku = trim($sku, ' ');
  939. $sku = trim($sku, ' ');
  940. $where .= " and sku like '%$sku%'";
  941. } else if ($title) {
  942. $title = trim($title, ' ');
  943. $title = trim($title, ' ');
  944. $where .= " and title like '%$title%'";
  945. }
  946. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  947. //取得信息列表
  948. $t = array();
  949. $typeclass = $this->typeclass->find_all();
  950. foreach ($typeclass as $v) {
  951. $t[$v['id']] = $v;
  952. }
  953. $rows = array();
  954. $list = array();
  955. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  956. foreach ($info_list as $key => $value) {
  957. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  958. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  959. $warehouse = $this->warehouse->read($value['warehouse']);
  960. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  961. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  962. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  963. $number = $value['number'];
  964. $ftime = time() - 15 * 24 * 3600;
  965. $z = count($z); //查看订单号
  966. $info_list[$key]['warehouse'] = $warehouse['title'];
  967. $info_list[$key]['features'] = count($c);
  968. $info_list[$key]['number'] = $z;
  969. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  970. $details = array();
  971. $cpid = array();
  972. foreach ($c as $k => $v) {
  973. $details[$v['details']] = $v['details'];
  974. if ($v['cpid'] != 0) {
  975. $cpid[$v['cpid']] = $v['cpid'];
  976. }
  977. }
  978. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  979. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  980. unset($info_list[$key]['pm']);
  981. unset($info_list[$key]['jm']);
  982. unset($info_list[$key]['bm']);
  983. }
  984. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  985. $pagenum = ceil($total / $perpage);
  986. $over = $total - ($start + $perpage);
  987. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  988. echo json_encode($rows);
  989. exit;
  990. }
  991. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  992. $this->_Template('whlabel_typeck', $this->data);
  993. }
  994. //进销存导出
  995. public function _whlabeckdc()
  996. {
  997. $prc = array();
  998. $purchase = $this->purchase->find_all();
  999. foreach ($purchase as $k => $v) {
  1000. $prc[$v['id']] = $v['title'];
  1001. }
  1002. if (isset($_GET['excel'])) {
  1003. $where = "sku != 'Preset'";
  1004. //数据排序
  1005. $order_str = "id desc";
  1006. if (empty($page)) {
  1007. $start = 0;
  1008. $perpage = 1;
  1009. } else {
  1010. $start = ($page - 1) * $perpage;
  1011. }
  1012. $category = $this->input->get('category', true);
  1013. $color = $this->input->get('color', true);
  1014. $lowe = $this->input->get('lowe', true);
  1015. $lacetype = $this->input->get('lacetype', true);
  1016. $size = $this->input->get('size', true);
  1017. $density = $this->input->get('density', true);
  1018. $haircap = $this->input->get('haircap', true);
  1019. $sku = $this->input->get('sku', true);
  1020. $details = $this->input->get('details', true);
  1021. $warehouse = 13;
  1022. $excelid = $this->input->get('sid', true);
  1023. if ($category) {
  1024. $where .= " and features like '%-$category-%'";
  1025. }
  1026. if ($color) {
  1027. $where .= " and features like '%-$color-%'";
  1028. }
  1029. if ($lowe) {
  1030. $where .= " and features like '%-$lowe-%'";
  1031. }
  1032. if ($lacetype) {
  1033. $where .= " and features like '%-$lacetype-%'";
  1034. }
  1035. if ($size) {
  1036. $where .= " and features like '%-$size-%'";
  1037. }
  1038. if ($density) {
  1039. $where .= " and features like '%-$density-%'";
  1040. }
  1041. if ($haircap) {
  1042. $where .= " and features like '%-$haircap-%'";
  1043. }
  1044. if ($warehouse) {
  1045. $where .= " and warehouse = '$warehouse'";
  1046. }
  1047. if ($sku) {
  1048. $where .= " and sku like '%$sku%'";
  1049. }
  1050. if ($details) {
  1051. $where .= " and details = '$details'";
  1052. }
  1053. $xzid = '';
  1054. if ($excelid) {
  1055. $excelid = explode(',', trim($excelid, ','));
  1056. foreach ($excelid as $key => $value) {
  1057. $xzid .= " id = " . $value . " or";
  1058. }
  1059. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1060. }
  1061. //取得信息列表
  1062. /**
  1063. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1064. $rows = array();$list = array();
  1065. foreach ($info_list as $key=>$value)
  1066. {
  1067. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1068. }
  1069. **/
  1070. $wh = array();
  1071. $w = $this->warehouse->find_all('1=1', 'id,title');
  1072. foreach ($w as $v) {
  1073. $wh[$v['id']] = $v['title'];
  1074. }
  1075. $tc = array();
  1076. $tcdata = array();
  1077. $list = array();
  1078. $classid = $this->classid->sku();
  1079. $tcall = $this->typeclass->find_all();
  1080. $typeclass = array();
  1081. foreach ($tcall as $v)
  1082. {
  1083. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1084. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1085. }
  1086. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1087. foreach ($rows as $key => $value) {
  1088. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1089. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1090. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1091. $rows[$key]['cpbz'] = $u9_info['bm'];
  1092. $rows[$key]['cs'] = $u9_info['jm'];
  1093. if(empty($value['details'])){
  1094. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1095. }else{
  1096. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1097. }
  1098. $details = array();
  1099. $cpid = array();
  1100. $cpbz = array();
  1101. $c = 0;
  1102. $g = 0;
  1103. $x = 0;
  1104. $t = 0;
  1105. $s = 0;
  1106. $q = 0;
  1107. foreach ($sd as $k => $v) {
  1108. if ($v['state'] == 0) {
  1109. $c++;
  1110. }
  1111. if ($v['state'] != 9) {
  1112. $g++;
  1113. }
  1114. if ($v['state'] == 1) {
  1115. $x++;
  1116. }
  1117. if ($v['state'] == 2) {
  1118. $t++;
  1119. }
  1120. if ($v['state'] == 8) {
  1121. $s++;
  1122. }
  1123. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1124. $q++;
  1125. }
  1126. $details[$v['details']] = $v['details'];
  1127. if ($v['cpid'] != 0) {
  1128. $cpid[$v['cpid']] = $v['cpid'];
  1129. }
  1130. if ($v['cpbz'] != '') {
  1131. $cpbz[$v['cpbz']] = $v['cpbz'];
  1132. }
  1133. }
  1134. $rows[$key]['details'] = implode("、", $details);
  1135. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1136. $number = $value['number'];
  1137. $ftime = time() - 15 * 24 * 3600;
  1138. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1139. $rows[$key]['number'] = $g;
  1140. $rows[$key]['features'] = $c;
  1141. $rows[$key]['x'] = $x;
  1142. $rows[$key]['t'] = $t;
  1143. $rows[$key]['s'] = $s;
  1144. $rows[$key]['q'] = $q;
  1145. $rows[$key]['wzsl'] = count($details);
  1146. //cpbzs
  1147. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1148. $unique_arr = array_unique($tmp_cpbzs);
  1149. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1150. }
  1151. $title = "进销存统计表" . date('Y-m-d', time());
  1152. $titlename = "<table border=1>
  1153. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1154. <tr align='center'>
  1155. <td>仓库</td>
  1156. <td>供应商</td>
  1157. <td>位置</td>
  1158. <td>库存编码</td>
  1159. <td>SKU</td>
  1160. <td>用友编码</td>
  1161. <td>用友料号</td>
  1162. <td>产品英文名</td>
  1163. <td>产品中文名</td>
  1164. <td>备注</td>
  1165. <td>入库总量</td>
  1166. <td>库存数量</td>
  1167. <td>销售数量</td>
  1168. <td>退货数量</td>
  1169. <td>删除数量</td>
  1170. <td>其它操作</td>
  1171. <td>位置数量</td>
  1172. </tr>
  1173. </table>";
  1174. $filename = $title . ".xls";
  1175. $tail = "";
  1176. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1177. }
  1178. }
  1179. public function _type()
  1180. {
  1181. $vip = 0;
  1182. if (isset($_SESSION['api'])) {
  1183. $user = $this->user->get_api($_SESSION['api']);
  1184. $fgshop = "";
  1185. $sid = "";
  1186. $usersp = explode('|', trim($user['shop'], '|'));
  1187. foreach ($usersp as $value) {
  1188. $fgshop .= " shop = " . $value . " or";
  1189. $sid .= " id = " . $value . " or";
  1190. }
  1191. if ($user['vip'] == 1) {
  1192. $vip = 1;
  1193. }
  1194. } else {
  1195. header('Location: /');
  1196. exit;
  1197. }
  1198. $prc = array();
  1199. $purchase = $this->purchase->find_all();
  1200. foreach ($purchase as $k => $v) {
  1201. $prc[$v['id']] = $v['title'];
  1202. }
  1203. $company = array();
  1204. $ct = $this->company->find_all();
  1205. foreach ($ct as $k => $v) {
  1206. $company[$v['id']] = $v['title'];
  1207. }
  1208. $sp = array();
  1209. $s = $this->shop->find_all('1=1', 'id,shopname');
  1210. foreach ($s as $v) {
  1211. $sp[$v['id']] = $v['shopname'];
  1212. }
  1213. $wh = array();
  1214. $w = $this->warehouse->find_all('1=1', 'id,title');
  1215. foreach ($w as $v) {
  1216. $wh[$v['id']] = $v['title'];
  1217. }
  1218. $post = $this->input->post(NULL, TRUE);
  1219. if (isset($post['page'])) {
  1220. $page = $this->input->post('page', true);
  1221. $perpage = $this->input->post('perpage', true);
  1222. $category = $this->input->post('category', true);
  1223. $size = $this->input->post('size', true);
  1224. $grade = $this->input->post('grade', true);
  1225. $color = $this->input->post('color', true);
  1226. $lowe = $this->input->post('lowe', true);
  1227. $sku = $this->input->post('sku');
  1228. $title = $this->input->post('title');
  1229. $warehouse = $this->input->post('warehouse', true);
  1230. $usa = $this->input->post('usa', true);
  1231. $purchase = $this->input->post('purchase', true);
  1232. $lacetype = $this->input->post('lacetype', true);
  1233. $haircap = $this->input->post('haircap', true);
  1234. $density = $this->input->post('density', true);
  1235. $details = $this->input->post('details', true);
  1236. $state = $this->input->post('state', true);
  1237. $shop = $this->input->post('shop', true);
  1238. $lacecolor = $this->input->post('lacecolor', true);
  1239. $hairnumber = $this->input->post('hairnumber', true);
  1240. $type = $this->input->post('type', true);
  1241. $ktime = $this->input->post('ktime', true);
  1242. $jtime = $this->input->post('jtime', true);
  1243. $ktime = strtotime($ktime);
  1244. $jtime = strtotime($jtime);
  1245. $cpbz = $this->input->post('cpbz', true);
  1246. $sm = $this->input->post('sm', true);
  1247. $where = "1=1";
  1248. $gj = "";
  1249. $ck = "";
  1250. if ($usa) {
  1251. if (!$warehouse) {
  1252. $where .= " and (warehouse = '5' or warehouse = '8')";
  1253. }
  1254. }
  1255. if ($warehouse) {
  1256. $where .= " and warehouse = '$warehouse'";
  1257. }
  1258. if ($details) {
  1259. $where .= " and details = '$details'";
  1260. }
  1261. if ($purchase) {
  1262. $where .= " and purchase = '$purchase'";
  1263. }
  1264. if ($state) {
  1265. $where .= " and state = '$state'";
  1266. }
  1267. if ($shop) {
  1268. $where .= " and shop like '%$shop%'";
  1269. }
  1270. if ($type) {
  1271. $where .= " and type = '$type'";
  1272. }
  1273. if ($ktime && $jtime) {
  1274. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1275. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1276. }
  1277. if ($cpbz) {
  1278. $where .= " and cpbz like '%$cpbz%' ";
  1279. }
  1280. if ($sm) {
  1281. $where .= " and sm like '%$sm%' ";
  1282. }
  1283. if ($lacecolor) {
  1284. $where .= " and features like '%-$lacecolor-%'";
  1285. }
  1286. if ($lacetype) {
  1287. $where .= " and features like '%-$lacetype-%'";
  1288. }
  1289. if ($category) {
  1290. $where .= " and features like '%-$category-%'";
  1291. }
  1292. if ($size) {
  1293. $where .= " and features like '%-$size-%'";
  1294. }
  1295. if ($grade) {
  1296. $where .= " and features like '%-$grade-%'";
  1297. }
  1298. if ($color) {
  1299. $where .= " and features like '%-$color-%'";
  1300. }
  1301. if ($lowe) {
  1302. $where .= " and features like '%-$lowe-%'";
  1303. }
  1304. if ($haircap) {
  1305. $where .= " and features like '%-$haircap-%'";
  1306. }
  1307. if ($density) {
  1308. $where .= " and features like '%-$density-%'";
  1309. }
  1310. if (!empty($hairnumber)) {
  1311. $where .= " and features like '%-128-%' ";
  1312. if ($hairnumber < 0) {
  1313. $class_list = $this->typeclass->find_all('classid = 43');
  1314. foreach ($class_list as $v) {
  1315. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1316. }
  1317. } else {
  1318. $where .= " and features like '%-$hairnumber-%'";
  1319. }
  1320. }
  1321. //数据排序
  1322. $order_str = "id desc";
  1323. if (empty($page)) {
  1324. $start = 0;
  1325. $perpage = 1;
  1326. } else {
  1327. $start = ($page - 1) * $perpage;
  1328. }
  1329. $fjnr = '';
  1330. if ($sku) {
  1331. $sku = trim($sku, ' ');
  1332. $sku = trim($sku, ' ');
  1333. $fjnr .= " and sku like '%$sku%'";
  1334. }
  1335. if ($title) {
  1336. $title = trim($title, ' ');
  1337. $title = trim($title, ' ');
  1338. $fjnr .= " and title like '%$title%'";
  1339. }
  1340. $wt = array();
  1341. $whlabel_type = $this->whlabel_type->find_all();
  1342. foreach ($whlabel_type as $v) {
  1343. $wt[$v['id']] = $v['title'];
  1344. }
  1345. //$where .= " and time > '$ktime' and time < '$jtime'";
  1346. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1347. //取得信息列表
  1348. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1349. $rows = array();
  1350. $list = array();
  1351. foreach ($info_list as $key => $value) {
  1352. if (isset($wt[$value['type']])) {
  1353. $info_list[$key]['type'] = $wt[$value['type']];
  1354. } else {
  1355. $info_list[$key]['type'] = '未设置';
  1356. }
  1357. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1358. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1359. $ztdata = '';
  1360. if (count($zt) > 0) {
  1361. foreach ($zt as $vv) {
  1362. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1363. }
  1364. }
  1365. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1366. $cdata = array_filter($qbdata, function ($item) {
  1367. return $item['state'] < 1;
  1368. });
  1369. $c = array_sum(array_column($cdata, 'jnum'));
  1370. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1371. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1372. });
  1373. $g = array_sum(array_column($gdata, 'jnum'));
  1374. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1375. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1376. });
  1377. $x = array_sum(array_column($xdata, 'jnum'));
  1378. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1379. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1380. });
  1381. $t = array_sum(array_column($tdata, 'jnum'));
  1382. // $zdata = array_filter($qbdata, function ($item) {
  1383. // return $item['zd'] != "" && $item['state'] < 1;
  1384. // });
  1385. // $z = array_sum(array_column($zdata, 'jnum'));
  1386. $zdata = array_filter($qbdata, function ($item) {
  1387. return $item['zd'] != "" && $item['state'] < 1;
  1388. });
  1389. $z = array_sum(array_column($zdata, 'jnum'));
  1390. //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1391. //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1392. //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1393. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1394. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1395. $details = array();
  1396. $cpid = array();
  1397. $od = array();
  1398. $odid = '';
  1399. $companytitle = '';
  1400. $shop_list = [];
  1401. foreach ($qbdata as $v) {
  1402. if ($v['zd'] != "" && $v['state'] < 1) {
  1403. if (!isset($od[$v['zd']])) {
  1404. $od[$v['zd']] = 1; //所有数据sku
  1405. } else {
  1406. $od[$v['zd']] = $od[$v['zd']] + 1;
  1407. }
  1408. }
  1409. if($v['state'] == 0){
  1410. $details[$v['details']] = $v['details'];
  1411. }
  1412. if ($v['state'] < 1) {
  1413. //$details[$v['details']] = $v['details'];
  1414. if ($v['cpid'] != 0) {
  1415. $cpid[$v['cpid']] = $v['cpid'];
  1416. }
  1417. }
  1418. if($v['state'] == 0){
  1419. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1420. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1421. }
  1422. if ($v['shop'] != '') {
  1423. $shop = explode(',', trim($v['shop'], ','));
  1424. foreach ($shop as $vv) {
  1425. if (!in_array($vv, $shop_list)) {
  1426. $shop_list[] = $vv;
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. foreach ($od as $k => $vv) {
  1433. $odid .= $k . '数量' . $vv;
  1434. }
  1435. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1436. $info_list[$key]['label'] = $value['sm'];
  1437. $number = $value['number'];
  1438. $ftime = time() - 15 * 24 * 3600;
  1439. $z = $z . '(' . $odid . ')'; //查看订单号
  1440. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1441. $info_list[$key]['features'] = $c;
  1442. $info_list[$key]['number'] = $ztdata;
  1443. $info_list[$key]['sm'] = $g;
  1444. $info_list[$key]['x'] = $x;
  1445. $info_list[$key]['t'] = $t;
  1446. $info_list[$key]['z'] = $z;
  1447. /**
  1448. foreach ($cdata as $k=>$v)
  1449. {
  1450. $details[$v['details']] = $v['details'];
  1451. if($v['cpid'] != 0)
  1452. {
  1453. $cpid[$v['cpid']] = $v['cpid'];
  1454. }
  1455. }
  1456. **/
  1457. $info_list[$key]['shop'] = '';
  1458. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1459. // if ($value['shop'] != '') {
  1460. // $shop = explode(',', trim($value['shop'], ','));
  1461. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1462. // }
  1463. $shop_list = array_unique($shop_list);
  1464. $shop_str = '';
  1465. foreach ($shop_list as $v) {
  1466. if(isset($sp[$v])){
  1467. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1468. }
  1469. }
  1470. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1471. /**
  1472. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1473. if(isset($companytitle[0]))
  1474. {
  1475. foreach ($companytitle as $k=>$v)
  1476. {
  1477. if($v['companytitle'] != '')
  1478. {
  1479. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1480. }
  1481. }
  1482. }
  1483. **/
  1484. }
  1485. $final_all_list = [];
  1486. foreach ($info_list as $k => $v) {
  1487. $final_all_list[] = [
  1488. 'id' => $v['id'],
  1489. "warehouse" => $v["warehouse"],
  1490. "purchase" => $v["purchase"],
  1491. "sku" => $v["sku"],
  1492. "title" => $v["title"] . "<br/>" . $v["pm"],
  1493. "details" => $v["details"],
  1494. "shop" => $v["shop"],
  1495. "cpbz" => $v["cpbz"],
  1496. 'label' => $v['label'],
  1497. "type" => $v["type"],
  1498. "features" => $v["features"],
  1499. "number" => $v["number"],
  1500. "sm" => $v["sm"],
  1501. "x" => $v["x"],
  1502. "t" => $v["t"],
  1503. "z" => $v["z"]
  1504. ];
  1505. }
  1506. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1507. $pagenum = ceil($total / $perpage);
  1508. $over = $total - ($start + $perpage);
  1509. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1510. echo json_encode($rows);
  1511. exit;
  1512. }
  1513. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1514. $this->data['shop'] = $wlshop;
  1515. $this->data['vip'] = $vip;
  1516. $this->_Template('whlabel_type', $this->data);
  1517. }
  1518. /**
  1519. * _type 优化版 v1
  1520. * 优化点:
  1521. * 1. 循环内 N+1 查询改为批量预取(方案 A),SQL 从 2+2P 降到固定 4 条
  1522. * 2. 总数统计改为只 COUNT 不传输明细字段(方案 C)
  1523. * 3. 批量 qbdata 查询去掉 features like 条件,走组合键 IN 精确匹配
  1524. * 4. 批量 transport 查询加 ORDER BY stime 保证顺序与原来一致
  1525. */
  1526. public function _typev1()
  1527. {
  1528. $vip = 0;
  1529. if (isset($_SESSION['api'])) {
  1530. $user = $this->user->get_api($_SESSION['api']);
  1531. $fgshop = "";
  1532. $sid = "";
  1533. $usersp = explode('|', trim($user['shop'], '|'));
  1534. foreach ($usersp as $value) {
  1535. $fgshop .= " shop = " . $value . " or";
  1536. $sid .= " id = " . $value . " or";
  1537. }
  1538. if ($user['vip'] == 1) {
  1539. $vip = 1;
  1540. }
  1541. } else {
  1542. header('Location: /');
  1543. exit;
  1544. }
  1545. $prc = array();
  1546. $purchase = $this->purchase->find_all();
  1547. foreach ($purchase as $k => $v) {
  1548. $prc[$v['id']] = $v['title'];
  1549. }
  1550. $company = array();
  1551. $ct = $this->company->find_all();
  1552. foreach ($ct as $k => $v) {
  1553. $company[$v['id']] = $v['title'];
  1554. }
  1555. $sp = array();
  1556. $s = $this->shop->find_all('1=1', 'id,shopname');
  1557. foreach ($s as $v) {
  1558. $sp[$v['id']] = $v['shopname'];
  1559. }
  1560. $wh = array();
  1561. $w = $this->warehouse->find_all('1=1', 'id,title');
  1562. foreach ($w as $v) {
  1563. $wh[$v['id']] = $v['title'];
  1564. }
  1565. $post = $this->input->post(NULL, TRUE);
  1566. if (isset($post['page'])) {
  1567. $page = $this->input->post('page', true);
  1568. $perpage = $this->input->post('perpage', true);
  1569. $category = $this->input->post('category', true);
  1570. $size = $this->input->post('size', true);
  1571. $grade = $this->input->post('grade', true);
  1572. $color = $this->input->post('color', true);
  1573. $lowe = $this->input->post('lowe', true);
  1574. $sku = $this->input->post('sku');
  1575. $title = $this->input->post('title');
  1576. $warehouse = $this->input->post('warehouse', true);
  1577. $usa = $this->input->post('usa', true);
  1578. $purchase = $this->input->post('purchase', true);
  1579. $lacetype = $this->input->post('lacetype', true);
  1580. $haircap = $this->input->post('haircap', true);
  1581. $density = $this->input->post('density', true);
  1582. $details = $this->input->post('details', true);
  1583. $state = $this->input->post('state', true);
  1584. $shop = $this->input->post('shop', true);
  1585. $lacecolor = $this->input->post('lacecolor', true);
  1586. $hairnumber = $this->input->post('hairnumber', true);
  1587. $type = $this->input->post('type', true);
  1588. $ktime = $this->input->post('ktime', true);
  1589. $jtime = $this->input->post('jtime', true);
  1590. $ktime = strtotime($ktime);
  1591. $jtime = strtotime($jtime);
  1592. $cpbz = $this->input->post('cpbz', true);
  1593. $sm = $this->input->post('sm', true);
  1594. $where = "1=1";
  1595. // $where_no_features 用于批量预取,去掉 features like 条件,靠组合键精确匹配
  1596. $where_no_features = "1=1";
  1597. if ($usa) {
  1598. if (!$warehouse) {
  1599. $where .= " and (warehouse = '5' or warehouse = '8')";
  1600. $where_no_features .= " and (warehouse = '5' or warehouse = '8')";
  1601. }
  1602. }
  1603. if ($warehouse) {
  1604. $where .= " and warehouse = '$warehouse'";
  1605. $where_no_features .= " and warehouse = '$warehouse'";
  1606. }
  1607. if ($details) {
  1608. $where .= " and details = '$details'";
  1609. $where_no_features .= " and details = '$details'";
  1610. }
  1611. if ($purchase) {
  1612. $where .= " and purchase = '$purchase'";
  1613. $where_no_features .= " and purchase = '$purchase'";
  1614. }
  1615. if ($state) {
  1616. $where .= " and state = '$state'";
  1617. $where_no_features .= " and state = '$state'";
  1618. }
  1619. if ($shop) {
  1620. $where .= " and shop like '%$shop%'";
  1621. $where_no_features .= " and shop like '%$shop%'";
  1622. }
  1623. if ($type) {
  1624. $where .= " and type = '$type'";
  1625. $where_no_features .= " and type = '$type'";
  1626. }
  1627. if ($cpbz) {
  1628. $where .= " and cpbz like '%$cpbz%' ";
  1629. $where_no_features .= " and cpbz like '%$cpbz%' ";
  1630. }
  1631. if ($sm) {
  1632. $where .= " and sm like '%$sm%' ";
  1633. $where_no_features .= " and sm like '%$sm%' ";
  1634. }
  1635. // features like 条件只加入 $where(列表分组用),不加入 $where_no_features
  1636. if ($lacecolor) {
  1637. $where .= " and features like '%-$lacecolor-%'";
  1638. }
  1639. if ($lacetype) {
  1640. $where .= " and features like '%-$lacetype-%'";
  1641. }
  1642. if ($category) {
  1643. $where .= " and features like '%-$category-%'";
  1644. }
  1645. if ($size) {
  1646. $where .= " and features like '%-$size-%'";
  1647. }
  1648. if ($grade) {
  1649. $where .= " and features like '%-$grade-%'";
  1650. }
  1651. if ($color) {
  1652. $where .= " and features like '%-$color-%'";
  1653. }
  1654. if ($lowe) {
  1655. $where .= " and features like '%-$lowe-%'";
  1656. }
  1657. if ($haircap) {
  1658. $where .= " and features like '%-$haircap-%'";
  1659. }
  1660. if ($density) {
  1661. $where .= " and features like '%-$density-%'";
  1662. }
  1663. if (!empty($hairnumber)) {
  1664. $where .= " and features like '%-128-%' ";
  1665. if ($hairnumber < 0) {
  1666. $class_list = $this->typeclass->find_all('classid = 43');
  1667. foreach ($class_list as $v) {
  1668. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1669. }
  1670. } else {
  1671. $where .= " and features like '%-$hairnumber-%'";
  1672. }
  1673. }
  1674. //数据排序
  1675. $order_str = "id desc";
  1676. if (empty($page)) {
  1677. $start = 0;
  1678. $perpage = 1;
  1679. } else {
  1680. $start = ($page - 1) * $perpage;
  1681. }
  1682. $fjnr = '';
  1683. if ($sku) {
  1684. $sku = trim($sku, ' ');
  1685. $sku = trim($sku, ' ');
  1686. $fjnr .= " and sku like '%$sku%'";
  1687. }
  1688. if ($title) {
  1689. $title = trim($title, ' ');
  1690. $title = trim($title, ' ');
  1691. $fjnr .= " and title like '%$title%'";
  1692. }
  1693. $wt = array();
  1694. $whlabel_type = $this->whlabel_type->find_all();
  1695. foreach ($whlabel_type as $v) {
  1696. $wt[$v['id']] = $v['title'];
  1697. }
  1698. // 列表分组(与原来完全一致)
  1699. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage);
  1700. //取得信息列表
  1701. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1702. // ========== 优化方案 A:批量预取 whlabel 组数据和 transport 数据 ==========
  1703. $keys = array();
  1704. foreach ($info_list as $v) {
  1705. $keys[] = "('" . addslashes($v['sku']) . "','" . addslashes($v['purchase'])
  1706. . "','" . addslashes($v['features']) . "','" . addslashes($v['warehouse']) . "')";
  1707. }
  1708. // 组合键函数,用于 PHP 端按分组索引
  1709. $comboKey = function ($r) {
  1710. return $r['sku'] . '|' . $r['purchase'] . '|' . $r['features'] . '|' . $r['warehouse'];
  1711. };
  1712. // 批量拉取 whlabel 组数据(使用 $where_no_features,不带 features like,靠 IN 元组精确匹配)
  1713. $all_qb = array();
  1714. if (!empty($keys)) {
  1715. $keyInSql = implode(',', $keys);
  1716. $qbAll = $this->whlabel->find_all(
  1717. $where_no_features . " and (sku,purchase,features,warehouse) IN (" . $keyInSql . ")"
  1718. );
  1719. foreach ($qbAll as $r) {
  1720. $all_qb[$comboKey($r)][] = $r;
  1721. }
  1722. }
  1723. // 批量拉取 transport 在途数据(3 列元组: sku,warehouse,features,与 IN 左侧列顺序一致)
  1724. $all_zt = array();
  1725. if (!empty($info_list)) {
  1726. $ztKeys = array();
  1727. foreach ($info_list as $v) {
  1728. $ztKeys[] = "('" . addslashes($v['sku']) . "','"
  1729. . addslashes($v['warehouse']) . "','"
  1730. . addslashes($v['features']) . "')";
  1731. }
  1732. $ztInSql = implode(',', $ztKeys);
  1733. $ztAll = $this->whlabeltransport->find_all(
  1734. "cz = '0' and (sku,warehouse,features) IN (" . $ztInSql . ")",
  1735. '*',
  1736. 'stime'
  1737. );
  1738. foreach ($ztAll as $r) {
  1739. $ck = $r['sku'] . '|' . $r['warehouse'] . '|' . $r['features'];
  1740. $all_zt[$ck][] = $r;
  1741. }
  1742. }
  1743. $rows = array();
  1744. $list = array();
  1745. foreach ($info_list as $key => $value) {
  1746. if (isset($wt[$value['type']])) {
  1747. $info_list[$key]['type'] = $wt[$value['type']];
  1748. } else {
  1749. $info_list[$key]['type'] = '未设置';
  1750. }
  1751. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1752. // transport 在途数据:从预取数组中取
  1753. $ztCk = $value['sku'] . '|' . $value['warehouse'] . '|' . $value['features'];
  1754. $zt = isset($all_zt[$ztCk]) ? $all_zt[$ztCk] : array();
  1755. $ztdata = '';
  1756. if (count($zt) > 0) {
  1757. foreach ($zt as $vv) {
  1758. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1759. }
  1760. }
  1761. // whlabel 组数据:从预取数组中取
  1762. $qbCk = $comboKey($value);
  1763. $qbdata = isset($all_qb[$qbCk]) ? $all_qb[$qbCk] : array();
  1764. $cdata = array_filter($qbdata, function ($item) {
  1765. return $item['state'] < 1;
  1766. });
  1767. $c = array_sum(array_column($cdata, 'jnum'));
  1768. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1769. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1770. });
  1771. $g = array_sum(array_column($gdata, 'jnum'));
  1772. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1773. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1774. });
  1775. $x = array_sum(array_column($xdata, 'jnum'));
  1776. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1777. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1778. });
  1779. $t = array_sum(array_column($tdata, 'jnum'));
  1780. $zdata = array_filter($qbdata, function ($item) {
  1781. return $item['zd'] != "" && $item['state'] < 1;
  1782. });
  1783. $z = array_sum(array_column($zdata, 'jnum'));
  1784. $detailsArr = array();
  1785. $cpid = array();
  1786. $od = array();
  1787. $odid = '';
  1788. $companytitle = '';
  1789. $shop_list = [];
  1790. foreach ($qbdata as $v) {
  1791. if ($v['zd'] != "" && $v['state'] < 1) {
  1792. if (!isset($od[$v['zd']])) {
  1793. $od[$v['zd']] = 1;
  1794. } else {
  1795. $od[$v['zd']] = $od[$v['zd']] + 1;
  1796. }
  1797. }
  1798. if ($v['state'] == 0) {
  1799. $detailsArr[$v['details']] = $v['details'];
  1800. }
  1801. if ($v['state'] < 1) {
  1802. if ($v['cpid'] != 0) {
  1803. $cpid[$v['cpid']] = $v['cpid'];
  1804. }
  1805. }
  1806. if ($v['state'] == 0) {
  1807. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1808. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1809. }
  1810. if ($v['shop'] != '') {
  1811. $shopArr = explode(',', trim($v['shop'], ','));
  1812. foreach ($shopArr as $vv) {
  1813. if (!in_array($vv, $shop_list)) {
  1814. $shop_list[] = $vv;
  1815. }
  1816. }
  1817. }
  1818. }
  1819. }
  1820. foreach ($od as $k => $vv) {
  1821. $odid .= $k . '数量' . $vv;
  1822. }
  1823. $info_list[$key]['cpbz'] = $value['cpbz'];
  1824. $info_list[$key]['label'] = $value['sm'];
  1825. $number = $value['number'];
  1826. $z = $z . '(' . $odid . ')';
  1827. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1828. $info_list[$key]['features'] = $c;
  1829. $info_list[$key]['number'] = $ztdata;
  1830. $info_list[$key]['sm'] = $g;
  1831. $info_list[$key]['x'] = $x;
  1832. $info_list[$key]['t'] = $t;
  1833. $info_list[$key]['z'] = $z;
  1834. $info_list[$key]['shop'] = '';
  1835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $detailsArr) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $detailsArr);
  1836. $shop_list = array_unique($shop_list);
  1837. $shop_str = '';
  1838. foreach ($shop_list as $v) {
  1839. if (isset($sp[$v])) {
  1840. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1841. }
  1842. }
  1843. $info_list[$key]['shop'] = $shop_str . $companytitle;
  1844. }
  1845. $final_all_list = [];
  1846. foreach ($info_list as $k => $v) {
  1847. $final_all_list[] = [
  1848. 'id' => $v['id'],
  1849. "warehouse" => $v["warehouse"],
  1850. "purchase" => $v["purchase"],
  1851. "sku" => $v["sku"],
  1852. "title" => $v["title"] . "<br/>" . $v["pm"],
  1853. "details" => $v["details"],
  1854. "shop" => $v["shop"],
  1855. "cpbz" => $v["cpbz"],
  1856. 'label' => $v['label'],
  1857. "type" => $v["type"],
  1858. "features" => $v["features"],
  1859. "number" => $v["number"],
  1860. "sm" => $v["sm"],
  1861. "x" => $v["x"],
  1862. "t" => $v["t"],
  1863. "z" => $v["z"]
  1864. ];
  1865. }
  1866. // ========== 优化方案 C:总数统计只 COUNT,不传明细字段 ==========
  1867. // 原实现: count(find_pc(..., 'id,warehouse,sku,title,features,number')),传输了大量明细字段
  1868. // 优化为: SELECT COUNT(*) FROM (SELECT 1 FROM whlabel WHERE ... GROUP BY ...) t,只传一个数字
  1869. $countSql = "SELECT COUNT(*) AS cnt FROM (SELECT 1 FROM crowd_whlabel WHERE " . $where . $fjnr . " GROUP BY sku,purchase,features,warehouse) t";
  1870. $countResult = $this->whlabel->query($countSql)->result_array();
  1871. $total = isset($countResult[0]['cnt']) ? (int)$countResult[0]['cnt'] : 0;
  1872. $pagenum = ceil($total / $perpage);
  1873. $over = $total - ($start + $perpage);
  1874. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1875. echo json_encode($rows);
  1876. exit;
  1877. }
  1878. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1879. $this->data['shop'] = $wlshop;
  1880. $this->data['vip'] = $vip;
  1881. $this->_Template('whlabel_typev1', $this->data);
  1882. }
  1883. //美仓进销存浏览
  1884. public function _usatype()
  1885. {
  1886. if (isset($_SESSION['api'])) {
  1887. $user = $this->user->get_api($_SESSION['api']);
  1888. $usp = $user;
  1889. $fgshop = "";
  1890. $sid = "";
  1891. $wid = "";
  1892. $wtype = "";
  1893. $userwh = explode('|', trim($user['warehouse'], '|'));
  1894. foreach ($userwh as $value) {
  1895. $wid .= " id = " . $value . " or";
  1896. $wtype .= " type = " . $value . " or";
  1897. }
  1898. }
  1899. $prc = array();
  1900. $purchase = $this->purchase->find_all();
  1901. foreach ($purchase as $k => $v) {
  1902. $prc[$v['id']] = $v['title'];
  1903. }
  1904. $post = $this->input->post(NULL, TRUE);
  1905. if (isset($post['page'])) {
  1906. $page = $this->input->post('page', true);
  1907. $perpage = $this->input->post('perpage', true);
  1908. $category = $this->input->post('category', true);
  1909. $size = $this->input->post('size', true);
  1910. $grade = $this->input->post('grade', true);
  1911. $color = $this->input->post('color', true);
  1912. $lowe = $this->input->post('lowe', true);
  1913. $sku = $this->input->post('sku');
  1914. $title = $this->input->post('title');
  1915. $warehouse = $this->input->post('warehouse', true);
  1916. $usa = $this->input->post('usa', true);
  1917. $purchase = $this->input->post('purchase', true);
  1918. $lacetype = $this->input->post('lacetype', true);
  1919. $haircap = $this->input->post('haircap', true);
  1920. $density = $this->input->post('density', true);
  1921. $details = $this->input->post('details', true);
  1922. $state = $this->input->post('state', true);
  1923. $lacecolor = $this->input->post('lacecolor', true);
  1924. $cklx = $this->input->post('cklx', true);
  1925. $ktime = $this->input->post('ktime', true);
  1926. $jtime = $this->input->post('jtime', true);
  1927. $ktime = strtotime($ktime);
  1928. $jtime = strtotime($jtime);
  1929. $where = "1=1";
  1930. $gj = "";
  1931. $ck = "";
  1932. if ($lacetype) {
  1933. $where .= " and features like '%-$lacetype-%'";
  1934. }
  1935. if ($category) {
  1936. $where .= " and features like '%-$category-%'";
  1937. }
  1938. if ($size) {
  1939. $where .= " and features like '%-$size-%'";
  1940. }
  1941. if ($grade) {
  1942. $where .= " and features like '%-$grade-%'";
  1943. }
  1944. if ($color) {
  1945. $where .= " and features like '%-$color-%'";
  1946. }
  1947. if ($lowe) {
  1948. $where .= " and features like '%-$lowe-%'";
  1949. }
  1950. if ($haircap) {
  1951. $where .= " and features like '%-$haircap-%'";
  1952. }
  1953. if ($density) {
  1954. $where .= " and features like '%-$density-%'";
  1955. }
  1956. if ($lacecolor) {
  1957. $where .= " and features like '%-$lacecolor-%'";
  1958. }
  1959. if ($usa) {
  1960. if (!$warehouse) {
  1961. $where .= " and (warehouse = '5' or warehouse = '8')";
  1962. }
  1963. }
  1964. if ($warehouse) {
  1965. $where .= " and warehouse = '$warehouse'";
  1966. }
  1967. if ($details) {
  1968. $where .= " and details = '$details'";
  1969. }
  1970. if ($purchase) {
  1971. $where .= " and purchase = '$purchase'";
  1972. }
  1973. if ($state) {
  1974. $where .= " and state = '$state'";
  1975. }
  1976. $where_add = '';
  1977. if ($cklx) {
  1978. $shop = $this->shop->read($cklx);
  1979. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1980. }
  1981. if ($ktime && $jtime) {
  1982. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1983. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1984. }
  1985. //数据排序
  1986. $order_str = "id desc";
  1987. if (empty($page)) {
  1988. $start = 0;
  1989. $perpage = 1;
  1990. } else {
  1991. $start = ($page - 1) * $perpage;
  1992. }
  1993. if ($sku) {
  1994. $sku = trim($sku, ' ');
  1995. $sku = trim($sku, ' ');
  1996. $where .= " and sku like '%$sku%'";
  1997. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1998. } else if ($title) {
  1999. $title = trim($title, ' ');
  2000. $title = trim($title, ' ');
  2001. $where .= " and title like '%$title%'";
  2002. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2003. } else {
  2004. //$where .= " and time > '$ktime' and time < '$jtime'";
  2005. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2006. }
  2007. //取得信息列表
  2008. $rows = array();
  2009. $list = array();
  2010. foreach ($info_list as $key => $value) {
  2011. $warehouse = $this->warehouse->read($value['warehouse']);
  2012. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2013. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2014. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2015. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2016. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2017. $od = array();
  2018. $odid = '';
  2019. foreach ($z as $v) {
  2020. if (!isset($od[$v['zd']])) {
  2021. $od[$v['zd']] = 1; //所有数据sku
  2022. } else {
  2023. $od[$v['zd']] = $od[$v['zd']] + 1;
  2024. }
  2025. }
  2026. foreach ($od as $k => $vv) {
  2027. $odid .= $k . '数量' . $vv . ' ';
  2028. }
  2029. $z = count($z) . '(' . $odid . ')'; //查看订单号
  2030. $info_list[$key]['features'] = $c;
  2031. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  2032. $ztdata = '';
  2033. if (count($zt) > 0) {
  2034. foreach ($zt as $vv) {
  2035. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  2036. }
  2037. }
  2038. $info_list[$key]['warehouse'] = $ztdata;
  2039. $info_list[$key]['g'] = $g;
  2040. $info_list[$key]['x'] = $x;
  2041. $info_list[$key]['t'] = $t;
  2042. $info_list[$key]['z'] = $z;
  2043. }
  2044. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  2045. $pagenum = ceil($total / $perpage);
  2046. $over = $total - ($start + $perpage);
  2047. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  2048. echo json_encode($rows);
  2049. exit;
  2050. }
  2051. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  2052. $this->data['warehouse'] = $warehouse;
  2053. $this->_Template('whlabel_typeusa', $this->data);
  2054. }
  2055. //美仓进销存浏览
  2056. public function _usatypeapp()
  2057. {
  2058. $post = $this->input->post(NULL, TRUE);
  2059. if (isset($post['page'])) {
  2060. $page = $this->input->post('page', true);
  2061. $perpage = $this->input->post('perpage', true);
  2062. $sku = $this->input->post('sku', true);
  2063. $warehouse = 5;
  2064. $title = $this->input->post('title', true);
  2065. $state = $this->input->post('state', true);
  2066. $ktime = $this->input->post('ktime', true);
  2067. $jtime = $this->input->post('jtime', true);
  2068. $ktime = strtotime($ktime);
  2069. $jtime = strtotime($jtime);
  2070. $where = "1=1";
  2071. $gj = "";
  2072. $ck = "";
  2073. if ($title) {
  2074. $st = explode(' ', trim($title, ' '));
  2075. foreach ($st as $v) {
  2076. $where .= " and title like '%$v%'";
  2077. }
  2078. }
  2079. if ($warehouse) {
  2080. $where .= " and warehouse = '$warehouse'";
  2081. }
  2082. if ($state) {
  2083. $where .= " and state = '$state'";
  2084. }
  2085. if ($sku) {
  2086. $where .= " and sku like '%$sku%'";
  2087. }
  2088. if ($ktime && $jtime) {
  2089. $gj = " and enter > '$ktime' and enter < '$jtime'";
  2090. $ck = " and outk > '$ktime' and outk < '$jtime'";
  2091. }
  2092. //数据排序
  2093. $order_str = "id desc";
  2094. if (empty($page)) {
  2095. $start = 0;
  2096. $perpage = 1;
  2097. } else {
  2098. $start = ($page - 1) * $perpage;
  2099. }
  2100. //取得信息列表
  2101. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  2102. $rows = array();
  2103. $list = array();
  2104. foreach ($info_list as $key => $value) {
  2105. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  2106. }
  2107. $rowsdq = array_slice($rows, $start, $perpage);
  2108. foreach ($rowsdq as $value) {
  2109. $warehouse = $this->warehouse->read($value['warehouse']);
  2110. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  2111. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  2112. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2113. $od = array();
  2114. $odid = '';
  2115. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  2116. }
  2117. $total = count($rows);
  2118. $pagenum = ceil($total / $perpage);
  2119. $over = $total - ($start + $perpage);
  2120. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2121. echo json_encode($rows);
  2122. exit;
  2123. }
  2124. $this->_Template('phone/p_usatypeapp', $this->data);
  2125. }
  2126. //入库操作
  2127. public function _enteradd()
  2128. {
  2129. $dt = 0;
  2130. if (isset($_SESSION['api'])) {
  2131. $user = $this->user->get_api($_SESSION['api']);
  2132. $usp = $user;
  2133. $fgshop = "";
  2134. $sid = "";
  2135. $user = explode('|', trim($user['shop'], '|'));
  2136. foreach ($user as $value) {
  2137. $fgshop .= " shop = " . $value . " or";
  2138. $sid .= " id = " . $value . " or";
  2139. }
  2140. }
  2141. $tc = $this->typeclass->find_all();
  2142. $typeclass = array();
  2143. foreach ($tc as $v) {
  2144. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  2145. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  2146. }
  2147. $post = $this->input->post(NULL, TRUE);
  2148. if (isset($post['sku'])) {
  2149. $list = array();
  2150. $num = "";
  2151. $title = "";
  2152. $features = "";
  2153. $order = $this->input->post('order', true);
  2154. $shop = $this->input->post('shop', true);
  2155. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2156. $sku = $this->input->post('sku', true);
  2157. $post['sm'] = $this->input->post('sm', true);
  2158. $post['warehouse'] = $this->input->post('warehouse', true);
  2159. $post['purchase'] = $this->input->post('purchase', true);
  2160. $post['retreatwarehouse'] = $post['warehouse'];
  2161. $post['state'] = $this->input->post('state', true);
  2162. $post['rktype'] = $this->input->post('rktype', true);
  2163. $post['text'] = $this->input->post('text', true);
  2164. $category = $this->input->post('category', true);
  2165. $list['category'] = $category;
  2166. $list['hairtype'] = $this->input->post('hairtype', true);
  2167. $list['grade'] = $this->input->post('grade', true);
  2168. $size = $this->input->post('size', true);
  2169. $xzsku = $this->input->post('xzsku', true);
  2170. $list['size'] = rtrim($size, ',');
  2171. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2172. $list['extension'] = $this->input->post('extension', true);
  2173. if ($category == 1297) {
  2174. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2175. }
  2176. if ($category == 1702) {
  2177. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2178. $list['syother'] = $this->input->post('syother', true);
  2179. }
  2180. if ($category == 133) {
  2181. $list['fittype'] = $this->input->post('fittype', true);
  2182. $list['acother'] = $this->input->post('acother', true);
  2183. }
  2184. $list['color'] = $this->input->post('color', true);
  2185. $list['lowe'] = $this->input->post('lowe', true);
  2186. if (!$post['purchase']) {
  2187. $post['purchase'] = 1;
  2188. }
  2189. if ($category == 127) {
  2190. $list['type'] = $this->input->post('type', true);
  2191. $list['headroad'] = $this->input->post('headroad', true);
  2192. $list['density'] = $this->input->post('density', true);
  2193. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2194. $list['lacesize'] = $this->input->post('lacesize', true);
  2195. }
  2196. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2197. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2198. }
  2199. if ($category == 128) {
  2200. $list['lacetype'] = $this->input->post('lacetype', true);
  2201. $list['haircap'] = $this->input->post('haircap', true);
  2202. $list['density'] = $this->input->post('density', true);
  2203. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2204. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2205. $list['wigother'] = $this->input->post('wigother', true);
  2206. $list['wigother1'] = $this->input->post('wigother1', true);
  2207. $list['wigother2'] = $this->input->post('wigother2', true);
  2208. $list['product_related'] = $this->input->post('product_related', true);
  2209. }
  2210. if ($category == 129) {
  2211. $list['wide'] = $this->input->post('wide', true);
  2212. }
  2213. if ($category == 131) {
  2214. $list['gifttype'] = $this->input->post('gifttype', true);
  2215. $list['giftother'] = $this->input->post('giftother', true);
  2216. }
  2217. if ($category == 134) {
  2218. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2219. }
  2220. if ($category == 1297) {
  2221. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2222. $list['sywigother'] = $this->input->post('sywigother', true);
  2223. }
  2224. if ($category == 130 || $category == 133 || $category == 1702) {
  2225. $list['items'] = $this->input->post('items', true);
  2226. $list['weight'] = $this->input->post('weight', true);
  2227. }
  2228. if($category == 130){
  2229. $list['jfother'] = $this->input->post('jfother', true);
  2230. }
  2231. if ($category == 1702) {
  2232. $list['syhairther'] = $this->input->post('syhairther', true);
  2233. }
  2234. $classid = $this->classid->sku();
  2235. $scsku = $classid;
  2236. $pm = $classid;
  2237. foreach ($list as $k => $v) {
  2238. if ($v != 0) {
  2239. $num .= $v;
  2240. $features .= $v . '-';
  2241. $post[$k] = $v;
  2242. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2243. if ($k != 'size') {
  2244. $title .= $typeclass[$v]['title'] . " ";
  2245. }
  2246. if (isset($pm[$typeclass[$v]['classid']])) {
  2247. if ($typeclass[$v]['title'] == '9A') {
  2248. $pm[$typeclass[$v]['classid']] = '9A';
  2249. } else if ($typeclass[$v]['title'] == '10A') {
  2250. $pm[$typeclass[$v]['classid']] = '10A';
  2251. } else {
  2252. $clzh = $typeclass[$v]['zh'];
  2253. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2254. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2255. $clzh = $clzh[0];
  2256. }
  2257. $pm[$typeclass[$v]['classid']] = $clzh;
  2258. }
  2259. }
  2260. }
  2261. }
  2262. $zh = implode(" ", $pm);
  2263. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2264. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2265. if ($list['size']) {
  2266. $typeclass = $this->typeclass->read($list['size']);
  2267. $title .= $typeclass['title'];
  2268. }
  2269. $time = time();
  2270. if ($xzsku) {
  2271. $scsku = implode("-", $scsku);
  2272. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2273. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2274. $post['sku'] = trim($scsku, ' ');
  2275. } else {
  2276. $post['sku'] = $sku;
  2277. }
  2278. //$post['sku'] = trim($sku,' ');
  2279. $post['title'] = rtrim($title, ' ');
  2280. $post['number'] = $num;
  2281. $post['features'] = '-' . $features;
  2282. $post['enter'] = $time;
  2283. $post['time'] = $time; //操作时间
  2284. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2285. if ($yza) {
  2286. if ($post['features'] != $yza[0]['features']) {
  2287. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2288. exit;
  2289. }
  2290. }
  2291. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2292. if ($yzb) {
  2293. if ($post['sku'] != $yzb[0]['sku']) {
  2294. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2295. exit;
  2296. }
  2297. }
  2298. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2299. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2300. exit;
  2301. }
  2302. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2303. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2304. exit;
  2305. }
  2306. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2307. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2308. exit;
  2309. }
  2310. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2311. if (isset($yz[0]['type'])) {
  2312. $post['type'] = $yz[0]['type'];
  2313. }
  2314. if ($post['state'] == 9) //如果选择预设库存
  2315. {
  2316. $this->whlabel->insert($post);
  2317. } else {
  2318. /**
  2319. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2320. if($ljg == 1)
  2321. {
  2322. for($i=0;$i<$order;$i++)
  2323. {
  2324. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2325. $this->whlabel->insert($post);
  2326. }
  2327. }
  2328. **/
  2329. //if($post['warehouse'] == '5')
  2330. //{
  2331. //}
  2332. $yydata = $post;
  2333. $yydata['zh'] = $zh;
  2334. /**
  2335. $wl = $this->apiyy->get_cjlp($yydata);
  2336. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2337. {
  2338. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2339. }
  2340. if($wl['Data'][0]['m_isSucess'] != 1)
  2341. {
  2342. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2343. }
  2344. **/
  2345. for ($i = 0; $i < $order; $i++) {
  2346. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2347. $this->whlabel->insert($post);
  2348. }
  2349. }
  2350. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2351. exit;
  2352. }
  2353. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2354. $this->data['wlshop'] = $wlshop;
  2355. $this->_Template('whlabel_enteradd', $this->data);
  2356. }
  2357. //修改产品
  2358. public function _enteredit($arg_array)
  2359. {
  2360. $dt = 0;
  2361. if (isset($_SESSION['api'])) {
  2362. $user = $this->user->get_api($_SESSION['api']);
  2363. $usp = $user;
  2364. $fgshop = "";
  2365. $sid = "";
  2366. $user = explode('|', trim($user['shop'], '|'));
  2367. foreach ($user as $value) {
  2368. $fgshop .= " shop = " . $value . " or";
  2369. $sid .= " id = " . $value . " or";
  2370. }
  2371. }
  2372. $post = $this->input->post(NULL, TRUE);
  2373. if (isset($post['sku'])) {
  2374. $list = array();
  2375. $num = "";
  2376. $title = "";
  2377. $features = "";
  2378. $id = $this->input->post('id', true);
  2379. $order = $this->input->post('order', true);
  2380. $shop = $this->input->post('shop', true);
  2381. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2382. $post['sku'] = $this->input->post('sku', true);
  2383. $post['sm'] = $this->input->post('sm', true);
  2384. $post['warehouse'] = $this->input->post('warehouse', true);
  2385. $post['purchase'] = $this->input->post('purchase', true);
  2386. $post['retreatwarehouse'] = $post['warehouse'];
  2387. $category = $this->input->post('category', true);
  2388. $list['category'] = $category;
  2389. $list['hairtype'] = $this->input->post('hairtype', true);
  2390. $list['grade'] = $this->input->post('grade', true);
  2391. $size = $this->input->post('size', true);
  2392. $list['size'] = rtrim($size, ',');
  2393. $post['rktype'] = $this->input->post('rktype', true);
  2394. $post['text'] = $this->input->post('text', true);
  2395. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2396. $list['extension'] = $this->input->post('extension', true);
  2397. if ($category == 1297) {
  2398. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2399. }
  2400. if ($category == 1702) {
  2401. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2402. $list['syother'] = $this->input->post('syother', true);
  2403. }
  2404. if ($category == 133) {
  2405. $list['fittype'] = $this->input->post('fittype', true);
  2406. $list['acother'] = $this->input->post('acother', true);
  2407. }
  2408. $list['color'] = $this->input->post('color', true);
  2409. $list['lowe'] = $this->input->post('lowe', true);
  2410. if (!$post['purchase']) {
  2411. $post['purchase'] = 1;
  2412. }
  2413. if ($category == 127) {
  2414. $list['type'] = $this->input->post('type', true);
  2415. $list['headroad'] = $this->input->post('headroad', true);
  2416. $list['density'] = $this->input->post('density', true);
  2417. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2418. $list['lacesize'] = $this->input->post('lacesize', true);
  2419. }
  2420. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2421. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2422. }
  2423. if ($category == 128) {
  2424. $list['lacetype'] = $this->input->post('lacetype', true);
  2425. $list['haircap'] = $this->input->post('haircap', true);
  2426. $list['density'] = $this->input->post('density', true);
  2427. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2428. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2429. $list['wigother'] = $this->input->post('wigother', true);
  2430. $list['wigother1'] = $this->input->post('wigother1', true);
  2431. $list['wigother2'] = $this->input->post('wigother2', true);
  2432. $list['product_related'] = $this->input->post('product_related', true);
  2433. }
  2434. if ($category == 129) {
  2435. $list['wide'] = $this->input->post('wide', true);
  2436. }
  2437. if ($category == 131) {
  2438. $list['gifttype'] = $this->input->post('gifttype', true);
  2439. $list['giftother'] = $this->input->post('giftother', true);
  2440. }
  2441. if ($category == 134) {
  2442. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2443. }
  2444. if ($category == 1297) {
  2445. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2446. $list['sywigother'] = $this->input->post('sywigother', true);
  2447. }
  2448. if ($category == 130 || $category == 133 || $category == 1702) {
  2449. $list['items'] = $this->input->post('items', true);
  2450. $list['weight'] = $this->input->post('weight', true);
  2451. }
  2452. if($category == 130){
  2453. $list['jfother'] = $this->input->post('jfother', true);
  2454. }
  2455. if ($category == 1702) {
  2456. $list['syhairther'] = $this->input->post('syhairther', true);
  2457. }
  2458. foreach ($list as $k => $v) {
  2459. if ($v != 0) {
  2460. $num .= $v;
  2461. $features .= $v . '-';
  2462. $typeclass = $this->typeclass->read($v);
  2463. if ($k != 'size') {
  2464. $title .= $typeclass['title'] . " ";
  2465. }
  2466. }
  2467. }
  2468. $typeclass = $this->typeclass->read($list['size']);
  2469. $title .= $typeclass['title'];
  2470. $time = time();
  2471. $post['title'] = rtrim($title, ' ');
  2472. $post['number'] = $num;
  2473. $post['features'] = '-' . $features;
  2474. $post['time'] = $time; //操作时间
  2475. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2476. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2477. exit;
  2478. }
  2479. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2480. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2481. exit;
  2482. }
  2483. $uid = $this->whlabel->read($id);
  2484. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2485. if ($datanum > 0) {
  2486. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2487. exit;
  2488. }
  2489. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2490. {
  2491. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2492. if ($yza) {
  2493. if ($post['features'] != $yza[0]['features']) {
  2494. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2495. exit;
  2496. }
  2497. }
  2498. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2499. if ($yzb) {
  2500. if ($post['sku'] != $yzb[0]['sku']) {
  2501. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2502. exit;
  2503. }
  2504. }
  2505. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2506. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2507. exit;
  2508. }
  2509. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2510. foreach ($data as $v) {
  2511. $post['id'] = $v['id'];
  2512. $this->whlabel->save($post, $v['id']);
  2513. }
  2514. } else {
  2515. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2516. if ($data > 0) {
  2517. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2518. exit;
  2519. } else {
  2520. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2521. foreach ($data as $v) {
  2522. $post['id'] = $v['id'];
  2523. $this->whlabel->save($post, $v['id']);
  2524. }
  2525. }
  2526. }
  2527. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2528. exit;
  2529. }
  2530. $uid = $this->whlabel->read($arg_array[0]);
  2531. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2532. $this->data['enter'] = $uid;
  2533. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2534. $this->data['wlshop'] = $wlshop;
  2535. $this->_Template('whlabel_enteredit', $this->data);
  2536. }
  2537. //入库浏览
  2538. public function _enter()
  2539. {
  2540. $post = $this->input->post(NULL, TRUE);
  2541. if (isset($post['s'])) {
  2542. $id_arr = $this->input->post('s');
  2543. $id_arr = explode(',', $id_arr);
  2544. if (!$id_arr) {
  2545. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2546. exit;
  2547. }
  2548. //循环删除记录
  2549. foreach ($id_arr as $v) {
  2550. $sid = $this->whlabel->read($v);
  2551. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2552. if ($count > 0) {
  2553. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2554. exit;
  2555. }
  2556. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2557. foreach ($info_list as $va) {
  2558. $this->whlabel->remove($va['id']);
  2559. }
  2560. }
  2561. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2562. exit;
  2563. }
  2564. $sp = array();
  2565. $s = $this->shop->find_all('1=1', 'id,shopname');
  2566. foreach ($s as $v) {
  2567. $sp[$v['id']] = $v['shopname'];
  2568. }
  2569. $wh = array();
  2570. $w = $this->warehouse->find_all('1=1', 'id,title');
  2571. foreach ($w as $v) {
  2572. $wh[$v['id']] = $v['title'];
  2573. }
  2574. if (isset($post['page'])) {
  2575. $page = $this->input->post('page', true);
  2576. $perpage = $this->input->post('perpage', true);
  2577. $category = $this->input->post('category', true);
  2578. $size = $this->input->post('size', true);
  2579. $grade = $this->input->post('grade', true);
  2580. $color = $this->input->post('color', true);
  2581. $lowe = $this->input->post('lowe', true);
  2582. $sku = $this->input->post('sku', true);
  2583. $warehouse = $this->input->post('warehouse', true);
  2584. $purchase = $this->input->post('purchase', true);
  2585. $ktime = $this->input->post('ktime', true);
  2586. $jtime = $this->input->post('jtime', true);
  2587. $ktime = strtotime($ktime);
  2588. $jtime = strtotime($jtime);
  2589. $where = "1=1";
  2590. $gj = "";
  2591. $ck = "";
  2592. if ($category) {
  2593. $where .= " and features like '%-$category-%'";
  2594. }
  2595. if ($size) {
  2596. $where .= " and features like '%-$size-%'";
  2597. }
  2598. if ($grade) {
  2599. $where .= " and features like '%-$grade-%'";
  2600. }
  2601. if ($color) {
  2602. $where .= " and features like '%-$color-%'";
  2603. }
  2604. if ($lowe) {
  2605. $where .= " and features like '%-$lowe-%'";
  2606. }
  2607. if ($warehouse) {
  2608. $where .= " and warehouse = '$warehouse'";
  2609. }
  2610. if ($purchase) {
  2611. $where .= " and purchase = '$purchase'";
  2612. }
  2613. if ($sku) {
  2614. $where .= " and sku like '%$sku%'";
  2615. }
  2616. if ($ktime && $jtime) {
  2617. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2618. }
  2619. //数据排序
  2620. $order_str = "enter desc";
  2621. if (empty($page)) {
  2622. $start = 0;
  2623. $perpage = 1;
  2624. } else {
  2625. $start = ($page - 1) * $perpage;
  2626. }
  2627. //取得信息列表
  2628. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2629. foreach ($info_list as $k => $v) {
  2630. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2631. if ($v['shop'] == '') {
  2632. $s = '通用';
  2633. } else {
  2634. $info_list[$k]['shop'] = '';
  2635. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2636. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2637. }
  2638. }
  2639. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2640. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2641. $info_list[$k]['g'] = $g;
  2642. }
  2643. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2644. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2645. $pagenum = ceil($total / $perpage);
  2646. $over = $total - ($start + $perpage);
  2647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2648. echo json_encode($rows);
  2649. exit;
  2650. }
  2651. $this->_Template('whlabel_enter', $this->data);
  2652. }
  2653. //出库浏览
  2654. public function _out()
  2655. {
  2656. $post = $this->input->post(NULL, TRUE);
  2657. if (isset($post['page'])) {
  2658. $page = $this->input->post('page', true);
  2659. $perpage = $this->input->post('perpage', true);
  2660. $category = $this->input->post('category', true);
  2661. $size = $this->input->post('size', true);
  2662. $grade = $this->input->post('grade', true);
  2663. $color = $this->input->post('color', true);
  2664. $lowe = $this->input->post('lowe', true);
  2665. $sku = $this->input->post('sku', true);
  2666. $warehouse = $this->input->post('warehouse', true);
  2667. $purchase = $this->input->post('purchase', true);
  2668. $state = $this->input->post('state', true);
  2669. $ktime = $this->input->post('ktime', true);
  2670. $jtime = $this->input->post('jtime', true);
  2671. $ktime = strtotime($ktime);
  2672. $jtime = strtotime($jtime);
  2673. $where = "state=3";
  2674. $gj = "";
  2675. $ck = "";
  2676. if ($category) {
  2677. $where .= " and features like '%-$category-%'";
  2678. }
  2679. if ($size) {
  2680. $where .= " and features like '%-$size-%'";
  2681. }
  2682. if ($grade) {
  2683. $where .= " and features like '%-$grade-%'";
  2684. }
  2685. if ($color) {
  2686. $where .= " and features like '%-$color-%'";
  2687. }
  2688. if ($lowe) {
  2689. $where .= " and features like '%-$lowe-%'";
  2690. }
  2691. if ($state) {
  2692. $where .= " and state = '$state'";
  2693. }
  2694. if ($warehouse) {
  2695. $where .= " and warehouse = '$warehouse'";
  2696. }
  2697. if ($purchase) {
  2698. $where .= " and purchase = '$purchase'";
  2699. }
  2700. if ($sku) {
  2701. $where .= " and sku = '$sku'";
  2702. }
  2703. if ($ktime && $jtime) {
  2704. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2705. }
  2706. //数据排序
  2707. $order_str = "id desc";
  2708. if (empty($page)) {
  2709. $start = 0;
  2710. $perpage = 1;
  2711. } else {
  2712. $start = ($page - 1) * $perpage;
  2713. }
  2714. //取得信息列表
  2715. $info_list = $this->whlabel->find_all($where, 'sku');
  2716. $rows = array();
  2717. $list = array();
  2718. foreach ($info_list as $key => $value) {
  2719. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2720. }
  2721. $rows = array_unique($rows); //删除重复记录
  2722. foreach ($rows as $key => $value) {
  2723. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2724. $ck = $this->warehouse->read($data['warehouse']);
  2725. $warehouse = $ck['title'];
  2726. $gy = $this->purchase->read($data['purchase']);
  2727. $purchase = $gy['purchase'];
  2728. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2729. $list[] = array('id' => $data['id'], 'warehouse' => $warehouse, 'purchase' => $purchase, 'sku' => $data['sku'], 'title' => $data['title'], 'time' => date('Y-m-d H:i:s', $data['enter']), 'number' => $g);
  2730. }
  2731. $total = count($list);
  2732. $pagenum = ceil($total / $perpage);
  2733. $over = $total - ($start + $perpage);
  2734. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2735. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2736. echo json_encode($rows);
  2737. exit;
  2738. }
  2739. $this->_Template('whlabel_out', $this->data);
  2740. }
  2741. //出库标签浏览
  2742. public function _label()
  2743. {
  2744. $post = $this->input->post(NULL, TRUE);
  2745. if (isset($post['page'])) {
  2746. $page = $this->input->post('page', true);
  2747. $perpage = $this->input->post('perpage', true);
  2748. $sku = $this->input->post('sku', true);
  2749. $warehouse = $this->input->post('warehouse', true);
  2750. $purchase = $this->input->post('purchase', true);
  2751. $orderinfo = $this->input->post('orderinfo', true);
  2752. $waybill = $this->input->post('waybill', true);
  2753. $category = $this->input->post('category', true);
  2754. $size = $this->input->post('size', true);
  2755. $grade = $this->input->post('grade', true);
  2756. $color = $this->input->post('color', true);
  2757. $lowe = $this->input->post('lowe', true);
  2758. $where = "state=1";
  2759. if ($sku) {
  2760. $where .= " and sku = '$sku'";
  2761. }
  2762. if ($warehouse) {
  2763. $where .= " and warehouse = '$warehouse'";
  2764. }
  2765. if ($purchase) {
  2766. $where .= " and purchase = '$purchase'";
  2767. }
  2768. if ($orderinfo) {
  2769. $where .= " and orderinfo = '$orderinfo'";
  2770. }
  2771. if ($waybill) {
  2772. $where .= " and waybill = '$waybill'";
  2773. }
  2774. if ($category) {
  2775. $where .= " and features like '%-$category-%'";
  2776. }
  2777. if ($size) {
  2778. $where .= " and features like '%-$size-%'";
  2779. }
  2780. if ($grade) {
  2781. $where .= " and features like '%-$grade-%'";
  2782. }
  2783. if ($color) {
  2784. $where .= " and features like '%-$color-%'";
  2785. }
  2786. if ($lowe) {
  2787. $where .= " and features like '%-$lowe-%'";
  2788. }
  2789. //数据排序
  2790. $order_str = "outk desc";
  2791. if (empty($page)) {
  2792. $start = 0;
  2793. $perpage = 1;
  2794. } else {
  2795. $start = ($page - 1) * $perpage;
  2796. }
  2797. //取得信息列表
  2798. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2799. foreach ($info_list as $key => $value) {
  2800. $warehouse = $this->warehouse->read($value['warehouse']);
  2801. $info_list[$key]['warehouse'] = $warehouse['title'];
  2802. $purchase = $this->purchase->read($value['purchase']);
  2803. $info_list[$key]['purchase'] = $purchase['title'];
  2804. if ($value['outk'] != 0) {
  2805. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2806. } else {
  2807. $info_list[$key]['outk'] = "";
  2808. }
  2809. if ($value['orderinfo'] == 0) {
  2810. $info_list[$key]['orderinfo'] = "";
  2811. }
  2812. if ($value['waybill'] == 0) {
  2813. $info_list[$key]['waybill'] = "";
  2814. }
  2815. }
  2816. $total = $this->whlabel->find_count($where);
  2817. $pagenum = ceil($total / $perpage);
  2818. $over = $total - ($start + $perpage);
  2819. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2820. echo json_encode($rows);
  2821. exit;
  2822. }
  2823. $this->_Template('whlabel_label', $this->data);
  2824. }
  2825. //独立站出库订单
  2826. public function _outorder()
  2827. {
  2828. if (isset($_SESSION['api'])) {
  2829. $user = $this->user->get_api($_SESSION['api']);
  2830. $usp = $user;
  2831. $fgshop = "";
  2832. $sid = "";
  2833. $user = explode('|', trim($user['shop'], '|'));
  2834. foreach ($user as $value) {
  2835. $fgshop .= " shop = " . $value . " or";
  2836. $sid .= " id = " . $value . " or";
  2837. }
  2838. } else {
  2839. echo "请重新登录";
  2840. }
  2841. $post = $this->input->post(NULL, TRUE);
  2842. if (isset($post['page'])) {
  2843. $page = $this->input->post('page', true);
  2844. $perpage = $this->input->post('perpage', true);
  2845. $warehouse = $this->input->post('warehouse', true);
  2846. $xztime = $this->input->post('xztime', true);
  2847. $timetk = $this->input->post('timetkk', true);
  2848. $timetj = $this->input->post('timetjj', true);
  2849. $shop = $this->input->post('shop', true);
  2850. $source = $this->input->post('source', true);
  2851. $orderinfo = $this->input->post('orderinfo', true);
  2852. $number = $this->input->post('number', true);
  2853. $sfxh = $this->input->post('sfxh', true);
  2854. $express = $this->input->post('express', true);
  2855. $waybill = $this->input->post('waybill', true);
  2856. $library = $this->input->post('library', true);
  2857. $country = $this->input->post('country', true);
  2858. $so = $this->input->post('so', true);
  2859. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2860. $print = $this->input->post('print', true);
  2861. $state = $this->input->post('state', true);
  2862. $orderurl = $this->input->post('orderurl', true);
  2863. $productid = $this->input->post('productid', true);
  2864. $timetk = strtotime($timetk);
  2865. $timetj = strtotime($timetj);
  2866. /**
  2867. $sj = $this->input->post('sj',true);
  2868. if($sj)
  2869. {
  2870. $sj = $this->input->post('sj',true);
  2871. }
  2872. else
  2873. {
  2874. $sj = "fullorder";
  2875. }
  2876. **/
  2877. $sj = "fullorder";
  2878. $where = "1=1";
  2879. if ($warehouse) {
  2880. $where .= " and type = '$warehouse'";
  2881. }
  2882. if ($timetk && $timetj) {
  2883. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2884. }
  2885. if ($orderinfo) {
  2886. $where .= " and orderinfo = '$orderinfo'";
  2887. }
  2888. if ($number) {
  2889. $where .= " and number = '$number'";
  2890. }
  2891. if ($express) {
  2892. $where .= " and express = '$express'";
  2893. }
  2894. if ($waybill) {
  2895. $where .= " and waybill = '$waybill'";
  2896. }
  2897. if ($library) {
  2898. $where .= " and library = '$library'";
  2899. }
  2900. if ($print) {
  2901. $where .= " and print = '$print'";
  2902. }
  2903. if ($libraryconfirm) {
  2904. $where .= " and libraryconfirm = '$libraryconfirm'";
  2905. }
  2906. if ($state) {
  2907. $where .= " and state = '$state'";
  2908. }
  2909. if ($shop) {
  2910. $where .= " and shop = '$shop'";
  2911. }
  2912. if ($country) {
  2913. $where .= " and country = '$country'";
  2914. }
  2915. if ($sfxh != '') {
  2916. $where .= " and sfxh = '$sfxh'";
  2917. }
  2918. if ($so) {
  2919. $where .= " and shipremarks like '%$so%'";
  2920. }
  2921. if ($source) {
  2922. if ($source == '2d') {
  2923. $where .= " and source >= '2'";
  2924. } else {
  2925. $where .= " and source = '$source'";
  2926. }
  2927. }
  2928. if (isset($_SESSION['api'])) {
  2929. foreach ($user as $value) {
  2930. $fgshop .= " shop = " . $value . " or";
  2931. }
  2932. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2933. }
  2934. if ($orderurl) {
  2935. $url = $this->orderurl->read($orderurl);
  2936. $where .= " and link like '%" . $url['url'] . "%'";
  2937. }
  2938. if($productid){
  2939. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2940. }
  2941. //数据排序
  2942. $order_str = "librarytime desc";
  2943. if (empty($page)) {
  2944. $start = 0;
  2945. $perpage = 1;
  2946. } else {
  2947. $start = ($page - 1) * $perpage;
  2948. }
  2949. //取得信息列表
  2950. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2951. //格式化数据
  2952. foreach ($info_list as $key => $value) {
  2953. $shop = $this->shop->read($value['shop']);
  2954. $info_list[$key]['shop'] = $shop['shopname'];
  2955. $express = $this->express->read($value['express']);
  2956. $info_list[$key]['express'] = $express['servicename'];
  2957. $warehouse = $this->warehouse->read($value['type']);
  2958. $info_list[$key]['type'] = $warehouse['title'];
  2959. if ($value['librarytime'] == '0') {
  2960. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2961. } else {
  2962. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2963. }
  2964. }
  2965. $total = $this->$sj->find_count($where);
  2966. $pagenum = ceil($total / $perpage);
  2967. $over = $total - ($start + $perpage);
  2968. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2969. echo json_encode($rows);
  2970. exit;
  2971. }
  2972. $this->data['express'] = $this->express->find_all();
  2973. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2974. $this->data['wlshop'] = $wlshop;
  2975. $user = $this->user->get_api($_SESSION['api']);
  2976. $powerid = $this->power->read($user['power']);
  2977. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2978. $pid = '';
  2979. foreach ($powertext as $v) {
  2980. $pid .= " id = " . $v . " or";
  2981. }
  2982. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2983. $this->data['fullorderexcel'] = $fullorderexcel;
  2984. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2985. $this->data['orderurl'] = $orderurl;
  2986. $this->_Template('whlabel_outorder', $this->data);
  2987. }
  2988. //tt出库
  2989. public function _toutorder()
  2990. {
  2991. $fgshop = "";
  2992. $sid = "";
  2993. if (isset($_SESSION['api'])) {
  2994. $user = $this->user->get_api($_SESSION['api']);
  2995. $usp = $user;
  2996. $user = explode('|', trim($user['shop'], '|'));
  2997. foreach ($user as $value) {
  2998. $fgshop .= " shop = " . $value . " or";
  2999. $sid .= " id = " . $value . " or";
  3000. }
  3001. } else {
  3002. echo "请重新登录";
  3003. die;
  3004. }
  3005. $post = $this->input->post(NULL, TRUE);
  3006. if (isset($post['page'])) {
  3007. $page = $this->input->post('page', true);
  3008. $perpage = $this->input->post('perpage', true);
  3009. $warehouse = $this->input->post('warehouse', true);
  3010. $xztime = $this->input->post('xztime', true);
  3011. $timetk = $this->input->post('timetkk', true);
  3012. $timetj = $this->input->post('timetjj', true);
  3013. $shop = $this->input->post('shop', true);
  3014. $source = $this->input->post('source', true);
  3015. $orderinfo = $this->input->post('orderinfo', true);
  3016. $number = $this->input->post('number', true);
  3017. $sfxh = $this->input->post('sfxh', true);
  3018. $express = $this->input->post('express', true);
  3019. $waybill = $this->input->post('waybill', true);
  3020. $library = $this->input->post('library', true);
  3021. $country = $this->input->post('country', true);
  3022. $so = $this->input->post('so', true);
  3023. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3024. $print = $this->input->post('print', true);
  3025. $state = $this->input->post('state', true);
  3026. $orderurl = $this->input->post('orderurl', true);
  3027. $timetk = strtotime($timetk);
  3028. $timetj = strtotime($timetj);
  3029. /**
  3030. $sj = $this->input->post('sj',true);
  3031. if($sj)
  3032. {
  3033. $sj = $this->input->post('sj',true);
  3034. }
  3035. else
  3036. {
  3037. $sj = "fullorder";
  3038. }
  3039. **/
  3040. $sj = "fullordertt";
  3041. $where = "1=1";
  3042. if ($warehouse) {
  3043. $where .= " and type = '$warehouse'";
  3044. }
  3045. if ($timetk && $timetj) {
  3046. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3047. }
  3048. if ($orderinfo) {
  3049. $where .= " and orderinfo = '$orderinfo'";
  3050. }
  3051. if ($number) {
  3052. $where .= " and number = '$number'";
  3053. }
  3054. if ($express) {
  3055. $where .= " and express = '$express'";
  3056. }
  3057. if ($waybill) {
  3058. $where .= " and waybill = '$waybill'";
  3059. }
  3060. if ($library) {
  3061. $where .= " and library = '$library'";
  3062. }
  3063. if ($print) {
  3064. $where .= " and print = '$print'";
  3065. }
  3066. if ($libraryconfirm) {
  3067. $where .= " and libraryconfirm = '$libraryconfirm'";
  3068. }
  3069. if ($state) {
  3070. $where .= " and state = '$state'";
  3071. }
  3072. if ($shop) {
  3073. $where .= " and shop = '$shop'";
  3074. }
  3075. if ($country) {
  3076. $where .= " and country = '$country'";
  3077. }
  3078. if ($sfxh != '') {
  3079. $where .= " and sfxh = '$sfxh'";
  3080. }
  3081. if ($so) {
  3082. $where .= " and shipremarks like '%$so%'";
  3083. }
  3084. if ($source) {
  3085. if ($source == '2d') {
  3086. $where .= " and source >= '2'";
  3087. } else {
  3088. $where .= " and source = '$source'";
  3089. }
  3090. }
  3091. if (isset($_SESSION['api'])) {
  3092. foreach ($user as $value) {
  3093. $fgshop .= " shop = " . $value . " or";
  3094. }
  3095. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3096. }
  3097. if ($orderurl) {
  3098. $url = $this->orderurl->read($orderurl);
  3099. $where .= " and link like '%" . $url['url'] . "%'";
  3100. }
  3101. //数据排序
  3102. $order_str = "librarytime desc";
  3103. if (empty($page)) {
  3104. $start = 0;
  3105. $perpage = 1;
  3106. } else {
  3107. $start = ($page - 1) * $perpage;
  3108. }
  3109. //取得信息列表
  3110. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3111. //格式化数据
  3112. foreach ($info_list as $key => $value) {
  3113. $shop = $this->shop->read($value['shop']);
  3114. $info_list[$key]['shop'] = $shop['shopname'];
  3115. $express = $this->express->read($value['express']);
  3116. $info_list[$key]['express'] = $express['servicename'];
  3117. $warehouse = $this->warehouse->read($value['type']);
  3118. $info_list[$key]['type'] = $warehouse['title'];
  3119. if ($value['librarytime'] == '0') {
  3120. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3121. } else {
  3122. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3123. }
  3124. }
  3125. $total = $this->$sj->find_count($where);
  3126. $pagenum = ceil($total / $perpage);
  3127. $over = $total - ($start + $perpage);
  3128. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3129. echo json_encode($rows);
  3130. exit;
  3131. }
  3132. $this->data['express'] = $this->express->find_all();
  3133. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3134. $this->data['wlshop'] = $wlshop;
  3135. $user = $this->user->get_api($_SESSION['api']);
  3136. $powerid = $this->power->read($user['power']);
  3137. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3138. $pid = '';
  3139. foreach ($powertext as $v) {
  3140. $pid .= " id = " . $v . " or";
  3141. }
  3142. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3143. $this->data['fullorderexcel'] = $fullorderexcel;
  3144. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3145. $this->data['orderurl'] = $orderurl;
  3146. $this->_Template('whlabel_toutorder', $this->data);
  3147. }
  3148. //tt出库
  3149. public function _aoutorder()
  3150. {
  3151. if (isset($_SESSION['api'])) {
  3152. $user = $this->user->get_api($_SESSION['api']);
  3153. $usp = $user;
  3154. $fgshop = "";
  3155. $sid = "";
  3156. $user = explode('|', trim($user['shop'], '|'));
  3157. foreach ($user as $value) {
  3158. $fgshop .= " shop = " . $value . " or";
  3159. $sid .= " id = " . $value . " or";
  3160. }
  3161. } else {
  3162. echo "请重新登录";
  3163. }
  3164. $post = $this->input->post(NULL, TRUE);
  3165. if (isset($post['page'])) {
  3166. $page = $this->input->post('page', true);
  3167. $perpage = $this->input->post('perpage', true);
  3168. $warehouse = $this->input->post('warehouse', true);
  3169. $xztime = $this->input->post('xztime', true);
  3170. $timetk = $this->input->post('timetkk', true);
  3171. $timetj = $this->input->post('timetjj', true);
  3172. $shop = $this->input->post('shop', true);
  3173. $source = $this->input->post('source', true);
  3174. $orderinfo = $this->input->post('orderinfo', true);
  3175. $number = $this->input->post('number', true);
  3176. $sfxh = $this->input->post('sfxh', true);
  3177. $express = $this->input->post('express', true);
  3178. $waybill = $this->input->post('waybill', true);
  3179. $library = $this->input->post('library', true);
  3180. $country = $this->input->post('country', true);
  3181. $so = $this->input->post('so', true);
  3182. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3183. $print = $this->input->post('print', true);
  3184. $state = $this->input->post('state', true);
  3185. $orderurl = $this->input->post('orderurl', true);
  3186. $timetk = strtotime($timetk);
  3187. $timetj = strtotime($timetj);
  3188. /**
  3189. $sj = $this->input->post('sj',true);
  3190. if($sj)
  3191. {
  3192. $sj = $this->input->post('sj',true);
  3193. }
  3194. else
  3195. {
  3196. $sj = "fullorder";
  3197. }
  3198. **/
  3199. $sj = "fullorderamz";
  3200. $where = "1=1";
  3201. if ($warehouse) {
  3202. $where .= " and type = '$warehouse'";
  3203. }
  3204. if ($timetk && $timetj) {
  3205. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3206. }
  3207. if ($orderinfo) {
  3208. $where .= " and orderinfo = '$orderinfo'";
  3209. }
  3210. if ($number) {
  3211. $where .= " and number = '$number'";
  3212. }
  3213. if ($express) {
  3214. $where .= " and express = '$express'";
  3215. }
  3216. if ($waybill) {
  3217. $where .= " and waybill = '$waybill'";
  3218. }
  3219. if ($library) {
  3220. $where .= " and library = '$library'";
  3221. }
  3222. if ($print) {
  3223. $where .= " and print = '$print'";
  3224. }
  3225. if ($libraryconfirm) {
  3226. $where .= " and libraryconfirm = '$libraryconfirm'";
  3227. }
  3228. if ($state) {
  3229. $where .= " and state = '$state'";
  3230. }
  3231. if ($shop) {
  3232. $where .= " and shop = '$shop'";
  3233. }
  3234. if ($country) {
  3235. $where .= " and country = '$country'";
  3236. }
  3237. if ($sfxh != '') {
  3238. $where .= " and sfxh = '$sfxh'";
  3239. }
  3240. if ($so) {
  3241. $where .= " and shipremarks like '%$so%'";
  3242. }
  3243. if ($source) {
  3244. if ($source == '2d') {
  3245. $where .= " and source >= '2'";
  3246. } else {
  3247. $where .= " and source = '$source'";
  3248. }
  3249. }
  3250. if (isset($_SESSION['api'])) {
  3251. foreach ($user as $value) {
  3252. $fgshop .= " shop = " . $value . " or";
  3253. }
  3254. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3255. }
  3256. if ($orderurl) {
  3257. $url = $this->orderurl->read($orderurl);
  3258. $where .= " and link like '%" . $url['url'] . "%'";
  3259. }
  3260. //数据排序
  3261. $order_str = "librarytime desc";
  3262. if (empty($page)) {
  3263. $start = 0;
  3264. $perpage = 1;
  3265. } else {
  3266. $start = ($page - 1) * $perpage;
  3267. }
  3268. //取得信息列表
  3269. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3270. //格式化数据
  3271. foreach ($info_list as $key => $value) {
  3272. $shop = $this->shop->read($value['shop']);
  3273. $info_list[$key]['shop'] = $shop['shopname'];
  3274. $express = $this->express->read($value['express']);
  3275. $info_list[$key]['express'] = $express['servicename'];
  3276. $warehouse = $this->warehouse->read($value['type']);
  3277. $info_list[$key]['type'] = $warehouse['title'];
  3278. if ($value['librarytime'] == '0') {
  3279. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3280. } else {
  3281. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3282. }
  3283. }
  3284. $total = $this->$sj->find_count($where);
  3285. $pagenum = ceil($total / $perpage);
  3286. $over = $total - ($start + $perpage);
  3287. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3288. echo json_encode($rows);
  3289. exit;
  3290. }
  3291. $this->data['express'] = $this->express->find_all();
  3292. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3293. $this->data['wlshop'] = $wlshop;
  3294. $user = $this->user->get_api($_SESSION['api']);
  3295. $powerid = $this->power->read($user['power']);
  3296. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3297. $pid = '';
  3298. foreach ($powertext as $v) {
  3299. $pid .= " id = " . $v . " or";
  3300. }
  3301. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3302. $this->data['fullorderexcel'] = $fullorderexcel;
  3303. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3304. $this->data['orderurl'] = $orderurl;
  3305. $this->_Template('whlabel_aoutorder', $this->data);
  3306. }
  3307. //速卖通出库订单
  3308. public function _soutorder()
  3309. {
  3310. if (isset($_SESSION['api'])) {
  3311. $user = $this->user->get_api($_SESSION['api']);
  3312. $usp = $user;
  3313. $fgshop = "";
  3314. $sid = "";
  3315. $user = explode('|', trim($user['shop'], '|'));
  3316. foreach ($user as $value) {
  3317. $sid .= " id = " . $value . " or";
  3318. }
  3319. }
  3320. $post = $this->input->post(NULL, TRUE);
  3321. if (isset($post['page'])) {
  3322. $page = $this->input->post('page', true);
  3323. $perpage = $this->input->post('perpage', true);
  3324. $warehouse = $this->input->post('warehouse', true);
  3325. $xztime = $this->input->post('xztime', true);
  3326. $timetk = $this->input->post('timetkk', true);
  3327. $timetj = $this->input->post('timetjj', true);
  3328. $shop = $this->input->post('shop', true);
  3329. $source = $this->input->post('source', true);
  3330. $orderinfo = $this->input->post('orderinfo', true);
  3331. $number = $this->input->post('number', true);
  3332. $express = $this->input->post('express', true);
  3333. $waybill = $this->input->post('waybill', true);
  3334. $library = $this->input->post('library', true);
  3335. $country = $this->input->post('country', true);
  3336. $sfxh = $this->input->post('sfxh', true);
  3337. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3338. $print = $this->input->post('print', true);
  3339. $state = $this->input->post('state', true);
  3340. $so = $this->input->post('so', true);
  3341. $timetk = strtotime($timetk);
  3342. $timetj = strtotime($timetj);
  3343. /**
  3344. $sj = $this->input->post('sj',true);
  3345. if($sj)
  3346. {
  3347. $sj = $this->input->post('sj',true);
  3348. }
  3349. else
  3350. {
  3351. $sj = "fullorder";
  3352. }
  3353. **/
  3354. $sj = "fullordersmt";
  3355. $where = "1=1";
  3356. if ($warehouse) {
  3357. $where .= " and type = '$warehouse'";
  3358. }
  3359. if ($timetk && $timetj) {
  3360. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3361. }
  3362. if ($orderinfo) {
  3363. $where .= " and orderinfo = '$orderinfo'";
  3364. }
  3365. if ($number) {
  3366. $where .= " and number = '$number'";
  3367. }
  3368. if ($express) {
  3369. $where .= " and express = '$express'";
  3370. }
  3371. if ($waybill) {
  3372. $where .= " and waybill = '$waybill'";
  3373. }
  3374. if ($library) {
  3375. $where .= " and library = '$library'";
  3376. }
  3377. if ($print) {
  3378. $where .= " and print = '$print'";
  3379. }
  3380. if ($libraryconfirm) {
  3381. $where .= " and libraryconfirm = '$libraryconfirm'";
  3382. }
  3383. if ($state) {
  3384. $where .= " and state = '$state'";
  3385. }
  3386. if ($shop) {
  3387. $where .= " and shop = '$shop'";
  3388. }
  3389. if ($sfxh != '') {
  3390. $where .= " and sfxh = '$sfxh'";
  3391. }
  3392. if ($so) {
  3393. $where .= " and shipremarks like '%$so%'";
  3394. }
  3395. if ($source) {
  3396. $where .= " and source = '$source'";
  3397. }
  3398. if ($country) {
  3399. $where .= " and country = '$country'";
  3400. } else {
  3401. if (isset($_SESSION['api'])) {
  3402. foreach ($user as $value) {
  3403. $fgshop .= " shop = " . $value . " or";
  3404. }
  3405. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3406. }
  3407. }
  3408. //数据排序
  3409. $order_str = "librarytime desc";
  3410. if (empty($page)) {
  3411. $start = 0;
  3412. $perpage = 1;
  3413. } else {
  3414. $start = ($page - 1) * $perpage;
  3415. }
  3416. //取得信息列表
  3417. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3418. //格式化数据
  3419. foreach ($info_list as $key => $value) {
  3420. $shop = $this->shop->read($value['shop']);
  3421. $info_list[$key]['shop'] = $shop['shopname'];
  3422. $express = $this->express->read($value['express']);
  3423. $info_list[$key]['express'] = $express['servicename'];
  3424. $warehouse = $this->warehouse->read($value['type']);
  3425. $info_list[$key]['type'] = $warehouse['title'];
  3426. if ($value['librarytime'] == '0') {
  3427. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3428. } else {
  3429. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3430. }
  3431. }
  3432. $total = $this->$sj->find_count($where);
  3433. $pagenum = ceil($total / $perpage);
  3434. $over = $total - ($start + $perpage);
  3435. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3436. echo json_encode($rows);
  3437. exit;
  3438. }
  3439. $this->data['express'] = $this->express->find_all();
  3440. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3441. $this->data['wlshop'] = $wlshop;
  3442. $user = $this->user->get_api($_SESSION['api']);
  3443. $powerid = $this->power->read($user['power']);
  3444. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3445. $pid = '';
  3446. foreach ($powertext as $v) {
  3447. $pid .= " id = " . $v . " or";
  3448. }
  3449. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3450. $this->data['fullorderexcel'] = $fullorderexcel;
  3451. $this->_Template('whlabel_soutorder', $this->data);
  3452. }
  3453. //订单退库
  3454. public function _retreat()
  3455. {
  3456. $post = $this->input->post(NULL, TRUE);
  3457. if (isset($post['page'])) {
  3458. $page = $this->input->post('page', true);
  3459. $perpage = $this->input->post('perpage', true);
  3460. $warehouse = $this->input->post('warehouse', true);
  3461. $timetk = $this->input->post('timetk', true);
  3462. $timetj = $this->input->post('timetj', true);
  3463. $shop = $this->input->post('shop', true);
  3464. $source = $this->input->post('source', true);
  3465. $state = $this->input->post('state', true);
  3466. $review = $this->input->post('review', true);
  3467. $state = $this->input->post('state', true);
  3468. $express = $this->input->post('express', true);
  3469. $orderinfo = $this->input->post('orderinfo', true);
  3470. $user = $this->input->post('user', true);
  3471. $name = $this->input->post('name', true);
  3472. $waybill = $this->input->post('waybill', true);
  3473. $timetk = strtotime($timetk);
  3474. $timetj = strtotime($timetj);
  3475. $where = "(state=206 or state=210) and mergeid = 0";
  3476. if ($warehouse) {
  3477. $where .= " and state = '$warehouse'";
  3478. }
  3479. if ($timetk && $timetj) {
  3480. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3481. }
  3482. if ($shop) {
  3483. $where .= " and shop = '$shop'";
  3484. }
  3485. if ($source) {
  3486. $where .= " and source = '$source'";
  3487. }
  3488. if ($state) {
  3489. $where .= " and state = '$state'";
  3490. }
  3491. if ($review) {
  3492. $where .= " and review = '$review'";
  3493. }
  3494. if ($state) {
  3495. $where .= " and state = '$state'";
  3496. }
  3497. if ($express) {
  3498. $where .= " and express = '$express'";
  3499. }
  3500. if ($orderinfo) {
  3501. $where .= " and orderinfo = '$orderinfo'";
  3502. }
  3503. if ($user) {
  3504. $where .= " and user = '$user'";
  3505. }
  3506. if ($name) {
  3507. $where .= " and name = '$name'";
  3508. }
  3509. if ($waybill) {
  3510. $where .= " and waybill = '$waybill'";
  3511. }
  3512. //数据排序
  3513. $order_str = "id desc";
  3514. if (empty($page)) {
  3515. $start = 0;
  3516. $perpage = 1;
  3517. } else {
  3518. $start = ($page - 1) * $perpage;
  3519. }
  3520. //取得信息列表
  3521. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3522. //格式化数据
  3523. foreach ($info_list as $key => $value) {
  3524. $shop = $this->shop->read($value['shop']);
  3525. $info_list[$key]['shop'] = $shop['shopname'];
  3526. $warehouse = $this->warehouse->read($value['warehouse']);
  3527. $info_list[$key]['warehouse'] = $warehouse['title'];
  3528. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3529. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3530. if ($value['waybill'] == 0) {
  3531. $info_list[$key]['waybill'] = "";
  3532. }
  3533. $express = $this->express->read($value['express']);
  3534. $info_list[$key]['express'] = $express['title'];
  3535. $typeclass = $this->typeclass->read($value['state']);
  3536. $info_list[$key]['state'] = $typeclass['title'];
  3537. }
  3538. $total = $this->fullorder->find_count($where);
  3539. $pagenum = ceil($total / $perpage);
  3540. $over = $total - ($start + $perpage);
  3541. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3542. echo json_encode($rows);
  3543. exit;
  3544. }
  3545. $this->data['express'] = $this->express->find_all();
  3546. $this->_Template('whlabel_retreat', $this->data);
  3547. }
  3548. //退库标签浏览
  3549. public function _retreatlk()
  3550. {
  3551. $post = $this->input->post(NULL, TRUE);
  3552. if (isset($post['page'])) {
  3553. $page = $this->input->post('page', true);
  3554. $perpage = $this->input->post('perpage', true);
  3555. $timetk = $this->input->post('timetk', true);
  3556. $timetj = $this->input->post('timetj', true);
  3557. $sku = $this->input->post('sku', true);
  3558. $warehouse = $this->input->post('warehouse', true);
  3559. $purchase = $this->input->post('purchase', true);
  3560. $orderinfo = $this->input->post('orderinfo', true);
  3561. $waybill = $this->input->post('waybill', true);
  3562. $category = $this->input->post('category', true);
  3563. $size = $this->input->post('size', true);
  3564. $grade = $this->input->post('grade', true);
  3565. $color = $this->input->post('color', true);
  3566. $lowe = $this->input->post('lowe', true);
  3567. $state = $this->input->post('state', true);
  3568. $timetk = strtotime($timetk);
  3569. $timetj = strtotime($timetj);
  3570. $where = "state=2";
  3571. if ($timetk && $timetj) {
  3572. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3573. }
  3574. if ($sku) {
  3575. $where .= " and sku = '$sku'";
  3576. }
  3577. if ($warehouse) {
  3578. $where .= " and warehouse = '$warehouse'";
  3579. }
  3580. if ($purchase) {
  3581. $where .= " and purchase = '$purchase'";
  3582. }
  3583. if ($orderinfo) {
  3584. $where .= " and orderinfo = '$orderinfo'";
  3585. }
  3586. if ($waybill) {
  3587. $where .= " and waybill = '$waybill'";
  3588. }
  3589. if ($category) {
  3590. $where .= " and features like '%-$category-%'";
  3591. }
  3592. if ($size) {
  3593. $where .= " and features like '%-$size-%'";
  3594. }
  3595. if ($grade) {
  3596. $where .= " and features like '%-$grade-%'";
  3597. }
  3598. if ($color) {
  3599. $where .= " and features like '%-$color-%'";
  3600. }
  3601. if ($lowe) {
  3602. $where .= " and features like '%-$lowe-%'";
  3603. }
  3604. //数据排序
  3605. $order_str = "time desc";
  3606. if (empty($page)) {
  3607. $start = 0;
  3608. $perpage = 1;
  3609. } else {
  3610. $start = ($page - 1) * $perpage;
  3611. }
  3612. //取得信息列表
  3613. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3614. foreach ($info_list as $key => $value) {
  3615. $warehouse = $this->warehouse->read($value['warehouse']);
  3616. $info_list[$key]['warehouse'] = $warehouse['title'];
  3617. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3618. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3619. $purchase = $this->purchase->read($value['purchase']);
  3620. $info_list[$key]['purchase'] = $purchase['title'];
  3621. if ($value['outk'] != 0) {
  3622. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3623. } else {
  3624. $info_list[$key]['outk'] = "";
  3625. }
  3626. if ($value['retreat'] != 0) {
  3627. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3628. } else {
  3629. $info_list[$key]['retreat'] = "";
  3630. }
  3631. if ($value['orderinfo'] == 0) {
  3632. $info_list[$key]['orderinfo'] = "";
  3633. }
  3634. if ($value['waybill'] == 0) {
  3635. $info_list[$key]['waybill'] = "";
  3636. }
  3637. }
  3638. $total = $this->whlabel->find_count($where);
  3639. $pagenum = ceil($total / $perpage);
  3640. $over = $total - ($start + $perpage);
  3641. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3642. echo json_encode($rows);
  3643. exit;
  3644. }
  3645. $this->_Template('whlabel_retreatlk', $this->data);
  3646. }
  3647. //更换标签及浏览
  3648. public function _change()
  3649. {
  3650. $post = $this->input->post(NULL, TRUE);
  3651. if (isset($post['page'])) {
  3652. $page = $this->input->post('page', true);
  3653. $perpage = $this->input->post('perpage', true);
  3654. $timetk = $this->input->post('timetk', true);
  3655. $timetj = $this->input->post('timetj', true);
  3656. $label = $this->input->post('label', true);
  3657. $oldlabel = $this->input->post('oldlabel', true);
  3658. $timetk = strtotime($timetk);
  3659. $timetj = strtotime($timetj);
  3660. $where = "state=10 ";
  3661. if ($timetk && $timetj) {
  3662. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3663. }
  3664. if ($label) {
  3665. $where .= " and label = '$label'";
  3666. }
  3667. if ($oldlabel) {
  3668. $where .= " and oldlabel = '$oldlabel'";
  3669. }
  3670. //数据排序
  3671. $order_str = "time asc";
  3672. if (empty($page)) {
  3673. $start = 0;
  3674. $perpage = 1;
  3675. } else {
  3676. $start = ($page - 1) * $perpage;
  3677. }
  3678. //取得信息列表
  3679. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3680. foreach ($info_list as $key => $value) {
  3681. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3682. }
  3683. $total = $this->whlabel->find_count($where);
  3684. $pagenum = ceil($total / $perpage);
  3685. $over = $total - ($start + $perpage);
  3686. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3687. echo json_encode($rows);
  3688. exit;
  3689. }
  3690. $this->_Template('whlabel_change', $this->data);
  3691. }
  3692. //产品标签
  3693. public function _cpbqdc()
  3694. {
  3695. if (isset($_GET['excel'])) {
  3696. $where = "1=1";
  3697. //数据排序
  3698. $order_str = "id desc";
  3699. if (empty($page)) {
  3700. $start = 0;
  3701. $perpage = 1;
  3702. } else {
  3703. $start = ($page - 1) * $perpage;
  3704. }
  3705. $warehouse = $this->input->get('warehouse', true);
  3706. $state = $this->input->get('state', true);
  3707. $timetk = $this->input->get('timetkk', true);
  3708. $timetj = $this->input->get('timetjj', true);
  3709. $timetk = strtotime($timetk);
  3710. $timetj = strtotime($timetj);
  3711. if ($warehouse) {
  3712. $where .= " and warehouse = '$warehouse'";
  3713. }
  3714. if ($state || $state == 0) {
  3715. $where .= " and state = '$state'";
  3716. }
  3717. if ($timetk && $timetj) {
  3718. $where .= " and time > '$timetk' and time < '$timetj'";
  3719. }
  3720. //取得信息列表
  3721. $info_list = $this->whlabel->find_all($where, '*');
  3722. $rows = array();
  3723. $list = array();
  3724. foreach ($info_list as $key => $value) {
  3725. $rows[$value['time']] = $value; //所有数据sku
  3726. }
  3727. foreach ($rows as $value) {
  3728. $warehouse = $this->warehouse->read($value['warehouse']);
  3729. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3730. $list[] = array($warehouse['title'], $value['sku'], $value['title'], date('Y-m-d H:i:s', $value['enter']), date('Y-m-d H:i:s', $value['time']), $value['text'], $s);
  3731. }
  3732. $title = "产品标签统计表";
  3733. $titlename = "<table border=1>
  3734. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3735. <tr align='center'>
  3736. <td>仓库</td>
  3737. <td>SKU</td>
  3738. <td>产品</td>
  3739. <td>入库时间</td>
  3740. <td>操作时间</td>
  3741. <td>备注</td>
  3742. <td>数量</td>
  3743. </tr>
  3744. </table>";
  3745. $filename = $title . ".xls";
  3746. $tail = "";
  3747. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3748. }
  3749. }
  3750. //进销存导出
  3751. public function _exceljxc()
  3752. {
  3753. $classid = $this->classid->sku();
  3754. $pm = $classid;
  3755. $typeclass = array();
  3756. $tc = $this->typeclass->find_all();
  3757. foreach ($tc as $v) {
  3758. $typeclass[$v['id']] = $v;
  3759. }
  3760. $prc = array();
  3761. $purchase = $this->purchase->find_all();
  3762. foreach ($purchase as $k => $v) {
  3763. $prc[$v['id']] = $v['title'];
  3764. }
  3765. if (isset($_GET['excel'])) {
  3766. $where = "sku != 'Preset'";
  3767. //数据排序
  3768. $order_str = "id desc";
  3769. if (empty($page)) {
  3770. $start = 0;
  3771. $perpage = 1;
  3772. } else {
  3773. $start = ($page - 1) * $perpage;
  3774. }
  3775. $category = $this->input->get('category', true);
  3776. $warehouse = $this->input->get('warehouse', true);
  3777. $excelid = $this->input->get('sid', true);
  3778. if ($category) {
  3779. $where .= " and features like '%-$category-%'";
  3780. }
  3781. if ($warehouse) {
  3782. $where .= " and warehouse = '$warehouse'";
  3783. }
  3784. $xzid = '';
  3785. if ($excelid) {
  3786. $excelid = explode(',', trim($excelid, ','));
  3787. foreach ($excelid as $key => $value) {
  3788. $xzid .= " id = " . $value . " or";
  3789. }
  3790. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3791. }
  3792. //取得信息列表
  3793. /**
  3794. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3795. $rows = array();$list = array();
  3796. foreach ($info_list as $key=>$value)
  3797. {
  3798. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3799. }
  3800. **/
  3801. $wt = array();
  3802. $whlabel_type = $this->whlabel_type->find_all();
  3803. foreach ($whlabel_type as $v) {
  3804. $wt[$v['id']] = $v['title'];
  3805. }
  3806. $wh = array();
  3807. $w = $this->warehouse->find_all('1=1', 'id,title');
  3808. foreach ($w as $v) {
  3809. $wh[$v['id']] = $v['title'];
  3810. }
  3811. $list = array();
  3812. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3813. foreach ($rows as $key => $value) {
  3814. if (isset($wt[$value['type']])) {
  3815. $rows[$key]['type'] = $wt[$value['type']];
  3816. } else {
  3817. $rows[$key]['type'] = '未设置';
  3818. }
  3819. $bm = '03';
  3820. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3821. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3822. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  3823. $details = array();
  3824. $cpid = array();
  3825. $cpbz = array();
  3826. $c = 0;
  3827. $g = 0;
  3828. $x = 0;
  3829. $t = 0;
  3830. $s = 0;
  3831. $q = 0;
  3832. foreach ($sd as $k => $v) {
  3833. if ($v['state'] == 0) {
  3834. $c++;
  3835. if ($v['cpid'] != 0) {
  3836. $cpid[$v['cpid']] = $v['cpid'];
  3837. }
  3838. if ($v['cpbz'] != '') {
  3839. $cpbz[$v['cpbz']] = $v['cpbz'];
  3840. }
  3841. }
  3842. if ($v['state'] != 9) {
  3843. $g++;
  3844. }
  3845. if ($v['state'] == 1) {
  3846. $x++;
  3847. }
  3848. if ($v['state'] == 2) {
  3849. $t++;
  3850. }
  3851. if ($v['state'] == 8) {
  3852. $s++;
  3853. }
  3854. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3855. $q++;
  3856. }
  3857. $details[$v['details']] = $v['details'];
  3858. }
  3859. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  3860. $rows[$key]['details'] = implode("、", $details);
  3861. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3862. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3863. $number = $value['number'];
  3864. $ftime = time() - 15 * 24 * 3600;
  3865. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3866. $rows[$key]['number'] = $g;
  3867. $rows[$key]['c'] = $c;
  3868. $rows[$key]['x'] = $x;
  3869. $rows[$key]['t'] = $t;
  3870. $rows[$key]['s'] = $s;
  3871. $rows[$key]['q'] = $q;
  3872. $rows[$key]['z'] = $z;
  3873. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3874. $features = explode('-', trim($features, '-'));
  3875. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3876. // $pm = $classid;
  3877. // $jm = $classid;
  3878. // foreach($features as $k=>$v)
  3879. // {
  3880. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3881. // {
  3882. // if($typeclass[$v]['bm'] != '')
  3883. // {
  3884. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3885. // }
  3886. // }
  3887. // if($v != 0)
  3888. // {
  3889. // if(!isset($typeclass[$v]))
  3890. // {
  3891. // continue;
  3892. // }
  3893. // if(isset($pm[$typeclass[$v]['classid']]))
  3894. // {
  3895. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3896. // {
  3897. // $tz = explode('|',$typeclass[$v]['zh']);
  3898. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3899. // }
  3900. // else
  3901. // {
  3902. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3903. // }
  3904. // }
  3905. // if(isset($jm[$typeclass[$v]['classid']]))
  3906. // {
  3907. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3908. // }
  3909. // }
  3910. // }
  3911. // $jm = array_filter($jm);
  3912. // $rows[$key]['bs'] = implode("-",$jm);
  3913. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3914. // $zh = implode(" ",$pm);
  3915. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3916. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3917. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3918. // $rows[$key]['features'] = $zh;
  3919. }
  3920. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3921. $final_list = [];
  3922. foreach ($list as $k => $v) {
  3923. if (empty($v['sku'])) {
  3924. continue;
  3925. }
  3926. $final_list[] = [
  3927. "warehouse" => $v["warehouse"],
  3928. "purchase" => $v["purchase"],
  3929. "details" => $v["details"],
  3930. "cpid" => $v["cpid"],
  3931. "dbcontent" => $v["dbcontent"],
  3932. "sku" => $v["sku"],
  3933. "cs" => $v["bm"],
  3934. "bs" => $v["jm"],
  3935. "title" => $v["title"],
  3936. "features" => $v["pm"],
  3937. "cpbz" => $v["cpbz"],
  3938. "sm" => $v["sm"],
  3939. "type" => $v["type"],
  3940. "number" => $v["number"],
  3941. "c" => $v["c"],
  3942. "x" => $v["x"],
  3943. "t" => $v["t"],
  3944. "s" => $v["s"],
  3945. "q" => $v["q"],
  3946. "z" => $v["z"],
  3947. "weight" => $v['weight'],
  3948. ];
  3949. }
  3950. $title = "总进销存统计表";
  3951. $titlename = "<table border=1>
  3952. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3953. <tr align='center'>
  3954. <td>仓库</td>
  3955. <td>供应商</td>
  3956. <td>位置</td>
  3957. <td>库存编码</td>
  3958. <td>类目</td>
  3959. <td>SKU</td>
  3960. <td>用友编码</td>
  3961. <td>用友料号</td>
  3962. <td>商品名称</td>
  3963. <td>商品中文</td>
  3964. <td>产品备注</td>
  3965. <td>库位负责人</td>
  3966. <td>类型</td>
  3967. <td>入库总量</td>
  3968. <td>库存数量</td>
  3969. <td>销售数量</td>
  3970. <td>退货数量</td>
  3971. <td>删除数量</td>
  3972. <td>其它操作</td>
  3973. <td>占单数量</td>
  3974. <td>重量(g)</td>
  3975. </tr>
  3976. </table>";
  3977. $filename = $title . ".xls";
  3978. $tail = "";
  3979. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3980. }
  3981. }
  3982. //入库导出
  3983. public function _excelr()
  3984. {
  3985. if (isset($_GET['excel'])) {
  3986. $category = $this->input->get('category', true);
  3987. $size = $this->input->get('size', true);
  3988. $grade = $this->input->get('grade', true);
  3989. $color = $this->input->get('color', true);
  3990. $lowe = $this->input->get('lowe', true);
  3991. $sku = $this->input->get('sku', true);
  3992. $warehouse = $this->input->get('warehouse', true);
  3993. $purchase = $this->input->get('purchase', true);
  3994. $ktime = $this->input->get('ktime', true);
  3995. $jtime = $this->input->get('jtime', true);
  3996. $rktype = $this->input->get('rktype',true);
  3997. $ktime = strtotime($ktime);
  3998. $jtime = strtotime($jtime);
  3999. $where = "1=1";
  4000. $gj = "";
  4001. $ck = "";
  4002. if ($category) {
  4003. $where .= " and features like '%-$category-%'";
  4004. }
  4005. if ($size) {
  4006. $where .= " and features like '%-$size-%'";
  4007. }
  4008. if ($grade) {
  4009. $where .= " and features like '%-$grade-%'";
  4010. }
  4011. if ($color) {
  4012. $where .= " and features like '%-$color-%'";
  4013. }
  4014. if ($lowe) {
  4015. $where .= " and features like '%-$lowe-%'";
  4016. }
  4017. if ($warehouse) {
  4018. $where .= " and warehouse = '$warehouse'";
  4019. }
  4020. if ($purchase) {
  4021. $where .= " and purchase = '$purchase'";
  4022. }
  4023. if ($sku) {
  4024. $where .= " and sku = '$sku'";
  4025. }
  4026. if($rktype){
  4027. $where .= " and rktype = '$rktype' ";
  4028. }
  4029. if ($ktime && $jtime) {
  4030. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4031. }
  4032. //数据排序
  4033. $order_str = "id desc";
  4034. if (empty($page)) {
  4035. $start = 0;
  4036. $perpage = 1;
  4037. } else {
  4038. $start = ($page - 1) * $perpage;
  4039. }
  4040. $list = array();
  4041. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4042. foreach ($rows as $value) {
  4043. $ck = $this->warehouse->read($value['warehouse']);
  4044. $warehouse = $ck['title'];
  4045. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4046. $retreatwarehouse = $tkck['title'];
  4047. $gy = $this->purchase->read($value['purchase']);
  4048. $purchase = $gy['title'];
  4049. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4050. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4051. }
  4052. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4053. $titlename = "<table border=1>
  4054. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4055. <tr align='center'>
  4056. <td>仓库</td>
  4057. <td>SKU</td>
  4058. <td>产品</td>
  4059. <td>时间</td>
  4060. <td>数量</td>
  4061. </tr>
  4062. </table>";
  4063. $filename = $title . ".xls";
  4064. $tail = "";
  4065. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4066. }
  4067. }
  4068. //出库、退库导出
  4069. public function _excelct()
  4070. {
  4071. $classid = $this->classid->sku();
  4072. $pm = $classid;
  4073. $typeclass = array();
  4074. $tc = $this->typeclass->find_all();
  4075. foreach ($tc as $v) {
  4076. $typeclass[$v['id']] = $v;
  4077. }
  4078. $prc = array();
  4079. $purchase = $this->purchase->find_all();
  4080. foreach ($purchase as $k => $v) {
  4081. $prc[$v['id']] = $v['title'];
  4082. }
  4083. if (isset($_GET['excel'])) {
  4084. $wh = array();
  4085. $w = $this->warehouse->find_all('1=1', 'id,title');
  4086. foreach ($w as $v) {
  4087. $wh[$v['id']] = $v['title'];
  4088. }
  4089. $type = $this->input->get('excel', true);
  4090. $category = $this->input->get('category', true);
  4091. $size = $this->input->get('size', true);
  4092. $grade = $this->input->get('grade', true);
  4093. $color = $this->input->get('color', true);
  4094. $lowe = $this->input->get('lowe', true);
  4095. $sku = $this->input->get('sku', true);
  4096. $title = $this->input->get('title', true);
  4097. $warehouse = $this->input->get('warehouse', true);
  4098. $purchase = $this->input->get('purchase', true);
  4099. $lacetype = $this->input->get('lacetype', true);
  4100. $haircap = $this->input->get('haircap', true);
  4101. $lacecolor = $this->input->get('lacecolor', true);
  4102. $density = $this->input->get('density', true);
  4103. $details = $this->input->get('details', true);
  4104. $state = $this->input->get('state', true);
  4105. $shop = $this->input->get('shop', true);
  4106. $hairnumber = $this->input->get('hairnumber', true);
  4107. $type_leixi = $this->input->get('type', true);
  4108. $cpbz = $this->input->get('cpbz', true);
  4109. $sm = $this->input->get('sm', true);
  4110. $sid = $this->input->get('sid', true);
  4111. $ktime = $this->input->get('ktime', true);
  4112. $jtime = $this->input->get('jtime', true);
  4113. $ktime = strtotime($ktime);
  4114. $jtime = strtotime($jtime);
  4115. //$where = " 1=1 ";
  4116. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4117. $where = " sku != '' ";
  4118. $gj = "";
  4119. $ck = "";
  4120. if ($category) {
  4121. $where .= " and features like '%-$category-%'";
  4122. }
  4123. if ($size) {
  4124. $where .= " and features like '%-$size-%'";
  4125. }
  4126. if ($grade) {
  4127. $where .= " and features like '%-$grade-%'";
  4128. }
  4129. if ($color) {
  4130. $where .= " and features like '%-$color-%'";
  4131. }
  4132. if ($lowe) {
  4133. $where .= " and features like '%-$lowe-%'";
  4134. }
  4135. if ($warehouse) {
  4136. $where .= " and warehouse = '$warehouse'";
  4137. }
  4138. if ($purchase) {
  4139. $where .= " and purchase = '$purchase'";
  4140. }
  4141. if ($state) {
  4142. $where .= " and state = '$state'";
  4143. }
  4144. if ($lacetype) {
  4145. $where .= " and features like '%-$lacetype-%'";
  4146. }
  4147. if ($lacecolor) {
  4148. $where .= " and features like '%-$lacecolor-%'";
  4149. }
  4150. if ($density) {
  4151. $where .= " and features like '%-$density-%'";
  4152. }
  4153. if ($haircap) {
  4154. $where .= " and features like '%-$haircap-%'";
  4155. }
  4156. if ($details) {
  4157. $where .= " and details = '$details'";
  4158. }
  4159. if ($shop) {
  4160. $where .= " and shop like '%$shop%'";
  4161. }
  4162. if ($title) {
  4163. $title = trim($title, ' ');
  4164. $title = trim($title, ' ');
  4165. $where .= " and title like '%$title%'";
  4166. }
  4167. if (!empty($hairnumber)) {
  4168. $where .= " and features like '%-128-%' ";
  4169. if ($hairnumber < 0) {
  4170. $class_list = $this->typeclass->find_all('classid = 43');
  4171. foreach ($class_list as $v) {
  4172. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4173. }
  4174. } else {
  4175. $where .= " and features like '%-$hairnumber-%'";
  4176. }
  4177. }
  4178. if ($type_leixi) {
  4179. $where .= " and type = '$type_leixi'";
  4180. }
  4181. if ($cpbz) {
  4182. $where .= " and cpbz like '%$cpbz%' ";
  4183. }
  4184. if ($sm) {
  4185. $where .= " and sm like '%$sm%' ";
  4186. }
  4187. if ($sku) {
  4188. $sku = trim($sku, ' ');
  4189. $sku = trim($sku, ' ');
  4190. $where .= " and sku like '%$sku%'";
  4191. }
  4192. if ($ktime && $jtime) {
  4193. if ($type == 1) {
  4194. $tl = '出库';
  4195. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4196. } else if ($type == 2) {
  4197. $tl = '退库';
  4198. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4199. } else if ($type == 3) {
  4200. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4201. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4202. } else if ($type == 4) {
  4203. $tl = '出库+零售';
  4204. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4205. } else if ($type == 5) {
  4206. $tl = '零售';
  4207. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4208. }
  4209. }
  4210. $sidwhere = '';
  4211. if ($sid) {
  4212. $sd = "";
  4213. $s = explode(',', trim($sid, ','));
  4214. foreach ($s as $value) {
  4215. $sd .= " id = " . $value . " or";
  4216. }
  4217. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4218. }
  4219. //数据排序
  4220. $order_str = "time desc";
  4221. if (empty($page)) {
  4222. $start = 0;
  4223. $perpage = 1;
  4224. } else {
  4225. $start = ($page - 1) * $perpage;
  4226. }
  4227. //取得信息列表
  4228. if ($type != 3 && $type != 5) {
  4229. if ($type == 1 || $type == 4) {
  4230. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4231. foreach ($info_list as $key => $value) {
  4232. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4233. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4234. $warehouse = $this->warehouse->read($value['warehouse']);
  4235. $info_list[$key]['warehouse'] = $warehouse['title'];
  4236. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4237. $features = explode('-', trim($features, '-'));
  4238. $pm = $classid;
  4239. foreach ($features as $k => $v) {
  4240. if ($v != 0) {
  4241. if (!isset($typeclass[$v])) {
  4242. continue;
  4243. }
  4244. if (isset($pm[$typeclass[$v]['classid']])) {
  4245. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4246. $tz = explode('|', $typeclass[$v]['zh']);
  4247. $pm[$typeclass[$v]['classid']] = $tz[0];
  4248. } else {
  4249. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4250. }
  4251. }
  4252. }
  4253. }
  4254. $zh = implode(" ", $pm);
  4255. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4256. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4257. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4258. $info_list[$key]['features'] = $zh;
  4259. }
  4260. $final_list = [];
  4261. foreach($info_list as $k=>$v){
  4262. $number = "";
  4263. if(!empty($v['orderinfo'])){
  4264. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4265. if(!empty($tmp_info['number'])){
  4266. $number = $tmp_info['number'];
  4267. }
  4268. }
  4269. $final_list[] = [
  4270. 'warehouse'=>$v['warehouse'],
  4271. 'purchase'=>$v['purchase'],
  4272. 'sku'=>$v['sku'],
  4273. 'title'=>$v['title'],
  4274. 'features'=>$v['features'],
  4275. 'label'=>$v['label'],
  4276. 'orderinfo'=>$v['orderinfo'],
  4277. 'number'=>$number,
  4278. 'waybill'=>$v['waybill'],
  4279. 'outk'=>$v['outk'],
  4280. ];
  4281. }
  4282. } else {
  4283. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4284. foreach ($info_list as $key => $value) {
  4285. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4286. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4287. $warehouse = $this->warehouse->read($value['warehouse']);
  4288. $info_list[$key]['warehouse'] = $warehouse['title'];
  4289. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4290. $features = explode('-', trim($features, '-'));
  4291. $pm = $classid;
  4292. foreach ($features as $k => $v) {
  4293. if ($v != 0) {
  4294. if (!isset($typeclass[$v])) {
  4295. continue;
  4296. }
  4297. if (isset($pm[$typeclass[$v]['classid']])) {
  4298. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4299. $tz = explode('|', $typeclass[$v]['zh']);
  4300. $pm[$typeclass[$v]['classid']] = $tz[0];
  4301. } else {
  4302. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4303. }
  4304. }
  4305. }
  4306. }
  4307. $zh = implode(" ", $pm);
  4308. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4309. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4310. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4311. $info_list[$key]['features'] = $zh;
  4312. }
  4313. $final_list = [];
  4314. foreach($info_list as $k=>$v){
  4315. $number = "";
  4316. if(!empty($v['orderinfo'])){
  4317. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4318. if(!empty($tmp_info['number'])){
  4319. $number = $tmp_info['number'];
  4320. }
  4321. }
  4322. $final_list[] = [
  4323. 'warehouse'=>$v['warehouse'],
  4324. 'purchase'=>$v['purchase'],
  4325. 'sku'=>$v['sku'],
  4326. 'title'=>$v['title'],
  4327. 'features'=>$v['features'],
  4328. 'label'=>$v['label'],
  4329. 'orderinfo'=>$v['orderinfo'],
  4330. 'number'=>$number,
  4331. 'waybill'=>$v['waybill'],
  4332. 'retreat'=>$v['retreat'],
  4333. ];
  4334. }
  4335. }
  4336. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4337. $titlename = "<table border=1>
  4338. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4339. <tr align='center'>
  4340. <td>仓库</td>
  4341. <td>供应商</td>
  4342. <td>SKU</td>
  4343. <td>商品名称</td>
  4344. <td>商品中文</td>
  4345. <td>标签</td>
  4346. <td>订单号</td>
  4347. <td>订单编码</td>
  4348. <td>运单号</td>
  4349. <td>" . $tl . "时间(中国时间)</td>
  4350. </tr>
  4351. </table>";
  4352. $filename = $title . ".xls";
  4353. $tail = "";
  4354. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4355. } else if ($type == 5) {
  4356. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4357. foreach ($info_list as $key => $value) {
  4358. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4359. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4360. $warehouse = $this->warehouse->read($value['warehouse']);
  4361. $info_list[$key]['warehouse'] = $warehouse['title'];
  4362. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4363. $features = explode('-', trim($features, '-'));
  4364. $pm = $classid;
  4365. foreach ($features as $k => $v) {
  4366. if ($v != 0) {
  4367. if (!isset($typeclass[$v])) {
  4368. continue;
  4369. }
  4370. if (isset($pm[$typeclass[$v]['classid']])) {
  4371. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4372. $tz = explode('|', $typeclass[$v]['zh']);
  4373. $pm[$typeclass[$v]['classid']] = $tz[0];
  4374. } else {
  4375. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4376. }
  4377. }
  4378. }
  4379. }
  4380. $zh = implode(" ", $pm);
  4381. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4382. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4383. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4384. $info_list[$key]['features'] = $zh;
  4385. }
  4386. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4387. $titlename = "<table border=1>
  4388. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4389. <tr align='center'>
  4390. <td>仓库</td>
  4391. <td>供应商</td>
  4392. <td>SKU</td>
  4393. <td>商品名称</td>
  4394. <td>商品中文</td>
  4395. <td>标签</td>
  4396. <td>" . $tl . "时间(中国时间)</td>
  4397. </tr>
  4398. </table>";
  4399. $filename = $title . ".xls";
  4400. $tail = "";
  4401. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4402. } else {
  4403. /**
  4404. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4405. $rows = array();$list = array();
  4406. foreach ($info_list as $key=>$value)
  4407. {
  4408. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4409. }
  4410. **/
  4411. $wh = array();
  4412. $w = $this->warehouse->find_all('1=1', 'id,title');
  4413. foreach ($w as $v) {
  4414. $wh[$v['id']] = $v['title'];
  4415. }
  4416. $wt = array();
  4417. $whlabel_type = $this->whlabel_type->find_all();
  4418. foreach ($whlabel_type as $v) {
  4419. $wt[$v['id']] = $v['title'];
  4420. }
  4421. $classid = $this->classid->sku();
  4422. $list = array();
  4423. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4424. foreach ($rows as $key => $value) {
  4425. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4426. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4427. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state,outk,retreat');
  4428. $details = array();
  4429. $cpid = array();
  4430. $cpbz = array();
  4431. $c = 0;
  4432. $g = 0;
  4433. $x = 0;
  4434. $t = 0;
  4435. $s = 0;
  4436. $q = 0;
  4437. foreach ($sd as $k => $v) {
  4438. if ($v['state'] == 0) {
  4439. $c++;
  4440. }
  4441. if ($v['state'] != 9) {
  4442. $g++;
  4443. }
  4444. if ($v['outk'] > 1) {
  4445. $x++;
  4446. }
  4447. if ($v['retreat'] > 0) {
  4448. $t++;
  4449. }
  4450. if ($v['state'] == 8) {
  4451. $s++;
  4452. }
  4453. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4454. $q++;
  4455. }
  4456. $details[$v['details']] = $v['details'];
  4457. if($v['state'] == 0){
  4458. if ($v['cpid'] != 0) {
  4459. $cpid[$v['cpid']] = $v['cpid'];
  4460. }
  4461. if ($v['cpbz'] != '') {
  4462. $cpbz[$v['cpbz']] = $v['cpbz'];
  4463. }
  4464. }
  4465. }
  4466. if (isset($wt[$value['type']])) {
  4467. $rows[$key]['type'] = $wt[$value['type']];
  4468. } else {
  4469. $rows[$key]['type'] = '未设置';
  4470. }
  4471. $rows[$key]['details'] = implode("、", $details);
  4472. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4473. $ftime = time() - 15 * 24 * 3600;
  4474. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4475. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4476. $rows[$key]['g'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state != 9' . $gj);
  4477. $rows[$key]['c'] = $c;
  4478. $rows[$key]['x'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state = 1' . $ck);
  4479. $rows[$key]['t'] = $t;
  4480. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  4481. $rows[$key]['z'] = $z;
  4482. // $jm = $classid;
  4483. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4484. $features = explode('-', trim($features, '-'));
  4485. // $pm = $classid;
  4486. // foreach ($features as $k => $v) {
  4487. // if ($v != 0) {
  4488. // if (!isset($typeclass[$v])) {
  4489. // continue;
  4490. // }
  4491. // if (isset($pm[$typeclass[$v]['classid']])) {
  4492. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4493. // $tz = explode('|', $typeclass[$v]['zh']);
  4494. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4495. // } else {
  4496. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4497. // }
  4498. // if (isset($jm[$typeclass[$v]['classid']])) {
  4499. // if ($typeclass[$v]['jm']) {
  4500. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4501. // }
  4502. // }
  4503. // }
  4504. // }
  4505. // }
  4506. // $zh = implode(" ", $pm);
  4507. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4508. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4509. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4510. // $rows[$key]['features'] = $zh;
  4511. // $jm = array_filter($jm); //去除空值
  4512. // $jm = implode("-", $jm);
  4513. // $rows[$key]['jm'] = $jm;
  4514. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4515. }
  4516. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4517. // echo "<pre>";
  4518. // print_r($tmp_list);
  4519. // die;
  4520. $final_list =[];
  4521. foreach($tmp_list as $k=>$v){
  4522. $final_list[] = [
  4523. "warehouse"=>$v['warehouse'],
  4524. "purchase"=>$v['purchase'],
  4525. "details"=>trim($v['details'],'、'),
  4526. "cpid"=>$v['cpid'],
  4527. "sku"=>$v['sku'],
  4528. "title"=>$v['title'],
  4529. "features"=>$v['pm'],
  4530. "cpbz"=>$v['cpbz'],
  4531. "sm"=>$v['sm'],
  4532. "type"=>$v['type'],
  4533. "g"=>$v["g"],
  4534. "c"=>$v["c"],
  4535. "x"=>$v["x"],
  4536. "t"=>$v["t"],
  4537. "z"=>$v["z"],
  4538. "jm"=>$v["jm"],
  4539. "weight"=>$v["weight"],
  4540. "asd"=>$v["asd"],
  4541. ];
  4542. }
  4543. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4544. $titlename = "<table border=1>
  4545. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4546. <tr align='center'>
  4547. <td>仓库</td>
  4548. <td>供应商</td>
  4549. <td>位置</td>
  4550. <td>库存编码</td>
  4551. <td>SKU</td>
  4552. <td>商品名称</td>
  4553. <td>商品中文</td>
  4554. <td>产品备注</td>
  4555. <td>说明</td>
  4556. <td>类型</td>
  4557. <td>入库总量</td>
  4558. <td>库存数量</td>
  4559. <td>销售数量</td>
  4560. <td>退货数量</td>
  4561. <td>占单数量</td>
  4562. <td>料号</td>
  4563. <td>重量</td>
  4564. <td>类目</td>
  4565. </tr>
  4566. </table>";
  4567. $filename = $title . ".xls";
  4568. $tail = "";
  4569. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4570. }
  4571. }
  4572. }
  4573. //出库+入库数据整合
  4574. public function _excelcr()
  4575. {
  4576. if (isset($_GET['excel'])) {
  4577. $type = $this->input->get('excel', true);
  4578. $category = $this->input->get('category', true);
  4579. $size = $this->input->get('size', true);
  4580. $grade = $this->input->get('grade', true);
  4581. $color = $this->input->get('color', true);
  4582. $lowe = $this->input->get('lowe', true);
  4583. $sku = $this->input->get('sku', true);
  4584. $warehouse = $this->input->get('warehouse', true);
  4585. $purchase = $this->input->get('purchase', true);
  4586. $state = $this->input->get('state', true);
  4587. $sid = $this->input->get('sid', true);
  4588. $ktime = $this->input->get('ktime', true);
  4589. $jtime = $this->input->get('jtime', true);
  4590. $ktime = strtotime($ktime);
  4591. $jtime = strtotime($jtime);
  4592. $where = "1=1";
  4593. $gj = "";
  4594. $ck = "";
  4595. if ($category) {
  4596. $where .= " and features like '%-$category-%'";
  4597. }
  4598. if ($size) {
  4599. $where .= " and features like '%-$size-%'";
  4600. }
  4601. if ($grade) {
  4602. $where .= " and features like '%-$grade-%'";
  4603. }
  4604. if ($color) {
  4605. $where .= " and features like '%-$color-%'";
  4606. }
  4607. if ($lowe) {
  4608. $where .= " and features like '%-$lowe-%'";
  4609. }
  4610. if ($warehouse) {
  4611. $where .= " and warehouse = '$warehouse'";
  4612. }
  4613. if ($purchase) {
  4614. $where .= " and purchase = '$purchase'";
  4615. }
  4616. if ($state) {
  4617. $where .= " and state = '$state'";
  4618. }
  4619. if ($sku) {
  4620. $where .= " and sku like '%$sku%'";
  4621. }
  4622. if ($ktime && $jtime) {
  4623. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4624. }
  4625. $sidwhere = '';
  4626. if ($sid) {
  4627. $sd = "";
  4628. $s = explode(',', trim($sid, ','));
  4629. foreach ($s as $value) {
  4630. $sd .= " id = " . $value . " or";
  4631. }
  4632. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4633. }
  4634. //取得信息列表
  4635. $timeread = $ktime;
  4636. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4637. $timelist = array();
  4638. for ($i = 0; $i < $timenum; $i++) {
  4639. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4640. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4641. }
  4642. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4643. //echo "<pre>";
  4644. //print_r($info_list);
  4645. //exit();
  4646. $rows = array();
  4647. $list = array();
  4648. foreach ($info_list as $key => $value) {
  4649. $thistime = $timelist;
  4650. if (isset($rows[strtolower($value['sku'])])) {
  4651. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4652. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4653. }
  4654. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4655. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4656. }
  4657. } else {
  4658. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4659. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4660. }
  4661. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4662. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4663. }
  4664. $rows[strtolower($value['sku'])] = $thistime;
  4665. }
  4666. }
  4667. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4668. <head>
  4669. <!--[if gte mso 9]><xml>
  4670. <x:ExcelWorkbook>
  4671. <x:ExcelWorksheets>
  4672. <x:ExcelWorksheet>
  4673. <x:Name>EXCEL</x:Name>
  4674. <x:WorksheetOptions>
  4675. <x:Print>
  4676. <x:ValidPrinterInfo />
  4677. </x:Print>
  4678. </x:WorksheetOptions>
  4679. </x:ExcelWorksheet>
  4680. </x:ExcelWorksheets>
  4681. </x:ExcelWorkbook>
  4682. </xml>
  4683. <![endif]-->
  4684. </head><body>";
  4685. $str .= "<table border=1><tr><td>SKU</td>";
  4686. foreach ($timelist as $k => $v) {
  4687. $str .= "<td>" . $k . "出库</td>";
  4688. $str .= "<td>" . $k . "入库</td>";
  4689. }
  4690. $str .= "</tr></table>";
  4691. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4692. foreach ($rows as $key => $val) {
  4693. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4694. foreach ($val as $k => $v) {
  4695. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4696. if ($val[$k]['r'] > 0) {
  4697. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4698. } else {
  4699. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4700. }
  4701. }
  4702. $str .= "</tr>";
  4703. }
  4704. $str .= "</table>";
  4705. $str .= "</body></html>";
  4706. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4707. header("Content-type: application/octet-stream");
  4708. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4709. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4710. header("Pragma: no-cache");
  4711. header("Expires: 0");
  4712. exit($str);
  4713. }
  4714. }
  4715. //数量调整模板导出
  4716. public function _presetout()
  4717. {
  4718. if (isset($_GET['excel'])) {
  4719. $where = "sku != 'Preset' and purchase != 0";
  4720. //数据排序
  4721. $order_str = "id desc";
  4722. if (empty($page)) {
  4723. $start = 0;
  4724. $perpage = 1;
  4725. } else {
  4726. $start = ($page - 1) * $perpage;
  4727. }
  4728. //取得信息列表
  4729. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4730. $rows = array();
  4731. $list = array();
  4732. foreach ($info_list as $value) {
  4733. $warehouse = $this->warehouse->read($value['warehouse']);
  4734. $number = $value['number'];
  4735. $ftime = time() - 15 * 24 * 3600;
  4736. $purchase = $this->purchase->read($value['purchase']);
  4737. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4738. }
  4739. $title = "库存模板";
  4740. $titlename = "<table border=1>
  4741. <tr align='center'>
  4742. <td>仓库</td>
  4743. <td>供应商编码</td>
  4744. <td>SKU</td>
  4745. <td>增减数量(正数或负数)</td>
  4746. <td>增减备注</td>
  4747. <td>库位</td>
  4748. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4749. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4750. </tr>
  4751. </table>";
  4752. $filename = $title . ".xls";
  4753. $tail = "";
  4754. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4755. }
  4756. }
  4757. //数量调整模板导入
  4758. public function _presetedit()
  4759. {
  4760. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4761. $config['upload_path'] = '.' . $dir;
  4762. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4763. $config['allowed_types'] = 'xls|xlsx|csv';
  4764. $config['max_size'] = 10240;
  4765. $this->load->library('upload', $config);
  4766. $this->upload->initialize($config);
  4767. if ($this->upload->do_upload('userfile')) {
  4768. $full_path = $dir . $this->upload->data('file_name');
  4769. $fileName = '.' . $full_path;
  4770. if (!file_exists($fileName)) {
  4771. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4772. exit;
  4773. } else {
  4774. require_once "./data/excel/PHPExcel/IOFactory.php";
  4775. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4776. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4777. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4778. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4779. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4780. ++$column; //如果列数大于26行
  4781. $list = array();
  4782. for ($i = 2; $i <= $row; $i++) // 行数循环
  4783. {
  4784. $data = array();
  4785. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4786. {
  4787. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4788. }
  4789. $list[] = $data;
  4790. }
  4791. }
  4792. $i = 0;
  4793. $j = 0;
  4794. $ed = array();
  4795. foreach ($list as $key => $value) {
  4796. $time = time();
  4797. if ($value['0'] == "") {
  4798. continue;
  4799. }
  4800. $warehouse = $this->warehouse->get_title($value['0']);
  4801. $purchase = $this->purchase->get_bm($value['1']);
  4802. $sku = $value['2'];
  4803. $num = $value['3']; //调整数量
  4804. $text = $value['4']; //扣减说明
  4805. $type = $value['5']; //调整方式0扣减1删除
  4806. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4807. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4808. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4809. if (!$purchase) //如果没有这个SKU
  4810. {
  4811. $ed[] = array($purchase . '-不存在此供应商编码');
  4812. $j++;
  4813. continue;
  4814. }
  4815. if (!$d) //如果没有这个SKU
  4816. {
  4817. $ed[] = array($sku . '-库存中不存在此SKU');
  4818. $j++;
  4819. continue;
  4820. }
  4821. if (!isset($warehouse['id'])) {
  4822. $ed[] = array($sku . '-仓库名错误!');
  4823. $j++;
  4824. continue;
  4825. }
  4826. if ($type != '0' && $type != '1') {
  4827. $ed[] = array($sku . '-扣减方式填写错误!');
  4828. $j++;
  4829. continue;
  4830. }
  4831. if ($num < 0) //扣减库存
  4832. {
  4833. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4834. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4835. $j++;
  4836. continue;
  4837. }
  4838. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4839. if (count($data) < abs($num)) {
  4840. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4841. $j++;
  4842. continue;
  4843. }
  4844. if ($type == 0) //如果扣减方式为 扣减库存
  4845. {
  4846. for ($i = 0; $i < abs($num); $i++) {
  4847. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4848. }
  4849. } else if ($type == 1) {
  4850. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4851. if (count($zt) > 0) {
  4852. $ed[] = array($sku . '-有在途库存无法删除!');
  4853. $j++;
  4854. continue;
  4855. }
  4856. for ($i = 0; $i < abs($num); $i++) {
  4857. $this->whlabel->remove($data[$i]['id']);
  4858. }
  4859. }
  4860. } else if ($num > 0) //增加库存
  4861. {
  4862. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4863. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4864. $j++;
  4865. continue;
  4866. }
  4867. $post['sku'] = $d['sku'];
  4868. $post['shop'] = $d['shop'];
  4869. $post['warehouse'] = $warehouse['id'];
  4870. $post['purchase'] = $purchase['id'];
  4871. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4872. $post['state'] = 0;
  4873. $post['title'] = $d['title'];
  4874. $post['number'] = $d['number'];
  4875. $post['features'] = $d['features'];
  4876. $post['enter'] = $time;
  4877. $post['time'] = $time; //操作时间
  4878. $post['rktype'] = $rktype;
  4879. for ($i = 0; $i < $num; $i++) {
  4880. $post['label'] = time() . rand(100, 999) . $i;
  4881. $this->whlabel->insert($post);
  4882. }
  4883. }
  4884. sleep(1); //防止入库时间一样,需要延迟1秒
  4885. }
  4886. if ($j > 0) {
  4887. $tt = date('Ymd', time());
  4888. $title = '库存导入错误信息-' . $tt;
  4889. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4890. $tail = "\n";
  4891. $filename = $title . ".xls";
  4892. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4893. $dir = '/data/excel/' . $time . '/';
  4894. $file_name = 'error_' . $time . rand(1000, 9999);
  4895. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4896. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4897. fwrite($myfile, $ecl);
  4898. fclose($myfile);
  4899. $error = $dir . $file_name . '.xls';
  4900. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4901. exit;
  4902. } else {
  4903. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4904. exit;
  4905. }
  4906. }
  4907. }
  4908. public function _presetedittwo(){
  4909. $data = $this->input->post(NULL, TRUE);
  4910. if(empty($list)){
  4911. $raw_data = $this->input->raw_input_stream;
  4912. // 解码 JSON
  4913. $data = json_decode($raw_data, true);
  4914. }
  4915. if(empty($data)){
  4916. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4917. exit;
  4918. }
  4919. $list = [];
  4920. if(isset($data['list'])){
  4921. $list = $data['list'];
  4922. }
  4923. $i = 0;
  4924. $j = 0;
  4925. $ed = array();
  4926. foreach ($list as $key => $value) {
  4927. $time = time();
  4928. if ($value['0'] == "") {
  4929. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4930. $j++;
  4931. continue;
  4932. }
  4933. $warehouse = $this->warehouse->get_title($value['0']);
  4934. if(empty($warehouse)){
  4935. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4936. $j++;
  4937. continue;
  4938. }
  4939. $purchase = $this->purchase->get_bm($value['1']);
  4940. $sku = $value['2'];
  4941. $num = $value['3']; //调整数量
  4942. $text = $value['4']; //扣减说明
  4943. $type = 0; //调整方式0扣减1删除
  4944. $details = empty($value['5'])?'':$value['5']; //库位
  4945. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4946. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4947. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4948. if (!$purchase) //如果没有这个SKU
  4949. {
  4950. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4951. $j++;
  4952. continue;
  4953. }
  4954. if (!$d) //如果没有这个SKU
  4955. {
  4956. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4957. $j++;
  4958. continue;
  4959. }
  4960. if (!isset($warehouse['id'])) {
  4961. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4962. $j++;
  4963. continue;
  4964. }
  4965. if ($type != '0' && $type != '1') {
  4966. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4967. $j++;
  4968. continue;
  4969. }
  4970. if ($num < 0) //扣减库存
  4971. {
  4972. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4973. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4974. $j++;
  4975. continue;
  4976. }
  4977. if(!empty($details)){
  4978. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  4979. }else{
  4980. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  4981. }
  4982. if (count($data) < abs($num)) {
  4983. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  4984. $j++;
  4985. continue;
  4986. }
  4987. if ($type == 0) //如果扣减方式为 扣减库存
  4988. {
  4989. for ($i = 0; $i < abs($num); $i++) {
  4990. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4991. }
  4992. } else if ($type == 1) {
  4993. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4994. if (count($zt) > 0) {
  4995. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  4996. $j++;
  4997. continue;
  4998. }
  4999. for ($i = 0; $i < abs($num); $i++) {
  5000. $this->whlabel->remove($data[$i]['id']);
  5001. }
  5002. }
  5003. } else if ($num > 0) //增加库存
  5004. {
  5005. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5006. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5007. $j++;
  5008. continue;
  5009. }
  5010. if(empty($details)){
  5011. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5012. if(empty($tmp_info)){
  5013. $details = '';
  5014. }else{
  5015. $details = $tmp_info['details'];
  5016. }
  5017. }else{
  5018. if($details == 'DZ001'){
  5019. }else{
  5020. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5021. if(empty($tmp_info)){
  5022. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5023. $j++;
  5024. continue;
  5025. }
  5026. }
  5027. }
  5028. $post['sku'] = $d['sku'];
  5029. $post['shop'] = $d['shop'];
  5030. $post['warehouse'] = $warehouse['id'];
  5031. $post['purchase'] = $purchase['id'];
  5032. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5033. $post['state'] = 0;
  5034. $post['title'] = $d['title'];
  5035. $post['number'] = $d['number'];
  5036. $post['features'] = $d['features'];
  5037. $post['details'] = $details;
  5038. $post['enter'] = $time;
  5039. $post['time'] = $time; //操作时间
  5040. $post['rktype'] = $rktype;
  5041. $post['sku_master_id'] = $d['sku_master_id'];
  5042. $post['sku_shop_id'] = $d['sku_shop_id'];
  5043. for ($i = 0; $i < $num; $i++) {
  5044. $post['label'] = time() . rand(100, 999) . $i;
  5045. $this->whlabel->insert($post);
  5046. }
  5047. }
  5048. sleep(1); //防止入库时间一样,需要延迟1秒
  5049. }
  5050. if ($j > 0) {
  5051. $tt = date('Ymd', time());
  5052. $title = '库存导入错误信息-' . $tt;
  5053. $error = $title . '.xls';
  5054. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5055. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5056. exit;
  5057. } else {
  5058. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5059. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5060. exit;
  5061. }
  5062. }
  5063. //笛卡儿积
  5064. function cp($ps, $sets, $list)
  5065. {
  5066. $result = array();
  5067. $j = 0;
  5068. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5069. if ($i == 0) {
  5070. $result = $sets[$i];
  5071. }
  5072. $tmp = array();
  5073. foreach ($result as $res) {
  5074. foreach ($sets[$i + 1] as $set) {
  5075. $tmp[] = $res . ',' . $set;
  5076. }
  5077. }
  5078. $result = $tmp;
  5079. }
  5080. $this->db->trans_begin();
  5081. foreach ($result as $v) {
  5082. $post = array();
  5083. $title = "";
  5084. $num = "";
  5085. $data = explode(',', $v);
  5086. for ($i = 0; $i < count($list); $i++) {
  5087. $post[$list[$i]] = $data[$i];
  5088. $typeclass = $this->typeclass->read($data[$i]);
  5089. $title = $title . $typeclass['title'] . " ";
  5090. if ($data[$i] != 0) {
  5091. $num .= $data[$i]; //所有数据ID拼接
  5092. }
  5093. }
  5094. foreach ($ps as $kp => $vp) {
  5095. $post[$kp] = $vp;
  5096. }
  5097. $post['number'] = $num;
  5098. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5099. if ($info_list) {
  5100. $j++;
  5101. } else {
  5102. $skunum = $this->whlabel->find_count();
  5103. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5104. $post['title'] = rtrim($title, ' ');
  5105. $this->whlabel->insert($post);
  5106. }
  5107. }
  5108. if ($this->db->trans_status() === FALSE) {
  5109. $this->db->trans_commit();
  5110. return NULL;
  5111. } else {
  5112. $this->db->trans_commit();
  5113. return $j;
  5114. }
  5115. }
  5116. public function _kj($arg_array)
  5117. {
  5118. if (isset($_POST['sku'])) {
  5119. $time = time();
  5120. $sku = $this->input->post('sku', true);
  5121. $warehouse = $this->input->post('warehouse', true);
  5122. $num = $this->input->post('num', true);
  5123. $text = $this->input->post('text', true);
  5124. $purchase = $this->input->post('purchase', true);
  5125. $cktype = $this->input->post('cktype', true);
  5126. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5127. if ($cktype != 1 && $text == '') {
  5128. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5129. exit;
  5130. }
  5131. if ($num > count($order)) {
  5132. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5133. exit;
  5134. } else {
  5135. for ($i = 0; $i < $num; $i++) {
  5136. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5137. }
  5138. }
  5139. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5140. exit;
  5141. }
  5142. $uid = $this->whlabel->read($arg_array[0]);
  5143. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5144. $this->data['data'] = $uid;
  5145. $this->_Template('whlabel_kj', $this->data);
  5146. }
  5147. public function _summary($arg_array)
  5148. {
  5149. $prc = array();
  5150. $purchase = $this->purchase->find_all();
  5151. foreach ($purchase as $k => $v) {
  5152. $prc[$v['id']] = $v['title'];
  5153. }
  5154. if (isset($_GET['excel'])) {
  5155. $ktime = $this->input->get('ktime', true);
  5156. $jtime = $this->input->get('jtime', true);
  5157. $ktime = strtotime($ktime);
  5158. $jtime = strtotime($jtime);
  5159. $where = "1=1";
  5160. if ($ktime && $jtime) {
  5161. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5162. }
  5163. //数据排序
  5164. $order_str = "time desc";
  5165. if (empty($page)) {
  5166. $start = 0;
  5167. $perpage = 1;
  5168. } else {
  5169. $start = ($page - 1) * $perpage;
  5170. }
  5171. //取得信息列表
  5172. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5173. foreach ($info_list as $key => $value) {
  5174. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5175. $warehouse = $this->warehouse->read($value['warehouse']);
  5176. $info_list[$key]['warehouse'] = $warehouse['title'];
  5177. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  5178. $details = array();
  5179. $cpid = array();
  5180. foreach ($x as $k => $v) {
  5181. if ($v['details'] != '') {
  5182. $details[$v['details']] = $v['details'];
  5183. }
  5184. if ($v['cpid'] != 0) {
  5185. $cpid[$v['cpid']] = $v['cpid'];
  5186. }
  5187. }
  5188. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5189. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5190. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5191. $info_list[$key]['s'] = $s;
  5192. $info_list[$key]['x'] = count($x);
  5193. }
  5194. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5195. $titlename = "<table border=1>
  5196. <tr align='center'>
  5197. <td>仓库</td>
  5198. <td>供应商</td>
  5199. <td>出库位置</td>
  5200. <td>出库编码</td>
  5201. <td>SKU</td>
  5202. <td>产品名</td>
  5203. <td>总剩余库存</td>
  5204. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5205. </tr>
  5206. </table>";
  5207. $filename = $title . ".xls";
  5208. $tail = "";
  5209. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5210. }
  5211. }
  5212. //usps发货清单
  5213. public function _manifest()
  5214. {
  5215. if (isset($_POST['manifest'])) {
  5216. $wltext = $this->input->post('wltext', true);
  5217. $time = time() - 16 * 3600;
  5218. $ptime = strtotime(date('Y-m-d', $time));
  5219. $waybill = array();
  5220. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5221. foreach ($fullorder as $v) {
  5222. $waybill[$v['waybill']] = $v['waybill'];
  5223. }
  5224. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5225. foreach ($fullordersmt as $v) {
  5226. $waybill[$v['waybill']] = $v['waybill'];
  5227. }
  5228. $wltext = explode(';', $wltext);
  5229. foreach ($wltext as $v) {
  5230. if (isset($waybill[$v])) {
  5231. unset($waybill[$v]);
  5232. }
  5233. }
  5234. $data = $this->usps->get_manifest($waybill);
  5235. if (isset($data['Description'])) {
  5236. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5237. exit;
  5238. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5239. $bctime = date('Ymd', time());
  5240. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5241. echo json_encode(array('msg' => $pdf, 'success' => true));
  5242. exit;
  5243. } else {
  5244. echo json_encode(array('msg' => $data, 'success' => false));
  5245. exit;
  5246. }
  5247. }
  5248. }
  5249. public function _pdf($pdf, $title, $bctime)
  5250. {
  5251. $pdf_path = './data/pdf/' . $bctime . '/';
  5252. $file_base64 = $pdf;
  5253. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5254. $file_base64 = base64_decode($file_base64);
  5255. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5256. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5257. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5258. }
  5259. /**
  5260. *
  5261. *
  5262. *
  5263. 进销存占单异常索引
  5264. *
  5265. *
  5266. *
  5267. **/
  5268. public function _abnormal()
  5269. {
  5270. $post = $this->input->post(NULL, TRUE);
  5271. if (isset($post['page'])) {
  5272. $page = $this->input->post('page', true);
  5273. $perpage = $this->input->post('perpage', true);
  5274. $sku = $this->input->post('sku', true);
  5275. $where = "1=1";
  5276. //数据排序
  5277. $order_str = "id desc";
  5278. if (empty($page)) {
  5279. $start = 0;
  5280. $perpage = 1;
  5281. } else {
  5282. $start = ($page - 1) * $perpage;
  5283. }
  5284. //取得信息列表
  5285. $info_list = $this->whlabel->find_all($where, '*');
  5286. $rows = array();
  5287. $list = array();
  5288. foreach ($info_list as $key => $value) {
  5289. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5290. }
  5291. foreach ($rows as $value) {
  5292. $warehouse = $this->warehouse->read($value['warehouse']);
  5293. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5294. $number = $value['number'];
  5295. $ftime = time() - 15 * 24 * 3600;
  5296. if ($value['shop'] != '') {
  5297. $shop = $value['shop'];
  5298. $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');
  5299. $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');
  5300. $order = array_merge($orderdlz, $ordersmt);
  5301. $od = 0;
  5302. $a = '';
  5303. $orid = '';
  5304. foreach ($order as $v) {
  5305. $or = explode('|', ltrim($v['whlabel'], '|'));
  5306. for ($i = 0; $i < count($or); $i++) {
  5307. $orod = explode('-', $or[$i]);
  5308. if ($orod[0] == $number) {
  5309. $od += $orod[1];
  5310. }
  5311. }
  5312. $orid .= $v['number'] . '-';
  5313. }
  5314. } else {
  5315. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5316. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5317. $order = array_merge($orderdlz, $ordersmt);
  5318. $od = 0;
  5319. $a = '';
  5320. $orid = '';
  5321. $qt = array();
  5322. foreach ($order as $v) {
  5323. $or = explode('|', ltrim($v['whlabel'], '|'));
  5324. for ($i = 0; $i < count($or); $i++) {
  5325. $orod = explode('-', $or[$i]);
  5326. if ($orod[0] == $number) {
  5327. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5328. if ($czzs > 0) {
  5329. if (isset($qt[$v['shop']])) {
  5330. if ($qt[$v['shop']] < $orod[1]) {
  5331. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5332. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5333. } else {
  5334. $qt[$v['shop']] -= $orod[1];
  5335. }
  5336. } else {
  5337. $qt[$v['shop']] = $czzs;
  5338. }
  5339. } else {
  5340. $od += $orod[1];
  5341. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5342. }
  5343. }
  5344. }
  5345. }
  5346. }
  5347. $z = $od . '(' . $orid . ')'; //查看订单号
  5348. //$z = $od;
  5349. if ($od > $c) {
  5350. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5351. }
  5352. }
  5353. $listdata = array_slice($list, $start, $perpage);
  5354. $total = count($list);
  5355. $pagenum = ceil($total / $perpage);
  5356. $over = $total - ($start + $perpage);
  5357. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5358. echo json_encode($rows);
  5359. exit;
  5360. }
  5361. $this->_Template('whlabel_abnormal', $this->data);
  5362. }
  5363. /**
  5364. *
  5365. *
  5366. *
  5367. 进销存占单异常索引
  5368. *
  5369. *
  5370. *
  5371. **/
  5372. public function _error()
  5373. {
  5374. $post = $this->input->post(NULL, TRUE);
  5375. if (isset($post['page'])) {
  5376. $page = $this->input->post('page', true);
  5377. $perpage = $this->input->post('perpage', true);
  5378. $sku = $this->input->post('sku', true);
  5379. $warehouse = $this->input->post('warehouse', true);
  5380. $ktime = $this->input->post('ktime', true);
  5381. $jtime = $this->input->post('jtime', true);
  5382. $ktime = strtotime($ktime);
  5383. $jtime = strtotime($jtime);
  5384. $where = "sku != 'Preset'";
  5385. $gj = '';
  5386. if ($sku) {
  5387. $where .= " and sku like '%$sku%'";
  5388. } else {
  5389. if ($ktime && $jtime) {
  5390. $gj = " and time > '$ktime' and time < '$jtime'";
  5391. }
  5392. }
  5393. if ($warehouse) {
  5394. $where .= " and warehouse = '$warehouse'";
  5395. }
  5396. //数据排序
  5397. $order_str = "id desc";
  5398. if (empty($page)) {
  5399. $start = 0;
  5400. $perpage = 1;
  5401. } else {
  5402. $start = ($page - 1) * $perpage;
  5403. }
  5404. //取得信息列表
  5405. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5406. $rows = array();
  5407. $list = array();
  5408. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5409. // foreach ($info_list as $value)
  5410. // {
  5411. // $warehouse = $this->warehouse->read($value['warehouse']);
  5412. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5413. // $number = $value['number'];$ftime = time()-15*24*3600;
  5414. // if($c < 1)
  5415. // {
  5416. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5417. // }
  5418. // }
  5419. $warehouse_list = $this->warehouse->find_all();
  5420. $warehouse_list = array_column($warehouse_list, null, 'id');
  5421. foreach ($info_list as $value) {
  5422. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5423. 'title' => "",
  5424. ];
  5425. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5426. $number = $value['number'];
  5427. $ftime = time() - 15 * 24 * 3600;
  5428. if ($c < 1) {
  5429. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5430. }
  5431. }
  5432. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5433. // $query = $this->db->query($sql);
  5434. // $info_list = $query->result_array();
  5435. // $sql_two = "select title,id from crowd_warehouse";
  5436. // $query_two = $this->db->query($sql_two);
  5437. // $warehouse_list = $query_two->result_array();
  5438. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5439. // foreach ($info_list as $value)
  5440. // {
  5441. // if(isset($warehouse_arr[$value['warehouse']])){
  5442. // $warehouse = $warehouse_arr[$value['warehouse']];
  5443. // }else{
  5444. // $warehouse = [
  5445. // 'id'=>0,
  5446. // 'title'=>"异常",
  5447. // ];
  5448. // }
  5449. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5450. // $number = $value['number'];$ftime = time()-15*24*3600;
  5451. // if($c < 1)
  5452. // {
  5453. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5454. // }
  5455. // }
  5456. $listdata = array_slice($list, $start, $perpage);
  5457. $total = count($list);
  5458. $pagenum = ceil($total / $perpage);
  5459. $over = $total - ($start + $perpage);
  5460. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5461. echo json_encode($rows);
  5462. exit;
  5463. }
  5464. if (isset($post['s'])) {
  5465. $id_arr = $this->input->post('s');
  5466. $id_arr = explode(',', trim($id_arr, ','));
  5467. if (!$id_arr) {
  5468. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5469. exit;
  5470. }
  5471. //循环删除记录
  5472. foreach ($id_arr as $v) {
  5473. $dd = $this->whlabel->read($v);
  5474. if (!isset($dd['id'])) {
  5475. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5476. exit;
  5477. }
  5478. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5479. if (isset($zt[0])) {
  5480. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5481. exit;
  5482. }
  5483. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5484. foreach ($deldd as $vv) {
  5485. $this->whlabel->remove($vv['id']);
  5486. }
  5487. }
  5488. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5489. exit;
  5490. }
  5491. $this->_Template('whlabel_error', $this->data);
  5492. }
  5493. public function _errorexcel()
  5494. {
  5495. $post = $this->input->post(NULL, TRUE);
  5496. if (isset($_GET['page'])) {
  5497. $page = $this->input->get('page', true);
  5498. $perpage = $this->input->get('perpage', true);
  5499. $sku = $this->input->get('sku', true);
  5500. $warehouse = $this->input->get('warehouse', true);
  5501. $ktime = $this->input->get('ktime', true);
  5502. $jtime = $this->input->get('jtime', true);
  5503. $ktime = strtotime($ktime);
  5504. $jtime = strtotime($jtime);
  5505. $where = "sku != 'Preset'";
  5506. $gj = '';
  5507. if ($sku) {
  5508. $where .= " and sku like '%$sku%'";
  5509. } else {
  5510. if ($ktime && $jtime) {
  5511. $gj = " and time > '$ktime' and time < '$jtime'";
  5512. }
  5513. }
  5514. if ($warehouse) {
  5515. $where .= " and warehouse = '$warehouse'";
  5516. }
  5517. //数据排序
  5518. $order_str = "id desc";
  5519. if (empty($page)) {
  5520. $start = 0;
  5521. $perpage = 1;
  5522. } else {
  5523. $start = ($page - 1) * $perpage;
  5524. }
  5525. //取得信息列表
  5526. $rows = array();
  5527. $list = array();
  5528. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5529. foreach ($info_list as $value) {
  5530. $warehouse = $this->warehouse->read($value['warehouse']);
  5531. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5532. $number = $value['number'];
  5533. $ftime = time() - 15 * 24 * 3600;
  5534. if ($c < 1) {
  5535. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5536. }
  5537. }
  5538. $title = "0库存汇总";
  5539. $titlename = "<table border=1>
  5540. <tr align='center'>
  5541. <td>仓库</td>
  5542. <td>SKU</td>
  5543. <td>产品</td>
  5544. <td>当前库存</td>
  5545. </tr>
  5546. </table>";
  5547. $filename = $title . ".xls";
  5548. $tail = "";
  5549. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5550. }
  5551. }
  5552. /**
  5553. *
  5554. *
  5555. * 占单
  5556. *
  5557. *
  5558. **/
  5559. public function _kcyz()
  5560. {
  5561. $post = $this->input->post(NULL, TRUE);
  5562. if (isset($post['warehouse'])) {
  5563. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5564. exit; //不再使用
  5565. $warehouse = $this->input->post('warehouse', true);
  5566. $whlabel = $this->input->post('whlabel', true);
  5567. $id = $this->input->post('id', true);
  5568. $shop = $this->input->post('shop', true);
  5569. $number = $this->input->post('number', true);
  5570. if (!$whlabel || $whlabel == '|') {
  5571. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5572. exit;
  5573. }
  5574. $pp = explode('|', trim($whlabel, '|'));
  5575. $x = 0;
  5576. $save = array();
  5577. foreach ($pp as $va) {
  5578. $num = explode('-', $va);
  5579. if ($number) {
  5580. $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 = '')"); //通用
  5581. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5582. } else {
  5583. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5584. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5585. }
  5586. $x++;
  5587. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5588. $save[] = $x - 1;
  5589. continue; //提前先加X不然出错,所以要减1
  5590. }
  5591. }
  5592. if (isset($save[0])) {
  5593. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5594. exit;
  5595. } else {
  5596. echo json_encode(array('success' => true));
  5597. exit;
  5598. }
  5599. }
  5600. }
  5601. public function _db()
  5602. {
  5603. $post = $this->input->post(NULL, TRUE);
  5604. if (isset($post['page'])) {
  5605. $page = $this->input->post('page', true);
  5606. $perpage = $this->input->post('perpage', true);
  5607. $sku = $this->input->post('sku', true);
  5608. $number = $this->input->post('number', true);
  5609. $warehouse = $this->input->post('warehouse', true);
  5610. $purchase = $this->input->post('purchase', true);
  5611. $orderinfo = $this->input->post('orderinfo', true);
  5612. $waybill = $this->input->post('waybill', true);
  5613. $category = $this->input->post('category', true);
  5614. $size = $this->input->post('size', true);
  5615. $grade = $this->input->post('grade', true);
  5616. $color = $this->input->post('color', true);
  5617. $lowe = $this->input->post('lowe', true);
  5618. $state = $this->input->post('state', true);
  5619. $label = $this->input->post('label', true);
  5620. $timetk = $this->input->post('timetkk', true);
  5621. $timetj = $this->input->post('timetjj', true);
  5622. $timetk = strtotime($timetk);
  5623. $timetj = strtotime($timetj);
  5624. $where = "dbtime > 0";
  5625. if ($timetk && $timetj) {
  5626. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5627. }
  5628. if ($sku) {
  5629. $where .= " and sku = '$sku'";
  5630. }
  5631. if ($warehouse) {
  5632. $where .= " and warehouse = '$warehouse'";
  5633. if ($warehouse == 12) {
  5634. $w = 'specialstock';
  5635. } else {
  5636. $w = 'whlabel';
  5637. }
  5638. }
  5639. if ($purchase) {
  5640. $where .= " and purchase = '$purchase'";
  5641. }
  5642. if ($category) {
  5643. $where .= " and features like '%-$category-%'";
  5644. }
  5645. if ($size) {
  5646. $where .= " and features like '%-$size-%'";
  5647. }
  5648. if ($grade) {
  5649. $where .= " and features like '%-$grade-%'";
  5650. }
  5651. if ($color) {
  5652. $where .= " and features like '%-$color-%'";
  5653. }
  5654. if ($lowe) {
  5655. $where .= " and features like '%-$lowe-%'";
  5656. }
  5657. if ($state != '') {
  5658. $where .= " and state = '$state'";
  5659. }
  5660. //数据排序
  5661. $order_str = "dbtime desc";
  5662. if (empty($page)) {
  5663. $start = 0;
  5664. $perpage = 1;
  5665. } else {
  5666. $start = ($page - 1) * $perpage;
  5667. }
  5668. //取得信息列表
  5669. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5670. foreach ($info_list as $key => $value) {
  5671. $warehouse = $this->$w->read($value['warehouse']);
  5672. $info_list[$key]['warehouse'] = $warehouse['title'];
  5673. $purchase = $this->purchase->read($value['purchase']);
  5674. $info_list[$key]['purchase'] = $purchase['title'];
  5675. if ($value['enter'] != 0) {
  5676. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5677. } else {
  5678. $info_list[$key]['enter'] = "";
  5679. }
  5680. if ($value['dbtime'] != 0) {
  5681. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5682. } else {
  5683. $info_list[$key]['dbtime'] = "";
  5684. }
  5685. if ($value['state'] == 0) {
  5686. $info_list[$key]['state'] = "在库";
  5687. } else if ($value['state'] == 1) {
  5688. $info_list[$key]['state'] = "出库";
  5689. } else if ($value['state'] == 2) {
  5690. $info_list[$key]['state'] = "退库";
  5691. } else if ($value['state'] == 3) {
  5692. $info_list[$key]['state'] = "调拨中";
  5693. } else if ($value['state'] == 4) {
  5694. $info_list[$key]['state'] = "再加工";
  5695. } else if ($value['state'] == 5) {
  5696. $info_list[$key]['state'] = "维修中";
  5697. } else if ($value['state'] == 6) {
  5698. $info_list[$key]['state'] = "盘亏";
  5699. } else if ($value['state'] == 7) {
  5700. $info_list[$key]['state'] = "更换标签";
  5701. } else if ($value['state'] == 8) {
  5702. $info_list[$key]['state'] = "其它";
  5703. } else if ($value['state'] == 9) {
  5704. $info_list[$key]['state'] = "预设";
  5705. }
  5706. }
  5707. $total = $this->whlabel->find_count($where);
  5708. $pagenum = ceil($total / $perpage);
  5709. $over = $total - ($start + $perpage);
  5710. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5711. echo json_encode($rows);
  5712. exit;
  5713. }
  5714. if (isset($post['outsku'])) {
  5715. $time = time();
  5716. $cz = $this->input->post('cz', true);
  5717. $label = $this->input->post('outsku', true);
  5718. $sl = $this->input->post('sl', true);
  5719. $num = $this->input->post('num', true);
  5720. //$warehouse = $this->input->post('warehouse',true);
  5721. if (!$sl) {
  5722. $sl = 1;
  5723. }
  5724. if (!$warehouse) {
  5725. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5726. exit;
  5727. }
  5728. $dblabel = $this->whlabellabel->get_label($label);
  5729. if ($dblabel) {
  5730. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5731. if (count($data) < 1) {
  5732. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5733. exit;
  5734. }
  5735. if (count($data) < $num) {
  5736. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5737. exit;
  5738. }
  5739. for ($i = 0; $i < $sl; $i++) {
  5740. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5741. }
  5742. echo json_encode(array('success' => true));
  5743. exit;
  5744. } else {
  5745. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5746. exit;
  5747. }
  5748. }
  5749. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5750. $this->_Template('whlabel_db', $this->data);
  5751. }
  5752. public function _dbrk()
  5753. {
  5754. $post = $this->input->post(NULL, TRUE);
  5755. if (isset($post['page'])) {
  5756. $page = $this->input->post('page', true);
  5757. $perpage = $this->input->post('perpage', true);
  5758. $sku = $this->input->post('sku', true);
  5759. $number = $this->input->post('number', true);
  5760. $warehouse = $this->input->post('warehouse', true);
  5761. $purchase = $this->input->post('purchase', true);
  5762. $orderinfo = $this->input->post('orderinfo', true);
  5763. $waybill = $this->input->post('waybill', true);
  5764. $category = $this->input->post('category', true);
  5765. $size = $this->input->post('size', true);
  5766. $grade = $this->input->post('grade', true);
  5767. $color = $this->input->post('color', true);
  5768. $lowe = $this->input->post('lowe', true);
  5769. $state = $this->input->post('state', true);
  5770. $label = $this->input->post('label', true);
  5771. $ctime = $this->input->post('ctime', true);
  5772. $timetk = $this->input->post('timetkk', true);
  5773. $timetj = $this->input->post('timetjj', true);
  5774. $timetk = strtotime($timetk);
  5775. $timetj = strtotime($timetj);
  5776. $where = "dbtime > 0";
  5777. if ($timetk && $timetj) {
  5778. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5779. }
  5780. if ($sku) {
  5781. $where .= " and sku = '$sku'";
  5782. }
  5783. if ($warehouse) {
  5784. $where .= " and warehouse = '$warehouse'";
  5785. }
  5786. if ($purchase) {
  5787. $where .= " and purchase = '$purchase'";
  5788. }
  5789. if ($category) {
  5790. $where .= " and features like '%-$category-%'";
  5791. }
  5792. if ($size) {
  5793. $where .= " and features like '%-$size-%'";
  5794. }
  5795. if ($grade) {
  5796. $where .= " and features like '%-$grade-%'";
  5797. }
  5798. if ($color) {
  5799. $where .= " and features like '%-$color-%'";
  5800. }
  5801. if ($lowe) {
  5802. $where .= " and features like '%-$lowe-%'";
  5803. }
  5804. if ($state != '') {
  5805. $where .= " and state = '$state'";
  5806. }
  5807. //数据排序
  5808. $order_str = "dbtime desc";
  5809. if (empty($page)) {
  5810. $start = 0;
  5811. $perpage = 1;
  5812. } else {
  5813. $start = ($page - 1) * $perpage;
  5814. }
  5815. //取得信息列表
  5816. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5817. foreach ($info_list as $key => $value) {
  5818. $warehouse = $this->warehouse->read($value['warehouse']);
  5819. $info_list[$key]['warehouse'] = $warehouse['title'];
  5820. $purchase = $this->purchase->read($value['purchase']);
  5821. $info_list[$key]['purchase'] = $purchase['title'];
  5822. if ($value['enter'] != 0) {
  5823. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5824. } else {
  5825. $info_list[$key]['enter'] = "";
  5826. }
  5827. if ($value['dbtime'] != 0) {
  5828. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5829. } else {
  5830. $info_list[$key]['dbtime'] = "";
  5831. }
  5832. if ($value['state'] == 0) {
  5833. $info_list[$key]['state'] = "在库";
  5834. } else if ($value['state'] == 1) {
  5835. $info_list[$key]['state'] = "出库";
  5836. } else if ($value['state'] == 2) {
  5837. $info_list[$key]['state'] = "退库";
  5838. } else if ($value['state'] == 3) {
  5839. $info_list[$key]['state'] = "调拨中";
  5840. } else if ($value['state'] == 4) {
  5841. $info_list[$key]['state'] = "再加工";
  5842. } else if ($value['state'] == 5) {
  5843. $info_list[$key]['state'] = "维修中";
  5844. } else if ($value['state'] == 6) {
  5845. $info_list[$key]['state'] = "盘亏";
  5846. } else if ($value['state'] == 7) {
  5847. $info_list[$key]['state'] = "更换标签";
  5848. } else if ($value['state'] == 8) {
  5849. $info_list[$key]['state'] = "其它";
  5850. } else if ($value['state'] == 9) {
  5851. $info_list[$key]['state'] = "预设";
  5852. }
  5853. }
  5854. $total = $this->whlabel->find_count($where);
  5855. $pagenum = ceil($total / $perpage);
  5856. $over = $total - ($start + $perpage);
  5857. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5858. echo json_encode($rows);
  5859. exit;
  5860. }
  5861. if (isset($post['rsku'])) {
  5862. $cz = $this->input->post('cz', true);
  5863. $label = $this->input->post('rsku', true);
  5864. $sl = $this->input->post('sl', true);
  5865. $warehouse = $this->input->post('warehouse', true);
  5866. if (!$sl) {
  5867. $sl = 1;
  5868. }
  5869. if (!$warehouse) {
  5870. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5871. exit;
  5872. }
  5873. $dblabel = $this->whlabellabel->get_label($label);
  5874. if ($dblabel) {
  5875. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5876. if (count($data) < 1) {
  5877. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5878. exit;
  5879. }
  5880. if ($sl > count($data)) {
  5881. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5882. exit;
  5883. }
  5884. $time = time();
  5885. for ($i = 0; $i < $sl; $i++) {
  5886. $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']);
  5887. }
  5888. echo json_encode(array('success' => true));
  5889. exit;
  5890. } else {
  5891. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5892. exit;
  5893. }
  5894. }
  5895. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5896. $this->_Template('whlabel_dbrk', $this->data);
  5897. }
  5898. public function _whlabelczdc()
  5899. {
  5900. if (isset($_GET['excel'])) {
  5901. //数据排序
  5902. $order_str = "id desc";
  5903. if (empty($page)) {
  5904. $start = 0;
  5905. $perpage = 1;
  5906. } else {
  5907. $start = ($page - 1) * $perpage;
  5908. }
  5909. $state = $this->input->get('state', true);
  5910. $sku = $this->input->get('sku', true);
  5911. $ctime = $this->input->get('ctime', true);
  5912. $category = $this->input->get('category', true);
  5913. $size = $this->input->get('size', true);
  5914. $grade = $this->input->get('grade', true);
  5915. $color = $this->input->get('color', true);
  5916. $lowe = $this->input->get('lowe', true);
  5917. $timetk = $this->input->get('timetkk', true);
  5918. $timetj = $this->input->get('timetjj', true);
  5919. $timetk = strtotime($timetk);
  5920. $timetj = strtotime($timetj);
  5921. $where = "dbtime > 0";
  5922. if ($timetk && $timetj) {
  5923. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5924. }
  5925. if ($category) {
  5926. $where .= " and features like '%-$category-%'";
  5927. }
  5928. if ($size) {
  5929. $where .= " and features like '%-$size-%'";
  5930. }
  5931. if ($grade) {
  5932. $where .= " and features like '%-$grade-%'";
  5933. }
  5934. if ($color) {
  5935. $where .= " and features like '%-$color-%'";
  5936. }
  5937. if ($lowe) {
  5938. $where .= " and features like '%-$lowe-%'";
  5939. }
  5940. //取得信息列表
  5941. $info_list = $this->whlabel->find_all($where, '*');
  5942. $rows = array();
  5943. $list = array();
  5944. foreach ($info_list as $key => $value) {
  5945. $rows[$value['sku']] = $value; //所有数据sku
  5946. }
  5947. foreach ($rows as $value) {
  5948. $warehouse = $this->warehouse->read($value['warehouse']);
  5949. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5950. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5951. if ($value['orderinfo'] == 0) {
  5952. $info_list[$key]['orderinfo'] = "";
  5953. }
  5954. if ($value['waybill'] == 0) {
  5955. $info_list[$key]['waybill'] = "";
  5956. }
  5957. if ($value['state'] == 0) {
  5958. $value['state'] = "在库";
  5959. } else if ($value['state'] == 3) {
  5960. $value['state'] = "调拨中";
  5961. }
  5962. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5963. }
  5964. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5965. $titlename = "<table border=1>
  5966. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5967. <tr align='center'>
  5968. <td>SKU</td>
  5969. <td>产品</td>
  5970. <td>调拨数量</td>
  5971. <td>入库数量</td>
  5972. </tr>
  5973. </table>";
  5974. $filename = $title . ".xls";
  5975. $tail = "";
  5976. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5977. }
  5978. }
  5979. public function _print($arg_array)
  5980. {
  5981. if (isset($_SESSION['api'])) {
  5982. $user = $this->user->get_api($_SESSION['api']);
  5983. $usp = $user;
  5984. $fgshop = "";
  5985. $sid = "";
  5986. $wid = "";
  5987. $wtype = "";
  5988. $usersp = explode('|', trim($user['shop'], '|'));
  5989. $userwh = explode('|', trim($user['warehouse'], '|'));
  5990. foreach ($usersp as $value) {
  5991. $fgshop .= " shop = " . $value . " or";
  5992. $sid .= " id = " . $value . " or";
  5993. }
  5994. foreach ($userwh as $value) {
  5995. $wid .= " id = " . $value . " or";
  5996. $wtype .= " type = " . $value . " or";
  5997. }
  5998. }
  5999. $post = $this->input->post(NULL, TRUE);
  6000. if (isset($post['tmsku'])) {
  6001. $tmsku = $this->input->post('tmsku', true);
  6002. if (is_numeric($tmsku)) {
  6003. $yyh = $this->whlabellabel->get_label($tmsku);
  6004. } else {
  6005. $yyh = $this->whlabellabel->get_sku($tmsku);
  6006. if(empty($yyh)){
  6007. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6008. if($r['code'] == -1 ){
  6009. echo json_encode(array('success' => false));
  6010. exit;
  6011. }else{
  6012. echo json_encode(array('features' => $r['data'], 'success' => true));
  6013. exit;
  6014. }
  6015. }
  6016. }
  6017. if ($yyh) {
  6018. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6019. exit;
  6020. } else {
  6021. echo json_encode(array('success' => false));
  6022. exit;
  6023. }
  6024. }
  6025. $classid = $this->classid->sku();
  6026. $pm = $classid;
  6027. $scsku = $classid;
  6028. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6029. if (isset($post['warehouse'])) {
  6030. if ($post['warehouse']) {
  6031. $list = array();
  6032. $num = "";
  6033. $title = "";
  6034. $features = "";
  6035. $order = 0;
  6036. $post['shop'] = '';
  6037. $brand = $this->input->post('brand', true);
  6038. if ($brand != '0,') {
  6039. $b = $this->brand->read(rtrim($brand, ','));
  6040. if ($b) {
  6041. $post['shop'] = str_replace('|', ',', $b['shop']);
  6042. }
  6043. }
  6044. $post['details'] = $this->input->post('details', true); //打印数量
  6045. $xbqnum = $this->input->post('xbqnum', true);
  6046. $post['purchase'] = $this->input->post('purchase', true);
  6047. $post['warehouse'] = $this->input->post('warehouse', true);
  6048. $post['purchase'] = $this->input->post('purchase', true);
  6049. $post['retreatwarehouse'] = $post['warehouse'];
  6050. $post['cpbz'] = $this->input->post('cpbz', true);
  6051. $post['state'] = 9;
  6052. $category = $this->input->post('category', true);
  6053. $list['category'] = $category;
  6054. $list['hairtype'] = $this->input->post('hairtype', true);
  6055. $list['grade'] = $this->input->post('grade', true);
  6056. $size = $this->input->post('size', true);
  6057. $list['size'] = rtrim($size, ',');
  6058. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6059. $list['extension'] = $this->input->post('extension', true);
  6060. if ($category == 1297) {
  6061. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6062. }
  6063. if ($category == 1702) {
  6064. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6065. $list['syother'] = $this->input->post('syother', true);
  6066. }
  6067. if ($category == 133) {
  6068. $list['fittype'] = $this->input->post('fittype', true);
  6069. $list['acother'] = $this->input->post('acother', true);
  6070. }
  6071. $list['color'] = $this->input->post('color', true);
  6072. $list['lowe'] = $this->input->post('lowe', true);
  6073. if ($category == 127) {
  6074. $list['type'] = $this->input->post('type', true);
  6075. $list['headroad'] = $this->input->post('headroad', true);
  6076. $list['density'] = $this->input->post('density', true);
  6077. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6078. $list['lacesize'] = $this->input->post('lacesize', true);
  6079. }
  6080. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6081. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6082. }
  6083. if ($category == 128) {
  6084. $list['lacetype'] = $this->input->post('lacetype', true);
  6085. $list['haircap'] = $this->input->post('haircap', true);
  6086. $list['density'] = $this->input->post('density', true);
  6087. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6088. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6089. $list['wigother'] = $this->input->post('wigother', true);
  6090. $list['wigother1'] = $this->input->post('wigother1', true);
  6091. $list['wigother2'] = $this->input->post('wigother2', true);
  6092. $list['product_related'] = $this->input->post('product_related', true);
  6093. }
  6094. if ($category == 129) {
  6095. $list['wide'] = $this->input->post('wide', true);
  6096. }
  6097. if ($category == 131) {
  6098. $list['gifttype'] = $this->input->post('gifttype', true);
  6099. $list['giftother'] = $this->input->post('giftother', true);
  6100. }
  6101. if ($category == 134) {
  6102. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6103. }
  6104. if ($category == 1297) {
  6105. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6106. $list['sywigother'] = $this->input->post('sywigother', true);
  6107. }
  6108. if ($category == 130 || $category == 133 || $category == 1702) {
  6109. $list['items'] = $this->input->post('items', true);
  6110. $list['weight'] = $this->input->post('weight', true);
  6111. }
  6112. if ($category == 1702) {
  6113. $list['syhairther'] = $this->input->post('syhairther', true);
  6114. }
  6115. if($category == 130){
  6116. $list['jfother'] = $this->input->post('jfother', true);
  6117. }
  6118. foreach ($list as $k => $v) {
  6119. if ($v != 0) {
  6120. $num .= $v;
  6121. $features .= $v . '-';
  6122. $post[$k] = $v;
  6123. $typeclass = $this->typeclass->read($v);
  6124. if (isset($pm[$typeclass['classid']])) {
  6125. if (stripos($typeclass['zh'], '|') !== false) {
  6126. $exzh = explode('|', $typeclass['zh']);
  6127. $pm[$typeclass['classid']] = $exzh[0];
  6128. } else {
  6129. $pm[$typeclass['classid']] = $typeclass['zh'];
  6130. }
  6131. }
  6132. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6133. if ($k != 'size') {
  6134. $title .= $typeclass['title'] . " ";
  6135. }
  6136. }
  6137. }
  6138. $typeclass = $this->typeclass->read($list['size']);
  6139. $title .= $typeclass['title'];
  6140. $time = time();
  6141. $post['title'] = rtrim($title, ' ');
  6142. $post['number'] = $num;
  6143. $post['features'] = '-' . $features;
  6144. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6145. $featurespp = explode('-', trim($featurespp, '-'));
  6146. if (isset($featurespp[5])) {
  6147. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6148. } else {
  6149. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6150. }
  6151. $post['enter'] = $time;
  6152. $post['time'] = $time; //操作时间
  6153. $scsku = implode("-", $scsku);
  6154. $zh = implode(" ", $pm);
  6155. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6156. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6157. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6158. $post['sku'] = $bqsku;
  6159. $label = time() . rand(0, 9);
  6160. $post['label'] = $label;
  6161. $cpid = $this->whlabellabel->find_count();
  6162. $post['cpid'] = $cpid + 1;
  6163. $cpid = $post['cpid'];
  6164. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6165. //if($whlabelbarcode)
  6166. //{
  6167. //$post['label'] = $whlabelbarcode['label'];
  6168. //if(!$this->whlabellabel->insert($post))
  6169. //{
  6170. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6171. //}
  6172. //}
  6173. //else
  6174. //{
  6175. $this->db->trans_begin();
  6176. $this->whlabellabel->insert($post);
  6177. //$this->whlabelbarcode->insert($post);
  6178. if ($this->db->trans_status() === TRUE) {
  6179. $this->db->trans_commit();
  6180. } else {
  6181. $this->db->trans_rollback();
  6182. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6183. exit;
  6184. }
  6185. //}
  6186. $warehouse_name = "";
  6187. $warehouse = $post['warehouse'];
  6188. if($warehouse == 12){
  6189. $warehouse_name = "特殊库存库";
  6190. }
  6191. // if($warehouse == 13){
  6192. // $warehouse_name = "许昌仓";
  6193. // }
  6194. // if($warehouse == 5){
  6195. // $warehouse_name = "美国店";
  6196. // }
  6197. // if($warehouse == 16){
  6198. // $warehouse_name = "定制头套仓";
  6199. // }
  6200. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6201. if(!empty($warehouse_name)){
  6202. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6203. }
  6204. $purchase = $this->purchase->read($post['purchase']);
  6205. 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));
  6206. exit; //特殊仓目前不需要仓库选项
  6207. }
  6208. }
  6209. if (isset($_SESSION['api'])) {
  6210. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6211. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6212. $this->data['wlshop'] = $wlshop;
  6213. $this->data['warehouse'] = $warehouse;
  6214. }
  6215. $whlabelwz = $this->whlabelwz->find_all();
  6216. $this->data['whlabelwz'] = $whlabelwz;
  6217. $this->_Template('whlabel_print', $this->data);
  6218. }
  6219. public function _usaprint($arg_array)
  6220. {
  6221. if (isset($_SESSION['api'])) {
  6222. $user = $this->user->get_api($_SESSION['api']);
  6223. $usp = $user;
  6224. $fgshop = "";
  6225. $sid = "";
  6226. $wid = "";
  6227. $wtype = "";
  6228. $usersp = explode('|', trim($user['shop'], '|'));
  6229. $userwh = explode('|', trim($user['warehouse'], '|'));
  6230. foreach ($usersp as $value) {
  6231. $fgshop .= " shop = " . $value . " or";
  6232. $sid .= " id = " . $value . " or";
  6233. }
  6234. foreach ($userwh as $value) {
  6235. $wid .= " id = " . $value . " or";
  6236. $wtype .= " type = " . $value . " or";
  6237. }
  6238. }
  6239. $post = $this->input->post(NULL, TRUE);
  6240. if (isset($post['tmsku'])) {
  6241. $tmsku = $this->input->post('tmsku', true);
  6242. if (is_numeric($tmsku)) {
  6243. $yyh = $this->whlabellabel->get_label($tmsku);
  6244. } else {
  6245. $yyh = $this->whlabellabel->get_sku($tmsku);
  6246. }
  6247. if ($yyh) {
  6248. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6249. exit;
  6250. } else {
  6251. echo json_encode(array('success' => false));
  6252. exit;
  6253. }
  6254. }
  6255. $classid = $this->classid->sku();
  6256. $pm = $classid;
  6257. $scsku = $classid;
  6258. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6259. if (isset($post['warehouse'])) {
  6260. if ($post['warehouse']) {
  6261. $list = array();
  6262. $num = "";
  6263. $title = "";
  6264. $features = "";
  6265. $order = 0;
  6266. $post['shop'] = '';
  6267. $brand = $this->input->post('brand', true);
  6268. if ($brand != '0,') {
  6269. $b = $this->brand->read(rtrim($brand, ','));
  6270. if ($b) {
  6271. $post['shop'] = str_replace('|', ',', $b['shop']);
  6272. }
  6273. }
  6274. $post['details'] = $this->input->post('details', true); //打印数量
  6275. $xbqnum = $this->input->post('xbqnum', true);
  6276. $post['purchase'] = $this->input->post('purchase', true);
  6277. $post['warehouse'] = $this->input->post('warehouse', true);
  6278. $post['purchase'] = $this->input->post('purchase', true);
  6279. $post['retreatwarehouse'] = $post['warehouse'];
  6280. $post['cpbz'] = $this->input->post('cpbz', true);
  6281. $post['state'] = 9;
  6282. $category = $this->input->post('category', true);
  6283. $list['category'] = $category;
  6284. $list['hairtype'] = $this->input->post('hairtype', true);
  6285. $list['grade'] = $this->input->post('grade', true);
  6286. $size = $this->input->post('size', true);
  6287. $list['size'] = rtrim($size, ',');
  6288. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6289. $list['extension'] = $this->input->post('extension', true);
  6290. if ($category == 1297) {
  6291. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6292. }
  6293. if ($category == 1702) {
  6294. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6295. $list['syother'] = $this->input->post('syother', true);
  6296. }
  6297. if ($category == 133) {
  6298. $list['fittype'] = $this->input->post('fittype', true);
  6299. $list['acother'] = $this->input->post('acother', true);
  6300. }
  6301. $list['color'] = $this->input->post('color', true);
  6302. $list['lowe'] = $this->input->post('lowe', true);
  6303. if ($category == 127) {
  6304. $list['type'] = $this->input->post('type', true);
  6305. $list['headroad'] = $this->input->post('headroad', true);
  6306. $list['density'] = $this->input->post('density', true);
  6307. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6308. $list['lacesize'] = $this->input->post('lacesize', true);
  6309. }
  6310. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6311. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6312. }
  6313. if ($category == 128) {
  6314. $list['lacetype'] = $this->input->post('lacetype', true);
  6315. $list['haircap'] = $this->input->post('haircap', true);
  6316. $list['density'] = $this->input->post('density', true);
  6317. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6318. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6319. $list['wigother'] = $this->input->post('wigother', true);
  6320. $list['wigother1'] = $this->input->post('wigother1', true);
  6321. $list['wigother2'] = $this->input->post('wigother2', true);
  6322. $list['product_related'] = $this->input->post('product_related', true);
  6323. }
  6324. if ($category == 129) {
  6325. $list['wide'] = $this->input->post('wide', true);
  6326. }
  6327. if ($category == 131) {
  6328. $list['gifttype'] = $this->input->post('gifttype', true);
  6329. $list['giftother'] = $this->input->post('giftother', true);
  6330. }
  6331. if ($category == 134) {
  6332. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6333. }
  6334. if ($category == 1297) {
  6335. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6336. $list['sywigother'] = $this->input->post('sywigother', true);
  6337. }
  6338. if ($category == 130 || $category == 133 || $category == 1702) {
  6339. $list['items'] = $this->input->post('items', true);
  6340. $list['weight'] = $this->input->post('weight', true);
  6341. }
  6342. if ($category == 1702) {
  6343. $list['syhairther'] = $this->input->post('syhairther', true);
  6344. }
  6345. foreach ($list as $k => $v) {
  6346. if ($v != 0) {
  6347. $num .= $v;
  6348. $features .= $v . '-';
  6349. $post[$k] = $v;
  6350. $typeclass = $this->typeclass->read($v);
  6351. if (isset($pm[$typeclass['classid']])) {
  6352. if (stripos($typeclass['zh'], '|') !== false) {
  6353. $exzh = explode('|', $typeclass['zh']);
  6354. $pm[$typeclass['classid']] = $exzh[0];
  6355. } else {
  6356. $pm[$typeclass['classid']] = $typeclass['zh'];
  6357. }
  6358. }
  6359. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6360. if ($k != 'size') {
  6361. $title .= $typeclass['title'] . " ";
  6362. }
  6363. }
  6364. }
  6365. $typeclass = $this->typeclass->read($list['size']);
  6366. $title .= $typeclass['title'];
  6367. $time = time();
  6368. $post['title'] = rtrim($title, ' ');
  6369. $post['number'] = $num;
  6370. $post['features'] = '-' . $features;
  6371. $fp = $this->whlabel->get_features($post['features']);
  6372. if (!$fp) {
  6373. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6374. exit;
  6375. }
  6376. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6377. $featurespp = explode('-', trim($featurespp, '-'));
  6378. if (isset($featurespp[5])) {
  6379. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6380. } else {
  6381. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6382. }
  6383. $post['enter'] = $time;
  6384. $post['time'] = $time; //操作时间
  6385. $scsku = implode("-", $scsku);
  6386. $zh = implode(" ", $pm);
  6387. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6388. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6389. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6390. $post['sku'] = $fp['sku'];
  6391. $post['label'] = $fp['sku'];
  6392. $cpid = $this->whlabellabel->find_count();
  6393. $post['cpid'] = $cpid + 1;
  6394. $cpid = $post['cpid'];
  6395. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6396. //if($whlabelbarcode)
  6397. //{
  6398. //$post['label'] = $whlabelbarcode['label'];
  6399. //if(!$this->whlabellabel->insert($post))
  6400. //{
  6401. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6402. //}
  6403. //}
  6404. //else
  6405. //{
  6406. $this->db->trans_begin();
  6407. $this->whlabellabel->insert($post);
  6408. //$this->whlabelbarcode->insert($post);
  6409. if ($this->db->trans_status() === TRUE) {
  6410. $this->db->trans_commit();
  6411. } else {
  6412. $this->db->trans_rollback();
  6413. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6414. exit;
  6415. }
  6416. //}
  6417. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6418. $purchase = $this->purchase->read($post['purchase']);
  6419. 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));
  6420. exit; //特殊仓目前不需要仓库选项
  6421. }
  6422. }
  6423. if (isset($_SESSION['api'])) {
  6424. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6425. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6426. $this->data['wlshop'] = $wlshop;
  6427. $this->data['warehouse'] = $warehouse;
  6428. }
  6429. $whlabelwz = $this->whlabelwz->find_all();
  6430. $this->data['whlabelwz'] = $whlabelwz;
  6431. $this->_Template('whlabel_usaprint', $this->data);
  6432. }
  6433. public function _printrk($arg_array)
  6434. {
  6435. $prc = array();
  6436. $purchase = $this->purchase->find_all();
  6437. foreach ($purchase as $k => $v) {
  6438. $prc[$v['id']] = $v['title'];
  6439. }
  6440. $post = $this->input->post(NULL, TRUE);
  6441. if (isset($post['page'])) {
  6442. $page = $this->input->post('page', true);
  6443. $perpage = $this->input->post('perpage', true);
  6444. $sku = $this->input->post('sku', true);
  6445. $bs = $this->input->post('bs', true);
  6446. $number = $this->input->post('number', true);
  6447. $warehouse = $this->input->post('warehouse', true);
  6448. $purchase = $this->input->post('purchase', true);
  6449. $orderinfo = $this->input->post('orderinfo', true);
  6450. $waybill = $this->input->post('waybill', true);
  6451. $category = $this->input->post('category', true);
  6452. $size = $this->input->post('size', true);
  6453. $grade = $this->input->post('grade', true);
  6454. $color = $this->input->post('color', true);
  6455. $lowe = $this->input->post('lowe', true);
  6456. $state = $this->input->post('state', true);
  6457. $label = $this->input->post('label', true);
  6458. $timetk = $this->input->post('ktime', true);
  6459. $timetj = $this->input->post('jtime', true);
  6460. $timetk = strtotime($timetk);
  6461. $timetj = strtotime($timetj);
  6462. $where = "1=1 ";
  6463. if ($timetk && $timetj) {
  6464. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6465. }
  6466. if ($sku) {
  6467. $where .= " and sku = '$sku'";
  6468. }
  6469. if ($bs != '') {
  6470. $where .= " and bs = '$bs'";
  6471. }
  6472. if ($number) {
  6473. $where .= " and number = '$number'";
  6474. }
  6475. if ($warehouse) {
  6476. $where .= " and warehouse = '$warehouse'";
  6477. }
  6478. if ($purchase) {
  6479. $where .= " and purchase = '$purchase'";
  6480. }
  6481. if ($orderinfo) {
  6482. $where .= " and orderinfo = '$orderinfo'";
  6483. }
  6484. if ($waybill) {
  6485. $where .= " and waybill = '$waybill'";
  6486. }
  6487. if ($category) {
  6488. $where .= " and features like '%-$category-%'";
  6489. }
  6490. if ($size) {
  6491. $where .= " and features like '%-$size-%'";
  6492. }
  6493. if ($grade) {
  6494. $where .= " and features like '%-$grade-%'";
  6495. }
  6496. if ($color) {
  6497. $where .= " and features like '%-$color-%'";
  6498. }
  6499. if ($lowe) {
  6500. $where .= " and features like '%-$lowe-%'";
  6501. }
  6502. if ($label) {
  6503. $where .= " and label = '$label'";
  6504. }
  6505. if ($state || $state == 0) {
  6506. $where .= " and state = '$state'";
  6507. }
  6508. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6509. //数据排序
  6510. $order_str = "enter desc";
  6511. if (empty($page)) {
  6512. $start = 0;
  6513. $perpage = 1;
  6514. } else {
  6515. $start = ($page - 1) * $perpage;
  6516. }
  6517. //取得信息列表
  6518. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6519. foreach ($info_list as $key => $value) {
  6520. $warehouse = $this->warehouse->read($value['warehouse']);
  6521. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6522. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6523. if ($value['state'] == 0) {
  6524. $info_list[$key]['state'] = "在库";
  6525. } else if ($value['state'] == 1) {
  6526. $info_list[$key]['state'] = "出库";
  6527. } else if ($value['state'] == 2) {
  6528. $info_list[$key]['state'] = "退库";
  6529. } else if ($value['state'] == 3) {
  6530. $info_list[$key]['state'] = "调拨中";
  6531. } else if ($value['state'] == 4) {
  6532. $info_list[$key]['state'] = "再加工";
  6533. } else if ($value['state'] == 5) {
  6534. $info_list[$key]['state'] = "维修中";
  6535. } else if ($value['state'] == 6) {
  6536. $info_list[$key]['state'] = "盘亏";
  6537. } else if ($value['state'] == 7) {
  6538. $info_list[$key]['state'] = "更换标签";
  6539. } else if ($value['state'] == 8) {
  6540. $info_list[$key]['state'] = "其它";
  6541. } else if ($value['state'] == 9) {
  6542. $info_list[$key]['state'] = "预设";
  6543. } else if ($value['state'] == 10) {
  6544. $info_list[$key]['state'] = "美店零售";
  6545. }
  6546. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6547. }
  6548. $total = $this->$ck->find_count($where);
  6549. $pagenum = ceil($total / $perpage);
  6550. $over = $total - ($start + $perpage);
  6551. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6552. echo json_encode($rows);
  6553. exit;
  6554. }
  6555. if (isset($post['tmsku'])) {
  6556. $time = time();
  6557. $tmsku = $this->input->post('tmsku', true);
  6558. //$post['shop'] = $this->input->post('shop',true);
  6559. $num = $this->input->post('num', true);
  6560. $rktype = $this->input->post('rktype', true);
  6561. if ($num > 200) {
  6562. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6563. exit;
  6564. }
  6565. if (!$rktype) {
  6566. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6567. }
  6568. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6569. /**
  6570. $wz = array();
  6571. foreach ($rk as $key=>$value)
  6572. {
  6573. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6574. }
  6575. if(count($wz) > 1)
  6576. {
  6577. $wz = array_values($wz);
  6578. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6579. }
  6580. **/
  6581. if (isset($rk[0]['purchase'])) {
  6582. $rk = $rk[0];
  6583. $j = 0;
  6584. $post['purchase'] = $rk['purchase'];
  6585. $post['warehouse'] = $rk['warehouse'];
  6586. $post['retreatwarehouse'] = $rk['warehouse'];
  6587. $post['sku'] = $rk['sku'];
  6588. $post['number'] = $rk['number'];
  6589. $post['features'] = $rk['features'];
  6590. $post['title'] = $rk['title'];
  6591. $post['enter'] = $time;
  6592. $post['time'] = $time;
  6593. $post['bs'] = 1;
  6594. $post['shop'] = $rk['shop'];
  6595. $post['details'] = $rk['details'];
  6596. $post['cpid'] = $rk['cpid'];
  6597. $post['cpbz'] = $rk['cpbz'];
  6598. $post['rktype'] = $rktype;
  6599. $warehouse = $this->warehouse->read($rk['warehouse']);
  6600. if ($warehouse['bdck'] == '') {
  6601. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6602. exit;
  6603. } else {
  6604. $bdck = $warehouse['bdck'];
  6605. }
  6606. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6607. if (isset($pdwz['details'])) {
  6608. if ($pdwz['details'] != $post['details']) {
  6609. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6610. }else{
  6611. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6612. exit;
  6613. }
  6614. }
  6615. }
  6616. $post['featurespp'] = $rk['featurespp'];
  6617. if ($post['warehouse'] == '5') {
  6618. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6619. if ($yza) {
  6620. if ($post['features'] != $yza[0]['features']) {
  6621. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6622. exit;
  6623. }
  6624. }
  6625. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6626. if ($yzb) {
  6627. if ($post['sku'] != $yzb[0]['sku']) {
  6628. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6629. exit;
  6630. }
  6631. }
  6632. }
  6633. for ($i = 0; $i < $num; $i++) {
  6634. $post['label'] = time() . rand(100, 999) . $i;
  6635. if ($this->$bdck->insert($post)) {
  6636. $j++;
  6637. }
  6638. }
  6639. /**
  6640. if($post['warehouse'] != 12)
  6641. {
  6642. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6643. }
  6644. **/
  6645. $this->whlabelscanlog->insert([
  6646. 'shop'=>$rk['shop'],
  6647. 'type'=>1,
  6648. 'purchase'=>$rk['purchase'],
  6649. 'sku'=>$rk['sku'],
  6650. 'features'=>$rk['features'],
  6651. 'title'=>$rk['title'],
  6652. 'label'=>$rk['label'],
  6653. 'warehouse'=>$rk['warehouse'],
  6654. 'wlid'=>$rk['id'],
  6655. 'num'=>$num,
  6656. 'addtime'=>time()
  6657. ]);
  6658. if ($j == $num) {
  6659. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6660. exit;
  6661. } else {
  6662. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6663. exit;
  6664. }
  6665. } else {
  6666. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6667. exit;
  6668. }
  6669. }
  6670. $this->_Template('whlabel_printrk', $this->data);
  6671. }
  6672. public function _printxzrk($arg_array)
  6673. {
  6674. $post = $this->input->post(NULL, TRUE);
  6675. if (isset($post['wzid'])) {
  6676. $time = time();
  6677. $id = $this->input->post('wzid', true);
  6678. //$post['shop'] = $this->input->post('shop',true);
  6679. $num = 1;
  6680. $rk = $this->whlabellabel->read($id);
  6681. if (isset($rk['purchase'])) {
  6682. $x = 0;
  6683. $post['purchase'] = $rk['purchase'];
  6684. $post['warehouse'] = $rk['warehouse'];
  6685. $post['retreatwarehouse'] = $rk['warehouse'];
  6686. $post['sku'] = $rk['sku'];
  6687. $post['number'] = $rk['number'];
  6688. $post['features'] = $rk['features'];
  6689. $post['title'] = $rk['title'];
  6690. $post['enter'] = $time;
  6691. $post['time'] = $time;
  6692. $post['bs'] = 1;
  6693. $post['shop'] = $rk['shop'];
  6694. $post['details'] = $rk['details'];
  6695. $post['cpid'] = $rk['cpid'];
  6696. $post['cpbz'] = $rk['cpbz'];
  6697. $warehouse = $this->warehouse->read($rk['warehouse']);
  6698. if ($warehouse['bdck'] == '') {
  6699. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6700. exit;
  6701. } else {
  6702. $bdck = $warehouse['bdck'];
  6703. }
  6704. $post['featurespp'] = $rk['featurespp'];
  6705. $this->db->trans_begin();
  6706. for ($i = 0; $i < $num; $i++) {
  6707. $post['label'] = time() . rand(100, 999) . $i;
  6708. $this->$bdck->insert($post);
  6709. }
  6710. /**
  6711. if($post['warehouse'] != 12)
  6712. {
  6713. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6714. }
  6715. **/
  6716. if ($this->db->trans_status() === TRUE) {
  6717. $this->db->trans_commit();
  6718. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6719. exit;
  6720. } else {
  6721. $this->db->trans_rollback();
  6722. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6723. exit;
  6724. }
  6725. } else {
  6726. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6727. exit;
  6728. }
  6729. }
  6730. }
  6731. public function _printck($arg_array)
  6732. {
  6733. $prc = array();
  6734. $purchase = $this->purchase->find_all();
  6735. foreach ($purchase as $k => $v) {
  6736. $prc[$v['id']] = $v['title'];
  6737. }
  6738. $post = $this->input->post(NULL, TRUE);
  6739. if (isset($post['page'])) {
  6740. $page = $this->input->post('page', true);
  6741. $perpage = $this->input->post('perpage', true);
  6742. $sku = $this->input->post('sku', true);
  6743. $bs = $this->input->post('bs', true);
  6744. $number = $this->input->post('number', true);
  6745. $warehouse = $this->input->post('warehouse', true);
  6746. $purchase = $this->input->post('purchase', true);
  6747. $orderinfo = $this->input->post('orderinfo', true);
  6748. $waybill = $this->input->post('waybill', true);
  6749. $category = $this->input->post('category', true);
  6750. $size = $this->input->post('size', true);
  6751. $grade = $this->input->post('grade', true);
  6752. $color = $this->input->post('color', true);
  6753. $lowe = $this->input->post('lowe', true);
  6754. $state = $this->input->post('state', true);
  6755. $label = $this->input->post('label', true);
  6756. $timetk = $this->input->post('ktime', true);
  6757. $timetj = $this->input->post('jtime', true);
  6758. $timetk = strtotime($timetk);
  6759. $timetj = strtotime($timetj);
  6760. $where = "state=1 ";
  6761. if ($timetk && $timetj) {
  6762. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6763. }
  6764. if ($sku) {
  6765. $where .= " and sku = '$sku'";
  6766. }
  6767. if ($bs != '') {
  6768. $where .= " and bs = '$bs'";
  6769. }
  6770. if ($number) {
  6771. $where .= " and number = '$number'";
  6772. }
  6773. if ($warehouse) {
  6774. $where .= " and warehouse = '$warehouse'";
  6775. }
  6776. if ($purchase) {
  6777. $where .= " and purchase = '$purchase'";
  6778. }
  6779. if ($orderinfo) {
  6780. $where .= " and orderinfo = '$orderinfo'";
  6781. }
  6782. if ($waybill) {
  6783. $where .= " and waybill = '$waybill'";
  6784. }
  6785. if ($category) {
  6786. $where .= " and features like '%-$category-%'";
  6787. }
  6788. if ($size) {
  6789. $where .= " and features like '%-$size-%'";
  6790. }
  6791. if ($grade) {
  6792. $where .= " and features like '%-$grade-%'";
  6793. }
  6794. if ($color) {
  6795. $where .= " and features like '%-$color-%'";
  6796. }
  6797. if ($lowe) {
  6798. $where .= " and features like '%-$lowe-%'";
  6799. }
  6800. if ($label) {
  6801. $where .= " and label = '$label'";
  6802. }
  6803. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6804. //数据排序
  6805. $order_str = "outk desc";
  6806. if (empty($page)) {
  6807. $start = 0;
  6808. $perpage = 1;
  6809. } else {
  6810. $start = ($page - 1) * $perpage;
  6811. }
  6812. //取得信息列表
  6813. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6814. foreach ($info_list as $key => $value) {
  6815. $warehouse = $this->warehouse->read($value['warehouse']);
  6816. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6817. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6818. if ($value['state'] == 0) {
  6819. $info_list[$key]['state'] = "在库";
  6820. } else if ($value['state'] == 1) {
  6821. $info_list[$key]['state'] = "出库";
  6822. } else if ($value['state'] == 2) {
  6823. $info_list[$key]['state'] = "退库";
  6824. } else if ($value['state'] == 3) {
  6825. $info_list[$key]['state'] = "调拨中";
  6826. } else if ($value['state'] == 4) {
  6827. $info_list[$key]['state'] = "再加工";
  6828. } else if ($value['state'] == 5) {
  6829. $info_list[$key]['state'] = "维修中";
  6830. } else if ($value['state'] == 6) {
  6831. $info_list[$key]['state'] = "盘亏";
  6832. } else if ($value['state'] == 7) {
  6833. $info_list[$key]['state'] = "更换标签";
  6834. } else if ($value['state'] == 8) {
  6835. $info_list[$key]['state'] = "其它";
  6836. } else if ($value['state'] == 9) {
  6837. $info_list[$key]['state'] = "预设";
  6838. } else if ($value['state'] == 10) {
  6839. $info_list[$key]['state'] = "美店零售";
  6840. }
  6841. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6842. }
  6843. $total = $this->$ck->find_count($where);
  6844. $pagenum = ceil($total / $perpage);
  6845. $over = $total - ($start + $perpage);
  6846. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6847. echo json_encode($rows);
  6848. exit;
  6849. }
  6850. if (isset($post['tmsku'])) {
  6851. $time = time();
  6852. $tmsku = $this->input->post('tmsku', true);
  6853. //$post['shop'] = $this->input->post('shop',true);
  6854. $num = $this->input->post('num', true);
  6855. $cktype = $this->input->post('cktype', true);
  6856. $label = $this->whlabellabel->get_label($tmsku);
  6857. if (!$cktype) {
  6858. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6859. }
  6860. if (!isset($label['warehouse'])) {
  6861. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6862. exit;
  6863. }
  6864. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6865. $extra_where = "";
  6866. if(!empty($label['details'])){
  6867. $extra_where .= " and details = '" . $label['details'] . "'";
  6868. }
  6869. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6870. if (stripos($label['features'], '-126-') !== false) {
  6871. $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);
  6872. } else {
  6873. $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);
  6874. }
  6875. $j = 0;
  6876. if (count($ck) >= $num) {
  6877. for ($i = 0; $i < $num; $i++) {
  6878. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6879. {
  6880. $j++;
  6881. }
  6882. }
  6883. $this->whlabelscanlog->insert([
  6884. 'shop'=>$label['shop'],
  6885. 'type'=>2,
  6886. 'purchase'=>$label['purchase'],
  6887. 'sku'=>$label['sku'],
  6888. 'features'=>$label['features'],
  6889. 'title'=>$label['title'],
  6890. 'label'=>$label['label'],
  6891. 'warehouse'=>$label['warehouse'],
  6892. 'wlid'=>$label['id'],
  6893. 'num'=>$num,
  6894. 'addtime'=>time()
  6895. ]);
  6896. if ($j == $num) {
  6897. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6898. exit;
  6899. } else {
  6900. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6901. exit;
  6902. }
  6903. } else {
  6904. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6905. exit;
  6906. }
  6907. }
  6908. if(isset($_SESSION['api']))
  6909. {
  6910. $user = $this->user->get_api($_SESSION['api']);
  6911. if(in_array($user['power'],[1,27])){
  6912. $vip = 1;
  6913. }
  6914. }
  6915. else
  6916. {
  6917. $vip = 0;
  6918. header('Location: /');exit;
  6919. }
  6920. $this->data['vip'] = $vip;
  6921. $this->_Template('whlabel_printck', $this->data);
  6922. }
  6923. public function _printexcel()
  6924. {
  6925. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6926. $config['upload_path'] = '.' . $dir;
  6927. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6928. $config['allowed_types'] = 'xls|xlsx|csv';
  6929. $config['max_size'] = 10240;
  6930. $this->load->library('upload', $config);
  6931. $this->upload->initialize($config);
  6932. if ($this->upload->do_upload('userfile')) {
  6933. $full_path = $dir . $this->upload->data('file_name');
  6934. $fileName = '.' . $full_path;
  6935. if (!file_exists($fileName)) {
  6936. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6937. exit;
  6938. } else {
  6939. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6940. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6941. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6942. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6943. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6944. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6945. ++$column; //如果列数大于26行
  6946. $list = array();
  6947. for ($i = 2; $i <= $row; $i++) // 行数循环
  6948. {
  6949. $data = array();
  6950. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6951. {
  6952. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6953. }
  6954. $list[] = $data;
  6955. }
  6956. }
  6957. $ed = array();
  6958. $i = 0;
  6959. $j = 0;
  6960. $dcdata = array();
  6961. $yc = '';
  6962. $cmf_arr = array_column($list, '1');
  6963. array_multisort($cmf_arr, SORT_ASC, $list);
  6964. foreach ($list as $key => $value) {
  6965. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6966. if ($typeclass) {
  6967. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6968. } else {
  6969. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6970. $i++;
  6971. continue;
  6972. }
  6973. }
  6974. if ($i > 0) {
  6975. $yc = $i . '条异常';
  6976. }
  6977. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6978. exit;
  6979. }
  6980. }
  6981. public function _uck()
  6982. {
  6983. if (isset($_GET['excel'])) {
  6984. $tc = array();
  6985. $typeclass = $this->typeclass->find_all();
  6986. foreach ($typeclass as $v) {
  6987. $tc[$v['id']] = $v['zh'];
  6988. }
  6989. $data = array();
  6990. $t = array();
  6991. $rq = '';
  6992. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6993. $ts = $ts / (24 * 3600);
  6994. for ($i = 0; $i < $ts; $i++) {
  6995. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6996. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6997. }
  6998. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6999. foreach ($info_list as $k => $v) {
  7000. $features = explode('-', trim($v['features'], '-'));
  7001. if (!isset($features[3]) || !isset($features[4])) {
  7002. continue;
  7003. }
  7004. $data[$k][0] = $tc[$features[0]]; //类型
  7005. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7006. $data[$k][2] = $tc[$features[4]]; //曲度
  7007. $data[$k][3] = '';
  7008. if (isset($data[$k][1])) {
  7009. $data[$k][3] .= $data[$k][1];
  7010. }
  7011. if (isset($data[$k][2])) {
  7012. $data[$k][3] .= $data[$k][2];
  7013. }
  7014. if (isset($features[5])) {
  7015. $data[$k][3] .= $tc[$features[5]];
  7016. }
  7017. if (isset($features[2])) {
  7018. $data[$k][3] .= $tc[$features[2]];
  7019. }
  7020. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7021. $data[$k][4] = $v['sku'];
  7022. $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())) . '))'); //月初库存
  7023. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7024. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7025. $ztrq = '';
  7026. $ztsl = '';
  7027. if (count($zt) > 0) {
  7028. foreach ($zt as $vv) {
  7029. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7030. $ztsl .= $vv['num'] . '<br>';
  7031. }
  7032. }
  7033. $data[$k][] = trim($ztsl, '<br>');
  7034. $data[$k][] = trim($ztrq, '<br>');
  7035. $byck = 0;
  7036. foreach ($t as $vv) {
  7037. $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));
  7038. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7039. $byck += $sl;
  7040. }
  7041. $data[$k][] = ($byck > 0) ? $byck : '';
  7042. }
  7043. $title = "详情 " . date("Y-m-d", time());
  7044. $titlename = "<table border=1>
  7045. <tr align='center'>
  7046. <td>类别</td>
  7047. <td>颜色</td>
  7048. <td>曲度</td>
  7049. <td>名称</td>
  7050. <td>SKU</td>
  7051. <td>月初库存</td>
  7052. <td>剩余库存</td>
  7053. <td>在途数量</td>
  7054. <td>预达日期</td>" .
  7055. $rq
  7056. . "<td>本月出库</td></tr>
  7057. </table>";
  7058. $filename = $title . ".xls";
  7059. $tail = "";
  7060. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7061. }
  7062. }
  7063. public function _whlabelexcelzh()
  7064. {
  7065. if (isset($_GET['excel'])) {
  7066. $where = "sku != 'Preset'";
  7067. //数据排序
  7068. $order_str = "id desc";
  7069. if (empty($page)) {
  7070. $start = 0;
  7071. $perpage = 1;
  7072. } else {
  7073. $start = ($page - 1) * $perpage;
  7074. }
  7075. $category = $this->input->get('category', true);
  7076. $warehouse = $this->input->get('warehouse', true);
  7077. $excelid = $this->input->get('sid', true);
  7078. if ($category) {
  7079. $where .= " and features like '%-$category-%'";
  7080. }
  7081. if ($warehouse) {
  7082. $where .= " and warehouse = '$warehouse'";
  7083. }
  7084. $xzid = '';
  7085. if ($excelid) {
  7086. $excelid = explode(',', trim($excelid, ','));
  7087. foreach ($excelid as $key => $value) {
  7088. $xzid .= " id = " . $value . " or";
  7089. }
  7090. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7091. }
  7092. //取得信息列表
  7093. /**
  7094. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7095. $rows = array();$list = array();
  7096. foreach ($info_list as $key=>$value)
  7097. {
  7098. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7099. }
  7100. **/
  7101. $list = array();
  7102. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7103. foreach ($rows as $key => $value) {
  7104. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7105. $zh = '';
  7106. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7107. foreach ($zt as $v) {
  7108. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7109. }
  7110. $zt = array_sum(array_column($zt, 'num'));
  7111. $number = $value['number'];
  7112. $ftime = time() - 15 * 24 * 3600;
  7113. $warehouse = $this->warehouse->read($value['warehouse']);
  7114. $rows[$key]['warehouse'] = $warehouse['title'];
  7115. $rows[$key]['number'] = $c;
  7116. $rows[$key]['features'] = $zh;
  7117. $rows[$key]['hb'] = $c + $zt;
  7118. }
  7119. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7120. $titlename = "<table border=1>
  7121. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7122. <tr align='center'>
  7123. <td>仓库</td>
  7124. <td>SKU</td>
  7125. <td>产品</td>
  7126. <td>库存数量</td>
  7127. <td>在途数量及预达日期</td>
  7128. <td>在途+库存数量</td>
  7129. </tr>
  7130. </table>";
  7131. $filename = $title . ".xls";
  7132. $tail = "";
  7133. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7134. }
  7135. if (isset($_GET['excel'])) {
  7136. $warehouse = $this->input->get('warehouse', true);
  7137. $sku = $this->input->get('sku', true);
  7138. $cz = $this->input->get('cz', true);
  7139. $text = $this->input->post('text', true);
  7140. $xztime = $this->input->get('xztime', true);
  7141. $timetk = $this->input->get('timetk', true);
  7142. $timetj = $this->input->get('timetj', true);
  7143. $timetk = strtotime($timetk);
  7144. $timetj = strtotime($timetj);
  7145. $where = "time = '0' ";
  7146. if ($warehouse) {
  7147. $where .= " and warehouse = '$warehouse'";
  7148. }
  7149. if ($sku) {
  7150. $where .= " and sku = '$sku'";
  7151. }
  7152. if ($text) {
  7153. $where .= " and text like '%$text%'";
  7154. }
  7155. if ($cz != '') {
  7156. $where .= " and cz = '$cz'";
  7157. }
  7158. if ($timetk && $timetj) {
  7159. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7160. }
  7161. //数据排序
  7162. $order_str = $xztime . " desc";
  7163. //取得信息列表
  7164. $zh = array();
  7165. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7166. foreach ($info_list as $v) {
  7167. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7168. $warehouse = $this->warehouse->read($v['warehouse']);
  7169. $v['warehouse'] = $warehouse['title'];
  7170. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7171. $v['stime'] = date('Y-m-d', $v['stime']);
  7172. if (isset($zh[$v['features']])) {
  7173. $zh[$v['features']]['num'] += $v['num'];
  7174. } else {
  7175. $zh[$v['features']] = $v;
  7176. }
  7177. $zh[$v['features']]['features'] = $c;
  7178. }
  7179. $title = "在途数据" . date('Y-m-d', time());
  7180. $titlename = "<table border=1>
  7181. <tr align='center'>
  7182. <td>仓库</td>
  7183. <td>SKU</td>
  7184. <td>名称</td>
  7185. <td>在途数量</td>
  7186. <td>库存数量</td>
  7187. <td>添加在途日期</td>
  7188. <td>预达日期</td>
  7189. <td>备注</td>
  7190. </tr>
  7191. </table>";
  7192. $filename = $title . ".xls";
  7193. $tail = "";
  7194. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7195. }
  7196. }
  7197. public function _fc()
  7198. {
  7199. $vip = 0;
  7200. if (isset($_SESSION['api'])) {
  7201. $user = $this->user->get_api($_SESSION['api']);
  7202. if ($user['vip'] == 1) {
  7203. $vip = 1;
  7204. }
  7205. } else {
  7206. header('Location: /');
  7207. exit;
  7208. }
  7209. $post = $this->input->post(NULL, TRUE);
  7210. if (isset($post['page'])) {
  7211. $page = $this->input->post('page', true);
  7212. $perpage = $this->input->post('perpage', true);
  7213. $category = $this->input->post('category', true);
  7214. $size = $this->input->post('size', true);
  7215. $grade = $this->input->post('grade', true);
  7216. $color = $this->input->post('color', true);
  7217. $lowe = $this->input->post('lowe', true);
  7218. $sku = $this->input->post('sku');
  7219. $title = $this->input->post('title');
  7220. $warehouse = $this->input->post('warehouse', true);
  7221. $usa = $this->input->post('usa', true);
  7222. $purchase = $this->input->post('purchase', true);
  7223. $lacetype = $this->input->post('lacetype', true);
  7224. $haircap = $this->input->post('haircap', true);
  7225. $density = $this->input->post('density', true);
  7226. $details = $this->input->post('details', true);
  7227. $state = $this->input->post('state', true);
  7228. $ktime = $this->input->post('ktime', true);
  7229. $jtime = $this->input->post('jtime', true);
  7230. $ktime = strtotime($ktime);
  7231. $jtime = strtotime($jtime);
  7232. $where = "state = '11'";
  7233. $gj = "";
  7234. $ck = "";
  7235. if ($lacetype) {
  7236. $where .= " and features like '%-$lacetype-%'";
  7237. }
  7238. if ($category) {
  7239. $where .= " and features like '%-$category-%'";
  7240. }
  7241. if ($size) {
  7242. $where .= " and features like '%-$size-%'";
  7243. }
  7244. if ($grade) {
  7245. $where .= " and features like '%-$grade-%'";
  7246. }
  7247. if ($color) {
  7248. $where .= " and features like '%-$color-%'";
  7249. }
  7250. if ($lowe) {
  7251. $where .= " and features like '%-$lowe-%'";
  7252. }
  7253. if ($haircap) {
  7254. $where .= " and features like '%-$haircap-%'";
  7255. }
  7256. if ($density) {
  7257. $where .= " and features like '%-$density-%'";
  7258. }
  7259. if ($usa) {
  7260. if (!$warehouse) {
  7261. $where .= " and (warehouse = '5' or warehouse = '8')";
  7262. }
  7263. }
  7264. if ($warehouse) {
  7265. $where .= " and warehouse = '$warehouse'";
  7266. }
  7267. if ($details) {
  7268. $where .= " and details = '$details'";
  7269. }
  7270. if ($purchase) {
  7271. $where .= " and purchase = '$purchase'";
  7272. }
  7273. if ($state) {
  7274. $where .= " and state = '$state'";
  7275. }
  7276. if ($ktime && $jtime) {
  7277. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7278. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7279. }
  7280. //数据排序
  7281. $order_str = "id desc";
  7282. if (empty($page)) {
  7283. $start = 0;
  7284. $perpage = 1;
  7285. } else {
  7286. $start = ($page - 1) * $perpage;
  7287. }
  7288. if ($sku) {
  7289. $sku = trim($sku, ' ');
  7290. $sku = trim($sku, ' ');
  7291. $where .= " and sku like '%$sku%'";
  7292. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7293. } else if ($title) {
  7294. $title = trim($title, ' ');
  7295. $title = trim($title, ' ');
  7296. $where .= " and title like '%$title%'";
  7297. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7298. } else {
  7299. //$where .= " and time > '$ktime' and time < '$jtime'";
  7300. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7301. }
  7302. //取得信息列表
  7303. $rows = array();
  7304. $list = array();
  7305. foreach ($info_list as $key => $value) {
  7306. $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'] . '"');
  7307. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7308. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7309. $warehouse = $this->warehouse->read($value['warehouse']);
  7310. $info_list[$key]['warehouse'] = $warehouse['title'];
  7311. $info_list[$key]['number'] = $g;
  7312. $info_list[$key]['features'] = $x;
  7313. $info_list[$key]['x'] = $s;
  7314. }
  7315. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7316. $pagenum = ceil($total / $perpage);
  7317. $over = $total - ($start + $perpage);
  7318. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7319. echo json_encode($rows);
  7320. exit;
  7321. }
  7322. $this->data['vip'] = $vip;
  7323. $this->_Template('whlabel_fc', $this->data);
  7324. }
  7325. public function _fcmb()
  7326. {
  7327. $where = "sku != 'Preset'";
  7328. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7329. foreach ($rows as $k => $v) {
  7330. $warehouse = $this->warehouse->read($v['warehouse']);
  7331. $rows[$k]['warehouse'] = $warehouse['title'];
  7332. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7333. $rows[$k]['t'] = '';
  7334. $rows[$k]['n'] = '';
  7335. }
  7336. $title = "封货产品数据导入模板";
  7337. $titlename = "<table border=1>
  7338. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7339. <tr align='center'>
  7340. <td>仓库</td>
  7341. <td>SKU</td>
  7342. <td>产品</td>
  7343. <td>封存产品总数量</td>
  7344. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7345. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7346. </tr>
  7347. </table>";
  7348. $filename = $title . ".xls";
  7349. $tail = "";
  7350. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7351. }
  7352. public function _fcexcel()
  7353. {
  7354. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7355. $config['upload_path'] = '.' . $dir;
  7356. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7357. $config['allowed_types'] = 'xls|xlsx|csv';
  7358. $config['max_size'] = 10240;
  7359. $this->load->library('upload', $config);
  7360. $this->upload->initialize($config);
  7361. if ($this->upload->do_upload('userfile')) {
  7362. $full_path = $dir . $this->upload->data('file_name');
  7363. $fileName = '.' . $full_path;
  7364. if (!file_exists($fileName)) {
  7365. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7366. exit;
  7367. } else {
  7368. libxml_use_internal_errors(true);
  7369. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7370. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7371. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7372. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7373. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7374. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7375. ++$column; //如果列数大于26行
  7376. $list = array();
  7377. for ($i = 2; $i <= $row; $i++) // 行数循环
  7378. {
  7379. $data = array();
  7380. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7381. {
  7382. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7383. }
  7384. $list[] = $data;
  7385. }
  7386. }
  7387. $i = 0;
  7388. $j = 0;
  7389. $ed = array();
  7390. foreach ($list as $key => $value) {
  7391. $time = time();
  7392. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7393. continue;
  7394. }
  7395. $warehouse = $this->warehouse->get_title($value['0']);
  7396. $sku = $value['1'];
  7397. $type = $value['4']; //调整方式0扣减1删除
  7398. $num = $value['5']; //调整数量
  7399. //$text = $value['4'];//扣减说明
  7400. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7401. if (!$d) //如果没有这个SKU
  7402. {
  7403. $ed[] = array($sku . '-库存中不存在此SKU');
  7404. $j++;
  7405. continue;
  7406. }
  7407. if (!isset($warehouse['id'])) {
  7408. $ed[] = array($sku . '-仓库名错误!');
  7409. $j++;
  7410. continue;
  7411. }
  7412. if ($type == 1 || $type == 2) //扣减库存
  7413. {
  7414. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7415. if (count($data) < abs($num)) {
  7416. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7417. $j++;
  7418. continue;
  7419. }
  7420. if ($type == 1) //转入库存
  7421. {
  7422. for ($i = 0; $i < abs($num); $i++) {
  7423. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7424. }
  7425. } else if ($type == 2) //删除
  7426. {
  7427. for ($i = 0; $i < abs($num); $i++) {
  7428. $this->whlabel->remove($data[$i]['id']);
  7429. }
  7430. }
  7431. } else if ($type == 0) //增加库存
  7432. {
  7433. $post['sku'] = $d['sku'];
  7434. $post['shop'] = '';
  7435. $post['warehouse'] = $warehouse['id'];
  7436. $post['purchase'] = $d['purchase'];
  7437. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7438. $post['state'] = 11;
  7439. $post['title'] = $d['title'];
  7440. $post['number'] = $d['number'];
  7441. $post['features'] = $d['features'];
  7442. $post['enter'] = $time;
  7443. $post['time'] = $time; //操作时间
  7444. for ($i = 0; $i < $num; $i++) {
  7445. $post['label'] = time() . rand(100, 999) . $i;
  7446. $this->whlabel->insert($post);
  7447. }
  7448. }
  7449. sleep(1); //防止入库时间一样,需要延迟1秒
  7450. }
  7451. if ($j > 0) {
  7452. $tt = date('Ymd', time());
  7453. $title = '库存导入错误信息-' . $tt;
  7454. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7455. $tail = "\n";
  7456. $filename = $title . ".xls";
  7457. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7458. $dir = '/data/excel/' . $time . '/';
  7459. $file_name = 'error_' . $time . rand(1000, 9999);
  7460. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7461. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7462. fwrite($myfile, $ecl);
  7463. fclose($myfile);
  7464. $error = $dir . $file_name . '.xls';
  7465. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7466. exit;
  7467. } else {
  7468. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7469. exit;
  7470. }
  7471. }
  7472. }
  7473. public function _fcjxc($arg_array)
  7474. {
  7475. if (isset($_GET['excel'])) {
  7476. $category = $this->input->get('category', true);
  7477. $size = $this->input->get('size', true);
  7478. $grade = $this->input->get('grade', true);
  7479. $color = $this->input->get('color', true);
  7480. $lowe = $this->input->get('lowe', true);
  7481. $sku = $this->input->get('sku');
  7482. $title = $this->input->get('title');
  7483. $warehouse = $arg_array[0];
  7484. $usa = $this->input->get('usa', true);
  7485. $purchase = $this->input->get('purchase', true);
  7486. $lacetype = $this->input->get('lacetype', true);
  7487. $haircap = $this->input->get('haircap', true);
  7488. $density = $this->input->get('density', true);
  7489. $title = $this->input->get('title', true);
  7490. $state = $this->input->get('state', true);
  7491. $ktime = $this->input->get('ktime', true);
  7492. $jtime = $this->input->get('jtime', true);
  7493. $where = "state=11";
  7494. $gj = "";
  7495. $ck = "";
  7496. if ($lacetype) {
  7497. $where .= " and features like '%-$lacetype-%'";
  7498. }
  7499. if ($category) {
  7500. $where .= " and features like '%-$category-%'";
  7501. }
  7502. if ($size) {
  7503. $where .= " and features like '%-$size-%'";
  7504. }
  7505. if ($grade) {
  7506. $where .= " and features like '%-$grade-%'";
  7507. }
  7508. if ($color) {
  7509. $where .= " and features like '%-$color-%'";
  7510. }
  7511. if ($lowe) {
  7512. $where .= " and features like '%-$lowe-%'";
  7513. }
  7514. if ($haircap) {
  7515. $where .= " and features like '%-$haircap-%'";
  7516. }
  7517. if ($density) {
  7518. $where .= " and features like '%-$density-%'";
  7519. }
  7520. if ($usa) {
  7521. if (!$warehouse) {
  7522. $where .= " and (warehouse = '5' or warehouse = '8')";
  7523. }
  7524. }
  7525. if ($warehouse) {
  7526. $where .= " and warehouse = '$warehouse'";
  7527. }
  7528. if ($purchase) {
  7529. $where .= " and purchase = '$purchase'";
  7530. }
  7531. if ($state) {
  7532. $where .= " and state = '$state'";
  7533. }
  7534. $order_str = "id desc";
  7535. if ($sku) {
  7536. $sku = trim($sku, ' ');
  7537. $sku = trim($sku, ' ');
  7538. $where .= " and sku like '%$sku%'";
  7539. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7540. } else if ($title) {
  7541. $title = trim($title, ' ');
  7542. $title = trim($title, ' ');
  7543. $where .= " and title like '%$title%'";
  7544. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7545. } else {
  7546. //$where .= " and time > '$ktime' and time < '$jtime'";
  7547. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7548. }
  7549. //取得信息列表
  7550. $rows = array();
  7551. $list = array();
  7552. foreach ($info_list as $key => $value) {
  7553. $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'] . '"');
  7554. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7555. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7556. $rows[$key] = $value;
  7557. $warehouse = $this->warehouse->read($value['warehouse']);
  7558. $rows[$key]['warehouse'] = $warehouse['title'];
  7559. $rows[$key]['features'] = $g;
  7560. $rows[$key]['a'] = $x;
  7561. $rows[$key]['b'] = $s;
  7562. }
  7563. $title = "总统计表";
  7564. $titlename = "<table border=1>
  7565. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7566. <tr align='center'>
  7567. <td>仓库</td>
  7568. <td>SKU</td>
  7569. <td>产品名称</td>
  7570. <td>录入总量</td>
  7571. <td>取出总量</td>
  7572. <td>剩余总量</td>
  7573. </tr>
  7574. </table>";
  7575. $filename = $title . ".xls";
  7576. $tail = "";
  7577. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7578. }
  7579. $vip = 0;
  7580. if (isset($_SESSION['api'])) {
  7581. $user = $this->user->get_api($_SESSION['api']);
  7582. if ($user['vip'] == 1) {
  7583. $vip = 1;
  7584. }
  7585. } else {
  7586. header('Location: /');
  7587. exit;
  7588. }
  7589. $post = $this->input->post(NULL, TRUE);
  7590. if (isset($post['page'])) {
  7591. $page = $this->input->post('page', true);
  7592. $perpage = $this->input->post('perpage', true);
  7593. $category = $this->input->post('category', true);
  7594. $size = $this->input->post('size', true);
  7595. $grade = $this->input->post('grade', true);
  7596. $color = $this->input->post('color', true);
  7597. $lowe = $this->input->post('lowe', true);
  7598. $sku = $this->input->post('sku');
  7599. $title = $this->input->post('title');
  7600. $warehouse = $arg_array[0];
  7601. $usa = $this->input->post('usa', true);
  7602. $purchase = $this->input->post('purchase', true);
  7603. $lacetype = $this->input->post('lacetype', true);
  7604. $haircap = $this->input->post('haircap', true);
  7605. $density = $this->input->post('density', true);
  7606. $title = $this->input->post('title', true);
  7607. $state = $this->input->post('state', true);
  7608. $ktime = $this->input->post('ktime', true);
  7609. $jtime = $this->input->post('jtime', true);
  7610. $ktime = strtotime($ktime);
  7611. $jtime = strtotime($jtime);
  7612. $where = "state=11";
  7613. $gj = "";
  7614. $ck = "";
  7615. if ($lacetype) {
  7616. $where .= " and features like '%-$lacetype-%'";
  7617. }
  7618. if ($category) {
  7619. $where .= " and features like '%-$category-%'";
  7620. }
  7621. if ($size) {
  7622. $where .= " and features like '%-$size-%'";
  7623. }
  7624. if ($grade) {
  7625. $where .= " and features like '%-$grade-%'";
  7626. }
  7627. if ($color) {
  7628. $where .= " and features like '%-$color-%'";
  7629. }
  7630. if ($lowe) {
  7631. $where .= " and features like '%-$lowe-%'";
  7632. }
  7633. if ($haircap) {
  7634. $where .= " and features like '%-$haircap-%'";
  7635. }
  7636. if ($density) {
  7637. $where .= " and features like '%-$density-%'";
  7638. }
  7639. if ($usa) {
  7640. if (!$warehouse) {
  7641. $where .= " and (warehouse = '5' or warehouse = '8')";
  7642. }
  7643. }
  7644. if ($warehouse) {
  7645. $where .= " and warehouse = '$warehouse'";
  7646. }
  7647. if ($purchase) {
  7648. $where .= " and purchase = '$purchase'";
  7649. }
  7650. if ($state) {
  7651. $where .= " and state = '$state'";
  7652. }
  7653. if ($ktime && $jtime) {
  7654. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7655. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7656. }
  7657. //数据排序
  7658. $order_str = "id desc";
  7659. $xs = 0;
  7660. $rows = array();
  7661. $list = array();
  7662. if (empty($page)) {
  7663. $start = 0;
  7664. $perpage = 1;
  7665. } else {
  7666. $start = ($page - 1) * $perpage;
  7667. }
  7668. if ($sku || $title) {
  7669. if ($title) {
  7670. $title = trim($title, ' ');
  7671. $title = trim($title, ' ');
  7672. $where .= " and title like '%$title%'";
  7673. } else {
  7674. $sku = trim($sku, ' ');
  7675. $sku = trim($sku, ' ');
  7676. $where .= " and sku like '%$sku%'";
  7677. }
  7678. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7679. foreach ($info_list as $key => $value) {
  7680. $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'] . '"');
  7681. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7682. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7683. $rows[$key] = $value;
  7684. $warehouse = $this->warehouse->read($value['warehouse']);
  7685. $rows[$key]['warehouse'] = $warehouse['title'];
  7686. $rows[$key]['features'] = $g;
  7687. $rows[$key]['a'] = $x;
  7688. $rows[$key]['b'] = $s;
  7689. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7690. $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天销量
  7691. $yj = $c / ($xl / 30);
  7692. if ($yj < 7) {
  7693. $rows[$key]['y'] = round($yj) . '天销量';
  7694. } else {
  7695. $rows[$key]['y'] = '正常';
  7696. }
  7697. }
  7698. } else {
  7699. //$where .= " and time > '$ktime' and time < '$jtime'";
  7700. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7701. foreach ($info_list as $key => $value) {
  7702. $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'] . '"');
  7703. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7704. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7705. $zs[$key] = $value;
  7706. $warehouse = $this->warehouse->read($value['warehouse']);
  7707. $zs[$key]['warehouse'] = $warehouse['title'];
  7708. $zs[$key]['features'] = $g;
  7709. $zs[$key]['a'] = $x;
  7710. $zs[$key]['b'] = $s;
  7711. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7712. $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天销量
  7713. $yj = $c / ($xl / 30);
  7714. if ($yj < 7) {
  7715. $zs[$key]['y'] = round($yj) . '天销量';
  7716. $rows[$key] = $zs[$key];
  7717. }
  7718. }
  7719. }
  7720. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7721. $pagenum = ceil($total / $perpage);
  7722. $over = $total - ($start + $perpage);
  7723. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7724. echo json_encode($rows);
  7725. exit;
  7726. }
  7727. $this->data['arg_array'] = $arg_array[0];
  7728. $this->_Template('whlabel_fcjxc', $this->data);
  7729. }
  7730. public function _0kcdel()
  7731. {
  7732. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7733. $config['upload_path'] = '.' . $dir;
  7734. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7735. $config['allowed_types'] = 'xls|xlsx|csv';
  7736. $config['max_size'] = 10240;
  7737. $this->load->library('upload', $config);
  7738. $this->upload->initialize($config);
  7739. if ($this->upload->do_upload('userfile')) {
  7740. $full_path = $dir . $this->upload->data('file_name');
  7741. $fileName = '.' . $full_path;
  7742. if (!file_exists($fileName)) {
  7743. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7744. exit;
  7745. } else {
  7746. require_once "./data/excel/PHPExcel/IOFactory.php";
  7747. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7748. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7749. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7750. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7751. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7752. ++$column; //如果列数大于26行
  7753. $list = array();
  7754. for ($i = 2; $i <= $row; $i++) // 行数循环
  7755. {
  7756. $data = array();
  7757. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7758. {
  7759. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7760. }
  7761. $list[] = $data;
  7762. }
  7763. }
  7764. $i = 0;
  7765. $j = 0;
  7766. $ed = array();
  7767. foreach ($list as $key => $value) {
  7768. $time = time();
  7769. if ($value['0'] == "" || $value['1'] == "") {
  7770. continue;
  7771. }
  7772. $warehouse = $this->warehouse->get_title($value['0']);
  7773. $sku = $value['1'];
  7774. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7775. if (!$d) //如果没有这个SKU
  7776. {
  7777. $ed[] = array($sku . '-库存中不存在此SKU');
  7778. $j++;
  7779. continue;
  7780. }
  7781. if (!isset($warehouse['id'])) {
  7782. $ed[] = array($sku . '-仓库名错误!');
  7783. $j++;
  7784. continue;
  7785. }
  7786. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7787. if ($z < 1) {
  7788. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7789. foreach ($z as $v) {
  7790. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7791. if (count($zt) > 0) {
  7792. $ed[] = array($sku . '-有在途库存无法删除!');
  7793. $j++;
  7794. continue;
  7795. }
  7796. $this->whlabel->remove($v['id']);
  7797. }
  7798. } else {
  7799. $ed[] = array($sku . '-非0库存!');
  7800. $j++;
  7801. continue;
  7802. }
  7803. }
  7804. if ($j > 0) {
  7805. $tt = date('Ymd', time());
  7806. $title = '删除0库存错误信息-' . $tt;
  7807. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7808. $tail = "\n";
  7809. $filename = $title . ".xls";
  7810. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7811. $dir = '/data/excel/' . $time . '/';
  7812. $file_name = 'error_' . $time . rand(1000, 9999);
  7813. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7814. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7815. fwrite($myfile, $ecl);
  7816. fclose($myfile);
  7817. $error = $dir . $file_name . '.xls';
  7818. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7819. exit;
  7820. } else {
  7821. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7822. exit;
  7823. }
  7824. }
  7825. }
  7826. public function _gbhtype()
  7827. {
  7828. $post = $this->input->post(NULL, TRUE);
  7829. if (isset($post['s'])) {
  7830. $n = $this->input->post('n');
  7831. $d = $this->input->post('s');
  7832. if (!$d) {
  7833. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7834. exit;
  7835. }
  7836. $d = explode(',', trim($d, ','));
  7837. $t = $this->whlabel_type->read($n);
  7838. //循环删除记录
  7839. foreach ($d as $v) {
  7840. $u = $this->whlabel->read($v);
  7841. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7842. foreach ($data as $val) {
  7843. $this->whlabel->save(array('type' => $n), $val['id']);
  7844. }
  7845. }
  7846. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7847. }
  7848. }
  7849. //出库、退库导出
  7850. public function _dccrtype()
  7851. {
  7852. $classid = $this->classid->sku();
  7853. $pm = $classid;
  7854. $typeclass = array();
  7855. $tc = $this->typeclass->find_all();
  7856. foreach ($tc as $v) {
  7857. $typeclass[$v['id']] = $v;
  7858. }
  7859. $prc = array();
  7860. $purchase = $this->purchase->find_all();
  7861. foreach ($purchase as $k => $v) {
  7862. $prc[$v['id']] = $v['title'];
  7863. }
  7864. if (isset($_GET['sid'])) {
  7865. $wh = array();
  7866. $w = $this->warehouse->find_all('1=1', 'id,title');
  7867. foreach ($w as $v) {
  7868. $wh[$v['id']] = $v['title'];
  7869. }
  7870. $type = $this->input->get('excel', true);
  7871. $category = $this->input->get('category', true);
  7872. $size = $this->input->get('size', true);
  7873. $grade = $this->input->get('grade', true);
  7874. $color = $this->input->get('color', true);
  7875. $lowe = $this->input->get('lowe', true);
  7876. $sku = $this->input->get('sku', true);
  7877. $warehouse = $this->input->get('warehouse', true);
  7878. $lacetype = $this->input->get('lacetype', true);
  7879. $lacecolor = $this->input->get('lacecolor', true);
  7880. $density = $this->input->get('density', true);
  7881. $haircap = $this->input->get('haircap', true);
  7882. $purchase = $this->input->get('purchase', true);
  7883. $title = $this->input->get('title', true);
  7884. $state = $this->input->get('state', true);
  7885. $sid = $this->input->get('sid', true);
  7886. $ktime = $this->input->get('ktime', true);
  7887. $jtime = $this->input->get('jtime', true);
  7888. $ktime = strtotime($ktime);
  7889. $jtime = strtotime($jtime);
  7890. $where = "1=1";
  7891. $gj = "";
  7892. $ck = "";
  7893. if ($category) {
  7894. $where .= " and features like '%-$category-%'";
  7895. }
  7896. if ($size) {
  7897. $where .= " and features like '%-$size-%'";
  7898. }
  7899. if ($grade) {
  7900. $where .= " and features like '%-$grade-%'";
  7901. }
  7902. if ($color) {
  7903. $where .= " and features like '%-$color-%'";
  7904. }
  7905. if ($lowe) {
  7906. $where .= " and features like '%-$lowe-%'";
  7907. }
  7908. if ($warehouse) {
  7909. $where .= " and warehouse = '$warehouse'";
  7910. }
  7911. if ($purchase) {
  7912. $where .= " and purchase = '$purchase'";
  7913. }
  7914. if ($state) {
  7915. $where .= " and state = '$state'";
  7916. }
  7917. if ($lacetype) {
  7918. $where .= " and features like '%-$lacetype-%'";
  7919. }
  7920. if ($lacecolor) {
  7921. $where .= " and features like '%-$lacecolor-%'";
  7922. }
  7923. if ($density) {
  7924. $where .= " and features like '%-$density-%'";
  7925. }
  7926. if ($haircap) {
  7927. $where .= " and features like '%-$haircap-%'";
  7928. }
  7929. if ($title) {
  7930. $title = trim($title, ' ');
  7931. $title = trim($title, ' ');
  7932. $where .= " and title like '%$title%'";
  7933. }
  7934. if ($sku) {
  7935. $sku = trim($sku, ' ');
  7936. $sku = trim($sku, ' ');
  7937. $where .= " and sku like '%$sku%'";
  7938. }
  7939. if ($ktime && $jtime) {
  7940. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7941. }
  7942. $sidwhere = '';
  7943. if ($sid) {
  7944. $sd = "";
  7945. $s = explode(',', trim($sid, ','));
  7946. foreach ($s as $value) {
  7947. $sd .= " id = " . $value . " or";
  7948. }
  7949. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7950. }
  7951. //数据排序
  7952. $order_str = "time desc";
  7953. if (empty($page)) {
  7954. $start = 0;
  7955. $perpage = 1;
  7956. } else {
  7957. $start = ($page - 1) * $perpage;
  7958. }
  7959. $wh = array();
  7960. $w = $this->warehouse->find_all('1=1', 'id,title');
  7961. foreach ($w as $v) {
  7962. $wh[$v['id']] = $v['title'];
  7963. }
  7964. $wt = array();
  7965. $whlabel_type = $this->whlabel_type->find_all();
  7966. foreach ($whlabel_type as $v) {
  7967. $wt[$v['id']] = $v['title'];
  7968. }
  7969. $classid = $this->classid->sku();
  7970. $list = array();
  7971. $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');
  7972. foreach ($rows_r as $key => $value) {
  7973. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7974. $pm = $classid;
  7975. $jm = $classid;
  7976. $rows_r[$key]['enter'] = '入库';
  7977. $rows_r[$key]['time'] = $value['enter'];
  7978. if ($value['rktype'] == 1) {
  7979. $rows_r[$key]['rktype'] = '采购入库';
  7980. } else if ($value['rktype'] == 2) {
  7981. $rows_r[$key]['rktype'] = '盘盈调整';
  7982. } else if ($value['rktype'] == 3) {
  7983. $rows_r[$key]['rktype'] = '其他调整入库';
  7984. } else if ($value['rktype'] == 4) {
  7985. $rows_r[$key]['rktype'] = '其他调整入库';
  7986. } else if ($value['rktype'] == 5) {
  7987. $rows_r[$key]['rktype'] = '退库入库';
  7988. } else if ($value['rktype'] == 6) {
  7989. $rows_r[$key]['rktype'] = '退货可用入库';
  7990. } else if ($value['rktype'] == 7) {
  7991. $rows_r[$key]['rktype'] = '形态转换入库';
  7992. } else {
  7993. $rows_r[$key]['rktype'] = '';
  7994. }
  7995. $features = explode('-', trim($value['features'], '-'));
  7996. foreach ($features as $v) {
  7997. if (isset($typeclass[$v])) {
  7998. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7999. $pm[$typeclass[$v]['classid']] = $zh[0];
  8000. }
  8001. if (isset($typeclass[$v])) {
  8002. if (isset($jm[$typeclass[$v]['classid']])) {
  8003. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8004. }
  8005. }
  8006. }
  8007. $zh = implode(" ", $pm);
  8008. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8009. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8010. $rows_r[$key]['zh'] = $zh;
  8011. $jm = array_filter($jm);
  8012. $rows_r[$key]['features'] = implode("-", $jm);
  8013. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8014. }
  8015. $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');
  8016. foreach ($rows_c as $key => $value) {
  8017. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8018. $pm = $classid;
  8019. $jm = $classid;
  8020. $rows_c[$key]['time'] = $value['outk'];
  8021. $rows_c[$key]['outk'] = '出库';
  8022. if ($value['cktype'] == 1) {
  8023. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8024. } else if ($value['cktype'] == 2) {
  8025. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8026. } else if ($value['cktype'] == 3) {
  8027. $rows_c[$key]['cktype'] = '盘亏调整';
  8028. } else if ($value['cktype'] == 4) {
  8029. $rows_c[$key]['cktype'] = '其他调整出库';
  8030. } else if ($value['cktype'] == 5) {
  8031. $rows_c[$key]['cktype'] = '形态转换出库';
  8032. } else {
  8033. $rows_c[$key]['cktype'] = '';
  8034. }
  8035. unset($rows_c[$key]['state']);
  8036. $features = explode('-', trim($value['features'], '-'));
  8037. foreach ($features as $v) {
  8038. if (isset($typeclass[$v])) {
  8039. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8040. $pm[$typeclass[$v]['classid']] = $zh[0];
  8041. }
  8042. if (isset($typeclass[$v])) {
  8043. if (isset($jm[$typeclass[$v]['classid']])) {
  8044. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8045. }
  8046. }
  8047. }
  8048. $zh = implode(" ", $pm);
  8049. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8050. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8051. $rows_c[$key]['zh'] = $zh;
  8052. $jm = array_filter($jm);
  8053. $rows_c[$key]['features'] = implode("-", $jm);
  8054. $rows_c[$key]['number'] = 1;
  8055. }
  8056. $merged = $rows_r;
  8057. foreach ($rows_c as $key => $value) {
  8058. if (isset($merged[$key])) {
  8059. $merged[] = $value;
  8060. } else {
  8061. $merged[$key] = $value;
  8062. }
  8063. }
  8064. usort($merged, function ($a, $b) {
  8065. return $a['time'] - $b['time'];
  8066. });
  8067. foreach ($merged as $key => $value) {
  8068. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8069. }
  8070. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8071. $titlename = "<table border=1>
  8072. <tr align='center'>
  8073. <td>仓库</td>
  8074. <td>SKU</td>
  8075. <td>商品名称</td>
  8076. <td>仓库品名</td>
  8077. <td>料号</td>
  8078. <td>时间</td>
  8079. <td>操作</td>
  8080. <td>类型</td>
  8081. <td>数量</td>
  8082. <td>备注</td>
  8083. </tr>
  8084. </table>";
  8085. $filename = $title . ".xlsx";
  8086. $tail = "";
  8087. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8088. }
  8089. }
  8090. /*************************************处理exceljs导出****************************************************/
  8091. public function _excelrjs(){
  8092. if (isset($_GET['excel'])) {
  8093. $category = $this->input->get('category', true);
  8094. $size = $this->input->get('size', true);
  8095. $grade = $this->input->get('grade', true);
  8096. $color = $this->input->get('color', true);
  8097. $lowe = $this->input->get('lowe', true);
  8098. $sku = $this->input->get('sku', true);
  8099. $warehouse = $this->input->get('warehouse', true);
  8100. $purchase = $this->input->get('purchase', true);
  8101. $ktime = $this->input->get('ktime', true);
  8102. $jtime = $this->input->get('jtime', true);
  8103. $ktime = strtotime($ktime);
  8104. $jtime = strtotime($jtime);
  8105. $where = "1=1";
  8106. $gj = "";
  8107. $ck = "";
  8108. if ($category) {
  8109. $where .= " and features like '%-$category-%'";
  8110. }
  8111. if ($size) {
  8112. $where .= " and features like '%-$size-%'";
  8113. }
  8114. if ($grade) {
  8115. $where .= " and features like '%-$grade-%'";
  8116. }
  8117. if ($color) {
  8118. $where .= " and features like '%-$color-%'";
  8119. }
  8120. if ($lowe) {
  8121. $where .= " and features like '%-$lowe-%'";
  8122. }
  8123. if ($warehouse) {
  8124. $where .= " and warehouse = '$warehouse'";
  8125. }
  8126. if ($purchase) {
  8127. $where .= " and purchase = '$purchase'";
  8128. }
  8129. if ($sku) {
  8130. $where .= " and sku = '$sku'";
  8131. }
  8132. if ($ktime && $jtime) {
  8133. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8134. }
  8135. //数据排序
  8136. $order_str = "id desc";
  8137. if (empty($page)) {
  8138. $start = 0;
  8139. $perpage = 1;
  8140. } else {
  8141. $start = ($page - 1) * $perpage;
  8142. }
  8143. $list = array();
  8144. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8145. foreach ($rows as $value) {
  8146. $ck = $this->warehouse->read($value['warehouse']);
  8147. $warehouse = $ck['title'];
  8148. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8149. $retreatwarehouse = $tkck['title'];
  8150. $gy = $this->purchase->read($value['purchase']);
  8151. $purchase = $gy['title'];
  8152. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8153. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8154. }
  8155. if(empty($list)){
  8156. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8157. }else{
  8158. $final_list = [];
  8159. foreach($list as $v){
  8160. $final_list[] = array_values($v);
  8161. }
  8162. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8163. array_unshift($final_list,[
  8164. "仓库","SKU","商品名称","时间","数量"
  8165. ]);
  8166. array_unshift($final_list,[
  8167. $title,"","","",""
  8168. ]);
  8169. $merges = [
  8170. [
  8171. "s"=>["r"=>0,"c"=>0],
  8172. "e"=>["r"=>0,"c"=>4]
  8173. ]
  8174. ];
  8175. $cols = [
  8176. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8177. ];
  8178. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8179. }
  8180. }
  8181. }
  8182. //出库、退库导出
  8183. public function _excelctjs()
  8184. {
  8185. $classid = $this->classid->sku();
  8186. $pm = $classid;
  8187. $typeclass = array();
  8188. $tc = $this->typeclass->find_all();
  8189. foreach ($tc as $v) {
  8190. $typeclass[$v['id']] = $v;
  8191. }
  8192. $prc = array();
  8193. $purchase = $this->purchase->find_all();
  8194. foreach ($purchase as $k => $v) {
  8195. $prc[$v['id']] = $v['title'];
  8196. }
  8197. if (isset($_GET['excel'])) {
  8198. $wh = array();
  8199. $w = $this->warehouse->find_all('1=1', 'id,title');
  8200. foreach ($w as $v) {
  8201. $wh[$v['id']] = $v['title'];
  8202. }
  8203. $type = $this->input->get('excel', true);
  8204. $category = $this->input->get('category', true);
  8205. $size = $this->input->get('size', true);
  8206. $grade = $this->input->get('grade', true);
  8207. $color = $this->input->get('color', true);
  8208. $lowe = $this->input->get('lowe', true);
  8209. $sku = $this->input->get('sku', true);
  8210. $title = $this->input->get('title', true);
  8211. $warehouse = $this->input->get('warehouse', true);
  8212. $purchase = $this->input->get('purchase', true);
  8213. $lacetype = $this->input->get('lacetype', true);
  8214. $haircap = $this->input->get('haircap', true);
  8215. $lacecolor = $this->input->get('lacecolor', true);
  8216. $density = $this->input->get('density', true);
  8217. $details = $this->input->get('details', true);
  8218. $state = $this->input->get('state', true);
  8219. $shop = $this->input->get('shop', true);
  8220. $hairnumber = $this->input->get('hairnumber', true);
  8221. $type_leixi = $this->input->get('type', true);
  8222. $cpbz = $this->input->get('cpbz', true);
  8223. $sm = $this->input->get('sm', true);
  8224. $sid = $this->input->get('sid', true);
  8225. $ktime = $this->input->get('ktime', true);
  8226. $jtime = $this->input->get('jtime', true);
  8227. $ktime = strtotime($ktime);
  8228. $jtime = strtotime($jtime);
  8229. //$where = " 1=1 ";
  8230. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8231. $where = " sku != '' ";
  8232. $gj = "";
  8233. $ck = "";
  8234. if ($category) {
  8235. $where .= " and features like '%-$category-%'";
  8236. }
  8237. if ($size) {
  8238. $where .= " and features like '%-$size-%'";
  8239. }
  8240. if ($grade) {
  8241. $where .= " and features like '%-$grade-%'";
  8242. }
  8243. if ($color) {
  8244. $where .= " and features like '%-$color-%'";
  8245. }
  8246. if ($lowe) {
  8247. $where .= " and features like '%-$lowe-%'";
  8248. }
  8249. if ($warehouse) {
  8250. $where .= " and warehouse = '$warehouse'";
  8251. }
  8252. if ($purchase) {
  8253. $where .= " and purchase = '$purchase'";
  8254. }
  8255. if ($state) {
  8256. $where .= " and state = '$state'";
  8257. }
  8258. if ($lacetype) {
  8259. $where .= " and features like '%-$lacetype-%'";
  8260. }
  8261. if ($lacecolor) {
  8262. $where .= " and features like '%-$lacecolor-%'";
  8263. }
  8264. if ($density) {
  8265. $where .= " and features like '%-$density-%'";
  8266. }
  8267. if ($haircap) {
  8268. $where .= " and features like '%-$haircap-%'";
  8269. }
  8270. if ($details) {
  8271. $where .= " and details = '$details'";
  8272. }
  8273. if ($shop) {
  8274. $where .= " and shop like '%$shop%'";
  8275. }
  8276. if ($title) {
  8277. $title = trim($title, ' ');
  8278. $title = trim($title, ' ');
  8279. $where .= " and title like '%$title%'";
  8280. }
  8281. if (!empty($hairnumber)) {
  8282. $where .= " and features like '%-128-%' ";
  8283. if ($hairnumber < 0) {
  8284. $class_list = $this->typeclass->find_all('classid = 43');
  8285. foreach ($class_list as $v) {
  8286. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8287. }
  8288. } else {
  8289. $where .= " and features like '%-$hairnumber-%'";
  8290. }
  8291. }
  8292. if ($type_leixi) {
  8293. $where .= " and type = '$type_leixi'";
  8294. }
  8295. if ($cpbz) {
  8296. $where .= " and cpbz like '%$cpbz%' ";
  8297. }
  8298. if ($sm) {
  8299. $where .= " and sm like '%$sm%' ";
  8300. }
  8301. if ($sku) {
  8302. $sku = trim($sku, ' ');
  8303. $sku = trim($sku, ' ');
  8304. $where .= " and sku like '%$sku%'";
  8305. }
  8306. if ($ktime && $jtime) {
  8307. if ($type == 1) {
  8308. $tl = '出库';
  8309. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8310. } else if ($type == 2) {
  8311. $tl = '退库';
  8312. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8313. } else if ($type == 3) {
  8314. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8315. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8316. } else if ($type == 4) {
  8317. $tl = '出库+零售';
  8318. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8319. } else if ($type == 5) {
  8320. $tl = '零售';
  8321. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8322. }
  8323. }
  8324. $sidwhere = '';
  8325. if ($sid) {
  8326. $sd = "";
  8327. $s = explode(',', trim($sid, ','));
  8328. foreach ($s as $value) {
  8329. $sd .= " id = " . $value . " or";
  8330. }
  8331. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8332. }
  8333. //数据排序
  8334. $order_str = "time desc";
  8335. if (empty($page)) {
  8336. $start = 0;
  8337. $perpage = 1;
  8338. } else {
  8339. $start = ($page - 1) * $perpage;
  8340. }
  8341. //取得信息列表
  8342. if ($type != 3 && $type != 5) {
  8343. if ($type == 1 || $type == 4) {
  8344. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8345. foreach ($info_list as $key => $value) {
  8346. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8347. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8348. $warehouse = $this->warehouse->read($value['warehouse']);
  8349. $info_list[$key]['warehouse'] = $warehouse['title'];
  8350. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8351. $features = explode('-', trim($features, '-'));
  8352. $pm = $classid;
  8353. foreach ($features as $k => $v) {
  8354. if ($v != 0) {
  8355. if (!isset($typeclass[$v])) {
  8356. continue;
  8357. }
  8358. if (isset($pm[$typeclass[$v]['classid']])) {
  8359. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8360. $tz = explode('|', $typeclass[$v]['zh']);
  8361. $pm[$typeclass[$v]['classid']] = $tz[0];
  8362. } else {
  8363. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8364. }
  8365. }
  8366. }
  8367. }
  8368. $zh = implode(" ", $pm);
  8369. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8370. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8371. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8372. $info_list[$key]['features'] = $zh;
  8373. }
  8374. $final_list = [];
  8375. foreach($info_list as $k=>$v){
  8376. $number = "";
  8377. if(!empty($v['orderinfo'])){
  8378. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8379. if(!empty($tmp_info['number'])){
  8380. $number = $tmp_info['number'];
  8381. }
  8382. }
  8383. $final_list[] = [
  8384. 'warehouse'=>$v['warehouse'],
  8385. 'purchase'=>$v['purchase'],
  8386. 'sku'=>$v['sku'],
  8387. 'title'=>$v['title'],
  8388. 'features'=>$v['features'],
  8389. 'label'=>$v['label'],
  8390. 'orderinfo'=>$v['orderinfo'],
  8391. 'number'=>$number,
  8392. 'waybill'=>$v['waybill'],
  8393. 'outk'=>$v['outk'],
  8394. ];
  8395. }
  8396. } else {
  8397. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8398. foreach ($info_list as $key => $value) {
  8399. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8400. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8401. $warehouse = $this->warehouse->read($value['warehouse']);
  8402. $info_list[$key]['warehouse'] = $warehouse['title'];
  8403. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8404. $features = explode('-', trim($features, '-'));
  8405. $pm = $classid;
  8406. foreach ($features as $k => $v) {
  8407. if ($v != 0) {
  8408. if (!isset($typeclass[$v])) {
  8409. continue;
  8410. }
  8411. if (isset($pm[$typeclass[$v]['classid']])) {
  8412. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8413. $tz = explode('|', $typeclass[$v]['zh']);
  8414. $pm[$typeclass[$v]['classid']] = $tz[0];
  8415. } else {
  8416. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8417. }
  8418. }
  8419. }
  8420. }
  8421. $zh = implode(" ", $pm);
  8422. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8423. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8424. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8425. $info_list[$key]['features'] = $zh;
  8426. }
  8427. $final_list = [];
  8428. foreach($info_list as $k=>$v){
  8429. $number = "";
  8430. if(!empty($v['orderinfo'])){
  8431. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8432. if(!empty($tmp_info['number'])){
  8433. $number = $tmp_info['number'];
  8434. }
  8435. }
  8436. $final_list[] = [
  8437. 'warehouse'=>$v['warehouse'],
  8438. 'purchase'=>$v['purchase'],
  8439. 'sku'=>$v['sku'],
  8440. 'title'=>$v['title'],
  8441. 'features'=>$v['features'],
  8442. 'label'=>$v['label'],
  8443. 'orderinfo'=>$v['orderinfo'],
  8444. 'number'=>$number,
  8445. 'waybill'=>$v['waybill'],
  8446. 'retreat'=>$v['retreat'],
  8447. ];
  8448. }
  8449. }
  8450. if(empty($final_list)){
  8451. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8452. }else{
  8453. $end_list = [];
  8454. foreach($final_list as $v){
  8455. $end_list[] = array_values($v);
  8456. }
  8457. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8458. array_unshift($end_list,[
  8459. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8460. ]);
  8461. array_unshift($end_list,[
  8462. $title,"","","","","","","","",""
  8463. ]);
  8464. $merges = [
  8465. [
  8466. "s"=>["r"=>0,"c"=>0],
  8467. "e"=>["r"=>0,"c"=>9]
  8468. ]
  8469. ];
  8470. $cols = [
  8471. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8472. ];
  8473. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8474. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8475. ] )));
  8476. }
  8477. } else if ($type == 5) {
  8478. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8479. foreach ($info_list as $key => $value) {
  8480. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8481. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8482. $warehouse = $this->warehouse->read($value['warehouse']);
  8483. $info_list[$key]['warehouse'] = $warehouse['title'];
  8484. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8485. $features = explode('-', trim($features, '-'));
  8486. $pm = $classid;
  8487. foreach ($features as $k => $v) {
  8488. if ($v != 0) {
  8489. if (!isset($typeclass[$v])) {
  8490. continue;
  8491. }
  8492. if (isset($pm[$typeclass[$v]['classid']])) {
  8493. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8494. $tz = explode('|', $typeclass[$v]['zh']);
  8495. $pm[$typeclass[$v]['classid']] = $tz[0];
  8496. } else {
  8497. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8498. }
  8499. }
  8500. }
  8501. }
  8502. $zh = implode(" ", $pm);
  8503. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8504. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8505. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8506. $info_list[$key]['features'] = $zh;
  8507. }
  8508. if(empty($info_list)){
  8509. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8510. }else{
  8511. $final_list = [];
  8512. foreach($info_list as $v){
  8513. $final_list[] = array_values($v);
  8514. }
  8515. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8516. array_unshift($final_list,[
  8517. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8518. ]);
  8519. array_unshift($final_list,[
  8520. $title,"","","","","","",
  8521. ]);
  8522. $merges = [
  8523. [
  8524. "s"=>["r"=>0,"c"=>0],
  8525. "e"=>["r"=>0,"c"=>6]
  8526. ]
  8527. ];
  8528. $cols = [
  8529. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8530. ];
  8531. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8532. }
  8533. } else {
  8534. $wh = array();
  8535. $w = $this->warehouse->find_all('1=1', 'id,title');
  8536. foreach ($w as $v) {
  8537. $wh[$v['id']] = $v['title'];
  8538. }
  8539. $wt = array();
  8540. $whlabel_type = $this->whlabel_type->find_all();
  8541. foreach ($whlabel_type as $v) {
  8542. $wt[$v['id']] = $v['title'];
  8543. }
  8544. $classid = $this->classid->sku();
  8545. $list = array();
  8546. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8547. foreach ($rows as $key => $value) {
  8548. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8549. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8550. $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');
  8551. $details = array();
  8552. $cpid = array();
  8553. $cpbz = array();
  8554. $c = 0;
  8555. $g = 0;
  8556. $x = 0;
  8557. $t = 0;
  8558. $s = 0;
  8559. $q = 0;
  8560. foreach ($sd as $k => $v) {
  8561. if ($v['state'] == 0) {
  8562. $c++;
  8563. }
  8564. if ($v['state'] != 9) {
  8565. $g++;
  8566. }
  8567. if ($v['outk'] > 1) {
  8568. $x++;
  8569. }
  8570. if ($v['retreat'] > 0) {
  8571. $t++;
  8572. }
  8573. if ($v['state'] == 8) {
  8574. $s++;
  8575. }
  8576. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8577. $q++;
  8578. }
  8579. $details[$v['details']] = $v['details'];
  8580. if ($v['cpid'] != 0) {
  8581. $cpid[$v['cpid']] = $v['cpid'];
  8582. }
  8583. if ($v['cpbz'] != '') {
  8584. $cpbz[$v['cpbz']] = $v['cpbz'];
  8585. }
  8586. }
  8587. if (isset($wt[$value['type']])) {
  8588. $rows[$key]['type'] = $wt[$value['type']];
  8589. } else {
  8590. $rows[$key]['type'] = '未设置';
  8591. }
  8592. $rows[$key]['details'] = implode("、", $details);
  8593. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8594. $ftime = time() - 15 * 24 * 3600;
  8595. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8596. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8597. $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);
  8598. $rows[$key]['c'] = $c;
  8599. $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);
  8600. $rows[$key]['t'] = $t;
  8601. $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'] . '"');
  8602. $rows[$key]['z'] = $z;
  8603. // $jm = $classid;
  8604. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8605. $features = explode('-', trim($features, '-'));
  8606. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8607. }
  8608. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8609. $final_list =[];
  8610. foreach($tmp_list as $k=>$v){
  8611. $final_list[] = [
  8612. "warehouse"=>$v['warehouse'],
  8613. "purchase"=>$v['purchase'],
  8614. "details"=>$v['details'],
  8615. "cpid"=>$v['cpid'],
  8616. "sku"=>$v['sku'],
  8617. "title"=>$v['title'],
  8618. "features"=>$v['pm'],
  8619. "cpbz"=>$v['cpbz'],
  8620. "sm"=>$v['sm'],
  8621. "type"=>$v['type'],
  8622. "g"=>$v["g"],
  8623. "c"=>$v["c"],
  8624. "x"=>$v["x"],
  8625. "t"=>$v["t"],
  8626. "z"=>$v["z"],
  8627. "jm"=>$v["jm"],
  8628. "weight"=>$v["weight"],
  8629. "asd"=>$v["asd"],
  8630. ];
  8631. }
  8632. if(empty($final_list)){
  8633. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8634. }else{
  8635. $end_list = [];
  8636. foreach($final_list as $v){
  8637. $end_list[] = array_values($v);
  8638. }
  8639. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8640. array_unshift($end_list,[
  8641. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8642. ]);
  8643. array_unshift($end_list,[
  8644. $title,"","","","","","","","","","","","","","","","","",""
  8645. ]);
  8646. $merges = [
  8647. [
  8648. "s"=>["r"=>0,"c"=>0],
  8649. "e"=>["r"=>0,"c"=>6]
  8650. ]
  8651. ];
  8652. $cols = [
  8653. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8654. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8655. ];
  8656. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8657. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8658. ])));
  8659. }
  8660. }
  8661. }
  8662. }
  8663. public function _exceljxcjs(){
  8664. $classid = $this->classid->sku();
  8665. $pm = $classid;
  8666. $typeclass = array();
  8667. $tc = $this->typeclass->find_all();
  8668. foreach ($tc as $v) {
  8669. $typeclass[$v['id']] = $v;
  8670. }
  8671. $prc = array();
  8672. $purchase = $this->purchase->find_all();
  8673. foreach ($purchase as $k => $v) {
  8674. $prc[$v['id']] = $v['title'];
  8675. }
  8676. if(!isset($_GET['excel'])){
  8677. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8678. }
  8679. $where = "sku != 'Preset'";
  8680. //数据排序
  8681. $order_str = "id desc";
  8682. if (empty($page)) {
  8683. $start = 0;
  8684. $perpage = 1;
  8685. } else {
  8686. $start = ($page - 1) * $perpage;
  8687. }
  8688. $category = $this->input->get('category', true);
  8689. $warehouse = $this->input->get('warehouse', true);
  8690. $excelid = $this->input->get('sid', true);
  8691. if ($category) {
  8692. $where .= " and features like '%-$category-%'";
  8693. }
  8694. if ($warehouse) {
  8695. $where .= " and warehouse = '$warehouse'";
  8696. }
  8697. $xzid = '';
  8698. if ($excelid) {
  8699. $excelid = explode(',', trim($excelid, ','));
  8700. foreach ($excelid as $key => $value) {
  8701. $xzid .= " id = " . $value . " or";
  8702. }
  8703. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8704. }
  8705. $wt = array();
  8706. $whlabel_type = $this->whlabel_type->find_all();
  8707. foreach ($whlabel_type as $v) {
  8708. $wt[$v['id']] = $v['title'];
  8709. }
  8710. $wh = array();
  8711. $w = $this->warehouse->find_all('1=1', 'id,title');
  8712. foreach ($w as $v) {
  8713. $wh[$v['id']] = $v['title'];
  8714. }
  8715. $list = array();
  8716. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8717. foreach ($rows as $key => $value) {
  8718. if (isset($wt[$value['type']])) {
  8719. $rows[$key]['type'] = $wt[$value['type']];
  8720. } else {
  8721. $rows[$key]['type'] = '未设置';
  8722. }
  8723. $bm = '03';
  8724. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8725. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8726. $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');
  8727. $details = array();
  8728. $cpid = array();
  8729. $cpbz = array();
  8730. $c = 0;
  8731. $g = 0;
  8732. $x = 0;
  8733. $t = 0;
  8734. $s = 0;
  8735. $q = 0;
  8736. foreach ($sd as $k => $v) {
  8737. if ($v['state'] == 0) {
  8738. $c++;
  8739. if ($v['cpid'] != 0) {
  8740. $cpid[$v['cpid']] = $v['cpid'];
  8741. }
  8742. if ($v['cpbz'] != '') {
  8743. $cpbz[$v['cpbz']] = $v['cpbz'];
  8744. }
  8745. }
  8746. if ($v['state'] != 9) {
  8747. $g++;
  8748. }
  8749. if ($v['state'] == 1) {
  8750. $x++;
  8751. }
  8752. if ($v['state'] == 2) {
  8753. $t++;
  8754. }
  8755. if ($v['state'] == 8) {
  8756. $s++;
  8757. }
  8758. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8759. $q++;
  8760. }
  8761. $details[$v['details']] = $v['details'];
  8762. }
  8763. $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'] . '"');
  8764. $rows[$key]['details'] = implode("、", $details);
  8765. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8766. $number = $value['number'];
  8767. $ftime = time() - 15 * 24 * 3600;
  8768. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8769. $rows[$key]['number'] = $g;
  8770. $rows[$key]['c'] = $c;
  8771. $rows[$key]['x'] = $x;
  8772. $rows[$key]['t'] = $t;
  8773. $rows[$key]['s'] = $s;
  8774. $rows[$key]['q'] = $q;
  8775. $rows[$key]['z'] = $z;
  8776. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8777. $features = explode('-', trim($features, '-'));
  8778. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8779. }
  8780. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8781. $final_list = [];
  8782. foreach ($list as $k => $v) {
  8783. if (empty($v['sku'])) {
  8784. continue;
  8785. }
  8786. $final_list[] = [
  8787. $v["warehouse"],
  8788. $v["purchase"],
  8789. $v["details"],
  8790. $v["cpid"],
  8791. $v["dbcontent"],
  8792. $v["sku"],
  8793. $v["bm"],
  8794. $v["jm"],
  8795. $v["title"],
  8796. $v["pm"],
  8797. $v["cpbz"],
  8798. $v["sm"],
  8799. $v["type"],
  8800. $v["number"],
  8801. $v["c"],
  8802. $v["x"],
  8803. $v["t"],
  8804. $v["s"],
  8805. $v["q"],
  8806. $v["z"],
  8807. $v['weight'],
  8808. ];
  8809. }
  8810. if(empty($final_list)){
  8811. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8812. }
  8813. $title = "总进销存统计表";
  8814. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8815. $merges = [
  8816. [
  8817. "s"=>["r"=>0,"c"=>0],
  8818. "e"=>["r"=>0,"c"=>21]
  8819. ]
  8820. ];
  8821. $cols = [
  8822. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8823. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8824. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8825. ];
  8826. array_unshift($final_list, $first_row);
  8827. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8828. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8829. }
  8830. public function _summaryjs($arg_array)
  8831. {
  8832. $prc = array();
  8833. $purchase = $this->purchase->find_all();
  8834. foreach ($purchase as $k => $v) {
  8835. $prc[$v['id']] = $v['title'];
  8836. }
  8837. if (isset($_GET['excel'])) {
  8838. $ktime = $this->input->get('ktime', true);
  8839. $jtime = $this->input->get('jtime', true);
  8840. $ktime = strtotime($ktime);
  8841. $jtime = strtotime($jtime);
  8842. $where = "1=1";
  8843. if ($ktime && $jtime) {
  8844. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8845. }
  8846. //数据排序
  8847. $order_str = "time desc";
  8848. if (empty($page)) {
  8849. $start = 0;
  8850. $perpage = 1;
  8851. } else {
  8852. $start = ($page - 1) * $perpage;
  8853. }
  8854. //取得信息列表
  8855. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8856. foreach ($info_list as $key => $value) {
  8857. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8858. $warehouse = $this->warehouse->read($value['warehouse']);
  8859. $info_list[$key]['warehouse'] = $warehouse['title'];
  8860. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8861. $details = array();
  8862. $cpid = array();
  8863. foreach ($x as $k => $v) {
  8864. if ($v['details'] != '') {
  8865. $details[$v['details']] = $v['details'];
  8866. }
  8867. if ($v['cpid'] != 0) {
  8868. $cpid[$v['cpid']] = $v['cpid'];
  8869. }
  8870. }
  8871. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8872. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8873. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8874. $info_list[$key]['s'] = $s;
  8875. $info_list[$key]['x'] = count($x);
  8876. }
  8877. if(empty($info_list)){
  8878. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8879. }
  8880. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8881. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8882. $merges = [
  8883. [
  8884. "s"=>["r"=>0,"c"=>0],
  8885. "e"=>["r"=>0,"c"=>7]
  8886. ]
  8887. ];
  8888. $cols = [
  8889. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8890. ];
  8891. $final_list = [];
  8892. foreach($info_list as $k => $v){
  8893. $final_list[] = array_values($v);
  8894. }
  8895. array_unshift($final_list, $first_row);
  8896. array_unshift($final_list,[
  8897. $title,"","","","","","","","",
  8898. ]);
  8899. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8900. $titlename = "<table border=1>
  8901. <tr align='center'>
  8902. <td>仓库</td>
  8903. <td>供应商</td>
  8904. <td>出库位置</td>
  8905. <td>出库编码</td>
  8906. <td>SKU</td>
  8907. <td>产品名</td>
  8908. <td>总剩余库存</td>
  8909. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8910. </tr>
  8911. </table>";
  8912. $filename = $title . ".xls";
  8913. $tail = "";
  8914. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8915. }
  8916. }
  8917. public function _uckjs()
  8918. {
  8919. if (isset($_GET['excel'])) {
  8920. $tc = array();
  8921. $typeclass = $this->typeclass->find_all();
  8922. foreach ($typeclass as $v) {
  8923. $tc[$v['id']] = $v['zh'];
  8924. }
  8925. $first_row = [
  8926. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8927. ];
  8928. $t = array();
  8929. $rq = '';
  8930. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8931. $ts = $ts / (24 * 3600);
  8932. for ($i = 0; $i < $ts; $i++) {
  8933. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8934. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8935. }
  8936. $day_len = count($t);
  8937. $first_row[] = "本月出库";
  8938. $merges = [
  8939. ];
  8940. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8941. $excel_key = 1;
  8942. $final_list = [];
  8943. foreach ($info_list as $k => $v) {
  8944. $features = explode('-', trim($v['features'], '-'));
  8945. if (!isset($features[3]) || !isset($features[4])) {
  8946. continue;
  8947. }
  8948. $tmp = [];
  8949. $tmp[0] = $tc[$features[0]]; //类型
  8950. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8951. $tmp[2] = $tc[$features[4]]; //曲度
  8952. $tmp[3] = '';
  8953. if (isset($data[$k][1])) {
  8954. $tmp[3] .=$tmp[1];
  8955. }
  8956. if (isset($data[$k][2])) {
  8957. $tmp[3] .= $tmp[2];
  8958. }
  8959. if (isset($features[5])) {
  8960. $tmp[3] .= $tc[$features[5]];
  8961. }
  8962. if (isset($features[2])) {
  8963. $tmp[3] .= $tc[$features[2]];
  8964. }
  8965. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8966. $tmp[4] = $v['sku'];
  8967. $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())) . '))'); //月初库存
  8968. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8969. $tmp[7] ="";
  8970. $tmp[8] ="";
  8971. $byck = 0;
  8972. foreach ($t as $vv) {
  8973. $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));
  8974. $tmp[] = ($sl > 0) ? $sl : '';
  8975. $byck += $sl;
  8976. }
  8977. $tmp[] = ($byck > 0) ? $byck : '';
  8978. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8979. // $ztrq = '';
  8980. // $ztsl = '';
  8981. // if (count($zt) > 0) {
  8982. // foreach ($zt as $vv) {
  8983. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8984. // $ztsl .= $vv['num'] . '<br>';
  8985. // }
  8986. // }
  8987. if(empty($zt)){
  8988. $final_list[] = $tmp;
  8989. $excel_key = $excel_key + 1;
  8990. }else{
  8991. $len = count($zt);
  8992. if($len == 1){
  8993. $tmp[7] = $zt[0]['num'] ;
  8994. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8995. $final_list[] = $tmp;
  8996. $excel_key = $excel_key + 1;
  8997. }else{
  8998. foreach($zt as $vv){
  8999. $tmp[7] = "";
  9000. $tmp[8] = "";
  9001. $tmp[7] = $vv['num'];
  9002. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9003. $final_list[] = $tmp;
  9004. }
  9005. $merges[] = [
  9006. "s"=>["r"=>$excel_key,"c"=>0],
  9007. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9008. ];
  9009. $merges[] = [
  9010. "s"=>["r"=>$excel_key,"c"=>1],
  9011. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9012. ];
  9013. $merges[] = [
  9014. "s"=>["r"=>$excel_key,"c"=>2],
  9015. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9016. ];
  9017. $merges[] = [
  9018. "s"=>["r"=>$excel_key,"c"=>3],
  9019. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9020. ];
  9021. $merges[] = [
  9022. "s"=>["r"=>$excel_key,"c"=>4],
  9023. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9024. ];
  9025. $merges[] = [
  9026. "s"=>["r"=>$excel_key,"c"=>5],
  9027. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9028. ];
  9029. $merges[] = [
  9030. "s"=>["r"=>$excel_key,"c"=>6],
  9031. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9032. ];
  9033. for($i=1;$i<=$day_len;$i++){
  9034. $merges[] = [
  9035. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9036. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9037. ];
  9038. }
  9039. $merges[] = [
  9040. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9041. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9042. ];
  9043. $excel_key = $excel_key + $len;
  9044. }
  9045. }
  9046. }
  9047. $title = "详情 " . date("Y-m-d", time());
  9048. if(empty($final_list)){
  9049. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9050. }
  9051. $cols = [
  9052. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9053. ];
  9054. array_unshift($final_list, $first_row);
  9055. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9056. }
  9057. }
  9058. public function _whlabelexcelzhjs(){
  9059. if(empty($_GET['excel'])){
  9060. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9061. }
  9062. $where = "sku != 'Preset' and sku != '' ";
  9063. //数据排序
  9064. $order_str = "id desc";
  9065. if (empty($page)) {
  9066. $start = 0;
  9067. $perpage = 1;
  9068. } else {
  9069. $start = ($page - 1) * $perpage;
  9070. }
  9071. $category = $this->input->get('category', true);
  9072. $warehouse = $this->input->get('warehouse', true);
  9073. $excelid = $this->input->get('sid', true);
  9074. if ($category) {
  9075. $where .= " and features like '%-$category-%'";
  9076. }
  9077. if ($warehouse) {
  9078. $where .= " and warehouse = '$warehouse'";
  9079. }
  9080. $xzid = '';
  9081. if ($excelid) {
  9082. $excelid = explode(',', trim($excelid, ','));
  9083. foreach ($excelid as $key => $value) {
  9084. $xzid .= " id = " . $value . " or";
  9085. }
  9086. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9087. }
  9088. $merges = [
  9089. [
  9090. "s"=>["r"=>0,"c"=>0],
  9091. "e"=>["r"=>0,"c"=>6]
  9092. ]
  9093. ];
  9094. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9095. $excel_index = 2;
  9096. $final_list = [];
  9097. foreach ($rows as $key => $value) {
  9098. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9099. $zh = '';
  9100. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9101. // foreach ($zt_list as $v) {
  9102. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9103. // }
  9104. $zt = array_sum(array_column($zt_list, 'num'));
  9105. $number = $value['number'];
  9106. $ftime = time() - 15 * 24 * 3600;
  9107. $warehouse = $this->warehouse->read($value['warehouse']);
  9108. // $rows[$key]['warehouse'] = $warehouse['title'];
  9109. // $rows[$key]['number'] = $c;
  9110. // $rows[$key]['features'] = $zh;
  9111. //$rows[$key]['hb'] = $c + $zt;
  9112. $tmp = [];
  9113. $tmp[0] = $warehouse['title'];
  9114. $tmp[1] = $value['sku'];
  9115. $tmp[2] = $value['title'];
  9116. $tmp[3] = $c;
  9117. $tmp[4] = "";
  9118. $tmp[5] = $c + $zt;
  9119. if(empty($zt_list)){
  9120. $tmp[4] = "";
  9121. $final_list[] = $tmp;
  9122. $excel_index = $excel_index + 1;
  9123. }else{
  9124. if(count($zt_list) == 1){
  9125. $tmp[4] = "";
  9126. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9127. $final_list[] = $tmp;
  9128. $excel_index = $excel_index + 1;
  9129. }else{
  9130. $len = count($zt_list);
  9131. foreach ($zt_list as $v){
  9132. $tmp[4] = "";
  9133. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9134. $final_list[] = $tmp;
  9135. }
  9136. $merges[] = [
  9137. "s"=>["r"=>$excel_index,"c"=>0],
  9138. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9139. ];
  9140. $merges[] = [
  9141. "s"=>["r"=>$excel_index,"c"=>1],
  9142. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9143. ];
  9144. $merges[] = [
  9145. "s"=>["r"=>$excel_index,"c"=>2],
  9146. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9147. ];
  9148. $merges[] = [
  9149. "s"=>["r"=>$excel_index,"c"=>3],
  9150. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9151. ];
  9152. $merges[] = [
  9153. "s"=>["r"=>$excel_index,"c"=>5],
  9154. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9155. ];
  9156. $excel_index = $excel_index + $len;
  9157. }
  9158. }
  9159. }
  9160. $first_row = [
  9161. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9162. ];
  9163. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9164. if(empty($final_list)){
  9165. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9166. }
  9167. $cols = [
  9168. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9169. ];
  9170. array_unshift($final_list, $first_row);
  9171. array_unshift($final_list, [
  9172. $title,"","","","",""
  9173. ]);
  9174. $end_list = [];
  9175. foreach ($final_list as $key => $value) {
  9176. $end_list[] = array_values($value);
  9177. }
  9178. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9179. }
  9180. //出库、退库导出
  9181. public function _dccrtypejs()
  9182. {
  9183. $classid = $this->classid->sku();
  9184. $pm = $classid;
  9185. $typeclass = array();
  9186. $tc = $this->typeclass->find_all();
  9187. foreach ($tc as $v) {
  9188. $typeclass[$v['id']] = $v;
  9189. }
  9190. $prc = array();
  9191. $purchase = $this->purchase->find_all();
  9192. foreach ($purchase as $k => $v) {
  9193. $prc[$v['id']] = $v['title'];
  9194. }
  9195. if (isset($_GET['sid'])) {
  9196. $wh = array();
  9197. $w = $this->warehouse->find_all('1=1', 'id,title');
  9198. foreach ($w as $v) {
  9199. $wh[$v['id']] = $v['title'];
  9200. }
  9201. $type = $this->input->get('excel', true);
  9202. $category = $this->input->get('category', true);
  9203. $size = $this->input->get('size', true);
  9204. $grade = $this->input->get('grade', true);
  9205. $color = $this->input->get('color', true);
  9206. $lowe = $this->input->get('lowe', true);
  9207. $sku = $this->input->get('sku', true);
  9208. $warehouse = $this->input->get('warehouse', true);
  9209. $lacetype = $this->input->get('lacetype', true);
  9210. $lacecolor = $this->input->get('lacecolor', true);
  9211. $density = $this->input->get('density', true);
  9212. $haircap = $this->input->get('haircap', true);
  9213. $purchase = $this->input->get('purchase', true);
  9214. $title = $this->input->get('title', true);
  9215. $state = $this->input->get('state', true);
  9216. $sid = $this->input->get('sid', true);
  9217. $ktime = $this->input->get('ktime', true);
  9218. $jtime = $this->input->get('jtime', true);
  9219. $ktime = strtotime($ktime);
  9220. $jtime = strtotime($jtime);
  9221. $where = "1=1";
  9222. $gj = "";
  9223. $ck = "";
  9224. if ($category) {
  9225. $where .= " and features like '%-$category-%'";
  9226. }
  9227. if ($size) {
  9228. $where .= " and features like '%-$size-%'";
  9229. }
  9230. if ($grade) {
  9231. $where .= " and features like '%-$grade-%'";
  9232. }
  9233. if ($color) {
  9234. $where .= " and features like '%-$color-%'";
  9235. }
  9236. if ($lowe) {
  9237. $where .= " and features like '%-$lowe-%'";
  9238. }
  9239. if ($warehouse) {
  9240. $where .= " and warehouse = '$warehouse'";
  9241. }
  9242. if ($purchase) {
  9243. $where .= " and purchase = '$purchase'";
  9244. }
  9245. if ($state) {
  9246. $where .= " and state = '$state'";
  9247. }
  9248. if ($lacetype) {
  9249. $where .= " and features like '%-$lacetype-%'";
  9250. }
  9251. if ($lacecolor) {
  9252. $where .= " and features like '%-$lacecolor-%'";
  9253. }
  9254. if ($density) {
  9255. $where .= " and features like '%-$density-%'";
  9256. }
  9257. if ($haircap) {
  9258. $where .= " and features like '%-$haircap-%'";
  9259. }
  9260. if ($title) {
  9261. $title = trim($title, ' ');
  9262. $title = trim($title, ' ');
  9263. $where .= " and title like '%$title%'";
  9264. }
  9265. if ($sku) {
  9266. $sku = trim($sku, ' ');
  9267. $sku = trim($sku, ' ');
  9268. $where .= " and sku like '%$sku%'";
  9269. }
  9270. if ($ktime && $jtime) {
  9271. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9272. }
  9273. $sidwhere = '';
  9274. if ($sid) {
  9275. $sd = "";
  9276. $s = explode(',', trim($sid, ','));
  9277. foreach ($s as $value) {
  9278. $sd .= " id = " . $value . " or";
  9279. }
  9280. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9281. }
  9282. //数据排序
  9283. $order_str = "time desc";
  9284. if (empty($page)) {
  9285. $start = 0;
  9286. $perpage = 1;
  9287. } else {
  9288. $start = ($page - 1) * $perpage;
  9289. }
  9290. $wh = array();
  9291. $w = $this->warehouse->find_all('1=1', 'id,title');
  9292. foreach ($w as $v) {
  9293. $wh[$v['id']] = $v['title'];
  9294. }
  9295. $wt = array();
  9296. $whlabel_type = $this->whlabel_type->find_all();
  9297. foreach ($whlabel_type as $v) {
  9298. $wt[$v['id']] = $v['title'];
  9299. }
  9300. $classid = $this->classid->sku();
  9301. $list = array();
  9302. $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');
  9303. foreach ($rows_r as $key => $value) {
  9304. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9305. $pm = $classid;
  9306. $jm = $classid;
  9307. $rows_r[$key]['enter'] = '入库';
  9308. $rows_r[$key]['time'] = $value['enter'];
  9309. if ($value['rktype'] == 1) {
  9310. $rows_r[$key]['rktype'] = '采购入库';
  9311. } else if ($value['rktype'] == 2) {
  9312. $rows_r[$key]['rktype'] = '盘盈调整';
  9313. } else if ($value['rktype'] == 3) {
  9314. $rows_r[$key]['rktype'] = '其他调整入库';
  9315. } else if ($value['rktype'] == 4) {
  9316. $rows_r[$key]['rktype'] = '其他调整入库';
  9317. } else if ($value['rktype'] == 5) {
  9318. $rows_r[$key]['rktype'] = '退库入库';
  9319. } else if ($value['rktype'] == 6) {
  9320. $rows_r[$key]['rktype'] = '退货可用入库';
  9321. } else if ($value['rktype'] == 7) {
  9322. $rows_r[$key]['rktype'] = '形态转换入库';
  9323. } else {
  9324. $rows_r[$key]['rktype'] = '';
  9325. }
  9326. $features = explode('-', trim($value['features'], '-'));
  9327. foreach ($features as $v) {
  9328. if (isset($typeclass[$v])) {
  9329. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9330. $pm[$typeclass[$v]['classid']] = $zh[0];
  9331. }
  9332. if (isset($typeclass[$v])) {
  9333. if (isset($jm[$typeclass[$v]['classid']])) {
  9334. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9335. }
  9336. }
  9337. }
  9338. $zh = implode(" ", $pm);
  9339. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9340. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9341. $rows_r[$key]['zh'] = $zh;
  9342. $jm = array_filter($jm);
  9343. $rows_r[$key]['features'] = implode("-", $jm);
  9344. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9345. }
  9346. $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');
  9347. foreach ($rows_c as $key => $value) {
  9348. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9349. $pm = $classid;
  9350. $jm = $classid;
  9351. $rows_c[$key]['time'] = $value['outk'];
  9352. $rows_c[$key]['outk'] = '出库';
  9353. if ($value['cktype'] == 1) {
  9354. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9355. } else if ($value['cktype'] == 2) {
  9356. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9357. } else if ($value['cktype'] == 3) {
  9358. $rows_c[$key]['cktype'] = '盘亏调整';
  9359. } else if ($value['cktype'] == 4) {
  9360. $rows_c[$key]['cktype'] = '其他调整出库';
  9361. } else if ($value['cktype'] == 5) {
  9362. $rows_c[$key]['cktype'] = '形态转换出库';
  9363. } else {
  9364. $rows_c[$key]['cktype'] = '';
  9365. }
  9366. unset($rows_c[$key]['state']);
  9367. $features = explode('-', trim($value['features'], '-'));
  9368. foreach ($features as $v) {
  9369. if (isset($typeclass[$v])) {
  9370. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9371. $pm[$typeclass[$v]['classid']] = $zh[0];
  9372. }
  9373. if (isset($typeclass[$v])) {
  9374. if (isset($jm[$typeclass[$v]['classid']])) {
  9375. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9376. }
  9377. }
  9378. }
  9379. $zh = implode(" ", $pm);
  9380. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9381. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9382. $rows_c[$key]['zh'] = $zh;
  9383. $jm = array_filter($jm);
  9384. $rows_c[$key]['features'] = implode("-", $jm);
  9385. $rows_c[$key]['number'] = 1;
  9386. }
  9387. $merged = $rows_r;
  9388. foreach ($rows_c as $key => $value) {
  9389. if (isset($merged[$key])) {
  9390. $merged[] = $value;
  9391. } else {
  9392. $merged[$key] = $value;
  9393. }
  9394. }
  9395. usort($merged, function ($a, $b) {
  9396. return $a['time'] - $b['time'];
  9397. });
  9398. foreach ($merged as $key => $value) {
  9399. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9400. }
  9401. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9402. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9403. $cols = [
  9404. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9405. ];
  9406. $final_list= [];
  9407. foreach($merged as $key => $value){
  9408. $final_list[] = array_values($value) ;
  9409. }
  9410. if(empty($merged)){
  9411. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9412. }
  9413. array_unshift($final_list, $first_row);
  9414. $end_list = [];
  9415. foreach ($final_list as $key => $value) {
  9416. $end_list[] = array_values($value);
  9417. }
  9418. $merges = [];
  9419. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9420. }
  9421. }
  9422. public function _errorexceljs()
  9423. {
  9424. $post = $this->input->post(NULL, TRUE);
  9425. if (isset($_GET['page'])) {
  9426. $page = $this->input->get('page', true);
  9427. $perpage = $this->input->get('perpage', true);
  9428. $sku = $this->input->get('sku', true);
  9429. $warehouse = $this->input->get('warehouse', true);
  9430. $ktime = $this->input->get('ktime', true);
  9431. $jtime = $this->input->get('jtime', true);
  9432. $ktime = strtotime($ktime);
  9433. $jtime = strtotime($jtime);
  9434. $where = "sku != 'Preset'";
  9435. $gj = '';
  9436. if ($sku) {
  9437. $where .= " and sku like '%$sku%'";
  9438. } else {
  9439. if ($ktime && $jtime) {
  9440. $gj = " and time > '$ktime' and time < '$jtime'";
  9441. }
  9442. }
  9443. if ($warehouse) {
  9444. $where .= " and warehouse = '$warehouse'";
  9445. }
  9446. //数据排序
  9447. $order_str = "id desc";
  9448. if (empty($page)) {
  9449. $start = 0;
  9450. $perpage = 1;
  9451. } else {
  9452. $start = ($page - 1) * $perpage;
  9453. }
  9454. //取得信息列表
  9455. $rows = array();
  9456. $list = array();
  9457. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9458. foreach ($info_list as $value) {
  9459. $warehouse = $this->warehouse->read($value['warehouse']);
  9460. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9461. $number = $value['number'];
  9462. $ftime = time() - 15 * 24 * 3600;
  9463. if ($c < 1) {
  9464. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9465. }
  9466. }
  9467. $title = "0库存汇总";
  9468. $first_row = ["仓库","SKU","产品","当前库存"];
  9469. $cols = [
  9470. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9471. ];
  9472. $final_list= [];
  9473. foreach($list as $key => $value){
  9474. $final_list[] = array_values($value) ;
  9475. }
  9476. if(empty($final_list)){
  9477. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9478. }
  9479. array_unshift($final_list, $first_row);
  9480. $merges = [];
  9481. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9482. }
  9483. }
  9484. }