Whlabel.php 331 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804
  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['cpid'] != 0) {
  4458. $cpid[$v['cpid']] = $v['cpid'];
  4459. }
  4460. if ($v['cpbz'] != '') {
  4461. $cpbz[$v['cpbz']] = $v['cpbz'];
  4462. }
  4463. }
  4464. if (isset($wt[$value['type']])) {
  4465. $rows[$key]['type'] = $wt[$value['type']];
  4466. } else {
  4467. $rows[$key]['type'] = '未设置';
  4468. }
  4469. $rows[$key]['details'] = implode("、", $details);
  4470. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4471. $ftime = time() - 15 * 24 * 3600;
  4472. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4473. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4474. $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);
  4475. $rows[$key]['c'] = $c;
  4476. $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);
  4477. $rows[$key]['t'] = $t;
  4478. $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'] . '"');
  4479. $rows[$key]['z'] = $z;
  4480. // $jm = $classid;
  4481. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4482. $features = explode('-', trim($features, '-'));
  4483. // $pm = $classid;
  4484. // foreach ($features as $k => $v) {
  4485. // if ($v != 0) {
  4486. // if (!isset($typeclass[$v])) {
  4487. // continue;
  4488. // }
  4489. // if (isset($pm[$typeclass[$v]['classid']])) {
  4490. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4491. // $tz = explode('|', $typeclass[$v]['zh']);
  4492. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4493. // } else {
  4494. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4495. // }
  4496. // if (isset($jm[$typeclass[$v]['classid']])) {
  4497. // if ($typeclass[$v]['jm']) {
  4498. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4499. // }
  4500. // }
  4501. // }
  4502. // }
  4503. // }
  4504. // $zh = implode(" ", $pm);
  4505. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4506. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4507. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4508. // $rows[$key]['features'] = $zh;
  4509. // $jm = array_filter($jm); //去除空值
  4510. // $jm = implode("-", $jm);
  4511. // $rows[$key]['jm'] = $jm;
  4512. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4513. }
  4514. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4515. // echo "<pre>";
  4516. // print_r($tmp_list);
  4517. // die;
  4518. $final_list =[];
  4519. foreach($tmp_list as $k=>$v){
  4520. $final_list[] = [
  4521. "warehouse"=>$v['warehouse'],
  4522. "purchase"=>$v['purchase'],
  4523. "details"=>trim($v['details'],'、'),
  4524. "cpid"=>$v['cpid'],
  4525. "sku"=>$v['sku'],
  4526. "title"=>$v['title'],
  4527. "features"=>$v['pm'],
  4528. "cpbz"=>$v['cpbz'],
  4529. "sm"=>$v['sm'],
  4530. "type"=>$v['type'],
  4531. "g"=>$v["g"],
  4532. "c"=>$v["c"],
  4533. "x"=>$v["x"],
  4534. "t"=>$v["t"],
  4535. "z"=>$v["z"],
  4536. "jm"=>$v["jm"],
  4537. "weight"=>$v["weight"],
  4538. "asd"=>$v["asd"],
  4539. ];
  4540. }
  4541. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4542. $titlename = "<table border=1>
  4543. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4544. <tr align='center'>
  4545. <td>仓库</td>
  4546. <td>供应商</td>
  4547. <td>位置</td>
  4548. <td>库存编码</td>
  4549. <td>SKU</td>
  4550. <td>商品名称</td>
  4551. <td>商品中文</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. </tr>
  4564. </table>";
  4565. $filename = $title . ".xls";
  4566. $tail = "";
  4567. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4568. }
  4569. }
  4570. }
  4571. //出库+入库数据整合
  4572. public function _excelcr()
  4573. {
  4574. if (isset($_GET['excel'])) {
  4575. $type = $this->input->get('excel', true);
  4576. $category = $this->input->get('category', true);
  4577. $size = $this->input->get('size', true);
  4578. $grade = $this->input->get('grade', true);
  4579. $color = $this->input->get('color', true);
  4580. $lowe = $this->input->get('lowe', true);
  4581. $sku = $this->input->get('sku', true);
  4582. $warehouse = $this->input->get('warehouse', true);
  4583. $purchase = $this->input->get('purchase', true);
  4584. $state = $this->input->get('state', true);
  4585. $sid = $this->input->get('sid', true);
  4586. $ktime = $this->input->get('ktime', true);
  4587. $jtime = $this->input->get('jtime', true);
  4588. $ktime = strtotime($ktime);
  4589. $jtime = strtotime($jtime);
  4590. $where = "1=1";
  4591. $gj = "";
  4592. $ck = "";
  4593. if ($category) {
  4594. $where .= " and features like '%-$category-%'";
  4595. }
  4596. if ($size) {
  4597. $where .= " and features like '%-$size-%'";
  4598. }
  4599. if ($grade) {
  4600. $where .= " and features like '%-$grade-%'";
  4601. }
  4602. if ($color) {
  4603. $where .= " and features like '%-$color-%'";
  4604. }
  4605. if ($lowe) {
  4606. $where .= " and features like '%-$lowe-%'";
  4607. }
  4608. if ($warehouse) {
  4609. $where .= " and warehouse = '$warehouse'";
  4610. }
  4611. if ($purchase) {
  4612. $where .= " and purchase = '$purchase'";
  4613. }
  4614. if ($state) {
  4615. $where .= " and state = '$state'";
  4616. }
  4617. if ($sku) {
  4618. $where .= " and sku like '%$sku%'";
  4619. }
  4620. if ($ktime && $jtime) {
  4621. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4622. }
  4623. $sidwhere = '';
  4624. if ($sid) {
  4625. $sd = "";
  4626. $s = explode(',', trim($sid, ','));
  4627. foreach ($s as $value) {
  4628. $sd .= " id = " . $value . " or";
  4629. }
  4630. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4631. }
  4632. //取得信息列表
  4633. $timeread = $ktime;
  4634. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4635. $timelist = array();
  4636. for ($i = 0; $i < $timenum; $i++) {
  4637. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4638. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4639. }
  4640. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4641. //echo "<pre>";
  4642. //print_r($info_list);
  4643. //exit();
  4644. $rows = array();
  4645. $list = array();
  4646. foreach ($info_list as $key => $value) {
  4647. $thistime = $timelist;
  4648. if (isset($rows[strtolower($value['sku'])])) {
  4649. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4650. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4651. }
  4652. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4653. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4654. }
  4655. } else {
  4656. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4657. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4658. }
  4659. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4660. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4661. }
  4662. $rows[strtolower($value['sku'])] = $thistime;
  4663. }
  4664. }
  4665. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4666. <head>
  4667. <!--[if gte mso 9]><xml>
  4668. <x:ExcelWorkbook>
  4669. <x:ExcelWorksheets>
  4670. <x:ExcelWorksheet>
  4671. <x:Name>EXCEL</x:Name>
  4672. <x:WorksheetOptions>
  4673. <x:Print>
  4674. <x:ValidPrinterInfo />
  4675. </x:Print>
  4676. </x:WorksheetOptions>
  4677. </x:ExcelWorksheet>
  4678. </x:ExcelWorksheets>
  4679. </x:ExcelWorkbook>
  4680. </xml>
  4681. <![endif]-->
  4682. </head><body>";
  4683. $str .= "<table border=1><tr><td>SKU</td>";
  4684. foreach ($timelist as $k => $v) {
  4685. $str .= "<td>" . $k . "出库</td>";
  4686. $str .= "<td>" . $k . "入库</td>";
  4687. }
  4688. $str .= "</tr></table>";
  4689. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4690. foreach ($rows as $key => $val) {
  4691. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4692. foreach ($val as $k => $v) {
  4693. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4694. if ($val[$k]['r'] > 0) {
  4695. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4696. } else {
  4697. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4698. }
  4699. }
  4700. $str .= "</tr>";
  4701. }
  4702. $str .= "</table>";
  4703. $str .= "</body></html>";
  4704. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4705. header("Content-type: application/octet-stream");
  4706. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4707. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4708. header("Pragma: no-cache");
  4709. header("Expires: 0");
  4710. exit($str);
  4711. }
  4712. }
  4713. //数量调整模板导出
  4714. public function _presetout()
  4715. {
  4716. if (isset($_GET['excel'])) {
  4717. $where = "sku != 'Preset' and purchase != 0";
  4718. //数据排序
  4719. $order_str = "id desc";
  4720. if (empty($page)) {
  4721. $start = 0;
  4722. $perpage = 1;
  4723. } else {
  4724. $start = ($page - 1) * $perpage;
  4725. }
  4726. //取得信息列表
  4727. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4728. $rows = array();
  4729. $list = array();
  4730. foreach ($info_list as $value) {
  4731. $warehouse = $this->warehouse->read($value['warehouse']);
  4732. $number = $value['number'];
  4733. $ftime = time() - 15 * 24 * 3600;
  4734. $purchase = $this->purchase->read($value['purchase']);
  4735. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4736. }
  4737. $title = "库存模板";
  4738. $titlename = "<table border=1>
  4739. <tr align='center'>
  4740. <td>仓库</td>
  4741. <td>供应商编码</td>
  4742. <td>SKU</td>
  4743. <td>增减数量(正数或负数)</td>
  4744. <td>增减备注</td>
  4745. <td>库位</td>
  4746. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4747. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4748. </tr>
  4749. </table>";
  4750. $filename = $title . ".xls";
  4751. $tail = "";
  4752. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4753. }
  4754. }
  4755. //数量调整模板导入
  4756. public function _presetedit()
  4757. {
  4758. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4759. $config['upload_path'] = '.' . $dir;
  4760. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4761. $config['allowed_types'] = 'xls|xlsx|csv';
  4762. $config['max_size'] = 10240;
  4763. $this->load->library('upload', $config);
  4764. $this->upload->initialize($config);
  4765. if ($this->upload->do_upload('userfile')) {
  4766. $full_path = $dir . $this->upload->data('file_name');
  4767. $fileName = '.' . $full_path;
  4768. if (!file_exists($fileName)) {
  4769. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4770. exit;
  4771. } else {
  4772. require_once "./data/excel/PHPExcel/IOFactory.php";
  4773. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4774. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4775. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4776. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4777. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4778. ++$column; //如果列数大于26行
  4779. $list = array();
  4780. for ($i = 2; $i <= $row; $i++) // 行数循环
  4781. {
  4782. $data = array();
  4783. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4784. {
  4785. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4786. }
  4787. $list[] = $data;
  4788. }
  4789. }
  4790. $i = 0;
  4791. $j = 0;
  4792. $ed = array();
  4793. foreach ($list as $key => $value) {
  4794. $time = time();
  4795. if ($value['0'] == "") {
  4796. continue;
  4797. }
  4798. $warehouse = $this->warehouse->get_title($value['0']);
  4799. $purchase = $this->purchase->get_bm($value['1']);
  4800. $sku = $value['2'];
  4801. $num = $value['3']; //调整数量
  4802. $text = $value['4']; //扣减说明
  4803. $type = $value['5']; //调整方式0扣减1删除
  4804. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4805. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4806. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4807. if (!$purchase) //如果没有这个SKU
  4808. {
  4809. $ed[] = array($purchase . '-不存在此供应商编码');
  4810. $j++;
  4811. continue;
  4812. }
  4813. if (!$d) //如果没有这个SKU
  4814. {
  4815. $ed[] = array($sku . '-库存中不存在此SKU');
  4816. $j++;
  4817. continue;
  4818. }
  4819. if (!isset($warehouse['id'])) {
  4820. $ed[] = array($sku . '-仓库名错误!');
  4821. $j++;
  4822. continue;
  4823. }
  4824. if ($type != '0' && $type != '1') {
  4825. $ed[] = array($sku . '-扣减方式填写错误!');
  4826. $j++;
  4827. continue;
  4828. }
  4829. if ($num < 0) //扣减库存
  4830. {
  4831. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4832. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4833. $j++;
  4834. continue;
  4835. }
  4836. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4837. if (count($data) < abs($num)) {
  4838. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4839. $j++;
  4840. continue;
  4841. }
  4842. if ($type == 0) //如果扣减方式为 扣减库存
  4843. {
  4844. for ($i = 0; $i < abs($num); $i++) {
  4845. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4846. }
  4847. } else if ($type == 1) {
  4848. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4849. if (count($zt) > 0) {
  4850. $ed[] = array($sku . '-有在途库存无法删除!');
  4851. $j++;
  4852. continue;
  4853. }
  4854. for ($i = 0; $i < abs($num); $i++) {
  4855. $this->whlabel->remove($data[$i]['id']);
  4856. }
  4857. }
  4858. } else if ($num > 0) //增加库存
  4859. {
  4860. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4861. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4862. $j++;
  4863. continue;
  4864. }
  4865. $post['sku'] = $d['sku'];
  4866. $post['shop'] = $d['shop'];
  4867. $post['warehouse'] = $warehouse['id'];
  4868. $post['purchase'] = $purchase['id'];
  4869. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4870. $post['state'] = 0;
  4871. $post['title'] = $d['title'];
  4872. $post['number'] = $d['number'];
  4873. $post['features'] = $d['features'];
  4874. $post['enter'] = $time;
  4875. $post['time'] = $time; //操作时间
  4876. $post['rktype'] = $rktype;
  4877. for ($i = 0; $i < $num; $i++) {
  4878. $post['label'] = time() . rand(100, 999) . $i;
  4879. $this->whlabel->insert($post);
  4880. }
  4881. }
  4882. sleep(1); //防止入库时间一样,需要延迟1秒
  4883. }
  4884. if ($j > 0) {
  4885. $tt = date('Ymd', time());
  4886. $title = '库存导入错误信息-' . $tt;
  4887. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4888. $tail = "\n";
  4889. $filename = $title . ".xls";
  4890. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4891. $dir = '/data/excel/' . $time . '/';
  4892. $file_name = 'error_' . $time . rand(1000, 9999);
  4893. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4894. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4895. fwrite($myfile, $ecl);
  4896. fclose($myfile);
  4897. $error = $dir . $file_name . '.xls';
  4898. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4899. exit;
  4900. } else {
  4901. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4902. exit;
  4903. }
  4904. }
  4905. }
  4906. public function _presetedittwo(){
  4907. $data = $this->input->post(NULL, TRUE);
  4908. if(empty($list)){
  4909. $raw_data = $this->input->raw_input_stream;
  4910. // 解码 JSON
  4911. $data = json_decode($raw_data, true);
  4912. }
  4913. if(empty($data)){
  4914. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4915. exit;
  4916. }
  4917. $list = [];
  4918. if(isset($data['list'])){
  4919. $list = $data['list'];
  4920. }
  4921. $i = 0;
  4922. $j = 0;
  4923. $ed = array();
  4924. foreach ($list as $key => $value) {
  4925. $time = time();
  4926. if ($value['0'] == "") {
  4927. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4928. $j++;
  4929. continue;
  4930. }
  4931. $warehouse = $this->warehouse->get_title($value['0']);
  4932. if(empty($warehouse)){
  4933. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4934. $j++;
  4935. continue;
  4936. }
  4937. $purchase = $this->purchase->get_bm($value['1']);
  4938. $sku = $value['2'];
  4939. $num = $value['3']; //调整数量
  4940. $text = $value['4']; //扣减说明
  4941. $type = 0; //调整方式0扣减1删除
  4942. $details = empty($value['5'])?'':$value['5']; //库位
  4943. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4944. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4945. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4946. if (!$purchase) //如果没有这个SKU
  4947. {
  4948. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4949. $j++;
  4950. continue;
  4951. }
  4952. if (!$d) //如果没有这个SKU
  4953. {
  4954. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4955. $j++;
  4956. continue;
  4957. }
  4958. if (!isset($warehouse['id'])) {
  4959. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4960. $j++;
  4961. continue;
  4962. }
  4963. if ($type != '0' && $type != '1') {
  4964. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4965. $j++;
  4966. continue;
  4967. }
  4968. if ($num < 0) //扣减库存
  4969. {
  4970. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4971. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4972. $j++;
  4973. continue;
  4974. }
  4975. if(!empty($details)){
  4976. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  4977. }else{
  4978. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  4979. }
  4980. if (count($data) < abs($num)) {
  4981. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  4982. $j++;
  4983. continue;
  4984. }
  4985. if ($type == 0) //如果扣减方式为 扣减库存
  4986. {
  4987. for ($i = 0; $i < abs($num); $i++) {
  4988. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4989. }
  4990. } else if ($type == 1) {
  4991. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4992. if (count($zt) > 0) {
  4993. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  4994. $j++;
  4995. continue;
  4996. }
  4997. for ($i = 0; $i < abs($num); $i++) {
  4998. $this->whlabel->remove($data[$i]['id']);
  4999. }
  5000. }
  5001. } else if ($num > 0) //增加库存
  5002. {
  5003. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5004. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5005. $j++;
  5006. continue;
  5007. }
  5008. if(empty($details)){
  5009. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5010. if(empty($tmp_info)){
  5011. $details = '';
  5012. }else{
  5013. $details = $tmp_info['details'];
  5014. }
  5015. }else{
  5016. if($details == 'DZ001'){
  5017. }else{
  5018. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5019. if(empty($tmp_info)){
  5020. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5021. $j++;
  5022. continue;
  5023. }
  5024. }
  5025. }
  5026. $post['sku'] = $d['sku'];
  5027. $post['shop'] = $d['shop'];
  5028. $post['warehouse'] = $warehouse['id'];
  5029. $post['purchase'] = $purchase['id'];
  5030. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5031. $post['state'] = 0;
  5032. $post['title'] = $d['title'];
  5033. $post['number'] = $d['number'];
  5034. $post['features'] = $d['features'];
  5035. $post['details'] = $details;
  5036. $post['enter'] = $time;
  5037. $post['time'] = $time; //操作时间
  5038. $post['rktype'] = $rktype;
  5039. $post['sku_master_id'] = $d['sku_master_id'];
  5040. $post['sku_shop_id'] = $d['sku_shop_id'];
  5041. for ($i = 0; $i < $num; $i++) {
  5042. $post['label'] = time() . rand(100, 999) . $i;
  5043. $this->whlabel->insert($post);
  5044. }
  5045. }
  5046. sleep(1); //防止入库时间一样,需要延迟1秒
  5047. }
  5048. if ($j > 0) {
  5049. $tt = date('Ymd', time());
  5050. $title = '库存导入错误信息-' . $tt;
  5051. $error = $title . '.xls';
  5052. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5053. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5054. exit;
  5055. } else {
  5056. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5057. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5058. exit;
  5059. }
  5060. }
  5061. //笛卡儿积
  5062. function cp($ps, $sets, $list)
  5063. {
  5064. $result = array();
  5065. $j = 0;
  5066. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5067. if ($i == 0) {
  5068. $result = $sets[$i];
  5069. }
  5070. $tmp = array();
  5071. foreach ($result as $res) {
  5072. foreach ($sets[$i + 1] as $set) {
  5073. $tmp[] = $res . ',' . $set;
  5074. }
  5075. }
  5076. $result = $tmp;
  5077. }
  5078. $this->db->trans_begin();
  5079. foreach ($result as $v) {
  5080. $post = array();
  5081. $title = "";
  5082. $num = "";
  5083. $data = explode(',', $v);
  5084. for ($i = 0; $i < count($list); $i++) {
  5085. $post[$list[$i]] = $data[$i];
  5086. $typeclass = $this->typeclass->read($data[$i]);
  5087. $title = $title . $typeclass['title'] . " ";
  5088. if ($data[$i] != 0) {
  5089. $num .= $data[$i]; //所有数据ID拼接
  5090. }
  5091. }
  5092. foreach ($ps as $kp => $vp) {
  5093. $post[$kp] = $vp;
  5094. }
  5095. $post['number'] = $num;
  5096. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5097. if ($info_list) {
  5098. $j++;
  5099. } else {
  5100. $skunum = $this->whlabel->find_count();
  5101. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5102. $post['title'] = rtrim($title, ' ');
  5103. $this->whlabel->insert($post);
  5104. }
  5105. }
  5106. if ($this->db->trans_status() === FALSE) {
  5107. $this->db->trans_commit();
  5108. return NULL;
  5109. } else {
  5110. $this->db->trans_commit();
  5111. return $j;
  5112. }
  5113. }
  5114. public function _kj($arg_array)
  5115. {
  5116. if (isset($_POST['sku'])) {
  5117. $time = time();
  5118. $sku = $this->input->post('sku', true);
  5119. $warehouse = $this->input->post('warehouse', true);
  5120. $num = $this->input->post('num', true);
  5121. $text = $this->input->post('text', true);
  5122. $purchase = $this->input->post('purchase', true);
  5123. $cktype = $this->input->post('cktype', true);
  5124. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5125. if ($cktype != 1 && $text == '') {
  5126. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5127. exit;
  5128. }
  5129. if ($num > count($order)) {
  5130. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5131. exit;
  5132. } else {
  5133. for ($i = 0; $i < $num; $i++) {
  5134. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5135. }
  5136. }
  5137. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5138. exit;
  5139. }
  5140. $uid = $this->whlabel->read($arg_array[0]);
  5141. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5142. $this->data['data'] = $uid;
  5143. $this->_Template('whlabel_kj', $this->data);
  5144. }
  5145. public function _summary($arg_array)
  5146. {
  5147. $prc = array();
  5148. $purchase = $this->purchase->find_all();
  5149. foreach ($purchase as $k => $v) {
  5150. $prc[$v['id']] = $v['title'];
  5151. }
  5152. if (isset($_GET['excel'])) {
  5153. $ktime = $this->input->get('ktime', true);
  5154. $jtime = $this->input->get('jtime', true);
  5155. $ktime = strtotime($ktime);
  5156. $jtime = strtotime($jtime);
  5157. $where = "1=1";
  5158. if ($ktime && $jtime) {
  5159. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5160. }
  5161. //数据排序
  5162. $order_str = "time desc";
  5163. if (empty($page)) {
  5164. $start = 0;
  5165. $perpage = 1;
  5166. } else {
  5167. $start = ($page - 1) * $perpage;
  5168. }
  5169. //取得信息列表
  5170. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5171. foreach ($info_list as $key => $value) {
  5172. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5173. $warehouse = $this->warehouse->read($value['warehouse']);
  5174. $info_list[$key]['warehouse'] = $warehouse['title'];
  5175. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  5176. $details = array();
  5177. $cpid = array();
  5178. foreach ($x as $k => $v) {
  5179. if ($v['details'] != '') {
  5180. $details[$v['details']] = $v['details'];
  5181. }
  5182. if ($v['cpid'] != 0) {
  5183. $cpid[$v['cpid']] = $v['cpid'];
  5184. }
  5185. }
  5186. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5187. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5188. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5189. $info_list[$key]['s'] = $s;
  5190. $info_list[$key]['x'] = count($x);
  5191. }
  5192. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5193. $titlename = "<table border=1>
  5194. <tr align='center'>
  5195. <td>仓库</td>
  5196. <td>供应商</td>
  5197. <td>出库位置</td>
  5198. <td>出库编码</td>
  5199. <td>SKU</td>
  5200. <td>产品名</td>
  5201. <td>总剩余库存</td>
  5202. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5203. </tr>
  5204. </table>";
  5205. $filename = $title . ".xls";
  5206. $tail = "";
  5207. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5208. }
  5209. }
  5210. //usps发货清单
  5211. public function _manifest()
  5212. {
  5213. if (isset($_POST['manifest'])) {
  5214. $wltext = $this->input->post('wltext', true);
  5215. $time = time() - 16 * 3600;
  5216. $ptime = strtotime(date('Y-m-d', $time));
  5217. $waybill = array();
  5218. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5219. foreach ($fullorder as $v) {
  5220. $waybill[$v['waybill']] = $v['waybill'];
  5221. }
  5222. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5223. foreach ($fullordersmt as $v) {
  5224. $waybill[$v['waybill']] = $v['waybill'];
  5225. }
  5226. $wltext = explode(';', $wltext);
  5227. foreach ($wltext as $v) {
  5228. if (isset($waybill[$v])) {
  5229. unset($waybill[$v]);
  5230. }
  5231. }
  5232. $data = $this->usps->get_manifest($waybill);
  5233. if (isset($data['Description'])) {
  5234. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5235. exit;
  5236. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5237. $bctime = date('Ymd', time());
  5238. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5239. echo json_encode(array('msg' => $pdf, 'success' => true));
  5240. exit;
  5241. } else {
  5242. echo json_encode(array('msg' => $data, 'success' => false));
  5243. exit;
  5244. }
  5245. }
  5246. }
  5247. public function _pdf($pdf, $title, $bctime)
  5248. {
  5249. $pdf_path = './data/pdf/' . $bctime . '/';
  5250. $file_base64 = $pdf;
  5251. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5252. $file_base64 = base64_decode($file_base64);
  5253. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5254. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5255. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5256. }
  5257. /**
  5258. *
  5259. *
  5260. *
  5261. 进销存占单异常索引
  5262. *
  5263. *
  5264. *
  5265. **/
  5266. public function _abnormal()
  5267. {
  5268. $post = $this->input->post(NULL, TRUE);
  5269. if (isset($post['page'])) {
  5270. $page = $this->input->post('page', true);
  5271. $perpage = $this->input->post('perpage', true);
  5272. $sku = $this->input->post('sku', true);
  5273. $where = "1=1";
  5274. //数据排序
  5275. $order_str = "id desc";
  5276. if (empty($page)) {
  5277. $start = 0;
  5278. $perpage = 1;
  5279. } else {
  5280. $start = ($page - 1) * $perpage;
  5281. }
  5282. //取得信息列表
  5283. $info_list = $this->whlabel->find_all($where, '*');
  5284. $rows = array();
  5285. $list = array();
  5286. foreach ($info_list as $key => $value) {
  5287. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5288. }
  5289. foreach ($rows as $value) {
  5290. $warehouse = $this->warehouse->read($value['warehouse']);
  5291. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5292. $number = $value['number'];
  5293. $ftime = time() - 15 * 24 * 3600;
  5294. if ($value['shop'] != '') {
  5295. $shop = $value['shop'];
  5296. $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');
  5297. $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');
  5298. $order = array_merge($orderdlz, $ordersmt);
  5299. $od = 0;
  5300. $a = '';
  5301. $orid = '';
  5302. foreach ($order as $v) {
  5303. $or = explode('|', ltrim($v['whlabel'], '|'));
  5304. for ($i = 0; $i < count($or); $i++) {
  5305. $orod = explode('-', $or[$i]);
  5306. if ($orod[0] == $number) {
  5307. $od += $orod[1];
  5308. }
  5309. }
  5310. $orid .= $v['number'] . '-';
  5311. }
  5312. } else {
  5313. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5314. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5315. $order = array_merge($orderdlz, $ordersmt);
  5316. $od = 0;
  5317. $a = '';
  5318. $orid = '';
  5319. $qt = array();
  5320. foreach ($order as $v) {
  5321. $or = explode('|', ltrim($v['whlabel'], '|'));
  5322. for ($i = 0; $i < count($or); $i++) {
  5323. $orod = explode('-', $or[$i]);
  5324. if ($orod[0] == $number) {
  5325. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5326. if ($czzs > 0) {
  5327. if (isset($qt[$v['shop']])) {
  5328. if ($qt[$v['shop']] < $orod[1]) {
  5329. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5330. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5331. } else {
  5332. $qt[$v['shop']] -= $orod[1];
  5333. }
  5334. } else {
  5335. $qt[$v['shop']] = $czzs;
  5336. }
  5337. } else {
  5338. $od += $orod[1];
  5339. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5340. }
  5341. }
  5342. }
  5343. }
  5344. }
  5345. $z = $od . '(' . $orid . ')'; //查看订单号
  5346. //$z = $od;
  5347. if ($od > $c) {
  5348. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5349. }
  5350. }
  5351. $listdata = array_slice($list, $start, $perpage);
  5352. $total = count($list);
  5353. $pagenum = ceil($total / $perpage);
  5354. $over = $total - ($start + $perpage);
  5355. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5356. echo json_encode($rows);
  5357. exit;
  5358. }
  5359. $this->_Template('whlabel_abnormal', $this->data);
  5360. }
  5361. /**
  5362. *
  5363. *
  5364. *
  5365. 进销存占单异常索引
  5366. *
  5367. *
  5368. *
  5369. **/
  5370. public function _error()
  5371. {
  5372. $post = $this->input->post(NULL, TRUE);
  5373. if (isset($post['page'])) {
  5374. $page = $this->input->post('page', true);
  5375. $perpage = $this->input->post('perpage', true);
  5376. $sku = $this->input->post('sku', true);
  5377. $warehouse = $this->input->post('warehouse', true);
  5378. $ktime = $this->input->post('ktime', true);
  5379. $jtime = $this->input->post('jtime', true);
  5380. $ktime = strtotime($ktime);
  5381. $jtime = strtotime($jtime);
  5382. $where = "sku != 'Preset'";
  5383. $gj = '';
  5384. if ($sku) {
  5385. $where .= " and sku like '%$sku%'";
  5386. } else {
  5387. if ($ktime && $jtime) {
  5388. $gj = " and time > '$ktime' and time < '$jtime'";
  5389. }
  5390. }
  5391. if ($warehouse) {
  5392. $where .= " and warehouse = '$warehouse'";
  5393. }
  5394. //数据排序
  5395. $order_str = "id desc";
  5396. if (empty($page)) {
  5397. $start = 0;
  5398. $perpage = 1;
  5399. } else {
  5400. $start = ($page - 1) * $perpage;
  5401. }
  5402. //取得信息列表
  5403. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5404. $rows = array();
  5405. $list = array();
  5406. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5407. // foreach ($info_list as $value)
  5408. // {
  5409. // $warehouse = $this->warehouse->read($value['warehouse']);
  5410. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5411. // $number = $value['number'];$ftime = time()-15*24*3600;
  5412. // if($c < 1)
  5413. // {
  5414. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5415. // }
  5416. // }
  5417. $warehouse_list = $this->warehouse->find_all();
  5418. $warehouse_list = array_column($warehouse_list, null, 'id');
  5419. foreach ($info_list as $value) {
  5420. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5421. 'title' => "",
  5422. ];
  5423. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5424. $number = $value['number'];
  5425. $ftime = time() - 15 * 24 * 3600;
  5426. if ($c < 1) {
  5427. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5428. }
  5429. }
  5430. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5431. // $query = $this->db->query($sql);
  5432. // $info_list = $query->result_array();
  5433. // $sql_two = "select title,id from crowd_warehouse";
  5434. // $query_two = $this->db->query($sql_two);
  5435. // $warehouse_list = $query_two->result_array();
  5436. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5437. // foreach ($info_list as $value)
  5438. // {
  5439. // if(isset($warehouse_arr[$value['warehouse']])){
  5440. // $warehouse = $warehouse_arr[$value['warehouse']];
  5441. // }else{
  5442. // $warehouse = [
  5443. // 'id'=>0,
  5444. // 'title'=>"异常",
  5445. // ];
  5446. // }
  5447. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5448. // $number = $value['number'];$ftime = time()-15*24*3600;
  5449. // if($c < 1)
  5450. // {
  5451. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5452. // }
  5453. // }
  5454. $listdata = array_slice($list, $start, $perpage);
  5455. $total = count($list);
  5456. $pagenum = ceil($total / $perpage);
  5457. $over = $total - ($start + $perpage);
  5458. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5459. echo json_encode($rows);
  5460. exit;
  5461. }
  5462. if (isset($post['s'])) {
  5463. $id_arr = $this->input->post('s');
  5464. $id_arr = explode(',', trim($id_arr, ','));
  5465. if (!$id_arr) {
  5466. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5467. exit;
  5468. }
  5469. //循环删除记录
  5470. foreach ($id_arr as $v) {
  5471. $dd = $this->whlabel->read($v);
  5472. if (!isset($dd['id'])) {
  5473. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5474. exit;
  5475. }
  5476. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5477. if (isset($zt[0])) {
  5478. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5479. exit;
  5480. }
  5481. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5482. foreach ($deldd as $vv) {
  5483. $this->whlabel->remove($vv['id']);
  5484. }
  5485. }
  5486. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5487. exit;
  5488. }
  5489. $this->_Template('whlabel_error', $this->data);
  5490. }
  5491. public function _errorexcel()
  5492. {
  5493. $post = $this->input->post(NULL, TRUE);
  5494. if (isset($_GET['page'])) {
  5495. $page = $this->input->get('page', true);
  5496. $perpage = $this->input->get('perpage', true);
  5497. $sku = $this->input->get('sku', true);
  5498. $warehouse = $this->input->get('warehouse', true);
  5499. $ktime = $this->input->get('ktime', true);
  5500. $jtime = $this->input->get('jtime', true);
  5501. $ktime = strtotime($ktime);
  5502. $jtime = strtotime($jtime);
  5503. $where = "sku != 'Preset'";
  5504. $gj = '';
  5505. if ($sku) {
  5506. $where .= " and sku like '%$sku%'";
  5507. } else {
  5508. if ($ktime && $jtime) {
  5509. $gj = " and time > '$ktime' and time < '$jtime'";
  5510. }
  5511. }
  5512. if ($warehouse) {
  5513. $where .= " and warehouse = '$warehouse'";
  5514. }
  5515. //数据排序
  5516. $order_str = "id desc";
  5517. if (empty($page)) {
  5518. $start = 0;
  5519. $perpage = 1;
  5520. } else {
  5521. $start = ($page - 1) * $perpage;
  5522. }
  5523. //取得信息列表
  5524. $rows = array();
  5525. $list = array();
  5526. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5527. foreach ($info_list as $value) {
  5528. $warehouse = $this->warehouse->read($value['warehouse']);
  5529. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5530. $number = $value['number'];
  5531. $ftime = time() - 15 * 24 * 3600;
  5532. if ($c < 1) {
  5533. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5534. }
  5535. }
  5536. $title = "0库存汇总";
  5537. $titlename = "<table border=1>
  5538. <tr align='center'>
  5539. <td>仓库</td>
  5540. <td>SKU</td>
  5541. <td>产品</td>
  5542. <td>当前库存</td>
  5543. </tr>
  5544. </table>";
  5545. $filename = $title . ".xls";
  5546. $tail = "";
  5547. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5548. }
  5549. }
  5550. /**
  5551. *
  5552. *
  5553. * 占单
  5554. *
  5555. *
  5556. **/
  5557. public function _kcyz()
  5558. {
  5559. $post = $this->input->post(NULL, TRUE);
  5560. if (isset($post['warehouse'])) {
  5561. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5562. exit; //不再使用
  5563. $warehouse = $this->input->post('warehouse', true);
  5564. $whlabel = $this->input->post('whlabel', true);
  5565. $id = $this->input->post('id', true);
  5566. $shop = $this->input->post('shop', true);
  5567. $number = $this->input->post('number', true);
  5568. if (!$whlabel || $whlabel == '|') {
  5569. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5570. exit;
  5571. }
  5572. $pp = explode('|', trim($whlabel, '|'));
  5573. $x = 0;
  5574. $save = array();
  5575. foreach ($pp as $va) {
  5576. $num = explode('-', $va);
  5577. if ($number) {
  5578. $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 = '')"); //通用
  5579. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5580. } else {
  5581. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5582. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5583. }
  5584. $x++;
  5585. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5586. $save[] = $x - 1;
  5587. continue; //提前先加X不然出错,所以要减1
  5588. }
  5589. }
  5590. if (isset($save[0])) {
  5591. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5592. exit;
  5593. } else {
  5594. echo json_encode(array('success' => true));
  5595. exit;
  5596. }
  5597. }
  5598. }
  5599. public function _db()
  5600. {
  5601. $post = $this->input->post(NULL, TRUE);
  5602. if (isset($post['page'])) {
  5603. $page = $this->input->post('page', true);
  5604. $perpage = $this->input->post('perpage', true);
  5605. $sku = $this->input->post('sku', true);
  5606. $number = $this->input->post('number', true);
  5607. $warehouse = $this->input->post('warehouse', true);
  5608. $purchase = $this->input->post('purchase', true);
  5609. $orderinfo = $this->input->post('orderinfo', true);
  5610. $waybill = $this->input->post('waybill', true);
  5611. $category = $this->input->post('category', true);
  5612. $size = $this->input->post('size', true);
  5613. $grade = $this->input->post('grade', true);
  5614. $color = $this->input->post('color', true);
  5615. $lowe = $this->input->post('lowe', true);
  5616. $state = $this->input->post('state', true);
  5617. $label = $this->input->post('label', true);
  5618. $timetk = $this->input->post('timetkk', true);
  5619. $timetj = $this->input->post('timetjj', true);
  5620. $timetk = strtotime($timetk);
  5621. $timetj = strtotime($timetj);
  5622. $where = "dbtime > 0";
  5623. if ($timetk && $timetj) {
  5624. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5625. }
  5626. if ($sku) {
  5627. $where .= " and sku = '$sku'";
  5628. }
  5629. if ($warehouse) {
  5630. $where .= " and warehouse = '$warehouse'";
  5631. if ($warehouse == 12) {
  5632. $w = 'specialstock';
  5633. } else {
  5634. $w = 'whlabel';
  5635. }
  5636. }
  5637. if ($purchase) {
  5638. $where .= " and purchase = '$purchase'";
  5639. }
  5640. if ($category) {
  5641. $where .= " and features like '%-$category-%'";
  5642. }
  5643. if ($size) {
  5644. $where .= " and features like '%-$size-%'";
  5645. }
  5646. if ($grade) {
  5647. $where .= " and features like '%-$grade-%'";
  5648. }
  5649. if ($color) {
  5650. $where .= " and features like '%-$color-%'";
  5651. }
  5652. if ($lowe) {
  5653. $where .= " and features like '%-$lowe-%'";
  5654. }
  5655. if ($state != '') {
  5656. $where .= " and state = '$state'";
  5657. }
  5658. //数据排序
  5659. $order_str = "dbtime desc";
  5660. if (empty($page)) {
  5661. $start = 0;
  5662. $perpage = 1;
  5663. } else {
  5664. $start = ($page - 1) * $perpage;
  5665. }
  5666. //取得信息列表
  5667. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5668. foreach ($info_list as $key => $value) {
  5669. $warehouse = $this->$w->read($value['warehouse']);
  5670. $info_list[$key]['warehouse'] = $warehouse['title'];
  5671. $purchase = $this->purchase->read($value['purchase']);
  5672. $info_list[$key]['purchase'] = $purchase['title'];
  5673. if ($value['enter'] != 0) {
  5674. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5675. } else {
  5676. $info_list[$key]['enter'] = "";
  5677. }
  5678. if ($value['dbtime'] != 0) {
  5679. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5680. } else {
  5681. $info_list[$key]['dbtime'] = "";
  5682. }
  5683. if ($value['state'] == 0) {
  5684. $info_list[$key]['state'] = "在库";
  5685. } else if ($value['state'] == 1) {
  5686. $info_list[$key]['state'] = "出库";
  5687. } else if ($value['state'] == 2) {
  5688. $info_list[$key]['state'] = "退库";
  5689. } else if ($value['state'] == 3) {
  5690. $info_list[$key]['state'] = "调拨中";
  5691. } else if ($value['state'] == 4) {
  5692. $info_list[$key]['state'] = "再加工";
  5693. } else if ($value['state'] == 5) {
  5694. $info_list[$key]['state'] = "维修中";
  5695. } else if ($value['state'] == 6) {
  5696. $info_list[$key]['state'] = "盘亏";
  5697. } else if ($value['state'] == 7) {
  5698. $info_list[$key]['state'] = "更换标签";
  5699. } else if ($value['state'] == 8) {
  5700. $info_list[$key]['state'] = "其它";
  5701. } else if ($value['state'] == 9) {
  5702. $info_list[$key]['state'] = "预设";
  5703. }
  5704. }
  5705. $total = $this->whlabel->find_count($where);
  5706. $pagenum = ceil($total / $perpage);
  5707. $over = $total - ($start + $perpage);
  5708. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5709. echo json_encode($rows);
  5710. exit;
  5711. }
  5712. if (isset($post['outsku'])) {
  5713. $time = time();
  5714. $cz = $this->input->post('cz', true);
  5715. $label = $this->input->post('outsku', true);
  5716. $sl = $this->input->post('sl', true);
  5717. $num = $this->input->post('num', true);
  5718. //$warehouse = $this->input->post('warehouse',true);
  5719. if (!$sl) {
  5720. $sl = 1;
  5721. }
  5722. if (!$warehouse) {
  5723. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5724. exit;
  5725. }
  5726. $dblabel = $this->whlabellabel->get_label($label);
  5727. if ($dblabel) {
  5728. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5729. if (count($data) < 1) {
  5730. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5731. exit;
  5732. }
  5733. if (count($data) < $num) {
  5734. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5735. exit;
  5736. }
  5737. for ($i = 0; $i < $sl; $i++) {
  5738. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5739. }
  5740. echo json_encode(array('success' => true));
  5741. exit;
  5742. } else {
  5743. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5744. exit;
  5745. }
  5746. }
  5747. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5748. $this->_Template('whlabel_db', $this->data);
  5749. }
  5750. public function _dbrk()
  5751. {
  5752. $post = $this->input->post(NULL, TRUE);
  5753. if (isset($post['page'])) {
  5754. $page = $this->input->post('page', true);
  5755. $perpage = $this->input->post('perpage', true);
  5756. $sku = $this->input->post('sku', true);
  5757. $number = $this->input->post('number', true);
  5758. $warehouse = $this->input->post('warehouse', true);
  5759. $purchase = $this->input->post('purchase', true);
  5760. $orderinfo = $this->input->post('orderinfo', true);
  5761. $waybill = $this->input->post('waybill', true);
  5762. $category = $this->input->post('category', true);
  5763. $size = $this->input->post('size', true);
  5764. $grade = $this->input->post('grade', true);
  5765. $color = $this->input->post('color', true);
  5766. $lowe = $this->input->post('lowe', true);
  5767. $state = $this->input->post('state', true);
  5768. $label = $this->input->post('label', true);
  5769. $ctime = $this->input->post('ctime', true);
  5770. $timetk = $this->input->post('timetkk', true);
  5771. $timetj = $this->input->post('timetjj', true);
  5772. $timetk = strtotime($timetk);
  5773. $timetj = strtotime($timetj);
  5774. $where = "dbtime > 0";
  5775. if ($timetk && $timetj) {
  5776. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5777. }
  5778. if ($sku) {
  5779. $where .= " and sku = '$sku'";
  5780. }
  5781. if ($warehouse) {
  5782. $where .= " and warehouse = '$warehouse'";
  5783. }
  5784. if ($purchase) {
  5785. $where .= " and purchase = '$purchase'";
  5786. }
  5787. if ($category) {
  5788. $where .= " and features like '%-$category-%'";
  5789. }
  5790. if ($size) {
  5791. $where .= " and features like '%-$size-%'";
  5792. }
  5793. if ($grade) {
  5794. $where .= " and features like '%-$grade-%'";
  5795. }
  5796. if ($color) {
  5797. $where .= " and features like '%-$color-%'";
  5798. }
  5799. if ($lowe) {
  5800. $where .= " and features like '%-$lowe-%'";
  5801. }
  5802. if ($state != '') {
  5803. $where .= " and state = '$state'";
  5804. }
  5805. //数据排序
  5806. $order_str = "dbtime desc";
  5807. if (empty($page)) {
  5808. $start = 0;
  5809. $perpage = 1;
  5810. } else {
  5811. $start = ($page - 1) * $perpage;
  5812. }
  5813. //取得信息列表
  5814. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5815. foreach ($info_list as $key => $value) {
  5816. $warehouse = $this->warehouse->read($value['warehouse']);
  5817. $info_list[$key]['warehouse'] = $warehouse['title'];
  5818. $purchase = $this->purchase->read($value['purchase']);
  5819. $info_list[$key]['purchase'] = $purchase['title'];
  5820. if ($value['enter'] != 0) {
  5821. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5822. } else {
  5823. $info_list[$key]['enter'] = "";
  5824. }
  5825. if ($value['dbtime'] != 0) {
  5826. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5827. } else {
  5828. $info_list[$key]['dbtime'] = "";
  5829. }
  5830. if ($value['state'] == 0) {
  5831. $info_list[$key]['state'] = "在库";
  5832. } else if ($value['state'] == 1) {
  5833. $info_list[$key]['state'] = "出库";
  5834. } else if ($value['state'] == 2) {
  5835. $info_list[$key]['state'] = "退库";
  5836. } else if ($value['state'] == 3) {
  5837. $info_list[$key]['state'] = "调拨中";
  5838. } else if ($value['state'] == 4) {
  5839. $info_list[$key]['state'] = "再加工";
  5840. } else if ($value['state'] == 5) {
  5841. $info_list[$key]['state'] = "维修中";
  5842. } else if ($value['state'] == 6) {
  5843. $info_list[$key]['state'] = "盘亏";
  5844. } else if ($value['state'] == 7) {
  5845. $info_list[$key]['state'] = "更换标签";
  5846. } else if ($value['state'] == 8) {
  5847. $info_list[$key]['state'] = "其它";
  5848. } else if ($value['state'] == 9) {
  5849. $info_list[$key]['state'] = "预设";
  5850. }
  5851. }
  5852. $total = $this->whlabel->find_count($where);
  5853. $pagenum = ceil($total / $perpage);
  5854. $over = $total - ($start + $perpage);
  5855. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5856. echo json_encode($rows);
  5857. exit;
  5858. }
  5859. if (isset($post['rsku'])) {
  5860. $cz = $this->input->post('cz', true);
  5861. $label = $this->input->post('rsku', true);
  5862. $sl = $this->input->post('sl', true);
  5863. $warehouse = $this->input->post('warehouse', true);
  5864. if (!$sl) {
  5865. $sl = 1;
  5866. }
  5867. if (!$warehouse) {
  5868. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5869. exit;
  5870. }
  5871. $dblabel = $this->whlabellabel->get_label($label);
  5872. if ($dblabel) {
  5873. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5874. if (count($data) < 1) {
  5875. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5876. exit;
  5877. }
  5878. if ($sl > count($data)) {
  5879. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5880. exit;
  5881. }
  5882. $time = time();
  5883. for ($i = 0; $i < $sl; $i++) {
  5884. $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']);
  5885. }
  5886. echo json_encode(array('success' => true));
  5887. exit;
  5888. } else {
  5889. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5890. exit;
  5891. }
  5892. }
  5893. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5894. $this->_Template('whlabel_dbrk', $this->data);
  5895. }
  5896. public function _whlabelczdc()
  5897. {
  5898. if (isset($_GET['excel'])) {
  5899. //数据排序
  5900. $order_str = "id desc";
  5901. if (empty($page)) {
  5902. $start = 0;
  5903. $perpage = 1;
  5904. } else {
  5905. $start = ($page - 1) * $perpage;
  5906. }
  5907. $state = $this->input->get('state', true);
  5908. $sku = $this->input->get('sku', true);
  5909. $ctime = $this->input->get('ctime', true);
  5910. $category = $this->input->get('category', true);
  5911. $size = $this->input->get('size', true);
  5912. $grade = $this->input->get('grade', true);
  5913. $color = $this->input->get('color', true);
  5914. $lowe = $this->input->get('lowe', true);
  5915. $timetk = $this->input->get('timetkk', true);
  5916. $timetj = $this->input->get('timetjj', true);
  5917. $timetk = strtotime($timetk);
  5918. $timetj = strtotime($timetj);
  5919. $where = "dbtime > 0";
  5920. if ($timetk && $timetj) {
  5921. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5922. }
  5923. if ($category) {
  5924. $where .= " and features like '%-$category-%'";
  5925. }
  5926. if ($size) {
  5927. $where .= " and features like '%-$size-%'";
  5928. }
  5929. if ($grade) {
  5930. $where .= " and features like '%-$grade-%'";
  5931. }
  5932. if ($color) {
  5933. $where .= " and features like '%-$color-%'";
  5934. }
  5935. if ($lowe) {
  5936. $where .= " and features like '%-$lowe-%'";
  5937. }
  5938. //取得信息列表
  5939. $info_list = $this->whlabel->find_all($where, '*');
  5940. $rows = array();
  5941. $list = array();
  5942. foreach ($info_list as $key => $value) {
  5943. $rows[$value['sku']] = $value; //所有数据sku
  5944. }
  5945. foreach ($rows as $value) {
  5946. $warehouse = $this->warehouse->read($value['warehouse']);
  5947. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5948. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5949. if ($value['orderinfo'] == 0) {
  5950. $info_list[$key]['orderinfo'] = "";
  5951. }
  5952. if ($value['waybill'] == 0) {
  5953. $info_list[$key]['waybill'] = "";
  5954. }
  5955. if ($value['state'] == 0) {
  5956. $value['state'] = "在库";
  5957. } else if ($value['state'] == 3) {
  5958. $value['state'] = "调拨中";
  5959. }
  5960. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5961. }
  5962. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5963. $titlename = "<table border=1>
  5964. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5965. <tr align='center'>
  5966. <td>SKU</td>
  5967. <td>产品</td>
  5968. <td>调拨数量</td>
  5969. <td>入库数量</td>
  5970. </tr>
  5971. </table>";
  5972. $filename = $title . ".xls";
  5973. $tail = "";
  5974. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5975. }
  5976. }
  5977. public function _print($arg_array)
  5978. {
  5979. if (isset($_SESSION['api'])) {
  5980. $user = $this->user->get_api($_SESSION['api']);
  5981. $usp = $user;
  5982. $fgshop = "";
  5983. $sid = "";
  5984. $wid = "";
  5985. $wtype = "";
  5986. $usersp = explode('|', trim($user['shop'], '|'));
  5987. $userwh = explode('|', trim($user['warehouse'], '|'));
  5988. foreach ($usersp as $value) {
  5989. $fgshop .= " shop = " . $value . " or";
  5990. $sid .= " id = " . $value . " or";
  5991. }
  5992. foreach ($userwh as $value) {
  5993. $wid .= " id = " . $value . " or";
  5994. $wtype .= " type = " . $value . " or";
  5995. }
  5996. }
  5997. $post = $this->input->post(NULL, TRUE);
  5998. if (isset($post['tmsku'])) {
  5999. $tmsku = $this->input->post('tmsku', true);
  6000. if (is_numeric($tmsku)) {
  6001. $yyh = $this->whlabellabel->get_label($tmsku);
  6002. } else {
  6003. $yyh = $this->whlabellabel->get_sku($tmsku);
  6004. if(empty($yyh)){
  6005. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6006. if($r['code'] == -1 ){
  6007. echo json_encode(array('success' => false));
  6008. exit;
  6009. }else{
  6010. echo json_encode(array('features' => $r['data'], 'success' => true));
  6011. exit;
  6012. }
  6013. }
  6014. }
  6015. if ($yyh) {
  6016. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6017. exit;
  6018. } else {
  6019. echo json_encode(array('success' => false));
  6020. exit;
  6021. }
  6022. }
  6023. $classid = $this->classid->sku();
  6024. $pm = $classid;
  6025. $scsku = $classid;
  6026. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6027. if (isset($post['warehouse'])) {
  6028. if ($post['warehouse']) {
  6029. $list = array();
  6030. $num = "";
  6031. $title = "";
  6032. $features = "";
  6033. $order = 0;
  6034. $post['shop'] = '';
  6035. $brand = $this->input->post('brand', true);
  6036. if ($brand != '0,') {
  6037. $b = $this->brand->read(rtrim($brand, ','));
  6038. if ($b) {
  6039. $post['shop'] = str_replace('|', ',', $b['shop']);
  6040. }
  6041. }
  6042. $post['details'] = $this->input->post('details', true); //打印数量
  6043. $xbqnum = $this->input->post('xbqnum', true);
  6044. $post['purchase'] = $this->input->post('purchase', true);
  6045. $post['warehouse'] = $this->input->post('warehouse', true);
  6046. $post['purchase'] = $this->input->post('purchase', true);
  6047. $post['retreatwarehouse'] = $post['warehouse'];
  6048. $post['cpbz'] = $this->input->post('cpbz', true);
  6049. $post['state'] = 9;
  6050. $category = $this->input->post('category', true);
  6051. $list['category'] = $category;
  6052. $list['hairtype'] = $this->input->post('hairtype', true);
  6053. $list['grade'] = $this->input->post('grade', true);
  6054. $size = $this->input->post('size', true);
  6055. $list['size'] = rtrim($size, ',');
  6056. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6057. $list['extension'] = $this->input->post('extension', true);
  6058. if ($category == 1297) {
  6059. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6060. }
  6061. if ($category == 1702) {
  6062. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6063. $list['syother'] = $this->input->post('syother', true);
  6064. }
  6065. if ($category == 133) {
  6066. $list['fittype'] = $this->input->post('fittype', true);
  6067. $list['acother'] = $this->input->post('acother', true);
  6068. }
  6069. $list['color'] = $this->input->post('color', true);
  6070. $list['lowe'] = $this->input->post('lowe', true);
  6071. if ($category == 127) {
  6072. $list['type'] = $this->input->post('type', true);
  6073. $list['headroad'] = $this->input->post('headroad', true);
  6074. $list['density'] = $this->input->post('density', true);
  6075. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6076. $list['lacesize'] = $this->input->post('lacesize', true);
  6077. }
  6078. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6079. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6080. }
  6081. if ($category == 128) {
  6082. $list['lacetype'] = $this->input->post('lacetype', true);
  6083. $list['haircap'] = $this->input->post('haircap', true);
  6084. $list['density'] = $this->input->post('density', true);
  6085. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6086. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6087. $list['wigother'] = $this->input->post('wigother', true);
  6088. $list['wigother1'] = $this->input->post('wigother1', true);
  6089. $list['wigother2'] = $this->input->post('wigother2', true);
  6090. $list['product_related'] = $this->input->post('product_related', true);
  6091. }
  6092. if ($category == 129) {
  6093. $list['wide'] = $this->input->post('wide', true);
  6094. }
  6095. if ($category == 131) {
  6096. $list['gifttype'] = $this->input->post('gifttype', true);
  6097. $list['giftother'] = $this->input->post('giftother', true);
  6098. }
  6099. if ($category == 134) {
  6100. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6101. }
  6102. if ($category == 1297) {
  6103. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6104. $list['sywigother'] = $this->input->post('sywigother', true);
  6105. }
  6106. if ($category == 130 || $category == 133 || $category == 1702) {
  6107. $list['items'] = $this->input->post('items', true);
  6108. $list['weight'] = $this->input->post('weight', true);
  6109. }
  6110. if ($category == 1702) {
  6111. $list['syhairther'] = $this->input->post('syhairther', true);
  6112. }
  6113. if($category == 130){
  6114. $list['jfother'] = $this->input->post('jfother', true);
  6115. }
  6116. foreach ($list as $k => $v) {
  6117. if ($v != 0) {
  6118. $num .= $v;
  6119. $features .= $v . '-';
  6120. $post[$k] = $v;
  6121. $typeclass = $this->typeclass->read($v);
  6122. if (isset($pm[$typeclass['classid']])) {
  6123. if (stripos($typeclass['zh'], '|') !== false) {
  6124. $exzh = explode('|', $typeclass['zh']);
  6125. $pm[$typeclass['classid']] = $exzh[0];
  6126. } else {
  6127. $pm[$typeclass['classid']] = $typeclass['zh'];
  6128. }
  6129. }
  6130. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6131. if ($k != 'size') {
  6132. $title .= $typeclass['title'] . " ";
  6133. }
  6134. }
  6135. }
  6136. $typeclass = $this->typeclass->read($list['size']);
  6137. $title .= $typeclass['title'];
  6138. $time = time();
  6139. $post['title'] = rtrim($title, ' ');
  6140. $post['number'] = $num;
  6141. $post['features'] = '-' . $features;
  6142. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6143. $featurespp = explode('-', trim($featurespp, '-'));
  6144. if (isset($featurespp[5])) {
  6145. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6146. } else {
  6147. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6148. }
  6149. $post['enter'] = $time;
  6150. $post['time'] = $time; //操作时间
  6151. $scsku = implode("-", $scsku);
  6152. $zh = implode(" ", $pm);
  6153. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6154. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6155. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6156. $post['sku'] = $bqsku;
  6157. $label = time() . rand(0, 9);
  6158. $post['label'] = $label;
  6159. $cpid = $this->whlabellabel->find_count();
  6160. $post['cpid'] = $cpid + 1;
  6161. $cpid = $post['cpid'];
  6162. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6163. //if($whlabelbarcode)
  6164. //{
  6165. //$post['label'] = $whlabelbarcode['label'];
  6166. //if(!$this->whlabellabel->insert($post))
  6167. //{
  6168. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6169. //}
  6170. //}
  6171. //else
  6172. //{
  6173. $this->db->trans_begin();
  6174. $this->whlabellabel->insert($post);
  6175. //$this->whlabelbarcode->insert($post);
  6176. if ($this->db->trans_status() === TRUE) {
  6177. $this->db->trans_commit();
  6178. } else {
  6179. $this->db->trans_rollback();
  6180. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6181. exit;
  6182. }
  6183. //}
  6184. $warehouse_name = "";
  6185. $warehouse = $post['warehouse'];
  6186. if($warehouse == 12){
  6187. $warehouse_name = "特殊库存库";
  6188. }
  6189. // if($warehouse == 13){
  6190. // $warehouse_name = "许昌仓";
  6191. // }
  6192. // if($warehouse == 5){
  6193. // $warehouse_name = "美国店";
  6194. // }
  6195. // if($warehouse == 16){
  6196. // $warehouse_name = "定制头套仓";
  6197. // }
  6198. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6199. if(!empty($warehouse_name)){
  6200. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6201. }
  6202. $purchase = $this->purchase->read($post['purchase']);
  6203. 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));
  6204. exit; //特殊仓目前不需要仓库选项
  6205. }
  6206. }
  6207. if (isset($_SESSION['api'])) {
  6208. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6209. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6210. $this->data['wlshop'] = $wlshop;
  6211. $this->data['warehouse'] = $warehouse;
  6212. }
  6213. $whlabelwz = $this->whlabelwz->find_all();
  6214. $this->data['whlabelwz'] = $whlabelwz;
  6215. $this->_Template('whlabel_print', $this->data);
  6216. }
  6217. public function _usaprint($arg_array)
  6218. {
  6219. if (isset($_SESSION['api'])) {
  6220. $user = $this->user->get_api($_SESSION['api']);
  6221. $usp = $user;
  6222. $fgshop = "";
  6223. $sid = "";
  6224. $wid = "";
  6225. $wtype = "";
  6226. $usersp = explode('|', trim($user['shop'], '|'));
  6227. $userwh = explode('|', trim($user['warehouse'], '|'));
  6228. foreach ($usersp as $value) {
  6229. $fgshop .= " shop = " . $value . " or";
  6230. $sid .= " id = " . $value . " or";
  6231. }
  6232. foreach ($userwh as $value) {
  6233. $wid .= " id = " . $value . " or";
  6234. $wtype .= " type = " . $value . " or";
  6235. }
  6236. }
  6237. $post = $this->input->post(NULL, TRUE);
  6238. if (isset($post['tmsku'])) {
  6239. $tmsku = $this->input->post('tmsku', true);
  6240. if (is_numeric($tmsku)) {
  6241. $yyh = $this->whlabellabel->get_label($tmsku);
  6242. } else {
  6243. $yyh = $this->whlabellabel->get_sku($tmsku);
  6244. }
  6245. if ($yyh) {
  6246. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6247. exit;
  6248. } else {
  6249. echo json_encode(array('success' => false));
  6250. exit;
  6251. }
  6252. }
  6253. $classid = $this->classid->sku();
  6254. $pm = $classid;
  6255. $scsku = $classid;
  6256. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6257. if (isset($post['warehouse'])) {
  6258. if ($post['warehouse']) {
  6259. $list = array();
  6260. $num = "";
  6261. $title = "";
  6262. $features = "";
  6263. $order = 0;
  6264. $post['shop'] = '';
  6265. $brand = $this->input->post('brand', true);
  6266. if ($brand != '0,') {
  6267. $b = $this->brand->read(rtrim($brand, ','));
  6268. if ($b) {
  6269. $post['shop'] = str_replace('|', ',', $b['shop']);
  6270. }
  6271. }
  6272. $post['details'] = $this->input->post('details', true); //打印数量
  6273. $xbqnum = $this->input->post('xbqnum', true);
  6274. $post['purchase'] = $this->input->post('purchase', true);
  6275. $post['warehouse'] = $this->input->post('warehouse', true);
  6276. $post['purchase'] = $this->input->post('purchase', true);
  6277. $post['retreatwarehouse'] = $post['warehouse'];
  6278. $post['cpbz'] = $this->input->post('cpbz', true);
  6279. $post['state'] = 9;
  6280. $category = $this->input->post('category', true);
  6281. $list['category'] = $category;
  6282. $list['hairtype'] = $this->input->post('hairtype', true);
  6283. $list['grade'] = $this->input->post('grade', true);
  6284. $size = $this->input->post('size', true);
  6285. $list['size'] = rtrim($size, ',');
  6286. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6287. $list['extension'] = $this->input->post('extension', true);
  6288. if ($category == 1297) {
  6289. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6290. }
  6291. if ($category == 1702) {
  6292. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6293. $list['syother'] = $this->input->post('syother', true);
  6294. }
  6295. if ($category == 133) {
  6296. $list['fittype'] = $this->input->post('fittype', true);
  6297. $list['acother'] = $this->input->post('acother', true);
  6298. }
  6299. $list['color'] = $this->input->post('color', true);
  6300. $list['lowe'] = $this->input->post('lowe', true);
  6301. if ($category == 127) {
  6302. $list['type'] = $this->input->post('type', true);
  6303. $list['headroad'] = $this->input->post('headroad', true);
  6304. $list['density'] = $this->input->post('density', true);
  6305. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6306. $list['lacesize'] = $this->input->post('lacesize', true);
  6307. }
  6308. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6309. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6310. }
  6311. if ($category == 128) {
  6312. $list['lacetype'] = $this->input->post('lacetype', true);
  6313. $list['haircap'] = $this->input->post('haircap', true);
  6314. $list['density'] = $this->input->post('density', true);
  6315. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6316. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6317. $list['wigother'] = $this->input->post('wigother', true);
  6318. $list['wigother1'] = $this->input->post('wigother1', true);
  6319. $list['wigother2'] = $this->input->post('wigother2', true);
  6320. $list['product_related'] = $this->input->post('product_related', true);
  6321. }
  6322. if ($category == 129) {
  6323. $list['wide'] = $this->input->post('wide', true);
  6324. }
  6325. if ($category == 131) {
  6326. $list['gifttype'] = $this->input->post('gifttype', true);
  6327. $list['giftother'] = $this->input->post('giftother', true);
  6328. }
  6329. if ($category == 134) {
  6330. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6331. }
  6332. if ($category == 1297) {
  6333. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6334. $list['sywigother'] = $this->input->post('sywigother', true);
  6335. }
  6336. if ($category == 130 || $category == 133 || $category == 1702) {
  6337. $list['items'] = $this->input->post('items', true);
  6338. $list['weight'] = $this->input->post('weight', true);
  6339. }
  6340. if ($category == 1702) {
  6341. $list['syhairther'] = $this->input->post('syhairther', true);
  6342. }
  6343. foreach ($list as $k => $v) {
  6344. if ($v != 0) {
  6345. $num .= $v;
  6346. $features .= $v . '-';
  6347. $post[$k] = $v;
  6348. $typeclass = $this->typeclass->read($v);
  6349. if (isset($pm[$typeclass['classid']])) {
  6350. if (stripos($typeclass['zh'], '|') !== false) {
  6351. $exzh = explode('|', $typeclass['zh']);
  6352. $pm[$typeclass['classid']] = $exzh[0];
  6353. } else {
  6354. $pm[$typeclass['classid']] = $typeclass['zh'];
  6355. }
  6356. }
  6357. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6358. if ($k != 'size') {
  6359. $title .= $typeclass['title'] . " ";
  6360. }
  6361. }
  6362. }
  6363. $typeclass = $this->typeclass->read($list['size']);
  6364. $title .= $typeclass['title'];
  6365. $time = time();
  6366. $post['title'] = rtrim($title, ' ');
  6367. $post['number'] = $num;
  6368. $post['features'] = '-' . $features;
  6369. $fp = $this->whlabel->get_features($post['features']);
  6370. if (!$fp) {
  6371. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6372. exit;
  6373. }
  6374. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6375. $featurespp = explode('-', trim($featurespp, '-'));
  6376. if (isset($featurespp[5])) {
  6377. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6378. } else {
  6379. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6380. }
  6381. $post['enter'] = $time;
  6382. $post['time'] = $time; //操作时间
  6383. $scsku = implode("-", $scsku);
  6384. $zh = implode(" ", $pm);
  6385. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6386. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6387. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6388. $post['sku'] = $fp['sku'];
  6389. $post['label'] = $fp['sku'];
  6390. $cpid = $this->whlabellabel->find_count();
  6391. $post['cpid'] = $cpid + 1;
  6392. $cpid = $post['cpid'];
  6393. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6394. //if($whlabelbarcode)
  6395. //{
  6396. //$post['label'] = $whlabelbarcode['label'];
  6397. //if(!$this->whlabellabel->insert($post))
  6398. //{
  6399. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6400. //}
  6401. //}
  6402. //else
  6403. //{
  6404. $this->db->trans_begin();
  6405. $this->whlabellabel->insert($post);
  6406. //$this->whlabelbarcode->insert($post);
  6407. if ($this->db->trans_status() === TRUE) {
  6408. $this->db->trans_commit();
  6409. } else {
  6410. $this->db->trans_rollback();
  6411. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6412. exit;
  6413. }
  6414. //}
  6415. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6416. $purchase = $this->purchase->read($post['purchase']);
  6417. 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));
  6418. exit; //特殊仓目前不需要仓库选项
  6419. }
  6420. }
  6421. if (isset($_SESSION['api'])) {
  6422. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6423. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6424. $this->data['wlshop'] = $wlshop;
  6425. $this->data['warehouse'] = $warehouse;
  6426. }
  6427. $whlabelwz = $this->whlabelwz->find_all();
  6428. $this->data['whlabelwz'] = $whlabelwz;
  6429. $this->_Template('whlabel_usaprint', $this->data);
  6430. }
  6431. public function _printrk($arg_array)
  6432. {
  6433. $prc = array();
  6434. $purchase = $this->purchase->find_all();
  6435. foreach ($purchase as $k => $v) {
  6436. $prc[$v['id']] = $v['title'];
  6437. }
  6438. $post = $this->input->post(NULL, TRUE);
  6439. if (isset($post['page'])) {
  6440. $page = $this->input->post('page', true);
  6441. $perpage = $this->input->post('perpage', true);
  6442. $sku = $this->input->post('sku', true);
  6443. $bs = $this->input->post('bs', true);
  6444. $number = $this->input->post('number', true);
  6445. $warehouse = $this->input->post('warehouse', true);
  6446. $purchase = $this->input->post('purchase', true);
  6447. $orderinfo = $this->input->post('orderinfo', true);
  6448. $waybill = $this->input->post('waybill', true);
  6449. $category = $this->input->post('category', true);
  6450. $size = $this->input->post('size', true);
  6451. $grade = $this->input->post('grade', true);
  6452. $color = $this->input->post('color', true);
  6453. $lowe = $this->input->post('lowe', true);
  6454. $state = $this->input->post('state', true);
  6455. $label = $this->input->post('label', true);
  6456. $timetk = $this->input->post('ktime', true);
  6457. $timetj = $this->input->post('jtime', true);
  6458. $timetk = strtotime($timetk);
  6459. $timetj = strtotime($timetj);
  6460. $where = "1=1 ";
  6461. if ($timetk && $timetj) {
  6462. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6463. }
  6464. if ($sku) {
  6465. $where .= " and sku = '$sku'";
  6466. }
  6467. if ($bs != '') {
  6468. $where .= " and bs = '$bs'";
  6469. }
  6470. if ($number) {
  6471. $where .= " and number = '$number'";
  6472. }
  6473. if ($warehouse) {
  6474. $where .= " and warehouse = '$warehouse'";
  6475. }
  6476. if ($purchase) {
  6477. $where .= " and purchase = '$purchase'";
  6478. }
  6479. if ($orderinfo) {
  6480. $where .= " and orderinfo = '$orderinfo'";
  6481. }
  6482. if ($waybill) {
  6483. $where .= " and waybill = '$waybill'";
  6484. }
  6485. if ($category) {
  6486. $where .= " and features like '%-$category-%'";
  6487. }
  6488. if ($size) {
  6489. $where .= " and features like '%-$size-%'";
  6490. }
  6491. if ($grade) {
  6492. $where .= " and features like '%-$grade-%'";
  6493. }
  6494. if ($color) {
  6495. $where .= " and features like '%-$color-%'";
  6496. }
  6497. if ($lowe) {
  6498. $where .= " and features like '%-$lowe-%'";
  6499. }
  6500. if ($label) {
  6501. $where .= " and label = '$label'";
  6502. }
  6503. if ($state || $state == 0) {
  6504. $where .= " and state = '$state'";
  6505. }
  6506. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6507. //数据排序
  6508. $order_str = "enter desc";
  6509. if (empty($page)) {
  6510. $start = 0;
  6511. $perpage = 1;
  6512. } else {
  6513. $start = ($page - 1) * $perpage;
  6514. }
  6515. //取得信息列表
  6516. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6517. foreach ($info_list as $key => $value) {
  6518. $warehouse = $this->warehouse->read($value['warehouse']);
  6519. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6520. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6521. if ($value['state'] == 0) {
  6522. $info_list[$key]['state'] = "在库";
  6523. } else if ($value['state'] == 1) {
  6524. $info_list[$key]['state'] = "出库";
  6525. } else if ($value['state'] == 2) {
  6526. $info_list[$key]['state'] = "退库";
  6527. } else if ($value['state'] == 3) {
  6528. $info_list[$key]['state'] = "调拨中";
  6529. } else if ($value['state'] == 4) {
  6530. $info_list[$key]['state'] = "再加工";
  6531. } else if ($value['state'] == 5) {
  6532. $info_list[$key]['state'] = "维修中";
  6533. } else if ($value['state'] == 6) {
  6534. $info_list[$key]['state'] = "盘亏";
  6535. } else if ($value['state'] == 7) {
  6536. $info_list[$key]['state'] = "更换标签";
  6537. } else if ($value['state'] == 8) {
  6538. $info_list[$key]['state'] = "其它";
  6539. } else if ($value['state'] == 9) {
  6540. $info_list[$key]['state'] = "预设";
  6541. } else if ($value['state'] == 10) {
  6542. $info_list[$key]['state'] = "美店零售";
  6543. }
  6544. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6545. }
  6546. $total = $this->$ck->find_count($where);
  6547. $pagenum = ceil($total / $perpage);
  6548. $over = $total - ($start + $perpage);
  6549. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6550. echo json_encode($rows);
  6551. exit;
  6552. }
  6553. if (isset($post['tmsku'])) {
  6554. $time = time();
  6555. $tmsku = $this->input->post('tmsku', true);
  6556. //$post['shop'] = $this->input->post('shop',true);
  6557. $num = $this->input->post('num', true);
  6558. $rktype = $this->input->post('rktype', true);
  6559. if ($num > 200) {
  6560. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6561. exit;
  6562. }
  6563. if (!$rktype) {
  6564. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6565. }
  6566. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6567. /**
  6568. $wz = array();
  6569. foreach ($rk as $key=>$value)
  6570. {
  6571. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6572. }
  6573. if(count($wz) > 1)
  6574. {
  6575. $wz = array_values($wz);
  6576. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6577. }
  6578. **/
  6579. if (isset($rk[0]['purchase'])) {
  6580. $rk = $rk[0];
  6581. $j = 0;
  6582. $post['purchase'] = $rk['purchase'];
  6583. $post['warehouse'] = $rk['warehouse'];
  6584. $post['retreatwarehouse'] = $rk['warehouse'];
  6585. $post['sku'] = $rk['sku'];
  6586. $post['number'] = $rk['number'];
  6587. $post['features'] = $rk['features'];
  6588. $post['title'] = $rk['title'];
  6589. $post['enter'] = $time;
  6590. $post['time'] = $time;
  6591. $post['bs'] = 1;
  6592. $post['shop'] = $rk['shop'];
  6593. $post['details'] = $rk['details'];
  6594. $post['cpid'] = $rk['cpid'];
  6595. $post['cpbz'] = $rk['cpbz'];
  6596. $post['rktype'] = $rktype;
  6597. $warehouse = $this->warehouse->read($rk['warehouse']);
  6598. if ($warehouse['bdck'] == '') {
  6599. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6600. exit;
  6601. } else {
  6602. $bdck = $warehouse['bdck'];
  6603. }
  6604. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6605. if (isset($pdwz['details'])) {
  6606. if ($pdwz['details'] != $post['details']) {
  6607. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6608. }else{
  6609. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6610. exit;
  6611. }
  6612. }
  6613. }
  6614. $post['featurespp'] = $rk['featurespp'];
  6615. if ($post['warehouse'] == '5') {
  6616. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6617. if ($yza) {
  6618. if ($post['features'] != $yza[0]['features']) {
  6619. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6620. exit;
  6621. }
  6622. }
  6623. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6624. if ($yzb) {
  6625. if ($post['sku'] != $yzb[0]['sku']) {
  6626. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6627. exit;
  6628. }
  6629. }
  6630. }
  6631. for ($i = 0; $i < $num; $i++) {
  6632. $post['label'] = time() . rand(100, 999) . $i;
  6633. if ($this->$bdck->insert($post)) {
  6634. $j++;
  6635. }
  6636. }
  6637. /**
  6638. if($post['warehouse'] != 12)
  6639. {
  6640. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6641. }
  6642. **/
  6643. $this->whlabelscanlog->insert([
  6644. 'shop'=>$rk['shop'],
  6645. 'type'=>1,
  6646. 'purchase'=>$rk['purchase'],
  6647. 'sku'=>$rk['sku'],
  6648. 'features'=>$rk['features'],
  6649. 'title'=>$rk['title'],
  6650. 'label'=>$rk['label'],
  6651. 'warehouse'=>$rk['warehouse'],
  6652. 'wlid'=>$rk['id'],
  6653. 'num'=>$num,
  6654. 'addtime'=>time()
  6655. ]);
  6656. if ($j == $num) {
  6657. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6658. exit;
  6659. } else {
  6660. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6661. exit;
  6662. }
  6663. } else {
  6664. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6665. exit;
  6666. }
  6667. }
  6668. $this->_Template('whlabel_printrk', $this->data);
  6669. }
  6670. public function _printxzrk($arg_array)
  6671. {
  6672. $post = $this->input->post(NULL, TRUE);
  6673. if (isset($post['wzid'])) {
  6674. $time = time();
  6675. $id = $this->input->post('wzid', true);
  6676. //$post['shop'] = $this->input->post('shop',true);
  6677. $num = 1;
  6678. $rk = $this->whlabellabel->read($id);
  6679. if (isset($rk['purchase'])) {
  6680. $x = 0;
  6681. $post['purchase'] = $rk['purchase'];
  6682. $post['warehouse'] = $rk['warehouse'];
  6683. $post['retreatwarehouse'] = $rk['warehouse'];
  6684. $post['sku'] = $rk['sku'];
  6685. $post['number'] = $rk['number'];
  6686. $post['features'] = $rk['features'];
  6687. $post['title'] = $rk['title'];
  6688. $post['enter'] = $time;
  6689. $post['time'] = $time;
  6690. $post['bs'] = 1;
  6691. $post['shop'] = $rk['shop'];
  6692. $post['details'] = $rk['details'];
  6693. $post['cpid'] = $rk['cpid'];
  6694. $post['cpbz'] = $rk['cpbz'];
  6695. $warehouse = $this->warehouse->read($rk['warehouse']);
  6696. if ($warehouse['bdck'] == '') {
  6697. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6698. exit;
  6699. } else {
  6700. $bdck = $warehouse['bdck'];
  6701. }
  6702. $post['featurespp'] = $rk['featurespp'];
  6703. $this->db->trans_begin();
  6704. for ($i = 0; $i < $num; $i++) {
  6705. $post['label'] = time() . rand(100, 999) . $i;
  6706. $this->$bdck->insert($post);
  6707. }
  6708. /**
  6709. if($post['warehouse'] != 12)
  6710. {
  6711. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6712. }
  6713. **/
  6714. if ($this->db->trans_status() === TRUE) {
  6715. $this->db->trans_commit();
  6716. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6717. exit;
  6718. } else {
  6719. $this->db->trans_rollback();
  6720. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6721. exit;
  6722. }
  6723. } else {
  6724. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6725. exit;
  6726. }
  6727. }
  6728. }
  6729. public function _printck($arg_array)
  6730. {
  6731. $prc = array();
  6732. $purchase = $this->purchase->find_all();
  6733. foreach ($purchase as $k => $v) {
  6734. $prc[$v['id']] = $v['title'];
  6735. }
  6736. $post = $this->input->post(NULL, TRUE);
  6737. if (isset($post['page'])) {
  6738. $page = $this->input->post('page', true);
  6739. $perpage = $this->input->post('perpage', true);
  6740. $sku = $this->input->post('sku', true);
  6741. $bs = $this->input->post('bs', true);
  6742. $number = $this->input->post('number', true);
  6743. $warehouse = $this->input->post('warehouse', true);
  6744. $purchase = $this->input->post('purchase', true);
  6745. $orderinfo = $this->input->post('orderinfo', true);
  6746. $waybill = $this->input->post('waybill', true);
  6747. $category = $this->input->post('category', true);
  6748. $size = $this->input->post('size', true);
  6749. $grade = $this->input->post('grade', true);
  6750. $color = $this->input->post('color', true);
  6751. $lowe = $this->input->post('lowe', true);
  6752. $state = $this->input->post('state', true);
  6753. $label = $this->input->post('label', true);
  6754. $timetk = $this->input->post('ktime', true);
  6755. $timetj = $this->input->post('jtime', true);
  6756. $timetk = strtotime($timetk);
  6757. $timetj = strtotime($timetj);
  6758. $where = "state=1 ";
  6759. if ($timetk && $timetj) {
  6760. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6761. }
  6762. if ($sku) {
  6763. $where .= " and sku = '$sku'";
  6764. }
  6765. if ($bs != '') {
  6766. $where .= " and bs = '$bs'";
  6767. }
  6768. if ($number) {
  6769. $where .= " and number = '$number'";
  6770. }
  6771. if ($warehouse) {
  6772. $where .= " and warehouse = '$warehouse'";
  6773. }
  6774. if ($purchase) {
  6775. $where .= " and purchase = '$purchase'";
  6776. }
  6777. if ($orderinfo) {
  6778. $where .= " and orderinfo = '$orderinfo'";
  6779. }
  6780. if ($waybill) {
  6781. $where .= " and waybill = '$waybill'";
  6782. }
  6783. if ($category) {
  6784. $where .= " and features like '%-$category-%'";
  6785. }
  6786. if ($size) {
  6787. $where .= " and features like '%-$size-%'";
  6788. }
  6789. if ($grade) {
  6790. $where .= " and features like '%-$grade-%'";
  6791. }
  6792. if ($color) {
  6793. $where .= " and features like '%-$color-%'";
  6794. }
  6795. if ($lowe) {
  6796. $where .= " and features like '%-$lowe-%'";
  6797. }
  6798. if ($label) {
  6799. $where .= " and label = '$label'";
  6800. }
  6801. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6802. //数据排序
  6803. $order_str = "outk desc";
  6804. if (empty($page)) {
  6805. $start = 0;
  6806. $perpage = 1;
  6807. } else {
  6808. $start = ($page - 1) * $perpage;
  6809. }
  6810. //取得信息列表
  6811. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6812. foreach ($info_list as $key => $value) {
  6813. $warehouse = $this->warehouse->read($value['warehouse']);
  6814. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6815. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6816. if ($value['state'] == 0) {
  6817. $info_list[$key]['state'] = "在库";
  6818. } else if ($value['state'] == 1) {
  6819. $info_list[$key]['state'] = "出库";
  6820. } else if ($value['state'] == 2) {
  6821. $info_list[$key]['state'] = "退库";
  6822. } else if ($value['state'] == 3) {
  6823. $info_list[$key]['state'] = "调拨中";
  6824. } else if ($value['state'] == 4) {
  6825. $info_list[$key]['state'] = "再加工";
  6826. } else if ($value['state'] == 5) {
  6827. $info_list[$key]['state'] = "维修中";
  6828. } else if ($value['state'] == 6) {
  6829. $info_list[$key]['state'] = "盘亏";
  6830. } else if ($value['state'] == 7) {
  6831. $info_list[$key]['state'] = "更换标签";
  6832. } else if ($value['state'] == 8) {
  6833. $info_list[$key]['state'] = "其它";
  6834. } else if ($value['state'] == 9) {
  6835. $info_list[$key]['state'] = "预设";
  6836. } else if ($value['state'] == 10) {
  6837. $info_list[$key]['state'] = "美店零售";
  6838. }
  6839. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6840. }
  6841. $total = $this->$ck->find_count($where);
  6842. $pagenum = ceil($total / $perpage);
  6843. $over = $total - ($start + $perpage);
  6844. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6845. echo json_encode($rows);
  6846. exit;
  6847. }
  6848. if (isset($post['tmsku'])) {
  6849. $time = time();
  6850. $tmsku = $this->input->post('tmsku', true);
  6851. //$post['shop'] = $this->input->post('shop',true);
  6852. $num = $this->input->post('num', true);
  6853. $cktype = $this->input->post('cktype', true);
  6854. $label = $this->whlabellabel->get_label($tmsku);
  6855. if (!$cktype) {
  6856. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6857. }
  6858. if (!isset($label['warehouse'])) {
  6859. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6860. exit;
  6861. }
  6862. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6863. $extra_where = "";
  6864. if(!empty($label['details'])){
  6865. $extra_where .= " and details = '" . $label['details'] . "'";
  6866. }
  6867. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6868. if (stripos($label['features'], '-126-') !== false) {
  6869. $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);
  6870. } else {
  6871. $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);
  6872. }
  6873. $j = 0;
  6874. if (count($ck) >= $num) {
  6875. for ($i = 0; $i < $num; $i++) {
  6876. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6877. {
  6878. $j++;
  6879. }
  6880. }
  6881. $this->whlabelscanlog->insert([
  6882. 'shop'=>$label['shop'],
  6883. 'type'=>2,
  6884. 'purchase'=>$label['purchase'],
  6885. 'sku'=>$label['sku'],
  6886. 'features'=>$label['features'],
  6887. 'title'=>$label['title'],
  6888. 'label'=>$label['label'],
  6889. 'warehouse'=>$label['warehouse'],
  6890. 'wlid'=>$label['id'],
  6891. 'num'=>$num,
  6892. 'addtime'=>time()
  6893. ]);
  6894. if ($j == $num) {
  6895. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6896. exit;
  6897. } else {
  6898. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6899. exit;
  6900. }
  6901. } else {
  6902. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6903. exit;
  6904. }
  6905. }
  6906. if(isset($_SESSION['api']))
  6907. {
  6908. $user = $this->user->get_api($_SESSION['api']);
  6909. if(in_array($user['power'],[1,27])){
  6910. $vip = 1;
  6911. }
  6912. }
  6913. else
  6914. {
  6915. $vip = 0;
  6916. header('Location: /');exit;
  6917. }
  6918. $this->data['vip'] = $vip;
  6919. $this->_Template('whlabel_printck', $this->data);
  6920. }
  6921. public function _printexcel()
  6922. {
  6923. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6924. $config['upload_path'] = '.' . $dir;
  6925. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6926. $config['allowed_types'] = 'xls|xlsx|csv';
  6927. $config['max_size'] = 10240;
  6928. $this->load->library('upload', $config);
  6929. $this->upload->initialize($config);
  6930. if ($this->upload->do_upload('userfile')) {
  6931. $full_path = $dir . $this->upload->data('file_name');
  6932. $fileName = '.' . $full_path;
  6933. if (!file_exists($fileName)) {
  6934. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6935. exit;
  6936. } else {
  6937. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6938. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6939. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6940. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6941. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6942. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6943. ++$column; //如果列数大于26行
  6944. $list = array();
  6945. for ($i = 2; $i <= $row; $i++) // 行数循环
  6946. {
  6947. $data = array();
  6948. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6949. {
  6950. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6951. }
  6952. $list[] = $data;
  6953. }
  6954. }
  6955. $ed = array();
  6956. $i = 0;
  6957. $j = 0;
  6958. $dcdata = array();
  6959. $yc = '';
  6960. $cmf_arr = array_column($list, '1');
  6961. array_multisort($cmf_arr, SORT_ASC, $list);
  6962. foreach ($list as $key => $value) {
  6963. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6964. if ($typeclass) {
  6965. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6966. } else {
  6967. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6968. $i++;
  6969. continue;
  6970. }
  6971. }
  6972. if ($i > 0) {
  6973. $yc = $i . '条异常';
  6974. }
  6975. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6976. exit;
  6977. }
  6978. }
  6979. public function _uck()
  6980. {
  6981. if (isset($_GET['excel'])) {
  6982. $tc = array();
  6983. $typeclass = $this->typeclass->find_all();
  6984. foreach ($typeclass as $v) {
  6985. $tc[$v['id']] = $v['zh'];
  6986. }
  6987. $data = array();
  6988. $t = array();
  6989. $rq = '';
  6990. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6991. $ts = $ts / (24 * 3600);
  6992. for ($i = 0; $i < $ts; $i++) {
  6993. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6994. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6995. }
  6996. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6997. foreach ($info_list as $k => $v) {
  6998. $features = explode('-', trim($v['features'], '-'));
  6999. if (!isset($features[3]) || !isset($features[4])) {
  7000. continue;
  7001. }
  7002. $data[$k][0] = $tc[$features[0]]; //类型
  7003. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7004. $data[$k][2] = $tc[$features[4]]; //曲度
  7005. $data[$k][3] = '';
  7006. if (isset($data[$k][1])) {
  7007. $data[$k][3] .= $data[$k][1];
  7008. }
  7009. if (isset($data[$k][2])) {
  7010. $data[$k][3] .= $data[$k][2];
  7011. }
  7012. if (isset($features[5])) {
  7013. $data[$k][3] .= $tc[$features[5]];
  7014. }
  7015. if (isset($features[2])) {
  7016. $data[$k][3] .= $tc[$features[2]];
  7017. }
  7018. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7019. $data[$k][4] = $v['sku'];
  7020. $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())) . '))'); //月初库存
  7021. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7022. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7023. $ztrq = '';
  7024. $ztsl = '';
  7025. if (count($zt) > 0) {
  7026. foreach ($zt as $vv) {
  7027. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7028. $ztsl .= $vv['num'] . '<br>';
  7029. }
  7030. }
  7031. $data[$k][] = trim($ztsl, '<br>');
  7032. $data[$k][] = trim($ztrq, '<br>');
  7033. $byck = 0;
  7034. foreach ($t as $vv) {
  7035. $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));
  7036. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7037. $byck += $sl;
  7038. }
  7039. $data[$k][] = ($byck > 0) ? $byck : '';
  7040. }
  7041. $title = "详情 " . date("Y-m-d", time());
  7042. $titlename = "<table border=1>
  7043. <tr align='center'>
  7044. <td>类别</td>
  7045. <td>颜色</td>
  7046. <td>曲度</td>
  7047. <td>名称</td>
  7048. <td>SKU</td>
  7049. <td>月初库存</td>
  7050. <td>剩余库存</td>
  7051. <td>在途数量</td>
  7052. <td>预达日期</td>" .
  7053. $rq
  7054. . "<td>本月出库</td></tr>
  7055. </table>";
  7056. $filename = $title . ".xls";
  7057. $tail = "";
  7058. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7059. }
  7060. }
  7061. public function _whlabelexcelzh()
  7062. {
  7063. if (isset($_GET['excel'])) {
  7064. $where = "sku != 'Preset'";
  7065. //数据排序
  7066. $order_str = "id desc";
  7067. if (empty($page)) {
  7068. $start = 0;
  7069. $perpage = 1;
  7070. } else {
  7071. $start = ($page - 1) * $perpage;
  7072. }
  7073. $category = $this->input->get('category', true);
  7074. $warehouse = $this->input->get('warehouse', true);
  7075. $excelid = $this->input->get('sid', true);
  7076. if ($category) {
  7077. $where .= " and features like '%-$category-%'";
  7078. }
  7079. if ($warehouse) {
  7080. $where .= " and warehouse = '$warehouse'";
  7081. }
  7082. $xzid = '';
  7083. if ($excelid) {
  7084. $excelid = explode(',', trim($excelid, ','));
  7085. foreach ($excelid as $key => $value) {
  7086. $xzid .= " id = " . $value . " or";
  7087. }
  7088. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7089. }
  7090. //取得信息列表
  7091. /**
  7092. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7093. $rows = array();$list = array();
  7094. foreach ($info_list as $key=>$value)
  7095. {
  7096. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7097. }
  7098. **/
  7099. $list = array();
  7100. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7101. foreach ($rows as $key => $value) {
  7102. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7103. $zh = '';
  7104. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7105. foreach ($zt as $v) {
  7106. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7107. }
  7108. $zt = array_sum(array_column($zt, 'num'));
  7109. $number = $value['number'];
  7110. $ftime = time() - 15 * 24 * 3600;
  7111. $warehouse = $this->warehouse->read($value['warehouse']);
  7112. $rows[$key]['warehouse'] = $warehouse['title'];
  7113. $rows[$key]['number'] = $c;
  7114. $rows[$key]['features'] = $zh;
  7115. $rows[$key]['hb'] = $c + $zt;
  7116. }
  7117. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7118. $titlename = "<table border=1>
  7119. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7120. <tr align='center'>
  7121. <td>仓库</td>
  7122. <td>SKU</td>
  7123. <td>产品</td>
  7124. <td>库存数量</td>
  7125. <td>在途数量及预达日期</td>
  7126. <td>在途+库存数量</td>
  7127. </tr>
  7128. </table>";
  7129. $filename = $title . ".xls";
  7130. $tail = "";
  7131. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7132. }
  7133. if (isset($_GET['excel'])) {
  7134. $warehouse = $this->input->get('warehouse', true);
  7135. $sku = $this->input->get('sku', true);
  7136. $cz = $this->input->get('cz', true);
  7137. $text = $this->input->post('text', true);
  7138. $xztime = $this->input->get('xztime', true);
  7139. $timetk = $this->input->get('timetk', true);
  7140. $timetj = $this->input->get('timetj', true);
  7141. $timetk = strtotime($timetk);
  7142. $timetj = strtotime($timetj);
  7143. $where = "time = '0' ";
  7144. if ($warehouse) {
  7145. $where .= " and warehouse = '$warehouse'";
  7146. }
  7147. if ($sku) {
  7148. $where .= " and sku = '$sku'";
  7149. }
  7150. if ($text) {
  7151. $where .= " and text like '%$text%'";
  7152. }
  7153. if ($cz != '') {
  7154. $where .= " and cz = '$cz'";
  7155. }
  7156. if ($timetk && $timetj) {
  7157. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7158. }
  7159. //数据排序
  7160. $order_str = $xztime . " desc";
  7161. //取得信息列表
  7162. $zh = array();
  7163. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7164. foreach ($info_list as $v) {
  7165. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7166. $warehouse = $this->warehouse->read($v['warehouse']);
  7167. $v['warehouse'] = $warehouse['title'];
  7168. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7169. $v['stime'] = date('Y-m-d', $v['stime']);
  7170. if (isset($zh[$v['features']])) {
  7171. $zh[$v['features']]['num'] += $v['num'];
  7172. } else {
  7173. $zh[$v['features']] = $v;
  7174. }
  7175. $zh[$v['features']]['features'] = $c;
  7176. }
  7177. $title = "在途数据" . date('Y-m-d', time());
  7178. $titlename = "<table border=1>
  7179. <tr align='center'>
  7180. <td>仓库</td>
  7181. <td>SKU</td>
  7182. <td>名称</td>
  7183. <td>在途数量</td>
  7184. <td>库存数量</td>
  7185. <td>添加在途日期</td>
  7186. <td>预达日期</td>
  7187. <td>备注</td>
  7188. </tr>
  7189. </table>";
  7190. $filename = $title . ".xls";
  7191. $tail = "";
  7192. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7193. }
  7194. }
  7195. public function _fc()
  7196. {
  7197. $vip = 0;
  7198. if (isset($_SESSION['api'])) {
  7199. $user = $this->user->get_api($_SESSION['api']);
  7200. if ($user['vip'] == 1) {
  7201. $vip = 1;
  7202. }
  7203. } else {
  7204. header('Location: /');
  7205. exit;
  7206. }
  7207. $post = $this->input->post(NULL, TRUE);
  7208. if (isset($post['page'])) {
  7209. $page = $this->input->post('page', true);
  7210. $perpage = $this->input->post('perpage', true);
  7211. $category = $this->input->post('category', true);
  7212. $size = $this->input->post('size', true);
  7213. $grade = $this->input->post('grade', true);
  7214. $color = $this->input->post('color', true);
  7215. $lowe = $this->input->post('lowe', true);
  7216. $sku = $this->input->post('sku');
  7217. $title = $this->input->post('title');
  7218. $warehouse = $this->input->post('warehouse', true);
  7219. $usa = $this->input->post('usa', true);
  7220. $purchase = $this->input->post('purchase', true);
  7221. $lacetype = $this->input->post('lacetype', true);
  7222. $haircap = $this->input->post('haircap', true);
  7223. $density = $this->input->post('density', true);
  7224. $details = $this->input->post('details', true);
  7225. $state = $this->input->post('state', true);
  7226. $ktime = $this->input->post('ktime', true);
  7227. $jtime = $this->input->post('jtime', true);
  7228. $ktime = strtotime($ktime);
  7229. $jtime = strtotime($jtime);
  7230. $where = "state = '11'";
  7231. $gj = "";
  7232. $ck = "";
  7233. if ($lacetype) {
  7234. $where .= " and features like '%-$lacetype-%'";
  7235. }
  7236. if ($category) {
  7237. $where .= " and features like '%-$category-%'";
  7238. }
  7239. if ($size) {
  7240. $where .= " and features like '%-$size-%'";
  7241. }
  7242. if ($grade) {
  7243. $where .= " and features like '%-$grade-%'";
  7244. }
  7245. if ($color) {
  7246. $where .= " and features like '%-$color-%'";
  7247. }
  7248. if ($lowe) {
  7249. $where .= " and features like '%-$lowe-%'";
  7250. }
  7251. if ($haircap) {
  7252. $where .= " and features like '%-$haircap-%'";
  7253. }
  7254. if ($density) {
  7255. $where .= " and features like '%-$density-%'";
  7256. }
  7257. if ($usa) {
  7258. if (!$warehouse) {
  7259. $where .= " and (warehouse = '5' or warehouse = '8')";
  7260. }
  7261. }
  7262. if ($warehouse) {
  7263. $where .= " and warehouse = '$warehouse'";
  7264. }
  7265. if ($details) {
  7266. $where .= " and details = '$details'";
  7267. }
  7268. if ($purchase) {
  7269. $where .= " and purchase = '$purchase'";
  7270. }
  7271. if ($state) {
  7272. $where .= " and state = '$state'";
  7273. }
  7274. if ($ktime && $jtime) {
  7275. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7276. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7277. }
  7278. //数据排序
  7279. $order_str = "id desc";
  7280. if (empty($page)) {
  7281. $start = 0;
  7282. $perpage = 1;
  7283. } else {
  7284. $start = ($page - 1) * $perpage;
  7285. }
  7286. if ($sku) {
  7287. $sku = trim($sku, ' ');
  7288. $sku = trim($sku, ' ');
  7289. $where .= " and sku like '%$sku%'";
  7290. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7291. } else if ($title) {
  7292. $title = trim($title, ' ');
  7293. $title = trim($title, ' ');
  7294. $where .= " and title like '%$title%'";
  7295. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7296. } else {
  7297. //$where .= " and time > '$ktime' and time < '$jtime'";
  7298. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7299. }
  7300. //取得信息列表
  7301. $rows = array();
  7302. $list = array();
  7303. foreach ($info_list as $key => $value) {
  7304. $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'] . '"');
  7305. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7306. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7307. $warehouse = $this->warehouse->read($value['warehouse']);
  7308. $info_list[$key]['warehouse'] = $warehouse['title'];
  7309. $info_list[$key]['number'] = $g;
  7310. $info_list[$key]['features'] = $x;
  7311. $info_list[$key]['x'] = $s;
  7312. }
  7313. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7314. $pagenum = ceil($total / $perpage);
  7315. $over = $total - ($start + $perpage);
  7316. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7317. echo json_encode($rows);
  7318. exit;
  7319. }
  7320. $this->data['vip'] = $vip;
  7321. $this->_Template('whlabel_fc', $this->data);
  7322. }
  7323. public function _fcmb()
  7324. {
  7325. $where = "sku != 'Preset'";
  7326. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7327. foreach ($rows as $k => $v) {
  7328. $warehouse = $this->warehouse->read($v['warehouse']);
  7329. $rows[$k]['warehouse'] = $warehouse['title'];
  7330. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7331. $rows[$k]['t'] = '';
  7332. $rows[$k]['n'] = '';
  7333. }
  7334. $title = "封货产品数据导入模板";
  7335. $titlename = "<table border=1>
  7336. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7337. <tr align='center'>
  7338. <td>仓库</td>
  7339. <td>SKU</td>
  7340. <td>产品</td>
  7341. <td>封存产品总数量</td>
  7342. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7343. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7344. </tr>
  7345. </table>";
  7346. $filename = $title . ".xls";
  7347. $tail = "";
  7348. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7349. }
  7350. public function _fcexcel()
  7351. {
  7352. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7353. $config['upload_path'] = '.' . $dir;
  7354. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7355. $config['allowed_types'] = 'xls|xlsx|csv';
  7356. $config['max_size'] = 10240;
  7357. $this->load->library('upload', $config);
  7358. $this->upload->initialize($config);
  7359. if ($this->upload->do_upload('userfile')) {
  7360. $full_path = $dir . $this->upload->data('file_name');
  7361. $fileName = '.' . $full_path;
  7362. if (!file_exists($fileName)) {
  7363. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7364. exit;
  7365. } else {
  7366. libxml_use_internal_errors(true);
  7367. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7368. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7369. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7370. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7371. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7372. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7373. ++$column; //如果列数大于26行
  7374. $list = array();
  7375. for ($i = 2; $i <= $row; $i++) // 行数循环
  7376. {
  7377. $data = array();
  7378. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7379. {
  7380. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7381. }
  7382. $list[] = $data;
  7383. }
  7384. }
  7385. $i = 0;
  7386. $j = 0;
  7387. $ed = array();
  7388. foreach ($list as $key => $value) {
  7389. $time = time();
  7390. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7391. continue;
  7392. }
  7393. $warehouse = $this->warehouse->get_title($value['0']);
  7394. $sku = $value['1'];
  7395. $type = $value['4']; //调整方式0扣减1删除
  7396. $num = $value['5']; //调整数量
  7397. //$text = $value['4'];//扣减说明
  7398. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7399. if (!$d) //如果没有这个SKU
  7400. {
  7401. $ed[] = array($sku . '-库存中不存在此SKU');
  7402. $j++;
  7403. continue;
  7404. }
  7405. if (!isset($warehouse['id'])) {
  7406. $ed[] = array($sku . '-仓库名错误!');
  7407. $j++;
  7408. continue;
  7409. }
  7410. if ($type == 1 || $type == 2) //扣减库存
  7411. {
  7412. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7413. if (count($data) < abs($num)) {
  7414. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7415. $j++;
  7416. continue;
  7417. }
  7418. if ($type == 1) //转入库存
  7419. {
  7420. for ($i = 0; $i < abs($num); $i++) {
  7421. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7422. }
  7423. } else if ($type == 2) //删除
  7424. {
  7425. for ($i = 0; $i < abs($num); $i++) {
  7426. $this->whlabel->remove($data[$i]['id']);
  7427. }
  7428. }
  7429. } else if ($type == 0) //增加库存
  7430. {
  7431. $post['sku'] = $d['sku'];
  7432. $post['shop'] = '';
  7433. $post['warehouse'] = $warehouse['id'];
  7434. $post['purchase'] = $d['purchase'];
  7435. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7436. $post['state'] = 11;
  7437. $post['title'] = $d['title'];
  7438. $post['number'] = $d['number'];
  7439. $post['features'] = $d['features'];
  7440. $post['enter'] = $time;
  7441. $post['time'] = $time; //操作时间
  7442. for ($i = 0; $i < $num; $i++) {
  7443. $post['label'] = time() . rand(100, 999) . $i;
  7444. $this->whlabel->insert($post);
  7445. }
  7446. }
  7447. sleep(1); //防止入库时间一样,需要延迟1秒
  7448. }
  7449. if ($j > 0) {
  7450. $tt = date('Ymd', time());
  7451. $title = '库存导入错误信息-' . $tt;
  7452. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7453. $tail = "\n";
  7454. $filename = $title . ".xls";
  7455. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7456. $dir = '/data/excel/' . $time . '/';
  7457. $file_name = 'error_' . $time . rand(1000, 9999);
  7458. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7459. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7460. fwrite($myfile, $ecl);
  7461. fclose($myfile);
  7462. $error = $dir . $file_name . '.xls';
  7463. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7464. exit;
  7465. } else {
  7466. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7467. exit;
  7468. }
  7469. }
  7470. }
  7471. public function _fcjxc($arg_array)
  7472. {
  7473. if (isset($_GET['excel'])) {
  7474. $category = $this->input->get('category', true);
  7475. $size = $this->input->get('size', true);
  7476. $grade = $this->input->get('grade', true);
  7477. $color = $this->input->get('color', true);
  7478. $lowe = $this->input->get('lowe', true);
  7479. $sku = $this->input->get('sku');
  7480. $title = $this->input->get('title');
  7481. $warehouse = $arg_array[0];
  7482. $usa = $this->input->get('usa', true);
  7483. $purchase = $this->input->get('purchase', true);
  7484. $lacetype = $this->input->get('lacetype', true);
  7485. $haircap = $this->input->get('haircap', true);
  7486. $density = $this->input->get('density', true);
  7487. $title = $this->input->get('title', true);
  7488. $state = $this->input->get('state', true);
  7489. $ktime = $this->input->get('ktime', true);
  7490. $jtime = $this->input->get('jtime', true);
  7491. $where = "state=11";
  7492. $gj = "";
  7493. $ck = "";
  7494. if ($lacetype) {
  7495. $where .= " and features like '%-$lacetype-%'";
  7496. }
  7497. if ($category) {
  7498. $where .= " and features like '%-$category-%'";
  7499. }
  7500. if ($size) {
  7501. $where .= " and features like '%-$size-%'";
  7502. }
  7503. if ($grade) {
  7504. $where .= " and features like '%-$grade-%'";
  7505. }
  7506. if ($color) {
  7507. $where .= " and features like '%-$color-%'";
  7508. }
  7509. if ($lowe) {
  7510. $where .= " and features like '%-$lowe-%'";
  7511. }
  7512. if ($haircap) {
  7513. $where .= " and features like '%-$haircap-%'";
  7514. }
  7515. if ($density) {
  7516. $where .= " and features like '%-$density-%'";
  7517. }
  7518. if ($usa) {
  7519. if (!$warehouse) {
  7520. $where .= " and (warehouse = '5' or warehouse = '8')";
  7521. }
  7522. }
  7523. if ($warehouse) {
  7524. $where .= " and warehouse = '$warehouse'";
  7525. }
  7526. if ($purchase) {
  7527. $where .= " and purchase = '$purchase'";
  7528. }
  7529. if ($state) {
  7530. $where .= " and state = '$state'";
  7531. }
  7532. $order_str = "id desc";
  7533. if ($sku) {
  7534. $sku = trim($sku, ' ');
  7535. $sku = trim($sku, ' ');
  7536. $where .= " and sku like '%$sku%'";
  7537. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7538. } else if ($title) {
  7539. $title = trim($title, ' ');
  7540. $title = trim($title, ' ');
  7541. $where .= " and title like '%$title%'";
  7542. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7543. } else {
  7544. //$where .= " and time > '$ktime' and time < '$jtime'";
  7545. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7546. }
  7547. //取得信息列表
  7548. $rows = array();
  7549. $list = array();
  7550. foreach ($info_list as $key => $value) {
  7551. $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'] . '"');
  7552. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7553. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7554. $rows[$key] = $value;
  7555. $warehouse = $this->warehouse->read($value['warehouse']);
  7556. $rows[$key]['warehouse'] = $warehouse['title'];
  7557. $rows[$key]['features'] = $g;
  7558. $rows[$key]['a'] = $x;
  7559. $rows[$key]['b'] = $s;
  7560. }
  7561. $title = "总统计表";
  7562. $titlename = "<table border=1>
  7563. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7564. <tr align='center'>
  7565. <td>仓库</td>
  7566. <td>SKU</td>
  7567. <td>产品名称</td>
  7568. <td>录入总量</td>
  7569. <td>取出总量</td>
  7570. <td>剩余总量</td>
  7571. </tr>
  7572. </table>";
  7573. $filename = $title . ".xls";
  7574. $tail = "";
  7575. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7576. }
  7577. $vip = 0;
  7578. if (isset($_SESSION['api'])) {
  7579. $user = $this->user->get_api($_SESSION['api']);
  7580. if ($user['vip'] == 1) {
  7581. $vip = 1;
  7582. }
  7583. } else {
  7584. header('Location: /');
  7585. exit;
  7586. }
  7587. $post = $this->input->post(NULL, TRUE);
  7588. if (isset($post['page'])) {
  7589. $page = $this->input->post('page', true);
  7590. $perpage = $this->input->post('perpage', true);
  7591. $category = $this->input->post('category', true);
  7592. $size = $this->input->post('size', true);
  7593. $grade = $this->input->post('grade', true);
  7594. $color = $this->input->post('color', true);
  7595. $lowe = $this->input->post('lowe', true);
  7596. $sku = $this->input->post('sku');
  7597. $title = $this->input->post('title');
  7598. $warehouse = $arg_array[0];
  7599. $usa = $this->input->post('usa', true);
  7600. $purchase = $this->input->post('purchase', true);
  7601. $lacetype = $this->input->post('lacetype', true);
  7602. $haircap = $this->input->post('haircap', true);
  7603. $density = $this->input->post('density', true);
  7604. $title = $this->input->post('title', true);
  7605. $state = $this->input->post('state', true);
  7606. $ktime = $this->input->post('ktime', true);
  7607. $jtime = $this->input->post('jtime', true);
  7608. $ktime = strtotime($ktime);
  7609. $jtime = strtotime($jtime);
  7610. $where = "state=11";
  7611. $gj = "";
  7612. $ck = "";
  7613. if ($lacetype) {
  7614. $where .= " and features like '%-$lacetype-%'";
  7615. }
  7616. if ($category) {
  7617. $where .= " and features like '%-$category-%'";
  7618. }
  7619. if ($size) {
  7620. $where .= " and features like '%-$size-%'";
  7621. }
  7622. if ($grade) {
  7623. $where .= " and features like '%-$grade-%'";
  7624. }
  7625. if ($color) {
  7626. $where .= " and features like '%-$color-%'";
  7627. }
  7628. if ($lowe) {
  7629. $where .= " and features like '%-$lowe-%'";
  7630. }
  7631. if ($haircap) {
  7632. $where .= " and features like '%-$haircap-%'";
  7633. }
  7634. if ($density) {
  7635. $where .= " and features like '%-$density-%'";
  7636. }
  7637. if ($usa) {
  7638. if (!$warehouse) {
  7639. $where .= " and (warehouse = '5' or warehouse = '8')";
  7640. }
  7641. }
  7642. if ($warehouse) {
  7643. $where .= " and warehouse = '$warehouse'";
  7644. }
  7645. if ($purchase) {
  7646. $where .= " and purchase = '$purchase'";
  7647. }
  7648. if ($state) {
  7649. $where .= " and state = '$state'";
  7650. }
  7651. if ($ktime && $jtime) {
  7652. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7653. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7654. }
  7655. //数据排序
  7656. $order_str = "id desc";
  7657. $xs = 0;
  7658. $rows = array();
  7659. $list = array();
  7660. if (empty($page)) {
  7661. $start = 0;
  7662. $perpage = 1;
  7663. } else {
  7664. $start = ($page - 1) * $perpage;
  7665. }
  7666. if ($sku || $title) {
  7667. if ($title) {
  7668. $title = trim($title, ' ');
  7669. $title = trim($title, ' ');
  7670. $where .= " and title like '%$title%'";
  7671. } else {
  7672. $sku = trim($sku, ' ');
  7673. $sku = trim($sku, ' ');
  7674. $where .= " and sku like '%$sku%'";
  7675. }
  7676. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7677. foreach ($info_list as $key => $value) {
  7678. $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'] . '"');
  7679. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7680. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7681. $rows[$key] = $value;
  7682. $warehouse = $this->warehouse->read($value['warehouse']);
  7683. $rows[$key]['warehouse'] = $warehouse['title'];
  7684. $rows[$key]['features'] = $g;
  7685. $rows[$key]['a'] = $x;
  7686. $rows[$key]['b'] = $s;
  7687. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7688. $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天销量
  7689. $yj = $c / ($xl / 30);
  7690. if ($yj < 7) {
  7691. $rows[$key]['y'] = round($yj) . '天销量';
  7692. } else {
  7693. $rows[$key]['y'] = '正常';
  7694. }
  7695. }
  7696. } else {
  7697. //$where .= " and time > '$ktime' and time < '$jtime'";
  7698. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7699. foreach ($info_list as $key => $value) {
  7700. $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'] . '"');
  7701. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7702. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7703. $zs[$key] = $value;
  7704. $warehouse = $this->warehouse->read($value['warehouse']);
  7705. $zs[$key]['warehouse'] = $warehouse['title'];
  7706. $zs[$key]['features'] = $g;
  7707. $zs[$key]['a'] = $x;
  7708. $zs[$key]['b'] = $s;
  7709. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7710. $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天销量
  7711. $yj = $c / ($xl / 30);
  7712. if ($yj < 7) {
  7713. $zs[$key]['y'] = round($yj) . '天销量';
  7714. $rows[$key] = $zs[$key];
  7715. }
  7716. }
  7717. }
  7718. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7719. $pagenum = ceil($total / $perpage);
  7720. $over = $total - ($start + $perpage);
  7721. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7722. echo json_encode($rows);
  7723. exit;
  7724. }
  7725. $this->data['arg_array'] = $arg_array[0];
  7726. $this->_Template('whlabel_fcjxc', $this->data);
  7727. }
  7728. public function _0kcdel()
  7729. {
  7730. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7731. $config['upload_path'] = '.' . $dir;
  7732. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7733. $config['allowed_types'] = 'xls|xlsx|csv';
  7734. $config['max_size'] = 10240;
  7735. $this->load->library('upload', $config);
  7736. $this->upload->initialize($config);
  7737. if ($this->upload->do_upload('userfile')) {
  7738. $full_path = $dir . $this->upload->data('file_name');
  7739. $fileName = '.' . $full_path;
  7740. if (!file_exists($fileName)) {
  7741. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7742. exit;
  7743. } else {
  7744. require_once "./data/excel/PHPExcel/IOFactory.php";
  7745. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7746. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7747. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7748. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7749. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7750. ++$column; //如果列数大于26行
  7751. $list = array();
  7752. for ($i = 2; $i <= $row; $i++) // 行数循环
  7753. {
  7754. $data = array();
  7755. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7756. {
  7757. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7758. }
  7759. $list[] = $data;
  7760. }
  7761. }
  7762. $i = 0;
  7763. $j = 0;
  7764. $ed = array();
  7765. foreach ($list as $key => $value) {
  7766. $time = time();
  7767. if ($value['0'] == "" || $value['1'] == "") {
  7768. continue;
  7769. }
  7770. $warehouse = $this->warehouse->get_title($value['0']);
  7771. $sku = $value['1'];
  7772. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7773. if (!$d) //如果没有这个SKU
  7774. {
  7775. $ed[] = array($sku . '-库存中不存在此SKU');
  7776. $j++;
  7777. continue;
  7778. }
  7779. if (!isset($warehouse['id'])) {
  7780. $ed[] = array($sku . '-仓库名错误!');
  7781. $j++;
  7782. continue;
  7783. }
  7784. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7785. if ($z < 1) {
  7786. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7787. foreach ($z as $v) {
  7788. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7789. if (count($zt) > 0) {
  7790. $ed[] = array($sku . '-有在途库存无法删除!');
  7791. $j++;
  7792. continue;
  7793. }
  7794. $this->whlabel->remove($v['id']);
  7795. }
  7796. } else {
  7797. $ed[] = array($sku . '-非0库存!');
  7798. $j++;
  7799. continue;
  7800. }
  7801. }
  7802. if ($j > 0) {
  7803. $tt = date('Ymd', time());
  7804. $title = '删除0库存错误信息-' . $tt;
  7805. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7806. $tail = "\n";
  7807. $filename = $title . ".xls";
  7808. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7809. $dir = '/data/excel/' . $time . '/';
  7810. $file_name = 'error_' . $time . rand(1000, 9999);
  7811. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7812. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7813. fwrite($myfile, $ecl);
  7814. fclose($myfile);
  7815. $error = $dir . $file_name . '.xls';
  7816. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7817. exit;
  7818. } else {
  7819. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7820. exit;
  7821. }
  7822. }
  7823. }
  7824. public function _gbhtype()
  7825. {
  7826. $post = $this->input->post(NULL, TRUE);
  7827. if (isset($post['s'])) {
  7828. $n = $this->input->post('n');
  7829. $d = $this->input->post('s');
  7830. if (!$d) {
  7831. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7832. exit;
  7833. }
  7834. $d = explode(',', trim($d, ','));
  7835. $t = $this->whlabel_type->read($n);
  7836. //循环删除记录
  7837. foreach ($d as $v) {
  7838. $u = $this->whlabel->read($v);
  7839. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7840. foreach ($data as $val) {
  7841. $this->whlabel->save(array('type' => $n), $val['id']);
  7842. }
  7843. }
  7844. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7845. }
  7846. }
  7847. //出库、退库导出
  7848. public function _dccrtype()
  7849. {
  7850. $classid = $this->classid->sku();
  7851. $pm = $classid;
  7852. $typeclass = array();
  7853. $tc = $this->typeclass->find_all();
  7854. foreach ($tc as $v) {
  7855. $typeclass[$v['id']] = $v;
  7856. }
  7857. $prc = array();
  7858. $purchase = $this->purchase->find_all();
  7859. foreach ($purchase as $k => $v) {
  7860. $prc[$v['id']] = $v['title'];
  7861. }
  7862. if (isset($_GET['sid'])) {
  7863. $wh = array();
  7864. $w = $this->warehouse->find_all('1=1', 'id,title');
  7865. foreach ($w as $v) {
  7866. $wh[$v['id']] = $v['title'];
  7867. }
  7868. $type = $this->input->get('excel', true);
  7869. $category = $this->input->get('category', true);
  7870. $size = $this->input->get('size', true);
  7871. $grade = $this->input->get('grade', true);
  7872. $color = $this->input->get('color', true);
  7873. $lowe = $this->input->get('lowe', true);
  7874. $sku = $this->input->get('sku', true);
  7875. $warehouse = $this->input->get('warehouse', true);
  7876. $lacetype = $this->input->get('lacetype', true);
  7877. $lacecolor = $this->input->get('lacecolor', true);
  7878. $density = $this->input->get('density', true);
  7879. $haircap = $this->input->get('haircap', true);
  7880. $purchase = $this->input->get('purchase', true);
  7881. $title = $this->input->get('title', true);
  7882. $state = $this->input->get('state', true);
  7883. $sid = $this->input->get('sid', true);
  7884. $ktime = $this->input->get('ktime', true);
  7885. $jtime = $this->input->get('jtime', true);
  7886. $ktime = strtotime($ktime);
  7887. $jtime = strtotime($jtime);
  7888. $where = "1=1";
  7889. $gj = "";
  7890. $ck = "";
  7891. if ($category) {
  7892. $where .= " and features like '%-$category-%'";
  7893. }
  7894. if ($size) {
  7895. $where .= " and features like '%-$size-%'";
  7896. }
  7897. if ($grade) {
  7898. $where .= " and features like '%-$grade-%'";
  7899. }
  7900. if ($color) {
  7901. $where .= " and features like '%-$color-%'";
  7902. }
  7903. if ($lowe) {
  7904. $where .= " and features like '%-$lowe-%'";
  7905. }
  7906. if ($warehouse) {
  7907. $where .= " and warehouse = '$warehouse'";
  7908. }
  7909. if ($purchase) {
  7910. $where .= " and purchase = '$purchase'";
  7911. }
  7912. if ($state) {
  7913. $where .= " and state = '$state'";
  7914. }
  7915. if ($lacetype) {
  7916. $where .= " and features like '%-$lacetype-%'";
  7917. }
  7918. if ($lacecolor) {
  7919. $where .= " and features like '%-$lacecolor-%'";
  7920. }
  7921. if ($density) {
  7922. $where .= " and features like '%-$density-%'";
  7923. }
  7924. if ($haircap) {
  7925. $where .= " and features like '%-$haircap-%'";
  7926. }
  7927. if ($title) {
  7928. $title = trim($title, ' ');
  7929. $title = trim($title, ' ');
  7930. $where .= " and title like '%$title%'";
  7931. }
  7932. if ($sku) {
  7933. $sku = trim($sku, ' ');
  7934. $sku = trim($sku, ' ');
  7935. $where .= " and sku like '%$sku%'";
  7936. }
  7937. if ($ktime && $jtime) {
  7938. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7939. }
  7940. $sidwhere = '';
  7941. if ($sid) {
  7942. $sd = "";
  7943. $s = explode(',', trim($sid, ','));
  7944. foreach ($s as $value) {
  7945. $sd .= " id = " . $value . " or";
  7946. }
  7947. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7948. }
  7949. //数据排序
  7950. $order_str = "time desc";
  7951. if (empty($page)) {
  7952. $start = 0;
  7953. $perpage = 1;
  7954. } else {
  7955. $start = ($page - 1) * $perpage;
  7956. }
  7957. $wh = array();
  7958. $w = $this->warehouse->find_all('1=1', 'id,title');
  7959. foreach ($w as $v) {
  7960. $wh[$v['id']] = $v['title'];
  7961. }
  7962. $wt = array();
  7963. $whlabel_type = $this->whlabel_type->find_all();
  7964. foreach ($whlabel_type as $v) {
  7965. $wt[$v['id']] = $v['title'];
  7966. }
  7967. $classid = $this->classid->sku();
  7968. $list = array();
  7969. $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');
  7970. foreach ($rows_r as $key => $value) {
  7971. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7972. $pm = $classid;
  7973. $jm = $classid;
  7974. $rows_r[$key]['enter'] = '入库';
  7975. $rows_r[$key]['time'] = $value['enter'];
  7976. if ($value['rktype'] == 1) {
  7977. $rows_r[$key]['rktype'] = '采购入库';
  7978. } else if ($value['rktype'] == 2) {
  7979. $rows_r[$key]['rktype'] = '盘盈调整';
  7980. } else if ($value['rktype'] == 3) {
  7981. $rows_r[$key]['rktype'] = '其他调整入库';
  7982. } else if ($value['rktype'] == 4) {
  7983. $rows_r[$key]['rktype'] = '其他调整入库';
  7984. } else if ($value['rktype'] == 5) {
  7985. $rows_r[$key]['rktype'] = '退库入库';
  7986. } else if ($value['rktype'] == 6) {
  7987. $rows_r[$key]['rktype'] = '退货可用入库';
  7988. } else if ($value['rktype'] == 7) {
  7989. $rows_r[$key]['rktype'] = '形态转换入库';
  7990. } else {
  7991. $rows_r[$key]['rktype'] = '';
  7992. }
  7993. $features = explode('-', trim($value['features'], '-'));
  7994. foreach ($features as $v) {
  7995. if (isset($typeclass[$v])) {
  7996. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7997. $pm[$typeclass[$v]['classid']] = $zh[0];
  7998. }
  7999. if (isset($typeclass[$v])) {
  8000. if (isset($jm[$typeclass[$v]['classid']])) {
  8001. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8002. }
  8003. }
  8004. }
  8005. $zh = implode(" ", $pm);
  8006. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8007. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8008. $rows_r[$key]['zh'] = $zh;
  8009. $jm = array_filter($jm);
  8010. $rows_r[$key]['features'] = implode("-", $jm);
  8011. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8012. }
  8013. $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');
  8014. foreach ($rows_c as $key => $value) {
  8015. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8016. $pm = $classid;
  8017. $jm = $classid;
  8018. $rows_c[$key]['time'] = $value['outk'];
  8019. $rows_c[$key]['outk'] = '出库';
  8020. if ($value['cktype'] == 1) {
  8021. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8022. } else if ($value['cktype'] == 2) {
  8023. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8024. } else if ($value['cktype'] == 3) {
  8025. $rows_c[$key]['cktype'] = '盘亏调整';
  8026. } else if ($value['cktype'] == 4) {
  8027. $rows_c[$key]['cktype'] = '其他调整出库';
  8028. } else if ($value['cktype'] == 5) {
  8029. $rows_c[$key]['cktype'] = '形态转换出库';
  8030. } else {
  8031. $rows_c[$key]['cktype'] = '';
  8032. }
  8033. unset($rows_c[$key]['state']);
  8034. $features = explode('-', trim($value['features'], '-'));
  8035. foreach ($features as $v) {
  8036. if (isset($typeclass[$v])) {
  8037. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8038. $pm[$typeclass[$v]['classid']] = $zh[0];
  8039. }
  8040. if (isset($typeclass[$v])) {
  8041. if (isset($jm[$typeclass[$v]['classid']])) {
  8042. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8043. }
  8044. }
  8045. }
  8046. $zh = implode(" ", $pm);
  8047. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8048. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8049. $rows_c[$key]['zh'] = $zh;
  8050. $jm = array_filter($jm);
  8051. $rows_c[$key]['features'] = implode("-", $jm);
  8052. $rows_c[$key]['number'] = 1;
  8053. }
  8054. $merged = $rows_r;
  8055. foreach ($rows_c as $key => $value) {
  8056. if (isset($merged[$key])) {
  8057. $merged[] = $value;
  8058. } else {
  8059. $merged[$key] = $value;
  8060. }
  8061. }
  8062. usort($merged, function ($a, $b) {
  8063. return $a['time'] - $b['time'];
  8064. });
  8065. foreach ($merged as $key => $value) {
  8066. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8067. }
  8068. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8069. $titlename = "<table border=1>
  8070. <tr align='center'>
  8071. <td>仓库</td>
  8072. <td>SKU</td>
  8073. <td>商品名称</td>
  8074. <td>仓库品名</td>
  8075. <td>料号</td>
  8076. <td>时间</td>
  8077. <td>操作</td>
  8078. <td>类型</td>
  8079. <td>数量</td>
  8080. <td>备注</td>
  8081. </tr>
  8082. </table>";
  8083. $filename = $title . ".xlsx";
  8084. $tail = "";
  8085. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8086. }
  8087. }
  8088. /*************************************处理exceljs导出****************************************************/
  8089. public function _excelrjs(){
  8090. if (isset($_GET['excel'])) {
  8091. $category = $this->input->get('category', true);
  8092. $size = $this->input->get('size', true);
  8093. $grade = $this->input->get('grade', true);
  8094. $color = $this->input->get('color', true);
  8095. $lowe = $this->input->get('lowe', true);
  8096. $sku = $this->input->get('sku', true);
  8097. $warehouse = $this->input->get('warehouse', true);
  8098. $purchase = $this->input->get('purchase', true);
  8099. $ktime = $this->input->get('ktime', true);
  8100. $jtime = $this->input->get('jtime', true);
  8101. $ktime = strtotime($ktime);
  8102. $jtime = strtotime($jtime);
  8103. $where = "1=1";
  8104. $gj = "";
  8105. $ck = "";
  8106. if ($category) {
  8107. $where .= " and features like '%-$category-%'";
  8108. }
  8109. if ($size) {
  8110. $where .= " and features like '%-$size-%'";
  8111. }
  8112. if ($grade) {
  8113. $where .= " and features like '%-$grade-%'";
  8114. }
  8115. if ($color) {
  8116. $where .= " and features like '%-$color-%'";
  8117. }
  8118. if ($lowe) {
  8119. $where .= " and features like '%-$lowe-%'";
  8120. }
  8121. if ($warehouse) {
  8122. $where .= " and warehouse = '$warehouse'";
  8123. }
  8124. if ($purchase) {
  8125. $where .= " and purchase = '$purchase'";
  8126. }
  8127. if ($sku) {
  8128. $where .= " and sku = '$sku'";
  8129. }
  8130. if ($ktime && $jtime) {
  8131. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8132. }
  8133. //数据排序
  8134. $order_str = "id desc";
  8135. if (empty($page)) {
  8136. $start = 0;
  8137. $perpage = 1;
  8138. } else {
  8139. $start = ($page - 1) * $perpage;
  8140. }
  8141. $list = array();
  8142. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8143. foreach ($rows as $value) {
  8144. $ck = $this->warehouse->read($value['warehouse']);
  8145. $warehouse = $ck['title'];
  8146. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8147. $retreatwarehouse = $tkck['title'];
  8148. $gy = $this->purchase->read($value['purchase']);
  8149. $purchase = $gy['title'];
  8150. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8151. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8152. }
  8153. if(empty($list)){
  8154. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8155. }else{
  8156. $final_list = [];
  8157. foreach($list as $v){
  8158. $final_list[] = array_values($v);
  8159. }
  8160. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8161. array_unshift($final_list,[
  8162. "仓库","SKU","商品名称","时间","数量"
  8163. ]);
  8164. array_unshift($final_list,[
  8165. $title,"","","",""
  8166. ]);
  8167. $merges = [
  8168. [
  8169. "s"=>["r"=>0,"c"=>0],
  8170. "e"=>["r"=>0,"c"=>4]
  8171. ]
  8172. ];
  8173. $cols = [
  8174. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8175. ];
  8176. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8177. }
  8178. }
  8179. }
  8180. //出库、退库导出
  8181. public function _excelctjs()
  8182. {
  8183. $classid = $this->classid->sku();
  8184. $pm = $classid;
  8185. $typeclass = array();
  8186. $tc = $this->typeclass->find_all();
  8187. foreach ($tc as $v) {
  8188. $typeclass[$v['id']] = $v;
  8189. }
  8190. $prc = array();
  8191. $purchase = $this->purchase->find_all();
  8192. foreach ($purchase as $k => $v) {
  8193. $prc[$v['id']] = $v['title'];
  8194. }
  8195. if (isset($_GET['excel'])) {
  8196. $wh = array();
  8197. $w = $this->warehouse->find_all('1=1', 'id,title');
  8198. foreach ($w as $v) {
  8199. $wh[$v['id']] = $v['title'];
  8200. }
  8201. $type = $this->input->get('excel', true);
  8202. $category = $this->input->get('category', true);
  8203. $size = $this->input->get('size', true);
  8204. $grade = $this->input->get('grade', true);
  8205. $color = $this->input->get('color', true);
  8206. $lowe = $this->input->get('lowe', true);
  8207. $sku = $this->input->get('sku', true);
  8208. $title = $this->input->get('title', true);
  8209. $warehouse = $this->input->get('warehouse', true);
  8210. $purchase = $this->input->get('purchase', true);
  8211. $lacetype = $this->input->get('lacetype', true);
  8212. $haircap = $this->input->get('haircap', true);
  8213. $lacecolor = $this->input->get('lacecolor', true);
  8214. $density = $this->input->get('density', true);
  8215. $details = $this->input->get('details', true);
  8216. $state = $this->input->get('state', true);
  8217. $shop = $this->input->get('shop', true);
  8218. $hairnumber = $this->input->get('hairnumber', true);
  8219. $type_leixi = $this->input->get('type', true);
  8220. $cpbz = $this->input->get('cpbz', true);
  8221. $sm = $this->input->get('sm', true);
  8222. $sid = $this->input->get('sid', true);
  8223. $ktime = $this->input->get('ktime', true);
  8224. $jtime = $this->input->get('jtime', true);
  8225. $ktime = strtotime($ktime);
  8226. $jtime = strtotime($jtime);
  8227. //$where = " 1=1 ";
  8228. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8229. $where = " sku != '' ";
  8230. $gj = "";
  8231. $ck = "";
  8232. if ($category) {
  8233. $where .= " and features like '%-$category-%'";
  8234. }
  8235. if ($size) {
  8236. $where .= " and features like '%-$size-%'";
  8237. }
  8238. if ($grade) {
  8239. $where .= " and features like '%-$grade-%'";
  8240. }
  8241. if ($color) {
  8242. $where .= " and features like '%-$color-%'";
  8243. }
  8244. if ($lowe) {
  8245. $where .= " and features like '%-$lowe-%'";
  8246. }
  8247. if ($warehouse) {
  8248. $where .= " and warehouse = '$warehouse'";
  8249. }
  8250. if ($purchase) {
  8251. $where .= " and purchase = '$purchase'";
  8252. }
  8253. if ($state) {
  8254. $where .= " and state = '$state'";
  8255. }
  8256. if ($lacetype) {
  8257. $where .= " and features like '%-$lacetype-%'";
  8258. }
  8259. if ($lacecolor) {
  8260. $where .= " and features like '%-$lacecolor-%'";
  8261. }
  8262. if ($density) {
  8263. $where .= " and features like '%-$density-%'";
  8264. }
  8265. if ($haircap) {
  8266. $where .= " and features like '%-$haircap-%'";
  8267. }
  8268. if ($details) {
  8269. $where .= " and details = '$details'";
  8270. }
  8271. if ($shop) {
  8272. $where .= " and shop like '%$shop%'";
  8273. }
  8274. if ($title) {
  8275. $title = trim($title, ' ');
  8276. $title = trim($title, ' ');
  8277. $where .= " and title like '%$title%'";
  8278. }
  8279. if (!empty($hairnumber)) {
  8280. $where .= " and features like '%-128-%' ";
  8281. if ($hairnumber < 0) {
  8282. $class_list = $this->typeclass->find_all('classid = 43');
  8283. foreach ($class_list as $v) {
  8284. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8285. }
  8286. } else {
  8287. $where .= " and features like '%-$hairnumber-%'";
  8288. }
  8289. }
  8290. if ($type_leixi) {
  8291. $where .= " and type = '$type_leixi'";
  8292. }
  8293. if ($cpbz) {
  8294. $where .= " and cpbz like '%$cpbz%' ";
  8295. }
  8296. if ($sm) {
  8297. $where .= " and sm like '%$sm%' ";
  8298. }
  8299. if ($sku) {
  8300. $sku = trim($sku, ' ');
  8301. $sku = trim($sku, ' ');
  8302. $where .= " and sku like '%$sku%'";
  8303. }
  8304. if ($ktime && $jtime) {
  8305. if ($type == 1) {
  8306. $tl = '出库';
  8307. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8308. } else if ($type == 2) {
  8309. $tl = '退库';
  8310. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8311. } else if ($type == 3) {
  8312. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8313. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8314. } else if ($type == 4) {
  8315. $tl = '出库+零售';
  8316. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8317. } else if ($type == 5) {
  8318. $tl = '零售';
  8319. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8320. }
  8321. }
  8322. $sidwhere = '';
  8323. if ($sid) {
  8324. $sd = "";
  8325. $s = explode(',', trim($sid, ','));
  8326. foreach ($s as $value) {
  8327. $sd .= " id = " . $value . " or";
  8328. }
  8329. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8330. }
  8331. //数据排序
  8332. $order_str = "time desc";
  8333. if (empty($page)) {
  8334. $start = 0;
  8335. $perpage = 1;
  8336. } else {
  8337. $start = ($page - 1) * $perpage;
  8338. }
  8339. //取得信息列表
  8340. if ($type != 3 && $type != 5) {
  8341. if ($type == 1 || $type == 4) {
  8342. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8343. foreach ($info_list as $key => $value) {
  8344. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8345. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8346. $warehouse = $this->warehouse->read($value['warehouse']);
  8347. $info_list[$key]['warehouse'] = $warehouse['title'];
  8348. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8349. $features = explode('-', trim($features, '-'));
  8350. $pm = $classid;
  8351. foreach ($features as $k => $v) {
  8352. if ($v != 0) {
  8353. if (!isset($typeclass[$v])) {
  8354. continue;
  8355. }
  8356. if (isset($pm[$typeclass[$v]['classid']])) {
  8357. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8358. $tz = explode('|', $typeclass[$v]['zh']);
  8359. $pm[$typeclass[$v]['classid']] = $tz[0];
  8360. } else {
  8361. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8362. }
  8363. }
  8364. }
  8365. }
  8366. $zh = implode(" ", $pm);
  8367. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8368. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8369. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8370. $info_list[$key]['features'] = $zh;
  8371. }
  8372. $final_list = [];
  8373. foreach($info_list as $k=>$v){
  8374. $number = "";
  8375. if(!empty($v['orderinfo'])){
  8376. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8377. if(!empty($tmp_info['number'])){
  8378. $number = $tmp_info['number'];
  8379. }
  8380. }
  8381. $final_list[] = [
  8382. 'warehouse'=>$v['warehouse'],
  8383. 'purchase'=>$v['purchase'],
  8384. 'sku'=>$v['sku'],
  8385. 'title'=>$v['title'],
  8386. 'features'=>$v['features'],
  8387. 'label'=>$v['label'],
  8388. 'orderinfo'=>$v['orderinfo'],
  8389. 'number'=>$number,
  8390. 'waybill'=>$v['waybill'],
  8391. 'outk'=>$v['outk'],
  8392. ];
  8393. }
  8394. } else {
  8395. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8396. foreach ($info_list as $key => $value) {
  8397. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8398. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8399. $warehouse = $this->warehouse->read($value['warehouse']);
  8400. $info_list[$key]['warehouse'] = $warehouse['title'];
  8401. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8402. $features = explode('-', trim($features, '-'));
  8403. $pm = $classid;
  8404. foreach ($features as $k => $v) {
  8405. if ($v != 0) {
  8406. if (!isset($typeclass[$v])) {
  8407. continue;
  8408. }
  8409. if (isset($pm[$typeclass[$v]['classid']])) {
  8410. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8411. $tz = explode('|', $typeclass[$v]['zh']);
  8412. $pm[$typeclass[$v]['classid']] = $tz[0];
  8413. } else {
  8414. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8415. }
  8416. }
  8417. }
  8418. }
  8419. $zh = implode(" ", $pm);
  8420. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8421. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8422. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8423. $info_list[$key]['features'] = $zh;
  8424. }
  8425. $final_list = [];
  8426. foreach($info_list as $k=>$v){
  8427. $number = "";
  8428. if(!empty($v['orderinfo'])){
  8429. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8430. if(!empty($tmp_info['number'])){
  8431. $number = $tmp_info['number'];
  8432. }
  8433. }
  8434. $final_list[] = [
  8435. 'warehouse'=>$v['warehouse'],
  8436. 'purchase'=>$v['purchase'],
  8437. 'sku'=>$v['sku'],
  8438. 'title'=>$v['title'],
  8439. 'features'=>$v['features'],
  8440. 'label'=>$v['label'],
  8441. 'orderinfo'=>$v['orderinfo'],
  8442. 'number'=>$number,
  8443. 'waybill'=>$v['waybill'],
  8444. 'retreat'=>$v['retreat'],
  8445. ];
  8446. }
  8447. }
  8448. if(empty($final_list)){
  8449. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8450. }else{
  8451. $end_list = [];
  8452. foreach($final_list as $v){
  8453. $end_list[] = array_values($v);
  8454. }
  8455. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8456. array_unshift($end_list,[
  8457. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8458. ]);
  8459. array_unshift($end_list,[
  8460. $title,"","","","","","","","",""
  8461. ]);
  8462. $merges = [
  8463. [
  8464. "s"=>["r"=>0,"c"=>0],
  8465. "e"=>["r"=>0,"c"=>9]
  8466. ]
  8467. ];
  8468. $cols = [
  8469. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8470. ];
  8471. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8472. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8473. ] )));
  8474. }
  8475. } else if ($type == 5) {
  8476. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8477. foreach ($info_list as $key => $value) {
  8478. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8479. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8480. $warehouse = $this->warehouse->read($value['warehouse']);
  8481. $info_list[$key]['warehouse'] = $warehouse['title'];
  8482. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8483. $features = explode('-', trim($features, '-'));
  8484. $pm = $classid;
  8485. foreach ($features as $k => $v) {
  8486. if ($v != 0) {
  8487. if (!isset($typeclass[$v])) {
  8488. continue;
  8489. }
  8490. if (isset($pm[$typeclass[$v]['classid']])) {
  8491. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8492. $tz = explode('|', $typeclass[$v]['zh']);
  8493. $pm[$typeclass[$v]['classid']] = $tz[0];
  8494. } else {
  8495. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8496. }
  8497. }
  8498. }
  8499. }
  8500. $zh = implode(" ", $pm);
  8501. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8502. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8503. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8504. $info_list[$key]['features'] = $zh;
  8505. }
  8506. if(empty($info_list)){
  8507. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8508. }else{
  8509. $final_list = [];
  8510. foreach($info_list as $v){
  8511. $final_list[] = array_values($v);
  8512. }
  8513. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8514. array_unshift($final_list,[
  8515. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8516. ]);
  8517. array_unshift($final_list,[
  8518. $title,"","","","","","",
  8519. ]);
  8520. $merges = [
  8521. [
  8522. "s"=>["r"=>0,"c"=>0],
  8523. "e"=>["r"=>0,"c"=>6]
  8524. ]
  8525. ];
  8526. $cols = [
  8527. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8528. ];
  8529. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8530. }
  8531. } else {
  8532. $wh = array();
  8533. $w = $this->warehouse->find_all('1=1', 'id,title');
  8534. foreach ($w as $v) {
  8535. $wh[$v['id']] = $v['title'];
  8536. }
  8537. $wt = array();
  8538. $whlabel_type = $this->whlabel_type->find_all();
  8539. foreach ($whlabel_type as $v) {
  8540. $wt[$v['id']] = $v['title'];
  8541. }
  8542. $classid = $this->classid->sku();
  8543. $list = array();
  8544. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8545. foreach ($rows as $key => $value) {
  8546. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8547. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8548. $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');
  8549. $details = array();
  8550. $cpid = array();
  8551. $cpbz = array();
  8552. $c = 0;
  8553. $g = 0;
  8554. $x = 0;
  8555. $t = 0;
  8556. $s = 0;
  8557. $q = 0;
  8558. foreach ($sd as $k => $v) {
  8559. if ($v['state'] == 0) {
  8560. $c++;
  8561. }
  8562. if ($v['state'] != 9) {
  8563. $g++;
  8564. }
  8565. if ($v['outk'] > 1) {
  8566. $x++;
  8567. }
  8568. if ($v['retreat'] > 0) {
  8569. $t++;
  8570. }
  8571. if ($v['state'] == 8) {
  8572. $s++;
  8573. }
  8574. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8575. $q++;
  8576. }
  8577. $details[$v['details']] = $v['details'];
  8578. if ($v['cpid'] != 0) {
  8579. $cpid[$v['cpid']] = $v['cpid'];
  8580. }
  8581. if ($v['cpbz'] != '') {
  8582. $cpbz[$v['cpbz']] = $v['cpbz'];
  8583. }
  8584. }
  8585. if (isset($wt[$value['type']])) {
  8586. $rows[$key]['type'] = $wt[$value['type']];
  8587. } else {
  8588. $rows[$key]['type'] = '未设置';
  8589. }
  8590. $rows[$key]['details'] = implode("、", $details);
  8591. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8592. $ftime = time() - 15 * 24 * 3600;
  8593. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8594. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8595. $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);
  8596. $rows[$key]['c'] = $c;
  8597. $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);
  8598. $rows[$key]['t'] = $t;
  8599. $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'] . '"');
  8600. $rows[$key]['z'] = $z;
  8601. // $jm = $classid;
  8602. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8603. $features = explode('-', trim($features, '-'));
  8604. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8605. }
  8606. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8607. $final_list =[];
  8608. foreach($tmp_list as $k=>$v){
  8609. $final_list[] = [
  8610. "warehouse"=>$v['warehouse'],
  8611. "purchase"=>$v['purchase'],
  8612. "details"=>$v['details'],
  8613. "cpid"=>$v['cpid'],
  8614. "sku"=>$v['sku'],
  8615. "title"=>$v['title'],
  8616. "features"=>$v['pm'],
  8617. "cpbz"=>$v['cpbz'],
  8618. "sm"=>$v['sm'],
  8619. "type"=>$v['type'],
  8620. "g"=>$v["g"],
  8621. "c"=>$v["c"],
  8622. "x"=>$v["x"],
  8623. "t"=>$v["t"],
  8624. "z"=>$v["z"],
  8625. "jm"=>$v["jm"],
  8626. "weight"=>$v["weight"],
  8627. "asd"=>$v["asd"],
  8628. ];
  8629. }
  8630. if(empty($final_list)){
  8631. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8632. }else{
  8633. $end_list = [];
  8634. foreach($final_list as $v){
  8635. $end_list[] = array_values($v);
  8636. }
  8637. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8638. array_unshift($end_list,[
  8639. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8640. ]);
  8641. array_unshift($end_list,[
  8642. $title,"","","","","","","","","","","","","","","","","",""
  8643. ]);
  8644. $merges = [
  8645. [
  8646. "s"=>["r"=>0,"c"=>0],
  8647. "e"=>["r"=>0,"c"=>6]
  8648. ]
  8649. ];
  8650. $cols = [
  8651. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8652. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8653. ];
  8654. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8655. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8656. ])));
  8657. }
  8658. }
  8659. }
  8660. }
  8661. public function _exceljxcjs(){
  8662. $classid = $this->classid->sku();
  8663. $pm = $classid;
  8664. $typeclass = array();
  8665. $tc = $this->typeclass->find_all();
  8666. foreach ($tc as $v) {
  8667. $typeclass[$v['id']] = $v;
  8668. }
  8669. $prc = array();
  8670. $purchase = $this->purchase->find_all();
  8671. foreach ($purchase as $k => $v) {
  8672. $prc[$v['id']] = $v['title'];
  8673. }
  8674. if(!isset($_GET['excel'])){
  8675. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8676. }
  8677. $where = "sku != 'Preset'";
  8678. //数据排序
  8679. $order_str = "id desc";
  8680. if (empty($page)) {
  8681. $start = 0;
  8682. $perpage = 1;
  8683. } else {
  8684. $start = ($page - 1) * $perpage;
  8685. }
  8686. $category = $this->input->get('category', true);
  8687. $warehouse = $this->input->get('warehouse', true);
  8688. $excelid = $this->input->get('sid', true);
  8689. if ($category) {
  8690. $where .= " and features like '%-$category-%'";
  8691. }
  8692. if ($warehouse) {
  8693. $where .= " and warehouse = '$warehouse'";
  8694. }
  8695. $xzid = '';
  8696. if ($excelid) {
  8697. $excelid = explode(',', trim($excelid, ','));
  8698. foreach ($excelid as $key => $value) {
  8699. $xzid .= " id = " . $value . " or";
  8700. }
  8701. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8702. }
  8703. $wt = array();
  8704. $whlabel_type = $this->whlabel_type->find_all();
  8705. foreach ($whlabel_type as $v) {
  8706. $wt[$v['id']] = $v['title'];
  8707. }
  8708. $wh = array();
  8709. $w = $this->warehouse->find_all('1=1', 'id,title');
  8710. foreach ($w as $v) {
  8711. $wh[$v['id']] = $v['title'];
  8712. }
  8713. $list = array();
  8714. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8715. foreach ($rows as $key => $value) {
  8716. if (isset($wt[$value['type']])) {
  8717. $rows[$key]['type'] = $wt[$value['type']];
  8718. } else {
  8719. $rows[$key]['type'] = '未设置';
  8720. }
  8721. $bm = '03';
  8722. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8723. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8724. $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');
  8725. $details = array();
  8726. $cpid = array();
  8727. $cpbz = array();
  8728. $c = 0;
  8729. $g = 0;
  8730. $x = 0;
  8731. $t = 0;
  8732. $s = 0;
  8733. $q = 0;
  8734. foreach ($sd as $k => $v) {
  8735. if ($v['state'] == 0) {
  8736. $c++;
  8737. if ($v['cpid'] != 0) {
  8738. $cpid[$v['cpid']] = $v['cpid'];
  8739. }
  8740. if ($v['cpbz'] != '') {
  8741. $cpbz[$v['cpbz']] = $v['cpbz'];
  8742. }
  8743. }
  8744. if ($v['state'] != 9) {
  8745. $g++;
  8746. }
  8747. if ($v['state'] == 1) {
  8748. $x++;
  8749. }
  8750. if ($v['state'] == 2) {
  8751. $t++;
  8752. }
  8753. if ($v['state'] == 8) {
  8754. $s++;
  8755. }
  8756. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8757. $q++;
  8758. }
  8759. $details[$v['details']] = $v['details'];
  8760. }
  8761. $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'] . '"');
  8762. $rows[$key]['details'] = implode("、", $details);
  8763. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8764. $number = $value['number'];
  8765. $ftime = time() - 15 * 24 * 3600;
  8766. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8767. $rows[$key]['number'] = $g;
  8768. $rows[$key]['c'] = $c;
  8769. $rows[$key]['x'] = $x;
  8770. $rows[$key]['t'] = $t;
  8771. $rows[$key]['s'] = $s;
  8772. $rows[$key]['q'] = $q;
  8773. $rows[$key]['z'] = $z;
  8774. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8775. $features = explode('-', trim($features, '-'));
  8776. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8777. }
  8778. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8779. $final_list = [];
  8780. foreach ($list as $k => $v) {
  8781. if (empty($v['sku'])) {
  8782. continue;
  8783. }
  8784. $final_list[] = [
  8785. $v["warehouse"],
  8786. $v["purchase"],
  8787. $v["details"],
  8788. $v["cpid"],
  8789. $v["dbcontent"],
  8790. $v["sku"],
  8791. $v["bm"],
  8792. $v["jm"],
  8793. $v["title"],
  8794. $v["pm"],
  8795. $v["cpbz"],
  8796. $v["sm"],
  8797. $v["type"],
  8798. $v["number"],
  8799. $v["c"],
  8800. $v["x"],
  8801. $v["t"],
  8802. $v["s"],
  8803. $v["q"],
  8804. $v["z"],
  8805. $v['weight'],
  8806. ];
  8807. }
  8808. if(empty($final_list)){
  8809. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8810. }
  8811. $title = "总进销存统计表";
  8812. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8813. $merges = [
  8814. [
  8815. "s"=>["r"=>0,"c"=>0],
  8816. "e"=>["r"=>0,"c"=>21]
  8817. ]
  8818. ];
  8819. $cols = [
  8820. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8821. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8822. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8823. ];
  8824. array_unshift($final_list, $first_row);
  8825. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8826. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8827. }
  8828. public function _summaryjs($arg_array)
  8829. {
  8830. $prc = array();
  8831. $purchase = $this->purchase->find_all();
  8832. foreach ($purchase as $k => $v) {
  8833. $prc[$v['id']] = $v['title'];
  8834. }
  8835. if (isset($_GET['excel'])) {
  8836. $ktime = $this->input->get('ktime', true);
  8837. $jtime = $this->input->get('jtime', true);
  8838. $ktime = strtotime($ktime);
  8839. $jtime = strtotime($jtime);
  8840. $where = "1=1";
  8841. if ($ktime && $jtime) {
  8842. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8843. }
  8844. //数据排序
  8845. $order_str = "time desc";
  8846. if (empty($page)) {
  8847. $start = 0;
  8848. $perpage = 1;
  8849. } else {
  8850. $start = ($page - 1) * $perpage;
  8851. }
  8852. //取得信息列表
  8853. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8854. foreach ($info_list as $key => $value) {
  8855. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8856. $warehouse = $this->warehouse->read($value['warehouse']);
  8857. $info_list[$key]['warehouse'] = $warehouse['title'];
  8858. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8859. $details = array();
  8860. $cpid = array();
  8861. foreach ($x as $k => $v) {
  8862. if ($v['details'] != '') {
  8863. $details[$v['details']] = $v['details'];
  8864. }
  8865. if ($v['cpid'] != 0) {
  8866. $cpid[$v['cpid']] = $v['cpid'];
  8867. }
  8868. }
  8869. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8870. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8871. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8872. $info_list[$key]['s'] = $s;
  8873. $info_list[$key]['x'] = count($x);
  8874. }
  8875. if(empty($info_list)){
  8876. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8877. }
  8878. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8879. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8880. $merges = [
  8881. [
  8882. "s"=>["r"=>0,"c"=>0],
  8883. "e"=>["r"=>0,"c"=>7]
  8884. ]
  8885. ];
  8886. $cols = [
  8887. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8888. ];
  8889. $final_list = [];
  8890. foreach($info_list as $k => $v){
  8891. $final_list[] = array_values($v);
  8892. }
  8893. array_unshift($final_list, $first_row);
  8894. array_unshift($final_list,[
  8895. $title,"","","","","","","","",
  8896. ]);
  8897. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8898. $titlename = "<table border=1>
  8899. <tr align='center'>
  8900. <td>仓库</td>
  8901. <td>供应商</td>
  8902. <td>出库位置</td>
  8903. <td>出库编码</td>
  8904. <td>SKU</td>
  8905. <td>产品名</td>
  8906. <td>总剩余库存</td>
  8907. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8908. </tr>
  8909. </table>";
  8910. $filename = $title . ".xls";
  8911. $tail = "";
  8912. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8913. }
  8914. }
  8915. public function _uckjs()
  8916. {
  8917. if (isset($_GET['excel'])) {
  8918. $tc = array();
  8919. $typeclass = $this->typeclass->find_all();
  8920. foreach ($typeclass as $v) {
  8921. $tc[$v['id']] = $v['zh'];
  8922. }
  8923. $first_row = [
  8924. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8925. ];
  8926. $t = array();
  8927. $rq = '';
  8928. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8929. $ts = $ts / (24 * 3600);
  8930. for ($i = 0; $i < $ts; $i++) {
  8931. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8932. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8933. }
  8934. $day_len = count($t);
  8935. $first_row[] = "本月出库";
  8936. $merges = [
  8937. ];
  8938. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8939. $excel_key = 1;
  8940. $final_list = [];
  8941. foreach ($info_list as $k => $v) {
  8942. $features = explode('-', trim($v['features'], '-'));
  8943. if (!isset($features[3]) || !isset($features[4])) {
  8944. continue;
  8945. }
  8946. $tmp = [];
  8947. $tmp[0] = $tc[$features[0]]; //类型
  8948. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8949. $tmp[2] = $tc[$features[4]]; //曲度
  8950. $tmp[3] = '';
  8951. if (isset($data[$k][1])) {
  8952. $tmp[3] .=$tmp[1];
  8953. }
  8954. if (isset($data[$k][2])) {
  8955. $tmp[3] .= $tmp[2];
  8956. }
  8957. if (isset($features[5])) {
  8958. $tmp[3] .= $tc[$features[5]];
  8959. }
  8960. if (isset($features[2])) {
  8961. $tmp[3] .= $tc[$features[2]];
  8962. }
  8963. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8964. $tmp[4] = $v['sku'];
  8965. $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())) . '))'); //月初库存
  8966. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8967. $tmp[7] ="";
  8968. $tmp[8] ="";
  8969. $byck = 0;
  8970. foreach ($t as $vv) {
  8971. $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));
  8972. $tmp[] = ($sl > 0) ? $sl : '';
  8973. $byck += $sl;
  8974. }
  8975. $tmp[] = ($byck > 0) ? $byck : '';
  8976. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8977. // $ztrq = '';
  8978. // $ztsl = '';
  8979. // if (count($zt) > 0) {
  8980. // foreach ($zt as $vv) {
  8981. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8982. // $ztsl .= $vv['num'] . '<br>';
  8983. // }
  8984. // }
  8985. if(empty($zt)){
  8986. $final_list[] = $tmp;
  8987. $excel_key = $excel_key + 1;
  8988. }else{
  8989. $len = count($zt);
  8990. if($len == 1){
  8991. $tmp[7] = $zt[0]['num'] ;
  8992. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8993. $final_list[] = $tmp;
  8994. $excel_key = $excel_key + 1;
  8995. }else{
  8996. foreach($zt as $vv){
  8997. $tmp[7] = "";
  8998. $tmp[8] = "";
  8999. $tmp[7] = $vv['num'];
  9000. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9001. $final_list[] = $tmp;
  9002. }
  9003. $merges[] = [
  9004. "s"=>["r"=>$excel_key,"c"=>0],
  9005. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9006. ];
  9007. $merges[] = [
  9008. "s"=>["r"=>$excel_key,"c"=>1],
  9009. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9010. ];
  9011. $merges[] = [
  9012. "s"=>["r"=>$excel_key,"c"=>2],
  9013. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9014. ];
  9015. $merges[] = [
  9016. "s"=>["r"=>$excel_key,"c"=>3],
  9017. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9018. ];
  9019. $merges[] = [
  9020. "s"=>["r"=>$excel_key,"c"=>4],
  9021. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9022. ];
  9023. $merges[] = [
  9024. "s"=>["r"=>$excel_key,"c"=>5],
  9025. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9026. ];
  9027. $merges[] = [
  9028. "s"=>["r"=>$excel_key,"c"=>6],
  9029. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9030. ];
  9031. for($i=1;$i<=$day_len;$i++){
  9032. $merges[] = [
  9033. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9034. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9035. ];
  9036. }
  9037. $merges[] = [
  9038. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9039. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9040. ];
  9041. $excel_key = $excel_key + $len;
  9042. }
  9043. }
  9044. }
  9045. $title = "详情 " . date("Y-m-d", time());
  9046. if(empty($final_list)){
  9047. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9048. }
  9049. $cols = [
  9050. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9051. ];
  9052. array_unshift($final_list, $first_row);
  9053. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9054. }
  9055. }
  9056. public function _whlabelexcelzhjs(){
  9057. if(empty($_GET['excel'])){
  9058. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9059. }
  9060. $where = "sku != 'Preset' and sku != '' ";
  9061. //数据排序
  9062. $order_str = "id desc";
  9063. if (empty($page)) {
  9064. $start = 0;
  9065. $perpage = 1;
  9066. } else {
  9067. $start = ($page - 1) * $perpage;
  9068. }
  9069. $category = $this->input->get('category', true);
  9070. $warehouse = $this->input->get('warehouse', true);
  9071. $excelid = $this->input->get('sid', true);
  9072. if ($category) {
  9073. $where .= " and features like '%-$category-%'";
  9074. }
  9075. if ($warehouse) {
  9076. $where .= " and warehouse = '$warehouse'";
  9077. }
  9078. $xzid = '';
  9079. if ($excelid) {
  9080. $excelid = explode(',', trim($excelid, ','));
  9081. foreach ($excelid as $key => $value) {
  9082. $xzid .= " id = " . $value . " or";
  9083. }
  9084. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9085. }
  9086. $merges = [
  9087. [
  9088. "s"=>["r"=>0,"c"=>0],
  9089. "e"=>["r"=>0,"c"=>6]
  9090. ]
  9091. ];
  9092. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9093. $excel_index = 2;
  9094. $final_list = [];
  9095. foreach ($rows as $key => $value) {
  9096. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9097. $zh = '';
  9098. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9099. // foreach ($zt_list as $v) {
  9100. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9101. // }
  9102. $zt = array_sum(array_column($zt_list, 'num'));
  9103. $number = $value['number'];
  9104. $ftime = time() - 15 * 24 * 3600;
  9105. $warehouse = $this->warehouse->read($value['warehouse']);
  9106. // $rows[$key]['warehouse'] = $warehouse['title'];
  9107. // $rows[$key]['number'] = $c;
  9108. // $rows[$key]['features'] = $zh;
  9109. //$rows[$key]['hb'] = $c + $zt;
  9110. $tmp = [];
  9111. $tmp[0] = $warehouse['title'];
  9112. $tmp[1] = $value['sku'];
  9113. $tmp[2] = $value['title'];
  9114. $tmp[3] = $c;
  9115. $tmp[4] = "";
  9116. $tmp[5] = $c + $zt;
  9117. if(empty($zt_list)){
  9118. $tmp[4] = "";
  9119. $final_list[] = $tmp;
  9120. $excel_index = $excel_index + 1;
  9121. }else{
  9122. if(count($zt_list) == 1){
  9123. $tmp[4] = "";
  9124. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9125. $final_list[] = $tmp;
  9126. $excel_index = $excel_index + 1;
  9127. }else{
  9128. $len = count($zt_list);
  9129. foreach ($zt_list as $v){
  9130. $tmp[4] = "";
  9131. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9132. $final_list[] = $tmp;
  9133. }
  9134. $merges[] = [
  9135. "s"=>["r"=>$excel_index,"c"=>0],
  9136. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9137. ];
  9138. $merges[] = [
  9139. "s"=>["r"=>$excel_index,"c"=>1],
  9140. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9141. ];
  9142. $merges[] = [
  9143. "s"=>["r"=>$excel_index,"c"=>2],
  9144. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9145. ];
  9146. $merges[] = [
  9147. "s"=>["r"=>$excel_index,"c"=>3],
  9148. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9149. ];
  9150. $merges[] = [
  9151. "s"=>["r"=>$excel_index,"c"=>5],
  9152. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9153. ];
  9154. $excel_index = $excel_index + $len;
  9155. }
  9156. }
  9157. }
  9158. $first_row = [
  9159. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9160. ];
  9161. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9162. if(empty($final_list)){
  9163. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9164. }
  9165. $cols = [
  9166. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9167. ];
  9168. array_unshift($final_list, $first_row);
  9169. array_unshift($final_list, [
  9170. $title,"","","","",""
  9171. ]);
  9172. $end_list = [];
  9173. foreach ($final_list as $key => $value) {
  9174. $end_list[] = array_values($value);
  9175. }
  9176. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9177. }
  9178. //出库、退库导出
  9179. public function _dccrtypejs()
  9180. {
  9181. $classid = $this->classid->sku();
  9182. $pm = $classid;
  9183. $typeclass = array();
  9184. $tc = $this->typeclass->find_all();
  9185. foreach ($tc as $v) {
  9186. $typeclass[$v['id']] = $v;
  9187. }
  9188. $prc = array();
  9189. $purchase = $this->purchase->find_all();
  9190. foreach ($purchase as $k => $v) {
  9191. $prc[$v['id']] = $v['title'];
  9192. }
  9193. if (isset($_GET['sid'])) {
  9194. $wh = array();
  9195. $w = $this->warehouse->find_all('1=1', 'id,title');
  9196. foreach ($w as $v) {
  9197. $wh[$v['id']] = $v['title'];
  9198. }
  9199. $type = $this->input->get('excel', true);
  9200. $category = $this->input->get('category', true);
  9201. $size = $this->input->get('size', true);
  9202. $grade = $this->input->get('grade', true);
  9203. $color = $this->input->get('color', true);
  9204. $lowe = $this->input->get('lowe', true);
  9205. $sku = $this->input->get('sku', true);
  9206. $warehouse = $this->input->get('warehouse', true);
  9207. $lacetype = $this->input->get('lacetype', true);
  9208. $lacecolor = $this->input->get('lacecolor', true);
  9209. $density = $this->input->get('density', true);
  9210. $haircap = $this->input->get('haircap', true);
  9211. $purchase = $this->input->get('purchase', true);
  9212. $title = $this->input->get('title', true);
  9213. $state = $this->input->get('state', true);
  9214. $sid = $this->input->get('sid', true);
  9215. $ktime = $this->input->get('ktime', true);
  9216. $jtime = $this->input->get('jtime', true);
  9217. $ktime = strtotime($ktime);
  9218. $jtime = strtotime($jtime);
  9219. $where = "1=1";
  9220. $gj = "";
  9221. $ck = "";
  9222. if ($category) {
  9223. $where .= " and features like '%-$category-%'";
  9224. }
  9225. if ($size) {
  9226. $where .= " and features like '%-$size-%'";
  9227. }
  9228. if ($grade) {
  9229. $where .= " and features like '%-$grade-%'";
  9230. }
  9231. if ($color) {
  9232. $where .= " and features like '%-$color-%'";
  9233. }
  9234. if ($lowe) {
  9235. $where .= " and features like '%-$lowe-%'";
  9236. }
  9237. if ($warehouse) {
  9238. $where .= " and warehouse = '$warehouse'";
  9239. }
  9240. if ($purchase) {
  9241. $where .= " and purchase = '$purchase'";
  9242. }
  9243. if ($state) {
  9244. $where .= " and state = '$state'";
  9245. }
  9246. if ($lacetype) {
  9247. $where .= " and features like '%-$lacetype-%'";
  9248. }
  9249. if ($lacecolor) {
  9250. $where .= " and features like '%-$lacecolor-%'";
  9251. }
  9252. if ($density) {
  9253. $where .= " and features like '%-$density-%'";
  9254. }
  9255. if ($haircap) {
  9256. $where .= " and features like '%-$haircap-%'";
  9257. }
  9258. if ($title) {
  9259. $title = trim($title, ' ');
  9260. $title = trim($title, ' ');
  9261. $where .= " and title like '%$title%'";
  9262. }
  9263. if ($sku) {
  9264. $sku = trim($sku, ' ');
  9265. $sku = trim($sku, ' ');
  9266. $where .= " and sku like '%$sku%'";
  9267. }
  9268. if ($ktime && $jtime) {
  9269. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9270. }
  9271. $sidwhere = '';
  9272. if ($sid) {
  9273. $sd = "";
  9274. $s = explode(',', trim($sid, ','));
  9275. foreach ($s as $value) {
  9276. $sd .= " id = " . $value . " or";
  9277. }
  9278. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9279. }
  9280. //数据排序
  9281. $order_str = "time desc";
  9282. if (empty($page)) {
  9283. $start = 0;
  9284. $perpage = 1;
  9285. } else {
  9286. $start = ($page - 1) * $perpage;
  9287. }
  9288. $wh = array();
  9289. $w = $this->warehouse->find_all('1=1', 'id,title');
  9290. foreach ($w as $v) {
  9291. $wh[$v['id']] = $v['title'];
  9292. }
  9293. $wt = array();
  9294. $whlabel_type = $this->whlabel_type->find_all();
  9295. foreach ($whlabel_type as $v) {
  9296. $wt[$v['id']] = $v['title'];
  9297. }
  9298. $classid = $this->classid->sku();
  9299. $list = array();
  9300. $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');
  9301. foreach ($rows_r as $key => $value) {
  9302. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9303. $pm = $classid;
  9304. $jm = $classid;
  9305. $rows_r[$key]['enter'] = '入库';
  9306. $rows_r[$key]['time'] = $value['enter'];
  9307. if ($value['rktype'] == 1) {
  9308. $rows_r[$key]['rktype'] = '采购入库';
  9309. } else if ($value['rktype'] == 2) {
  9310. $rows_r[$key]['rktype'] = '盘盈调整';
  9311. } else if ($value['rktype'] == 3) {
  9312. $rows_r[$key]['rktype'] = '其他调整入库';
  9313. } else if ($value['rktype'] == 4) {
  9314. $rows_r[$key]['rktype'] = '其他调整入库';
  9315. } else if ($value['rktype'] == 5) {
  9316. $rows_r[$key]['rktype'] = '退库入库';
  9317. } else if ($value['rktype'] == 6) {
  9318. $rows_r[$key]['rktype'] = '退货可用入库';
  9319. } else if ($value['rktype'] == 7) {
  9320. $rows_r[$key]['rktype'] = '形态转换入库';
  9321. } else {
  9322. $rows_r[$key]['rktype'] = '';
  9323. }
  9324. $features = explode('-', trim($value['features'], '-'));
  9325. foreach ($features as $v) {
  9326. if (isset($typeclass[$v])) {
  9327. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9328. $pm[$typeclass[$v]['classid']] = $zh[0];
  9329. }
  9330. if (isset($typeclass[$v])) {
  9331. if (isset($jm[$typeclass[$v]['classid']])) {
  9332. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9333. }
  9334. }
  9335. }
  9336. $zh = implode(" ", $pm);
  9337. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9338. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9339. $rows_r[$key]['zh'] = $zh;
  9340. $jm = array_filter($jm);
  9341. $rows_r[$key]['features'] = implode("-", $jm);
  9342. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9343. }
  9344. $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');
  9345. foreach ($rows_c as $key => $value) {
  9346. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9347. $pm = $classid;
  9348. $jm = $classid;
  9349. $rows_c[$key]['time'] = $value['outk'];
  9350. $rows_c[$key]['outk'] = '出库';
  9351. if ($value['cktype'] == 1) {
  9352. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9353. } else if ($value['cktype'] == 2) {
  9354. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9355. } else if ($value['cktype'] == 3) {
  9356. $rows_c[$key]['cktype'] = '盘亏调整';
  9357. } else if ($value['cktype'] == 4) {
  9358. $rows_c[$key]['cktype'] = '其他调整出库';
  9359. } else if ($value['cktype'] == 5) {
  9360. $rows_c[$key]['cktype'] = '形态转换出库';
  9361. } else {
  9362. $rows_c[$key]['cktype'] = '';
  9363. }
  9364. unset($rows_c[$key]['state']);
  9365. $features = explode('-', trim($value['features'], '-'));
  9366. foreach ($features as $v) {
  9367. if (isset($typeclass[$v])) {
  9368. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9369. $pm[$typeclass[$v]['classid']] = $zh[0];
  9370. }
  9371. if (isset($typeclass[$v])) {
  9372. if (isset($jm[$typeclass[$v]['classid']])) {
  9373. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9374. }
  9375. }
  9376. }
  9377. $zh = implode(" ", $pm);
  9378. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9379. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9380. $rows_c[$key]['zh'] = $zh;
  9381. $jm = array_filter($jm);
  9382. $rows_c[$key]['features'] = implode("-", $jm);
  9383. $rows_c[$key]['number'] = 1;
  9384. }
  9385. $merged = $rows_r;
  9386. foreach ($rows_c as $key => $value) {
  9387. if (isset($merged[$key])) {
  9388. $merged[] = $value;
  9389. } else {
  9390. $merged[$key] = $value;
  9391. }
  9392. }
  9393. usort($merged, function ($a, $b) {
  9394. return $a['time'] - $b['time'];
  9395. });
  9396. foreach ($merged as $key => $value) {
  9397. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9398. }
  9399. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9400. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9401. $cols = [
  9402. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9403. ];
  9404. $final_list= [];
  9405. foreach($merged as $key => $value){
  9406. $final_list[] = array_values($value) ;
  9407. }
  9408. if(empty($merged)){
  9409. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9410. }
  9411. array_unshift($final_list, $first_row);
  9412. $end_list = [];
  9413. foreach ($final_list as $key => $value) {
  9414. $end_list[] = array_values($value);
  9415. }
  9416. $merges = [];
  9417. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9418. }
  9419. }
  9420. public function _errorexceljs()
  9421. {
  9422. $post = $this->input->post(NULL, TRUE);
  9423. if (isset($_GET['page'])) {
  9424. $page = $this->input->get('page', true);
  9425. $perpage = $this->input->get('perpage', true);
  9426. $sku = $this->input->get('sku', true);
  9427. $warehouse = $this->input->get('warehouse', true);
  9428. $ktime = $this->input->get('ktime', true);
  9429. $jtime = $this->input->get('jtime', true);
  9430. $ktime = strtotime($ktime);
  9431. $jtime = strtotime($jtime);
  9432. $where = "sku != 'Preset'";
  9433. $gj = '';
  9434. if ($sku) {
  9435. $where .= " and sku like '%$sku%'";
  9436. } else {
  9437. if ($ktime && $jtime) {
  9438. $gj = " and time > '$ktime' and time < '$jtime'";
  9439. }
  9440. }
  9441. if ($warehouse) {
  9442. $where .= " and warehouse = '$warehouse'";
  9443. }
  9444. //数据排序
  9445. $order_str = "id desc";
  9446. if (empty($page)) {
  9447. $start = 0;
  9448. $perpage = 1;
  9449. } else {
  9450. $start = ($page - 1) * $perpage;
  9451. }
  9452. //取得信息列表
  9453. $rows = array();
  9454. $list = array();
  9455. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9456. foreach ($info_list as $value) {
  9457. $warehouse = $this->warehouse->read($value['warehouse']);
  9458. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9459. $number = $value['number'];
  9460. $ftime = time() - 15 * 24 * 3600;
  9461. if ($c < 1) {
  9462. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9463. }
  9464. }
  9465. $title = "0库存汇总";
  9466. $first_row = ["仓库","SKU","产品","当前库存"];
  9467. $cols = [
  9468. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9469. ];
  9470. $final_list= [];
  9471. foreach($list as $key => $value){
  9472. $final_list[] = array_values($value) ;
  9473. }
  9474. if(empty($final_list)){
  9475. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9476. }
  9477. array_unshift($final_list, $first_row);
  9478. $merges = [];
  9479. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9480. }
  9481. }
  9482. }