Whlabel.php 343 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. $this->load->_model("Model_whlabelscbf","whlabelscbf");
  49. }
  50. //定义方法的调用规则 获取URI第二段值
  51. public function _remap($arg, $arg_array)
  52. {
  53. if ($arg == 'existence') //在库标签
  54. {
  55. $this->_existence();
  56. } else if ($arg == 'cpbqdc') //在库标签
  57. {
  58. $this->_cpbqdc();
  59. } else if ($arg == 'type') //进销存浏览
  60. {
  61. $this->_type();
  62. }else if ($arg == 'typev1') //进销存浏览
  63. {
  64. $this->_typev1();
  65. } else if ($arg == 'typedy') //进销存浏览店员页面
  66. {
  67. $this->_typedy($arg_array);
  68. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  69. {
  70. $this->_typedy_ck($arg_array);
  71. } else if ($arg == 'typeck') {
  72. $this->_typeck($arg_array);
  73. } else if ($arg == 'whlabeckdc') {
  74. $this->_whlabeckdc($arg_array);
  75. } else if ($arg == 'usatype') //美仓进销存浏览
  76. {
  77. $this->_usatype();
  78. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  79. {
  80. $this->_usatypeapp();
  81. } else if ($arg == 'enteradd') //入库操作
  82. {
  83. $this->_enteradd();
  84. } else if ($arg == 'enteredit') //修改
  85. {
  86. $this->_enteredit($arg_array);
  87. } else if ($arg == 'enter') //入库浏览
  88. {
  89. $this->_enter();
  90. } else if ($arg == 'out') //出库浏览
  91. {
  92. $this->_out();
  93. } else if ($arg == 'label') //出库标签浏览
  94. {
  95. $this->_label();
  96. } else if ($arg == 'outorder') //独立站出库订单
  97. {
  98. $this->_outorder();
  99. } else if ($arg == 'soutorder') //速卖通出库订单
  100. {
  101. $this->_soutorder();
  102. } else if ($arg == 'toutorder') //TT出库订单
  103. {
  104. $this->_toutorder();
  105. }else if ($arg == 'aoutorder') //amz出库订单
  106. {
  107. $this->_aoutorder();
  108. } else if ($arg == 'retreat') //退库订单
  109. {
  110. $this->_retreat();
  111. } else if ($arg == 'retreatlk') //退库订单
  112. {
  113. $this->_retreatlk();
  114. } else if ($arg == 'change') //更换标签
  115. {
  116. $this->_change();
  117. } else if ($arg == 'del') //删除
  118. {
  119. $this->_del();
  120. } else if ($arg == 'exceljxc') //进销存信息导出
  121. {
  122. $this->_exceljxc();
  123. } else if ($arg == 'excelr') //入库信息导出
  124. {
  125. $this->_excelr();
  126. } else if ($arg == 'excelct') //出库、退库信息导出
  127. {
  128. $this->_excelct();
  129. } else if ($arg == 'dccrtype') //根据出入库类型导出
  130. {
  131. $this->_dccrtype();
  132. } else if ($arg == 'excelcr') //出库、退库信息导出
  133. {
  134. $this->_excelcr();
  135. } else if ($arg == 'kcyz') //库存验证
  136. {
  137. $this->_kcyz();
  138. } else if ($arg == 'kj') //库存扣减
  139. {
  140. $this->_kj($arg_array);
  141. } else if ($arg == 'presetout') //预设库存导入
  142. {
  143. $this->_presetout($arg_array);
  144. } else if ($arg == 'presetedit') //预设库存导入
  145. {
  146. $this->_presetedit($arg_array);
  147. }else if ($arg == 'presetedittwo') //预设库存导入
  148. {
  149. $this->_presetedittwo($arg_array);
  150. } else if ($arg == 'summary') //汇总导出
  151. {
  152. $this->_summary($arg_array);
  153. } else if ($arg == 'manifest') //usps发货清单
  154. {
  155. $this->_manifest();
  156. } else if ($arg == 'abnormal') //占单异常
  157. {
  158. $this->_abnormal();
  159. } else if ($arg == 'error') //0库存SKU
  160. {
  161. $this->_error();
  162. } else if ($arg == 'errorexcel') //0库存SKU导出
  163. {
  164. $this->_errorexcel();
  165. } else if ($arg == 'db') {
  166. $this->_db();
  167. } else if ($arg == 'dbrk') {
  168. $this->_dbrk();
  169. } else if ($arg == 'whlabelczdc') {
  170. $this->_whlabelczdc();
  171. } else if ($arg == 'print') {
  172. $this->_print($arg_array);
  173. } else if ($arg == 'usaprint') {
  174. $this->_usaprint($arg_array);
  175. } else if ($arg == 'printck') {
  176. $this->_printck($arg_array);
  177. } else if ($arg == 'printrk') {
  178. $this->_printrk($arg_array);
  179. } else if ($arg == 'printxzrk') {
  180. $this->_printxzrk($arg_array);
  181. } else if ($arg == 'printexcel') {
  182. $this->_printexcel($arg_array);
  183. } else if ($arg == 'uck') {
  184. $this->_uck();
  185. } else if ($arg == 'whlabelexcelzh') {
  186. $this->_whlabelexcelzh();
  187. } else if ($arg == 'fc') {
  188. $this->_fc();
  189. } else if ($arg == 'fcmb') {
  190. $this->_fcmb();
  191. } else if ($arg == 'fcexcel') {
  192. $this->_fcexcel();
  193. } else if ($arg == 'fcjxc') {
  194. $this->_fcjxc($arg_array);
  195. } else if ($arg == '0kcdel') {
  196. $this->_0kcdel(); //导表删除0库存
  197. } else if ($arg == 'gbhtype') {
  198. $this->_gbhtype(); //更改备货状态
  199. } else if($arg == 'excelrjs'){
  200. $this->_excelrjs();
  201. } else if($arg == 'excelctjs'){
  202. $this->_excelctjs();
  203. }else if ($arg == 'exceljxcjs') //进销存信息导出
  204. {
  205. $this->_exceljxcjs();
  206. } else if ($arg == 'summaryjs') //汇总导出
  207. {
  208. $this->_summaryjs($arg_array);
  209. }else if($arg == 'uckjs'){
  210. $this->_uckjs();
  211. }else if ($arg == 'whlabelexcelzhjs') {
  212. $this->_whlabelexcelzhjs();
  213. }else if($arg == 'dccrtypejs'){
  214. $this->_dccrtypejs();
  215. }else if($arg == 'errorexceljs'){
  216. $this->_errorexceljs();
  217. }else if($arg == "w_t_cs"){
  218. $this->_w_t_cs(); //首页
  219. }else {
  220. $this->_index();
  221. }
  222. }
  223. public function _w_t_cs(){
  224. $vip = 0;
  225. if (isset($_SESSION['api'])) {
  226. $user = $this->user->get_api($_SESSION['api']);
  227. $fgshop = "";
  228. $sid = "";
  229. $usersp = explode('|', trim($user['shop'], '|'));
  230. foreach ($usersp as $value) {
  231. $fgshop .= " shop = " . $value . " or";
  232. $sid .= " id = " . $value . " or";
  233. }
  234. if ($user['vip'] == 1) {
  235. $vip = 1;
  236. }
  237. } else {
  238. header('Location: /');
  239. exit;
  240. }
  241. $prc = array();
  242. $purchase = $this->purchase->find_all();
  243. foreach ($purchase as $k => $v) {
  244. $prc[$v['id']] = $v['title'];
  245. }
  246. $company = array();
  247. $ct = $this->company->find_all();
  248. foreach ($ct as $k => $v) {
  249. $company[$v['id']] = $v['title'];
  250. }
  251. $sp = array();
  252. $s = $this->shop->find_all('1=1', 'id,shopname');
  253. foreach ($s as $v) {
  254. $sp[$v['id']] = $v['shopname'];
  255. }
  256. $wh = array();
  257. $w = $this->warehouse->find_all('1=1', 'id,title');
  258. foreach ($w as $v) {
  259. $wh[$v['id']] = $v['title'];
  260. }
  261. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  262. $this->data['shop'] = $wlshop;
  263. $this->data['vip'] = $vip;
  264. $this->_Template('whlabel_typejs', $this->data);
  265. }
  266. //管理
  267. public function _index()
  268. {
  269. $post = $this->input->post(NULL, TRUE);
  270. if (isset($post['page'])) {
  271. $page = $this->input->post('page', true);
  272. $perpage = $this->input->post('perpage', true);
  273. $sku = $this->input->post('sku', true);
  274. $number = $this->input->post('number', true);
  275. $warehouse = $this->input->post('warehouse', true);
  276. $purchase = $this->input->post('purchase', true);
  277. $orderinfo = $this->input->post('orderinfo', true);
  278. $waybill = $this->input->post('waybill', true);
  279. $category = $this->input->post('category', true);
  280. $size = $this->input->post('size', true);
  281. $grade = $this->input->post('grade', true);
  282. $color = $this->input->post('color', true);
  283. $lowe = $this->input->post('lowe', true);
  284. $state = $this->input->post('state', true);
  285. $label = $this->input->post('label', true);
  286. $timetk = $this->input->post('timetkk', true);
  287. $timetj = $this->input->post('timetjj', true);
  288. $timetk = strtotime($timetk);
  289. $timetj = strtotime($timetj);
  290. $where = "1=1 ";
  291. if ($timetk && $timetj) {
  292. $where .= " and time > '$timetk' and time < '$timetj'";
  293. }
  294. if ($sku) {
  295. $where .= " and sku = '$sku'";
  296. }
  297. if ($number) {
  298. $where .= " and number = '$number'";
  299. }
  300. if ($warehouse) {
  301. $where .= " and warehouse = '$warehouse'";
  302. }
  303. if ($purchase) {
  304. $where .= " and purchase = '$purchase'";
  305. }
  306. if ($orderinfo) {
  307. $where .= " and orderinfo = '$orderinfo'";
  308. }
  309. if ($waybill) {
  310. $where .= " and waybill = '$waybill'";
  311. }
  312. if ($category) {
  313. $where .= " and features like '%-$category-%'";
  314. }
  315. if ($size) {
  316. $where .= " and features like '%-$size-%'";
  317. }
  318. if ($grade) {
  319. $where .= " and features like '%-$grade-%'";
  320. }
  321. if ($color) {
  322. $where .= " and features like '%-$color-%'";
  323. }
  324. if ($lowe) {
  325. $where .= " and features like '%-$lowe-%'";
  326. }
  327. if ($label) {
  328. $where .= " and label = '$label'";
  329. }
  330. if ($state != '') {
  331. $where .= " and state = '$state'";
  332. }
  333. //数据排序
  334. $order_str = "time desc";
  335. if (empty($page)) {
  336. $start = 0;
  337. $perpage = 1;
  338. } else {
  339. $start = ($page - 1) * $perpage;
  340. }
  341. //取得信息列表
  342. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  343. foreach ($info_list as $key => $value) {
  344. $warehouse = $this->warehouse->read($value['warehouse']);
  345. $info_list[$key]['warehouse'] = $warehouse['title'];
  346. $purchase = $this->purchase->read($value['purchase']);
  347. $info_list[$key]['purchase'] = $purchase['title'];
  348. if ($value['enter'] != 0) {
  349. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  350. } else {
  351. $info_list[$key]['enter'] = "";
  352. }
  353. if ($value['outk'] != 0) {
  354. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  355. } else {
  356. $info_list[$key]['outk'] = "";
  357. }
  358. if ($value['printing'] != 0) {
  359. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  360. } else {
  361. $info_list[$key]['printing'] = "";
  362. }
  363. if ($value['orderinfo'] == 0) {
  364. $info_list[$key]['orderinfo'] = "";
  365. }
  366. if ($value['waybill'] == 0) {
  367. $info_list[$key]['waybill'] = "";
  368. }
  369. if ($value['state'] == 0) {
  370. $info_list[$key]['state'] = "在库";
  371. } else if ($value['state'] == 1) {
  372. $info_list[$key]['state'] = "出库";
  373. } else if ($value['state'] == 2) {
  374. $info_list[$key]['state'] = "退库";
  375. } else if ($value['state'] == 3) {
  376. $info_list[$key]['state'] = "调拨中";
  377. } else if ($value['state'] == 4) {
  378. $info_list[$key]['state'] = "再加工";
  379. } else if ($value['state'] == 5) {
  380. $info_list[$key]['state'] = "维修中";
  381. } else if ($value['state'] == 6) {
  382. $info_list[$key]['state'] = "盘亏";
  383. } else if ($value['state'] == 7) {
  384. $info_list[$key]['state'] = "更换标签";
  385. } else if ($value['state'] == 8) {
  386. $info_list[$key]['state'] = "其它";
  387. } else if ($value['state'] == 9) {
  388. $info_list[$key]['state'] = "预设";
  389. } else if ($value['state'] == 10) {
  390. $info_list[$key]['state'] = "美店零售";
  391. }
  392. if ($value['text'] == "") {
  393. $info_list[$key]['text'] = "";
  394. }
  395. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  396. }
  397. $total = $this->whlabel->find_count($where);
  398. $pagenum = ceil($total / $perpage);
  399. $over = $total - ($start + $perpage);
  400. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  401. echo json_encode($rows);
  402. exit;
  403. }
  404. if (isset($post['outsku'])) {
  405. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  406. $cz = $this->input->post('cz', true);
  407. if ($cz == '1') {
  408. $sku = $this->input->post('outsku', true);
  409. if ($sku) {
  410. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  411. if (count($data) < 1) {
  412. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  413. exit;
  414. }
  415. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  416. echo json_encode(array('success' => true));
  417. exit;
  418. }
  419. } else {
  420. $sku = $this->input->post('outsku', true);
  421. if ($sku) {
  422. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  423. if (count($data) < 1) {
  424. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  425. exit;
  426. }
  427. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  428. echo json_encode(array('success' => true));
  429. exit;
  430. }
  431. }
  432. }
  433. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  434. $this->_Template('whlabel', $this->data);
  435. }
  436. //在库标签
  437. public function _existence()
  438. {
  439. $post = $this->input->post(NULL, TRUE);
  440. if (isset($post['s'])) {
  441. $id_arr = $this->input->post('s');
  442. $id_arr = explode(',', $id_arr);
  443. if (!$id_arr) {
  444. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  445. exit;
  446. }
  447. //循环删除记录
  448. foreach ($id_arr as $v) {
  449. $sid = $this->whlabel->read($v);
  450. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  451. if ($count > 0) {
  452. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  453. exit;
  454. }
  455. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  456. if (count($zt) > 0) {
  457. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  458. exit;
  459. }
  460. $this->whlabel->remove($v);
  461. }
  462. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  463. exit;
  464. }
  465. if (isset($post['page'])) {
  466. $page = $this->input->post('page', true);
  467. $perpage = $this->input->post('perpage', true);
  468. $warehouse = $this->input->post('warehouse', true);
  469. $label = $this->input->post('label', true);
  470. $where = "1=1 and state = 0";
  471. if ($warehouse) {
  472. $where .= " and warehouse = '$warehouse'";
  473. }
  474. if ($label) {
  475. $where .= " and label = '$label'";
  476. }
  477. //数据排序
  478. $order_str = "time asc";
  479. if (empty($page)) {
  480. $start = 0;
  481. $perpage = 1;
  482. } else {
  483. $start = ($page - 1) * $perpage;
  484. }
  485. //取得信息列表
  486. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  487. foreach ($info_list as $key => $value) {
  488. if ($value['enter'] != 0) {
  489. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  490. } else {
  491. $info_list[$key]['enter'] = "";
  492. }
  493. if ($value['printing'] != 0) {
  494. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  495. } else {
  496. $info_list[$key]['printing'] = "";
  497. }
  498. }
  499. $total = $this->whlabel->find_count($where);
  500. $pagenum = ceil($total / $perpage);
  501. $over = $total - ($start + $perpage);
  502. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  503. echo json_encode($rows);
  504. exit;
  505. }
  506. $this->_Template('whlabel_existence', $this->data);
  507. }
  508. //进销存浏览
  509. public function _typedy($arg_array)
  510. {
  511. $prc = array();
  512. $purchase = $this->purchase->find_all();
  513. foreach ($purchase as $k => $v) {
  514. $prc[$v['id']] = $v['title'];
  515. }
  516. $post = $this->input->post(NULL, TRUE);
  517. if (isset($post['page'])) {
  518. $page = $this->input->post('page', true);
  519. $perpage = $this->input->post('perpage', true);
  520. $category = $this->input->post('category', true);
  521. $size = $this->input->post('size', true);
  522. $grade = $this->input->post('grade', true);
  523. $color = $this->input->post('color', true);
  524. $lowe = $this->input->post('lowe', true);
  525. $sku = $this->input->post('sku');
  526. $title = $this->input->post('title');
  527. $warehouse = $this->input->post('warehouse', true);
  528. $usa = $this->input->post('usa', true);
  529. $purchase = $this->input->post('purchase', true);
  530. $lacetype = $this->input->post('lacetype', true);
  531. $haircap = $this->input->post('haircap', true);
  532. $density = $this->input->post('density', true);
  533. $details = $this->input->post('details', true);
  534. $state = $this->input->post('state', true);
  535. $lacecolor = $this->input->post('lacecolor', true);
  536. $hairnumber = $this->input->post('hairnumber', true);
  537. $cklx = $this->input->post('cklx', true);
  538. $ktime = $this->input->post('ktime', true);
  539. $jtime = $this->input->post('jtime', true);
  540. $sm = $this->input->post('sm', true);
  541. $cpbz = $this->input->post('cpbz', true);
  542. $type = $this->input->post('type', true);
  543. $ktime = strtotime($ktime);
  544. $jtime = strtotime($jtime);
  545. $where = "1=1";
  546. $gj = "";
  547. $ck = "";
  548. if ($usa) {
  549. if (!$warehouse) {
  550. $where .= " and (warehouse = '5' or warehouse = '8')";
  551. }
  552. }
  553. if ($warehouse) {
  554. $where .= " and warehouse = '$warehouse'";
  555. }
  556. if ($details) {
  557. $where .= " and details = '$details'";
  558. }
  559. if ($purchase) {
  560. $where .= " and purchase = '$purchase'";
  561. }
  562. if (isset($state)) {
  563. if($state >-1){
  564. $where .= " and state = '$state'";
  565. }
  566. }
  567. if ($lacetype) {
  568. $where .= " and features like '%-$lacetype-%'";
  569. }
  570. if ($category) {
  571. $where .= " and features like '%-$category-%'";
  572. }
  573. if ($size) {
  574. $where .= " and features like '%-$size-%'";
  575. }
  576. if ($grade) {
  577. $where .= " and features like '%-$grade-%'";
  578. }
  579. if ($color) {
  580. $where .= " and features like '%-$color-%'";
  581. }
  582. if ($lowe) {
  583. $where .= " and features like '%-$lowe-%'";
  584. }
  585. if ($haircap) {
  586. $where .= " and features like '%-$haircap-%'";
  587. }
  588. if ($density) {
  589. $where .= " and features like '%-$density-%'";
  590. }
  591. if ($lacecolor) {
  592. $where .= " and features like '%-$lacecolor-%'";
  593. }
  594. if($sm){
  595. $where .= " and sm like '%".$sm."%'";
  596. }
  597. if($cpbz){
  598. $where .= " and cpbz like '%".$cpbz."%'";
  599. }
  600. if($type){
  601. $where .= " and type = ".$type."";
  602. }
  603. if (!empty($hairnumber)) {
  604. $where .= " and features like '%-128-%' ";
  605. if ($hairnumber < 0) {
  606. $class_list = $this->typeclass->find_all('classid = 43');
  607. foreach ($class_list as $v) {
  608. $where .= " and features not like '%-" . $v['id'] . "-%'";
  609. }
  610. } else {
  611. $where .= " and features like '%-$hairnumber-%'";
  612. }
  613. }
  614. $where_add = '';
  615. if ($cklx) {
  616. $shop = $this->shop->read($cklx);
  617. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  618. }
  619. if ($ktime && $jtime) {
  620. $gj = " and enter > '$ktime' and enter < '$jtime'";
  621. $ck = " and outk > '$ktime' and outk < '$jtime'";
  622. }
  623. //数据排序
  624. $order_str = "id desc";
  625. if (empty($page)) {
  626. $start = 0;
  627. $perpage = 1;
  628. } else {
  629. $start = ($page - 1) * $perpage;
  630. }
  631. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  632. if ($sku) {
  633. $sku = trim($sku, ' ');
  634. $sku = trim($sku, ' ');
  635. $where .= " and sku like '%$sku%'";
  636. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  637. } else if ($title) {
  638. $title = trim($title, ' ');
  639. $title = trim($title, ' ');
  640. $where .= " and title like '%$title%'";
  641. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  642. } else {
  643. //$where .= " and time > '$ktime' and time < '$jtime'";
  644. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  645. }
  646. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  647. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  648. foreach ($info_list as $k => $v) {
  649. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  650. unset($info_list[$k]['pm']);
  651. unset($info_list[$k]['jm']);
  652. unset($info_list[$k]['bm']);
  653. }
  654. //取得信息列表
  655. $rows = array();
  656. $list = array();
  657. foreach ($info_list as $key => $value) {
  658. $warehouse = $this->warehouse->read($value['warehouse']);
  659. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  660. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  661. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  662. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  663. $info_list[$key]['label'] = $value['sm'];
  664. $number = $value['number'];
  665. $ftime = time() - 15 * 24 * 3600;
  666. $info_list[$key]['warehouse'] = $warehouse['title'];
  667. $info_list[$key]['features'] = count($c);
  668. $z = count($z); //查看订单号
  669. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  670. $ztdata = '';
  671. if (count($zt) > 0) {
  672. foreach ($zt as $vv) {
  673. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  674. }
  675. }
  676. $info_list[$key]['number'] = $ztdata;
  677. $info_list[$key]['sm'] = $z;
  678. $details = array();
  679. $cpid = array();
  680. foreach ($c as $k => $v) {
  681. $details[$v['details']] = $v['details'];
  682. if ($v['cpid'] != 0) {
  683. $cpid[$v['cpid']] = $v['cpid'];
  684. }
  685. }
  686. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  687. if ($value['shop'] != '') {
  688. $shop = explode(',', trim($value['shop'], ','));
  689. $shop = $this->shop->read($shop[0]);
  690. $info_list[$key]['shop'] = $shop['shopname'];
  691. }
  692. }
  693. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  694. $pagenum = ceil($total / $perpage);
  695. $over = $total - ($start + $perpage);
  696. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  697. echo json_encode($rows);
  698. exit;
  699. }
  700. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  701. $this->_Template('whlabel_typedy', $this->data);
  702. }
  703. //进销存浏览
  704. public function _typedy_ck($arg_array)
  705. {
  706. $prc = array();
  707. $purchase = $this->purchase->find_all();
  708. foreach ($purchase as $k => $v) {
  709. $prc[$v['id']] = $v['title'];
  710. }
  711. $post = $this->input->post(NULL, TRUE);
  712. if (isset($post['page'])) {
  713. $page = $this->input->post('page', true);
  714. $perpage = $this->input->post('perpage', true);
  715. $category = $this->input->post('category', true);
  716. $size = $this->input->post('size', true);
  717. $grade = $this->input->post('grade', true);
  718. $color = $this->input->post('color', true);
  719. $lowe = $this->input->post('lowe', true);
  720. $sku = $this->input->post('sku');
  721. $title = $this->input->post('title');
  722. $warehouse = $this->input->post('warehouse', true);
  723. $usa = $this->input->post('usa', true);
  724. $purchase = $this->input->post('purchase', true);
  725. $lacetype = $this->input->post('lacetype', true);
  726. $haircap = $this->input->post('haircap', true);
  727. $density = $this->input->post('density', true);
  728. $details = $this->input->post('details', true);
  729. $state = $this->input->post('state', true);
  730. $lacecolor = $this->input->post('lacecolor', true);
  731. $cklx = $this->input->post('cklx', true);
  732. $ktime = $this->input->post('ktime', true);
  733. $jtime = $this->input->post('jtime', true);
  734. $ktime = strtotime($ktime);
  735. $jtime = strtotime($jtime);
  736. $where = "1=1";
  737. $gj = "";
  738. $ck = "";
  739. if ($lacetype) {
  740. $where .= " and features like '%-$lacetype-%'";
  741. }
  742. if ($category) {
  743. $where .= " and features like '%-$category-%'";
  744. }
  745. if ($size) {
  746. $where .= " and features like '%-$size-%'";
  747. }
  748. if ($grade) {
  749. $where .= " and features like '%-$grade-%'";
  750. }
  751. if ($color) {
  752. $where .= " and features like '%-$color-%'";
  753. }
  754. if ($lowe) {
  755. $where .= " and features like '%-$lowe-%'";
  756. }
  757. if ($haircap) {
  758. $where .= " and features like '%-$haircap-%'";
  759. }
  760. if ($density) {
  761. $where .= " and features like '%-$density-%'";
  762. }
  763. if ($lacecolor) {
  764. $where .= " and features like '%-$lacecolor-%'";
  765. }
  766. if ($usa) {
  767. if (!$warehouse) {
  768. $where .= " and (warehouse = '5' or warehouse = '8')";
  769. }
  770. }
  771. if ($warehouse) {
  772. $where .= " and warehouse = '$warehouse'";
  773. }
  774. if ($details) {
  775. $where .= " and details = '$details'";
  776. }
  777. if ($purchase) {
  778. $where .= " and purchase = '$purchase'";
  779. }
  780. if ($state) {
  781. $where .= " and state = '$state'";
  782. }
  783. $where_add = '';
  784. if ($cklx) {
  785. $shop = $this->shop->read($cklx);
  786. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  787. }
  788. if ($ktime && $jtime) {
  789. $gj = " and enter > '$ktime' and enter < '$jtime'";
  790. $ck = " and outk > '$ktime' and outk < '$jtime'";
  791. }
  792. //数据排序
  793. $order_str = "id desc";
  794. if (empty($page)) {
  795. $start = 0;
  796. $perpage = 1;
  797. } else {
  798. $start = ($page - 1) * $perpage;
  799. }
  800. if ($sku) {
  801. $sku = trim($sku, ' ');
  802. $sku = trim($sku, ' ');
  803. $where .= " and sku like '%$sku%'";
  804. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  805. } else if ($title) {
  806. $title = trim($title, ' ');
  807. $title = trim($title, ' ');
  808. $where .= " and title like '%$title%'";
  809. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  810. } else {
  811. //$where .= " and time > '$ktime' and time < '$jtime'";
  812. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  813. }
  814. //取得信息列表
  815. $rows = array();
  816. $list = array();
  817. foreach ($info_list as $key => $value) {
  818. $warehouse = $this->warehouse->read($value['warehouse']);
  819. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  820. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  821. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  822. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  823. $ftime = time() - 15 * 24 * 3600;
  824. $info_list[$key]['warehouse'] = $warehouse['title'];
  825. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  826. //$z = count($z);//查看订单号
  827. //$info_list[$key]['zd'] = $z;
  828. $details = array();
  829. $cpid = array();
  830. foreach ($c as $k => $v) {
  831. $details[$v['details']] = $v['details'];
  832. if ($v['cpid'] != 0) {
  833. $cpid[$v['cpid']] = $v['cpid'];
  834. }
  835. }
  836. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  837. if ($value['shop'] != '') {
  838. $shop = explode(',', trim($value['shop'], ','));
  839. $shop = $this->shop->read($shop[0]);
  840. $info_list[$key]['shop'] = $shop['shopname'];
  841. }
  842. }
  843. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  844. $pagenum = ceil($total / $perpage);
  845. $over = $total - ($start + $perpage);
  846. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  847. echo json_encode($rows);
  848. exit;
  849. }
  850. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  851. $this->_Template('whlabel_typedy_ck', $this->data);
  852. }
  853. public function _typeck($arg_array)
  854. {
  855. $prc = array();
  856. $purchase = $this->purchase->find_all();
  857. foreach ($purchase as $k => $v) {
  858. $prc[$v['id']] = $v['title'];
  859. }
  860. $post = $this->input->post(NULL, TRUE);
  861. if (isset($post['page'])) {
  862. $page = $this->input->post('page', true);
  863. $perpage = $this->input->post('perpage', true);
  864. $category = $this->input->post('category', true);
  865. $size = $this->input->post('size', true);
  866. $grade = $this->input->post('grade', true);
  867. $color = $this->input->post('color', true);
  868. $lacecolor = $this->input->post('lacecolor', true);
  869. $lowe = $this->input->post('lowe', true);
  870. $sku = $this->input->post('sku');
  871. $title = $this->input->post('title');
  872. $warehouse = 13;
  873. $usa = $this->input->post('usa', true);
  874. $purchase = $this->input->post('purchase', true);
  875. $lacetype = $this->input->post('lacetype', true);
  876. $haircap = $this->input->post('haircap', true);
  877. $density = $this->input->post('density', true);
  878. $details = $this->input->post('details', true);
  879. $state = $this->input->post('state', true);
  880. $ktime = $this->input->post('ktime', true);
  881. $jtime = $this->input->post('jtime', true);
  882. $ktime = strtotime($ktime);
  883. $jtime = strtotime($jtime);
  884. $where = "1=1";
  885. $gj = "";
  886. $ck = "";
  887. if ($lacetype) {
  888. $where .= " and features like '%-$lacetype-%'";
  889. }
  890. if ($category) {
  891. $where .= " and features like '%-$category-%'";
  892. }
  893. if ($size) {
  894. $where .= " and features like '%-$size-%'";
  895. }
  896. if ($grade) {
  897. $where .= " and features like '%-$grade-%'";
  898. }
  899. if ($color) {
  900. $where .= " and features like '%-$color-%'";
  901. }
  902. if ($lacecolor) {
  903. $where .= " and features like '%-$lacecolor-%'";
  904. }
  905. if ($lowe) {
  906. $where .= " and features like '%-$lowe-%'";
  907. }
  908. if ($haircap) {
  909. $where .= " and features like '%-$haircap-%'";
  910. }
  911. if ($density) {
  912. $where .= " and features like '%-$density-%'";
  913. }
  914. if ($warehouse) {
  915. $where .= " and warehouse = '$warehouse'";
  916. }
  917. if ($details) {
  918. $where .= " and details = '$details'";
  919. }
  920. if ($purchase) {
  921. $where .= " and purchase = '$purchase'";
  922. }
  923. if ($state) {
  924. $where .= " and state = '$state'";
  925. }
  926. if ($ktime && $jtime) {
  927. $gj = " and enter > '$ktime' and enter < '$jtime'";
  928. $ck = " and outk > '$ktime' and outk < '$jtime'";
  929. }
  930. //数据排序
  931. $order_str = "id desc";
  932. if (empty($page)) {
  933. $start = 0;
  934. $perpage = 1;
  935. } else {
  936. $start = ($page - 1) * $perpage;
  937. }
  938. if ($sku) {
  939. $sku = trim($sku, ' ');
  940. $sku = trim($sku, ' ');
  941. $where .= " and sku like '%$sku%'";
  942. } else if ($title) {
  943. $title = trim($title, ' ');
  944. $title = trim($title, ' ');
  945. $where .= " and title like '%$title%'";
  946. }
  947. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  948. //取得信息列表
  949. $t = array();
  950. $typeclass = $this->typeclass->find_all();
  951. foreach ($typeclass as $v) {
  952. $t[$v['id']] = $v;
  953. }
  954. $rows = array();
  955. $list = array();
  956. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  957. foreach ($info_list as $key => $value) {
  958. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  959. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  960. $warehouse = $this->warehouse->read($value['warehouse']);
  961. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  962. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  963. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  964. $number = $value['number'];
  965. $ftime = time() - 15 * 24 * 3600;
  966. $z = count($z); //查看订单号
  967. $info_list[$key]['warehouse'] = $warehouse['title'];
  968. $info_list[$key]['features'] = count($c);
  969. $info_list[$key]['number'] = $z;
  970. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  971. $details = array();
  972. $cpid = array();
  973. foreach ($c as $k => $v) {
  974. $details[$v['details']] = $v['details'];
  975. if ($v['cpid'] != 0) {
  976. $cpid[$v['cpid']] = $v['cpid'];
  977. }
  978. }
  979. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  980. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  981. unset($info_list[$key]['pm']);
  982. unset($info_list[$key]['jm']);
  983. unset($info_list[$key]['bm']);
  984. }
  985. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  986. $pagenum = ceil($total / $perpage);
  987. $over = $total - ($start + $perpage);
  988. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  989. echo json_encode($rows);
  990. exit;
  991. }
  992. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  993. $this->_Template('whlabel_typeck', $this->data);
  994. }
  995. //进销存导出
  996. public function _whlabeckdc()
  997. {
  998. $prc = array();
  999. $purchase = $this->purchase->find_all();
  1000. foreach ($purchase as $k => $v) {
  1001. $prc[$v['id']] = $v['title'];
  1002. }
  1003. if (isset($_GET['excel'])) {
  1004. $where = "sku != 'Preset'";
  1005. //数据排序
  1006. $order_str = "id desc";
  1007. if (empty($page)) {
  1008. $start = 0;
  1009. $perpage = 1;
  1010. } else {
  1011. $start = ($page - 1) * $perpage;
  1012. }
  1013. $category = $this->input->get('category', true);
  1014. $color = $this->input->get('color', true);
  1015. $lowe = $this->input->get('lowe', true);
  1016. $lacetype = $this->input->get('lacetype', true);
  1017. $size = $this->input->get('size', true);
  1018. $density = $this->input->get('density', true);
  1019. $haircap = $this->input->get('haircap', true);
  1020. $sku = $this->input->get('sku', true);
  1021. $details = $this->input->get('details', true);
  1022. $warehouse = 13;
  1023. $excelid = $this->input->get('sid', true);
  1024. if ($category) {
  1025. $where .= " and features like '%-$category-%'";
  1026. }
  1027. if ($color) {
  1028. $where .= " and features like '%-$color-%'";
  1029. }
  1030. if ($lowe) {
  1031. $where .= " and features like '%-$lowe-%'";
  1032. }
  1033. if ($lacetype) {
  1034. $where .= " and features like '%-$lacetype-%'";
  1035. }
  1036. if ($size) {
  1037. $where .= " and features like '%-$size-%'";
  1038. }
  1039. if ($density) {
  1040. $where .= " and features like '%-$density-%'";
  1041. }
  1042. if ($haircap) {
  1043. $where .= " and features like '%-$haircap-%'";
  1044. }
  1045. if ($warehouse) {
  1046. $where .= " and warehouse = '$warehouse'";
  1047. }
  1048. if ($sku) {
  1049. $where .= " and sku like '%$sku%'";
  1050. }
  1051. if ($details) {
  1052. $where .= " and details = '$details'";
  1053. }
  1054. $xzid = '';
  1055. if ($excelid) {
  1056. $excelid = explode(',', trim($excelid, ','));
  1057. foreach ($excelid as $key => $value) {
  1058. $xzid .= " id = " . $value . " or";
  1059. }
  1060. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1061. }
  1062. //取得信息列表
  1063. /**
  1064. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1065. $rows = array();$list = array();
  1066. foreach ($info_list as $key=>$value)
  1067. {
  1068. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1069. }
  1070. **/
  1071. $wh = array();
  1072. $w = $this->warehouse->find_all('1=1', 'id,title');
  1073. foreach ($w as $v) {
  1074. $wh[$v['id']] = $v['title'];
  1075. }
  1076. $tc = array();
  1077. $tcdata = array();
  1078. $list = array();
  1079. $classid = $this->classid->sku();
  1080. $tcall = $this->typeclass->find_all();
  1081. $typeclass = array();
  1082. foreach ($tcall as $v)
  1083. {
  1084. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1085. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1086. }
  1087. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1088. foreach ($rows as $key => $value) {
  1089. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1090. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1091. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1092. $rows[$key]['cpbz'] = $u9_info['bm'];
  1093. $rows[$key]['cs'] = $u9_info['jm'];
  1094. if(empty($value['details'])){
  1095. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1096. }else{
  1097. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1098. }
  1099. $details = array();
  1100. $cpid = array();
  1101. $cpbz = array();
  1102. $c = 0;
  1103. $g = 0;
  1104. $x = 0;
  1105. $t = 0;
  1106. $s = 0;
  1107. $q = 0;
  1108. foreach ($sd as $k => $v) {
  1109. if ($v['state'] == 0) {
  1110. $c++;
  1111. }
  1112. if ($v['state'] != 9) {
  1113. $g++;
  1114. }
  1115. if ($v['state'] == 1) {
  1116. $x++;
  1117. }
  1118. if ($v['state'] == 2) {
  1119. $t++;
  1120. }
  1121. if ($v['state'] == 8) {
  1122. $s++;
  1123. }
  1124. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1125. $q++;
  1126. }
  1127. $details[$v['details']] = $v['details'];
  1128. if ($v['cpid'] != 0) {
  1129. $cpid[$v['cpid']] = $v['cpid'];
  1130. }
  1131. if ($v['cpbz'] != '') {
  1132. $cpbz[$v['cpbz']] = $v['cpbz'];
  1133. }
  1134. }
  1135. $rows[$key]['details'] = implode("、", $details);
  1136. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1137. $number = $value['number'];
  1138. $ftime = time() - 15 * 24 * 3600;
  1139. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1140. $rows[$key]['number'] = $g;
  1141. $rows[$key]['features'] = $c;
  1142. $rows[$key]['x'] = $x;
  1143. $rows[$key]['t'] = $t;
  1144. $rows[$key]['s'] = $s;
  1145. $rows[$key]['q'] = $q;
  1146. $rows[$key]['wzsl'] = count($details);
  1147. //cpbzs
  1148. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1149. $unique_arr = array_unique($tmp_cpbzs);
  1150. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1151. }
  1152. $title = "进销存统计表" . date('Y-m-d', time());
  1153. $titlename = "<table border=1>
  1154. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1155. <tr align='center'>
  1156. <td>仓库</td>
  1157. <td>供应商</td>
  1158. <td>位置</td>
  1159. <td>库存编码</td>
  1160. <td>SKU</td>
  1161. <td>用友编码</td>
  1162. <td>用友料号</td>
  1163. <td>产品英文名</td>
  1164. <td>产品中文名</td>
  1165. <td>备注</td>
  1166. <td>入库总量</td>
  1167. <td>库存数量</td>
  1168. <td>销售数量</td>
  1169. <td>退货数量</td>
  1170. <td>删除数量</td>
  1171. <td>其它操作</td>
  1172. <td>位置数量</td>
  1173. </tr>
  1174. </table>";
  1175. $filename = $title . ".xls";
  1176. $tail = "";
  1177. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1178. }
  1179. }
  1180. public function _type()
  1181. {
  1182. $vip = 0;
  1183. if (isset($_SESSION['api'])) {
  1184. $user = $this->user->get_api($_SESSION['api']);
  1185. $fgshop = "";
  1186. $sid = "";
  1187. $usersp = explode('|', trim($user['shop'], '|'));
  1188. foreach ($usersp as $value) {
  1189. $fgshop .= " shop = " . $value . " or";
  1190. $sid .= " id = " . $value . " or";
  1191. }
  1192. if ($user['vip'] == 1) {
  1193. $vip = 1;
  1194. }
  1195. } else {
  1196. header('Location: /');
  1197. exit;
  1198. }
  1199. $prc = array();
  1200. $purchase = $this->purchase->find_all();
  1201. foreach ($purchase as $k => $v) {
  1202. $prc[$v['id']] = $v['title'];
  1203. }
  1204. $company = array();
  1205. $ct = $this->company->find_all();
  1206. foreach ($ct as $k => $v) {
  1207. $company[$v['id']] = $v['title'];
  1208. }
  1209. $sp = array();
  1210. $s = $this->shop->find_all('1=1', 'id,shopname');
  1211. foreach ($s as $v) {
  1212. $sp[$v['id']] = $v['shopname'];
  1213. }
  1214. $wh = array();
  1215. $w = $this->warehouse->find_all('1=1', 'id,title');
  1216. foreach ($w as $v) {
  1217. $wh[$v['id']] = $v['title'];
  1218. }
  1219. $post = $this->input->post(NULL, TRUE);
  1220. if (isset($post['page'])) {
  1221. $page = $this->input->post('page', true);
  1222. $perpage = $this->input->post('perpage', true);
  1223. $category = $this->input->post('category', true);
  1224. $size = $this->input->post('size', true);
  1225. $grade = $this->input->post('grade', true);
  1226. $color = $this->input->post('color', true);
  1227. $lowe = $this->input->post('lowe', true);
  1228. $sku = $this->input->post('sku');
  1229. $title = $this->input->post('title');
  1230. $warehouse = $this->input->post('warehouse', true);
  1231. $usa = $this->input->post('usa', true);
  1232. $purchase = $this->input->post('purchase', true);
  1233. $lacetype = $this->input->post('lacetype', true);
  1234. $haircap = $this->input->post('haircap', true);
  1235. $density = $this->input->post('density', true);
  1236. $details = $this->input->post('details', true);
  1237. $state = $this->input->post('state', true);
  1238. $shop = $this->input->post('shop', true);
  1239. $lacecolor = $this->input->post('lacecolor', true);
  1240. $hairnumber = $this->input->post('hairnumber', true);
  1241. $type = $this->input->post('type', true);
  1242. $ktime = $this->input->post('ktime', true);
  1243. $jtime = $this->input->post('jtime', true);
  1244. $ktime = strtotime($ktime);
  1245. $jtime = strtotime($jtime);
  1246. $cpbz = $this->input->post('cpbz', true);
  1247. $sm = $this->input->post('sm', true);
  1248. $where = "1=1";
  1249. $gj = "";
  1250. $ck = "";
  1251. if ($usa) {
  1252. if (!$warehouse) {
  1253. $where .= " and (warehouse = '5' or warehouse = '8')";
  1254. }
  1255. }
  1256. if ($warehouse) {
  1257. $where .= " and warehouse = '$warehouse'";
  1258. }
  1259. if ($details) {
  1260. $where .= " and details = '$details'";
  1261. }
  1262. if ($purchase) {
  1263. $where .= " and purchase = '$purchase'";
  1264. }
  1265. if ($state) {
  1266. $where .= " and state = '$state'";
  1267. }
  1268. if ($shop) {
  1269. $where .= " and shop like '%$shop%'";
  1270. }
  1271. if ($type) {
  1272. $where .= " and type = '$type'";
  1273. }
  1274. if ($ktime && $jtime) {
  1275. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1276. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1277. }
  1278. if ($cpbz) {
  1279. $where .= " and cpbz like '%$cpbz%' ";
  1280. }
  1281. if ($sm) {
  1282. $where .= " and sm like '%$sm%' ";
  1283. }
  1284. if ($lacecolor) {
  1285. $where .= " and features like '%-$lacecolor-%'";
  1286. }
  1287. if ($lacetype) {
  1288. $where .= " and features like '%-$lacetype-%'";
  1289. }
  1290. if ($category) {
  1291. $where .= " and features like '%-$category-%'";
  1292. }
  1293. if ($size) {
  1294. $where .= " and features like '%-$size-%'";
  1295. }
  1296. if ($grade) {
  1297. $where .= " and features like '%-$grade-%'";
  1298. }
  1299. if ($color) {
  1300. $where .= " and features like '%-$color-%'";
  1301. }
  1302. if ($lowe) {
  1303. $where .= " and features like '%-$lowe-%'";
  1304. }
  1305. if ($haircap) {
  1306. $where .= " and features like '%-$haircap-%'";
  1307. }
  1308. if ($density) {
  1309. $where .= " and features like '%-$density-%'";
  1310. }
  1311. if (!empty($hairnumber)) {
  1312. $where .= " and features like '%-128-%' ";
  1313. if ($hairnumber < 0) {
  1314. $class_list = $this->typeclass->find_all('classid = 43');
  1315. foreach ($class_list as $v) {
  1316. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1317. }
  1318. } else {
  1319. $where .= " and features like '%-$hairnumber-%'";
  1320. }
  1321. }
  1322. //数据排序
  1323. $order_str = "id desc";
  1324. if (empty($page)) {
  1325. $start = 0;
  1326. $perpage = 1;
  1327. } else {
  1328. $start = ($page - 1) * $perpage;
  1329. }
  1330. $fjnr = '';
  1331. if ($sku) {
  1332. $sku = trim($sku, ' ');
  1333. $sku = trim($sku, ' ');
  1334. $fjnr .= " and sku like '%$sku%'";
  1335. }
  1336. if ($title) {
  1337. $title = trim($title, ' ');
  1338. $title = trim($title, ' ');
  1339. $fjnr .= " and title like '%$title%'";
  1340. }
  1341. $wt = array();
  1342. $whlabel_type = $this->whlabel_type->find_all();
  1343. foreach ($whlabel_type as $v) {
  1344. $wt[$v['id']] = $v['title'];
  1345. }
  1346. //$where .= " and time > '$ktime' and time < '$jtime'";
  1347. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1348. //取得信息列表
  1349. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1350. $rows = array();
  1351. $list = array();
  1352. foreach ($info_list as $key => $value) {
  1353. if (isset($wt[$value['type']])) {
  1354. $info_list[$key]['type'] = $wt[$value['type']];
  1355. } else {
  1356. $info_list[$key]['type'] = '未设置';
  1357. }
  1358. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1359. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1360. $ztdata = '';
  1361. if (count($zt) > 0) {
  1362. foreach ($zt as $vv) {
  1363. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1364. }
  1365. }
  1366. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1367. $cdata = array_filter($qbdata, function ($item) {
  1368. return $item['state'] < 1;
  1369. });
  1370. $c = array_sum(array_column($cdata, 'jnum'));
  1371. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1373. });
  1374. $g = array_sum(array_column($gdata, 'jnum'));
  1375. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1376. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1377. });
  1378. $x = array_sum(array_column($xdata, 'jnum'));
  1379. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1380. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1381. });
  1382. $t = array_sum(array_column($tdata, 'jnum'));
  1383. // $zdata = array_filter($qbdata, function ($item) {
  1384. // return $item['zd'] != "" && $item['state'] < 1;
  1385. // });
  1386. // $z = array_sum(array_column($zdata, 'jnum'));
  1387. $zdata = array_filter($qbdata, function ($item) {
  1388. return $item['zd'] != "" && $item['state'] < 1;
  1389. });
  1390. $z = array_sum(array_column($zdata, 'jnum'));
  1391. //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1392. //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1393. //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1394. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1395. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1396. $details = array();
  1397. $cpid = array();
  1398. $od = array();
  1399. $odid = '';
  1400. $companytitle = '';
  1401. $shop_list = [];
  1402. foreach ($qbdata as $v) {
  1403. if ($v['zd'] != "" && $v['state'] < 1) {
  1404. if (!isset($od[$v['zd']])) {
  1405. $od[$v['zd']] = 1; //所有数据sku
  1406. } else {
  1407. $od[$v['zd']] = $od[$v['zd']] + 1;
  1408. }
  1409. }
  1410. if($v['state'] == 0){
  1411. $details[$v['details']] = $v['details'];
  1412. }
  1413. if ($v['state'] < 1) {
  1414. //$details[$v['details']] = $v['details'];
  1415. if ($v['cpid'] != 0) {
  1416. $cpid[$v['cpid']] = $v['cpid'];
  1417. }
  1418. }
  1419. if($v['state'] == 0){
  1420. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1421. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1422. }
  1423. if ($v['shop'] != '') {
  1424. $shop = explode(',', trim($v['shop'], ','));
  1425. foreach ($shop as $vv) {
  1426. if (!in_array($vv, $shop_list)) {
  1427. $shop_list[] = $vv;
  1428. }
  1429. }
  1430. }
  1431. }
  1432. }
  1433. foreach ($od as $k => $vv) {
  1434. $odid .= $k . '数量' . $vv;
  1435. }
  1436. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1437. $info_list[$key]['label'] = $value['sm'];
  1438. $number = $value['number'];
  1439. $ftime = time() - 15 * 24 * 3600;
  1440. $z = $z . '(' . $odid . ')'; //查看订单号
  1441. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1442. $info_list[$key]['features'] = $c;
  1443. $info_list[$key]['number'] = $ztdata;
  1444. $info_list[$key]['sm'] = $g;
  1445. $info_list[$key]['x'] = $x;
  1446. $info_list[$key]['t'] = $t;
  1447. $info_list[$key]['z'] = $z;
  1448. /**
  1449. foreach ($cdata as $k=>$v)
  1450. {
  1451. $details[$v['details']] = $v['details'];
  1452. if($v['cpid'] != 0)
  1453. {
  1454. $cpid[$v['cpid']] = $v['cpid'];
  1455. }
  1456. }
  1457. **/
  1458. $info_list[$key]['shop'] = '';
  1459. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1460. // if ($value['shop'] != '') {
  1461. // $shop = explode(',', trim($value['shop'], ','));
  1462. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1463. // }
  1464. $shop_list = array_unique($shop_list);
  1465. $shop_str = '';
  1466. foreach ($shop_list as $v) {
  1467. if(isset($sp[$v])){
  1468. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1469. }
  1470. }
  1471. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1472. /**
  1473. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1474. if(isset($companytitle[0]))
  1475. {
  1476. foreach ($companytitle as $k=>$v)
  1477. {
  1478. if($v['companytitle'] != '')
  1479. {
  1480. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1481. }
  1482. }
  1483. }
  1484. **/
  1485. }
  1486. $final_all_list = [];
  1487. foreach ($info_list as $k => $v) {
  1488. $final_all_list[] = [
  1489. 'id' => $v['id'],
  1490. "warehouse" => $v["warehouse"],
  1491. "purchase" => $v["purchase"],
  1492. "sku" => $v["sku"],
  1493. "title" => $v["title"] . "<br/>" . $v["pm"],
  1494. "details" => $v["details"],
  1495. "shop" => $v["shop"],
  1496. "cpbz" => $v["cpbz"],
  1497. 'label' => $v['label'],
  1498. "type" => $v["type"],
  1499. "features" => $v["features"],
  1500. "number" => $v["number"],
  1501. "sm" => $v["sm"],
  1502. "x" => $v["x"],
  1503. "t" => $v["t"],
  1504. "z" => $v["z"]
  1505. ];
  1506. }
  1507. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1508. $pagenum = ceil($total / $perpage);
  1509. $over = $total - ($start + $perpage);
  1510. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1511. echo json_encode($rows);
  1512. exit;
  1513. }
  1514. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1515. $this->data['shop'] = $wlshop;
  1516. $this->data['vip'] = $vip;
  1517. $this->_Template('whlabel_type', $this->data);
  1518. }
  1519. /**
  1520. * _type 优化版 v1
  1521. * 优化点:
  1522. * 1. 循环内 N+1 查询改为批量预取(方案 A),SQL 从 2+2P 降到固定 4 条
  1523. * 2. 总数统计改为只 COUNT 不传输明细字段(方案 C)
  1524. * 3. 批量 qbdata 查询去掉 features like 条件,走组合键 IN 精确匹配
  1525. * 4. 批量 transport 查询加 ORDER BY stime 保证顺序与原来一致
  1526. */
  1527. public function _typev1()
  1528. {
  1529. $vip = 0;
  1530. if (isset($_SESSION['api'])) {
  1531. $user = $this->user->get_api($_SESSION['api']);
  1532. $fgshop = "";
  1533. $sid = "";
  1534. $usersp = explode('|', trim($user['shop'], '|'));
  1535. foreach ($usersp as $value) {
  1536. $fgshop .= " shop = " . $value . " or";
  1537. $sid .= " id = " . $value . " or";
  1538. }
  1539. if ($user['vip'] == 1) {
  1540. $vip = 1;
  1541. }
  1542. } else {
  1543. header('Location: /');
  1544. exit;
  1545. }
  1546. $prc = array();
  1547. $purchase = $this->purchase->find_all();
  1548. foreach ($purchase as $k => $v) {
  1549. $prc[$v['id']] = $v['title'];
  1550. }
  1551. $company = array();
  1552. $ct = $this->company->find_all();
  1553. foreach ($ct as $k => $v) {
  1554. $company[$v['id']] = $v['title'];
  1555. }
  1556. $sp = array();
  1557. $s = $this->shop->find_all('1=1', 'id,shopname');
  1558. foreach ($s as $v) {
  1559. $sp[$v['id']] = $v['shopname'];
  1560. }
  1561. $wh = array();
  1562. $w = $this->warehouse->find_all('1=1', 'id,title');
  1563. foreach ($w as $v) {
  1564. $wh[$v['id']] = $v['title'];
  1565. }
  1566. $post = $this->input->post(NULL, TRUE);
  1567. if (isset($post['page'])) {
  1568. $page = $this->input->post('page', true);
  1569. $perpage = $this->input->post('perpage', true);
  1570. $category = $this->input->post('category', true);
  1571. $size = $this->input->post('size', true);
  1572. $grade = $this->input->post('grade', true);
  1573. $color = $this->input->post('color', true);
  1574. $lowe = $this->input->post('lowe', true);
  1575. $sku = $this->input->post('sku');
  1576. $title = $this->input->post('title');
  1577. $warehouse = $this->input->post('warehouse', true);
  1578. $usa = $this->input->post('usa', true);
  1579. $purchase = $this->input->post('purchase', true);
  1580. $lacetype = $this->input->post('lacetype', true);
  1581. $haircap = $this->input->post('haircap', true);
  1582. $density = $this->input->post('density', true);
  1583. $details = $this->input->post('details', true);
  1584. $state = $this->input->post('state', true);
  1585. $shop = $this->input->post('shop', true);
  1586. $lacecolor = $this->input->post('lacecolor', true);
  1587. $hairnumber = $this->input->post('hairnumber', true);
  1588. $type = $this->input->post('type', true);
  1589. $ktime = $this->input->post('ktime', true);
  1590. $jtime = $this->input->post('jtime', true);
  1591. $ktime = strtotime($ktime);
  1592. $jtime = strtotime($jtime);
  1593. $cpbz = $this->input->post('cpbz', true);
  1594. $sm = $this->input->post('sm', true);
  1595. $where = "1=1";
  1596. // $where_no_features 用于批量预取,去掉 features like 条件,靠组合键精确匹配
  1597. $where_no_features = "1=1";
  1598. if ($usa) {
  1599. if (!$warehouse) {
  1600. $where .= " and (warehouse = '5' or warehouse = '8')";
  1601. $where_no_features .= " and (warehouse = '5' or warehouse = '8')";
  1602. }
  1603. }
  1604. if ($warehouse) {
  1605. $where .= " and warehouse = '$warehouse'";
  1606. $where_no_features .= " and warehouse = '$warehouse'";
  1607. }
  1608. if ($details) {
  1609. $where .= " and details = '$details'";
  1610. $where_no_features .= " and details = '$details'";
  1611. }
  1612. if ($purchase) {
  1613. $where .= " and purchase = '$purchase'";
  1614. $where_no_features .= " and purchase = '$purchase'";
  1615. }
  1616. if ($state) {
  1617. $where .= " and state = '$state'";
  1618. $where_no_features .= " and state = '$state'";
  1619. }
  1620. if ($shop) {
  1621. $where .= " and shop like '%$shop%'";
  1622. $where_no_features .= " and shop like '%$shop%'";
  1623. }
  1624. if ($type) {
  1625. $where .= " and type = '$type'";
  1626. $where_no_features .= " and type = '$type'";
  1627. }
  1628. if ($cpbz) {
  1629. $where .= " and cpbz like '%$cpbz%' ";
  1630. $where_no_features .= " and cpbz like '%$cpbz%' ";
  1631. }
  1632. if ($sm) {
  1633. $where .= " and sm like '%$sm%' ";
  1634. $where_no_features .= " and sm like '%$sm%' ";
  1635. }
  1636. // features like 条件只加入 $where(列表分组用),不加入 $where_no_features
  1637. if ($lacecolor) {
  1638. $where .= " and features like '%-$lacecolor-%'";
  1639. }
  1640. if ($lacetype) {
  1641. $where .= " and features like '%-$lacetype-%'";
  1642. }
  1643. if ($category) {
  1644. $where .= " and features like '%-$category-%'";
  1645. }
  1646. if ($size) {
  1647. $where .= " and features like '%-$size-%'";
  1648. }
  1649. if ($grade) {
  1650. $where .= " and features like '%-$grade-%'";
  1651. }
  1652. if ($color) {
  1653. $where .= " and features like '%-$color-%'";
  1654. }
  1655. if ($lowe) {
  1656. $where .= " and features like '%-$lowe-%'";
  1657. }
  1658. if ($haircap) {
  1659. $where .= " and features like '%-$haircap-%'";
  1660. }
  1661. if ($density) {
  1662. $where .= " and features like '%-$density-%'";
  1663. }
  1664. if (!empty($hairnumber)) {
  1665. $where .= " and features like '%-128-%' ";
  1666. if ($hairnumber < 0) {
  1667. $class_list = $this->typeclass->find_all('classid = 43');
  1668. foreach ($class_list as $v) {
  1669. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1670. }
  1671. } else {
  1672. $where .= " and features like '%-$hairnumber-%'";
  1673. }
  1674. }
  1675. //数据排序
  1676. $order_str = "id desc";
  1677. if (empty($page)) {
  1678. $start = 0;
  1679. $perpage = 1;
  1680. } else {
  1681. $start = ($page - 1) * $perpage;
  1682. }
  1683. $fjnr = '';
  1684. if ($sku) {
  1685. $sku = trim($sku, ' ');
  1686. $sku = trim($sku, ' ');
  1687. $fjnr .= " and sku like '%$sku%'";
  1688. }
  1689. if ($title) {
  1690. $title = trim($title, ' ');
  1691. $title = trim($title, ' ');
  1692. $fjnr .= " and title like '%$title%'";
  1693. }
  1694. $wt = array();
  1695. $whlabel_type = $this->whlabel_type->find_all();
  1696. foreach ($whlabel_type as $v) {
  1697. $wt[$v['id']] = $v['title'];
  1698. }
  1699. // 列表分组(与原来完全一致)
  1700. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage);
  1701. //取得信息列表
  1702. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1703. // ========== 优化方案 A:批量预取 whlabel 组数据和 transport 数据 ==========
  1704. $keys = array();
  1705. foreach ($info_list as $v) {
  1706. $keys[] = "('" . addslashes($v['sku']) . "','" . addslashes($v['purchase'])
  1707. . "','" . addslashes($v['features']) . "','" . addslashes($v['warehouse']) . "')";
  1708. }
  1709. // 组合键函数,用于 PHP 端按分组索引
  1710. $comboKey = function ($r) {
  1711. return $r['sku'] . '|' . $r['purchase'] . '|' . $r['features'] . '|' . $r['warehouse'];
  1712. };
  1713. // 批量拉取 whlabel 组数据(使用 $where_no_features,不带 features like,靠 IN 元组精确匹配)
  1714. $all_qb = array();
  1715. if (!empty($keys)) {
  1716. $keyInSql = implode(',', $keys);
  1717. $qbAll = $this->whlabel->find_all(
  1718. $where_no_features . " and (sku,purchase,features,warehouse) IN (" . $keyInSql . ")"
  1719. );
  1720. foreach ($qbAll as $r) {
  1721. $all_qb[$comboKey($r)][] = $r;
  1722. }
  1723. }
  1724. // 批量拉取 transport 在途数据(3 列元组: sku,warehouse,features,与 IN 左侧列顺序一致)
  1725. $all_zt = array();
  1726. if (!empty($info_list)) {
  1727. $ztKeys = array();
  1728. foreach ($info_list as $v) {
  1729. $ztKeys[] = "('" . addslashes($v['sku']) . "','"
  1730. . addslashes($v['warehouse']) . "','"
  1731. . addslashes($v['features']) . "')";
  1732. }
  1733. $ztInSql = implode(',', $ztKeys);
  1734. $ztAll = $this->whlabeltransport->find_all(
  1735. "cz = '0' and (sku,warehouse,features) IN (" . $ztInSql . ")",
  1736. '*',
  1737. 'stime'
  1738. );
  1739. foreach ($ztAll as $r) {
  1740. $ck = $r['sku'] . '|' . $r['warehouse'] . '|' . $r['features'];
  1741. $all_zt[$ck][] = $r;
  1742. }
  1743. }
  1744. $rows = array();
  1745. $list = array();
  1746. foreach ($info_list as $key => $value) {
  1747. if (isset($wt[$value['type']])) {
  1748. $info_list[$key]['type'] = $wt[$value['type']];
  1749. } else {
  1750. $info_list[$key]['type'] = '未设置';
  1751. }
  1752. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1753. // transport 在途数据:从预取数组中取
  1754. $ztCk = $value['sku'] . '|' . $value['warehouse'] . '|' . $value['features'];
  1755. $zt = isset($all_zt[$ztCk]) ? $all_zt[$ztCk] : array();
  1756. $ztdata = '';
  1757. if (count($zt) > 0) {
  1758. foreach ($zt as $vv) {
  1759. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1760. }
  1761. }
  1762. // whlabel 组数据:从预取数组中取
  1763. $qbCk = $comboKey($value);
  1764. $qbdata = isset($all_qb[$qbCk]) ? $all_qb[$qbCk] : array();
  1765. $cdata = array_filter($qbdata, function ($item) {
  1766. return $item['state'] < 1;
  1767. });
  1768. $c = array_sum(array_column($cdata, 'jnum'));
  1769. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1770. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1771. });
  1772. $g = array_sum(array_column($gdata, 'jnum'));
  1773. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1774. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1775. });
  1776. $x = array_sum(array_column($xdata, 'jnum'));
  1777. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1778. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1779. });
  1780. $t = array_sum(array_column($tdata, 'jnum'));
  1781. $zdata = array_filter($qbdata, function ($item) {
  1782. return $item['zd'] != "" && $item['state'] < 1;
  1783. });
  1784. $z = array_sum(array_column($zdata, 'jnum'));
  1785. $detailsArr = array();
  1786. $cpid = array();
  1787. $od = array();
  1788. $odid = '';
  1789. $companytitle = '';
  1790. $shop_list = [];
  1791. foreach ($qbdata as $v) {
  1792. if ($v['zd'] != "" && $v['state'] < 1) {
  1793. if (!isset($od[$v['zd']])) {
  1794. $od[$v['zd']] = 1;
  1795. } else {
  1796. $od[$v['zd']] = $od[$v['zd']] + 1;
  1797. }
  1798. }
  1799. if ($v['state'] == 0) {
  1800. $detailsArr[$v['details']] = $v['details'];
  1801. }
  1802. if ($v['state'] < 1) {
  1803. if ($v['cpid'] != 0) {
  1804. $cpid[$v['cpid']] = $v['cpid'];
  1805. }
  1806. }
  1807. if ($v['state'] == 0) {
  1808. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1809. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1810. }
  1811. if ($v['shop'] != '') {
  1812. $shopArr = explode(',', trim($v['shop'], ','));
  1813. foreach ($shopArr as $vv) {
  1814. if (!in_array($vv, $shop_list)) {
  1815. $shop_list[] = $vv;
  1816. }
  1817. }
  1818. }
  1819. }
  1820. }
  1821. foreach ($od as $k => $vv) {
  1822. $odid .= $k . '数量' . $vv;
  1823. }
  1824. $info_list[$key]['cpbz'] = $value['cpbz'];
  1825. $info_list[$key]['label'] = $value['sm'];
  1826. $number = $value['number'];
  1827. $z = $z . '(' . $odid . ')';
  1828. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1829. $info_list[$key]['features'] = $c;
  1830. $info_list[$key]['number'] = $ztdata;
  1831. $info_list[$key]['sm'] = $g;
  1832. $info_list[$key]['x'] = $x;
  1833. $info_list[$key]['t'] = $t;
  1834. $info_list[$key]['z'] = $z;
  1835. $info_list[$key]['shop'] = '';
  1836. $info_list[$key]['details'] = ($cpid) ? implode(" ", $detailsArr) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $detailsArr);
  1837. $shop_list = array_unique($shop_list);
  1838. $shop_str = '';
  1839. foreach ($shop_list as $v) {
  1840. if (isset($sp[$v])) {
  1841. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1842. }
  1843. }
  1844. $info_list[$key]['shop'] = $shop_str . $companytitle;
  1845. }
  1846. $final_all_list = [];
  1847. foreach ($info_list as $k => $v) {
  1848. $final_all_list[] = [
  1849. 'id' => $v['id'],
  1850. "warehouse" => $v["warehouse"],
  1851. "purchase" => $v["purchase"],
  1852. "sku" => $v["sku"],
  1853. "title" => $v["title"] . "<br/>" . $v["pm"],
  1854. "details" => $v["details"],
  1855. "shop" => $v["shop"],
  1856. "cpbz" => $v["cpbz"],
  1857. 'label' => $v['label'],
  1858. "type" => $v["type"],
  1859. "features" => $v["features"],
  1860. "number" => $v["number"],
  1861. "sm" => $v["sm"],
  1862. "x" => $v["x"],
  1863. "t" => $v["t"],
  1864. "z" => $v["z"]
  1865. ];
  1866. }
  1867. // ========== 优化方案 C:总数统计只 COUNT,不传明细字段 ==========
  1868. // 原实现: count(find_pc(..., 'id,warehouse,sku,title,features,number')),传输了大量明细字段
  1869. // 优化为: SELECT COUNT(*) FROM (SELECT 1 FROM whlabel WHERE ... GROUP BY ...) t,只传一个数字
  1870. $countSql = "SELECT COUNT(*) AS cnt FROM (SELECT 1 FROM crowd_whlabel WHERE " . $where . $fjnr . " GROUP BY sku,purchase,features,warehouse) t";
  1871. $countResult = $this->whlabel->query($countSql)->result_array();
  1872. $total = isset($countResult[0]['cnt']) ? (int)$countResult[0]['cnt'] : 0;
  1873. $pagenum = ceil($total / $perpage);
  1874. $over = $total - ($start + $perpage);
  1875. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1876. echo json_encode($rows);
  1877. exit;
  1878. }
  1879. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1880. $this->data['shop'] = $wlshop;
  1881. $this->data['vip'] = $vip;
  1882. $this->_Template('whlabel_typev1', $this->data);
  1883. }
  1884. //美仓进销存浏览
  1885. public function _usatype()
  1886. {
  1887. if (isset($_SESSION['api'])) {
  1888. $user = $this->user->get_api($_SESSION['api']);
  1889. $usp = $user;
  1890. $fgshop = "";
  1891. $sid = "";
  1892. $wid = "";
  1893. $wtype = "";
  1894. $userwh = explode('|', trim($user['warehouse'], '|'));
  1895. foreach ($userwh as $value) {
  1896. $wid .= " id = " . $value . " or";
  1897. $wtype .= " type = " . $value . " or";
  1898. }
  1899. }
  1900. $prc = array();
  1901. $purchase = $this->purchase->find_all();
  1902. foreach ($purchase as $k => $v) {
  1903. $prc[$v['id']] = $v['title'];
  1904. }
  1905. $post = $this->input->post(NULL, TRUE);
  1906. if (isset($post['page'])) {
  1907. $page = $this->input->post('page', true);
  1908. $perpage = $this->input->post('perpage', true);
  1909. $category = $this->input->post('category', true);
  1910. $size = $this->input->post('size', true);
  1911. $grade = $this->input->post('grade', true);
  1912. $color = $this->input->post('color', true);
  1913. $lowe = $this->input->post('lowe', true);
  1914. $sku = $this->input->post('sku');
  1915. $title = $this->input->post('title');
  1916. $warehouse = $this->input->post('warehouse', true);
  1917. $usa = $this->input->post('usa', true);
  1918. $purchase = $this->input->post('purchase', true);
  1919. $lacetype = $this->input->post('lacetype', true);
  1920. $haircap = $this->input->post('haircap', true);
  1921. $density = $this->input->post('density', true);
  1922. $details = $this->input->post('details', true);
  1923. $state = $this->input->post('state', true);
  1924. $lacecolor = $this->input->post('lacecolor', true);
  1925. $cklx = $this->input->post('cklx', true);
  1926. $ktime = $this->input->post('ktime', true);
  1927. $jtime = $this->input->post('jtime', true);
  1928. $ktime = strtotime($ktime);
  1929. $jtime = strtotime($jtime);
  1930. $where = "1=1";
  1931. $gj = "";
  1932. $ck = "";
  1933. if ($lacetype) {
  1934. $where .= " and features like '%-$lacetype-%'";
  1935. }
  1936. if ($category) {
  1937. $where .= " and features like '%-$category-%'";
  1938. }
  1939. if ($size) {
  1940. $where .= " and features like '%-$size-%'";
  1941. }
  1942. if ($grade) {
  1943. $where .= " and features like '%-$grade-%'";
  1944. }
  1945. if ($color) {
  1946. $where .= " and features like '%-$color-%'";
  1947. }
  1948. if ($lowe) {
  1949. $where .= " and features like '%-$lowe-%'";
  1950. }
  1951. if ($haircap) {
  1952. $where .= " and features like '%-$haircap-%'";
  1953. }
  1954. if ($density) {
  1955. $where .= " and features like '%-$density-%'";
  1956. }
  1957. if ($lacecolor) {
  1958. $where .= " and features like '%-$lacecolor-%'";
  1959. }
  1960. if ($usa) {
  1961. if (!$warehouse) {
  1962. $where .= " and (warehouse = '5' or warehouse = '8')";
  1963. }
  1964. }
  1965. if ($warehouse) {
  1966. $where .= " and warehouse = '$warehouse'";
  1967. }
  1968. if ($details) {
  1969. $where .= " and details = '$details'";
  1970. }
  1971. if ($purchase) {
  1972. $where .= " and purchase = '$purchase'";
  1973. }
  1974. if ($state) {
  1975. $where .= " and state = '$state'";
  1976. }
  1977. $where_add = '';
  1978. if ($cklx) {
  1979. $shop = $this->shop->read($cklx);
  1980. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1981. }
  1982. if ($ktime && $jtime) {
  1983. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1984. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1985. }
  1986. //数据排序
  1987. $order_str = "id desc";
  1988. if (empty($page)) {
  1989. $start = 0;
  1990. $perpage = 1;
  1991. } else {
  1992. $start = ($page - 1) * $perpage;
  1993. }
  1994. if ($sku) {
  1995. $sku = trim($sku, ' ');
  1996. $sku = trim($sku, ' ');
  1997. $where .= " and sku like '%$sku%'";
  1998. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1999. } else if ($title) {
  2000. $title = trim($title, ' ');
  2001. $title = trim($title, ' ');
  2002. $where .= " and title like '%$title%'";
  2003. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2004. } else {
  2005. //$where .= " and time > '$ktime' and time < '$jtime'";
  2006. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2007. }
  2008. //取得信息列表
  2009. $rows = array();
  2010. $list = array();
  2011. foreach ($info_list as $key => $value) {
  2012. $warehouse = $this->warehouse->read($value['warehouse']);
  2013. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2014. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2015. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2016. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2017. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2018. $od = array();
  2019. $odid = '';
  2020. foreach ($z as $v) {
  2021. if (!isset($od[$v['zd']])) {
  2022. $od[$v['zd']] = 1; //所有数据sku
  2023. } else {
  2024. $od[$v['zd']] = $od[$v['zd']] + 1;
  2025. }
  2026. }
  2027. foreach ($od as $k => $vv) {
  2028. $odid .= $k . '数量' . $vv . ' ';
  2029. }
  2030. $z = count($z) . '(' . $odid . ')'; //查看订单号
  2031. $info_list[$key]['features'] = $c;
  2032. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  2033. $ztdata = '';
  2034. if (count($zt) > 0) {
  2035. foreach ($zt as $vv) {
  2036. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  2037. }
  2038. }
  2039. $info_list[$key]['warehouse'] = $ztdata;
  2040. $info_list[$key]['g'] = $g;
  2041. $info_list[$key]['x'] = $x;
  2042. $info_list[$key]['t'] = $t;
  2043. $info_list[$key]['z'] = $z;
  2044. }
  2045. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  2046. $pagenum = ceil($total / $perpage);
  2047. $over = $total - ($start + $perpage);
  2048. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  2049. echo json_encode($rows);
  2050. exit;
  2051. }
  2052. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  2053. $this->data['warehouse'] = $warehouse;
  2054. $this->_Template('whlabel_typeusa', $this->data);
  2055. }
  2056. //美仓进销存浏览
  2057. public function _usatypeapp()
  2058. {
  2059. $post = $this->input->post(NULL, TRUE);
  2060. if (isset($post['page'])) {
  2061. $page = $this->input->post('page', true);
  2062. $perpage = $this->input->post('perpage', true);
  2063. $sku = $this->input->post('sku', true);
  2064. $warehouse = 5;
  2065. $title = $this->input->post('title', true);
  2066. $state = $this->input->post('state', true);
  2067. $ktime = $this->input->post('ktime', true);
  2068. $jtime = $this->input->post('jtime', true);
  2069. $ktime = strtotime($ktime);
  2070. $jtime = strtotime($jtime);
  2071. $where = "1=1";
  2072. $gj = "";
  2073. $ck = "";
  2074. if ($title) {
  2075. $st = explode(' ', trim($title, ' '));
  2076. foreach ($st as $v) {
  2077. $where .= " and title like '%$v%'";
  2078. }
  2079. }
  2080. if ($warehouse) {
  2081. $where .= " and warehouse = '$warehouse'";
  2082. }
  2083. if ($state) {
  2084. $where .= " and state = '$state'";
  2085. }
  2086. if ($sku) {
  2087. $where .= " and sku like '%$sku%'";
  2088. }
  2089. if ($ktime && $jtime) {
  2090. $gj = " and enter > '$ktime' and enter < '$jtime'";
  2091. $ck = " and outk > '$ktime' and outk < '$jtime'";
  2092. }
  2093. //数据排序
  2094. $order_str = "id desc";
  2095. if (empty($page)) {
  2096. $start = 0;
  2097. $perpage = 1;
  2098. } else {
  2099. $start = ($page - 1) * $perpage;
  2100. }
  2101. //取得信息列表
  2102. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  2103. $rows = array();
  2104. $list = array();
  2105. foreach ($info_list as $key => $value) {
  2106. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  2107. }
  2108. $rowsdq = array_slice($rows, $start, $perpage);
  2109. foreach ($rowsdq as $value) {
  2110. $warehouse = $this->warehouse->read($value['warehouse']);
  2111. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  2112. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  2113. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2114. $od = array();
  2115. $odid = '';
  2116. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  2117. }
  2118. $total = count($rows);
  2119. $pagenum = ceil($total / $perpage);
  2120. $over = $total - ($start + $perpage);
  2121. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2122. echo json_encode($rows);
  2123. exit;
  2124. }
  2125. $this->_Template('phone/p_usatypeapp', $this->data);
  2126. }
  2127. //入库操作
  2128. public function _enteradd()
  2129. {
  2130. $dt = 0;
  2131. if (isset($_SESSION['api'])) {
  2132. $user = $this->user->get_api($_SESSION['api']);
  2133. $usp = $user;
  2134. $fgshop = "";
  2135. $sid = "";
  2136. $user = explode('|', trim($user['shop'], '|'));
  2137. foreach ($user as $value) {
  2138. $fgshop .= " shop = " . $value . " or";
  2139. $sid .= " id = " . $value . " or";
  2140. }
  2141. }
  2142. $tc = $this->typeclass->find_all();
  2143. $typeclass = array();
  2144. foreach ($tc as $v) {
  2145. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  2146. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  2147. }
  2148. $post = $this->input->post(NULL, TRUE);
  2149. if (isset($post['sku'])) {
  2150. $list = array();
  2151. $num = "";
  2152. $title = "";
  2153. $features = "";
  2154. $order = $this->input->post('order', true);
  2155. $shop = $this->input->post('shop', true);
  2156. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2157. $sku = $this->input->post('sku', true);
  2158. $post['sm'] = $this->input->post('sm', true);
  2159. $post['warehouse'] = $this->input->post('warehouse', true);
  2160. $post['purchase'] = $this->input->post('purchase', true);
  2161. $post['retreatwarehouse'] = $post['warehouse'];
  2162. $post['state'] = $this->input->post('state', true);
  2163. $post['rktype'] = $this->input->post('rktype', true);
  2164. $post['text'] = $this->input->post('text', true);
  2165. $category = $this->input->post('category', true);
  2166. $list['category'] = $category;
  2167. $list['hairtype'] = $this->input->post('hairtype', true);
  2168. $list['grade'] = $this->input->post('grade', true);
  2169. $size = $this->input->post('size', true);
  2170. $xzsku = $this->input->post('xzsku', true);
  2171. $list['size'] = rtrim($size, ',');
  2172. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2173. $list['extension'] = $this->input->post('extension', true);
  2174. if ($category == 1297) {
  2175. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2176. }
  2177. if ($category == 1702) {
  2178. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2179. $list['syother'] = $this->input->post('syother', true);
  2180. }
  2181. if ($category == 133) {
  2182. $list['fittype'] = $this->input->post('fittype', true);
  2183. $list['acother'] = $this->input->post('acother', true);
  2184. }
  2185. $list['color'] = $this->input->post('color', true);
  2186. $list['lowe'] = $this->input->post('lowe', true);
  2187. if (!$post['purchase']) {
  2188. $post['purchase'] = 1;
  2189. }
  2190. if ($category == 127) {
  2191. $list['type'] = $this->input->post('type', true);
  2192. $list['headroad'] = $this->input->post('headroad', true);
  2193. $list['density'] = $this->input->post('density', true);
  2194. $list['lacesize'] = $this->input->post('lacesize', true);
  2195. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2196. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2197. $list['lacetypestwo'] = $this->input->post('lacetypestwo', 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. if($k == 'hairtype'){
  2243. if(!in_array($v,[163,164,165,166])){
  2244. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2245. }
  2246. }else{
  2247. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2248. }
  2249. if ($k != 'size') {
  2250. $title .= $typeclass[$v]['title'] . " ";
  2251. }
  2252. if (isset($pm[$typeclass[$v]['classid']])) {
  2253. if ($typeclass[$v]['title'] == '9A') {
  2254. $pm[$typeclass[$v]['classid']] = '9A';
  2255. } else if ($typeclass[$v]['title'] == '10A') {
  2256. $pm[$typeclass[$v]['classid']] = '10A';
  2257. } else {
  2258. $clzh = $typeclass[$v]['zh'];
  2259. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2260. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2261. $clzh = $clzh[0];
  2262. }
  2263. if($k == 'hairtype'){
  2264. if(!in_array($v,[163,164,165,166])){
  2265. $pm[$typeclass[$v]['classid']] = $clzh;
  2266. }
  2267. }else{
  2268. $pm[$typeclass[$v]['classid']] = $clzh;
  2269. }
  2270. }
  2271. }
  2272. }
  2273. }
  2274. $zh = implode(" ", $pm);
  2275. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2276. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2277. if ($list['size']) {
  2278. $typeclass = $this->typeclass->read($list['size']);
  2279. $title .= $typeclass['title'];
  2280. }
  2281. $time = time();
  2282. if ($xzsku) {
  2283. $scsku = implode("-", $scsku);
  2284. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2285. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2286. $post['sku'] = trim($scsku, ' ');
  2287. } else {
  2288. $post['sku'] = $sku;
  2289. }
  2290. //$post['sku'] = trim($sku,' ');
  2291. $post['title'] = rtrim($title, ' ');
  2292. $post['number'] = $num;
  2293. $post['features'] = '-' . $features;
  2294. $post['enter'] = $time;
  2295. $post['time'] = $time; //操作时间
  2296. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2297. if ($yza) {
  2298. if ($post['features'] != $yza[0]['features']) {
  2299. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2300. exit;
  2301. }
  2302. }
  2303. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2304. if ($yzb) {
  2305. if ($post['sku'] != $yzb[0]['sku']) {
  2306. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2307. exit;
  2308. }
  2309. }
  2310. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2311. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2312. exit;
  2313. }
  2314. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2315. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2316. exit;
  2317. }
  2318. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2319. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2320. exit;
  2321. }
  2322. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2323. if (isset($yz[0]['type'])) {
  2324. $post['type'] = $yz[0]['type'];
  2325. }
  2326. if ($post['state'] == 9) //如果选择预设库存
  2327. {
  2328. $this->whlabel->insert($post);
  2329. } else {
  2330. /**
  2331. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2332. if($ljg == 1)
  2333. {
  2334. for($i=0;$i<$order;$i++)
  2335. {
  2336. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2337. $this->whlabel->insert($post);
  2338. }
  2339. }
  2340. **/
  2341. //if($post['warehouse'] == '5')
  2342. //{
  2343. //}
  2344. $yydata = $post;
  2345. $yydata['zh'] = $zh;
  2346. /**
  2347. $wl = $this->apiyy->get_cjlp($yydata);
  2348. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2349. {
  2350. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2351. }
  2352. if($wl['Data'][0]['m_isSucess'] != 1)
  2353. {
  2354. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2355. }
  2356. **/
  2357. for ($i = 0; $i < $order; $i++) {
  2358. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2359. $this->whlabel->insert($post);
  2360. }
  2361. }
  2362. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2363. exit;
  2364. }
  2365. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2366. $this->data['wlshop'] = $wlshop;
  2367. $this->_Template('whlabel_enteradd', $this->data);
  2368. }
  2369. //修改产品
  2370. public function _enteredit($arg_array)
  2371. {
  2372. $dt = 0;
  2373. if (isset($_SESSION['api'])) {
  2374. $user = $this->user->get_api($_SESSION['api']);
  2375. $usp = $user;
  2376. $fgshop = "";
  2377. $sid = "";
  2378. $user = explode('|', trim($user['shop'], '|'));
  2379. foreach ($user as $value) {
  2380. $fgshop .= " shop = " . $value . " or";
  2381. $sid .= " id = " . $value . " or";
  2382. }
  2383. }
  2384. $post = $this->input->post(NULL, TRUE);
  2385. if (isset($post['sku'])) {
  2386. $list = array();
  2387. $num = "";
  2388. $title = "";
  2389. $features = "";
  2390. $id = $this->input->post('id', true);
  2391. $order = $this->input->post('order', true);
  2392. $shop = $this->input->post('shop', true);
  2393. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2394. $post['sku'] = $this->input->post('sku', true);
  2395. $post['sm'] = $this->input->post('sm', true);
  2396. $post['warehouse'] = $this->input->post('warehouse', true);
  2397. $post['purchase'] = $this->input->post('purchase', true);
  2398. $post['retreatwarehouse'] = $post['warehouse'];
  2399. $category = $this->input->post('category', true);
  2400. $list['category'] = $category;
  2401. $list['hairtype'] = $this->input->post('hairtype', true);
  2402. $list['grade'] = $this->input->post('grade', true);
  2403. $size = $this->input->post('size', true);
  2404. $list['size'] = rtrim($size, ',');
  2405. $post['rktype'] = $this->input->post('rktype', true);
  2406. $post['text'] = $this->input->post('text', true);
  2407. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2408. $list['extension'] = $this->input->post('extension', true);
  2409. if ($category == 1297) {
  2410. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2411. }
  2412. if ($category == 1702) {
  2413. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2414. $list['syother'] = $this->input->post('syother', true);
  2415. }
  2416. if ($category == 133) {
  2417. $list['fittype'] = $this->input->post('fittype', true);
  2418. $list['acother'] = $this->input->post('acother', true);
  2419. }
  2420. $list['color'] = $this->input->post('color', true);
  2421. $list['lowe'] = $this->input->post('lowe', true);
  2422. if (!$post['purchase']) {
  2423. $post['purchase'] = 1;
  2424. }
  2425. if ($category == 127) {
  2426. $list['type'] = $this->input->post('type', true);
  2427. $list['headroad'] = $this->input->post('headroad', true);
  2428. $list['density'] = $this->input->post('density', true);
  2429. $list['lacesize'] = $this->input->post('lacesize', true);
  2430. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2431. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2432. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  2433. }
  2434. if ($category == 128) {
  2435. $list['lacetype'] = $this->input->post('lacetype', true);
  2436. $list['haircap'] = $this->input->post('haircap', true);
  2437. $list['density'] = $this->input->post('density', true);
  2438. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2439. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2440. $list['wigother'] = $this->input->post('wigother', true);
  2441. $list['wigother1'] = $this->input->post('wigother1', true);
  2442. $list['wigother2'] = $this->input->post('wigother2', true);
  2443. $list['product_related'] = $this->input->post('product_related', true);
  2444. }
  2445. if ($category == 129) {
  2446. $list['wide'] = $this->input->post('wide', true);
  2447. }
  2448. if ($category == 131) {
  2449. $list['gifttype'] = $this->input->post('gifttype', true);
  2450. $list['giftother'] = $this->input->post('giftother', true);
  2451. }
  2452. if ($category == 134) {
  2453. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2454. }
  2455. if ($category == 1297) {
  2456. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2457. $list['sywigother'] = $this->input->post('sywigother', true);
  2458. }
  2459. if ($category == 130 || $category == 133 || $category == 1702) {
  2460. $list['items'] = $this->input->post('items', true);
  2461. $list['weight'] = $this->input->post('weight', true);
  2462. }
  2463. if($category == 130){
  2464. $list['jfother'] = $this->input->post('jfother', true);
  2465. }
  2466. if ($category == 1702) {
  2467. $list['syhairther'] = $this->input->post('syhairther', true);
  2468. }
  2469. foreach ($list as $k => $v) {
  2470. if ($v != 0) {
  2471. $num .= $v;
  2472. $features .= $v . '-';
  2473. $typeclass = $this->typeclass->read($v);
  2474. if ($k != 'size') {
  2475. $title .= $typeclass['title'] . " ";
  2476. }
  2477. }
  2478. }
  2479. $typeclass = $this->typeclass->read($list['size']);
  2480. $title .= $typeclass['title'];
  2481. $time = time();
  2482. $post['title'] = rtrim($title, ' ');
  2483. $post['number'] = $num;
  2484. $post['features'] = '-' . $features;
  2485. $post['time'] = $time; //操作时间
  2486. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2487. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2488. exit;
  2489. }
  2490. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2491. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2492. exit;
  2493. }
  2494. $uid = $this->whlabel->read($id);
  2495. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2496. if ($datanum > 0) {
  2497. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2498. exit;
  2499. }
  2500. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2501. {
  2502. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2503. if ($yza) {
  2504. if ($post['features'] != $yza[0]['features']) {
  2505. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2506. exit;
  2507. }
  2508. }
  2509. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2510. if ($yzb) {
  2511. if ($post['sku'] != $yzb[0]['sku']) {
  2512. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2513. exit;
  2514. }
  2515. }
  2516. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2517. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2518. exit;
  2519. }
  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. } else {
  2526. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2527. if ($data > 0) {
  2528. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2529. exit;
  2530. } else {
  2531. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2532. foreach ($data as $v) {
  2533. $post['id'] = $v['id'];
  2534. $this->whlabel->save($post, $v['id']);
  2535. }
  2536. }
  2537. }
  2538. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2539. exit;
  2540. }
  2541. $uid = $this->whlabel->read($arg_array[0]);
  2542. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2543. $this->data['enter'] = $uid;
  2544. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2545. $this->data['wlshop'] = $wlshop;
  2546. $this->_Template('whlabel_enteredit', $this->data);
  2547. }
  2548. //入库浏览
  2549. public function _enter()
  2550. {
  2551. $post = $this->input->post(NULL, TRUE);
  2552. if (isset($post['s'])) {
  2553. $id_arr = $this->input->post('s');
  2554. $id_arr = explode(',', $id_arr);
  2555. if (!$id_arr) {
  2556. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2557. exit;
  2558. }
  2559. //循环删除记录
  2560. foreach ($id_arr as $v) {
  2561. $sid = $this->whlabel->read($v);
  2562. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2563. if ($count > 0) {
  2564. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2565. exit;
  2566. }
  2567. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2568. foreach ($info_list as $va) {
  2569. $this->whlabel->remove($va['id']);
  2570. }
  2571. }
  2572. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2573. exit;
  2574. }
  2575. $sp = array();
  2576. $s = $this->shop->find_all('1=1', 'id,shopname');
  2577. foreach ($s as $v) {
  2578. $sp[$v['id']] = $v['shopname'];
  2579. }
  2580. $wh = array();
  2581. $w = $this->warehouse->find_all('1=1', 'id,title');
  2582. foreach ($w as $v) {
  2583. $wh[$v['id']] = $v['title'];
  2584. }
  2585. if (isset($post['page'])) {
  2586. $page = $this->input->post('page', true);
  2587. $perpage = $this->input->post('perpage', true);
  2588. $category = $this->input->post('category', true);
  2589. $size = $this->input->post('size', true);
  2590. $grade = $this->input->post('grade', true);
  2591. $color = $this->input->post('color', true);
  2592. $lowe = $this->input->post('lowe', true);
  2593. $sku = $this->input->post('sku', true);
  2594. $warehouse = $this->input->post('warehouse', true);
  2595. $purchase = $this->input->post('purchase', true);
  2596. $ktime = $this->input->post('ktime', true);
  2597. $jtime = $this->input->post('jtime', true);
  2598. $ktime = strtotime($ktime);
  2599. $jtime = strtotime($jtime);
  2600. $where = "1=1";
  2601. $gj = "";
  2602. $ck = "";
  2603. if ($category) {
  2604. $where .= " and features like '%-$category-%'";
  2605. }
  2606. if ($size) {
  2607. $where .= " and features like '%-$size-%'";
  2608. }
  2609. if ($grade) {
  2610. $where .= " and features like '%-$grade-%'";
  2611. }
  2612. if ($color) {
  2613. $where .= " and features like '%-$color-%'";
  2614. }
  2615. if ($lowe) {
  2616. $where .= " and features like '%-$lowe-%'";
  2617. }
  2618. if ($warehouse) {
  2619. $where .= " and warehouse = '$warehouse'";
  2620. }
  2621. if ($purchase) {
  2622. $where .= " and purchase = '$purchase'";
  2623. }
  2624. if ($sku) {
  2625. $where .= " and sku like '%$sku%'";
  2626. }
  2627. if ($ktime && $jtime) {
  2628. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2629. }
  2630. //数据排序
  2631. $order_str = "enter desc";
  2632. if (empty($page)) {
  2633. $start = 0;
  2634. $perpage = 1;
  2635. } else {
  2636. $start = ($page - 1) * $perpage;
  2637. }
  2638. //取得信息列表
  2639. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2640. foreach ($info_list as $k => $v) {
  2641. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2642. if ($v['shop'] == '') {
  2643. $s = '通用';
  2644. } else {
  2645. $info_list[$k]['shop'] = '';
  2646. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2647. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2648. }
  2649. }
  2650. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2651. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2652. $info_list[$k]['g'] = $g;
  2653. }
  2654. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2655. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2656. $pagenum = ceil($total / $perpage);
  2657. $over = $total - ($start + $perpage);
  2658. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2659. echo json_encode($rows);
  2660. exit;
  2661. }
  2662. $this->_Template('whlabel_enter', $this->data);
  2663. }
  2664. //出库浏览
  2665. public function _out()
  2666. {
  2667. $post = $this->input->post(NULL, TRUE);
  2668. if (isset($post['page'])) {
  2669. $page = $this->input->post('page', true);
  2670. $perpage = $this->input->post('perpage', true);
  2671. $category = $this->input->post('category', true);
  2672. $size = $this->input->post('size', true);
  2673. $grade = $this->input->post('grade', true);
  2674. $color = $this->input->post('color', true);
  2675. $lowe = $this->input->post('lowe', true);
  2676. $sku = $this->input->post('sku', true);
  2677. $warehouse = $this->input->post('warehouse', true);
  2678. $purchase = $this->input->post('purchase', true);
  2679. $state = $this->input->post('state', true);
  2680. $ktime = $this->input->post('ktime', true);
  2681. $jtime = $this->input->post('jtime', true);
  2682. $ktime = strtotime($ktime);
  2683. $jtime = strtotime($jtime);
  2684. $where = "state=3";
  2685. $gj = "";
  2686. $ck = "";
  2687. if ($category) {
  2688. $where .= " and features like '%-$category-%'";
  2689. }
  2690. if ($size) {
  2691. $where .= " and features like '%-$size-%'";
  2692. }
  2693. if ($grade) {
  2694. $where .= " and features like '%-$grade-%'";
  2695. }
  2696. if ($color) {
  2697. $where .= " and features like '%-$color-%'";
  2698. }
  2699. if ($lowe) {
  2700. $where .= " and features like '%-$lowe-%'";
  2701. }
  2702. if ($state) {
  2703. $where .= " and state = '$state'";
  2704. }
  2705. if ($warehouse) {
  2706. $where .= " and warehouse = '$warehouse'";
  2707. }
  2708. if ($purchase) {
  2709. $where .= " and purchase = '$purchase'";
  2710. }
  2711. if ($sku) {
  2712. $where .= " and sku = '$sku'";
  2713. }
  2714. if ($ktime && $jtime) {
  2715. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2716. }
  2717. //数据排序
  2718. $order_str = "id desc";
  2719. if (empty($page)) {
  2720. $start = 0;
  2721. $perpage = 1;
  2722. } else {
  2723. $start = ($page - 1) * $perpage;
  2724. }
  2725. //取得信息列表
  2726. $info_list = $this->whlabel->find_all($where, 'sku');
  2727. $rows = array();
  2728. $list = array();
  2729. foreach ($info_list as $key => $value) {
  2730. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2731. }
  2732. $rows = array_unique($rows); //删除重复记录
  2733. foreach ($rows as $key => $value) {
  2734. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2735. $ck = $this->warehouse->read($data['warehouse']);
  2736. $warehouse = $ck['title'];
  2737. $gy = $this->purchase->read($data['purchase']);
  2738. $purchase = $gy['purchase'];
  2739. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2740. $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);
  2741. }
  2742. $total = count($list);
  2743. $pagenum = ceil($total / $perpage);
  2744. $over = $total - ($start + $perpage);
  2745. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2746. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2747. echo json_encode($rows);
  2748. exit;
  2749. }
  2750. $this->_Template('whlabel_out', $this->data);
  2751. }
  2752. //出库标签浏览
  2753. public function _label()
  2754. {
  2755. $post = $this->input->post(NULL, TRUE);
  2756. if (isset($post['page'])) {
  2757. $page = $this->input->post('page', true);
  2758. $perpage = $this->input->post('perpage', true);
  2759. $sku = $this->input->post('sku', true);
  2760. $warehouse = $this->input->post('warehouse', true);
  2761. $purchase = $this->input->post('purchase', true);
  2762. $orderinfo = $this->input->post('orderinfo', true);
  2763. $waybill = $this->input->post('waybill', true);
  2764. $category = $this->input->post('category', true);
  2765. $size = $this->input->post('size', true);
  2766. $grade = $this->input->post('grade', true);
  2767. $color = $this->input->post('color', true);
  2768. $lowe = $this->input->post('lowe', true);
  2769. $where = "state=1";
  2770. if ($sku) {
  2771. $where .= " and sku = '$sku'";
  2772. }
  2773. if ($warehouse) {
  2774. $where .= " and warehouse = '$warehouse'";
  2775. }
  2776. if ($purchase) {
  2777. $where .= " and purchase = '$purchase'";
  2778. }
  2779. if ($orderinfo) {
  2780. $where .= " and orderinfo = '$orderinfo'";
  2781. }
  2782. if ($waybill) {
  2783. $where .= " and waybill = '$waybill'";
  2784. }
  2785. if ($category) {
  2786. $where .= " and features like '%-$category-%'";
  2787. }
  2788. if ($size) {
  2789. $where .= " and features like '%-$size-%'";
  2790. }
  2791. if ($grade) {
  2792. $where .= " and features like '%-$grade-%'";
  2793. }
  2794. if ($color) {
  2795. $where .= " and features like '%-$color-%'";
  2796. }
  2797. if ($lowe) {
  2798. $where .= " and features like '%-$lowe-%'";
  2799. }
  2800. //数据排序
  2801. $order_str = "outk desc";
  2802. if (empty($page)) {
  2803. $start = 0;
  2804. $perpage = 1;
  2805. } else {
  2806. $start = ($page - 1) * $perpage;
  2807. }
  2808. //取得信息列表
  2809. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2810. foreach ($info_list as $key => $value) {
  2811. $warehouse = $this->warehouse->read($value['warehouse']);
  2812. $info_list[$key]['warehouse'] = $warehouse['title'];
  2813. $purchase = $this->purchase->read($value['purchase']);
  2814. $info_list[$key]['purchase'] = $purchase['title'];
  2815. if ($value['outk'] != 0) {
  2816. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2817. } else {
  2818. $info_list[$key]['outk'] = "";
  2819. }
  2820. if ($value['orderinfo'] == 0) {
  2821. $info_list[$key]['orderinfo'] = "";
  2822. }
  2823. if ($value['waybill'] == 0) {
  2824. $info_list[$key]['waybill'] = "";
  2825. }
  2826. }
  2827. $total = $this->whlabel->find_count($where);
  2828. $pagenum = ceil($total / $perpage);
  2829. $over = $total - ($start + $perpage);
  2830. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2831. echo json_encode($rows);
  2832. exit;
  2833. }
  2834. $this->_Template('whlabel_label', $this->data);
  2835. }
  2836. //独立站出库订单
  2837. public function _outorder()
  2838. {
  2839. if (isset($_SESSION['api'])) {
  2840. $user = $this->user->get_api($_SESSION['api']);
  2841. $usp = $user;
  2842. $fgshop = "";
  2843. $sid = "";
  2844. $user = explode('|', trim($user['shop'], '|'));
  2845. foreach ($user as $value) {
  2846. $fgshop .= " shop = " . $value . " or";
  2847. $sid .= " id = " . $value . " or";
  2848. }
  2849. } else {
  2850. echo "请重新登录";
  2851. }
  2852. $post = $this->input->post(NULL, TRUE);
  2853. if (isset($post['page'])) {
  2854. $page = $this->input->post('page', true);
  2855. $perpage = $this->input->post('perpage', true);
  2856. $warehouse = $this->input->post('warehouse', true);
  2857. $xztime = $this->input->post('xztime', true);
  2858. $timetk = $this->input->post('timetkk', true);
  2859. $timetj = $this->input->post('timetjj', true);
  2860. $shop = $this->input->post('shop', true);
  2861. $source = $this->input->post('source', true);
  2862. $orderinfo = $this->input->post('orderinfo', true);
  2863. $number = $this->input->post('number', true);
  2864. $sfxh = $this->input->post('sfxh', true);
  2865. $express = $this->input->post('express', true);
  2866. $waybill = $this->input->post('waybill', true);
  2867. $library = $this->input->post('library', true);
  2868. $country = $this->input->post('country', true);
  2869. $so = $this->input->post('so', true);
  2870. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2871. $print = $this->input->post('print', true);
  2872. $state = $this->input->post('state', true);
  2873. $orderurl = $this->input->post('orderurl', true);
  2874. $productid = $this->input->post('productid', true);
  2875. $timetk = strtotime($timetk);
  2876. $timetj = strtotime($timetj);
  2877. /**
  2878. $sj = $this->input->post('sj',true);
  2879. if($sj)
  2880. {
  2881. $sj = $this->input->post('sj',true);
  2882. }
  2883. else
  2884. {
  2885. $sj = "fullorder";
  2886. }
  2887. **/
  2888. $sj = "fullorder";
  2889. $where = "1=1";
  2890. if ($warehouse) {
  2891. $where .= " and type = '$warehouse'";
  2892. }
  2893. if ($timetk && $timetj) {
  2894. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2895. }
  2896. if ($orderinfo) {
  2897. $where .= " and orderinfo = '$orderinfo'";
  2898. }
  2899. if ($number) {
  2900. $where .= " and number = '$number'";
  2901. }
  2902. if ($express) {
  2903. $where .= " and express = '$express'";
  2904. }
  2905. if ($waybill) {
  2906. $where .= " and waybill = '$waybill'";
  2907. }
  2908. if ($library) {
  2909. $where .= " and library = '$library'";
  2910. }
  2911. if ($print) {
  2912. $where .= " and print = '$print'";
  2913. }
  2914. if ($libraryconfirm) {
  2915. $where .= " and libraryconfirm = '$libraryconfirm'";
  2916. }
  2917. if ($state) {
  2918. $where .= " and state = '$state'";
  2919. }
  2920. if ($shop) {
  2921. $where .= " and shop = '$shop'";
  2922. }
  2923. if ($country) {
  2924. $where .= " and country = '$country'";
  2925. }
  2926. if ($sfxh != '') {
  2927. $where .= " and sfxh = '$sfxh'";
  2928. }
  2929. if ($so) {
  2930. $where .= " and shipremarks like '%$so%'";
  2931. }
  2932. if ($source) {
  2933. if ($source == '2d') {
  2934. $where .= " and source >= '2'";
  2935. } else {
  2936. $where .= " and source = '$source'";
  2937. }
  2938. }
  2939. if (isset($_SESSION['api'])) {
  2940. foreach ($user as $value) {
  2941. $fgshop .= " shop = " . $value . " or";
  2942. }
  2943. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2944. }
  2945. if ($orderurl) {
  2946. $url = $this->orderurl->read($orderurl);
  2947. $where .= " and link like '%" . $url['url'] . "%'";
  2948. }
  2949. if($productid){
  2950. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2951. }
  2952. //数据排序
  2953. $order_str = "librarytime desc";
  2954. if (empty($page)) {
  2955. $start = 0;
  2956. $perpage = 1;
  2957. } else {
  2958. $start = ($page - 1) * $perpage;
  2959. }
  2960. //取得信息列表
  2961. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2962. //格式化数据
  2963. foreach ($info_list as $key => $value) {
  2964. $shop = $this->shop->read($value['shop']);
  2965. $info_list[$key]['shop'] = $shop['shopname'];
  2966. $express = $this->express->read($value['express']);
  2967. $info_list[$key]['express'] = $express['servicename'];
  2968. $warehouse = $this->warehouse->read($value['type']);
  2969. $info_list[$key]['type'] = $warehouse['title'];
  2970. if ($value['librarytime'] == '0') {
  2971. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2972. } else {
  2973. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2974. }
  2975. }
  2976. $total = $this->$sj->find_count($where);
  2977. $pagenum = ceil($total / $perpage);
  2978. $over = $total - ($start + $perpage);
  2979. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2980. echo json_encode($rows);
  2981. exit;
  2982. }
  2983. $this->data['express'] = $this->express->find_all();
  2984. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2985. $this->data['wlshop'] = $wlshop;
  2986. $user = $this->user->get_api($_SESSION['api']);
  2987. $powerid = $this->power->read($user['power']);
  2988. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2989. $pid = '';
  2990. foreach ($powertext as $v) {
  2991. $pid .= " id = " . $v . " or";
  2992. }
  2993. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2994. $this->data['fullorderexcel'] = $fullorderexcel;
  2995. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2996. $this->data['orderurl'] = $orderurl;
  2997. $this->_Template('whlabel_outorder', $this->data);
  2998. }
  2999. //tt出库
  3000. public function _toutorder()
  3001. {
  3002. $fgshop = "";
  3003. $sid = "";
  3004. if (isset($_SESSION['api'])) {
  3005. $user = $this->user->get_api($_SESSION['api']);
  3006. $usp = $user;
  3007. $user = explode('|', trim($user['shop'], '|'));
  3008. foreach ($user as $value) {
  3009. $fgshop .= " shop = " . $value . " or";
  3010. $sid .= " id = " . $value . " or";
  3011. }
  3012. } else {
  3013. echo "请重新登录";
  3014. die;
  3015. }
  3016. $post = $this->input->post(NULL, TRUE);
  3017. if (isset($post['page'])) {
  3018. $page = $this->input->post('page', true);
  3019. $perpage = $this->input->post('perpage', true);
  3020. $warehouse = $this->input->post('warehouse', true);
  3021. $xztime = $this->input->post('xztime', true);
  3022. $timetk = $this->input->post('timetkk', true);
  3023. $timetj = $this->input->post('timetjj', true);
  3024. $shop = $this->input->post('shop', true);
  3025. $source = $this->input->post('source', true);
  3026. $orderinfo = $this->input->post('orderinfo', true);
  3027. $number = $this->input->post('number', true);
  3028. $sfxh = $this->input->post('sfxh', true);
  3029. $express = $this->input->post('express', true);
  3030. $waybill = $this->input->post('waybill', true);
  3031. $library = $this->input->post('library', true);
  3032. $country = $this->input->post('country', true);
  3033. $so = $this->input->post('so', true);
  3034. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3035. $print = $this->input->post('print', true);
  3036. $state = $this->input->post('state', true);
  3037. $orderurl = $this->input->post('orderurl', true);
  3038. $timetk = strtotime($timetk);
  3039. $timetj = strtotime($timetj);
  3040. /**
  3041. $sj = $this->input->post('sj',true);
  3042. if($sj)
  3043. {
  3044. $sj = $this->input->post('sj',true);
  3045. }
  3046. else
  3047. {
  3048. $sj = "fullorder";
  3049. }
  3050. **/
  3051. $sj = "fullordertt";
  3052. $where = "1=1";
  3053. if ($warehouse) {
  3054. $where .= " and type = '$warehouse'";
  3055. }
  3056. if ($timetk && $timetj) {
  3057. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3058. }
  3059. if ($orderinfo) {
  3060. $where .= " and orderinfo = '$orderinfo'";
  3061. }
  3062. if ($number) {
  3063. $where .= " and number = '$number'";
  3064. }
  3065. if ($express) {
  3066. $where .= " and express = '$express'";
  3067. }
  3068. if ($waybill) {
  3069. $where .= " and waybill = '$waybill'";
  3070. }
  3071. if ($library) {
  3072. $where .= " and library = '$library'";
  3073. }
  3074. if ($print) {
  3075. $where .= " and print = '$print'";
  3076. }
  3077. if ($libraryconfirm) {
  3078. $where .= " and libraryconfirm = '$libraryconfirm'";
  3079. }
  3080. if ($state) {
  3081. $where .= " and state = '$state'";
  3082. }
  3083. if ($shop) {
  3084. $where .= " and shop = '$shop'";
  3085. }
  3086. if ($country) {
  3087. $where .= " and country = '$country'";
  3088. }
  3089. if ($sfxh != '') {
  3090. $where .= " and sfxh = '$sfxh'";
  3091. }
  3092. if ($so) {
  3093. $where .= " and shipremarks like '%$so%'";
  3094. }
  3095. if ($source) {
  3096. if ($source == '2d') {
  3097. $where .= " and source >= '2'";
  3098. } else {
  3099. $where .= " and source = '$source'";
  3100. }
  3101. }
  3102. if (isset($_SESSION['api'])) {
  3103. foreach ($user as $value) {
  3104. $fgshop .= " shop = " . $value . " or";
  3105. }
  3106. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3107. }
  3108. if ($orderurl) {
  3109. $url = $this->orderurl->read($orderurl);
  3110. $where .= " and link like '%" . $url['url'] . "%'";
  3111. }
  3112. //数据排序
  3113. $order_str = "librarytime desc";
  3114. if (empty($page)) {
  3115. $start = 0;
  3116. $perpage = 1;
  3117. } else {
  3118. $start = ($page - 1) * $perpage;
  3119. }
  3120. //取得信息列表
  3121. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3122. //格式化数据
  3123. foreach ($info_list as $key => $value) {
  3124. $shop = $this->shop->read($value['shop']);
  3125. $info_list[$key]['shop'] = $shop['shopname'];
  3126. $express = $this->express->read($value['express']);
  3127. $info_list[$key]['express'] = $express['servicename'];
  3128. $warehouse = $this->warehouse->read($value['type']);
  3129. $info_list[$key]['type'] = $warehouse['title'];
  3130. if ($value['librarytime'] == '0') {
  3131. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3132. } else {
  3133. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3134. }
  3135. }
  3136. $total = $this->$sj->find_count($where);
  3137. $pagenum = ceil($total / $perpage);
  3138. $over = $total - ($start + $perpage);
  3139. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3140. echo json_encode($rows);
  3141. exit;
  3142. }
  3143. $this->data['express'] = $this->express->find_all();
  3144. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3145. $this->data['wlshop'] = $wlshop;
  3146. $user = $this->user->get_api($_SESSION['api']);
  3147. $powerid = $this->power->read($user['power']);
  3148. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3149. $pid = '';
  3150. foreach ($powertext as $v) {
  3151. $pid .= " id = " . $v . " or";
  3152. }
  3153. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3154. $this->data['fullorderexcel'] = $fullorderexcel;
  3155. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3156. $this->data['orderurl'] = $orderurl;
  3157. $this->_Template('whlabel_toutorder', $this->data);
  3158. }
  3159. //tt出库
  3160. public function _aoutorder()
  3161. {
  3162. if (isset($_SESSION['api'])) {
  3163. $user = $this->user->get_api($_SESSION['api']);
  3164. $usp = $user;
  3165. $fgshop = "";
  3166. $sid = "";
  3167. $user = explode('|', trim($user['shop'], '|'));
  3168. foreach ($user as $value) {
  3169. $fgshop .= " shop = " . $value . " or";
  3170. $sid .= " id = " . $value . " or";
  3171. }
  3172. } else {
  3173. echo "请重新登录";
  3174. }
  3175. $post = $this->input->post(NULL, TRUE);
  3176. if (isset($post['page'])) {
  3177. $page = $this->input->post('page', true);
  3178. $perpage = $this->input->post('perpage', true);
  3179. $warehouse = $this->input->post('warehouse', true);
  3180. $xztime = $this->input->post('xztime', true);
  3181. $timetk = $this->input->post('timetkk', true);
  3182. $timetj = $this->input->post('timetjj', true);
  3183. $shop = $this->input->post('shop', true);
  3184. $source = $this->input->post('source', true);
  3185. $orderinfo = $this->input->post('orderinfo', true);
  3186. $number = $this->input->post('number', true);
  3187. $sfxh = $this->input->post('sfxh', true);
  3188. $express = $this->input->post('express', true);
  3189. $waybill = $this->input->post('waybill', true);
  3190. $library = $this->input->post('library', true);
  3191. $country = $this->input->post('country', true);
  3192. $so = $this->input->post('so', true);
  3193. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3194. $print = $this->input->post('print', true);
  3195. $state = $this->input->post('state', true);
  3196. $orderurl = $this->input->post('orderurl', true);
  3197. $timetk = strtotime($timetk);
  3198. $timetj = strtotime($timetj);
  3199. /**
  3200. $sj = $this->input->post('sj',true);
  3201. if($sj)
  3202. {
  3203. $sj = $this->input->post('sj',true);
  3204. }
  3205. else
  3206. {
  3207. $sj = "fullorder";
  3208. }
  3209. **/
  3210. $sj = "fullorderamz";
  3211. $where = "1=1";
  3212. if ($warehouse) {
  3213. $where .= " and type = '$warehouse'";
  3214. }
  3215. if ($timetk && $timetj) {
  3216. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3217. }
  3218. if ($orderinfo) {
  3219. $where .= " and orderinfo = '$orderinfo'";
  3220. }
  3221. if ($number) {
  3222. $where .= " and number = '$number'";
  3223. }
  3224. if ($express) {
  3225. $where .= " and express = '$express'";
  3226. }
  3227. if ($waybill) {
  3228. $where .= " and waybill = '$waybill'";
  3229. }
  3230. if ($library) {
  3231. $where .= " and library = '$library'";
  3232. }
  3233. if ($print) {
  3234. $where .= " and print = '$print'";
  3235. }
  3236. if ($libraryconfirm) {
  3237. $where .= " and libraryconfirm = '$libraryconfirm'";
  3238. }
  3239. if ($state) {
  3240. $where .= " and state = '$state'";
  3241. }
  3242. if ($shop) {
  3243. $where .= " and shop = '$shop'";
  3244. }
  3245. if ($country) {
  3246. $where .= " and country = '$country'";
  3247. }
  3248. if ($sfxh != '') {
  3249. $where .= " and sfxh = '$sfxh'";
  3250. }
  3251. if ($so) {
  3252. $where .= " and shipremarks like '%$so%'";
  3253. }
  3254. if ($source) {
  3255. if ($source == '2d') {
  3256. $where .= " and source >= '2'";
  3257. } else {
  3258. $where .= " and source = '$source'";
  3259. }
  3260. }
  3261. if (isset($_SESSION['api'])) {
  3262. foreach ($user as $value) {
  3263. $fgshop .= " shop = " . $value . " or";
  3264. }
  3265. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3266. }
  3267. if ($orderurl) {
  3268. $url = $this->orderurl->read($orderurl);
  3269. $where .= " and link like '%" . $url['url'] . "%'";
  3270. }
  3271. //数据排序
  3272. $order_str = "librarytime desc";
  3273. if (empty($page)) {
  3274. $start = 0;
  3275. $perpage = 1;
  3276. } else {
  3277. $start = ($page - 1) * $perpage;
  3278. }
  3279. //取得信息列表
  3280. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3281. //格式化数据
  3282. foreach ($info_list as $key => $value) {
  3283. $shop = $this->shop->read($value['shop']);
  3284. $info_list[$key]['shop'] = $shop['shopname'];
  3285. $express = $this->express->read($value['express']);
  3286. $info_list[$key]['express'] = $express['servicename'];
  3287. $warehouse = $this->warehouse->read($value['type']);
  3288. $info_list[$key]['type'] = $warehouse['title'];
  3289. if ($value['librarytime'] == '0') {
  3290. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3291. } else {
  3292. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3293. }
  3294. }
  3295. $total = $this->$sj->find_count($where);
  3296. $pagenum = ceil($total / $perpage);
  3297. $over = $total - ($start + $perpage);
  3298. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3299. echo json_encode($rows);
  3300. exit;
  3301. }
  3302. $this->data['express'] = $this->express->find_all();
  3303. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3304. $this->data['wlshop'] = $wlshop;
  3305. $user = $this->user->get_api($_SESSION['api']);
  3306. $powerid = $this->power->read($user['power']);
  3307. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3308. $pid = '';
  3309. foreach ($powertext as $v) {
  3310. $pid .= " id = " . $v . " or";
  3311. }
  3312. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3313. $this->data['fullorderexcel'] = $fullorderexcel;
  3314. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3315. $this->data['orderurl'] = $orderurl;
  3316. $this->_Template('whlabel_aoutorder', $this->data);
  3317. }
  3318. //速卖通出库订单
  3319. public function _soutorder()
  3320. {
  3321. if (isset($_SESSION['api'])) {
  3322. $user = $this->user->get_api($_SESSION['api']);
  3323. $usp = $user;
  3324. $fgshop = "";
  3325. $sid = "";
  3326. $user = explode('|', trim($user['shop'], '|'));
  3327. foreach ($user as $value) {
  3328. $sid .= " id = " . $value . " or";
  3329. }
  3330. }
  3331. $post = $this->input->post(NULL, TRUE);
  3332. if (isset($post['page'])) {
  3333. $page = $this->input->post('page', true);
  3334. $perpage = $this->input->post('perpage', true);
  3335. $warehouse = $this->input->post('warehouse', true);
  3336. $xztime = $this->input->post('xztime', true);
  3337. $timetk = $this->input->post('timetkk', true);
  3338. $timetj = $this->input->post('timetjj', true);
  3339. $shop = $this->input->post('shop', true);
  3340. $source = $this->input->post('source', true);
  3341. $orderinfo = $this->input->post('orderinfo', true);
  3342. $number = $this->input->post('number', true);
  3343. $express = $this->input->post('express', true);
  3344. $waybill = $this->input->post('waybill', true);
  3345. $library = $this->input->post('library', true);
  3346. $country = $this->input->post('country', true);
  3347. $sfxh = $this->input->post('sfxh', true);
  3348. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3349. $print = $this->input->post('print', true);
  3350. $state = $this->input->post('state', true);
  3351. $so = $this->input->post('so', true);
  3352. $timetk = strtotime($timetk);
  3353. $timetj = strtotime($timetj);
  3354. /**
  3355. $sj = $this->input->post('sj',true);
  3356. if($sj)
  3357. {
  3358. $sj = $this->input->post('sj',true);
  3359. }
  3360. else
  3361. {
  3362. $sj = "fullorder";
  3363. }
  3364. **/
  3365. $sj = "fullordersmt";
  3366. $where = "1=1";
  3367. if ($warehouse) {
  3368. $where .= " and type = '$warehouse'";
  3369. }
  3370. if ($timetk && $timetj) {
  3371. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3372. }
  3373. if ($orderinfo) {
  3374. $where .= " and orderinfo = '$orderinfo'";
  3375. }
  3376. if ($number) {
  3377. $where .= " and number = '$number'";
  3378. }
  3379. if ($express) {
  3380. $where .= " and express = '$express'";
  3381. }
  3382. if ($waybill) {
  3383. $where .= " and waybill = '$waybill'";
  3384. }
  3385. if ($library) {
  3386. $where .= " and library = '$library'";
  3387. }
  3388. if ($print) {
  3389. $where .= " and print = '$print'";
  3390. }
  3391. if ($libraryconfirm) {
  3392. $where .= " and libraryconfirm = '$libraryconfirm'";
  3393. }
  3394. if ($state) {
  3395. $where .= " and state = '$state'";
  3396. }
  3397. if ($shop) {
  3398. $where .= " and shop = '$shop'";
  3399. }
  3400. if ($sfxh != '') {
  3401. $where .= " and sfxh = '$sfxh'";
  3402. }
  3403. if ($so) {
  3404. $where .= " and shipremarks like '%$so%'";
  3405. }
  3406. if ($source) {
  3407. $where .= " and source = '$source'";
  3408. }
  3409. if ($country) {
  3410. $where .= " and country = '$country'";
  3411. } else {
  3412. if (isset($_SESSION['api'])) {
  3413. foreach ($user as $value) {
  3414. $fgshop .= " shop = " . $value . " or";
  3415. }
  3416. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3417. }
  3418. }
  3419. //数据排序
  3420. $order_str = "librarytime desc";
  3421. if (empty($page)) {
  3422. $start = 0;
  3423. $perpage = 1;
  3424. } else {
  3425. $start = ($page - 1) * $perpage;
  3426. }
  3427. //取得信息列表
  3428. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3429. //格式化数据
  3430. foreach ($info_list as $key => $value) {
  3431. $shop = $this->shop->read($value['shop']);
  3432. $info_list[$key]['shop'] = $shop['shopname'];
  3433. $express = $this->express->read($value['express']);
  3434. $info_list[$key]['express'] = $express['servicename'];
  3435. $warehouse = $this->warehouse->read($value['type']);
  3436. $info_list[$key]['type'] = $warehouse['title'];
  3437. if ($value['librarytime'] == '0') {
  3438. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3439. } else {
  3440. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3441. }
  3442. }
  3443. $total = $this->$sj->find_count($where);
  3444. $pagenum = ceil($total / $perpage);
  3445. $over = $total - ($start + $perpage);
  3446. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3447. echo json_encode($rows);
  3448. exit;
  3449. }
  3450. $this->data['express'] = $this->express->find_all();
  3451. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3452. $this->data['wlshop'] = $wlshop;
  3453. $user = $this->user->get_api($_SESSION['api']);
  3454. $powerid = $this->power->read($user['power']);
  3455. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3456. $pid = '';
  3457. foreach ($powertext as $v) {
  3458. $pid .= " id = " . $v . " or";
  3459. }
  3460. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3461. $this->data['fullorderexcel'] = $fullorderexcel;
  3462. $this->_Template('whlabel_soutorder', $this->data);
  3463. }
  3464. //订单退库
  3465. public function _retreat()
  3466. {
  3467. $post = $this->input->post(NULL, TRUE);
  3468. if (isset($post['page'])) {
  3469. $page = $this->input->post('page', true);
  3470. $perpage = $this->input->post('perpage', true);
  3471. $warehouse = $this->input->post('warehouse', true);
  3472. $timetk = $this->input->post('timetk', true);
  3473. $timetj = $this->input->post('timetj', true);
  3474. $shop = $this->input->post('shop', true);
  3475. $source = $this->input->post('source', true);
  3476. $state = $this->input->post('state', true);
  3477. $review = $this->input->post('review', true);
  3478. $state = $this->input->post('state', true);
  3479. $express = $this->input->post('express', true);
  3480. $orderinfo = $this->input->post('orderinfo', true);
  3481. $user = $this->input->post('user', true);
  3482. $name = $this->input->post('name', true);
  3483. $waybill = $this->input->post('waybill', true);
  3484. $timetk = strtotime($timetk);
  3485. $timetj = strtotime($timetj);
  3486. $where = "(state=206 or state=210) and mergeid = 0";
  3487. if ($warehouse) {
  3488. $where .= " and state = '$warehouse'";
  3489. }
  3490. if ($timetk && $timetj) {
  3491. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3492. }
  3493. if ($shop) {
  3494. $where .= " and shop = '$shop'";
  3495. }
  3496. if ($source) {
  3497. $where .= " and source = '$source'";
  3498. }
  3499. if ($state) {
  3500. $where .= " and state = '$state'";
  3501. }
  3502. if ($review) {
  3503. $where .= " and review = '$review'";
  3504. }
  3505. if ($state) {
  3506. $where .= " and state = '$state'";
  3507. }
  3508. if ($express) {
  3509. $where .= " and express = '$express'";
  3510. }
  3511. if ($orderinfo) {
  3512. $where .= " and orderinfo = '$orderinfo'";
  3513. }
  3514. if ($user) {
  3515. $where .= " and user = '$user'";
  3516. }
  3517. if ($name) {
  3518. $where .= " and name = '$name'";
  3519. }
  3520. if ($waybill) {
  3521. $where .= " and waybill = '$waybill'";
  3522. }
  3523. //数据排序
  3524. $order_str = "id desc";
  3525. if (empty($page)) {
  3526. $start = 0;
  3527. $perpage = 1;
  3528. } else {
  3529. $start = ($page - 1) * $perpage;
  3530. }
  3531. //取得信息列表
  3532. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3533. //格式化数据
  3534. foreach ($info_list as $key => $value) {
  3535. $shop = $this->shop->read($value['shop']);
  3536. $info_list[$key]['shop'] = $shop['shopname'];
  3537. $warehouse = $this->warehouse->read($value['warehouse']);
  3538. $info_list[$key]['warehouse'] = $warehouse['title'];
  3539. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3540. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3541. if ($value['waybill'] == 0) {
  3542. $info_list[$key]['waybill'] = "";
  3543. }
  3544. $express = $this->express->read($value['express']);
  3545. $info_list[$key]['express'] = $express['title'];
  3546. $typeclass = $this->typeclass->read($value['state']);
  3547. $info_list[$key]['state'] = $typeclass['title'];
  3548. }
  3549. $total = $this->fullorder->find_count($where);
  3550. $pagenum = ceil($total / $perpage);
  3551. $over = $total - ($start + $perpage);
  3552. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3553. echo json_encode($rows);
  3554. exit;
  3555. }
  3556. $this->data['express'] = $this->express->find_all();
  3557. $this->_Template('whlabel_retreat', $this->data);
  3558. }
  3559. //退库标签浏览
  3560. public function _retreatlk()
  3561. {
  3562. $post = $this->input->post(NULL, TRUE);
  3563. if (isset($post['page'])) {
  3564. $page = $this->input->post('page', true);
  3565. $perpage = $this->input->post('perpage', true);
  3566. $timetk = $this->input->post('timetk', true);
  3567. $timetj = $this->input->post('timetj', true);
  3568. $sku = $this->input->post('sku', true);
  3569. $warehouse = $this->input->post('warehouse', true);
  3570. $purchase = $this->input->post('purchase', true);
  3571. $orderinfo = $this->input->post('orderinfo', true);
  3572. $waybill = $this->input->post('waybill', true);
  3573. $category = $this->input->post('category', true);
  3574. $size = $this->input->post('size', true);
  3575. $grade = $this->input->post('grade', true);
  3576. $color = $this->input->post('color', true);
  3577. $lowe = $this->input->post('lowe', true);
  3578. $state = $this->input->post('state', true);
  3579. $timetk = strtotime($timetk);
  3580. $timetj = strtotime($timetj);
  3581. $where = "state=2";
  3582. if ($timetk && $timetj) {
  3583. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3584. }
  3585. if ($sku) {
  3586. $where .= " and sku = '$sku'";
  3587. }
  3588. if ($warehouse) {
  3589. $where .= " and warehouse = '$warehouse'";
  3590. }
  3591. if ($purchase) {
  3592. $where .= " and purchase = '$purchase'";
  3593. }
  3594. if ($orderinfo) {
  3595. $where .= " and orderinfo = '$orderinfo'";
  3596. }
  3597. if ($waybill) {
  3598. $where .= " and waybill = '$waybill'";
  3599. }
  3600. if ($category) {
  3601. $where .= " and features like '%-$category-%'";
  3602. }
  3603. if ($size) {
  3604. $where .= " and features like '%-$size-%'";
  3605. }
  3606. if ($grade) {
  3607. $where .= " and features like '%-$grade-%'";
  3608. }
  3609. if ($color) {
  3610. $where .= " and features like '%-$color-%'";
  3611. }
  3612. if ($lowe) {
  3613. $where .= " and features like '%-$lowe-%'";
  3614. }
  3615. //数据排序
  3616. $order_str = "time desc";
  3617. if (empty($page)) {
  3618. $start = 0;
  3619. $perpage = 1;
  3620. } else {
  3621. $start = ($page - 1) * $perpage;
  3622. }
  3623. //取得信息列表
  3624. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3625. foreach ($info_list as $key => $value) {
  3626. $warehouse = $this->warehouse->read($value['warehouse']);
  3627. $info_list[$key]['warehouse'] = $warehouse['title'];
  3628. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3629. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3630. $purchase = $this->purchase->read($value['purchase']);
  3631. $info_list[$key]['purchase'] = $purchase['title'];
  3632. if ($value['outk'] != 0) {
  3633. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3634. } else {
  3635. $info_list[$key]['outk'] = "";
  3636. }
  3637. if ($value['retreat'] != 0) {
  3638. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3639. } else {
  3640. $info_list[$key]['retreat'] = "";
  3641. }
  3642. if ($value['orderinfo'] == 0) {
  3643. $info_list[$key]['orderinfo'] = "";
  3644. }
  3645. if ($value['waybill'] == 0) {
  3646. $info_list[$key]['waybill'] = "";
  3647. }
  3648. }
  3649. $total = $this->whlabel->find_count($where);
  3650. $pagenum = ceil($total / $perpage);
  3651. $over = $total - ($start + $perpage);
  3652. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3653. echo json_encode($rows);
  3654. exit;
  3655. }
  3656. $this->_Template('whlabel_retreatlk', $this->data);
  3657. }
  3658. //更换标签及浏览
  3659. public function _change()
  3660. {
  3661. $post = $this->input->post(NULL, TRUE);
  3662. if (isset($post['page'])) {
  3663. $page = $this->input->post('page', true);
  3664. $perpage = $this->input->post('perpage', true);
  3665. $timetk = $this->input->post('timetk', true);
  3666. $timetj = $this->input->post('timetj', true);
  3667. $label = $this->input->post('label', true);
  3668. $oldlabel = $this->input->post('oldlabel', true);
  3669. $timetk = strtotime($timetk);
  3670. $timetj = strtotime($timetj);
  3671. $where = "state=10 ";
  3672. if ($timetk && $timetj) {
  3673. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3674. }
  3675. if ($label) {
  3676. $where .= " and label = '$label'";
  3677. }
  3678. if ($oldlabel) {
  3679. $where .= " and oldlabel = '$oldlabel'";
  3680. }
  3681. //数据排序
  3682. $order_str = "time asc";
  3683. if (empty($page)) {
  3684. $start = 0;
  3685. $perpage = 1;
  3686. } else {
  3687. $start = ($page - 1) * $perpage;
  3688. }
  3689. //取得信息列表
  3690. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3691. foreach ($info_list as $key => $value) {
  3692. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3693. }
  3694. $total = $this->whlabel->find_count($where);
  3695. $pagenum = ceil($total / $perpage);
  3696. $over = $total - ($start + $perpage);
  3697. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3698. echo json_encode($rows);
  3699. exit;
  3700. }
  3701. $this->_Template('whlabel_change', $this->data);
  3702. }
  3703. //产品标签
  3704. public function _cpbqdc()
  3705. {
  3706. if (isset($_GET['excel'])) {
  3707. $where = "1=1";
  3708. //数据排序
  3709. $order_str = "id desc";
  3710. if (empty($page)) {
  3711. $start = 0;
  3712. $perpage = 1;
  3713. } else {
  3714. $start = ($page - 1) * $perpage;
  3715. }
  3716. $warehouse = $this->input->get('warehouse', true);
  3717. $state = $this->input->get('state', true);
  3718. $timetk = $this->input->get('timetkk', true);
  3719. $timetj = $this->input->get('timetjj', true);
  3720. $timetk = strtotime($timetk);
  3721. $timetj = strtotime($timetj);
  3722. if ($warehouse) {
  3723. $where .= " and warehouse = '$warehouse'";
  3724. }
  3725. if ($state || $state == 0) {
  3726. $where .= " and state = '$state'";
  3727. }
  3728. if ($timetk && $timetj) {
  3729. $where .= " and time > '$timetk' and time < '$timetj'";
  3730. }
  3731. //取得信息列表
  3732. $info_list = $this->whlabel->find_all($where, '*');
  3733. $rows = array();
  3734. $list = array();
  3735. foreach ($info_list as $key => $value) {
  3736. $rows[$value['time']] = $value; //所有数据sku
  3737. }
  3738. foreach ($rows as $value) {
  3739. $warehouse = $this->warehouse->read($value['warehouse']);
  3740. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3741. $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);
  3742. }
  3743. $title = "产品标签统计表";
  3744. $titlename = "<table border=1>
  3745. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3746. <tr align='center'>
  3747. <td>仓库</td>
  3748. <td>SKU</td>
  3749. <td>产品</td>
  3750. <td>入库时间</td>
  3751. <td>操作时间</td>
  3752. <td>备注</td>
  3753. <td>数量</td>
  3754. </tr>
  3755. </table>";
  3756. $filename = $title . ".xls";
  3757. $tail = "";
  3758. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3759. }
  3760. }
  3761. //进销存导出
  3762. public function _exceljxc()
  3763. {
  3764. $classid = $this->classid->sku();
  3765. $pm = $classid;
  3766. $typeclass = array();
  3767. $tc = $this->typeclass->find_all();
  3768. foreach ($tc as $v) {
  3769. $typeclass[$v['id']] = $v;
  3770. }
  3771. $prc = array();
  3772. $purchase = $this->purchase->find_all();
  3773. foreach ($purchase as $k => $v) {
  3774. $prc[$v['id']] = $v['title'];
  3775. }
  3776. if (isset($_GET['excel'])) {
  3777. $where = "sku != 'Preset'";
  3778. //数据排序
  3779. $order_str = "id desc";
  3780. if (empty($page)) {
  3781. $start = 0;
  3782. $perpage = 1;
  3783. } else {
  3784. $start = ($page - 1) * $perpage;
  3785. }
  3786. $category = $this->input->get('category', true);
  3787. $warehouse = $this->input->get('warehouse', true);
  3788. $excelid = $this->input->get('sid', true);
  3789. if ($category) {
  3790. $where .= " and features like '%-$category-%'";
  3791. }
  3792. if ($warehouse) {
  3793. $where .= " and warehouse = '$warehouse'";
  3794. }
  3795. $xzid = '';
  3796. if ($excelid) {
  3797. $excelid = explode(',', trim($excelid, ','));
  3798. foreach ($excelid as $key => $value) {
  3799. $xzid .= " id = " . $value . " or";
  3800. }
  3801. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3802. }
  3803. //取得信息列表
  3804. /**
  3805. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3806. $rows = array();$list = array();
  3807. foreach ($info_list as $key=>$value)
  3808. {
  3809. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3810. }
  3811. **/
  3812. $wt = array();
  3813. $whlabel_type = $this->whlabel_type->find_all();
  3814. foreach ($whlabel_type as $v) {
  3815. $wt[$v['id']] = $v['title'];
  3816. }
  3817. $wh = array();
  3818. $w = $this->warehouse->find_all('1=1', 'id,title');
  3819. foreach ($w as $v) {
  3820. $wh[$v['id']] = $v['title'];
  3821. }
  3822. $list = array();
  3823. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3824. foreach ($rows as $key => $value) {
  3825. if (isset($wt[$value['type']])) {
  3826. $rows[$key]['type'] = $wt[$value['type']];
  3827. } else {
  3828. $rows[$key]['type'] = '未设置';
  3829. }
  3830. $bm = '03';
  3831. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3832. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3833. $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');
  3834. $details = array();
  3835. $cpid = array();
  3836. $cpbz = array();
  3837. $c = 0;
  3838. $g = 0;
  3839. $x = 0;
  3840. $t = 0;
  3841. $s = 0;
  3842. $q = 0;
  3843. foreach ($sd as $k => $v) {
  3844. if ($v['state'] == 0) {
  3845. $c++;
  3846. if ($v['cpid'] != 0) {
  3847. $cpid[$v['cpid']] = $v['cpid'];
  3848. }
  3849. if ($v['cpbz'] != '') {
  3850. $cpbz[$v['cpbz']] = $v['cpbz'];
  3851. }
  3852. }
  3853. if ($v['state'] != 9) {
  3854. $g++;
  3855. }
  3856. if ($v['state'] == 1) {
  3857. $x++;
  3858. }
  3859. if ($v['state'] == 2) {
  3860. $t++;
  3861. }
  3862. if ($v['state'] == 8) {
  3863. $s++;
  3864. }
  3865. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3866. $q++;
  3867. }
  3868. $details[$v['details']] = $v['details'];
  3869. }
  3870. $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'] . '"');
  3871. $rows[$key]['details'] = implode("、", $details);
  3872. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3873. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3874. $number = $value['number'];
  3875. $ftime = time() - 15 * 24 * 3600;
  3876. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3877. $rows[$key]['number'] = $g;
  3878. $rows[$key]['c'] = $c;
  3879. $rows[$key]['x'] = $x;
  3880. $rows[$key]['t'] = $t;
  3881. $rows[$key]['s'] = $s;
  3882. $rows[$key]['q'] = $q;
  3883. $rows[$key]['z'] = $z;
  3884. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3885. $features = explode('-', trim($features, '-'));
  3886. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3887. // $pm = $classid;
  3888. // $jm = $classid;
  3889. // foreach($features as $k=>$v)
  3890. // {
  3891. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3892. // {
  3893. // if($typeclass[$v]['bm'] != '')
  3894. // {
  3895. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3896. // }
  3897. // }
  3898. // if($v != 0)
  3899. // {
  3900. // if(!isset($typeclass[$v]))
  3901. // {
  3902. // continue;
  3903. // }
  3904. // if(isset($pm[$typeclass[$v]['classid']]))
  3905. // {
  3906. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3907. // {
  3908. // $tz = explode('|',$typeclass[$v]['zh']);
  3909. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3910. // }
  3911. // else
  3912. // {
  3913. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3914. // }
  3915. // }
  3916. // if(isset($jm[$typeclass[$v]['classid']]))
  3917. // {
  3918. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3919. // }
  3920. // }
  3921. // }
  3922. // $jm = array_filter($jm);
  3923. // $rows[$key]['bs'] = implode("-",$jm);
  3924. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3925. // $zh = implode(" ",$pm);
  3926. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3927. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3928. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3929. // $rows[$key]['features'] = $zh;
  3930. }
  3931. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3932. $final_list = [];
  3933. foreach ($list as $k => $v) {
  3934. if (empty($v['sku'])) {
  3935. continue;
  3936. }
  3937. $final_list[] = [
  3938. "warehouse" => $v["warehouse"],
  3939. "purchase" => $v["purchase"],
  3940. "details" => $v["details"],
  3941. "cpid" => $v["cpid"],
  3942. "dbcontent" => $v["dbcontent"],
  3943. "sku" => $v["sku"],
  3944. "cs" => $v["bm"],
  3945. "bs" => $v["jm"],
  3946. "title" => $v["title"],
  3947. "features" => $v["pm"],
  3948. "cpbz" => $v["cpbz"],
  3949. "sm" => $v["sm"],
  3950. "type" => $v["type"],
  3951. "number" => $v["number"],
  3952. "c" => $v["c"],
  3953. "x" => $v["x"],
  3954. "t" => $v["t"],
  3955. "s" => $v["s"],
  3956. "q" => $v["q"],
  3957. "z" => $v["z"],
  3958. "weight" => $v['weight'],
  3959. ];
  3960. }
  3961. $title = "总进销存统计表";
  3962. $titlename = "<table border=1>
  3963. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3964. <tr align='center'>
  3965. <td>仓库</td>
  3966. <td>供应商</td>
  3967. <td>位置</td>
  3968. <td>库存编码</td>
  3969. <td>类目</td>
  3970. <td>SKU</td>
  3971. <td>用友编码</td>
  3972. <td>用友料号</td>
  3973. <td>商品名称</td>
  3974. <td>商品中文</td>
  3975. <td>产品备注</td>
  3976. <td>库位负责人</td>
  3977. <td>类型</td>
  3978. <td>入库总量</td>
  3979. <td>库存数量</td>
  3980. <td>销售数量</td>
  3981. <td>退货数量</td>
  3982. <td>删除数量</td>
  3983. <td>其它操作</td>
  3984. <td>占单数量</td>
  3985. <td>重量(g)</td>
  3986. </tr>
  3987. </table>";
  3988. $filename = $title . ".xls";
  3989. $tail = "";
  3990. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3991. }
  3992. }
  3993. //入库导出
  3994. public function _excelr()
  3995. {
  3996. if (isset($_GET['excel'])) {
  3997. $category = $this->input->get('category', true);
  3998. $size = $this->input->get('size', true);
  3999. $grade = $this->input->get('grade', true);
  4000. $color = $this->input->get('color', true);
  4001. $lowe = $this->input->get('lowe', true);
  4002. $sku = $this->input->get('sku', true);
  4003. $warehouse = $this->input->get('warehouse', true);
  4004. $purchase = $this->input->get('purchase', true);
  4005. $ktime = $this->input->get('ktime', true);
  4006. $jtime = $this->input->get('jtime', true);
  4007. $rktype = $this->input->get('rktype',true);
  4008. $ktime = strtotime($ktime);
  4009. $jtime = strtotime($jtime);
  4010. $where = "1=1";
  4011. $gj = "";
  4012. $ck = "";
  4013. if ($category) {
  4014. $where .= " and features like '%-$category-%'";
  4015. }
  4016. if ($size) {
  4017. $where .= " and features like '%-$size-%'";
  4018. }
  4019. if ($grade) {
  4020. $where .= " and features like '%-$grade-%'";
  4021. }
  4022. if ($color) {
  4023. $where .= " and features like '%-$color-%'";
  4024. }
  4025. if ($lowe) {
  4026. $where .= " and features like '%-$lowe-%'";
  4027. }
  4028. if ($warehouse) {
  4029. $where .= " and warehouse = '$warehouse'";
  4030. }
  4031. if ($purchase) {
  4032. $where .= " and purchase = '$purchase'";
  4033. }
  4034. if ($sku) {
  4035. $where .= " and sku = '$sku'";
  4036. }
  4037. if($rktype){
  4038. $where .= " and rktype = '$rktype' ";
  4039. }
  4040. if ($ktime && $jtime) {
  4041. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4042. }
  4043. //数据排序
  4044. $order_str = "id desc";
  4045. if (empty($page)) {
  4046. $start = 0;
  4047. $perpage = 1;
  4048. } else {
  4049. $start = ($page - 1) * $perpage;
  4050. }
  4051. $list = array();
  4052. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4053. $three_month = strtotime('-3 months');
  4054. $rows_d = $this->whlabelscbf->find_pc($where." and del_time > ".$three_month, 'enter,sku,warehouse', '*', $order_str);
  4055. $rows_d = array_map(function ($item) {
  4056. unset($item['del_time']); // 删除 age 字段
  4057. return $item;
  4058. }, $rows_d);
  4059. $rows = array_merge($rows, $rows_d);
  4060. foreach ($rows as $value) {
  4061. $ck = $this->warehouse->read($value['warehouse']);
  4062. $warehouse = $ck['title'];
  4063. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4064. $retreatwarehouse = $tkck['title'];
  4065. $gy = $this->purchase->read($value['purchase']);
  4066. $purchase = $gy['title'];
  4067. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4068. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4069. }
  4070. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4071. $titlename = "<table border=1>
  4072. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4073. <tr align='center'>
  4074. <td>仓库</td>
  4075. <td>SKU</td>
  4076. <td>产品</td>
  4077. <td>时间</td>
  4078. <td>数量</td>
  4079. </tr>
  4080. </table>";
  4081. $filename = $title . ".xls";
  4082. $tail = "";
  4083. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4084. }
  4085. }
  4086. //出库、退库导出
  4087. public function _excelct()
  4088. {
  4089. $classid = $this->classid->sku();
  4090. $pm = $classid;
  4091. $typeclass = array();
  4092. $tc = $this->typeclass->find_all();
  4093. foreach ($tc as $v) {
  4094. $typeclass[$v['id']] = $v;
  4095. }
  4096. $prc = array();
  4097. $purchase = $this->purchase->find_all();
  4098. foreach ($purchase as $k => $v) {
  4099. $prc[$v['id']] = $v['title'];
  4100. }
  4101. if (isset($_GET['excel'])) {
  4102. $wh = array();
  4103. $w = $this->warehouse->find_all('1=1', 'id,title');
  4104. foreach ($w as $v) {
  4105. $wh[$v['id']] = $v['title'];
  4106. }
  4107. $type = $this->input->get('excel', true);
  4108. $category = $this->input->get('category', true);
  4109. $size = $this->input->get('size', true);
  4110. $grade = $this->input->get('grade', true);
  4111. $color = $this->input->get('color', true);
  4112. $lowe = $this->input->get('lowe', true);
  4113. $sku = $this->input->get('sku', true);
  4114. $title = $this->input->get('title', true);
  4115. $warehouse = $this->input->get('warehouse', true);
  4116. $purchase = $this->input->get('purchase', true);
  4117. $lacetype = $this->input->get('lacetype', true);
  4118. $haircap = $this->input->get('haircap', true);
  4119. $lacecolor = $this->input->get('lacecolor', true);
  4120. $density = $this->input->get('density', true);
  4121. $details = $this->input->get('details', true);
  4122. $state = $this->input->get('state', true);
  4123. $shop = $this->input->get('shop', true);
  4124. $hairnumber = $this->input->get('hairnumber', true);
  4125. $type_leixi = $this->input->get('type', true);
  4126. $cpbz = $this->input->get('cpbz', true);
  4127. $sm = $this->input->get('sm', true);
  4128. $sid = $this->input->get('sid', true);
  4129. $ktime = $this->input->get('ktime', true);
  4130. $jtime = $this->input->get('jtime', true);
  4131. $ktime = strtotime($ktime);
  4132. $jtime = strtotime($jtime);
  4133. //$where = " 1=1 ";
  4134. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4135. $where = " sku != '' ";
  4136. $gj = "";
  4137. $ck = "";
  4138. if ($category) {
  4139. $where .= " and features like '%-$category-%'";
  4140. }
  4141. if ($size) {
  4142. $where .= " and features like '%-$size-%'";
  4143. }
  4144. if ($grade) {
  4145. $where .= " and features like '%-$grade-%'";
  4146. }
  4147. if ($color) {
  4148. $where .= " and features like '%-$color-%'";
  4149. }
  4150. if ($lowe) {
  4151. $where .= " and features like '%-$lowe-%'";
  4152. }
  4153. if ($warehouse) {
  4154. $where .= " and warehouse = '$warehouse'";
  4155. }
  4156. if ($purchase) {
  4157. $where .= " and purchase = '$purchase'";
  4158. }
  4159. if ($state) {
  4160. $where .= " and state = '$state'";
  4161. }
  4162. if ($lacetype) {
  4163. $where .= " and features like '%-$lacetype-%'";
  4164. }
  4165. if ($lacecolor) {
  4166. $where .= " and features like '%-$lacecolor-%'";
  4167. }
  4168. if ($density) {
  4169. $where .= " and features like '%-$density-%'";
  4170. }
  4171. if ($haircap) {
  4172. $where .= " and features like '%-$haircap-%'";
  4173. }
  4174. if ($details) {
  4175. $where .= " and details = '$details'";
  4176. }
  4177. if ($shop) {
  4178. $where .= " and shop like '%$shop%'";
  4179. }
  4180. if ($title) {
  4181. $title = trim($title, ' ');
  4182. $title = trim($title, ' ');
  4183. $where .= " and title like '%$title%'";
  4184. }
  4185. if (!empty($hairnumber)) {
  4186. $where .= " and features like '%-128-%' ";
  4187. if ($hairnumber < 0) {
  4188. $class_list = $this->typeclass->find_all('classid = 43');
  4189. foreach ($class_list as $v) {
  4190. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4191. }
  4192. } else {
  4193. $where .= " and features like '%-$hairnumber-%'";
  4194. }
  4195. }
  4196. if ($type_leixi) {
  4197. $where .= " and type = '$type_leixi'";
  4198. }
  4199. if ($cpbz) {
  4200. $where .= " and cpbz like '%$cpbz%' ";
  4201. }
  4202. if ($sm) {
  4203. $where .= " and sm like '%$sm%' ";
  4204. }
  4205. if ($sku) {
  4206. $sku = trim($sku, ' ');
  4207. $sku = trim($sku, ' ');
  4208. $where .= " and sku like '%$sku%'";
  4209. }
  4210. if ($ktime && $jtime) {
  4211. if ($type == 1) {
  4212. $tl = '出库';
  4213. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4214. } else if ($type == 2) {
  4215. $tl = '退库';
  4216. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4217. } else if ($type == 3) {
  4218. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4219. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4220. } else if ($type == 4) {
  4221. $tl = '出库+零售';
  4222. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4223. } else if ($type == 5) {
  4224. $tl = '零售';
  4225. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4226. }
  4227. }
  4228. $sidwhere = '';
  4229. if ($sid) {
  4230. $sd = "";
  4231. $s = explode(',', trim($sid, ','));
  4232. foreach ($s as $value) {
  4233. $sd .= " id = " . $value . " or";
  4234. }
  4235. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4236. }
  4237. //数据排序
  4238. $order_str = "time desc";
  4239. if (empty($page)) {
  4240. $start = 0;
  4241. $perpage = 1;
  4242. } else {
  4243. $start = ($page - 1) * $perpage;
  4244. }
  4245. //取得信息列表
  4246. if ($type != 3 && $type != 5) {
  4247. if ($type == 1 || $type == 4) {
  4248. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4249. $three_month = strtotime('-3 months');
  4250. $info_list_d = $this->whlabelscbf->find_all($where." and del_time > ".$three_month, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4251. $info_list_d = array_map(function ($item) {
  4252. unset($item['del_time']); // 删除 age 字段
  4253. return $item;
  4254. }, $info_list_d);
  4255. $info_list = array_merge($info_list, $info_list_d);
  4256. foreach ($info_list as $key => $value) {
  4257. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4258. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4259. $warehouse = $this->warehouse->read($value['warehouse']);
  4260. $info_list[$key]['warehouse'] = $warehouse['title'];
  4261. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4262. $features = explode('-', trim($features, '-'));
  4263. $pm = $classid;
  4264. foreach ($features as $k => $v) {
  4265. if ($v != 0) {
  4266. if (!isset($typeclass[$v])) {
  4267. continue;
  4268. }
  4269. if (isset($pm[$typeclass[$v]['classid']])) {
  4270. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4271. $tz = explode('|', $typeclass[$v]['zh']);
  4272. $pm[$typeclass[$v]['classid']] = $tz[0];
  4273. } else {
  4274. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4275. }
  4276. }
  4277. }
  4278. }
  4279. $zh = implode(" ", $pm);
  4280. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4281. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4282. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4283. $info_list[$key]['features'] = $zh;
  4284. }
  4285. $final_list = [];
  4286. foreach($info_list as $k=>$v){
  4287. $number = "";
  4288. if(!empty($v['orderinfo'])){
  4289. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4290. if(!empty($tmp_info['number'])){
  4291. $number = $tmp_info['number'];
  4292. }
  4293. }
  4294. $final_list[] = [
  4295. 'warehouse'=>$v['warehouse'],
  4296. 'purchase'=>$v['purchase'],
  4297. 'sku'=>$v['sku'],
  4298. 'title'=>$v['title'],
  4299. 'features'=>$v['features'],
  4300. 'label'=>$v['label'],
  4301. 'orderinfo'=>$v['orderinfo'],
  4302. 'number'=>$number,
  4303. 'waybill'=>$v['waybill'],
  4304. 'outk'=>$v['outk'],
  4305. ];
  4306. }
  4307. } else {
  4308. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4309. foreach ($info_list as $key => $value) {
  4310. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4311. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4312. $warehouse = $this->warehouse->read($value['warehouse']);
  4313. $info_list[$key]['warehouse'] = $warehouse['title'];
  4314. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4315. $features = explode('-', trim($features, '-'));
  4316. $pm = $classid;
  4317. foreach ($features as $k => $v) {
  4318. if ($v != 0) {
  4319. if (!isset($typeclass[$v])) {
  4320. continue;
  4321. }
  4322. if (isset($pm[$typeclass[$v]['classid']])) {
  4323. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4324. $tz = explode('|', $typeclass[$v]['zh']);
  4325. $pm[$typeclass[$v]['classid']] = $tz[0];
  4326. } else {
  4327. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4328. }
  4329. }
  4330. }
  4331. }
  4332. $zh = implode(" ", $pm);
  4333. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4334. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4335. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4336. $info_list[$key]['features'] = $zh;
  4337. }
  4338. $final_list = [];
  4339. foreach($info_list as $k=>$v){
  4340. $number = "";
  4341. if(!empty($v['orderinfo'])){
  4342. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4343. if(!empty($tmp_info['number'])){
  4344. $number = $tmp_info['number'];
  4345. }
  4346. }
  4347. $final_list[] = [
  4348. 'warehouse'=>$v['warehouse'],
  4349. 'purchase'=>$v['purchase'],
  4350. 'sku'=>$v['sku'],
  4351. 'title'=>$v['title'],
  4352. 'features'=>$v['features'],
  4353. 'label'=>$v['label'],
  4354. 'orderinfo'=>$v['orderinfo'],
  4355. 'number'=>$number,
  4356. 'waybill'=>$v['waybill'],
  4357. 'retreat'=>$v['retreat'],
  4358. ];
  4359. }
  4360. }
  4361. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4362. $titlename = "<table border=1>
  4363. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4364. <tr align='center'>
  4365. <td>仓库</td>
  4366. <td>供应商</td>
  4367. <td>SKU</td>
  4368. <td>商品名称</td>
  4369. <td>商品中文</td>
  4370. <td>标签</td>
  4371. <td>订单号</td>
  4372. <td>订单编码</td>
  4373. <td>运单号</td>
  4374. <td>" . $tl . "时间(中国时间)</td>
  4375. </tr>
  4376. </table>";
  4377. $filename = $title . ".xls";
  4378. $tail = "";
  4379. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4380. } else if ($type == 5) {
  4381. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4382. $three_month = strtotime('-3 months');
  4383. $info_list_d = $this->whlabelscbf->find_all($where." and del_time > ".$three_month, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4384. $info_list_d = array_map(function ($item) {
  4385. unset($item['del_time']); // 删除 age 字段
  4386. return $item;
  4387. }, $info_list_d);
  4388. $info_list = array_merge($info_list, $info_list_d);
  4389. foreach ($info_list as $key => $value) {
  4390. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4391. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4392. $warehouse = $this->warehouse->read($value['warehouse']);
  4393. $info_list[$key]['warehouse'] = $warehouse['title'];
  4394. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4395. $features = explode('-', trim($features, '-'));
  4396. $pm = $classid;
  4397. foreach ($features as $k => $v) {
  4398. if ($v != 0) {
  4399. if (!isset($typeclass[$v])) {
  4400. continue;
  4401. }
  4402. if (isset($pm[$typeclass[$v]['classid']])) {
  4403. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4404. $tz = explode('|', $typeclass[$v]['zh']);
  4405. $pm[$typeclass[$v]['classid']] = $tz[0];
  4406. } else {
  4407. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4408. }
  4409. }
  4410. }
  4411. }
  4412. $zh = implode(" ", $pm);
  4413. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4414. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4415. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4416. $info_list[$key]['features'] = $zh;
  4417. }
  4418. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4419. $titlename = "<table border=1>
  4420. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4421. <tr align='center'>
  4422. <td>仓库</td>
  4423. <td>供应商</td>
  4424. <td>SKU</td>
  4425. <td>商品名称</td>
  4426. <td>商品中文</td>
  4427. <td>标签</td>
  4428. <td>" . $tl . "时间(中国时间)</td>
  4429. </tr>
  4430. </table>";
  4431. $filename = $title . ".xls";
  4432. $tail = "";
  4433. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4434. } else {
  4435. /**
  4436. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4437. $rows = array();$list = array();
  4438. foreach ($info_list as $key=>$value)
  4439. {
  4440. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4441. }
  4442. **/
  4443. $wh = array();
  4444. $w = $this->warehouse->find_all('1=1', 'id,title');
  4445. foreach ($w as $v) {
  4446. $wh[$v['id']] = $v['title'];
  4447. }
  4448. $wt = array();
  4449. $whlabel_type = $this->whlabel_type->find_all();
  4450. foreach ($whlabel_type as $v) {
  4451. $wt[$v['id']] = $v['title'];
  4452. }
  4453. $classid = $this->classid->sku();
  4454. $list = array();
  4455. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4456. foreach ($rows as $key => $value) {
  4457. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4458. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4459. $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');
  4460. $details = array();
  4461. $cpid = array();
  4462. $cpbz = array();
  4463. $c = 0;
  4464. $g = 0;
  4465. $x = 0;
  4466. $t = 0;
  4467. $s = 0;
  4468. $q = 0;
  4469. foreach ($sd as $k => $v) {
  4470. if ($v['state'] == 0) {
  4471. $c++;
  4472. }
  4473. if ($v['state'] != 9) {
  4474. $g++;
  4475. }
  4476. if ($v['outk'] > 1) {
  4477. $x++;
  4478. }
  4479. if ($v['retreat'] > 0) {
  4480. $t++;
  4481. }
  4482. if ($v['state'] == 8) {
  4483. $s++;
  4484. }
  4485. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4486. $q++;
  4487. }
  4488. $details[$v['details']] = $v['details'];
  4489. if($v['state'] == 0){
  4490. if ($v['cpid'] != 0) {
  4491. $cpid[$v['cpid']] = $v['cpid'];
  4492. }
  4493. if ($v['cpbz'] != '') {
  4494. $cpbz[$v['cpbz']] = $v['cpbz'];
  4495. }
  4496. }
  4497. }
  4498. if (isset($wt[$value['type']])) {
  4499. $rows[$key]['type'] = $wt[$value['type']];
  4500. } else {
  4501. $rows[$key]['type'] = '未设置';
  4502. }
  4503. $rows[$key]['details'] = implode("、", $details);
  4504. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4505. $ftime = time() - 15 * 24 * 3600;
  4506. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4507. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4508. $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);
  4509. $rows[$key]['c'] = $c;
  4510. $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);
  4511. $rows[$key]['t'] = $t;
  4512. $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'] . '"');
  4513. $rows[$key]['z'] = $z;
  4514. // $jm = $classid;
  4515. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4516. $features = explode('-', trim($features, '-'));
  4517. // $pm = $classid;
  4518. // foreach ($features as $k => $v) {
  4519. // if ($v != 0) {
  4520. // if (!isset($typeclass[$v])) {
  4521. // continue;
  4522. // }
  4523. // if (isset($pm[$typeclass[$v]['classid']])) {
  4524. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4525. // $tz = explode('|', $typeclass[$v]['zh']);
  4526. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4527. // } else {
  4528. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4529. // }
  4530. // if (isset($jm[$typeclass[$v]['classid']])) {
  4531. // if ($typeclass[$v]['jm']) {
  4532. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4533. // }
  4534. // }
  4535. // }
  4536. // }
  4537. // }
  4538. // $zh = implode(" ", $pm);
  4539. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4540. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4541. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4542. // $rows[$key]['features'] = $zh;
  4543. // $jm = array_filter($jm); //去除空值
  4544. // $jm = implode("-", $jm);
  4545. // $rows[$key]['jm'] = $jm;
  4546. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4547. }
  4548. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4549. // echo "<pre>";
  4550. // print_r($tmp_list);
  4551. // die;
  4552. $final_list =[];
  4553. foreach($tmp_list as $k=>$v){
  4554. $final_list[] = [
  4555. "warehouse"=>$v['warehouse'],
  4556. "purchase"=>$v['purchase'],
  4557. "details"=>trim($v['details'],'、'),
  4558. "cpid"=>$v['cpid'],
  4559. "sku"=>$v['sku'],
  4560. "title"=>$v['title'],
  4561. "features"=>$v['pm'],
  4562. "cpbz"=>$v['cpbz'],
  4563. "sm"=>$v['sm'],
  4564. "type"=>$v['type'],
  4565. "g"=>$v["g"],
  4566. "c"=>$v["c"],
  4567. "x"=>$v["x"],
  4568. "t"=>$v["t"],
  4569. "z"=>$v["z"],
  4570. "jm"=>$v["jm"],
  4571. "weight"=>$v["weight"],
  4572. "asd"=>$v["asd"],
  4573. ];
  4574. }
  4575. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4576. $titlename = "<table border=1>
  4577. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4578. <tr align='center'>
  4579. <td>仓库</td>
  4580. <td>供应商</td>
  4581. <td>位置</td>
  4582. <td>库存编码</td>
  4583. <td>SKU</td>
  4584. <td>商品名称</td>
  4585. <td>商品中文</td>
  4586. <td>产品备注</td>
  4587. <td>说明</td>
  4588. <td>类型</td>
  4589. <td>入库总量</td>
  4590. <td>库存数量</td>
  4591. <td>销售数量</td>
  4592. <td>退货数量</td>
  4593. <td>占单数量</td>
  4594. <td>料号</td>
  4595. <td>重量</td>
  4596. <td>类目</td>
  4597. </tr>
  4598. </table>";
  4599. $filename = $title . ".xls";
  4600. $tail = "";
  4601. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4602. }
  4603. }
  4604. }
  4605. //出库+入库数据整合
  4606. public function _excelcr()
  4607. {
  4608. if (isset($_GET['excel'])) {
  4609. $type = $this->input->get('excel', true);
  4610. $category = $this->input->get('category', true);
  4611. $size = $this->input->get('size', true);
  4612. $grade = $this->input->get('grade', true);
  4613. $color = $this->input->get('color', true);
  4614. $lowe = $this->input->get('lowe', true);
  4615. $sku = $this->input->get('sku', true);
  4616. $warehouse = $this->input->get('warehouse', true);
  4617. $purchase = $this->input->get('purchase', true);
  4618. $state = $this->input->get('state', true);
  4619. $sid = $this->input->get('sid', true);
  4620. $ktime = $this->input->get('ktime', true);
  4621. $jtime = $this->input->get('jtime', true);
  4622. $ktime = strtotime($ktime);
  4623. $jtime = strtotime($jtime);
  4624. $where = "1=1";
  4625. $gj = "";
  4626. $ck = "";
  4627. if ($category) {
  4628. $where .= " and features like '%-$category-%'";
  4629. }
  4630. if ($size) {
  4631. $where .= " and features like '%-$size-%'";
  4632. }
  4633. if ($grade) {
  4634. $where .= " and features like '%-$grade-%'";
  4635. }
  4636. if ($color) {
  4637. $where .= " and features like '%-$color-%'";
  4638. }
  4639. if ($lowe) {
  4640. $where .= " and features like '%-$lowe-%'";
  4641. }
  4642. if ($warehouse) {
  4643. $where .= " and warehouse = '$warehouse'";
  4644. }
  4645. if ($purchase) {
  4646. $where .= " and purchase = '$purchase'";
  4647. }
  4648. if ($state) {
  4649. $where .= " and state = '$state'";
  4650. }
  4651. if ($sku) {
  4652. $where .= " and sku like '%$sku%'";
  4653. }
  4654. if ($ktime && $jtime) {
  4655. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4656. }
  4657. $sidwhere = '';
  4658. if ($sid) {
  4659. $sd = "";
  4660. $s = explode(',', trim($sid, ','));
  4661. foreach ($s as $value) {
  4662. $sd .= " id = " . $value . " or";
  4663. }
  4664. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4665. }
  4666. //取得信息列表
  4667. $timeread = $ktime;
  4668. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4669. $timelist = array();
  4670. for ($i = 0; $i < $timenum; $i++) {
  4671. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4672. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4673. }
  4674. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4675. //echo "<pre>";
  4676. //print_r($info_list);
  4677. //exit();
  4678. $rows = array();
  4679. $list = array();
  4680. foreach ($info_list as $key => $value) {
  4681. $thistime = $timelist;
  4682. if (isset($rows[strtolower($value['sku'])])) {
  4683. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4684. if(isset($rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])])){
  4685. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4686. }
  4687. }
  4688. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4689. if(isset($rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])])){
  4690. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4691. }
  4692. }
  4693. } else {
  4694. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4695. if(isset($thistime[date('Y-m-d', $value['outk'])])){
  4696. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4697. }
  4698. }
  4699. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4700. if(isset($thistime[date('Y-m-d', $value['enter'])])){
  4701. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4702. }
  4703. }
  4704. $rows[strtolower($value['sku'])] = $thistime;
  4705. }
  4706. }
  4707. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4708. <head>
  4709. <!--[if gte mso 9]><xml>
  4710. <x:ExcelWorkbook>
  4711. <x:ExcelWorksheets>
  4712. <x:ExcelWorksheet>
  4713. <x:Name>EXCEL</x:Name>
  4714. <x:WorksheetOptions>
  4715. <x:Print>
  4716. <x:ValidPrinterInfo />
  4717. </x:Print>
  4718. </x:WorksheetOptions>
  4719. </x:ExcelWorksheet>
  4720. </x:ExcelWorksheets>
  4721. </x:ExcelWorkbook>
  4722. </xml>
  4723. <![endif]-->
  4724. </head><body>";
  4725. $str .= "<table border=1><tr><td>SKU</td>";
  4726. foreach ($timelist as $k => $v) {
  4727. $str .= "<td>" . $k . "出库</td>";
  4728. $str .= "<td>" . $k . "入库</td>";
  4729. }
  4730. $str .= "</tr></table>";
  4731. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4732. foreach ($rows as $key => $val) {
  4733. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4734. foreach ($val as $k => $v) {
  4735. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4736. if ($val[$k]['r'] > 0) {
  4737. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4738. } else {
  4739. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4740. }
  4741. }
  4742. $str .= "</tr>";
  4743. }
  4744. $str .= "</table>";
  4745. $str .= "</body></html>";
  4746. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4747. header("Content-type: application/octet-stream");
  4748. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4749. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4750. header("Pragma: no-cache");
  4751. header("Expires: 0");
  4752. exit($str);
  4753. }
  4754. }
  4755. //数量调整模板导出
  4756. public function _presetout()
  4757. {
  4758. if (isset($_GET['excel'])) {
  4759. $where = "sku != 'Preset' and purchase != 0";
  4760. //数据排序
  4761. $order_str = "id desc";
  4762. if (empty($page)) {
  4763. $start = 0;
  4764. $perpage = 1;
  4765. } else {
  4766. $start = ($page - 1) * $perpage;
  4767. }
  4768. //取得信息列表
  4769. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4770. $rows = array();
  4771. $list = array();
  4772. foreach ($info_list as $value) {
  4773. $warehouse = $this->warehouse->read($value['warehouse']);
  4774. $number = $value['number'];
  4775. $ftime = time() - 15 * 24 * 3600;
  4776. $purchase = $this->purchase->read($value['purchase']);
  4777. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4778. }
  4779. $title = "库存模板";
  4780. $titlename = "<table border=1>
  4781. <tr align='center'>
  4782. <td>仓库</td>
  4783. <td>供应商编码</td>
  4784. <td>SKU</td>
  4785. <td>增减数量(正数或负数)</td>
  4786. <td>增减备注</td>
  4787. <td>库位</td>
  4788. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4789. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4790. </tr>
  4791. </table>";
  4792. $filename = $title . ".xls";
  4793. $tail = "";
  4794. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4795. }
  4796. }
  4797. //数量调整模板导入
  4798. public function _presetedit()
  4799. {
  4800. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4801. $config['upload_path'] = '.' . $dir;
  4802. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4803. $config['allowed_types'] = 'xls|xlsx|csv';
  4804. $config['max_size'] = 10240;
  4805. $this->load->library('upload', $config);
  4806. $this->upload->initialize($config);
  4807. if ($this->upload->do_upload('userfile')) {
  4808. $full_path = $dir . $this->upload->data('file_name');
  4809. $fileName = '.' . $full_path;
  4810. if (!file_exists($fileName)) {
  4811. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4812. exit;
  4813. } else {
  4814. require_once "./data/excel/PHPExcel/IOFactory.php";
  4815. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4816. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4817. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4818. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4819. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4820. ++$column; //如果列数大于26行
  4821. $list = array();
  4822. for ($i = 2; $i <= $row; $i++) // 行数循环
  4823. {
  4824. $data = array();
  4825. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4826. {
  4827. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4828. }
  4829. $list[] = $data;
  4830. }
  4831. }
  4832. $i = 0;
  4833. $j = 0;
  4834. $ed = array();
  4835. foreach ($list as $key => $value) {
  4836. $time = time();
  4837. if ($value['0'] == "") {
  4838. continue;
  4839. }
  4840. $warehouse = $this->warehouse->get_title($value['0']);
  4841. $purchase = $this->purchase->get_bm($value['1']);
  4842. $sku = $value['2'];
  4843. $num = $value['3']; //调整数量
  4844. $text = $value['4']; //扣减说明
  4845. $type = $value['5']; //调整方式0扣减1删除
  4846. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4847. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4848. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4849. if (!$purchase) //如果没有这个SKU
  4850. {
  4851. $ed[] = array($purchase . '-不存在此供应商编码');
  4852. $j++;
  4853. continue;
  4854. }
  4855. if (!$d) //如果没有这个SKU
  4856. {
  4857. $ed[] = array($sku . '-库存中不存在此SKU');
  4858. $j++;
  4859. continue;
  4860. }
  4861. if (!isset($warehouse['id'])) {
  4862. $ed[] = array($sku . '-仓库名错误!');
  4863. $j++;
  4864. continue;
  4865. }
  4866. if ($type != '0' && $type != '1') {
  4867. $ed[] = array($sku . '-扣减方式填写错误!');
  4868. $j++;
  4869. continue;
  4870. }
  4871. if ($num < 0) //扣减库存
  4872. {
  4873. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4874. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4875. $j++;
  4876. continue;
  4877. }
  4878. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4879. if (count($data) < abs($num)) {
  4880. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4881. $j++;
  4882. continue;
  4883. }
  4884. if ($type == 0) //如果扣减方式为 扣减库存
  4885. {
  4886. for ($i = 0; $i < abs($num); $i++) {
  4887. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4888. }
  4889. } else if ($type == 1) {
  4890. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4891. if (count($zt) > 0) {
  4892. $ed[] = array($sku . '-有在途库存无法删除!');
  4893. $j++;
  4894. continue;
  4895. }
  4896. for ($i = 0; $i < abs($num); $i++) {
  4897. $this->whlabel->remove($data[$i]['id']);
  4898. }
  4899. }
  4900. } else if ($num > 0) //增加库存
  4901. {
  4902. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4903. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4904. $j++;
  4905. continue;
  4906. }
  4907. $post['sku'] = $d['sku'];
  4908. $post['shop'] = $d['shop'];
  4909. $post['warehouse'] = $warehouse['id'];
  4910. $post['purchase'] = $purchase['id'];
  4911. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4912. $post['state'] = 0;
  4913. $post['title'] = $d['title'];
  4914. $post['number'] = $d['number'];
  4915. $post['features'] = $d['features'];
  4916. $post['enter'] = $time;
  4917. $post['time'] = $time; //操作时间
  4918. $post['rktype'] = $rktype;
  4919. for ($i = 0; $i < $num; $i++) {
  4920. $post['label'] = time() . rand(100, 999) . $i;
  4921. $this->whlabel->insert($post);
  4922. }
  4923. }
  4924. sleep(1); //防止入库时间一样,需要延迟1秒
  4925. }
  4926. if ($j > 0) {
  4927. $tt = date('Ymd', time());
  4928. $title = '库存导入错误信息-' . $tt;
  4929. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4930. $tail = "\n";
  4931. $filename = $title . ".xls";
  4932. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4933. $dir = '/data/excel/' . $time . '/';
  4934. $file_name = 'error_' . $time . rand(1000, 9999);
  4935. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4936. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4937. fwrite($myfile, $ecl);
  4938. fclose($myfile);
  4939. $error = $dir . $file_name . '.xls';
  4940. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4941. exit;
  4942. } else {
  4943. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4944. exit;
  4945. }
  4946. }
  4947. }
  4948. public function _presetedittwo(){
  4949. $data = $this->input->post(NULL, TRUE);
  4950. if(empty($list)){
  4951. $raw_data = $this->input->raw_input_stream;
  4952. // 解码 JSON
  4953. $data = json_decode($raw_data, true);
  4954. }
  4955. if(empty($data)){
  4956. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4957. exit;
  4958. }
  4959. $list = [];
  4960. if(isset($data['list'])){
  4961. $list = $data['list'];
  4962. }
  4963. $i = 0;
  4964. $j = 0;
  4965. $ed = array();
  4966. foreach ($list as $key => $value) {
  4967. $time = time();
  4968. if ($value['0'] == "") {
  4969. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4970. $j++;
  4971. continue;
  4972. }
  4973. $warehouse = $this->warehouse->get_title($value['0']);
  4974. if(empty($warehouse)){
  4975. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4976. $j++;
  4977. continue;
  4978. }
  4979. $purchase = $this->purchase->get_bm($value['1']);
  4980. $sku = $value['2'];
  4981. $num = $value['3']; //调整数量
  4982. $text = $value['4']; //扣减说明
  4983. $type = 0; //调整方式0扣减1删除
  4984. $details = empty($value['5'])?'':$value['5']; //库位
  4985. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4986. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4987. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4988. if (!$purchase) //如果没有这个SKU
  4989. {
  4990. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4991. $j++;
  4992. continue;
  4993. }
  4994. if (!$d) //如果没有这个SKU
  4995. {
  4996. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4997. $j++;
  4998. continue;
  4999. }
  5000. if (!isset($warehouse['id'])) {
  5001. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  5002. $j++;
  5003. continue;
  5004. }
  5005. if ($type != '0' && $type != '1') {
  5006. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  5007. $j++;
  5008. continue;
  5009. }
  5010. if ($num < 0) //扣减库存
  5011. {
  5012. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  5013. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  5014. $j++;
  5015. continue;
  5016. }
  5017. if(!empty($details)){
  5018. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  5019. }else{
  5020. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  5021. }
  5022. if (count($data) < abs($num)) {
  5023. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  5024. $j++;
  5025. continue;
  5026. }
  5027. if ($type == 0) //如果扣减方式为 扣减库存
  5028. {
  5029. for ($i = 0; $i < abs($num); $i++) {
  5030. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  5031. }
  5032. } else if ($type == 1) {
  5033. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  5034. if (count($zt) > 0) {
  5035. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  5036. $j++;
  5037. continue;
  5038. }
  5039. for ($i = 0; $i < abs($num); $i++) {
  5040. $this->whlabel->remove($data[$i]['id']);
  5041. }
  5042. }
  5043. } else if ($num > 0) //增加库存
  5044. {
  5045. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5046. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5047. $j++;
  5048. continue;
  5049. }
  5050. if(empty($details)){
  5051. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5052. if(empty($tmp_info)){
  5053. $details = '';
  5054. }else{
  5055. $details = $tmp_info['details'];
  5056. }
  5057. }else{
  5058. if($details == 'DZ001'){
  5059. }else{
  5060. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5061. if(empty($tmp_info)){
  5062. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5063. $j++;
  5064. continue;
  5065. }
  5066. }
  5067. }
  5068. $post['sku'] = $d['sku'];
  5069. $post['shop'] = $d['shop'];
  5070. $post['warehouse'] = $warehouse['id'];
  5071. $post['purchase'] = $purchase['id'];
  5072. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5073. $post['state'] = 0;
  5074. $post['title'] = $d['title'];
  5075. $post['number'] = $d['number'];
  5076. $post['features'] = $d['features'];
  5077. $post['details'] = $details;
  5078. $post['enter'] = $time;
  5079. $post['time'] = $time; //操作时间
  5080. $post['rktype'] = $rktype;
  5081. $post['sku_master_id'] = $d['sku_master_id'];
  5082. $post['sku_shop_id'] = $d['sku_shop_id'];
  5083. for ($i = 0; $i < $num; $i++) {
  5084. $post['label'] = time() . rand(100, 999) . $i;
  5085. $this->whlabel->insert($post);
  5086. }
  5087. }
  5088. sleep(1); //防止入库时间一样,需要延迟1秒
  5089. }
  5090. if ($j > 0) {
  5091. $tt = date('Ymd', time());
  5092. $title = '库存导入错误信息-' . $tt;
  5093. $error = $title . '.xls';
  5094. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5095. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5096. exit;
  5097. } else {
  5098. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5099. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5100. exit;
  5101. }
  5102. }
  5103. //笛卡儿积
  5104. function cp($ps, $sets, $list)
  5105. {
  5106. $result = array();
  5107. $j = 0;
  5108. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5109. if ($i == 0) {
  5110. $result = $sets[$i];
  5111. }
  5112. $tmp = array();
  5113. foreach ($result as $res) {
  5114. foreach ($sets[$i + 1] as $set) {
  5115. $tmp[] = $res . ',' . $set;
  5116. }
  5117. }
  5118. $result = $tmp;
  5119. }
  5120. $this->db->trans_begin();
  5121. foreach ($result as $v) {
  5122. $post = array();
  5123. $title = "";
  5124. $num = "";
  5125. $data = explode(',', $v);
  5126. for ($i = 0; $i < count($list); $i++) {
  5127. $post[$list[$i]] = $data[$i];
  5128. $typeclass = $this->typeclass->read($data[$i]);
  5129. $title = $title . $typeclass['title'] . " ";
  5130. if ($data[$i] != 0) {
  5131. $num .= $data[$i]; //所有数据ID拼接
  5132. }
  5133. }
  5134. foreach ($ps as $kp => $vp) {
  5135. $post[$kp] = $vp;
  5136. }
  5137. $post['number'] = $num;
  5138. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5139. if ($info_list) {
  5140. $j++;
  5141. } else {
  5142. $skunum = $this->whlabel->find_count();
  5143. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5144. $post['title'] = rtrim($title, ' ');
  5145. $this->whlabel->insert($post);
  5146. }
  5147. }
  5148. if ($this->db->trans_status() === FALSE) {
  5149. $this->db->trans_commit();
  5150. return NULL;
  5151. } else {
  5152. $this->db->trans_commit();
  5153. return $j;
  5154. }
  5155. }
  5156. public function _kj($arg_array)
  5157. {
  5158. if (isset($_POST['sku'])) {
  5159. $time = time();
  5160. $sku = $this->input->post('sku', true);
  5161. $warehouse = $this->input->post('warehouse', true);
  5162. $num = $this->input->post('num', true);
  5163. $text = $this->input->post('text', true);
  5164. $purchase = $this->input->post('purchase', true);
  5165. $cktype = $this->input->post('cktype', true);
  5166. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5167. if ($cktype != 1 && $text == '') {
  5168. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5169. exit;
  5170. }
  5171. if ($num > count($order)) {
  5172. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5173. exit;
  5174. } else {
  5175. for ($i = 0; $i < $num; $i++) {
  5176. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5177. }
  5178. }
  5179. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5180. exit;
  5181. }
  5182. $uid = $this->whlabel->read($arg_array[0]);
  5183. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5184. $this->data['data'] = $uid;
  5185. $this->_Template('whlabel_kj', $this->data);
  5186. }
  5187. public function _summary($arg_array)
  5188. {
  5189. $prc = array();
  5190. $purchase = $this->purchase->find_all();
  5191. foreach ($purchase as $k => $v) {
  5192. $prc[$v['id']] = $v['title'];
  5193. }
  5194. if (isset($_GET['excel'])) {
  5195. $ktime = $this->input->get('ktime', true);
  5196. $jtime = $this->input->get('jtime', true);
  5197. $ktime = strtotime($ktime);
  5198. $jtime = strtotime($jtime);
  5199. $where = "1=1";
  5200. if ($ktime && $jtime) {
  5201. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5202. }
  5203. //数据排序
  5204. $order_str = "time desc";
  5205. if (empty($page)) {
  5206. $start = 0;
  5207. $perpage = 1;
  5208. } else {
  5209. $start = ($page - 1) * $perpage;
  5210. }
  5211. //取得信息列表
  5212. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5213. foreach ($info_list as $key => $value) {
  5214. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5215. $warehouse = $this->warehouse->read($value['warehouse']);
  5216. $info_list[$key]['warehouse'] = $warehouse['title'];
  5217. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid,status');
  5218. $details = array();
  5219. $cpid = array();
  5220. foreach ($x as $k => $v) {
  5221. if($v['status'] == 0){
  5222. if ($v['details'] != '') {
  5223. $details[$v['details']] = $v['details'];
  5224. }
  5225. if ($v['cpid'] != 0) {
  5226. $cpid[$v['cpid']] = $v['cpid'];
  5227. }
  5228. }
  5229. }
  5230. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5231. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5232. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5233. $info_list[$key]['s'] = $s;
  5234. $info_list[$key]['x'] = count($x);
  5235. }
  5236. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5237. $titlename = "<table border=1>
  5238. <tr align='center'>
  5239. <td>仓库</td>
  5240. <td>供应商</td>
  5241. <td>出库位置</td>
  5242. <td>出库编码</td>
  5243. <td>SKU</td>
  5244. <td>产品名</td>
  5245. <td>总剩余库存</td>
  5246. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5247. </tr>
  5248. </table>";
  5249. $filename = $title . ".xls";
  5250. $tail = "";
  5251. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5252. }
  5253. }
  5254. //usps发货清单
  5255. public function _manifest()
  5256. {
  5257. if (isset($_POST['manifest'])) {
  5258. $wltext = $this->input->post('wltext', true);
  5259. $time = time() - 16 * 3600;
  5260. $ptime = strtotime(date('Y-m-d', $time));
  5261. $waybill = array();
  5262. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5263. foreach ($fullorder as $v) {
  5264. $waybill[$v['waybill']] = $v['waybill'];
  5265. }
  5266. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5267. foreach ($fullordersmt as $v) {
  5268. $waybill[$v['waybill']] = $v['waybill'];
  5269. }
  5270. $wltext = explode(';', $wltext);
  5271. foreach ($wltext as $v) {
  5272. if (isset($waybill[$v])) {
  5273. unset($waybill[$v]);
  5274. }
  5275. }
  5276. $data = $this->usps->get_manifest($waybill);
  5277. if (isset($data['Description'])) {
  5278. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5279. exit;
  5280. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5281. $bctime = date('Ymd', time());
  5282. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5283. echo json_encode(array('msg' => $pdf, 'success' => true));
  5284. exit;
  5285. } else {
  5286. echo json_encode(array('msg' => $data, 'success' => false));
  5287. exit;
  5288. }
  5289. }
  5290. }
  5291. public function _pdf($pdf, $title, $bctime)
  5292. {
  5293. $pdf_path = './data/pdf/' . $bctime . '/';
  5294. $file_base64 = $pdf;
  5295. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5296. $file_base64 = base64_decode($file_base64);
  5297. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5298. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5299. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5300. }
  5301. /**
  5302. *
  5303. *
  5304. *
  5305. 进销存占单异常索引
  5306. *
  5307. *
  5308. *
  5309. **/
  5310. public function _abnormal()
  5311. {
  5312. $post = $this->input->post(NULL, TRUE);
  5313. if (isset($post['page'])) {
  5314. $page = $this->input->post('page', true);
  5315. $perpage = $this->input->post('perpage', true);
  5316. $sku = $this->input->post('sku', true);
  5317. $where = "1=1";
  5318. //数据排序
  5319. $order_str = "id desc";
  5320. if (empty($page)) {
  5321. $start = 0;
  5322. $perpage = 1;
  5323. } else {
  5324. $start = ($page - 1) * $perpage;
  5325. }
  5326. //取得信息列表
  5327. $info_list = $this->whlabel->find_all($where, '*');
  5328. $rows = array();
  5329. $list = array();
  5330. foreach ($info_list as $key => $value) {
  5331. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5332. }
  5333. foreach ($rows as $value) {
  5334. $warehouse = $this->warehouse->read($value['warehouse']);
  5335. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5336. $number = $value['number'];
  5337. $ftime = time() - 15 * 24 * 3600;
  5338. if ($value['shop'] != '') {
  5339. $shop = $value['shop'];
  5340. $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');
  5341. $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');
  5342. $order = array_merge($orderdlz, $ordersmt);
  5343. $od = 0;
  5344. $a = '';
  5345. $orid = '';
  5346. foreach ($order as $v) {
  5347. $or = explode('|', ltrim($v['whlabel'], '|'));
  5348. for ($i = 0; $i < count($or); $i++) {
  5349. $orod = explode('-', $or[$i]);
  5350. if ($orod[0] == $number) {
  5351. $od += $orod[1];
  5352. }
  5353. }
  5354. $orid .= $v['number'] . '-';
  5355. }
  5356. } else {
  5357. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5358. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5359. $order = array_merge($orderdlz, $ordersmt);
  5360. $od = 0;
  5361. $a = '';
  5362. $orid = '';
  5363. $qt = array();
  5364. foreach ($order as $v) {
  5365. $or = explode('|', ltrim($v['whlabel'], '|'));
  5366. for ($i = 0; $i < count($or); $i++) {
  5367. $orod = explode('-', $or[$i]);
  5368. if ($orod[0] == $number) {
  5369. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5370. if ($czzs > 0) {
  5371. if (isset($qt[$v['shop']])) {
  5372. if ($qt[$v['shop']] < $orod[1]) {
  5373. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5374. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5375. } else {
  5376. $qt[$v['shop']] -= $orod[1];
  5377. }
  5378. } else {
  5379. $qt[$v['shop']] = $czzs;
  5380. }
  5381. } else {
  5382. $od += $orod[1];
  5383. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5384. }
  5385. }
  5386. }
  5387. }
  5388. }
  5389. $z = $od . '(' . $orid . ')'; //查看订单号
  5390. //$z = $od;
  5391. if ($od > $c) {
  5392. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5393. }
  5394. }
  5395. $listdata = array_slice($list, $start, $perpage);
  5396. $total = count($list);
  5397. $pagenum = ceil($total / $perpage);
  5398. $over = $total - ($start + $perpage);
  5399. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5400. echo json_encode($rows);
  5401. exit;
  5402. }
  5403. $this->_Template('whlabel_abnormal', $this->data);
  5404. }
  5405. /**
  5406. *
  5407. *
  5408. *
  5409. 进销存占单异常索引
  5410. *
  5411. *
  5412. *
  5413. **/
  5414. public function _error()
  5415. {
  5416. $post = $this->input->post(NULL, TRUE);
  5417. if (isset($post['page'])) {
  5418. $page = $this->input->post('page', true);
  5419. $perpage = $this->input->post('perpage', true);
  5420. $sku = $this->input->post('sku', true);
  5421. $warehouse = $this->input->post('warehouse', true);
  5422. $ktime = $this->input->post('ktime', true);
  5423. $jtime = $this->input->post('jtime', true);
  5424. $ktime = strtotime($ktime);
  5425. $jtime = strtotime($jtime);
  5426. $where = "sku != 'Preset'";
  5427. $gj = '';
  5428. if ($sku) {
  5429. $where .= " and sku like '%$sku%'";
  5430. } else {
  5431. if ($ktime && $jtime) {
  5432. $gj = " and time > '$ktime' and time < '$jtime'";
  5433. }
  5434. }
  5435. if ($warehouse) {
  5436. $where .= " and warehouse = '$warehouse'";
  5437. }
  5438. //数据排序
  5439. $order_str = "id desc";
  5440. if (empty($page)) {
  5441. $start = 0;
  5442. $perpage = 1;
  5443. } else {
  5444. $start = ($page - 1) * $perpage;
  5445. }
  5446. //取得信息列表
  5447. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5448. $rows = array();
  5449. $list = array();
  5450. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5451. // foreach ($info_list as $value)
  5452. // {
  5453. // $warehouse = $this->warehouse->read($value['warehouse']);
  5454. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5455. // $number = $value['number'];$ftime = time()-15*24*3600;
  5456. // if($c < 1)
  5457. // {
  5458. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5459. // }
  5460. // }
  5461. $warehouse_list = $this->warehouse->find_all();
  5462. $warehouse_list = array_column($warehouse_list, null, 'id');
  5463. foreach ($info_list as $value) {
  5464. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5465. 'title' => "",
  5466. ];
  5467. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5468. $number = $value['number'];
  5469. $ftime = time() - 15 * 24 * 3600;
  5470. if ($c < 1) {
  5471. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5472. }
  5473. }
  5474. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5475. // $query = $this->db->query($sql);
  5476. // $info_list = $query->result_array();
  5477. // $sql_two = "select title,id from crowd_warehouse";
  5478. // $query_two = $this->db->query($sql_two);
  5479. // $warehouse_list = $query_two->result_array();
  5480. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5481. // foreach ($info_list as $value)
  5482. // {
  5483. // if(isset($warehouse_arr[$value['warehouse']])){
  5484. // $warehouse = $warehouse_arr[$value['warehouse']];
  5485. // }else{
  5486. // $warehouse = [
  5487. // 'id'=>0,
  5488. // 'title'=>"异常",
  5489. // ];
  5490. // }
  5491. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5492. // $number = $value['number'];$ftime = time()-15*24*3600;
  5493. // if($c < 1)
  5494. // {
  5495. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5496. // }
  5497. // }
  5498. $listdata = array_slice($list, $start, $perpage);
  5499. $total = count($list);
  5500. $pagenum = ceil($total / $perpage);
  5501. $over = $total - ($start + $perpage);
  5502. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5503. echo json_encode($rows);
  5504. exit;
  5505. }
  5506. if (isset($post['s'])) {
  5507. $id_arr = $this->input->post('s');
  5508. $id_arr = explode(',', trim($id_arr, ','));
  5509. if (!$id_arr) {
  5510. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5511. exit;
  5512. }
  5513. //循环删除记录
  5514. foreach ($id_arr as $v) {
  5515. $dd = $this->whlabel->read($v);
  5516. if (!isset($dd['id'])) {
  5517. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5518. exit;
  5519. }
  5520. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5521. if (isset($zt[0])) {
  5522. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5523. exit;
  5524. }
  5525. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5526. foreach ($deldd as $vv) {
  5527. $tmp_info = $vv;
  5528. $tmp_info['del_time'] = time();
  5529. $this->db->insert('whlabelscbf',$tmp_info);
  5530. $this->whlabel->remove($vv['id']);
  5531. }
  5532. }
  5533. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5534. exit;
  5535. }
  5536. $this->_Template('whlabel_error', $this->data);
  5537. }
  5538. public function _errorexcel()
  5539. {
  5540. $post = $this->input->post(NULL, TRUE);
  5541. if (isset($_GET['page'])) {
  5542. $page = $this->input->get('page', true);
  5543. $perpage = $this->input->get('perpage', true);
  5544. $sku = $this->input->get('sku', true);
  5545. $warehouse = $this->input->get('warehouse', true);
  5546. $ktime = $this->input->get('ktime', true);
  5547. $jtime = $this->input->get('jtime', true);
  5548. $ktime = strtotime($ktime);
  5549. $jtime = strtotime($jtime);
  5550. $where = "sku != 'Preset'";
  5551. $gj = '';
  5552. if ($sku) {
  5553. $where .= " and sku like '%$sku%'";
  5554. } else {
  5555. if ($ktime && $jtime) {
  5556. $gj = " and time > '$ktime' and time < '$jtime'";
  5557. }
  5558. }
  5559. if ($warehouse) {
  5560. $where .= " and warehouse = '$warehouse'";
  5561. }
  5562. //数据排序
  5563. $order_str = "id desc";
  5564. if (empty($page)) {
  5565. $start = 0;
  5566. $perpage = 1;
  5567. } else {
  5568. $start = ($page - 1) * $perpage;
  5569. }
  5570. //取得信息列表
  5571. $rows = array();
  5572. $list = array();
  5573. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5574. foreach ($info_list as $value) {
  5575. $warehouse = $this->warehouse->read($value['warehouse']);
  5576. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5577. $number = $value['number'];
  5578. $ftime = time() - 15 * 24 * 3600;
  5579. if ($c < 1) {
  5580. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5581. }
  5582. }
  5583. $title = "0库存汇总";
  5584. $titlename = "<table border=1>
  5585. <tr align='center'>
  5586. <td>仓库</td>
  5587. <td>SKU</td>
  5588. <td>产品</td>
  5589. <td>当前库存</td>
  5590. </tr>
  5591. </table>";
  5592. $filename = $title . ".xls";
  5593. $tail = "";
  5594. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5595. }
  5596. }
  5597. /**
  5598. *
  5599. *
  5600. * 占单
  5601. *
  5602. *
  5603. **/
  5604. public function _kcyz()
  5605. {
  5606. $post = $this->input->post(NULL, TRUE);
  5607. if (isset($post['warehouse'])) {
  5608. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5609. exit; //不再使用
  5610. $warehouse = $this->input->post('warehouse', true);
  5611. $whlabel = $this->input->post('whlabel', true);
  5612. $id = $this->input->post('id', true);
  5613. $shop = $this->input->post('shop', true);
  5614. $number = $this->input->post('number', true);
  5615. if (!$whlabel || $whlabel == '|') {
  5616. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5617. exit;
  5618. }
  5619. $pp = explode('|', trim($whlabel, '|'));
  5620. $x = 0;
  5621. $save = array();
  5622. foreach ($pp as $va) {
  5623. $num = explode('-', $va);
  5624. if ($number) {
  5625. $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 = '')"); //通用
  5626. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5627. } else {
  5628. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5629. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5630. }
  5631. $x++;
  5632. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5633. $save[] = $x - 1;
  5634. continue; //提前先加X不然出错,所以要减1
  5635. }
  5636. }
  5637. if (isset($save[0])) {
  5638. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5639. exit;
  5640. } else {
  5641. echo json_encode(array('success' => true));
  5642. exit;
  5643. }
  5644. }
  5645. }
  5646. public function _db()
  5647. {
  5648. $post = $this->input->post(NULL, TRUE);
  5649. if (isset($post['page'])) {
  5650. $page = $this->input->post('page', true);
  5651. $perpage = $this->input->post('perpage', true);
  5652. $sku = $this->input->post('sku', true);
  5653. $number = $this->input->post('number', true);
  5654. $warehouse = $this->input->post('warehouse', true);
  5655. $purchase = $this->input->post('purchase', true);
  5656. $orderinfo = $this->input->post('orderinfo', true);
  5657. $waybill = $this->input->post('waybill', true);
  5658. $category = $this->input->post('category', true);
  5659. $size = $this->input->post('size', true);
  5660. $grade = $this->input->post('grade', true);
  5661. $color = $this->input->post('color', true);
  5662. $lowe = $this->input->post('lowe', true);
  5663. $state = $this->input->post('state', true);
  5664. $label = $this->input->post('label', true);
  5665. $timetk = $this->input->post('timetkk', true);
  5666. $timetj = $this->input->post('timetjj', true);
  5667. $timetk = strtotime($timetk);
  5668. $timetj = strtotime($timetj);
  5669. $where = "dbtime > 0";
  5670. if ($timetk && $timetj) {
  5671. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5672. }
  5673. if ($sku) {
  5674. $where .= " and sku = '$sku'";
  5675. }
  5676. if ($warehouse) {
  5677. $where .= " and warehouse = '$warehouse'";
  5678. if ($warehouse == 12) {
  5679. $w = 'specialstock';
  5680. } else {
  5681. $w = 'whlabel';
  5682. }
  5683. }
  5684. if ($purchase) {
  5685. $where .= " and purchase = '$purchase'";
  5686. }
  5687. if ($category) {
  5688. $where .= " and features like '%-$category-%'";
  5689. }
  5690. if ($size) {
  5691. $where .= " and features like '%-$size-%'";
  5692. }
  5693. if ($grade) {
  5694. $where .= " and features like '%-$grade-%'";
  5695. }
  5696. if ($color) {
  5697. $where .= " and features like '%-$color-%'";
  5698. }
  5699. if ($lowe) {
  5700. $where .= " and features like '%-$lowe-%'";
  5701. }
  5702. if ($state != '') {
  5703. $where .= " and state = '$state'";
  5704. }
  5705. //数据排序
  5706. $order_str = "dbtime desc";
  5707. if (empty($page)) {
  5708. $start = 0;
  5709. $perpage = 1;
  5710. } else {
  5711. $start = ($page - 1) * $perpage;
  5712. }
  5713. //取得信息列表
  5714. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5715. foreach ($info_list as $key => $value) {
  5716. $warehouse = $this->$w->read($value['warehouse']);
  5717. $info_list[$key]['warehouse'] = $warehouse['title'];
  5718. $purchase = $this->purchase->read($value['purchase']);
  5719. $info_list[$key]['purchase'] = $purchase['title'];
  5720. if ($value['enter'] != 0) {
  5721. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5722. } else {
  5723. $info_list[$key]['enter'] = "";
  5724. }
  5725. if ($value['dbtime'] != 0) {
  5726. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5727. } else {
  5728. $info_list[$key]['dbtime'] = "";
  5729. }
  5730. if ($value['state'] == 0) {
  5731. $info_list[$key]['state'] = "在库";
  5732. } else if ($value['state'] == 1) {
  5733. $info_list[$key]['state'] = "出库";
  5734. } else if ($value['state'] == 2) {
  5735. $info_list[$key]['state'] = "退库";
  5736. } else if ($value['state'] == 3) {
  5737. $info_list[$key]['state'] = "调拨中";
  5738. } else if ($value['state'] == 4) {
  5739. $info_list[$key]['state'] = "再加工";
  5740. } else if ($value['state'] == 5) {
  5741. $info_list[$key]['state'] = "维修中";
  5742. } else if ($value['state'] == 6) {
  5743. $info_list[$key]['state'] = "盘亏";
  5744. } else if ($value['state'] == 7) {
  5745. $info_list[$key]['state'] = "更换标签";
  5746. } else if ($value['state'] == 8) {
  5747. $info_list[$key]['state'] = "其它";
  5748. } else if ($value['state'] == 9) {
  5749. $info_list[$key]['state'] = "预设";
  5750. }
  5751. }
  5752. $total = $this->whlabel->find_count($where);
  5753. $pagenum = ceil($total / $perpage);
  5754. $over = $total - ($start + $perpage);
  5755. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5756. echo json_encode($rows);
  5757. exit;
  5758. }
  5759. if (isset($post['outsku'])) {
  5760. $time = time();
  5761. $cz = $this->input->post('cz', true);
  5762. $label = $this->input->post('outsku', true);
  5763. $sl = $this->input->post('sl', true);
  5764. $num = $this->input->post('num', true);
  5765. //$warehouse = $this->input->post('warehouse',true);
  5766. if (!$sl) {
  5767. $sl = 1;
  5768. }
  5769. if (!$warehouse) {
  5770. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5771. exit;
  5772. }
  5773. $dblabel = $this->whlabellabel->get_label($label);
  5774. if ($dblabel) {
  5775. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5776. if (count($data) < 1) {
  5777. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5778. exit;
  5779. }
  5780. if (count($data) < $num) {
  5781. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5782. exit;
  5783. }
  5784. for ($i = 0; $i < $sl; $i++) {
  5785. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5786. }
  5787. echo json_encode(array('success' => true));
  5788. exit;
  5789. } else {
  5790. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5791. exit;
  5792. }
  5793. }
  5794. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5795. $this->_Template('whlabel_db', $this->data);
  5796. }
  5797. public function _dbrk()
  5798. {
  5799. $post = $this->input->post(NULL, TRUE);
  5800. if (isset($post['page'])) {
  5801. $page = $this->input->post('page', true);
  5802. $perpage = $this->input->post('perpage', true);
  5803. $sku = $this->input->post('sku', true);
  5804. $number = $this->input->post('number', true);
  5805. $warehouse = $this->input->post('warehouse', true);
  5806. $purchase = $this->input->post('purchase', true);
  5807. $orderinfo = $this->input->post('orderinfo', true);
  5808. $waybill = $this->input->post('waybill', true);
  5809. $category = $this->input->post('category', true);
  5810. $size = $this->input->post('size', true);
  5811. $grade = $this->input->post('grade', true);
  5812. $color = $this->input->post('color', true);
  5813. $lowe = $this->input->post('lowe', true);
  5814. $state = $this->input->post('state', true);
  5815. $label = $this->input->post('label', true);
  5816. $ctime = $this->input->post('ctime', true);
  5817. $timetk = $this->input->post('timetkk', true);
  5818. $timetj = $this->input->post('timetjj', true);
  5819. $timetk = strtotime($timetk);
  5820. $timetj = strtotime($timetj);
  5821. $where = "dbtime > 0";
  5822. if ($timetk && $timetj) {
  5823. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5824. }
  5825. if ($sku) {
  5826. $where .= " and sku = '$sku'";
  5827. }
  5828. if ($warehouse) {
  5829. $where .= " and warehouse = '$warehouse'";
  5830. }
  5831. if ($purchase) {
  5832. $where .= " and purchase = '$purchase'";
  5833. }
  5834. if ($category) {
  5835. $where .= " and features like '%-$category-%'";
  5836. }
  5837. if ($size) {
  5838. $where .= " and features like '%-$size-%'";
  5839. }
  5840. if ($grade) {
  5841. $where .= " and features like '%-$grade-%'";
  5842. }
  5843. if ($color) {
  5844. $where .= " and features like '%-$color-%'";
  5845. }
  5846. if ($lowe) {
  5847. $where .= " and features like '%-$lowe-%'";
  5848. }
  5849. if ($state != '') {
  5850. $where .= " and state = '$state'";
  5851. }
  5852. //数据排序
  5853. $order_str = "dbtime desc";
  5854. if (empty($page)) {
  5855. $start = 0;
  5856. $perpage = 1;
  5857. } else {
  5858. $start = ($page - 1) * $perpage;
  5859. }
  5860. //取得信息列表
  5861. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5862. foreach ($info_list as $key => $value) {
  5863. $warehouse = $this->warehouse->read($value['warehouse']);
  5864. $info_list[$key]['warehouse'] = $warehouse['title'];
  5865. $purchase = $this->purchase->read($value['purchase']);
  5866. $info_list[$key]['purchase'] = $purchase['title'];
  5867. if ($value['enter'] != 0) {
  5868. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5869. } else {
  5870. $info_list[$key]['enter'] = "";
  5871. }
  5872. if ($value['dbtime'] != 0) {
  5873. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5874. } else {
  5875. $info_list[$key]['dbtime'] = "";
  5876. }
  5877. if ($value['state'] == 0) {
  5878. $info_list[$key]['state'] = "在库";
  5879. } else if ($value['state'] == 1) {
  5880. $info_list[$key]['state'] = "出库";
  5881. } else if ($value['state'] == 2) {
  5882. $info_list[$key]['state'] = "退库";
  5883. } else if ($value['state'] == 3) {
  5884. $info_list[$key]['state'] = "调拨中";
  5885. } else if ($value['state'] == 4) {
  5886. $info_list[$key]['state'] = "再加工";
  5887. } else if ($value['state'] == 5) {
  5888. $info_list[$key]['state'] = "维修中";
  5889. } else if ($value['state'] == 6) {
  5890. $info_list[$key]['state'] = "盘亏";
  5891. } else if ($value['state'] == 7) {
  5892. $info_list[$key]['state'] = "更换标签";
  5893. } else if ($value['state'] == 8) {
  5894. $info_list[$key]['state'] = "其它";
  5895. } else if ($value['state'] == 9) {
  5896. $info_list[$key]['state'] = "预设";
  5897. }
  5898. }
  5899. $total = $this->whlabel->find_count($where);
  5900. $pagenum = ceil($total / $perpage);
  5901. $over = $total - ($start + $perpage);
  5902. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5903. echo json_encode($rows);
  5904. exit;
  5905. }
  5906. if (isset($post['rsku'])) {
  5907. $cz = $this->input->post('cz', true);
  5908. $label = $this->input->post('rsku', true);
  5909. $sl = $this->input->post('sl', true);
  5910. $warehouse = $this->input->post('warehouse', true);
  5911. if (!$sl) {
  5912. $sl = 1;
  5913. }
  5914. if (!$warehouse) {
  5915. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5916. exit;
  5917. }
  5918. $dblabel = $this->whlabellabel->get_label($label);
  5919. if ($dblabel) {
  5920. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5921. if (count($data) < 1) {
  5922. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5923. exit;
  5924. }
  5925. if ($sl > count($data)) {
  5926. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5927. exit;
  5928. }
  5929. $time = time();
  5930. for ($i = 0; $i < $sl; $i++) {
  5931. $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']);
  5932. }
  5933. echo json_encode(array('success' => true));
  5934. exit;
  5935. } else {
  5936. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5937. exit;
  5938. }
  5939. }
  5940. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5941. $this->_Template('whlabel_dbrk', $this->data);
  5942. }
  5943. public function _whlabelczdc()
  5944. {
  5945. if (isset($_GET['excel'])) {
  5946. //数据排序
  5947. $order_str = "id desc";
  5948. if (empty($page)) {
  5949. $start = 0;
  5950. $perpage = 1;
  5951. } else {
  5952. $start = ($page - 1) * $perpage;
  5953. }
  5954. $state = $this->input->get('state', true);
  5955. $sku = $this->input->get('sku', true);
  5956. $ctime = $this->input->get('ctime', true);
  5957. $category = $this->input->get('category', true);
  5958. $size = $this->input->get('size', true);
  5959. $grade = $this->input->get('grade', true);
  5960. $color = $this->input->get('color', true);
  5961. $lowe = $this->input->get('lowe', true);
  5962. $timetk = $this->input->get('timetkk', true);
  5963. $timetj = $this->input->get('timetjj', true);
  5964. $timetk = strtotime($timetk);
  5965. $timetj = strtotime($timetj);
  5966. $where = "dbtime > 0";
  5967. if ($timetk && $timetj) {
  5968. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5969. }
  5970. if ($category) {
  5971. $where .= " and features like '%-$category-%'";
  5972. }
  5973. if ($size) {
  5974. $where .= " and features like '%-$size-%'";
  5975. }
  5976. if ($grade) {
  5977. $where .= " and features like '%-$grade-%'";
  5978. }
  5979. if ($color) {
  5980. $where .= " and features like '%-$color-%'";
  5981. }
  5982. if ($lowe) {
  5983. $where .= " and features like '%-$lowe-%'";
  5984. }
  5985. //取得信息列表
  5986. $info_list = $this->whlabel->find_all($where, '*');
  5987. $rows = array();
  5988. $list = array();
  5989. foreach ($info_list as $key => $value) {
  5990. $rows[$value['sku']] = $value; //所有数据sku
  5991. }
  5992. foreach ($rows as $value) {
  5993. $warehouse = $this->warehouse->read($value['warehouse']);
  5994. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5995. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5996. if ($value['orderinfo'] == 0) {
  5997. $info_list[$key]['orderinfo'] = "";
  5998. }
  5999. if ($value['waybill'] == 0) {
  6000. $info_list[$key]['waybill'] = "";
  6001. }
  6002. if ($value['state'] == 0) {
  6003. $value['state'] = "在库";
  6004. } else if ($value['state'] == 3) {
  6005. $value['state'] = "调拨中";
  6006. }
  6007. $list[] = array($value['sku'], $value['title'], $db, $rk);
  6008. }
  6009. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  6010. $titlename = "<table border=1>
  6011. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  6012. <tr align='center'>
  6013. <td>SKU</td>
  6014. <td>产品</td>
  6015. <td>调拨数量</td>
  6016. <td>入库数量</td>
  6017. </tr>
  6018. </table>";
  6019. $filename = $title . ".xls";
  6020. $tail = "";
  6021. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  6022. }
  6023. }
  6024. public function _print($arg_array)
  6025. {
  6026. if (isset($_SESSION['api'])) {
  6027. $user = $this->user->get_api($_SESSION['api']);
  6028. $usp = $user;
  6029. $fgshop = "";
  6030. $sid = "";
  6031. $wid = "";
  6032. $wtype = "";
  6033. $usersp = explode('|', trim($user['shop'], '|'));
  6034. $userwh = explode('|', trim($user['warehouse'], '|'));
  6035. foreach ($usersp as $value) {
  6036. $fgshop .= " shop = " . $value . " or";
  6037. $sid .= " id = " . $value . " or";
  6038. }
  6039. foreach ($userwh as $value) {
  6040. $wid .= " id = " . $value . " or";
  6041. $wtype .= " type = " . $value . " or";
  6042. }
  6043. }
  6044. $post = $this->input->post(NULL, TRUE);
  6045. if (isset($post['tmsku'])) {
  6046. $tmsku = $this->input->post('tmsku', true);
  6047. if (is_numeric($tmsku)) {
  6048. $yyh = $this->whlabellabel->get_label($tmsku);
  6049. } else {
  6050. $yyh = $this->whlabellabel->get_sku($tmsku);
  6051. if(empty($yyh)){
  6052. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6053. if($r['code'] == -1 ){
  6054. echo json_encode(array('success' => false));
  6055. exit;
  6056. }else{
  6057. echo json_encode(array('features' => $r['data'], 'success' => true));
  6058. exit;
  6059. }
  6060. }
  6061. }
  6062. if ($yyh) {
  6063. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6064. exit;
  6065. } else {
  6066. echo json_encode(array('success' => false));
  6067. exit;
  6068. }
  6069. }
  6070. $classid = $this->classid->sku();
  6071. $pm = $classid;
  6072. $scsku = $classid;
  6073. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6074. if (isset($post['warehouse'])) {
  6075. if ($post['warehouse']) {
  6076. $list = array();
  6077. $num = "";
  6078. $title = "";
  6079. $features = "";
  6080. $order = 0;
  6081. $post['shop'] = '';
  6082. $brand = $this->input->post('brand', true);
  6083. if ($brand != '0,') {
  6084. $b = $this->brand->read(rtrim($brand, ','));
  6085. if ($b) {
  6086. $post['shop'] = str_replace('|', ',', $b['shop']);
  6087. }
  6088. }
  6089. $post['details'] = $this->input->post('details', true); //打印数量
  6090. $xbqnum = $this->input->post('xbqnum', true);
  6091. $post['purchase'] = $this->input->post('purchase', true);
  6092. $post['warehouse'] = $this->input->post('warehouse', true);
  6093. $post['purchase'] = $this->input->post('purchase', true);
  6094. $post['retreatwarehouse'] = $post['warehouse'];
  6095. $post['cpbz'] = $this->input->post('cpbz', true);
  6096. $post['state'] = 9;
  6097. $category = $this->input->post('category', true);
  6098. $list['category'] = $category;
  6099. $list['hairtype'] = $this->input->post('hairtype', true);
  6100. $list['grade'] = $this->input->post('grade', true);
  6101. $size = $this->input->post('size', true);
  6102. $list['size'] = rtrim($size, ',');
  6103. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6104. $list['extension'] = $this->input->post('extension', true);
  6105. if ($category == 1297) {
  6106. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6107. }
  6108. if ($category == 1702) {
  6109. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6110. $list['syother'] = $this->input->post('syother', true);
  6111. }
  6112. if ($category == 133) {
  6113. $list['fittype'] = $this->input->post('fittype', true);
  6114. $list['acother'] = $this->input->post('acother', true);
  6115. }
  6116. $list['color'] = $this->input->post('color', true);
  6117. $list['lowe'] = $this->input->post('lowe', true);
  6118. if ($category == 127) {
  6119. $list['type'] = $this->input->post('type', true);
  6120. $list['headroad'] = $this->input->post('headroad', true);
  6121. $list['density'] = $this->input->post('density', true);
  6122. $list['lacesize'] = $this->input->post('lacesize', true);
  6123. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6124. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6125. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  6126. }
  6127. if ($category == 128) {
  6128. $list['lacetype'] = $this->input->post('lacetype', true);
  6129. $list['haircap'] = $this->input->post('haircap', true);
  6130. $list['density'] = $this->input->post('density', true);
  6131. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6132. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6133. $list['wigother'] = $this->input->post('wigother', true);
  6134. $list['wigother1'] = $this->input->post('wigother1', true);
  6135. $list['wigother2'] = $this->input->post('wigother2', true);
  6136. $list['product_related'] = $this->input->post('product_related', true);
  6137. }
  6138. if ($category == 129) {
  6139. $list['wide'] = $this->input->post('wide', true);
  6140. }
  6141. if ($category == 131) {
  6142. $list['gifttype'] = $this->input->post('gifttype', true);
  6143. $list['giftother'] = $this->input->post('giftother', true);
  6144. }
  6145. if ($category == 134) {
  6146. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6147. }
  6148. if ($category == 1297) {
  6149. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6150. $list['sywigother'] = $this->input->post('sywigother', true);
  6151. }
  6152. if ($category == 130 || $category == 133 || $category == 1702) {
  6153. $list['items'] = $this->input->post('items', true);
  6154. $list['weight'] = $this->input->post('weight', true);
  6155. }
  6156. if ($category == 1702) {
  6157. $list['syhairther'] = $this->input->post('syhairther', true);
  6158. }
  6159. if($category == 130){
  6160. $list['jfother'] = $this->input->post('jfother', true);
  6161. }
  6162. foreach ($list as $k => $v) {
  6163. if ($v != 0) {
  6164. $num .= $v;
  6165. $features .= $v . '-';
  6166. $post[$k] = $v;
  6167. $typeclass = $this->typeclass->read($v);
  6168. if (isset($pm[$typeclass['classid']])) {
  6169. if (stripos($typeclass['zh'], '|') !== false) {
  6170. $exzh = explode('|', $typeclass['zh']);
  6171. if($k == 'hairtype'){
  6172. if(!in_array($v,[163,164,165,166])){
  6173. $pm[$typeclass['classid']] = $exzh[0];
  6174. }
  6175. }else{
  6176. $pm[$typeclass['classid']] = $exzh[0];
  6177. }
  6178. } else {
  6179. if($k == 'hairtype'){
  6180. if(!in_array($v,[163,164,165,166])){
  6181. $pm[$typeclass['classid']] = $typeclass['zh'];
  6182. }
  6183. }else{
  6184. $pm[$typeclass['classid']] = $typeclass['zh'];
  6185. }
  6186. }
  6187. }
  6188. if($k == 'hairtype'){
  6189. if(!in_array($v,[163,164,165,166])){
  6190. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6191. }
  6192. }else{
  6193. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6194. }
  6195. if ($k != 'size') {
  6196. $title .= $typeclass['title'] . " ";
  6197. }
  6198. }
  6199. }
  6200. $typeclass = $this->typeclass->read($list['size']);
  6201. $title .= $typeclass['title'];
  6202. $time = time();
  6203. $post['title'] = rtrim($title, ' ');
  6204. $post['number'] = $num;
  6205. $post['features'] = '-' . $features;
  6206. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6207. $featurespp = explode('-', trim($featurespp, '-'));
  6208. if (isset($featurespp[5])) {
  6209. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6210. } else {
  6211. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6212. }
  6213. $post['enter'] = $time;
  6214. $post['time'] = $time; //操作时间
  6215. $scsku = implode("-", $scsku);
  6216. $zh = implode(" ", $pm);
  6217. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6218. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6219. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6220. $post['sku'] = $bqsku;
  6221. $label = time() . rand(0, 9);
  6222. $post['label'] = $label;
  6223. $cpid = $this->whlabellabel->find_count();
  6224. $post['cpid'] = $cpid + 1;
  6225. $cpid = $post['cpid'];
  6226. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6227. //if($whlabelbarcode)
  6228. //{
  6229. //$post['label'] = $whlabelbarcode['label'];
  6230. //if(!$this->whlabellabel->insert($post))
  6231. //{
  6232. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6233. //}
  6234. //}
  6235. //else
  6236. //{
  6237. $this->db->trans_begin();
  6238. $this->whlabellabel->insert($post);
  6239. //$this->whlabelbarcode->insert($post);
  6240. if ($this->db->trans_status() === TRUE) {
  6241. $this->db->trans_commit();
  6242. } else {
  6243. $this->db->trans_rollback();
  6244. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6245. exit;
  6246. }
  6247. //}
  6248. $warehouse_name = "";
  6249. $warehouse = $post['warehouse'];
  6250. if($warehouse == 12){
  6251. $warehouse_name = "特殊库存库";
  6252. }
  6253. // if($warehouse == 13){
  6254. // $warehouse_name = "许昌仓";
  6255. // }
  6256. // if($warehouse == 5){
  6257. // $warehouse_name = "美国店";
  6258. // }
  6259. // if($warehouse == 16){
  6260. // $warehouse_name = "定制头套仓";
  6261. // }
  6262. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6263. if(!empty($warehouse_name)){
  6264. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6265. }
  6266. $purchase = $this->purchase->read($post['purchase']);
  6267. 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));
  6268. exit; //特殊仓目前不需要仓库选项
  6269. }
  6270. }
  6271. if (isset($_SESSION['api'])) {
  6272. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6273. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6274. $this->data['wlshop'] = $wlshop;
  6275. $this->data['warehouse'] = $warehouse;
  6276. }
  6277. $whlabelwz = $this->whlabelwz->find_all();
  6278. $this->data['whlabelwz'] = $whlabelwz;
  6279. $this->_Template('whlabel_print', $this->data);
  6280. }
  6281. public function _usaprint($arg_array)
  6282. {
  6283. if (isset($_SESSION['api'])) {
  6284. $user = $this->user->get_api($_SESSION['api']);
  6285. $usp = $user;
  6286. $fgshop = "";
  6287. $sid = "";
  6288. $wid = "";
  6289. $wtype = "";
  6290. $usersp = explode('|', trim($user['shop'], '|'));
  6291. $userwh = explode('|', trim($user['warehouse'], '|'));
  6292. foreach ($usersp as $value) {
  6293. $fgshop .= " shop = " . $value . " or";
  6294. $sid .= " id = " . $value . " or";
  6295. }
  6296. foreach ($userwh as $value) {
  6297. $wid .= " id = " . $value . " or";
  6298. $wtype .= " type = " . $value . " or";
  6299. }
  6300. }
  6301. $post = $this->input->post(NULL, TRUE);
  6302. if (isset($post['tmsku'])) {
  6303. $tmsku = $this->input->post('tmsku', true);
  6304. if (is_numeric($tmsku)) {
  6305. $yyh = $this->whlabellabel->get_label($tmsku);
  6306. } else {
  6307. $yyh = $this->whlabellabel->get_sku($tmsku);
  6308. }
  6309. if ($yyh) {
  6310. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6311. exit;
  6312. } else {
  6313. echo json_encode(array('success' => false));
  6314. exit;
  6315. }
  6316. }
  6317. $classid = $this->classid->sku();
  6318. $pm = $classid;
  6319. $scsku = $classid;
  6320. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6321. if (isset($post['warehouse'])) {
  6322. if ($post['warehouse']) {
  6323. $list = array();
  6324. $num = "";
  6325. $title = "";
  6326. $features = "";
  6327. $order = 0;
  6328. $post['shop'] = '';
  6329. $brand = $this->input->post('brand', true);
  6330. if ($brand != '0,') {
  6331. $b = $this->brand->read(rtrim($brand, ','));
  6332. if ($b) {
  6333. $post['shop'] = str_replace('|', ',', $b['shop']);
  6334. }
  6335. }
  6336. $post['details'] = $this->input->post('details', true); //打印数量
  6337. $xbqnum = $this->input->post('xbqnum', true);
  6338. $post['purchase'] = $this->input->post('purchase', true);
  6339. $post['warehouse'] = $this->input->post('warehouse', true);
  6340. $post['purchase'] = $this->input->post('purchase', true);
  6341. $post['retreatwarehouse'] = $post['warehouse'];
  6342. $post['cpbz'] = $this->input->post('cpbz', true);
  6343. $post['state'] = 9;
  6344. $category = $this->input->post('category', true);
  6345. $list['category'] = $category;
  6346. $list['hairtype'] = $this->input->post('hairtype', true);
  6347. $list['grade'] = $this->input->post('grade', true);
  6348. $size = $this->input->post('size', true);
  6349. $list['size'] = rtrim($size, ',');
  6350. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6351. $list['extension'] = $this->input->post('extension', true);
  6352. if ($category == 1297) {
  6353. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6354. }
  6355. if ($category == 1702) {
  6356. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6357. $list['syother'] = $this->input->post('syother', true);
  6358. }
  6359. if ($category == 133) {
  6360. $list['fittype'] = $this->input->post('fittype', true);
  6361. $list['acother'] = $this->input->post('acother', true);
  6362. }
  6363. $list['color'] = $this->input->post('color', true);
  6364. $list['lowe'] = $this->input->post('lowe', true);
  6365. if ($category == 127) {
  6366. $list['type'] = $this->input->post('type', true);
  6367. $list['headroad'] = $this->input->post('headroad', true);
  6368. $list['density'] = $this->input->post('density', true);
  6369. $list['lacesize'] = $this->input->post('lacesize', true);
  6370. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6371. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6372. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  6373. }
  6374. if ($category == 128) {
  6375. $list['lacetype'] = $this->input->post('lacetype', true);
  6376. $list['haircap'] = $this->input->post('haircap', true);
  6377. $list['density'] = $this->input->post('density', true);
  6378. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6379. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6380. $list['wigother'] = $this->input->post('wigother', true);
  6381. $list['wigother1'] = $this->input->post('wigother1', true);
  6382. $list['wigother2'] = $this->input->post('wigother2', true);
  6383. $list['product_related'] = $this->input->post('product_related', true);
  6384. }
  6385. if ($category == 129) {
  6386. $list['wide'] = $this->input->post('wide', true);
  6387. }
  6388. if ($category == 131) {
  6389. $list['gifttype'] = $this->input->post('gifttype', true);
  6390. $list['giftother'] = $this->input->post('giftother', true);
  6391. }
  6392. if ($category == 134) {
  6393. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6394. }
  6395. if ($category == 1297) {
  6396. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6397. $list['sywigother'] = $this->input->post('sywigother', true);
  6398. }
  6399. if ($category == 130 || $category == 133 || $category == 1702) {
  6400. $list['items'] = $this->input->post('items', true);
  6401. $list['weight'] = $this->input->post('weight', true);
  6402. }
  6403. if ($category == 1702) {
  6404. $list['syhairther'] = $this->input->post('syhairther', true);
  6405. }
  6406. foreach ($list as $k => $v) {
  6407. if ($v != 0) {
  6408. $num .= $v;
  6409. $features .= $v . '-';
  6410. $post[$k] = $v;
  6411. $typeclass = $this->typeclass->read($v);
  6412. if (isset($pm[$typeclass['classid']])) {
  6413. if (stripos($typeclass['zh'], '|') !== false) {
  6414. $exzh = explode('|', $typeclass['zh']);
  6415. if($k == 'hairtype'){
  6416. if(!in_array($v,[163,164,165,166])){
  6417. $pm[$typeclass['classid']] = $exzh[0];
  6418. }
  6419. }else{
  6420. $pm[$typeclass['classid']] = $exzh[0];
  6421. }
  6422. } else {
  6423. if($k == 'hairtype'){
  6424. if(!in_array($v,[163,164,165,166])){
  6425. $pm[$typeclass['classid']] = $typeclass['zh'];
  6426. }
  6427. }else{
  6428. $pm[$typeclass['classid']] = $typeclass['zh'];
  6429. }
  6430. }
  6431. }
  6432. if($k == 'hairtype'){
  6433. if(!in_array($v,[163,164,165,166])){
  6434. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6435. }
  6436. }else{
  6437. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6438. }
  6439. if ($k != 'size') {
  6440. $title .= $typeclass['title'] . " ";
  6441. }
  6442. }
  6443. }
  6444. $typeclass = $this->typeclass->read($list['size']);
  6445. $title .= $typeclass['title'];
  6446. $time = time();
  6447. $post['title'] = rtrim($title, ' ');
  6448. $post['number'] = $num;
  6449. $post['features'] = '-' . $features;
  6450. $fp = $this->whlabel->get_features($post['features']);
  6451. if (!$fp) {
  6452. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6453. exit;
  6454. }
  6455. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6456. $featurespp = explode('-', trim($featurespp, '-'));
  6457. if (isset($featurespp[5])) {
  6458. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6459. } else {
  6460. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6461. }
  6462. $post['enter'] = $time;
  6463. $post['time'] = $time; //操作时间
  6464. $scsku = implode("-", $scsku);
  6465. $zh = implode(" ", $pm);
  6466. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6467. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6468. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6469. $post['sku'] = $fp['sku'];
  6470. $post['label'] = $fp['sku'];
  6471. $cpid = $this->whlabellabel->find_count();
  6472. $post['cpid'] = $cpid + 1;
  6473. $cpid = $post['cpid'];
  6474. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6475. //if($whlabelbarcode)
  6476. //{
  6477. //$post['label'] = $whlabelbarcode['label'];
  6478. //if(!$this->whlabellabel->insert($post))
  6479. //{
  6480. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6481. //}
  6482. //}
  6483. //else
  6484. //{
  6485. $this->db->trans_begin();
  6486. $this->whlabellabel->insert($post);
  6487. //$this->whlabelbarcode->insert($post);
  6488. if ($this->db->trans_status() === TRUE) {
  6489. $this->db->trans_commit();
  6490. } else {
  6491. $this->db->trans_rollback();
  6492. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6493. exit;
  6494. }
  6495. //}
  6496. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6497. $purchase = $this->purchase->read($post['purchase']);
  6498. 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));
  6499. exit; //特殊仓目前不需要仓库选项
  6500. }
  6501. }
  6502. if (isset($_SESSION['api'])) {
  6503. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6504. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6505. $this->data['wlshop'] = $wlshop;
  6506. $this->data['warehouse'] = $warehouse;
  6507. }
  6508. $whlabelwz = $this->whlabelwz->find_all();
  6509. $this->data['whlabelwz'] = $whlabelwz;
  6510. $this->_Template('whlabel_usaprint', $this->data);
  6511. }
  6512. public function _printrk($arg_array)
  6513. {
  6514. $prc = array();
  6515. $purchase = $this->purchase->find_all();
  6516. foreach ($purchase as $k => $v) {
  6517. $prc[$v['id']] = $v['title'];
  6518. }
  6519. $post = $this->input->post(NULL, TRUE);
  6520. if (isset($post['page'])) {
  6521. $page = $this->input->post('page', true);
  6522. $perpage = $this->input->post('perpage', true);
  6523. $sku = $this->input->post('sku', true);
  6524. $bs = $this->input->post('bs', true);
  6525. $number = $this->input->post('number', true);
  6526. $warehouse = $this->input->post('warehouse', true);
  6527. $purchase = $this->input->post('purchase', true);
  6528. $orderinfo = $this->input->post('orderinfo', true);
  6529. $waybill = $this->input->post('waybill', true);
  6530. $category = $this->input->post('category', true);
  6531. $size = $this->input->post('size', true);
  6532. $grade = $this->input->post('grade', true);
  6533. $color = $this->input->post('color', true);
  6534. $lowe = $this->input->post('lowe', true);
  6535. $state = $this->input->post('state', true);
  6536. $label = $this->input->post('label', true);
  6537. $timetk = $this->input->post('ktime', true);
  6538. $timetj = $this->input->post('jtime', true);
  6539. $timetk = strtotime($timetk);
  6540. $timetj = strtotime($timetj);
  6541. $where = "1=1 ";
  6542. if ($timetk && $timetj) {
  6543. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6544. }
  6545. if ($sku) {
  6546. $where .= " and sku = '$sku'";
  6547. }
  6548. if ($bs != '') {
  6549. $where .= " and bs = '$bs'";
  6550. }
  6551. if ($number) {
  6552. $where .= " and number = '$number'";
  6553. }
  6554. if ($warehouse) {
  6555. $where .= " and warehouse = '$warehouse'";
  6556. }
  6557. if ($purchase) {
  6558. $where .= " and purchase = '$purchase'";
  6559. }
  6560. if ($orderinfo) {
  6561. $where .= " and orderinfo = '$orderinfo'";
  6562. }
  6563. if ($waybill) {
  6564. $where .= " and waybill = '$waybill'";
  6565. }
  6566. if ($category) {
  6567. $where .= " and features like '%-$category-%'";
  6568. }
  6569. if ($size) {
  6570. $where .= " and features like '%-$size-%'";
  6571. }
  6572. if ($grade) {
  6573. $where .= " and features like '%-$grade-%'";
  6574. }
  6575. if ($color) {
  6576. $where .= " and features like '%-$color-%'";
  6577. }
  6578. if ($lowe) {
  6579. $where .= " and features like '%-$lowe-%'";
  6580. }
  6581. if ($label) {
  6582. $where .= " and label = '$label'";
  6583. }
  6584. // if ($state || $state == 0) {
  6585. // $where .= " and state = '$state'";
  6586. // }
  6587. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6588. //数据排序
  6589. $order_str = "enter desc";
  6590. if (empty($page)) {
  6591. $start = 0;
  6592. $perpage = 1;
  6593. } else {
  6594. $start = ($page - 1) * $perpage;
  6595. }
  6596. //取得信息列表
  6597. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6598. foreach ($info_list as $key => $value) {
  6599. $warehouse = $this->warehouse->read($value['warehouse']);
  6600. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6601. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6602. if ($value['state'] == 0) {
  6603. $info_list[$key]['state'] = "在库";
  6604. } else if ($value['state'] == 1) {
  6605. $info_list[$key]['state'] = "出库";
  6606. } else if ($value['state'] == 2) {
  6607. $info_list[$key]['state'] = "退库";
  6608. } else if ($value['state'] == 3) {
  6609. $info_list[$key]['state'] = "调拨中";
  6610. } else if ($value['state'] == 4) {
  6611. $info_list[$key]['state'] = "再加工";
  6612. } else if ($value['state'] == 5) {
  6613. $info_list[$key]['state'] = "维修中";
  6614. } else if ($value['state'] == 6) {
  6615. $info_list[$key]['state'] = "盘亏";
  6616. } else if ($value['state'] == 7) {
  6617. $info_list[$key]['state'] = "更换标签";
  6618. } else if ($value['state'] == 8) {
  6619. $info_list[$key]['state'] = "其它";
  6620. } else if ($value['state'] == 9) {
  6621. $info_list[$key]['state'] = "预设";
  6622. } else if ($value['state'] == 10) {
  6623. $info_list[$key]['state'] = "美店零售";
  6624. }
  6625. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6626. }
  6627. $total = $this->$ck->find_count($where);
  6628. $pagenum = ceil($total / $perpage);
  6629. $over = $total - ($start + $perpage);
  6630. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6631. echo json_encode($rows);
  6632. exit;
  6633. }
  6634. if (isset($post['tmsku'])) {
  6635. $time = time();
  6636. $tmsku = $this->input->post('tmsku', true);
  6637. //$post['shop'] = $this->input->post('shop',true);
  6638. $num = $this->input->post('num', true);
  6639. $rktype = $this->input->post('rktype', true);
  6640. if ($num > 200) {
  6641. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6642. exit;
  6643. }
  6644. if (!$rktype) {
  6645. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6646. }
  6647. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6648. /**
  6649. $wz = array();
  6650. foreach ($rk as $key=>$value)
  6651. {
  6652. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6653. }
  6654. if(count($wz) > 1)
  6655. {
  6656. $wz = array_values($wz);
  6657. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6658. }
  6659. **/
  6660. if (isset($rk[0]['purchase'])) {
  6661. $rk = $rk[0];
  6662. $j = 0;
  6663. $post['purchase'] = $rk['purchase'];
  6664. $post['warehouse'] = $rk['warehouse'];
  6665. $post['retreatwarehouse'] = $rk['warehouse'];
  6666. $post['sku'] = $rk['sku'];
  6667. $post['number'] = $rk['number'];
  6668. $post['features'] = $rk['features'];
  6669. $post['title'] = $rk['title'];
  6670. $post['enter'] = $time;
  6671. $post['time'] = $time;
  6672. $post['bs'] = 1;
  6673. $post['shop'] = $rk['shop'];
  6674. $post['details'] = $rk['details'];
  6675. $post['cpid'] = $rk['cpid'];
  6676. $post['cpbz'] = $rk['cpbz'];
  6677. $post['rktype'] = $rktype;
  6678. $warehouse = $this->warehouse->read($rk['warehouse']);
  6679. if ($warehouse['bdck'] == '') {
  6680. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6681. exit;
  6682. } else {
  6683. $bdck = $warehouse['bdck'];
  6684. }
  6685. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6686. if (isset($pdwz['details'])) {
  6687. if ($pdwz['details'] != $post['details']) {
  6688. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6689. }else{
  6690. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6691. exit;
  6692. }
  6693. }
  6694. }
  6695. $post['featurespp'] = $rk['featurespp'];
  6696. if ($post['warehouse'] == '5') {
  6697. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6698. if ($yza) {
  6699. if ($post['features'] != $yza[0]['features']) {
  6700. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6701. exit;
  6702. }
  6703. }
  6704. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6705. if ($yzb) {
  6706. if ($post['sku'] != $yzb[0]['sku']) {
  6707. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6708. exit;
  6709. }
  6710. }
  6711. }
  6712. for ($i = 0; $i < $num; $i++) {
  6713. $post['label'] = time() . rand(100, 999) . $i;
  6714. if ($this->$bdck->insert($post)) {
  6715. $j++;
  6716. }
  6717. }
  6718. /**
  6719. if($post['warehouse'] != 12)
  6720. {
  6721. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6722. }
  6723. **/
  6724. // $this->whlabelscanlog->insert([
  6725. // 'shop'=>$rk['shop'],
  6726. // 'type'=>1,
  6727. // 'purchase'=>$rk['purchase'],
  6728. // 'sku'=>$rk['sku'],
  6729. // 'features'=>$rk['features'],
  6730. // 'title'=>$rk['title'],
  6731. // 'label'=>$rk['label'],
  6732. // 'warehouse'=>$rk['warehouse'],
  6733. // 'wlid'=>$rk['id'],
  6734. // 'num'=>$num,
  6735. // 'addtime'=>time()
  6736. // ]);
  6737. if ($j == $num) {
  6738. $this->whlabelscanlog->insert([
  6739. 'shop'=>$rk['shop'],
  6740. 'type'=>1,
  6741. 'purchase'=>$rk['purchase'],
  6742. 'sku'=>$rk['sku'],
  6743. 'features'=>$rk['features'],
  6744. 'title'=>$rk['title'],
  6745. 'label'=>$rk['label'],
  6746. 'warehouse'=>$rk['warehouse'],
  6747. 'wlid'=>$rk['id'],
  6748. 'num'=>$num,
  6749. 'addtime'=>$time,
  6750. 'remark'=>'入库成功'
  6751. ]);
  6752. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6753. exit;
  6754. } else {
  6755. $this->whlabelscanlog->insert([
  6756. 'shop'=>$rk['shop'],
  6757. 'type'=>1,
  6758. 'purchase'=>$rk['purchase'],
  6759. 'sku'=>$rk['sku'],
  6760. 'features'=>$rk['features'],
  6761. 'title'=>$rk['title'],
  6762. 'label'=>$rk['label'],
  6763. 'warehouse'=>$rk['warehouse'],
  6764. 'wlid'=>$rk['id'],
  6765. 'num'=>$num,
  6766. 'addtime'=>$time,
  6767. 'remark'=>'未成功入库数量:' . $num - $j . ',请补入'
  6768. ]);
  6769. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6770. exit;
  6771. }
  6772. } else {
  6773. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6774. exit;
  6775. }
  6776. }
  6777. $this->_Template('whlabel_printrk', $this->data);
  6778. }
  6779. public function _printxzrk($arg_array)
  6780. {
  6781. $post = $this->input->post(NULL, TRUE);
  6782. if (isset($post['wzid'])) {
  6783. $time = time();
  6784. $id = $this->input->post('wzid', true);
  6785. //$post['shop'] = $this->input->post('shop',true);
  6786. $num = 1;
  6787. $rk = $this->whlabellabel->read($id);
  6788. if (isset($rk['purchase'])) {
  6789. $x = 0;
  6790. $post['purchase'] = $rk['purchase'];
  6791. $post['warehouse'] = $rk['warehouse'];
  6792. $post['retreatwarehouse'] = $rk['warehouse'];
  6793. $post['sku'] = $rk['sku'];
  6794. $post['number'] = $rk['number'];
  6795. $post['features'] = $rk['features'];
  6796. $post['title'] = $rk['title'];
  6797. $post['enter'] = $time;
  6798. $post['time'] = $time;
  6799. $post['bs'] = 1;
  6800. $post['shop'] = $rk['shop'];
  6801. $post['details'] = $rk['details'];
  6802. $post['cpid'] = $rk['cpid'];
  6803. $post['cpbz'] = $rk['cpbz'];
  6804. $warehouse = $this->warehouse->read($rk['warehouse']);
  6805. if ($warehouse['bdck'] == '') {
  6806. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6807. exit;
  6808. } else {
  6809. $bdck = $warehouse['bdck'];
  6810. }
  6811. $post['featurespp'] = $rk['featurespp'];
  6812. $this->db->trans_begin();
  6813. for ($i = 0; $i < $num; $i++) {
  6814. $post['label'] = time() . rand(100, 999) . $i;
  6815. $this->$bdck->insert($post);
  6816. }
  6817. /**
  6818. if($post['warehouse'] != 12)
  6819. {
  6820. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6821. }
  6822. **/
  6823. if ($this->db->trans_status() === TRUE) {
  6824. $this->db->trans_commit();
  6825. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6826. exit;
  6827. } else {
  6828. $this->db->trans_rollback();
  6829. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6830. exit;
  6831. }
  6832. } else {
  6833. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6834. exit;
  6835. }
  6836. }
  6837. }
  6838. public function _printck($arg_array)
  6839. {
  6840. $prc = array();
  6841. $purchase = $this->purchase->find_all();
  6842. foreach ($purchase as $k => $v) {
  6843. $prc[$v['id']] = $v['title'];
  6844. }
  6845. $post = $this->input->post(NULL, TRUE);
  6846. if (isset($post['page'])) {
  6847. $page = $this->input->post('page', true);
  6848. $perpage = $this->input->post('perpage', true);
  6849. $sku = $this->input->post('sku', true);
  6850. $bs = $this->input->post('bs', true);
  6851. $number = $this->input->post('number', true);
  6852. $warehouse = $this->input->post('warehouse', true);
  6853. $purchase = $this->input->post('purchase', true);
  6854. $orderinfo = $this->input->post('orderinfo', true);
  6855. $waybill = $this->input->post('waybill', true);
  6856. $category = $this->input->post('category', true);
  6857. $size = $this->input->post('size', true);
  6858. $grade = $this->input->post('grade', true);
  6859. $color = $this->input->post('color', true);
  6860. $lowe = $this->input->post('lowe', true);
  6861. $state = $this->input->post('state', true);
  6862. $label = $this->input->post('label', true);
  6863. $timetk = $this->input->post('ktime', true);
  6864. $timetj = $this->input->post('jtime', true);
  6865. $timetk = strtotime($timetk);
  6866. $timetj = strtotime($timetj);
  6867. $where = "state=1 ";
  6868. if ($timetk && $timetj) {
  6869. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6870. }
  6871. if ($sku) {
  6872. $where .= " and sku = '$sku'";
  6873. }
  6874. if ($bs != '') {
  6875. $where .= " and bs = '$bs'";
  6876. }
  6877. if ($number) {
  6878. $where .= " and number = '$number'";
  6879. }
  6880. if ($warehouse) {
  6881. $where .= " and warehouse = '$warehouse'";
  6882. }
  6883. if ($purchase) {
  6884. $where .= " and purchase = '$purchase'";
  6885. }
  6886. if ($orderinfo) {
  6887. $where .= " and orderinfo = '$orderinfo'";
  6888. }
  6889. if ($waybill) {
  6890. $where .= " and waybill = '$waybill'";
  6891. }
  6892. if ($category) {
  6893. $where .= " and features like '%-$category-%'";
  6894. }
  6895. if ($size) {
  6896. $where .= " and features like '%-$size-%'";
  6897. }
  6898. if ($grade) {
  6899. $where .= " and features like '%-$grade-%'";
  6900. }
  6901. if ($color) {
  6902. $where .= " and features like '%-$color-%'";
  6903. }
  6904. if ($lowe) {
  6905. $where .= " and features like '%-$lowe-%'";
  6906. }
  6907. if ($label) {
  6908. $where .= " and label = '$label'";
  6909. }
  6910. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6911. //数据排序
  6912. $order_str = "outk desc";
  6913. if (empty($page)) {
  6914. $start = 0;
  6915. $perpage = 1;
  6916. } else {
  6917. $start = ($page - 1) * $perpage;
  6918. }
  6919. //取得信息列表
  6920. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6921. foreach ($info_list as $key => $value) {
  6922. $warehouse = $this->warehouse->read($value['warehouse']);
  6923. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6924. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6925. if ($value['state'] == 0) {
  6926. $info_list[$key]['state'] = "在库";
  6927. } else if ($value['state'] == 1) {
  6928. $info_list[$key]['state'] = "出库";
  6929. } else if ($value['state'] == 2) {
  6930. $info_list[$key]['state'] = "退库";
  6931. } else if ($value['state'] == 3) {
  6932. $info_list[$key]['state'] = "调拨中";
  6933. } else if ($value['state'] == 4) {
  6934. $info_list[$key]['state'] = "再加工";
  6935. } else if ($value['state'] == 5) {
  6936. $info_list[$key]['state'] = "维修中";
  6937. } else if ($value['state'] == 6) {
  6938. $info_list[$key]['state'] = "盘亏";
  6939. } else if ($value['state'] == 7) {
  6940. $info_list[$key]['state'] = "更换标签";
  6941. } else if ($value['state'] == 8) {
  6942. $info_list[$key]['state'] = "其它";
  6943. } else if ($value['state'] == 9) {
  6944. $info_list[$key]['state'] = "预设";
  6945. } else if ($value['state'] == 10) {
  6946. $info_list[$key]['state'] = "美店零售";
  6947. }
  6948. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6949. }
  6950. $total = $this->$ck->find_count($where);
  6951. $pagenum = ceil($total / $perpage);
  6952. $over = $total - ($start + $perpage);
  6953. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6954. echo json_encode($rows);
  6955. exit;
  6956. }
  6957. if (isset($post['tmsku'])) {
  6958. $time = time();
  6959. $tmsku = $this->input->post('tmsku', true);
  6960. //$post['shop'] = $this->input->post('shop',true);
  6961. $num = $this->input->post('num', true);
  6962. $cktype = $this->input->post('cktype', true);
  6963. $label = $this->whlabellabel->get_label($tmsku);
  6964. if (!$cktype) {
  6965. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6966. }
  6967. if (!isset($label['warehouse'])) {
  6968. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6969. exit;
  6970. }
  6971. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6972. $extra_where = "";
  6973. if(!empty($label['details'])){
  6974. $extra_where .= " and details = '" . $label['details'] . "'";
  6975. }
  6976. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6977. if (stripos($label['features'], '-126-') !== false) {
  6978. $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);
  6979. } else {
  6980. $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);
  6981. }
  6982. $j = 0;
  6983. if (count($ck) >= $num) {
  6984. for ($i = 0; $i < $num; $i++) {
  6985. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6986. {
  6987. $j++;
  6988. }
  6989. }
  6990. if ($j == $num) {
  6991. $this->whlabelscanlog->insert([
  6992. 'shop'=>$label['shop'],
  6993. 'type'=>2,
  6994. 'purchase'=>$label['purchase'],
  6995. 'sku'=>$label['sku'],
  6996. 'features'=>$label['features'],
  6997. 'title'=>$label['title'],
  6998. 'label'=>$label['label'],
  6999. 'warehouse'=>$label['warehouse'],
  7000. 'wlid'=>$label['id'],
  7001. 'num'=>$num,
  7002. 'addtime'=>$time,
  7003. 'remark'=>'出库成功!'
  7004. ]);
  7005. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  7006. exit;
  7007. } else {
  7008. $this->whlabelscanlog->insert([
  7009. 'shop'=>$label['shop'],
  7010. 'type'=>2,
  7011. 'purchase'=>$label['purchase'],
  7012. 'sku'=>$label['sku'],
  7013. 'features'=>$label['features'],
  7014. 'title'=>$label['title'],
  7015. 'label'=>$label['label'],
  7016. 'warehouse'=>$label['warehouse'],
  7017. 'wlid'=>$label['id'],
  7018. 'num'=>$num,
  7019. 'addtime'=>$time,
  7020. 'remark'=>'未成功出库数量:' . $num - $j . ',请补入'
  7021. ]);
  7022. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  7023. exit;
  7024. }
  7025. } else {
  7026. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  7027. exit;
  7028. }
  7029. }
  7030. if(isset($_SESSION['api']))
  7031. {
  7032. $user = $this->user->get_api($_SESSION['api']);
  7033. if(in_array($user['power'],[1,27])){
  7034. $vip = 1;
  7035. }
  7036. }
  7037. else
  7038. {
  7039. $vip = 0;
  7040. header('Location: /');exit;
  7041. }
  7042. $this->data['vip'] = $vip;
  7043. $this->_Template('whlabel_printck', $this->data);
  7044. }
  7045. public function _printexcel()
  7046. {
  7047. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7048. $config['upload_path'] = '.' . $dir;
  7049. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7050. $config['allowed_types'] = 'xls|xlsx|csv';
  7051. $config['max_size'] = 10240;
  7052. $this->load->library('upload', $config);
  7053. $this->upload->initialize($config);
  7054. if ($this->upload->do_upload('userfile')) {
  7055. $full_path = $dir . $this->upload->data('file_name');
  7056. $fileName = '.' . $full_path;
  7057. if (!file_exists($fileName)) {
  7058. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7059. exit;
  7060. } else {
  7061. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7062. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7063. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7064. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7065. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7066. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7067. ++$column; //如果列数大于26行
  7068. $list = array();
  7069. for ($i = 2; $i <= $row; $i++) // 行数循环
  7070. {
  7071. $data = array();
  7072. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7073. {
  7074. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7075. }
  7076. $list[] = $data;
  7077. }
  7078. }
  7079. $ed = array();
  7080. $i = 0;
  7081. $j = 0;
  7082. $dcdata = array();
  7083. $yc = '';
  7084. $cmf_arr = array_column($list, '1');
  7085. array_multisort($cmf_arr, SORT_ASC, $list);
  7086. foreach ($list as $key => $value) {
  7087. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  7088. if ($typeclass) {
  7089. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  7090. } else {
  7091. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  7092. $i++;
  7093. continue;
  7094. }
  7095. }
  7096. if ($i > 0) {
  7097. $yc = $i . '条异常';
  7098. }
  7099. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  7100. exit;
  7101. }
  7102. }
  7103. public function _uck()
  7104. {
  7105. if (isset($_GET['excel'])) {
  7106. $tc = array();
  7107. $typeclass = $this->typeclass->find_all();
  7108. foreach ($typeclass as $v) {
  7109. $tc[$v['id']] = $v['zh'];
  7110. }
  7111. $data = array();
  7112. $t = array();
  7113. $rq = '';
  7114. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  7115. $ts = $ts / (24 * 3600);
  7116. for ($i = 0; $i < $ts; $i++) {
  7117. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  7118. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  7119. }
  7120. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  7121. foreach ($info_list as $k => $v) {
  7122. $features = explode('-', trim($v['features'], '-'));
  7123. if (!isset($features[3]) || !isset($features[4])) {
  7124. continue;
  7125. }
  7126. $data[$k][0] = $tc[$features[0]]; //类型
  7127. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7128. $data[$k][2] = $tc[$features[4]]; //曲度
  7129. $data[$k][3] = '';
  7130. if (isset($data[$k][1])) {
  7131. $data[$k][3] .= $data[$k][1];
  7132. }
  7133. if (isset($data[$k][2])) {
  7134. $data[$k][3] .= $data[$k][2];
  7135. }
  7136. if (isset($features[5])) {
  7137. $data[$k][3] .= $tc[$features[5]];
  7138. }
  7139. if (isset($features[2])) {
  7140. $data[$k][3] .= $tc[$features[2]];
  7141. }
  7142. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7143. $data[$k][4] = $v['sku'];
  7144. $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())) . '))'); //月初库存
  7145. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7146. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7147. $ztrq = '';
  7148. $ztsl = '';
  7149. if (count($zt) > 0) {
  7150. foreach ($zt as $vv) {
  7151. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7152. $ztsl .= $vv['num'] . '<br>';
  7153. }
  7154. }
  7155. $data[$k][] = trim($ztsl, '<br>');
  7156. $data[$k][] = trim($ztrq, '<br>');
  7157. $byck = 0;
  7158. foreach ($t as $vv) {
  7159. $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));
  7160. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7161. $byck += $sl;
  7162. }
  7163. $data[$k][] = ($byck > 0) ? $byck : '';
  7164. }
  7165. $title = "详情 " . date("Y-m-d", time());
  7166. $titlename = "<table border=1>
  7167. <tr align='center'>
  7168. <td>类别</td>
  7169. <td>颜色</td>
  7170. <td>曲度</td>
  7171. <td>名称</td>
  7172. <td>SKU</td>
  7173. <td>月初库存</td>
  7174. <td>剩余库存</td>
  7175. <td>在途数量</td>
  7176. <td>预达日期</td>" .
  7177. $rq
  7178. . "<td>本月出库</td></tr>
  7179. </table>";
  7180. $filename = $title . ".xls";
  7181. $tail = "";
  7182. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7183. }
  7184. }
  7185. //梦体发现 用数字粘贴 会出现遗产给的数据
  7186. public function _whlabelexcelzh_ztsh()
  7187. {
  7188. if (isset($_GET['excel'])) {
  7189. $where = "sku != 'Preset'";
  7190. //数据排序
  7191. $order_str = "id desc";
  7192. if (empty($page)) {
  7193. $start = 0;
  7194. $perpage = 1;
  7195. } else {
  7196. $start = ($page - 1) * $perpage;
  7197. }
  7198. $category = $this->input->get('category', true);
  7199. $warehouse = $this->input->get('warehouse', true);
  7200. $excelid = $this->input->get('sid', true);
  7201. if ($category) {
  7202. $where .= " and features like '%-$category-%'";
  7203. }
  7204. if ($warehouse) {
  7205. $where .= " and warehouse = '$warehouse'";
  7206. }
  7207. $xzid = '';
  7208. if ($excelid) {
  7209. $excelid = explode(',', trim($excelid, ','));
  7210. foreach ($excelid as $key => $value) {
  7211. $xzid .= " id = " . $value . " or";
  7212. }
  7213. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7214. }
  7215. //取得信息列表
  7216. /**
  7217. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7218. $rows = array();$list = array();
  7219. foreach ($info_list as $key=>$value)
  7220. {
  7221. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7222. }
  7223. **/
  7224. $list = array();
  7225. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7226. foreach ($rows as $key => $value) {
  7227. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7228. $zh = '';
  7229. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7230. foreach ($zt as $v) {
  7231. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7232. }
  7233. $zt = array_sum(array_column($zt, 'num'));
  7234. $number = $value['number'];
  7235. $ftime = time() - 15 * 24 * 3600;
  7236. $warehouse = $this->warehouse->read($value['warehouse']);
  7237. $rows[$key]['warehouse'] = $warehouse['title'];
  7238. $rows[$key]['number'] = $c;
  7239. $rows[$key]['features'] = $zh;
  7240. $rows[$key]['hb'] = $c + $zt;
  7241. }
  7242. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7243. $titlename = "<table border=1>
  7244. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7245. <tr align='center'>
  7246. <td>仓库</td>
  7247. <td>SKU</td>
  7248. <td>产品</td>
  7249. <td>库存数量</td>
  7250. <td>在途数量及预达日期</td>
  7251. <td>在途+库存数量</td>
  7252. </tr>
  7253. </table>";
  7254. $filename = $title . ".xls";
  7255. $tail = "";
  7256. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7257. }
  7258. if (isset($_GET['excel'])) {
  7259. $warehouse = $this->input->get('warehouse', true);
  7260. $sku = $this->input->get('sku', true);
  7261. $cz = $this->input->get('cz', true);
  7262. $text = $this->input->post('text', true);
  7263. $xztime = $this->input->get('xztime', true);
  7264. $timetk = $this->input->get('timetk', true);
  7265. $timetj = $this->input->get('timetj', true);
  7266. $timetk = strtotime($timetk);
  7267. $timetj = strtotime($timetj);
  7268. $where = "time = '0' ";
  7269. if ($warehouse) {
  7270. $where .= " and warehouse = '$warehouse'";
  7271. }
  7272. if ($sku) {
  7273. $where .= " and sku = '$sku'";
  7274. }
  7275. if ($text) {
  7276. $where .= " and text like '%$text%'";
  7277. }
  7278. if ($cz != '') {
  7279. $where .= " and cz = '$cz'";
  7280. }
  7281. if ($timetk && $timetj) {
  7282. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7283. }
  7284. //数据排序
  7285. $order_str = $xztime . " desc";
  7286. //取得信息列表
  7287. $zh = array();
  7288. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7289. foreach ($info_list as $v) {
  7290. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7291. $warehouse = $this->warehouse->read($v['warehouse']);
  7292. $v['warehouse'] = $warehouse['title'];
  7293. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7294. $v['stime'] = date('Y-m-d', $v['stime']);
  7295. if (isset($zh[$v['features']])) {
  7296. $zh[$v['features']]['num'] += $v['num'];
  7297. } else {
  7298. $zh[$v['features']] = $v;
  7299. }
  7300. $zh[$v['features']]['features'] = $c;
  7301. }
  7302. $title = "在途数据" . date('Y-m-d', time());
  7303. $titlename = "<table border=1>
  7304. <tr align='center'>
  7305. <td>仓库</td>
  7306. <td>SKU</td>
  7307. <td>名称</td>
  7308. <td>在途数量</td>
  7309. <td>库存数量</td>
  7310. <td>添加在途日期</td>
  7311. <td>预达日期</td>
  7312. <td>备注</td>
  7313. </tr>
  7314. </table>";
  7315. $filename = $title . ".xls";
  7316. $tail = "";
  7317. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7318. }
  7319. }
  7320. //用XML(SpreadsheetML)格式导出excel,逻辑与_whlabelexcelzh一致,仅输出格式不同
  7321. public function _whlabelexcelzh()
  7322. {
  7323. //$colwidths:按表头顺序设置各列宽度(单位≈字符数);$wrapcols:需要自动换行的列下标(从0开始)
  7324. $excelxml = function ($info_list, $headers, $numkeys, $filename, $colwidths = array(), $wrapcols = array()) {
  7325. $str = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  7326. $str .= '<?mso-application progid="Excel.Sheet"?>' . "\n";
  7327. $str .= '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . "\n";
  7328. $str .= '<Styles>' . "\n";
  7329. $str .= '<Style ss:ID="wrap"><Alignment ss:Vertical="Center" ss:WrapText="1"/></Style>' . "\n";
  7330. $str .= '</Styles>' . "\n";
  7331. $str .= '<Worksheet ss:Name="Sheet1">' . "\n";
  7332. $str .= '<Table>' . "\n";
  7333. foreach ($colwidths as $w) {
  7334. $str .= '<Column ss:Width="' . $w . '"/>' . "\n";
  7335. }
  7336. $str .= '<Row>' . "\n";
  7337. foreach ($headers as $h) {
  7338. $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($h, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7339. }
  7340. $str .= '</Row>' . "\n";
  7341. foreach ($info_list as $row) {
  7342. $str .= '<Row>' . "\n";
  7343. $j = 0;
  7344. foreach ($row as $ke => $va) {
  7345. $va = (string)$va;
  7346. $va = str_replace('<br>', "\n", $va);
  7347. $wrapattr = in_array($j, $wrapcols) ? ' ss:StyleID="wrap"' : '';
  7348. if ($va === '') {
  7349. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String"></Data></Cell>' . "\n";
  7350. } else if (in_array($ke, $numkeys) && is_numeric($va)) {
  7351. $str .= '<Cell' . $wrapattr . '><Data ss:Type="Number">' . $va . '</Data></Cell>' . "\n";
  7352. } else {
  7353. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String">' . htmlspecialchars($va, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7354. }
  7355. $j++;
  7356. }
  7357. $str .= '</Row>' . "\n";
  7358. }
  7359. $str .= '</Table>' . "\n";
  7360. $str .= '</Worksheet>' . "\n";
  7361. $str .= '</Workbook>' . "\n";
  7362. while (ob_get_level()) {
  7363. ob_end_clean();
  7364. }
  7365. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  7366. header("Content-Disposition: attachment; filename=" . $filename);
  7367. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7368. header("Pragma: no-cache");
  7369. header("Expires: 0");
  7370. echo $str;
  7371. exit();
  7372. };
  7373. if (isset($_GET['excel'])) {
  7374. $where = "sku != 'Preset'";
  7375. //数据排序
  7376. $order_str = "id desc";
  7377. if (empty($page)) {
  7378. $start = 0;
  7379. $perpage = 1;
  7380. } else {
  7381. $start = ($page - 1) * $perpage;
  7382. }
  7383. $category = $this->input->get('category', true);
  7384. $warehouse = $this->input->get('warehouse', true);
  7385. $excelid = $this->input->get('sid', true);
  7386. if ($category) {
  7387. $where .= " and features like '%-$category-%'";
  7388. }
  7389. if ($warehouse) {
  7390. $where .= " and warehouse = '$warehouse'";
  7391. }
  7392. $xzid = '';
  7393. if ($excelid) {
  7394. $excelid = explode(',', trim($excelid, ','));
  7395. foreach ($excelid as $key => $value) {
  7396. $xzid .= " id = " . $value . " or";
  7397. }
  7398. $xzid = " and (" . rtrim($xzid, 'or') . ");";
  7399. }
  7400. $list = array();
  7401. $rows = $this->whlabel->find_pc($where, 'sku,title,features,warehouse', 'warehouse,sku,title,number,features');
  7402. foreach ($rows as $key => $value) {
  7403. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7404. $zh = '';
  7405. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7406. foreach ($zt as $v) {
  7407. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7408. }
  7409. $zt = array_sum(array_column($zt, 'num'));
  7410. $number = $value['number'];
  7411. $ftime = time() - 15 * 24 * 3600;
  7412. $warehouse = $this->warehouse->read($value['warehouse']);
  7413. //按表头顺序输出:仓库 | SKU | 产品 | 库存数量 | 在途数量及预达日期 | 在途+库存数量
  7414. $rows[$key] = array(
  7415. 'warehouse' => ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $value['warehouse'],
  7416. 'sku' => $value['sku'],
  7417. 'title' => isset($value['title']) ? $value['title'] : '',
  7418. 'number' => $c,
  7419. 'features' => $zh,
  7420. 'hb' => $c + $zt,
  7421. );
  7422. }
  7423. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7424. $filename = $title . ".xls";
  7425. $headers = array('仓库', 'SKU', '产品', '库存数量', '在途数量及预达日期', '在途+库存数量');
  7426. $numkeys = array('number', 'hb');
  7427. //列宽与表头一一对应(单位≈字符数);SKU(1)、产品(2)、在途列(4)超宽自动换行
  7428. $colwidths = array(80, 300,450, 50, 120, 80);
  7429. $wrapcols = array(1, 2, 4);
  7430. $excelxml($rows, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7431. }
  7432. if (isset($_GET['excel'])) {
  7433. $warehouse = $this->input->get('warehouse', true);
  7434. $sku = $this->input->get('sku', true);
  7435. $cz = $this->input->get('cz', true);
  7436. $text = $this->input->post('text', true);
  7437. $xztime = $this->input->get('xztime', true);
  7438. $timetk = $this->input->get('timetk', true);
  7439. $timetj = $this->input->get('timetj', true);
  7440. $timetk = strtotime($timetk);
  7441. $timetj = strtotime($timetj);
  7442. $where = "time = '0' ";
  7443. if ($warehouse) {
  7444. $where .= " and warehouse = '$warehouse'";
  7445. }
  7446. if ($sku) {
  7447. $where .= " and sku = '$sku'";
  7448. }
  7449. if ($text) {
  7450. $where .= " and text like '%$text%'";
  7451. }
  7452. if ($cz != '') {
  7453. $where .= " and cz = '$cz'";
  7454. }
  7455. if ($timetk && $timetj) {
  7456. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7457. }
  7458. //数据排序
  7459. $order_str = $xztime . " desc";
  7460. //取得信息列表
  7461. $zh = array();
  7462. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7463. foreach ($info_list as $v) {
  7464. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7465. $warehouse = $this->warehouse->read($v['warehouse']);
  7466. $v['warehouse'] = ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $v['warehouse'];
  7467. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7468. $v['stime'] = date('Y-m-d', $v['stime']);
  7469. if (isset($zh[$v['features']])) {
  7470. $zh[$v['features']]['num'] += $v['num'];
  7471. } else {
  7472. $zh[$v['features']] = $v;
  7473. }
  7474. $zh[$v['features']]['features'] = $c;
  7475. }
  7476. $title = "在途数据" . date('Y-m-d', time());
  7477. $filename = $title . ".xls";
  7478. $headers = array('仓库', 'SKU', '名称', '在途数量', '库存数量', '添加在途日期', '预达日期', '备注');
  7479. $numkeys = array('num', 'features');
  7480. //列宽与表头一一对应(单位≈字符数);SKU(1)、名称(2)、备注(7)超宽自动换行
  7481. $colwidths = array(18, 20, 50, 12, 12, 20, 12, 40);
  7482. $wrapcols = array(1, 2, 7);
  7483. $excelxml($zh, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7484. }
  7485. }
  7486. public function _fc()
  7487. {
  7488. $vip = 0;
  7489. if (isset($_SESSION['api'])) {
  7490. $user = $this->user->get_api($_SESSION['api']);
  7491. if ($user['vip'] == 1) {
  7492. $vip = 1;
  7493. }
  7494. } else {
  7495. header('Location: /');
  7496. exit;
  7497. }
  7498. $post = $this->input->post(NULL, TRUE);
  7499. if (isset($post['page'])) {
  7500. $page = $this->input->post('page', true);
  7501. $perpage = $this->input->post('perpage', true);
  7502. $category = $this->input->post('category', true);
  7503. $size = $this->input->post('size', true);
  7504. $grade = $this->input->post('grade', true);
  7505. $color = $this->input->post('color', true);
  7506. $lowe = $this->input->post('lowe', true);
  7507. $sku = $this->input->post('sku');
  7508. $title = $this->input->post('title');
  7509. $warehouse = $this->input->post('warehouse', true);
  7510. $usa = $this->input->post('usa', true);
  7511. $purchase = $this->input->post('purchase', true);
  7512. $lacetype = $this->input->post('lacetype', true);
  7513. $haircap = $this->input->post('haircap', true);
  7514. $density = $this->input->post('density', true);
  7515. $details = $this->input->post('details', true);
  7516. $state = $this->input->post('state', true);
  7517. $ktime = $this->input->post('ktime', true);
  7518. $jtime = $this->input->post('jtime', true);
  7519. $ktime = strtotime($ktime);
  7520. $jtime = strtotime($jtime);
  7521. $where = "state = '11'";
  7522. $gj = "";
  7523. $ck = "";
  7524. if ($lacetype) {
  7525. $where .= " and features like '%-$lacetype-%'";
  7526. }
  7527. if ($category) {
  7528. $where .= " and features like '%-$category-%'";
  7529. }
  7530. if ($size) {
  7531. $where .= " and features like '%-$size-%'";
  7532. }
  7533. if ($grade) {
  7534. $where .= " and features like '%-$grade-%'";
  7535. }
  7536. if ($color) {
  7537. $where .= " and features like '%-$color-%'";
  7538. }
  7539. if ($lowe) {
  7540. $where .= " and features like '%-$lowe-%'";
  7541. }
  7542. if ($haircap) {
  7543. $where .= " and features like '%-$haircap-%'";
  7544. }
  7545. if ($density) {
  7546. $where .= " and features like '%-$density-%'";
  7547. }
  7548. if ($usa) {
  7549. if (!$warehouse) {
  7550. $where .= " and (warehouse = '5' or warehouse = '8')";
  7551. }
  7552. }
  7553. if ($warehouse) {
  7554. $where .= " and warehouse = '$warehouse'";
  7555. }
  7556. if ($details) {
  7557. $where .= " and details = '$details'";
  7558. }
  7559. if ($purchase) {
  7560. $where .= " and purchase = '$purchase'";
  7561. }
  7562. if ($state) {
  7563. $where .= " and state = '$state'";
  7564. }
  7565. if ($ktime && $jtime) {
  7566. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7567. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7568. }
  7569. //数据排序
  7570. $order_str = "id desc";
  7571. if (empty($page)) {
  7572. $start = 0;
  7573. $perpage = 1;
  7574. } else {
  7575. $start = ($page - 1) * $perpage;
  7576. }
  7577. if ($sku) {
  7578. $sku = trim($sku, ' ');
  7579. $sku = trim($sku, ' ');
  7580. $where .= " and sku like '%$sku%'";
  7581. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7582. } else if ($title) {
  7583. $title = trim($title, ' ');
  7584. $title = trim($title, ' ');
  7585. $where .= " and title like '%$title%'";
  7586. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7587. } else {
  7588. //$where .= " and time > '$ktime' and time < '$jtime'";
  7589. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7590. }
  7591. //取得信息列表
  7592. $rows = array();
  7593. $list = array();
  7594. foreach ($info_list as $key => $value) {
  7595. $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'] . '"');
  7596. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7597. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7598. $warehouse = $this->warehouse->read($value['warehouse']);
  7599. $info_list[$key]['warehouse'] = $warehouse['title'];
  7600. $info_list[$key]['number'] = $g;
  7601. $info_list[$key]['features'] = $x;
  7602. $info_list[$key]['x'] = $s;
  7603. }
  7604. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7605. $pagenum = ceil($total / $perpage);
  7606. $over = $total - ($start + $perpage);
  7607. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7608. echo json_encode($rows);
  7609. exit;
  7610. }
  7611. $this->data['vip'] = $vip;
  7612. $this->_Template('whlabel_fc', $this->data);
  7613. }
  7614. public function _fcmb()
  7615. {
  7616. $where = "sku != 'Preset'";
  7617. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7618. foreach ($rows as $k => $v) {
  7619. $warehouse = $this->warehouse->read($v['warehouse']);
  7620. $rows[$k]['warehouse'] = $warehouse['title'];
  7621. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7622. $rows[$k]['t'] = '';
  7623. $rows[$k]['n'] = '';
  7624. }
  7625. $title = "封货产品数据导入模板";
  7626. $titlename = "<table border=1>
  7627. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7628. <tr align='center'>
  7629. <td>仓库</td>
  7630. <td>SKU</td>
  7631. <td>产品</td>
  7632. <td>封存产品总数量</td>
  7633. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7634. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7635. </tr>
  7636. </table>";
  7637. $filename = $title . ".xls";
  7638. $tail = "";
  7639. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7640. }
  7641. public function _fcexcel()
  7642. {
  7643. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7644. $config['upload_path'] = '.' . $dir;
  7645. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7646. $config['allowed_types'] = 'xls|xlsx|csv';
  7647. $config['max_size'] = 10240;
  7648. $this->load->library('upload', $config);
  7649. $this->upload->initialize($config);
  7650. if ($this->upload->do_upload('userfile')) {
  7651. $full_path = $dir . $this->upload->data('file_name');
  7652. $fileName = '.' . $full_path;
  7653. if (!file_exists($fileName)) {
  7654. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7655. exit;
  7656. } else {
  7657. libxml_use_internal_errors(true);
  7658. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7659. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7660. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7661. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7662. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7663. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7664. ++$column; //如果列数大于26行
  7665. $list = array();
  7666. for ($i = 2; $i <= $row; $i++) // 行数循环
  7667. {
  7668. $data = array();
  7669. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7670. {
  7671. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7672. }
  7673. $list[] = $data;
  7674. }
  7675. }
  7676. $i = 0;
  7677. $j = 0;
  7678. $ed = array();
  7679. foreach ($list as $key => $value) {
  7680. $time = time();
  7681. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7682. continue;
  7683. }
  7684. $warehouse = $this->warehouse->get_title($value['0']);
  7685. $sku = $value['1'];
  7686. $type = $value['4']; //调整方式0扣减1删除
  7687. $num = $value['5']; //调整数量
  7688. //$text = $value['4'];//扣减说明
  7689. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7690. if (!$d) //如果没有这个SKU
  7691. {
  7692. $ed[] = array($sku . '-库存中不存在此SKU');
  7693. $j++;
  7694. continue;
  7695. }
  7696. if (!isset($warehouse['id'])) {
  7697. $ed[] = array($sku . '-仓库名错误!');
  7698. $j++;
  7699. continue;
  7700. }
  7701. if ($type == 1 || $type == 2) //扣减库存
  7702. {
  7703. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7704. if (count($data) < abs($num)) {
  7705. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7706. $j++;
  7707. continue;
  7708. }
  7709. if ($type == 1) //转入库存
  7710. {
  7711. for ($i = 0; $i < abs($num); $i++) {
  7712. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7713. }
  7714. } else if ($type == 2) //删除
  7715. {
  7716. for ($i = 0; $i < abs($num); $i++) {
  7717. $this->whlabel->remove($data[$i]['id']);
  7718. }
  7719. }
  7720. } else if ($type == 0) //增加库存
  7721. {
  7722. $post['sku'] = $d['sku'];
  7723. $post['shop'] = '';
  7724. $post['warehouse'] = $warehouse['id'];
  7725. $post['purchase'] = $d['purchase'];
  7726. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7727. $post['state'] = 11;
  7728. $post['title'] = $d['title'];
  7729. $post['number'] = $d['number'];
  7730. $post['features'] = $d['features'];
  7731. $post['enter'] = $time;
  7732. $post['time'] = $time; //操作时间
  7733. for ($i = 0; $i < $num; $i++) {
  7734. $post['label'] = time() . rand(100, 999) . $i;
  7735. $this->whlabel->insert($post);
  7736. }
  7737. }
  7738. sleep(1); //防止入库时间一样,需要延迟1秒
  7739. }
  7740. if ($j > 0) {
  7741. $tt = date('Ymd', time());
  7742. $title = '库存导入错误信息-' . $tt;
  7743. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7744. $tail = "\n";
  7745. $filename = $title . ".xls";
  7746. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7747. $dir = '/data/excel/' . $time . '/';
  7748. $file_name = 'error_' . $time . rand(1000, 9999);
  7749. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7750. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7751. fwrite($myfile, $ecl);
  7752. fclose($myfile);
  7753. $error = $dir . $file_name . '.xls';
  7754. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7755. exit;
  7756. } else {
  7757. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7758. exit;
  7759. }
  7760. }
  7761. }
  7762. public function _fcjxc($arg_array)
  7763. {
  7764. if (isset($_GET['excel'])) {
  7765. $category = $this->input->get('category', true);
  7766. $size = $this->input->get('size', true);
  7767. $grade = $this->input->get('grade', true);
  7768. $color = $this->input->get('color', true);
  7769. $lowe = $this->input->get('lowe', true);
  7770. $sku = $this->input->get('sku');
  7771. $title = $this->input->get('title');
  7772. $warehouse = $arg_array[0];
  7773. $usa = $this->input->get('usa', true);
  7774. $purchase = $this->input->get('purchase', true);
  7775. $lacetype = $this->input->get('lacetype', true);
  7776. $haircap = $this->input->get('haircap', true);
  7777. $density = $this->input->get('density', true);
  7778. $title = $this->input->get('title', true);
  7779. $state = $this->input->get('state', true);
  7780. $ktime = $this->input->get('ktime', true);
  7781. $jtime = $this->input->get('jtime', true);
  7782. $where = "state=11";
  7783. $gj = "";
  7784. $ck = "";
  7785. if ($lacetype) {
  7786. $where .= " and features like '%-$lacetype-%'";
  7787. }
  7788. if ($category) {
  7789. $where .= " and features like '%-$category-%'";
  7790. }
  7791. if ($size) {
  7792. $where .= " and features like '%-$size-%'";
  7793. }
  7794. if ($grade) {
  7795. $where .= " and features like '%-$grade-%'";
  7796. }
  7797. if ($color) {
  7798. $where .= " and features like '%-$color-%'";
  7799. }
  7800. if ($lowe) {
  7801. $where .= " and features like '%-$lowe-%'";
  7802. }
  7803. if ($haircap) {
  7804. $where .= " and features like '%-$haircap-%'";
  7805. }
  7806. if ($density) {
  7807. $where .= " and features like '%-$density-%'";
  7808. }
  7809. if ($usa) {
  7810. if (!$warehouse) {
  7811. $where .= " and (warehouse = '5' or warehouse = '8')";
  7812. }
  7813. }
  7814. if ($warehouse) {
  7815. $where .= " and warehouse = '$warehouse'";
  7816. }
  7817. if ($purchase) {
  7818. $where .= " and purchase = '$purchase'";
  7819. }
  7820. if ($state) {
  7821. $where .= " and state = '$state'";
  7822. }
  7823. $order_str = "id desc";
  7824. if ($sku) {
  7825. $sku = trim($sku, ' ');
  7826. $sku = trim($sku, ' ');
  7827. $where .= " and sku like '%$sku%'";
  7828. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7829. } else if ($title) {
  7830. $title = trim($title, ' ');
  7831. $title = trim($title, ' ');
  7832. $where .= " and title like '%$title%'";
  7833. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7834. } else {
  7835. //$where .= " and time > '$ktime' and time < '$jtime'";
  7836. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7837. }
  7838. //取得信息列表
  7839. $rows = array();
  7840. $list = array();
  7841. foreach ($info_list as $key => $value) {
  7842. $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'] . '"');
  7843. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7844. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7845. $rows[$key] = $value;
  7846. $warehouse = $this->warehouse->read($value['warehouse']);
  7847. $rows[$key]['warehouse'] = $warehouse['title'];
  7848. $rows[$key]['features'] = $g;
  7849. $rows[$key]['a'] = $x;
  7850. $rows[$key]['b'] = $s;
  7851. }
  7852. $title = "总统计表";
  7853. $titlename = "<table border=1>
  7854. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7855. <tr align='center'>
  7856. <td>仓库</td>
  7857. <td>SKU</td>
  7858. <td>产品名称</td>
  7859. <td>录入总量</td>
  7860. <td>取出总量</td>
  7861. <td>剩余总量</td>
  7862. </tr>
  7863. </table>";
  7864. $filename = $title . ".xls";
  7865. $tail = "";
  7866. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7867. }
  7868. $vip = 0;
  7869. if (isset($_SESSION['api'])) {
  7870. $user = $this->user->get_api($_SESSION['api']);
  7871. if ($user['vip'] == 1) {
  7872. $vip = 1;
  7873. }
  7874. } else {
  7875. header('Location: /');
  7876. exit;
  7877. }
  7878. $post = $this->input->post(NULL, TRUE);
  7879. if (isset($post['page'])) {
  7880. $page = $this->input->post('page', true);
  7881. $perpage = $this->input->post('perpage', true);
  7882. $category = $this->input->post('category', true);
  7883. $size = $this->input->post('size', true);
  7884. $grade = $this->input->post('grade', true);
  7885. $color = $this->input->post('color', true);
  7886. $lowe = $this->input->post('lowe', true);
  7887. $sku = $this->input->post('sku');
  7888. $title = $this->input->post('title');
  7889. $warehouse = $arg_array[0];
  7890. $usa = $this->input->post('usa', true);
  7891. $purchase = $this->input->post('purchase', true);
  7892. $lacetype = $this->input->post('lacetype', true);
  7893. $haircap = $this->input->post('haircap', true);
  7894. $density = $this->input->post('density', true);
  7895. $title = $this->input->post('title', true);
  7896. $state = $this->input->post('state', true);
  7897. $ktime = $this->input->post('ktime', true);
  7898. $jtime = $this->input->post('jtime', true);
  7899. $ktime = strtotime($ktime);
  7900. $jtime = strtotime($jtime);
  7901. $where = "state=11";
  7902. $gj = "";
  7903. $ck = "";
  7904. if ($lacetype) {
  7905. $where .= " and features like '%-$lacetype-%'";
  7906. }
  7907. if ($category) {
  7908. $where .= " and features like '%-$category-%'";
  7909. }
  7910. if ($size) {
  7911. $where .= " and features like '%-$size-%'";
  7912. }
  7913. if ($grade) {
  7914. $where .= " and features like '%-$grade-%'";
  7915. }
  7916. if ($color) {
  7917. $where .= " and features like '%-$color-%'";
  7918. }
  7919. if ($lowe) {
  7920. $where .= " and features like '%-$lowe-%'";
  7921. }
  7922. if ($haircap) {
  7923. $where .= " and features like '%-$haircap-%'";
  7924. }
  7925. if ($density) {
  7926. $where .= " and features like '%-$density-%'";
  7927. }
  7928. if ($usa) {
  7929. if (!$warehouse) {
  7930. $where .= " and (warehouse = '5' or warehouse = '8')";
  7931. }
  7932. }
  7933. if ($warehouse) {
  7934. $where .= " and warehouse = '$warehouse'";
  7935. }
  7936. if ($purchase) {
  7937. $where .= " and purchase = '$purchase'";
  7938. }
  7939. if ($state) {
  7940. $where .= " and state = '$state'";
  7941. }
  7942. if ($ktime && $jtime) {
  7943. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7944. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7945. }
  7946. //数据排序
  7947. $order_str = "id desc";
  7948. $xs = 0;
  7949. $rows = array();
  7950. $list = array();
  7951. if (empty($page)) {
  7952. $start = 0;
  7953. $perpage = 1;
  7954. } else {
  7955. $start = ($page - 1) * $perpage;
  7956. }
  7957. if ($sku || $title) {
  7958. if ($title) {
  7959. $title = trim($title, ' ');
  7960. $title = trim($title, ' ');
  7961. $where .= " and title like '%$title%'";
  7962. } else {
  7963. $sku = trim($sku, ' ');
  7964. $sku = trim($sku, ' ');
  7965. $where .= " and sku like '%$sku%'";
  7966. }
  7967. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7968. foreach ($info_list as $key => $value) {
  7969. $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'] . '"');
  7970. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7971. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7972. $rows[$key] = $value;
  7973. $warehouse = $this->warehouse->read($value['warehouse']);
  7974. $rows[$key]['warehouse'] = $warehouse['title'];
  7975. $rows[$key]['features'] = $g;
  7976. $rows[$key]['a'] = $x;
  7977. $rows[$key]['b'] = $s;
  7978. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7979. $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天销量
  7980. $yj = $c / ($xl / 30);
  7981. if ($yj < 7) {
  7982. $rows[$key]['y'] = round($yj) . '天销量';
  7983. } else {
  7984. $rows[$key]['y'] = '正常';
  7985. }
  7986. }
  7987. } else {
  7988. //$where .= " and time > '$ktime' and time < '$jtime'";
  7989. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7990. foreach ($info_list as $key => $value) {
  7991. $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'] . '"');
  7992. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7993. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7994. $zs[$key] = $value;
  7995. $warehouse = $this->warehouse->read($value['warehouse']);
  7996. $zs[$key]['warehouse'] = $warehouse['title'];
  7997. $zs[$key]['features'] = $g;
  7998. $zs[$key]['a'] = $x;
  7999. $zs[$key]['b'] = $s;
  8000. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  8001. $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天销量
  8002. $yj = $c / ($xl / 30);
  8003. if ($yj < 7) {
  8004. $zs[$key]['y'] = round($yj) . '天销量';
  8005. $rows[$key] = $zs[$key];
  8006. }
  8007. }
  8008. }
  8009. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  8010. $pagenum = ceil($total / $perpage);
  8011. $over = $total - ($start + $perpage);
  8012. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  8013. echo json_encode($rows);
  8014. exit;
  8015. }
  8016. $this->data['arg_array'] = $arg_array[0];
  8017. $this->_Template('whlabel_fcjxc', $this->data);
  8018. }
  8019. public function _0kcdel()
  8020. {
  8021. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  8022. $config['upload_path'] = '.' . $dir;
  8023. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  8024. $config['allowed_types'] = 'xls|xlsx|csv';
  8025. $config['max_size'] = 10240;
  8026. $this->load->library('upload', $config);
  8027. $this->upload->initialize($config);
  8028. if ($this->upload->do_upload('userfile')) {
  8029. $full_path = $dir . $this->upload->data('file_name');
  8030. $fileName = '.' . $full_path;
  8031. if (!file_exists($fileName)) {
  8032. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  8033. exit;
  8034. } else {
  8035. require_once "./data/excel/PHPExcel/IOFactory.php";
  8036. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  8037. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  8038. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  8039. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  8040. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  8041. ++$column; //如果列数大于26行
  8042. $list = array();
  8043. for ($i = 2; $i <= $row; $i++) // 行数循环
  8044. {
  8045. $data = array();
  8046. for ($c = 'A'; $c != $column; $c++) // 列数循环
  8047. {
  8048. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  8049. }
  8050. $list[] = $data;
  8051. }
  8052. }
  8053. $i = 0;
  8054. $j = 0;
  8055. $ed = array();
  8056. foreach ($list as $key => $value) {
  8057. $time = time();
  8058. if ($value['0'] == "" || $value['1'] == "") {
  8059. continue;
  8060. }
  8061. $warehouse = $this->warehouse->get_title($value['0']);
  8062. $sku = $value['1'];
  8063. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  8064. if (!$d) //如果没有这个SKU
  8065. {
  8066. $ed[] = array($sku . '-库存中不存在此SKU');
  8067. $j++;
  8068. continue;
  8069. }
  8070. if (!isset($warehouse['id'])) {
  8071. $ed[] = array($sku . '-仓库名错误!');
  8072. $j++;
  8073. continue;
  8074. }
  8075. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  8076. if ($z < 1) {
  8077. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  8078. foreach ($z as $v) {
  8079. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  8080. if (count($zt) > 0) {
  8081. $ed[] = array($sku . '-有在途库存无法删除!');
  8082. $j++;
  8083. continue;
  8084. }
  8085. $tmp_info = $v;
  8086. $tmp_info['del_time'] = time();
  8087. $this->db->insert('whlabelscbf',$tmp_info);
  8088. $this->whlabel->remove($v['id']);
  8089. }
  8090. } else {
  8091. $ed[] = array($sku . '-非0库存!');
  8092. $j++;
  8093. continue;
  8094. }
  8095. }
  8096. if ($j > 0) {
  8097. $tt = date('Ymd', time());
  8098. $title = '删除0库存错误信息-' . $tt;
  8099. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  8100. $tail = "\n";
  8101. $filename = $title . ".xls";
  8102. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  8103. $dir = '/data/excel/' . $time . '/';
  8104. $file_name = 'error_' . $time . rand(1000, 9999);
  8105. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  8106. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  8107. fwrite($myfile, $ecl);
  8108. fclose($myfile);
  8109. $error = $dir . $file_name . '.xls';
  8110. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  8111. exit;
  8112. } else {
  8113. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  8114. exit;
  8115. }
  8116. }
  8117. }
  8118. public function _gbhtype()
  8119. {
  8120. $post = $this->input->post(NULL, TRUE);
  8121. if (isset($post['s'])) {
  8122. $n = $this->input->post('n');
  8123. $d = $this->input->post('s');
  8124. if (!$d) {
  8125. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  8126. exit;
  8127. }
  8128. $d = explode(',', trim($d, ','));
  8129. $t = $this->whlabel_type->read($n);
  8130. //循环删除记录
  8131. foreach ($d as $v) {
  8132. $u = $this->whlabel->read($v);
  8133. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  8134. foreach ($data as $val) {
  8135. $this->whlabel->save(array('type' => $n), $val['id']);
  8136. }
  8137. }
  8138. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  8139. }
  8140. }
  8141. //出库、退库导出
  8142. public function _dccrtype()
  8143. {
  8144. $classid = $this->classid->sku();
  8145. $pm = $classid;
  8146. $typeclass = array();
  8147. $tc = $this->typeclass->find_all();
  8148. foreach ($tc as $v) {
  8149. $typeclass[$v['id']] = $v;
  8150. }
  8151. $prc = array();
  8152. $purchase = $this->purchase->find_all();
  8153. foreach ($purchase as $k => $v) {
  8154. $prc[$v['id']] = $v['title'];
  8155. }
  8156. if (isset($_GET['sid'])) {
  8157. $wh = array();
  8158. $w = $this->warehouse->find_all('1=1', 'id,title');
  8159. foreach ($w as $v) {
  8160. $wh[$v['id']] = $v['title'];
  8161. }
  8162. $type = $this->input->get('excel', true);
  8163. $category = $this->input->get('category', true);
  8164. $size = $this->input->get('size', true);
  8165. $grade = $this->input->get('grade', true);
  8166. $color = $this->input->get('color', true);
  8167. $lowe = $this->input->get('lowe', true);
  8168. $sku = $this->input->get('sku', true);
  8169. $warehouse = $this->input->get('warehouse', true);
  8170. $lacetype = $this->input->get('lacetype', true);
  8171. $lacecolor = $this->input->get('lacecolor', true);
  8172. $density = $this->input->get('density', true);
  8173. $haircap = $this->input->get('haircap', true);
  8174. $purchase = $this->input->get('purchase', true);
  8175. $title = $this->input->get('title', true);
  8176. $state = $this->input->get('state', true);
  8177. $sid = $this->input->get('sid', true);
  8178. $ktime = $this->input->get('ktime', true);
  8179. $jtime = $this->input->get('jtime', true);
  8180. $ktime = strtotime($ktime);
  8181. $jtime = strtotime($jtime);
  8182. $where = "1=1";
  8183. $gj = "";
  8184. $ck = "";
  8185. if ($category) {
  8186. $where .= " and features like '%-$category-%'";
  8187. }
  8188. if ($size) {
  8189. $where .= " and features like '%-$size-%'";
  8190. }
  8191. if ($grade) {
  8192. $where .= " and features like '%-$grade-%'";
  8193. }
  8194. if ($color) {
  8195. $where .= " and features like '%-$color-%'";
  8196. }
  8197. if ($lowe) {
  8198. $where .= " and features like '%-$lowe-%'";
  8199. }
  8200. if ($warehouse) {
  8201. $where .= " and warehouse = '$warehouse'";
  8202. }
  8203. if ($purchase) {
  8204. $where .= " and purchase = '$purchase'";
  8205. }
  8206. if ($state) {
  8207. $where .= " and state = '$state'";
  8208. }
  8209. if ($lacetype) {
  8210. $where .= " and features like '%-$lacetype-%'";
  8211. }
  8212. if ($lacecolor) {
  8213. $where .= " and features like '%-$lacecolor-%'";
  8214. }
  8215. if ($density) {
  8216. $where .= " and features like '%-$density-%'";
  8217. }
  8218. if ($haircap) {
  8219. $where .= " and features like '%-$haircap-%'";
  8220. }
  8221. if ($title) {
  8222. $title = trim($title, ' ');
  8223. $title = trim($title, ' ');
  8224. $where .= " and title like '%$title%'";
  8225. }
  8226. if ($sku) {
  8227. $sku = trim($sku, ' ');
  8228. $sku = trim($sku, ' ');
  8229. $where .= " and sku like '%$sku%'";
  8230. }
  8231. if ($ktime && $jtime) {
  8232. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8233. }
  8234. $sidwhere = '';
  8235. if ($sid) {
  8236. $sd = "";
  8237. $s = explode(',', trim($sid, ','));
  8238. foreach ($s as $value) {
  8239. $sd .= " id = " . $value . " or";
  8240. }
  8241. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8242. }
  8243. //数据排序
  8244. $order_str = "time desc";
  8245. if (empty($page)) {
  8246. $start = 0;
  8247. $perpage = 1;
  8248. } else {
  8249. $start = ($page - 1) * $perpage;
  8250. }
  8251. $wh = array();
  8252. $w = $this->warehouse->find_all('1=1', 'id,title');
  8253. foreach ($w as $v) {
  8254. $wh[$v['id']] = $v['title'];
  8255. }
  8256. $wt = array();
  8257. $whlabel_type = $this->whlabel_type->find_all();
  8258. foreach ($whlabel_type as $v) {
  8259. $wt[$v['id']] = $v['title'];
  8260. }
  8261. $classid = $this->classid->sku();
  8262. $list = array();
  8263. $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');
  8264. foreach ($rows_r as $key => $value) {
  8265. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8266. $pm = $classid;
  8267. $jm = $classid;
  8268. $rows_r[$key]['enter'] = '入库';
  8269. $rows_r[$key]['time'] = $value['enter'];
  8270. if ($value['rktype'] == 1) {
  8271. $rows_r[$key]['rktype'] = '采购入库';
  8272. } else if ($value['rktype'] == 2) {
  8273. $rows_r[$key]['rktype'] = '盘盈调整';
  8274. } else if ($value['rktype'] == 3) {
  8275. $rows_r[$key]['rktype'] = '其他调整入库';
  8276. } else if ($value['rktype'] == 4) {
  8277. $rows_r[$key]['rktype'] = '其他调整入库';
  8278. } else if ($value['rktype'] == 5) {
  8279. $rows_r[$key]['rktype'] = '退库入库';
  8280. } else if ($value['rktype'] == 6) {
  8281. $rows_r[$key]['rktype'] = '退货可用入库';
  8282. } else if ($value['rktype'] == 7) {
  8283. $rows_r[$key]['rktype'] = '形态转换入库';
  8284. } else {
  8285. $rows_r[$key]['rktype'] = '';
  8286. }
  8287. $features = explode('-', trim($value['features'], '-'));
  8288. foreach ($features as $v) {
  8289. if (isset($typeclass[$v])) {
  8290. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8291. $pm[$typeclass[$v]['classid']] = $zh[0];
  8292. }
  8293. if (isset($typeclass[$v])) {
  8294. if (isset($jm[$typeclass[$v]['classid']])) {
  8295. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8296. }
  8297. }
  8298. }
  8299. $zh = implode(" ", $pm);
  8300. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8301. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8302. $rows_r[$key]['zh'] = $zh;
  8303. $jm = array_filter($jm);
  8304. $rows_r[$key]['features'] = implode("-", $jm);
  8305. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8306. }
  8307. $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');
  8308. foreach ($rows_c as $key => $value) {
  8309. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8310. $pm = $classid;
  8311. $jm = $classid;
  8312. $rows_c[$key]['time'] = $value['outk'];
  8313. $rows_c[$key]['outk'] = '出库';
  8314. if ($value['cktype'] == 1) {
  8315. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8316. } else if ($value['cktype'] == 2) {
  8317. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8318. } else if ($value['cktype'] == 3) {
  8319. $rows_c[$key]['cktype'] = '盘亏调整';
  8320. } else if ($value['cktype'] == 4) {
  8321. $rows_c[$key]['cktype'] = '其他调整出库';
  8322. } else if ($value['cktype'] == 5) {
  8323. $rows_c[$key]['cktype'] = '形态转换出库';
  8324. } else {
  8325. $rows_c[$key]['cktype'] = '';
  8326. }
  8327. unset($rows_c[$key]['state']);
  8328. $features = explode('-', trim($value['features'], '-'));
  8329. foreach ($features as $v) {
  8330. if (isset($typeclass[$v])) {
  8331. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8332. $pm[$typeclass[$v]['classid']] = $zh[0];
  8333. }
  8334. if (isset($typeclass[$v])) {
  8335. if (isset($jm[$typeclass[$v]['classid']])) {
  8336. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8337. }
  8338. }
  8339. }
  8340. $zh = implode(" ", $pm);
  8341. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8342. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8343. $rows_c[$key]['zh'] = $zh;
  8344. $jm = array_filter($jm);
  8345. $rows_c[$key]['features'] = implode("-", $jm);
  8346. $rows_c[$key]['number'] = 1;
  8347. }
  8348. $merged = $rows_r;
  8349. foreach ($rows_c as $key => $value) {
  8350. if (isset($merged[$key])) {
  8351. $merged[] = $value;
  8352. } else {
  8353. $merged[$key] = $value;
  8354. }
  8355. }
  8356. usort($merged, function ($a, $b) {
  8357. return $a['time'] - $b['time'];
  8358. });
  8359. foreach ($merged as $key => $value) {
  8360. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8361. }
  8362. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8363. $titlename = "<table border=1>
  8364. <tr align='center'>
  8365. <td>仓库</td>
  8366. <td>SKU</td>
  8367. <td>商品名称</td>
  8368. <td>仓库品名</td>
  8369. <td>料号</td>
  8370. <td>时间</td>
  8371. <td>操作</td>
  8372. <td>类型</td>
  8373. <td>数量</td>
  8374. <td>备注</td>
  8375. </tr>
  8376. </table>";
  8377. $filename = $title . ".xlsx";
  8378. $tail = "";
  8379. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8380. }
  8381. }
  8382. /*************************************处理exceljs导出****************************************************/
  8383. public function _excelrjs(){
  8384. if (isset($_GET['excel'])) {
  8385. $category = $this->input->get('category', true);
  8386. $size = $this->input->get('size', true);
  8387. $grade = $this->input->get('grade', true);
  8388. $color = $this->input->get('color', true);
  8389. $lowe = $this->input->get('lowe', true);
  8390. $sku = $this->input->get('sku', true);
  8391. $warehouse = $this->input->get('warehouse', true);
  8392. $purchase = $this->input->get('purchase', true);
  8393. $ktime = $this->input->get('ktime', true);
  8394. $jtime = $this->input->get('jtime', true);
  8395. $ktime = strtotime($ktime);
  8396. $jtime = strtotime($jtime);
  8397. $where = "1=1";
  8398. $gj = "";
  8399. $ck = "";
  8400. if ($category) {
  8401. $where .= " and features like '%-$category-%'";
  8402. }
  8403. if ($size) {
  8404. $where .= " and features like '%-$size-%'";
  8405. }
  8406. if ($grade) {
  8407. $where .= " and features like '%-$grade-%'";
  8408. }
  8409. if ($color) {
  8410. $where .= " and features like '%-$color-%'";
  8411. }
  8412. if ($lowe) {
  8413. $where .= " and features like '%-$lowe-%'";
  8414. }
  8415. if ($warehouse) {
  8416. $where .= " and warehouse = '$warehouse'";
  8417. }
  8418. if ($purchase) {
  8419. $where .= " and purchase = '$purchase'";
  8420. }
  8421. if ($sku) {
  8422. $where .= " and sku = '$sku'";
  8423. }
  8424. if ($ktime && $jtime) {
  8425. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8426. }
  8427. //数据排序
  8428. $order_str = "id desc";
  8429. if (empty($page)) {
  8430. $start = 0;
  8431. $perpage = 1;
  8432. } else {
  8433. $start = ($page - 1) * $perpage;
  8434. }
  8435. $list = array();
  8436. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8437. foreach ($rows as $value) {
  8438. $ck = $this->warehouse->read($value['warehouse']);
  8439. $warehouse = $ck['title'];
  8440. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8441. $retreatwarehouse = $tkck['title'];
  8442. $gy = $this->purchase->read($value['purchase']);
  8443. $purchase = $gy['title'];
  8444. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8445. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8446. }
  8447. if(empty($list)){
  8448. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8449. }else{
  8450. $final_list = [];
  8451. foreach($list as $v){
  8452. $final_list[] = array_values($v);
  8453. }
  8454. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8455. array_unshift($final_list,[
  8456. "仓库","SKU","商品名称","时间","数量"
  8457. ]);
  8458. array_unshift($final_list,[
  8459. $title,"","","",""
  8460. ]);
  8461. $merges = [
  8462. [
  8463. "s"=>["r"=>0,"c"=>0],
  8464. "e"=>["r"=>0,"c"=>4]
  8465. ]
  8466. ];
  8467. $cols = [
  8468. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8469. ];
  8470. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8471. }
  8472. }
  8473. }
  8474. //出库、退库导出
  8475. public function _excelctjs()
  8476. {
  8477. $classid = $this->classid->sku();
  8478. $pm = $classid;
  8479. $typeclass = array();
  8480. $tc = $this->typeclass->find_all();
  8481. foreach ($tc as $v) {
  8482. $typeclass[$v['id']] = $v;
  8483. }
  8484. $prc = array();
  8485. $purchase = $this->purchase->find_all();
  8486. foreach ($purchase as $k => $v) {
  8487. $prc[$v['id']] = $v['title'];
  8488. }
  8489. if (isset($_GET['excel'])) {
  8490. $wh = array();
  8491. $w = $this->warehouse->find_all('1=1', 'id,title');
  8492. foreach ($w as $v) {
  8493. $wh[$v['id']] = $v['title'];
  8494. }
  8495. $type = $this->input->get('excel', true);
  8496. $category = $this->input->get('category', true);
  8497. $size = $this->input->get('size', true);
  8498. $grade = $this->input->get('grade', true);
  8499. $color = $this->input->get('color', true);
  8500. $lowe = $this->input->get('lowe', true);
  8501. $sku = $this->input->get('sku', true);
  8502. $title = $this->input->get('title', true);
  8503. $warehouse = $this->input->get('warehouse', true);
  8504. $purchase = $this->input->get('purchase', true);
  8505. $lacetype = $this->input->get('lacetype', true);
  8506. $haircap = $this->input->get('haircap', true);
  8507. $lacecolor = $this->input->get('lacecolor', true);
  8508. $density = $this->input->get('density', true);
  8509. $details = $this->input->get('details', true);
  8510. $state = $this->input->get('state', true);
  8511. $shop = $this->input->get('shop', true);
  8512. $hairnumber = $this->input->get('hairnumber', true);
  8513. $type_leixi = $this->input->get('type', true);
  8514. $cpbz = $this->input->get('cpbz', true);
  8515. $sm = $this->input->get('sm', true);
  8516. $sid = $this->input->get('sid', true);
  8517. $ktime = $this->input->get('ktime', true);
  8518. $jtime = $this->input->get('jtime', true);
  8519. $ktime = strtotime($ktime);
  8520. $jtime = strtotime($jtime);
  8521. //$where = " 1=1 ";
  8522. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8523. $where = " sku != '' ";
  8524. $gj = "";
  8525. $ck = "";
  8526. if ($category) {
  8527. $where .= " and features like '%-$category-%'";
  8528. }
  8529. if ($size) {
  8530. $where .= " and features like '%-$size-%'";
  8531. }
  8532. if ($grade) {
  8533. $where .= " and features like '%-$grade-%'";
  8534. }
  8535. if ($color) {
  8536. $where .= " and features like '%-$color-%'";
  8537. }
  8538. if ($lowe) {
  8539. $where .= " and features like '%-$lowe-%'";
  8540. }
  8541. if ($warehouse) {
  8542. $where .= " and warehouse = '$warehouse'";
  8543. }
  8544. if ($purchase) {
  8545. $where .= " and purchase = '$purchase'";
  8546. }
  8547. if ($state) {
  8548. $where .= " and state = '$state'";
  8549. }
  8550. if ($lacetype) {
  8551. $where .= " and features like '%-$lacetype-%'";
  8552. }
  8553. if ($lacecolor) {
  8554. $where .= " and features like '%-$lacecolor-%'";
  8555. }
  8556. if ($density) {
  8557. $where .= " and features like '%-$density-%'";
  8558. }
  8559. if ($haircap) {
  8560. $where .= " and features like '%-$haircap-%'";
  8561. }
  8562. if ($details) {
  8563. $where .= " and details = '$details'";
  8564. }
  8565. if ($shop) {
  8566. $where .= " and shop like '%$shop%'";
  8567. }
  8568. if ($title) {
  8569. $title = trim($title, ' ');
  8570. $title = trim($title, ' ');
  8571. $where .= " and title like '%$title%'";
  8572. }
  8573. if (!empty($hairnumber)) {
  8574. $where .= " and features like '%-128-%' ";
  8575. if ($hairnumber < 0) {
  8576. $class_list = $this->typeclass->find_all('classid = 43');
  8577. foreach ($class_list as $v) {
  8578. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8579. }
  8580. } else {
  8581. $where .= " and features like '%-$hairnumber-%'";
  8582. }
  8583. }
  8584. if ($type_leixi) {
  8585. $where .= " and type = '$type_leixi'";
  8586. }
  8587. if ($cpbz) {
  8588. $where .= " and cpbz like '%$cpbz%' ";
  8589. }
  8590. if ($sm) {
  8591. $where .= " and sm like '%$sm%' ";
  8592. }
  8593. if ($sku) {
  8594. $sku = trim($sku, ' ');
  8595. $sku = trim($sku, ' ');
  8596. $where .= " and sku like '%$sku%'";
  8597. }
  8598. if ($ktime && $jtime) {
  8599. if ($type == 1) {
  8600. $tl = '出库';
  8601. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8602. } else if ($type == 2) {
  8603. $tl = '退库';
  8604. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8605. } else if ($type == 3) {
  8606. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8607. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8608. } else if ($type == 4) {
  8609. $tl = '出库+零售';
  8610. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8611. } else if ($type == 5) {
  8612. $tl = '零售';
  8613. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8614. }
  8615. }
  8616. $sidwhere = '';
  8617. if ($sid) {
  8618. $sd = "";
  8619. $s = explode(',', trim($sid, ','));
  8620. foreach ($s as $value) {
  8621. $sd .= " id = " . $value . " or";
  8622. }
  8623. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8624. }
  8625. //数据排序
  8626. $order_str = "time desc";
  8627. if (empty($page)) {
  8628. $start = 0;
  8629. $perpage = 1;
  8630. } else {
  8631. $start = ($page - 1) * $perpage;
  8632. }
  8633. //取得信息列表
  8634. if ($type != 3 && $type != 5) {
  8635. if ($type == 1 || $type == 4) {
  8636. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8637. foreach ($info_list as $key => $value) {
  8638. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8639. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8640. $warehouse = $this->warehouse->read($value['warehouse']);
  8641. $info_list[$key]['warehouse'] = $warehouse['title'];
  8642. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8643. $features = explode('-', trim($features, '-'));
  8644. $pm = $classid;
  8645. foreach ($features as $k => $v) {
  8646. if ($v != 0) {
  8647. if (!isset($typeclass[$v])) {
  8648. continue;
  8649. }
  8650. if (isset($pm[$typeclass[$v]['classid']])) {
  8651. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8652. $tz = explode('|', $typeclass[$v]['zh']);
  8653. $pm[$typeclass[$v]['classid']] = $tz[0];
  8654. } else {
  8655. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8656. }
  8657. }
  8658. }
  8659. }
  8660. $zh = implode(" ", $pm);
  8661. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8662. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8663. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8664. $info_list[$key]['features'] = $zh;
  8665. }
  8666. $final_list = [];
  8667. foreach($info_list as $k=>$v){
  8668. $number = "";
  8669. if(!empty($v['orderinfo'])){
  8670. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8671. if(!empty($tmp_info['number'])){
  8672. $number = $tmp_info['number'];
  8673. }
  8674. }
  8675. $final_list[] = [
  8676. 'warehouse'=>$v['warehouse'],
  8677. 'purchase'=>$v['purchase'],
  8678. 'sku'=>$v['sku'],
  8679. 'title'=>$v['title'],
  8680. 'features'=>$v['features'],
  8681. 'label'=>$v['label'],
  8682. 'orderinfo'=>$v['orderinfo'],
  8683. 'number'=>$number,
  8684. 'waybill'=>$v['waybill'],
  8685. 'outk'=>$v['outk'],
  8686. ];
  8687. }
  8688. } else {
  8689. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8690. foreach ($info_list as $key => $value) {
  8691. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8692. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8693. $warehouse = $this->warehouse->read($value['warehouse']);
  8694. $info_list[$key]['warehouse'] = $warehouse['title'];
  8695. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8696. $features = explode('-', trim($features, '-'));
  8697. $pm = $classid;
  8698. foreach ($features as $k => $v) {
  8699. if ($v != 0) {
  8700. if (!isset($typeclass[$v])) {
  8701. continue;
  8702. }
  8703. if (isset($pm[$typeclass[$v]['classid']])) {
  8704. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8705. $tz = explode('|', $typeclass[$v]['zh']);
  8706. $pm[$typeclass[$v]['classid']] = $tz[0];
  8707. } else {
  8708. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8709. }
  8710. }
  8711. }
  8712. }
  8713. $zh = implode(" ", $pm);
  8714. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8715. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8716. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8717. $info_list[$key]['features'] = $zh;
  8718. }
  8719. $final_list = [];
  8720. foreach($info_list as $k=>$v){
  8721. $number = "";
  8722. if(!empty($v['orderinfo'])){
  8723. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8724. if(!empty($tmp_info['number'])){
  8725. $number = $tmp_info['number'];
  8726. }
  8727. }
  8728. $final_list[] = [
  8729. 'warehouse'=>$v['warehouse'],
  8730. 'purchase'=>$v['purchase'],
  8731. 'sku'=>$v['sku'],
  8732. 'title'=>$v['title'],
  8733. 'features'=>$v['features'],
  8734. 'label'=>$v['label'],
  8735. 'orderinfo'=>$v['orderinfo'],
  8736. 'number'=>$number,
  8737. 'waybill'=>$v['waybill'],
  8738. 'retreat'=>$v['retreat'],
  8739. ];
  8740. }
  8741. }
  8742. if(empty($final_list)){
  8743. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8744. }else{
  8745. $end_list = [];
  8746. foreach($final_list as $v){
  8747. $end_list[] = array_values($v);
  8748. }
  8749. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8750. array_unshift($end_list,[
  8751. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8752. ]);
  8753. array_unshift($end_list,[
  8754. $title,"","","","","","","","",""
  8755. ]);
  8756. $merges = [
  8757. [
  8758. "s"=>["r"=>0,"c"=>0],
  8759. "e"=>["r"=>0,"c"=>9]
  8760. ]
  8761. ];
  8762. $cols = [
  8763. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8764. ];
  8765. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8766. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8767. ] )));
  8768. }
  8769. } else if ($type == 5) {
  8770. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8771. foreach ($info_list as $key => $value) {
  8772. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8773. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8774. $warehouse = $this->warehouse->read($value['warehouse']);
  8775. $info_list[$key]['warehouse'] = $warehouse['title'];
  8776. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8777. $features = explode('-', trim($features, '-'));
  8778. $pm = $classid;
  8779. foreach ($features as $k => $v) {
  8780. if ($v != 0) {
  8781. if (!isset($typeclass[$v])) {
  8782. continue;
  8783. }
  8784. if (isset($pm[$typeclass[$v]['classid']])) {
  8785. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8786. $tz = explode('|', $typeclass[$v]['zh']);
  8787. $pm[$typeclass[$v]['classid']] = $tz[0];
  8788. } else {
  8789. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8790. }
  8791. }
  8792. }
  8793. }
  8794. $zh = implode(" ", $pm);
  8795. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8796. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8797. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8798. $info_list[$key]['features'] = $zh;
  8799. }
  8800. if(empty($info_list)){
  8801. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8802. }else{
  8803. $final_list = [];
  8804. foreach($info_list as $v){
  8805. $final_list[] = array_values($v);
  8806. }
  8807. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8808. array_unshift($final_list,[
  8809. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8810. ]);
  8811. array_unshift($final_list,[
  8812. $title,"","","","","","",
  8813. ]);
  8814. $merges = [
  8815. [
  8816. "s"=>["r"=>0,"c"=>0],
  8817. "e"=>["r"=>0,"c"=>6]
  8818. ]
  8819. ];
  8820. $cols = [
  8821. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8822. ];
  8823. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8824. }
  8825. } else {
  8826. $wh = array();
  8827. $w = $this->warehouse->find_all('1=1', 'id,title');
  8828. foreach ($w as $v) {
  8829. $wh[$v['id']] = $v['title'];
  8830. }
  8831. $wt = array();
  8832. $whlabel_type = $this->whlabel_type->find_all();
  8833. foreach ($whlabel_type as $v) {
  8834. $wt[$v['id']] = $v['title'];
  8835. }
  8836. $classid = $this->classid->sku();
  8837. $list = array();
  8838. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8839. foreach ($rows as $key => $value) {
  8840. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8841. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8842. $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');
  8843. $details = array();
  8844. $cpid = array();
  8845. $cpbz = array();
  8846. $c = 0;
  8847. $g = 0;
  8848. $x = 0;
  8849. $t = 0;
  8850. $s = 0;
  8851. $q = 0;
  8852. foreach ($sd as $k => $v) {
  8853. if ($v['state'] == 0) {
  8854. $c++;
  8855. }
  8856. if ($v['state'] != 9) {
  8857. $g++;
  8858. }
  8859. if ($v['outk'] > 1) {
  8860. $x++;
  8861. }
  8862. if ($v['retreat'] > 0) {
  8863. $t++;
  8864. }
  8865. if ($v['state'] == 8) {
  8866. $s++;
  8867. }
  8868. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8869. $q++;
  8870. }
  8871. $details[$v['details']] = $v['details'];
  8872. if ($v['cpid'] != 0) {
  8873. $cpid[$v['cpid']] = $v['cpid'];
  8874. }
  8875. if ($v['cpbz'] != '') {
  8876. $cpbz[$v['cpbz']] = $v['cpbz'];
  8877. }
  8878. }
  8879. if (isset($wt[$value['type']])) {
  8880. $rows[$key]['type'] = $wt[$value['type']];
  8881. } else {
  8882. $rows[$key]['type'] = '未设置';
  8883. }
  8884. $rows[$key]['details'] = implode("、", $details);
  8885. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8886. $ftime = time() - 15 * 24 * 3600;
  8887. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8888. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8889. $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);
  8890. $rows[$key]['c'] = $c;
  8891. $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);
  8892. $rows[$key]['t'] = $t;
  8893. $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'] . '"');
  8894. $rows[$key]['z'] = $z;
  8895. // $jm = $classid;
  8896. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8897. $features = explode('-', trim($features, '-'));
  8898. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8899. }
  8900. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8901. $final_list =[];
  8902. foreach($tmp_list as $k=>$v){
  8903. $final_list[] = [
  8904. "warehouse"=>$v['warehouse'],
  8905. "purchase"=>$v['purchase'],
  8906. "details"=>$v['details'],
  8907. "cpid"=>$v['cpid'],
  8908. "sku"=>$v['sku'],
  8909. "title"=>$v['title'],
  8910. "features"=>$v['pm'],
  8911. "cpbz"=>$v['cpbz'],
  8912. "sm"=>$v['sm'],
  8913. "type"=>$v['type'],
  8914. "g"=>$v["g"],
  8915. "c"=>$v["c"],
  8916. "x"=>$v["x"],
  8917. "t"=>$v["t"],
  8918. "z"=>$v["z"],
  8919. "jm"=>$v["jm"],
  8920. "weight"=>$v["weight"],
  8921. "asd"=>$v["asd"],
  8922. ];
  8923. }
  8924. if(empty($final_list)){
  8925. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8926. }else{
  8927. $end_list = [];
  8928. foreach($final_list as $v){
  8929. $end_list[] = array_values($v);
  8930. }
  8931. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8932. array_unshift($end_list,[
  8933. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8934. ]);
  8935. array_unshift($end_list,[
  8936. $title,"","","","","","","","","","","","","","","","","",""
  8937. ]);
  8938. $merges = [
  8939. [
  8940. "s"=>["r"=>0,"c"=>0],
  8941. "e"=>["r"=>0,"c"=>6]
  8942. ]
  8943. ];
  8944. $cols = [
  8945. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8946. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8947. ];
  8948. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8949. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8950. ])));
  8951. }
  8952. }
  8953. }
  8954. }
  8955. public function _exceljxcjs(){
  8956. $classid = $this->classid->sku();
  8957. $pm = $classid;
  8958. $typeclass = array();
  8959. $tc = $this->typeclass->find_all();
  8960. foreach ($tc as $v) {
  8961. $typeclass[$v['id']] = $v;
  8962. }
  8963. $prc = array();
  8964. $purchase = $this->purchase->find_all();
  8965. foreach ($purchase as $k => $v) {
  8966. $prc[$v['id']] = $v['title'];
  8967. }
  8968. if(!isset($_GET['excel'])){
  8969. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8970. }
  8971. $where = "sku != 'Preset'";
  8972. //数据排序
  8973. $order_str = "id desc";
  8974. if (empty($page)) {
  8975. $start = 0;
  8976. $perpage = 1;
  8977. } else {
  8978. $start = ($page - 1) * $perpage;
  8979. }
  8980. $category = $this->input->get('category', true);
  8981. $warehouse = $this->input->get('warehouse', true);
  8982. $excelid = $this->input->get('sid', true);
  8983. if ($category) {
  8984. $where .= " and features like '%-$category-%'";
  8985. }
  8986. if ($warehouse) {
  8987. $where .= " and warehouse = '$warehouse'";
  8988. }
  8989. $xzid = '';
  8990. if ($excelid) {
  8991. $excelid = explode(',', trim($excelid, ','));
  8992. foreach ($excelid as $key => $value) {
  8993. $xzid .= " id = " . $value . " or";
  8994. }
  8995. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8996. }
  8997. $wt = array();
  8998. $whlabel_type = $this->whlabel_type->find_all();
  8999. foreach ($whlabel_type as $v) {
  9000. $wt[$v['id']] = $v['title'];
  9001. }
  9002. $wh = array();
  9003. $w = $this->warehouse->find_all('1=1', 'id,title');
  9004. foreach ($w as $v) {
  9005. $wh[$v['id']] = $v['title'];
  9006. }
  9007. $list = array();
  9008. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  9009. foreach ($rows as $key => $value) {
  9010. if (isset($wt[$value['type']])) {
  9011. $rows[$key]['type'] = $wt[$value['type']];
  9012. } else {
  9013. $rows[$key]['type'] = '未设置';
  9014. }
  9015. $bm = '03';
  9016. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  9017. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  9018. $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');
  9019. $details = array();
  9020. $cpid = array();
  9021. $cpbz = array();
  9022. $c = 0;
  9023. $g = 0;
  9024. $x = 0;
  9025. $t = 0;
  9026. $s = 0;
  9027. $q = 0;
  9028. foreach ($sd as $k => $v) {
  9029. if ($v['state'] == 0) {
  9030. $c++;
  9031. if ($v['cpid'] != 0) {
  9032. $cpid[$v['cpid']] = $v['cpid'];
  9033. }
  9034. if ($v['cpbz'] != '') {
  9035. $cpbz[$v['cpbz']] = $v['cpbz'];
  9036. }
  9037. }
  9038. if ($v['state'] != 9) {
  9039. $g++;
  9040. }
  9041. if ($v['state'] == 1) {
  9042. $x++;
  9043. }
  9044. if ($v['state'] == 2) {
  9045. $t++;
  9046. }
  9047. if ($v['state'] == 8) {
  9048. $s++;
  9049. }
  9050. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  9051. $q++;
  9052. }
  9053. $details[$v['details']] = $v['details'];
  9054. }
  9055. $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'] . '"');
  9056. $rows[$key]['details'] = implode("、", $details);
  9057. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9058. $number = $value['number'];
  9059. $ftime = time() - 15 * 24 * 3600;
  9060. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  9061. $rows[$key]['number'] = $g;
  9062. $rows[$key]['c'] = $c;
  9063. $rows[$key]['x'] = $x;
  9064. $rows[$key]['t'] = $t;
  9065. $rows[$key]['s'] = $s;
  9066. $rows[$key]['q'] = $q;
  9067. $rows[$key]['z'] = $z;
  9068. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  9069. $features = explode('-', trim($features, '-'));
  9070. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  9071. }
  9072. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  9073. $final_list = [];
  9074. foreach ($list as $k => $v) {
  9075. if (empty($v['sku'])) {
  9076. continue;
  9077. }
  9078. $final_list[] = [
  9079. $v["warehouse"],
  9080. $v["purchase"],
  9081. $v["details"],
  9082. $v["cpid"],
  9083. $v["dbcontent"],
  9084. $v["sku"],
  9085. $v["bm"],
  9086. $v["jm"],
  9087. $v["title"],
  9088. $v["pm"],
  9089. $v["cpbz"],
  9090. $v["sm"],
  9091. $v["type"],
  9092. $v["number"],
  9093. $v["c"],
  9094. $v["x"],
  9095. $v["t"],
  9096. $v["s"],
  9097. $v["q"],
  9098. $v["z"],
  9099. $v['weight'],
  9100. ];
  9101. }
  9102. if(empty($final_list)){
  9103. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9104. }
  9105. $title = "总进销存统计表";
  9106. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  9107. $merges = [
  9108. [
  9109. "s"=>["r"=>0,"c"=>0],
  9110. "e"=>["r"=>0,"c"=>21]
  9111. ]
  9112. ];
  9113. $cols = [
  9114. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  9115. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9116. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9117. ];
  9118. array_unshift($final_list, $first_row);
  9119. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  9120. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9121. }
  9122. public function _summaryjs($arg_array)
  9123. {
  9124. $prc = array();
  9125. $purchase = $this->purchase->find_all();
  9126. foreach ($purchase as $k => $v) {
  9127. $prc[$v['id']] = $v['title'];
  9128. }
  9129. if (isset($_GET['excel'])) {
  9130. $ktime = $this->input->get('ktime', true);
  9131. $jtime = $this->input->get('jtime', true);
  9132. $ktime = strtotime($ktime);
  9133. $jtime = strtotime($jtime);
  9134. $where = "1=1";
  9135. if ($ktime && $jtime) {
  9136. $where .= " and outk > '$ktime' and outk < '$jtime'";
  9137. }
  9138. //数据排序
  9139. $order_str = "time desc";
  9140. if (empty($page)) {
  9141. $start = 0;
  9142. $perpage = 1;
  9143. } else {
  9144. $start = ($page - 1) * $perpage;
  9145. }
  9146. //取得信息列表
  9147. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  9148. foreach ($info_list as $key => $value) {
  9149. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  9150. $warehouse = $this->warehouse->read($value['warehouse']);
  9151. $info_list[$key]['warehouse'] = $warehouse['title'];
  9152. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  9153. $details = array();
  9154. $cpid = array();
  9155. foreach ($x as $k => $v) {
  9156. if ($v['details'] != '') {
  9157. $details[$v['details']] = $v['details'];
  9158. }
  9159. if ($v['cpid'] != 0) {
  9160. $cpid[$v['cpid']] = $v['cpid'];
  9161. }
  9162. }
  9163. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  9164. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9165. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  9166. $info_list[$key]['s'] = $s;
  9167. $info_list[$key]['x'] = count($x);
  9168. }
  9169. if(empty($info_list)){
  9170. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9171. }
  9172. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  9173. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  9174. $merges = [
  9175. [
  9176. "s"=>["r"=>0,"c"=>0],
  9177. "e"=>["r"=>0,"c"=>7]
  9178. ]
  9179. ];
  9180. $cols = [
  9181. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  9182. ];
  9183. $final_list = [];
  9184. foreach($info_list as $k => $v){
  9185. $final_list[] = array_values($v);
  9186. }
  9187. array_unshift($final_list, $first_row);
  9188. array_unshift($final_list,[
  9189. $title,"","","","","","","","",
  9190. ]);
  9191. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9192. $titlename = "<table border=1>
  9193. <tr align='center'>
  9194. <td>仓库</td>
  9195. <td>供应商</td>
  9196. <td>出库位置</td>
  9197. <td>出库编码</td>
  9198. <td>SKU</td>
  9199. <td>产品名</td>
  9200. <td>总剩余库存</td>
  9201. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  9202. </tr>
  9203. </table>";
  9204. $filename = $title . ".xls";
  9205. $tail = "";
  9206. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  9207. }
  9208. }
  9209. public function _uckjs()
  9210. {
  9211. if (isset($_GET['excel'])) {
  9212. $tc = array();
  9213. $typeclass = $this->typeclass->find_all();
  9214. foreach ($typeclass as $v) {
  9215. $tc[$v['id']] = $v['zh'];
  9216. }
  9217. $first_row = [
  9218. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  9219. ];
  9220. $t = array();
  9221. $rq = '';
  9222. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  9223. $ts = $ts / (24 * 3600);
  9224. for ($i = 0; $i < $ts; $i++) {
  9225. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9226. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9227. }
  9228. $day_len = count($t);
  9229. $first_row[] = "本月出库";
  9230. $merges = [
  9231. ];
  9232. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  9233. $excel_key = 1;
  9234. $final_list = [];
  9235. foreach ($info_list as $k => $v) {
  9236. $features = explode('-', trim($v['features'], '-'));
  9237. if (!isset($features[3]) || !isset($features[4])) {
  9238. continue;
  9239. }
  9240. $tmp = [];
  9241. $tmp[0] = $tc[$features[0]]; //类型
  9242. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  9243. $tmp[2] = $tc[$features[4]]; //曲度
  9244. $tmp[3] = '';
  9245. if (isset($data[$k][1])) {
  9246. $tmp[3] .=$tmp[1];
  9247. }
  9248. if (isset($data[$k][2])) {
  9249. $tmp[3] .= $tmp[2];
  9250. }
  9251. if (isset($features[5])) {
  9252. $tmp[3] .= $tc[$features[5]];
  9253. }
  9254. if (isset($features[2])) {
  9255. $tmp[3] .= $tc[$features[2]];
  9256. }
  9257. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  9258. $tmp[4] = $v['sku'];
  9259. $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())) . '))'); //月初库存
  9260. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  9261. $tmp[7] ="";
  9262. $tmp[8] ="";
  9263. $byck = 0;
  9264. foreach ($t as $vv) {
  9265. $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));
  9266. $tmp[] = ($sl > 0) ? $sl : '';
  9267. $byck += $sl;
  9268. }
  9269. $tmp[] = ($byck > 0) ? $byck : '';
  9270. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  9271. // $ztrq = '';
  9272. // $ztsl = '';
  9273. // if (count($zt) > 0) {
  9274. // foreach ($zt as $vv) {
  9275. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  9276. // $ztsl .= $vv['num'] . '<br>';
  9277. // }
  9278. // }
  9279. if(empty($zt)){
  9280. $final_list[] = $tmp;
  9281. $excel_key = $excel_key + 1;
  9282. }else{
  9283. $len = count($zt);
  9284. if($len == 1){
  9285. $tmp[7] = $zt[0]['num'] ;
  9286. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  9287. $final_list[] = $tmp;
  9288. $excel_key = $excel_key + 1;
  9289. }else{
  9290. foreach($zt as $vv){
  9291. $tmp[7] = "";
  9292. $tmp[8] = "";
  9293. $tmp[7] = $vv['num'];
  9294. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9295. $final_list[] = $tmp;
  9296. }
  9297. $merges[] = [
  9298. "s"=>["r"=>$excel_key,"c"=>0],
  9299. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9300. ];
  9301. $merges[] = [
  9302. "s"=>["r"=>$excel_key,"c"=>1],
  9303. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9304. ];
  9305. $merges[] = [
  9306. "s"=>["r"=>$excel_key,"c"=>2],
  9307. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9308. ];
  9309. $merges[] = [
  9310. "s"=>["r"=>$excel_key,"c"=>3],
  9311. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9312. ];
  9313. $merges[] = [
  9314. "s"=>["r"=>$excel_key,"c"=>4],
  9315. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9316. ];
  9317. $merges[] = [
  9318. "s"=>["r"=>$excel_key,"c"=>5],
  9319. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9320. ];
  9321. $merges[] = [
  9322. "s"=>["r"=>$excel_key,"c"=>6],
  9323. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9324. ];
  9325. for($i=1;$i<=$day_len;$i++){
  9326. $merges[] = [
  9327. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9328. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9329. ];
  9330. }
  9331. $merges[] = [
  9332. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9333. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9334. ];
  9335. $excel_key = $excel_key + $len;
  9336. }
  9337. }
  9338. }
  9339. $title = "详情 " . date("Y-m-d", time());
  9340. if(empty($final_list)){
  9341. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9342. }
  9343. $cols = [
  9344. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9345. ];
  9346. array_unshift($final_list, $first_row);
  9347. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9348. }
  9349. }
  9350. public function _whlabelexcelzhjs(){
  9351. if(empty($_GET['excel'])){
  9352. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9353. }
  9354. $where = "sku != 'Preset' and sku != '' ";
  9355. //数据排序
  9356. $order_str = "id desc";
  9357. if (empty($page)) {
  9358. $start = 0;
  9359. $perpage = 1;
  9360. } else {
  9361. $start = ($page - 1) * $perpage;
  9362. }
  9363. $category = $this->input->get('category', true);
  9364. $warehouse = $this->input->get('warehouse', true);
  9365. $excelid = $this->input->get('sid', true);
  9366. if ($category) {
  9367. $where .= " and features like '%-$category-%'";
  9368. }
  9369. if ($warehouse) {
  9370. $where .= " and warehouse = '$warehouse'";
  9371. }
  9372. $xzid = '';
  9373. if ($excelid) {
  9374. $excelid = explode(',', trim($excelid, ','));
  9375. foreach ($excelid as $key => $value) {
  9376. $xzid .= " id = " . $value . " or";
  9377. }
  9378. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9379. }
  9380. $merges = [
  9381. [
  9382. "s"=>["r"=>0,"c"=>0],
  9383. "e"=>["r"=>0,"c"=>6]
  9384. ]
  9385. ];
  9386. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9387. $excel_index = 2;
  9388. $final_list = [];
  9389. foreach ($rows as $key => $value) {
  9390. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9391. $zh = '';
  9392. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9393. // foreach ($zt_list as $v) {
  9394. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9395. // }
  9396. $zt = array_sum(array_column($zt_list, 'num'));
  9397. $number = $value['number'];
  9398. $ftime = time() - 15 * 24 * 3600;
  9399. $warehouse = $this->warehouse->read($value['warehouse']);
  9400. // $rows[$key]['warehouse'] = $warehouse['title'];
  9401. // $rows[$key]['number'] = $c;
  9402. // $rows[$key]['features'] = $zh;
  9403. //$rows[$key]['hb'] = $c + $zt;
  9404. $tmp = [];
  9405. $tmp[0] = $warehouse['title'];
  9406. $tmp[1] = $value['sku'];
  9407. $tmp[2] = $value['title'];
  9408. $tmp[3] = $c;
  9409. $tmp[4] = "";
  9410. $tmp[5] = $c + $zt;
  9411. if(empty($zt_list)){
  9412. $tmp[4] = "";
  9413. $final_list[] = $tmp;
  9414. $excel_index = $excel_index + 1;
  9415. }else{
  9416. if(count($zt_list) == 1){
  9417. $tmp[4] = "";
  9418. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9419. $final_list[] = $tmp;
  9420. $excel_index = $excel_index + 1;
  9421. }else{
  9422. $len = count($zt_list);
  9423. foreach ($zt_list as $v){
  9424. $tmp[4] = "";
  9425. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9426. $final_list[] = $tmp;
  9427. }
  9428. $merges[] = [
  9429. "s"=>["r"=>$excel_index,"c"=>0],
  9430. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9431. ];
  9432. $merges[] = [
  9433. "s"=>["r"=>$excel_index,"c"=>1],
  9434. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9435. ];
  9436. $merges[] = [
  9437. "s"=>["r"=>$excel_index,"c"=>2],
  9438. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9439. ];
  9440. $merges[] = [
  9441. "s"=>["r"=>$excel_index,"c"=>3],
  9442. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9443. ];
  9444. $merges[] = [
  9445. "s"=>["r"=>$excel_index,"c"=>5],
  9446. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9447. ];
  9448. $excel_index = $excel_index + $len;
  9449. }
  9450. }
  9451. }
  9452. $first_row = [
  9453. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9454. ];
  9455. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9456. if(empty($final_list)){
  9457. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9458. }
  9459. $cols = [
  9460. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9461. ];
  9462. array_unshift($final_list, $first_row);
  9463. array_unshift($final_list, [
  9464. $title,"","","","",""
  9465. ]);
  9466. $end_list = [];
  9467. foreach ($final_list as $key => $value) {
  9468. $end_list[] = array_values($value);
  9469. }
  9470. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9471. }
  9472. //出库、退库导出
  9473. public function _dccrtypejs()
  9474. {
  9475. $classid = $this->classid->sku();
  9476. $pm = $classid;
  9477. $typeclass = array();
  9478. $tc = $this->typeclass->find_all();
  9479. foreach ($tc as $v) {
  9480. $typeclass[$v['id']] = $v;
  9481. }
  9482. $prc = array();
  9483. $purchase = $this->purchase->find_all();
  9484. foreach ($purchase as $k => $v) {
  9485. $prc[$v['id']] = $v['title'];
  9486. }
  9487. if (isset($_GET['sid'])) {
  9488. $wh = array();
  9489. $w = $this->warehouse->find_all('1=1', 'id,title');
  9490. foreach ($w as $v) {
  9491. $wh[$v['id']] = $v['title'];
  9492. }
  9493. $type = $this->input->get('excel', true);
  9494. $category = $this->input->get('category', true);
  9495. $size = $this->input->get('size', true);
  9496. $grade = $this->input->get('grade', true);
  9497. $color = $this->input->get('color', true);
  9498. $lowe = $this->input->get('lowe', true);
  9499. $sku = $this->input->get('sku', true);
  9500. $warehouse = $this->input->get('warehouse', true);
  9501. $lacetype = $this->input->get('lacetype', true);
  9502. $lacecolor = $this->input->get('lacecolor', true);
  9503. $density = $this->input->get('density', true);
  9504. $haircap = $this->input->get('haircap', true);
  9505. $purchase = $this->input->get('purchase', true);
  9506. $title = $this->input->get('title', true);
  9507. $state = $this->input->get('state', true);
  9508. $sid = $this->input->get('sid', true);
  9509. $ktime = $this->input->get('ktime', true);
  9510. $jtime = $this->input->get('jtime', true);
  9511. $ktime = strtotime($ktime);
  9512. $jtime = strtotime($jtime);
  9513. $where = "1=1";
  9514. $gj = "";
  9515. $ck = "";
  9516. if ($category) {
  9517. $where .= " and features like '%-$category-%'";
  9518. }
  9519. if ($size) {
  9520. $where .= " and features like '%-$size-%'";
  9521. }
  9522. if ($grade) {
  9523. $where .= " and features like '%-$grade-%'";
  9524. }
  9525. if ($color) {
  9526. $where .= " and features like '%-$color-%'";
  9527. }
  9528. if ($lowe) {
  9529. $where .= " and features like '%-$lowe-%'";
  9530. }
  9531. if ($warehouse) {
  9532. $where .= " and warehouse = '$warehouse'";
  9533. }
  9534. if ($purchase) {
  9535. $where .= " and purchase = '$purchase'";
  9536. }
  9537. if ($state) {
  9538. $where .= " and state = '$state'";
  9539. }
  9540. if ($lacetype) {
  9541. $where .= " and features like '%-$lacetype-%'";
  9542. }
  9543. if ($lacecolor) {
  9544. $where .= " and features like '%-$lacecolor-%'";
  9545. }
  9546. if ($density) {
  9547. $where .= " and features like '%-$density-%'";
  9548. }
  9549. if ($haircap) {
  9550. $where .= " and features like '%-$haircap-%'";
  9551. }
  9552. if ($title) {
  9553. $title = trim($title, ' ');
  9554. $title = trim($title, ' ');
  9555. $where .= " and title like '%$title%'";
  9556. }
  9557. if ($sku) {
  9558. $sku = trim($sku, ' ');
  9559. $sku = trim($sku, ' ');
  9560. $where .= " and sku like '%$sku%'";
  9561. }
  9562. if ($ktime && $jtime) {
  9563. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9564. }
  9565. $sidwhere = '';
  9566. if ($sid) {
  9567. $sd = "";
  9568. $s = explode(',', trim($sid, ','));
  9569. foreach ($s as $value) {
  9570. $sd .= " id = " . $value . " or";
  9571. }
  9572. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9573. }
  9574. //数据排序
  9575. $order_str = "time desc";
  9576. if (empty($page)) {
  9577. $start = 0;
  9578. $perpage = 1;
  9579. } else {
  9580. $start = ($page - 1) * $perpage;
  9581. }
  9582. $wh = array();
  9583. $w = $this->warehouse->find_all('1=1', 'id,title');
  9584. foreach ($w as $v) {
  9585. $wh[$v['id']] = $v['title'];
  9586. }
  9587. $wt = array();
  9588. $whlabel_type = $this->whlabel_type->find_all();
  9589. foreach ($whlabel_type as $v) {
  9590. $wt[$v['id']] = $v['title'];
  9591. }
  9592. $classid = $this->classid->sku();
  9593. $list = array();
  9594. $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');
  9595. foreach ($rows_r as $key => $value) {
  9596. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9597. $pm = $classid;
  9598. $jm = $classid;
  9599. $rows_r[$key]['enter'] = '入库';
  9600. $rows_r[$key]['time'] = $value['enter'];
  9601. if ($value['rktype'] == 1) {
  9602. $rows_r[$key]['rktype'] = '采购入库';
  9603. } else if ($value['rktype'] == 2) {
  9604. $rows_r[$key]['rktype'] = '盘盈调整';
  9605. } else if ($value['rktype'] == 3) {
  9606. $rows_r[$key]['rktype'] = '其他调整入库';
  9607. } else if ($value['rktype'] == 4) {
  9608. $rows_r[$key]['rktype'] = '其他调整入库';
  9609. } else if ($value['rktype'] == 5) {
  9610. $rows_r[$key]['rktype'] = '退库入库';
  9611. } else if ($value['rktype'] == 6) {
  9612. $rows_r[$key]['rktype'] = '退货可用入库';
  9613. } else if ($value['rktype'] == 7) {
  9614. $rows_r[$key]['rktype'] = '形态转换入库';
  9615. } else {
  9616. $rows_r[$key]['rktype'] = '';
  9617. }
  9618. $features = explode('-', trim($value['features'], '-'));
  9619. foreach ($features as $v) {
  9620. if (isset($typeclass[$v])) {
  9621. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9622. $pm[$typeclass[$v]['classid']] = $zh[0];
  9623. }
  9624. if (isset($typeclass[$v])) {
  9625. if (isset($jm[$typeclass[$v]['classid']])) {
  9626. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9627. }
  9628. }
  9629. }
  9630. $zh = implode(" ", $pm);
  9631. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9632. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9633. $rows_r[$key]['zh'] = $zh;
  9634. $jm = array_filter($jm);
  9635. $rows_r[$key]['features'] = implode("-", $jm);
  9636. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9637. }
  9638. $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');
  9639. foreach ($rows_c as $key => $value) {
  9640. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9641. $pm = $classid;
  9642. $jm = $classid;
  9643. $rows_c[$key]['time'] = $value['outk'];
  9644. $rows_c[$key]['outk'] = '出库';
  9645. if ($value['cktype'] == 1) {
  9646. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9647. } else if ($value['cktype'] == 2) {
  9648. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9649. } else if ($value['cktype'] == 3) {
  9650. $rows_c[$key]['cktype'] = '盘亏调整';
  9651. } else if ($value['cktype'] == 4) {
  9652. $rows_c[$key]['cktype'] = '其他调整出库';
  9653. } else if ($value['cktype'] == 5) {
  9654. $rows_c[$key]['cktype'] = '形态转换出库';
  9655. } else {
  9656. $rows_c[$key]['cktype'] = '';
  9657. }
  9658. unset($rows_c[$key]['state']);
  9659. $features = explode('-', trim($value['features'], '-'));
  9660. foreach ($features as $v) {
  9661. if (isset($typeclass[$v])) {
  9662. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9663. $pm[$typeclass[$v]['classid']] = $zh[0];
  9664. }
  9665. if (isset($typeclass[$v])) {
  9666. if (isset($jm[$typeclass[$v]['classid']])) {
  9667. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9668. }
  9669. }
  9670. }
  9671. $zh = implode(" ", $pm);
  9672. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9673. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9674. $rows_c[$key]['zh'] = $zh;
  9675. $jm = array_filter($jm);
  9676. $rows_c[$key]['features'] = implode("-", $jm);
  9677. $rows_c[$key]['number'] = 1;
  9678. }
  9679. $merged = $rows_r;
  9680. foreach ($rows_c as $key => $value) {
  9681. if (isset($merged[$key])) {
  9682. $merged[] = $value;
  9683. } else {
  9684. $merged[$key] = $value;
  9685. }
  9686. }
  9687. usort($merged, function ($a, $b) {
  9688. return $a['time'] - $b['time'];
  9689. });
  9690. foreach ($merged as $key => $value) {
  9691. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9692. }
  9693. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9694. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9695. $cols = [
  9696. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9697. ];
  9698. $final_list= [];
  9699. foreach($merged as $key => $value){
  9700. $final_list[] = array_values($value) ;
  9701. }
  9702. if(empty($merged)){
  9703. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9704. }
  9705. array_unshift($final_list, $first_row);
  9706. $end_list = [];
  9707. foreach ($final_list as $key => $value) {
  9708. $end_list[] = array_values($value);
  9709. }
  9710. $merges = [];
  9711. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9712. }
  9713. }
  9714. public function _errorexceljs()
  9715. {
  9716. $post = $this->input->post(NULL, TRUE);
  9717. if (isset($_GET['page'])) {
  9718. $page = $this->input->get('page', true);
  9719. $perpage = $this->input->get('perpage', true);
  9720. $sku = $this->input->get('sku', true);
  9721. $warehouse = $this->input->get('warehouse', true);
  9722. $ktime = $this->input->get('ktime', true);
  9723. $jtime = $this->input->get('jtime', true);
  9724. $ktime = strtotime($ktime);
  9725. $jtime = strtotime($jtime);
  9726. $where = "sku != 'Preset'";
  9727. $gj = '';
  9728. if ($sku) {
  9729. $where .= " and sku like '%$sku%'";
  9730. } else {
  9731. if ($ktime && $jtime) {
  9732. $gj = " and time > '$ktime' and time < '$jtime'";
  9733. }
  9734. }
  9735. if ($warehouse) {
  9736. $where .= " and warehouse = '$warehouse'";
  9737. }
  9738. //数据排序
  9739. $order_str = "id desc";
  9740. if (empty($page)) {
  9741. $start = 0;
  9742. $perpage = 1;
  9743. } else {
  9744. $start = ($page - 1) * $perpage;
  9745. }
  9746. //取得信息列表
  9747. $rows = array();
  9748. $list = array();
  9749. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9750. foreach ($info_list as $value) {
  9751. $warehouse = $this->warehouse->read($value['warehouse']);
  9752. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9753. $number = $value['number'];
  9754. $ftime = time() - 15 * 24 * 3600;
  9755. if ($c < 1) {
  9756. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9757. }
  9758. }
  9759. $title = "0库存汇总";
  9760. $first_row = ["仓库","SKU","产品","当前库存"];
  9761. $cols = [
  9762. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9763. ];
  9764. $final_list= [];
  9765. foreach($list as $key => $value){
  9766. $final_list[] = array_values($value) ;
  9767. }
  9768. if(empty($final_list)){
  9769. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9770. }
  9771. array_unshift($final_list, $first_row);
  9772. $merges = [];
  9773. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9774. }
  9775. }
  9776. }