Whlabel.php 318 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. } else if ($arg == 'typedy') //进销存浏览店员页面
  62. {
  63. $this->_typedy($arg_array);
  64. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  65. {
  66. $this->_typedy_ck($arg_array);
  67. } else if ($arg == 'typeck') {
  68. $this->_typeck($arg_array);
  69. } else if ($arg == 'whlabeckdc') {
  70. $this->_whlabeckdc($arg_array);
  71. } else if ($arg == 'usatype') //美仓进销存浏览
  72. {
  73. $this->_usatype();
  74. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  75. {
  76. $this->_usatypeapp();
  77. } else if ($arg == 'enteradd') //入库操作
  78. {
  79. $this->_enteradd();
  80. } else if ($arg == 'enteredit') //修改
  81. {
  82. $this->_enteredit($arg_array);
  83. } else if ($arg == 'enter') //入库浏览
  84. {
  85. $this->_enter();
  86. } else if ($arg == 'out') //出库浏览
  87. {
  88. $this->_out();
  89. } else if ($arg == 'label') //出库标签浏览
  90. {
  91. $this->_label();
  92. } else if ($arg == 'outorder') //独立站出库订单
  93. {
  94. $this->_outorder();
  95. } else if ($arg == 'soutorder') //速卖通出库订单
  96. {
  97. $this->_soutorder();
  98. } else if ($arg == 'toutorder') //TT出库订单
  99. {
  100. $this->_toutorder();
  101. }else if ($arg == 'aoutorder') //amz出库订单
  102. {
  103. $this->_aoutorder();
  104. } else if ($arg == 'retreat') //退库订单
  105. {
  106. $this->_retreat();
  107. } else if ($arg == 'retreatlk') //退库订单
  108. {
  109. $this->_retreatlk();
  110. } else if ($arg == 'change') //更换标签
  111. {
  112. $this->_change();
  113. } else if ($arg == 'del') //删除
  114. {
  115. $this->_del();
  116. } else if ($arg == 'exceljxc') //进销存信息导出
  117. {
  118. $this->_exceljxc();
  119. } else if ($arg == 'excelr') //入库信息导出
  120. {
  121. $this->_excelr();
  122. } else if ($arg == 'excelct') //出库、退库信息导出
  123. {
  124. $this->_excelct();
  125. } else if ($arg == 'dccrtype') //根据出入库类型导出
  126. {
  127. $this->_dccrtype();
  128. } else if ($arg == 'excelcr') //出库、退库信息导出
  129. {
  130. $this->_excelcr();
  131. } else if ($arg == 'kcyz') //库存验证
  132. {
  133. $this->_kcyz();
  134. } else if ($arg == 'kj') //库存扣减
  135. {
  136. $this->_kj($arg_array);
  137. } else if ($arg == 'presetout') //预设库存导入
  138. {
  139. $this->_presetout($arg_array);
  140. } else if ($arg == 'presetedit') //预设库存导入
  141. {
  142. $this->_presetedit($arg_array);
  143. }else if ($arg == 'presetedittwo') //预设库存导入
  144. {
  145. $this->_presetedittwo($arg_array);
  146. } else if ($arg == 'summary') //汇总导出
  147. {
  148. $this->_summary($arg_array);
  149. } else if ($arg == 'manifest') //usps发货清单
  150. {
  151. $this->_manifest();
  152. } else if ($arg == 'abnormal') //占单异常
  153. {
  154. $this->_abnormal();
  155. } else if ($arg == 'error') //0库存SKU
  156. {
  157. $this->_error();
  158. } else if ($arg == 'errorexcel') //0库存SKU导出
  159. {
  160. $this->_errorexcel();
  161. } else if ($arg == 'db') {
  162. $this->_db();
  163. } else if ($arg == 'dbrk') {
  164. $this->_dbrk();
  165. } else if ($arg == 'whlabelczdc') {
  166. $this->_whlabelczdc();
  167. } else if ($arg == 'print') {
  168. $this->_print($arg_array);
  169. } else if ($arg == 'usaprint') {
  170. $this->_usaprint($arg_array);
  171. } else if ($arg == 'printck') {
  172. $this->_printck($arg_array);
  173. } else if ($arg == 'printrk') {
  174. $this->_printrk($arg_array);
  175. } else if ($arg == 'printxzrk') {
  176. $this->_printxzrk($arg_array);
  177. } else if ($arg == 'printexcel') {
  178. $this->_printexcel($arg_array);
  179. } else if ($arg == 'uck') {
  180. $this->_uck();
  181. } else if ($arg == 'whlabelexcelzh') {
  182. $this->_whlabelexcelzh();
  183. } else if ($arg == 'fc') {
  184. $this->_fc();
  185. } else if ($arg == 'fcmb') {
  186. $this->_fcmb();
  187. } else if ($arg == 'fcexcel') {
  188. $this->_fcexcel();
  189. } else if ($arg == 'fcjxc') {
  190. $this->_fcjxc($arg_array);
  191. } else if ($arg == '0kcdel') {
  192. $this->_0kcdel(); //导表删除0库存
  193. } else if ($arg == 'gbhtype') {
  194. $this->_gbhtype(); //更改备货状态
  195. } else if($arg == 'excelrjs'){
  196. $this->_excelrjs();
  197. } else if($arg == 'excelctjs'){
  198. $this->_excelctjs();
  199. }else if ($arg == 'exceljxcjs') //进销存信息导出
  200. {
  201. $this->_exceljxcjs();
  202. } else if ($arg == 'summaryjs') //汇总导出
  203. {
  204. $this->_summaryjs($arg_array);
  205. }else if($arg == 'uckjs'){
  206. $this->_uckjs();
  207. }else if ($arg == 'whlabelexcelzhjs') {
  208. $this->_whlabelexcelzhjs();
  209. }else if($arg == 'dccrtypejs'){
  210. $this->_dccrtypejs();
  211. }else if($arg == 'errorexceljs'){
  212. $this->_errorexceljs();
  213. }else if($arg == "w_t_cs"){
  214. $this->_w_t_cs(); //首页
  215. }else {
  216. $this->_index();
  217. }
  218. }
  219. public function _w_t_cs(){
  220. $vip = 0;
  221. if (isset($_SESSION['api'])) {
  222. $user = $this->user->get_api($_SESSION['api']);
  223. $fgshop = "";
  224. $sid = "";
  225. $usersp = explode('|', trim($user['shop'], '|'));
  226. foreach ($usersp as $value) {
  227. $fgshop .= " shop = " . $value . " or";
  228. $sid .= " id = " . $value . " or";
  229. }
  230. if ($user['vip'] == 1) {
  231. $vip = 1;
  232. }
  233. } else {
  234. header('Location: /');
  235. exit;
  236. }
  237. $prc = array();
  238. $purchase = $this->purchase->find_all();
  239. foreach ($purchase as $k => $v) {
  240. $prc[$v['id']] = $v['title'];
  241. }
  242. $company = array();
  243. $ct = $this->company->find_all();
  244. foreach ($ct as $k => $v) {
  245. $company[$v['id']] = $v['title'];
  246. }
  247. $sp = array();
  248. $s = $this->shop->find_all('1=1', 'id,shopname');
  249. foreach ($s as $v) {
  250. $sp[$v['id']] = $v['shopname'];
  251. }
  252. $wh = array();
  253. $w = $this->warehouse->find_all('1=1', 'id,title');
  254. foreach ($w as $v) {
  255. $wh[$v['id']] = $v['title'];
  256. }
  257. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  258. $this->data['shop'] = $wlshop;
  259. $this->data['vip'] = $vip;
  260. $this->_Template('whlabel_typejs', $this->data);
  261. }
  262. //管理
  263. public function _index()
  264. {
  265. $post = $this->input->post(NULL, TRUE);
  266. if (isset($post['page'])) {
  267. $page = $this->input->post('page', true);
  268. $perpage = $this->input->post('perpage', true);
  269. $sku = $this->input->post('sku', true);
  270. $number = $this->input->post('number', true);
  271. $warehouse = $this->input->post('warehouse', true);
  272. $purchase = $this->input->post('purchase', true);
  273. $orderinfo = $this->input->post('orderinfo', true);
  274. $waybill = $this->input->post('waybill', true);
  275. $category = $this->input->post('category', true);
  276. $size = $this->input->post('size', true);
  277. $grade = $this->input->post('grade', true);
  278. $color = $this->input->post('color', true);
  279. $lowe = $this->input->post('lowe', true);
  280. $state = $this->input->post('state', true);
  281. $label = $this->input->post('label', true);
  282. $timetk = $this->input->post('timetkk', true);
  283. $timetj = $this->input->post('timetjj', true);
  284. $timetk = strtotime($timetk);
  285. $timetj = strtotime($timetj);
  286. $where = "1=1 ";
  287. if ($timetk && $timetj) {
  288. $where .= " and time > '$timetk' and time < '$timetj'";
  289. }
  290. if ($sku) {
  291. $where .= " and sku = '$sku'";
  292. }
  293. if ($number) {
  294. $where .= " and number = '$number'";
  295. }
  296. if ($warehouse) {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if ($purchase) {
  300. $where .= " and purchase = '$purchase'";
  301. }
  302. if ($orderinfo) {
  303. $where .= " and orderinfo = '$orderinfo'";
  304. }
  305. if ($waybill) {
  306. $where .= " and waybill = '$waybill'";
  307. }
  308. if ($category) {
  309. $where .= " and features like '%-$category-%'";
  310. }
  311. if ($size) {
  312. $where .= " and features like '%-$size-%'";
  313. }
  314. if ($grade) {
  315. $where .= " and features like '%-$grade-%'";
  316. }
  317. if ($color) {
  318. $where .= " and features like '%-$color-%'";
  319. }
  320. if ($lowe) {
  321. $where .= " and features like '%-$lowe-%'";
  322. }
  323. if ($label) {
  324. $where .= " and label = '$label'";
  325. }
  326. if ($state != '') {
  327. $where .= " and state = '$state'";
  328. }
  329. //数据排序
  330. $order_str = "time desc";
  331. if (empty($page)) {
  332. $start = 0;
  333. $perpage = 1;
  334. } else {
  335. $start = ($page - 1) * $perpage;
  336. }
  337. //取得信息列表
  338. $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);
  339. foreach ($info_list as $key => $value) {
  340. $warehouse = $this->warehouse->read($value['warehouse']);
  341. $info_list[$key]['warehouse'] = $warehouse['title'];
  342. $purchase = $this->purchase->read($value['purchase']);
  343. $info_list[$key]['purchase'] = $purchase['title'];
  344. if ($value['enter'] != 0) {
  345. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  346. } else {
  347. $info_list[$key]['enter'] = "";
  348. }
  349. if ($value['outk'] != 0) {
  350. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  351. } else {
  352. $info_list[$key]['outk'] = "";
  353. }
  354. if ($value['printing'] != 0) {
  355. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  356. } else {
  357. $info_list[$key]['printing'] = "";
  358. }
  359. if ($value['orderinfo'] == 0) {
  360. $info_list[$key]['orderinfo'] = "";
  361. }
  362. if ($value['waybill'] == 0) {
  363. $info_list[$key]['waybill'] = "";
  364. }
  365. if ($value['state'] == 0) {
  366. $info_list[$key]['state'] = "在库";
  367. } else if ($value['state'] == 1) {
  368. $info_list[$key]['state'] = "出库";
  369. } else if ($value['state'] == 2) {
  370. $info_list[$key]['state'] = "退库";
  371. } else if ($value['state'] == 3) {
  372. $info_list[$key]['state'] = "调拨中";
  373. } else if ($value['state'] == 4) {
  374. $info_list[$key]['state'] = "再加工";
  375. } else if ($value['state'] == 5) {
  376. $info_list[$key]['state'] = "维修中";
  377. } else if ($value['state'] == 6) {
  378. $info_list[$key]['state'] = "盘亏";
  379. } else if ($value['state'] == 7) {
  380. $info_list[$key]['state'] = "更换标签";
  381. } else if ($value['state'] == 8) {
  382. $info_list[$key]['state'] = "其它";
  383. } else if ($value['state'] == 9) {
  384. $info_list[$key]['state'] = "预设";
  385. } else if ($value['state'] == 10) {
  386. $info_list[$key]['state'] = "美店零售";
  387. }
  388. if ($value['text'] == "") {
  389. $info_list[$key]['text'] = "";
  390. }
  391. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  392. }
  393. $total = $this->whlabel->find_count($where);
  394. $pagenum = ceil($total / $perpage);
  395. $over = $total - ($start + $perpage);
  396. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  397. echo json_encode($rows);
  398. exit;
  399. }
  400. if (isset($post['outsku'])) {
  401. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  402. $cz = $this->input->post('cz', true);
  403. if ($cz == '1') {
  404. $sku = $this->input->post('outsku', true);
  405. if ($sku) {
  406. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  407. if (count($data) < 1) {
  408. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  409. exit;
  410. }
  411. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  412. echo json_encode(array('success' => true));
  413. exit;
  414. }
  415. } else {
  416. $sku = $this->input->post('outsku', true);
  417. if ($sku) {
  418. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  419. if (count($data) < 1) {
  420. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  421. exit;
  422. }
  423. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  424. echo json_encode(array('success' => true));
  425. exit;
  426. }
  427. }
  428. }
  429. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  430. $this->_Template('whlabel', $this->data);
  431. }
  432. //在库标签
  433. public function _existence()
  434. {
  435. $post = $this->input->post(NULL, TRUE);
  436. if (isset($post['s'])) {
  437. $id_arr = $this->input->post('s');
  438. $id_arr = explode(',', $id_arr);
  439. if (!$id_arr) {
  440. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  441. exit;
  442. }
  443. //循环删除记录
  444. foreach ($id_arr as $v) {
  445. $sid = $this->whlabel->read($v);
  446. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  447. if ($count > 0) {
  448. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  449. exit;
  450. }
  451. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  452. if (count($zt) > 0) {
  453. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  454. exit;
  455. }
  456. $this->whlabel->remove($v);
  457. }
  458. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  459. exit;
  460. }
  461. if (isset($post['page'])) {
  462. $page = $this->input->post('page', true);
  463. $perpage = $this->input->post('perpage', true);
  464. $warehouse = $this->input->post('warehouse', true);
  465. $label = $this->input->post('label', true);
  466. $where = "1=1 and state = 0";
  467. if ($warehouse) {
  468. $where .= " and warehouse = '$warehouse'";
  469. }
  470. if ($label) {
  471. $where .= " and label = '$label'";
  472. }
  473. //数据排序
  474. $order_str = "time asc";
  475. if (empty($page)) {
  476. $start = 0;
  477. $perpage = 1;
  478. } else {
  479. $start = ($page - 1) * $perpage;
  480. }
  481. //取得信息列表
  482. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  483. foreach ($info_list as $key => $value) {
  484. if ($value['enter'] != 0) {
  485. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  486. } else {
  487. $info_list[$key]['enter'] = "";
  488. }
  489. if ($value['printing'] != 0) {
  490. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  491. } else {
  492. $info_list[$key]['printing'] = "";
  493. }
  494. }
  495. $total = $this->whlabel->find_count($where);
  496. $pagenum = ceil($total / $perpage);
  497. $over = $total - ($start + $perpage);
  498. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  499. echo json_encode($rows);
  500. exit;
  501. }
  502. $this->_Template('whlabel_existence', $this->data);
  503. }
  504. //进销存浏览
  505. public function _typedy($arg_array)
  506. {
  507. $prc = array();
  508. $purchase = $this->purchase->find_all();
  509. foreach ($purchase as $k => $v) {
  510. $prc[$v['id']] = $v['title'];
  511. }
  512. $post = $this->input->post(NULL, TRUE);
  513. if (isset($post['page'])) {
  514. $page = $this->input->post('page', true);
  515. $perpage = $this->input->post('perpage', true);
  516. $category = $this->input->post('category', true);
  517. $size = $this->input->post('size', true);
  518. $grade = $this->input->post('grade', true);
  519. $color = $this->input->post('color', true);
  520. $lowe = $this->input->post('lowe', true);
  521. $sku = $this->input->post('sku');
  522. $title = $this->input->post('title');
  523. $warehouse = $this->input->post('warehouse', true);
  524. $usa = $this->input->post('usa', true);
  525. $purchase = $this->input->post('purchase', true);
  526. $lacetype = $this->input->post('lacetype', true);
  527. $haircap = $this->input->post('haircap', true);
  528. $density = $this->input->post('density', true);
  529. $details = $this->input->post('details', true);
  530. $state = $this->input->post('state', true);
  531. $lacecolor = $this->input->post('lacecolor', true);
  532. $hairnumber = $this->input->post('hairnumber', true);
  533. $cklx = $this->input->post('cklx', true);
  534. $ktime = $this->input->post('ktime', true);
  535. $jtime = $this->input->post('jtime', true);
  536. $sm = $this->input->post('sm', true);
  537. $cpbz = $this->input->post('cpbz', true);
  538. $type = $this->input->post('type', true);
  539. $ktime = strtotime($ktime);
  540. $jtime = strtotime($jtime);
  541. $where = "1=1";
  542. $gj = "";
  543. $ck = "";
  544. if ($usa) {
  545. if (!$warehouse) {
  546. $where .= " and (warehouse = '5' or warehouse = '8')";
  547. }
  548. }
  549. if ($warehouse) {
  550. $where .= " and warehouse = '$warehouse'";
  551. }
  552. if ($details) {
  553. $where .= " and details = '$details'";
  554. }
  555. if ($purchase) {
  556. $where .= " and purchase = '$purchase'";
  557. }
  558. if (isset($state)) {
  559. if($state >-1){
  560. $where .= " and state = '$state'";
  561. }
  562. }
  563. if ($lacetype) {
  564. $where .= " and features like '%-$lacetype-%'";
  565. }
  566. if ($category) {
  567. $where .= " and features like '%-$category-%'";
  568. }
  569. if ($size) {
  570. $where .= " and features like '%-$size-%'";
  571. }
  572. if ($grade) {
  573. $where .= " and features like '%-$grade-%'";
  574. }
  575. if ($color) {
  576. $where .= " and features like '%-$color-%'";
  577. }
  578. if ($lowe) {
  579. $where .= " and features like '%-$lowe-%'";
  580. }
  581. if ($haircap) {
  582. $where .= " and features like '%-$haircap-%'";
  583. }
  584. if ($density) {
  585. $where .= " and features like '%-$density-%'";
  586. }
  587. if ($lacecolor) {
  588. $where .= " and features like '%-$lacecolor-%'";
  589. }
  590. if($sm){
  591. $where .= " and sm like '%".$sm."%'";
  592. }
  593. if($cpbz){
  594. $where .= " and cpbz like '%".$cpbz."%'";
  595. }
  596. if($type){
  597. $where .= " and type = ".$type."";
  598. }
  599. if (!empty($hairnumber)) {
  600. $where .= " and features like '%-128-%' ";
  601. if ($hairnumber < 0) {
  602. $class_list = $this->typeclass->find_all('classid = 43');
  603. foreach ($class_list as $v) {
  604. $where .= " and features not like '%-" . $v['id'] . "-%'";
  605. }
  606. } else {
  607. $where .= " and features like '%-$hairnumber-%'";
  608. }
  609. }
  610. $where_add = '';
  611. if ($cklx) {
  612. $shop = $this->shop->read($cklx);
  613. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  614. }
  615. if ($ktime && $jtime) {
  616. $gj = " and enter > '$ktime' and enter < '$jtime'";
  617. $ck = " and outk > '$ktime' and outk < '$jtime'";
  618. }
  619. //数据排序
  620. $order_str = "id desc";
  621. if (empty($page)) {
  622. $start = 0;
  623. $perpage = 1;
  624. } else {
  625. $start = ($page - 1) * $perpage;
  626. }
  627. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  628. if ($sku) {
  629. $sku = trim($sku, ' ');
  630. $sku = trim($sku, ' ');
  631. $where .= " and sku like '%$sku%'";
  632. $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);
  633. } else if ($title) {
  634. $title = trim($title, ' ');
  635. $title = trim($title, ' ');
  636. $where .= " and title like '%$title%'";
  637. $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);
  638. } else {
  639. //$where .= " and time > '$ktime' and time < '$jtime'";
  640. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  641. }
  642. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  643. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  644. foreach ($info_list as $k => $v) {
  645. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  646. unset($info_list[$k]['pm']);
  647. unset($info_list[$k]['jm']);
  648. unset($info_list[$k]['bm']);
  649. }
  650. //取得信息列表
  651. $rows = array();
  652. $list = array();
  653. foreach ($info_list as $key => $value) {
  654. $warehouse = $this->warehouse->read($value['warehouse']);
  655. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  656. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  657. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  658. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  659. $info_list[$key]['label'] = $value['sm'];
  660. $number = $value['number'];
  661. $ftime = time() - 15 * 24 * 3600;
  662. $info_list[$key]['warehouse'] = $warehouse['title'];
  663. $info_list[$key]['features'] = count($c);
  664. $z = count($z); //查看订单号
  665. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  666. $ztdata = '';
  667. if (count($zt) > 0) {
  668. foreach ($zt as $vv) {
  669. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  670. }
  671. }
  672. $info_list[$key]['number'] = $ztdata;
  673. $info_list[$key]['sm'] = $z;
  674. $details = array();
  675. $cpid = array();
  676. foreach ($c as $k => $v) {
  677. $details[$v['details']] = $v['details'];
  678. if ($v['cpid'] != 0) {
  679. $cpid[$v['cpid']] = $v['cpid'];
  680. }
  681. }
  682. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  683. if ($value['shop'] != '') {
  684. $shop = explode(',', trim($value['shop'], ','));
  685. $shop = $this->shop->read($shop[0]);
  686. $info_list[$key]['shop'] = $shop['shopname'];
  687. }
  688. }
  689. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  690. $pagenum = ceil($total / $perpage);
  691. $over = $total - ($start + $perpage);
  692. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  693. echo json_encode($rows);
  694. exit;
  695. }
  696. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  697. $this->_Template('whlabel_typedy', $this->data);
  698. }
  699. //进销存浏览
  700. public function _typedy_ck($arg_array)
  701. {
  702. $prc = array();
  703. $purchase = $this->purchase->find_all();
  704. foreach ($purchase as $k => $v) {
  705. $prc[$v['id']] = $v['title'];
  706. }
  707. $post = $this->input->post(NULL, TRUE);
  708. if (isset($post['page'])) {
  709. $page = $this->input->post('page', true);
  710. $perpage = $this->input->post('perpage', true);
  711. $category = $this->input->post('category', true);
  712. $size = $this->input->post('size', true);
  713. $grade = $this->input->post('grade', true);
  714. $color = $this->input->post('color', true);
  715. $lowe = $this->input->post('lowe', true);
  716. $sku = $this->input->post('sku');
  717. $title = $this->input->post('title');
  718. $warehouse = $this->input->post('warehouse', true);
  719. $usa = $this->input->post('usa', true);
  720. $purchase = $this->input->post('purchase', true);
  721. $lacetype = $this->input->post('lacetype', true);
  722. $haircap = $this->input->post('haircap', true);
  723. $density = $this->input->post('density', true);
  724. $details = $this->input->post('details', true);
  725. $state = $this->input->post('state', true);
  726. $lacecolor = $this->input->post('lacecolor', true);
  727. $cklx = $this->input->post('cklx', true);
  728. $ktime = $this->input->post('ktime', true);
  729. $jtime = $this->input->post('jtime', true);
  730. $ktime = strtotime($ktime);
  731. $jtime = strtotime($jtime);
  732. $where = "1=1";
  733. $gj = "";
  734. $ck = "";
  735. if ($lacetype) {
  736. $where .= " and features like '%-$lacetype-%'";
  737. }
  738. if ($category) {
  739. $where .= " and features like '%-$category-%'";
  740. }
  741. if ($size) {
  742. $where .= " and features like '%-$size-%'";
  743. }
  744. if ($grade) {
  745. $where .= " and features like '%-$grade-%'";
  746. }
  747. if ($color) {
  748. $where .= " and features like '%-$color-%'";
  749. }
  750. if ($lowe) {
  751. $where .= " and features like '%-$lowe-%'";
  752. }
  753. if ($haircap) {
  754. $where .= " and features like '%-$haircap-%'";
  755. }
  756. if ($density) {
  757. $where .= " and features like '%-$density-%'";
  758. }
  759. if ($lacecolor) {
  760. $where .= " and features like '%-$lacecolor-%'";
  761. }
  762. if ($usa) {
  763. if (!$warehouse) {
  764. $where .= " and (warehouse = '5' or warehouse = '8')";
  765. }
  766. }
  767. if ($warehouse) {
  768. $where .= " and warehouse = '$warehouse'";
  769. }
  770. if ($details) {
  771. $where .= " and details = '$details'";
  772. }
  773. if ($purchase) {
  774. $where .= " and purchase = '$purchase'";
  775. }
  776. if ($state) {
  777. $where .= " and state = '$state'";
  778. }
  779. $where_add = '';
  780. if ($cklx) {
  781. $shop = $this->shop->read($cklx);
  782. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  783. }
  784. if ($ktime && $jtime) {
  785. $gj = " and enter > '$ktime' and enter < '$jtime'";
  786. $ck = " and outk > '$ktime' and outk < '$jtime'";
  787. }
  788. //数据排序
  789. $order_str = "id desc";
  790. if (empty($page)) {
  791. $start = 0;
  792. $perpage = 1;
  793. } else {
  794. $start = ($page - 1) * $perpage;
  795. }
  796. if ($sku) {
  797. $sku = trim($sku, ' ');
  798. $sku = trim($sku, ' ');
  799. $where .= " and sku like '%$sku%'";
  800. $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);
  801. } else if ($title) {
  802. $title = trim($title, ' ');
  803. $title = trim($title, ' ');
  804. $where .= " and title like '%$title%'";
  805. $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);
  806. } else {
  807. //$where .= " and time > '$ktime' and time < '$jtime'";
  808. $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);
  809. }
  810. //取得信息列表
  811. $rows = array();
  812. $list = array();
  813. foreach ($info_list as $key => $value) {
  814. $warehouse = $this->warehouse->read($value['warehouse']);
  815. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  816. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  817. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  818. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  819. $ftime = time() - 15 * 24 * 3600;
  820. $info_list[$key]['warehouse'] = $warehouse['title'];
  821. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  822. //$z = count($z);//查看订单号
  823. //$info_list[$key]['zd'] = $z;
  824. $details = array();
  825. $cpid = array();
  826. foreach ($c as $k => $v) {
  827. $details[$v['details']] = $v['details'];
  828. if ($v['cpid'] != 0) {
  829. $cpid[$v['cpid']] = $v['cpid'];
  830. }
  831. }
  832. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  833. if ($value['shop'] != '') {
  834. $shop = explode(',', trim($value['shop'], ','));
  835. $shop = $this->shop->read($shop[0]);
  836. $info_list[$key]['shop'] = $shop['shopname'];
  837. }
  838. }
  839. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  840. $pagenum = ceil($total / $perpage);
  841. $over = $total - ($start + $perpage);
  842. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  843. echo json_encode($rows);
  844. exit;
  845. }
  846. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  847. $this->_Template('whlabel_typedy_ck', $this->data);
  848. }
  849. public function _typeck($arg_array)
  850. {
  851. $prc = array();
  852. $purchase = $this->purchase->find_all();
  853. foreach ($purchase as $k => $v) {
  854. $prc[$v['id']] = $v['title'];
  855. }
  856. $post = $this->input->post(NULL, TRUE);
  857. if (isset($post['page'])) {
  858. $page = $this->input->post('page', true);
  859. $perpage = $this->input->post('perpage', true);
  860. $category = $this->input->post('category', true);
  861. $size = $this->input->post('size', true);
  862. $grade = $this->input->post('grade', true);
  863. $color = $this->input->post('color', true);
  864. $lacecolor = $this->input->post('lacecolor', true);
  865. $lowe = $this->input->post('lowe', true);
  866. $sku = $this->input->post('sku');
  867. $title = $this->input->post('title');
  868. $warehouse = 13;
  869. $usa = $this->input->post('usa', true);
  870. $purchase = $this->input->post('purchase', true);
  871. $lacetype = $this->input->post('lacetype', true);
  872. $haircap = $this->input->post('haircap', true);
  873. $density = $this->input->post('density', true);
  874. $details = $this->input->post('details', true);
  875. $state = $this->input->post('state', true);
  876. $ktime = $this->input->post('ktime', true);
  877. $jtime = $this->input->post('jtime', true);
  878. $ktime = strtotime($ktime);
  879. $jtime = strtotime($jtime);
  880. $where = "1=1";
  881. $gj = "";
  882. $ck = "";
  883. if ($lacetype) {
  884. $where .= " and features like '%-$lacetype-%'";
  885. }
  886. if ($category) {
  887. $where .= " and features like '%-$category-%'";
  888. }
  889. if ($size) {
  890. $where .= " and features like '%-$size-%'";
  891. }
  892. if ($grade) {
  893. $where .= " and features like '%-$grade-%'";
  894. }
  895. if ($color) {
  896. $where .= " and features like '%-$color-%'";
  897. }
  898. if ($lacecolor) {
  899. $where .= " and features like '%-$lacecolor-%'";
  900. }
  901. if ($lowe) {
  902. $where .= " and features like '%-$lowe-%'";
  903. }
  904. if ($haircap) {
  905. $where .= " and features like '%-$haircap-%'";
  906. }
  907. if ($density) {
  908. $where .= " and features like '%-$density-%'";
  909. }
  910. if ($warehouse) {
  911. $where .= " and warehouse = '$warehouse'";
  912. }
  913. if ($details) {
  914. $where .= " and details = '$details'";
  915. }
  916. if ($purchase) {
  917. $where .= " and purchase = '$purchase'";
  918. }
  919. if ($state) {
  920. $where .= " and state = '$state'";
  921. }
  922. if ($ktime && $jtime) {
  923. $gj = " and enter > '$ktime' and enter < '$jtime'";
  924. $ck = " and outk > '$ktime' and outk < '$jtime'";
  925. }
  926. //数据排序
  927. $order_str = "id desc";
  928. if (empty($page)) {
  929. $start = 0;
  930. $perpage = 1;
  931. } else {
  932. $start = ($page - 1) * $perpage;
  933. }
  934. if ($sku) {
  935. $sku = trim($sku, ' ');
  936. $sku = trim($sku, ' ');
  937. $where .= " and sku like '%$sku%'";
  938. } else if ($title) {
  939. $title = trim($title, ' ');
  940. $title = trim($title, ' ');
  941. $where .= " and title like '%$title%'";
  942. }
  943. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  944. //取得信息列表
  945. $t = array();
  946. $typeclass = $this->typeclass->find_all();
  947. foreach ($typeclass as $v) {
  948. $t[$v['id']] = $v;
  949. }
  950. $rows = array();
  951. $list = array();
  952. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  953. foreach ($info_list as $key => $value) {
  954. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  955. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  956. $warehouse = $this->warehouse->read($value['warehouse']);
  957. $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');
  958. $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'] . '"');
  959. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  960. $number = $value['number'];
  961. $ftime = time() - 15 * 24 * 3600;
  962. $z = count($z); //查看订单号
  963. $info_list[$key]['warehouse'] = $warehouse['title'];
  964. $info_list[$key]['features'] = count($c);
  965. $info_list[$key]['number'] = $z;
  966. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  967. $details = array();
  968. $cpid = array();
  969. foreach ($c as $k => $v) {
  970. $details[$v['details']] = $v['details'];
  971. if ($v['cpid'] != 0) {
  972. $cpid[$v['cpid']] = $v['cpid'];
  973. }
  974. }
  975. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  976. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  977. unset($info_list[$key]['pm']);
  978. unset($info_list[$key]['jm']);
  979. unset($info_list[$key]['bm']);
  980. }
  981. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  982. $pagenum = ceil($total / $perpage);
  983. $over = $total - ($start + $perpage);
  984. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  985. echo json_encode($rows);
  986. exit;
  987. }
  988. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  989. $this->_Template('whlabel_typeck', $this->data);
  990. }
  991. //进销存导出
  992. public function _whlabeckdc()
  993. {
  994. $prc = array();
  995. $purchase = $this->purchase->find_all();
  996. foreach ($purchase as $k => $v) {
  997. $prc[$v['id']] = $v['title'];
  998. }
  999. if (isset($_GET['excel'])) {
  1000. $where = "sku != 'Preset'";
  1001. //数据排序
  1002. $order_str = "id desc";
  1003. if (empty($page)) {
  1004. $start = 0;
  1005. $perpage = 1;
  1006. } else {
  1007. $start = ($page - 1) * $perpage;
  1008. }
  1009. $category = $this->input->get('category', true);
  1010. $color = $this->input->get('color', true);
  1011. $lowe = $this->input->get('lowe', true);
  1012. $lacetype = $this->input->get('lacetype', true);
  1013. $size = $this->input->get('size', true);
  1014. $density = $this->input->get('density', true);
  1015. $haircap = $this->input->get('haircap', true);
  1016. $sku = $this->input->get('sku', true);
  1017. $details = $this->input->get('details', true);
  1018. $warehouse = 13;
  1019. $excelid = $this->input->get('sid', true);
  1020. if ($category) {
  1021. $where .= " and features like '%-$category-%'";
  1022. }
  1023. if ($color) {
  1024. $where .= " and features like '%-$color-%'";
  1025. }
  1026. if ($lowe) {
  1027. $where .= " and features like '%-$lowe-%'";
  1028. }
  1029. if ($lacetype) {
  1030. $where .= " and features like '%-$lacetype-%'";
  1031. }
  1032. if ($size) {
  1033. $where .= " and features like '%-$size-%'";
  1034. }
  1035. if ($density) {
  1036. $where .= " and features like '%-$density-%'";
  1037. }
  1038. if ($haircap) {
  1039. $where .= " and features like '%-$haircap-%'";
  1040. }
  1041. if ($warehouse) {
  1042. $where .= " and warehouse = '$warehouse'";
  1043. }
  1044. if ($sku) {
  1045. $where .= " and sku like '%$sku%'";
  1046. }
  1047. if ($details) {
  1048. $where .= " and details = '$details'";
  1049. }
  1050. $xzid = '';
  1051. if ($excelid) {
  1052. $excelid = explode(',', trim($excelid, ','));
  1053. foreach ($excelid as $key => $value) {
  1054. $xzid .= " id = " . $value . " or";
  1055. }
  1056. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1057. }
  1058. //取得信息列表
  1059. /**
  1060. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1061. $rows = array();$list = array();
  1062. foreach ($info_list as $key=>$value)
  1063. {
  1064. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1065. }
  1066. **/
  1067. $wh = array();
  1068. $w = $this->warehouse->find_all('1=1', 'id,title');
  1069. foreach ($w as $v) {
  1070. $wh[$v['id']] = $v['title'];
  1071. }
  1072. $tc = array();
  1073. $tcdata = array();
  1074. $list = array();
  1075. $classid = $this->classid->sku();
  1076. $tcall = $this->typeclass->find_all();
  1077. $typeclass = array();
  1078. foreach ($tcall as $v)
  1079. {
  1080. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1081. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1082. }
  1083. $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 ");
  1084. foreach ($rows as $key => $value) {
  1085. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1086. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1087. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1088. $rows[$key]['cpbz'] = $u9_info['bm'];
  1089. $rows[$key]['cs'] = $u9_info['jm'];
  1090. if(empty($value['details'])){
  1091. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1092. }else{
  1093. $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');
  1094. }
  1095. $details = array();
  1096. $cpid = array();
  1097. $cpbz = array();
  1098. $c = 0;
  1099. $g = 0;
  1100. $x = 0;
  1101. $t = 0;
  1102. $s = 0;
  1103. $q = 0;
  1104. foreach ($sd as $k => $v) {
  1105. if ($v['state'] == 0) {
  1106. $c++;
  1107. }
  1108. if ($v['state'] != 9) {
  1109. $g++;
  1110. }
  1111. if ($v['state'] == 1) {
  1112. $x++;
  1113. }
  1114. if ($v['state'] == 2) {
  1115. $t++;
  1116. }
  1117. if ($v['state'] == 8) {
  1118. $s++;
  1119. }
  1120. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1121. $q++;
  1122. }
  1123. $details[$v['details']] = $v['details'];
  1124. if ($v['cpid'] != 0) {
  1125. $cpid[$v['cpid']] = $v['cpid'];
  1126. }
  1127. if ($v['cpbz'] != '') {
  1128. $cpbz[$v['cpbz']] = $v['cpbz'];
  1129. }
  1130. }
  1131. $rows[$key]['details'] = implode("、", $details);
  1132. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1133. $number = $value['number'];
  1134. $ftime = time() - 15 * 24 * 3600;
  1135. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1136. $rows[$key]['number'] = $g;
  1137. $rows[$key]['features'] = $c;
  1138. $rows[$key]['x'] = $x;
  1139. $rows[$key]['t'] = $t;
  1140. $rows[$key]['s'] = $s;
  1141. $rows[$key]['q'] = $q;
  1142. $rows[$key]['wzsl'] = count($details);
  1143. //cpbzs
  1144. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1145. $unique_arr = array_unique($tmp_cpbzs);
  1146. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1147. }
  1148. $title = "进销存统计表" . date('Y-m-d', time());
  1149. $titlename = "<table border=1>
  1150. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1151. <tr align='center'>
  1152. <td>仓库</td>
  1153. <td>供应商</td>
  1154. <td>位置</td>
  1155. <td>库存编码</td>
  1156. <td>SKU</td>
  1157. <td>用友编码</td>
  1158. <td>用友料号</td>
  1159. <td>产品英文名</td>
  1160. <td>产品中文名</td>
  1161. <td>备注</td>
  1162. <td>入库总量</td>
  1163. <td>库存数量</td>
  1164. <td>销售数量</td>
  1165. <td>退货数量</td>
  1166. <td>删除数量</td>
  1167. <td>其它操作</td>
  1168. <td>位置数量</td>
  1169. </tr>
  1170. </table>";
  1171. $filename = $title . ".xls";
  1172. $tail = "";
  1173. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1174. }
  1175. }
  1176. public function _type()
  1177. {
  1178. $vip = 0;
  1179. if (isset($_SESSION['api'])) {
  1180. $user = $this->user->get_api($_SESSION['api']);
  1181. $fgshop = "";
  1182. $sid = "";
  1183. $usersp = explode('|', trim($user['shop'], '|'));
  1184. foreach ($usersp as $value) {
  1185. $fgshop .= " shop = " . $value . " or";
  1186. $sid .= " id = " . $value . " or";
  1187. }
  1188. if ($user['vip'] == 1) {
  1189. $vip = 1;
  1190. }
  1191. } else {
  1192. header('Location: /');
  1193. exit;
  1194. }
  1195. $prc = array();
  1196. $purchase = $this->purchase->find_all();
  1197. foreach ($purchase as $k => $v) {
  1198. $prc[$v['id']] = $v['title'];
  1199. }
  1200. $company = array();
  1201. $ct = $this->company->find_all();
  1202. foreach ($ct as $k => $v) {
  1203. $company[$v['id']] = $v['title'];
  1204. }
  1205. $sp = array();
  1206. $s = $this->shop->find_all('1=1', 'id,shopname');
  1207. foreach ($s as $v) {
  1208. $sp[$v['id']] = $v['shopname'];
  1209. }
  1210. $wh = array();
  1211. $w = $this->warehouse->find_all('1=1', 'id,title');
  1212. foreach ($w as $v) {
  1213. $wh[$v['id']] = $v['title'];
  1214. }
  1215. $post = $this->input->post(NULL, TRUE);
  1216. if (isset($post['page'])) {
  1217. $page = $this->input->post('page', true);
  1218. $perpage = $this->input->post('perpage', true);
  1219. $category = $this->input->post('category', true);
  1220. $size = $this->input->post('size', true);
  1221. $grade = $this->input->post('grade', true);
  1222. $color = $this->input->post('color', true);
  1223. $lowe = $this->input->post('lowe', true);
  1224. $sku = $this->input->post('sku');
  1225. $title = $this->input->post('title');
  1226. $warehouse = $this->input->post('warehouse', true);
  1227. $usa = $this->input->post('usa', true);
  1228. $purchase = $this->input->post('purchase', true);
  1229. $lacetype = $this->input->post('lacetype', true);
  1230. $haircap = $this->input->post('haircap', true);
  1231. $density = $this->input->post('density', true);
  1232. $details = $this->input->post('details', true);
  1233. $state = $this->input->post('state', true);
  1234. $shop = $this->input->post('shop', true);
  1235. $lacecolor = $this->input->post('lacecolor', true);
  1236. $hairnumber = $this->input->post('hairnumber', true);
  1237. $type = $this->input->post('type', true);
  1238. $ktime = $this->input->post('ktime', true);
  1239. $jtime = $this->input->post('jtime', true);
  1240. $ktime = strtotime($ktime);
  1241. $jtime = strtotime($jtime);
  1242. $cpbz = $this->input->post('cpbz', true);
  1243. $sm = $this->input->post('sm', true);
  1244. $where = "1=1";
  1245. $gj = "";
  1246. $ck = "";
  1247. if ($usa) {
  1248. if (!$warehouse) {
  1249. $where .= " and (warehouse = '5' or warehouse = '8')";
  1250. }
  1251. }
  1252. if ($warehouse) {
  1253. $where .= " and warehouse = '$warehouse'";
  1254. }
  1255. if ($details) {
  1256. $where .= " and details = '$details'";
  1257. }
  1258. if ($purchase) {
  1259. $where .= " and purchase = '$purchase'";
  1260. }
  1261. if ($state) {
  1262. $where .= " and state = '$state'";
  1263. }
  1264. if ($shop) {
  1265. $where .= " and shop like '%$shop%'";
  1266. }
  1267. if ($type) {
  1268. $where .= " and type = '$type'";
  1269. }
  1270. if ($ktime && $jtime) {
  1271. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1272. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1273. }
  1274. if ($cpbz) {
  1275. $where .= " and cpbz like '%$cpbz%' ";
  1276. }
  1277. if ($sm) {
  1278. $where .= " and sm like '%$sm%' ";
  1279. }
  1280. if ($lacecolor) {
  1281. $where .= " and features like '%-$lacecolor-%'";
  1282. }
  1283. if ($lacetype) {
  1284. $where .= " and features like '%-$lacetype-%'";
  1285. }
  1286. if ($category) {
  1287. $where .= " and features like '%-$category-%'";
  1288. }
  1289. if ($size) {
  1290. $where .= " and features like '%-$size-%'";
  1291. }
  1292. if ($grade) {
  1293. $where .= " and features like '%-$grade-%'";
  1294. }
  1295. if ($color) {
  1296. $where .= " and features like '%-$color-%'";
  1297. }
  1298. if ($lowe) {
  1299. $where .= " and features like '%-$lowe-%'";
  1300. }
  1301. if ($haircap) {
  1302. $where .= " and features like '%-$haircap-%'";
  1303. }
  1304. if ($density) {
  1305. $where .= " and features like '%-$density-%'";
  1306. }
  1307. if (!empty($hairnumber)) {
  1308. $where .= " and features like '%-128-%' ";
  1309. if ($hairnumber < 0) {
  1310. $class_list = $this->typeclass->find_all('classid = 43');
  1311. foreach ($class_list as $v) {
  1312. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1313. }
  1314. } else {
  1315. $where .= " and features like '%-$hairnumber-%'";
  1316. }
  1317. }
  1318. //数据排序
  1319. $order_str = "id desc";
  1320. if (empty($page)) {
  1321. $start = 0;
  1322. $perpage = 1;
  1323. } else {
  1324. $start = ($page - 1) * $perpage;
  1325. }
  1326. $fjnr = '';
  1327. if ($sku) {
  1328. $sku = trim($sku, ' ');
  1329. $sku = trim($sku, ' ');
  1330. $fjnr .= " and sku like '%$sku%'";
  1331. }
  1332. if ($title) {
  1333. $title = trim($title, ' ');
  1334. $title = trim($title, ' ');
  1335. $fjnr .= " and title like '%$title%'";
  1336. }
  1337. $wt = array();
  1338. $whlabel_type = $this->whlabel_type->find_all();
  1339. foreach ($whlabel_type as $v) {
  1340. $wt[$v['id']] = $v['title'];
  1341. }
  1342. //$where .= " and time > '$ktime' and time < '$jtime'";
  1343. $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
  1344. //取得信息列表
  1345. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1346. $rows = array();
  1347. $list = array();
  1348. foreach ($info_list as $key => $value) {
  1349. if (isset($wt[$value['type']])) {
  1350. $info_list[$key]['type'] = $wt[$value['type']];
  1351. } else {
  1352. $info_list[$key]['type'] = '未设置';
  1353. }
  1354. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1355. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1356. $ztdata = '';
  1357. if (count($zt) > 0) {
  1358. foreach ($zt as $vv) {
  1359. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1360. }
  1361. }
  1362. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1363. $cdata = array_filter($qbdata, function ($item) {
  1364. return $item['state'] < 1;
  1365. });
  1366. $c = array_sum(array_column($cdata, 'jnum'));
  1367. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1368. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1369. });
  1370. $g = array_sum(array_column($gdata, 'jnum'));
  1371. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1373. });
  1374. $x = array_sum(array_column($xdata, 'jnum'));
  1375. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1376. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1377. });
  1378. $t = array_sum(array_column($tdata, 'jnum'));
  1379. // $zdata = array_filter($qbdata, function ($item) {
  1380. // return $item['zd'] != "" && $item['state'] < 1;
  1381. // });
  1382. // $z = array_sum(array_column($zdata, '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. //$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');
  1388. //$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'].'"');
  1389. //$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'].'"');
  1390. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1391. //$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'].'"');
  1392. $details = array();
  1393. $cpid = array();
  1394. $od = array();
  1395. $odid = '';
  1396. $companytitle = '';
  1397. $shop_list = [];
  1398. foreach ($qbdata as $v) {
  1399. if ($v['zd'] != "" && $v['state'] < 1) {
  1400. if (!isset($od[$v['zd']])) {
  1401. $od[$v['zd']] = 1; //所有数据sku
  1402. } else {
  1403. $od[$v['zd']] = $od[$v['zd']] + 1;
  1404. }
  1405. }
  1406. if($v['state'] == 0){
  1407. $details[$v['details']] = $v['details'];
  1408. }
  1409. if ($v['state'] < 1) {
  1410. //$details[$v['details']] = $v['details'];
  1411. if ($v['cpid'] != 0) {
  1412. $cpid[$v['cpid']] = $v['cpid'];
  1413. }
  1414. }
  1415. if($v['state'] == 0){
  1416. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1417. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1418. }
  1419. if ($v['shop'] != '') {
  1420. $shop = explode(',', trim($v['shop'], ','));
  1421. foreach ($shop as $vv) {
  1422. if (!in_array($vv, $shop_list)) {
  1423. $shop_list[] = $vv;
  1424. }
  1425. }
  1426. }
  1427. }
  1428. }
  1429. foreach ($od as $k => $vv) {
  1430. $odid .= $k . '数量' . $vv;
  1431. }
  1432. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1433. $info_list[$key]['label'] = $value['sm'];
  1434. $number = $value['number'];
  1435. $ftime = time() - 15 * 24 * 3600;
  1436. $z = $z . '(' . $odid . ')'; //查看订单号
  1437. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1438. $info_list[$key]['features'] = $c;
  1439. $info_list[$key]['number'] = $ztdata;
  1440. $info_list[$key]['sm'] = $g;
  1441. $info_list[$key]['x'] = $x;
  1442. $info_list[$key]['t'] = $t;
  1443. $info_list[$key]['z'] = $z;
  1444. /**
  1445. foreach ($cdata as $k=>$v)
  1446. {
  1447. $details[$v['details']] = $v['details'];
  1448. if($v['cpid'] != 0)
  1449. {
  1450. $cpid[$v['cpid']] = $v['cpid'];
  1451. }
  1452. }
  1453. **/
  1454. $info_list[$key]['shop'] = '';
  1455. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1456. // if ($value['shop'] != '') {
  1457. // $shop = explode(',', trim($value['shop'], ','));
  1458. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1459. // }
  1460. $shop_list = array_unique($shop_list);
  1461. $shop_str = '';
  1462. foreach ($shop_list as $v) {
  1463. if(isset($sp[$v])){
  1464. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1465. }
  1466. }
  1467. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1468. /**
  1469. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1470. if(isset($companytitle[0]))
  1471. {
  1472. foreach ($companytitle as $k=>$v)
  1473. {
  1474. if($v['companytitle'] != '')
  1475. {
  1476. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1477. }
  1478. }
  1479. }
  1480. **/
  1481. }
  1482. $final_all_list = [];
  1483. foreach ($info_list as $k => $v) {
  1484. $final_all_list[] = [
  1485. 'id' => $v['id'],
  1486. "warehouse" => $v["warehouse"],
  1487. "purchase" => $v["purchase"],
  1488. "sku" => $v["sku"],
  1489. "title" => $v["title"] . "<br/>" . $v["pm"],
  1490. "details" => $v["details"],
  1491. "shop" => $v["shop"],
  1492. "cpbz" => $v["cpbz"],
  1493. 'label' => $v['label'],
  1494. "type" => $v["type"],
  1495. "features" => $v["features"],
  1496. "number" => $v["number"],
  1497. "sm" => $v["sm"],
  1498. "x" => $v["x"],
  1499. "t" => $v["t"],
  1500. "z" => $v["z"]
  1501. ];
  1502. }
  1503. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1504. $pagenum = ceil($total / $perpage);
  1505. $over = $total - ($start + $perpage);
  1506. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1507. echo json_encode($rows);
  1508. exit;
  1509. }
  1510. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1511. $this->data['shop'] = $wlshop;
  1512. $this->data['vip'] = $vip;
  1513. $this->_Template('whlabel_type', $this->data);
  1514. }
  1515. //美仓进销存浏览
  1516. public function _usatype()
  1517. {
  1518. if (isset($_SESSION['api'])) {
  1519. $user = $this->user->get_api($_SESSION['api']);
  1520. $usp = $user;
  1521. $fgshop = "";
  1522. $sid = "";
  1523. $wid = "";
  1524. $wtype = "";
  1525. $userwh = explode('|', trim($user['warehouse'], '|'));
  1526. foreach ($userwh as $value) {
  1527. $wid .= " id = " . $value . " or";
  1528. $wtype .= " type = " . $value . " or";
  1529. }
  1530. }
  1531. $prc = array();
  1532. $purchase = $this->purchase->find_all();
  1533. foreach ($purchase as $k => $v) {
  1534. $prc[$v['id']] = $v['title'];
  1535. }
  1536. $post = $this->input->post(NULL, TRUE);
  1537. if (isset($post['page'])) {
  1538. $page = $this->input->post('page', true);
  1539. $perpage = $this->input->post('perpage', true);
  1540. $category = $this->input->post('category', true);
  1541. $size = $this->input->post('size', true);
  1542. $grade = $this->input->post('grade', true);
  1543. $color = $this->input->post('color', true);
  1544. $lowe = $this->input->post('lowe', true);
  1545. $sku = $this->input->post('sku');
  1546. $title = $this->input->post('title');
  1547. $warehouse = $this->input->post('warehouse', true);
  1548. $usa = $this->input->post('usa', true);
  1549. $purchase = $this->input->post('purchase', true);
  1550. $lacetype = $this->input->post('lacetype', true);
  1551. $haircap = $this->input->post('haircap', true);
  1552. $density = $this->input->post('density', true);
  1553. $details = $this->input->post('details', true);
  1554. $state = $this->input->post('state', true);
  1555. $lacecolor = $this->input->post('lacecolor', true);
  1556. $cklx = $this->input->post('cklx', true);
  1557. $ktime = $this->input->post('ktime', true);
  1558. $jtime = $this->input->post('jtime', true);
  1559. $ktime = strtotime($ktime);
  1560. $jtime = strtotime($jtime);
  1561. $where = "1=1";
  1562. $gj = "";
  1563. $ck = "";
  1564. if ($lacetype) {
  1565. $where .= " and features like '%-$lacetype-%'";
  1566. }
  1567. if ($category) {
  1568. $where .= " and features like '%-$category-%'";
  1569. }
  1570. if ($size) {
  1571. $where .= " and features like '%-$size-%'";
  1572. }
  1573. if ($grade) {
  1574. $where .= " and features like '%-$grade-%'";
  1575. }
  1576. if ($color) {
  1577. $where .= " and features like '%-$color-%'";
  1578. }
  1579. if ($lowe) {
  1580. $where .= " and features like '%-$lowe-%'";
  1581. }
  1582. if ($haircap) {
  1583. $where .= " and features like '%-$haircap-%'";
  1584. }
  1585. if ($density) {
  1586. $where .= " and features like '%-$density-%'";
  1587. }
  1588. if ($lacecolor) {
  1589. $where .= " and features like '%-$lacecolor-%'";
  1590. }
  1591. if ($usa) {
  1592. if (!$warehouse) {
  1593. $where .= " and (warehouse = '5' or warehouse = '8')";
  1594. }
  1595. }
  1596. if ($warehouse) {
  1597. $where .= " and warehouse = '$warehouse'";
  1598. }
  1599. if ($details) {
  1600. $where .= " and details = '$details'";
  1601. }
  1602. if ($purchase) {
  1603. $where .= " and purchase = '$purchase'";
  1604. }
  1605. if ($state) {
  1606. $where .= " and state = '$state'";
  1607. }
  1608. $where_add = '';
  1609. if ($cklx) {
  1610. $shop = $this->shop->read($cklx);
  1611. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1612. }
  1613. if ($ktime && $jtime) {
  1614. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1615. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1616. }
  1617. //数据排序
  1618. $order_str = "id desc";
  1619. if (empty($page)) {
  1620. $start = 0;
  1621. $perpage = 1;
  1622. } else {
  1623. $start = ($page - 1) * $perpage;
  1624. }
  1625. if ($sku) {
  1626. $sku = trim($sku, ' ');
  1627. $sku = trim($sku, ' ');
  1628. $where .= " and sku like '%$sku%'";
  1629. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1630. } else if ($title) {
  1631. $title = trim($title, ' ');
  1632. $title = trim($title, ' ');
  1633. $where .= " and title like '%$title%'";
  1634. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1635. } else {
  1636. //$where .= " and time > '$ktime' and time < '$jtime'";
  1637. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1638. }
  1639. //取得信息列表
  1640. $rows = array();
  1641. $list = array();
  1642. foreach ($info_list as $key => $value) {
  1643. $warehouse = $this->warehouse->read($value['warehouse']);
  1644. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1645. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1646. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1647. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1648. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1649. $od = array();
  1650. $odid = '';
  1651. foreach ($z as $v) {
  1652. if (!isset($od[$v['zd']])) {
  1653. $od[$v['zd']] = 1; //所有数据sku
  1654. } else {
  1655. $od[$v['zd']] = $od[$v['zd']] + 1;
  1656. }
  1657. }
  1658. foreach ($od as $k => $vv) {
  1659. $odid .= $k . '数量' . $vv . ' ';
  1660. }
  1661. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1662. $info_list[$key]['features'] = $c;
  1663. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1664. $ztdata = '';
  1665. if (count($zt) > 0) {
  1666. foreach ($zt as $vv) {
  1667. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1668. }
  1669. }
  1670. $info_list[$key]['warehouse'] = $ztdata;
  1671. $info_list[$key]['g'] = $g;
  1672. $info_list[$key]['x'] = $x;
  1673. $info_list[$key]['t'] = $t;
  1674. $info_list[$key]['z'] = $z;
  1675. }
  1676. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1677. $pagenum = ceil($total / $perpage);
  1678. $over = $total - ($start + $perpage);
  1679. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1680. echo json_encode($rows);
  1681. exit;
  1682. }
  1683. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1684. $this->data['warehouse'] = $warehouse;
  1685. $this->_Template('whlabel_typeusa', $this->data);
  1686. }
  1687. //美仓进销存浏览
  1688. public function _usatypeapp()
  1689. {
  1690. $post = $this->input->post(NULL, TRUE);
  1691. if (isset($post['page'])) {
  1692. $page = $this->input->post('page', true);
  1693. $perpage = $this->input->post('perpage', true);
  1694. $sku = $this->input->post('sku', true);
  1695. $warehouse = 5;
  1696. $title = $this->input->post('title', true);
  1697. $state = $this->input->post('state', true);
  1698. $ktime = $this->input->post('ktime', true);
  1699. $jtime = $this->input->post('jtime', true);
  1700. $ktime = strtotime($ktime);
  1701. $jtime = strtotime($jtime);
  1702. $where = "1=1";
  1703. $gj = "";
  1704. $ck = "";
  1705. if ($title) {
  1706. $st = explode(' ', trim($title, ' '));
  1707. foreach ($st as $v) {
  1708. $where .= " and title like '%$v%'";
  1709. }
  1710. }
  1711. if ($warehouse) {
  1712. $where .= " and warehouse = '$warehouse'";
  1713. }
  1714. if ($state) {
  1715. $where .= " and state = '$state'";
  1716. }
  1717. if ($sku) {
  1718. $where .= " and sku like '%$sku%'";
  1719. }
  1720. if ($ktime && $jtime) {
  1721. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1722. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1723. }
  1724. //数据排序
  1725. $order_str = "id desc";
  1726. if (empty($page)) {
  1727. $start = 0;
  1728. $perpage = 1;
  1729. } else {
  1730. $start = ($page - 1) * $perpage;
  1731. }
  1732. //取得信息列表
  1733. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1734. $rows = array();
  1735. $list = array();
  1736. foreach ($info_list as $key => $value) {
  1737. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1738. }
  1739. $rowsdq = array_slice($rows, $start, $perpage);
  1740. foreach ($rowsdq as $value) {
  1741. $warehouse = $this->warehouse->read($value['warehouse']);
  1742. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1743. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1744. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1745. $od = array();
  1746. $odid = '';
  1747. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1748. }
  1749. $total = count($rows);
  1750. $pagenum = ceil($total / $perpage);
  1751. $over = $total - ($start + $perpage);
  1752. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1753. echo json_encode($rows);
  1754. exit;
  1755. }
  1756. $this->_Template('phone/p_usatypeapp', $this->data);
  1757. }
  1758. //入库操作
  1759. public function _enteradd()
  1760. {
  1761. $dt = 0;
  1762. if (isset($_SESSION['api'])) {
  1763. $user = $this->user->get_api($_SESSION['api']);
  1764. $usp = $user;
  1765. $fgshop = "";
  1766. $sid = "";
  1767. $user = explode('|', trim($user['shop'], '|'));
  1768. foreach ($user as $value) {
  1769. $fgshop .= " shop = " . $value . " or";
  1770. $sid .= " id = " . $value . " or";
  1771. }
  1772. }
  1773. $tc = $this->typeclass->find_all();
  1774. $typeclass = array();
  1775. foreach ($tc as $v) {
  1776. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1777. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1778. }
  1779. $post = $this->input->post(NULL, TRUE);
  1780. if (isset($post['sku'])) {
  1781. $list = array();
  1782. $num = "";
  1783. $title = "";
  1784. $features = "";
  1785. $order = $this->input->post('order', true);
  1786. $shop = $this->input->post('shop', true);
  1787. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1788. $sku = $this->input->post('sku', true);
  1789. $post['sm'] = $this->input->post('sm', true);
  1790. $post['warehouse'] = $this->input->post('warehouse', true);
  1791. $post['purchase'] = $this->input->post('purchase', true);
  1792. $post['retreatwarehouse'] = $post['warehouse'];
  1793. $post['state'] = $this->input->post('state', true);
  1794. $post['rktype'] = $this->input->post('rktype', true);
  1795. $post['text'] = $this->input->post('text', true);
  1796. $category = $this->input->post('category', true);
  1797. $list['category'] = $category;
  1798. $list['hairtype'] = $this->input->post('hairtype', true);
  1799. $list['grade'] = $this->input->post('grade', true);
  1800. $size = $this->input->post('size', true);
  1801. $xzsku = $this->input->post('xzsku', true);
  1802. $list['size'] = rtrim($size, ',');
  1803. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1804. $list['extension'] = $this->input->post('extension', true);
  1805. if ($category == 1297) {
  1806. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1807. }
  1808. if ($category == 1702) {
  1809. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1810. $list['syother'] = $this->input->post('syother', true);
  1811. }
  1812. if ($category == 133) {
  1813. $list['fittype'] = $this->input->post('fittype', true);
  1814. $list['acother'] = $this->input->post('acother', true);
  1815. }
  1816. $list['color'] = $this->input->post('color', true);
  1817. $list['lowe'] = $this->input->post('lowe', true);
  1818. if (!$post['purchase']) {
  1819. $post['purchase'] = 1;
  1820. }
  1821. if ($category == 127) {
  1822. $list['type'] = $this->input->post('type', true);
  1823. $list['headroad'] = $this->input->post('headroad', true);
  1824. $list['density'] = $this->input->post('density', true);
  1825. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1826. $list['lacesize'] = $this->input->post('lacesize', true);
  1827. }
  1828. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1829. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1830. }
  1831. if ($category == 128) {
  1832. $list['lacetype'] = $this->input->post('lacetype', true);
  1833. $list['haircap'] = $this->input->post('haircap', true);
  1834. $list['density'] = $this->input->post('density', true);
  1835. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1836. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1837. $list['wigother'] = $this->input->post('wigother', true);
  1838. $list['wigother1'] = $this->input->post('wigother1', true);
  1839. $list['wigother2'] = $this->input->post('wigother2', true);
  1840. $list['product_related'] = $this->input->post('product_related', true);
  1841. }
  1842. if ($category == 129) {
  1843. $list['wide'] = $this->input->post('wide', true);
  1844. }
  1845. if ($category == 131) {
  1846. $list['gifttype'] = $this->input->post('gifttype', true);
  1847. $list['giftother'] = $this->input->post('giftother', true);
  1848. }
  1849. if ($category == 134) {
  1850. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1851. }
  1852. if ($category == 1297) {
  1853. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1854. $list['sywigother'] = $this->input->post('sywigother', true);
  1855. }
  1856. if ($category == 130 || $category == 133 || $category == 1702) {
  1857. $list['items'] = $this->input->post('items', true);
  1858. $list['weight'] = $this->input->post('weight', true);
  1859. }
  1860. if($category == 130){
  1861. $list['jfother'] = $this->input->post('jfother', true);
  1862. }
  1863. if ($category == 1702) {
  1864. $list['syhairther'] = $this->input->post('syhairther', true);
  1865. }
  1866. $classid = $this->classid->sku();
  1867. $scsku = $classid;
  1868. $pm = $classid;
  1869. foreach ($list as $k => $v) {
  1870. if ($v != 0) {
  1871. $num .= $v;
  1872. $features .= $v . '-';
  1873. $post[$k] = $v;
  1874. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1875. if ($k != 'size') {
  1876. $title .= $typeclass[$v]['title'] . " ";
  1877. }
  1878. if (isset($pm[$typeclass[$v]['classid']])) {
  1879. if ($typeclass[$v]['title'] == '9A') {
  1880. $pm[$typeclass[$v]['classid']] = '9A';
  1881. } else if ($typeclass[$v]['title'] == '10A') {
  1882. $pm[$typeclass[$v]['classid']] = '10A';
  1883. } else {
  1884. $clzh = $typeclass[$v]['zh'];
  1885. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1886. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1887. $clzh = $clzh[0];
  1888. }
  1889. $pm[$typeclass[$v]['classid']] = $clzh;
  1890. }
  1891. }
  1892. }
  1893. }
  1894. $zh = implode(" ", $pm);
  1895. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1896. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1897. if ($list['size']) {
  1898. $typeclass = $this->typeclass->read($list['size']);
  1899. $title .= $typeclass['title'];
  1900. }
  1901. $time = time();
  1902. if ($xzsku) {
  1903. $scsku = implode("-", $scsku);
  1904. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1905. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1906. $post['sku'] = trim($scsku, ' ');
  1907. } else {
  1908. $post['sku'] = $sku;
  1909. }
  1910. //$post['sku'] = trim($sku,' ');
  1911. $post['title'] = rtrim($title, ' ');
  1912. $post['number'] = $num;
  1913. $post['features'] = '-' . $features;
  1914. $post['enter'] = $time;
  1915. $post['time'] = $time; //操作时间
  1916. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1917. if ($yza) {
  1918. if ($post['features'] != $yza[0]['features']) {
  1919. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1920. exit;
  1921. }
  1922. }
  1923. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1924. if ($yzb) {
  1925. if ($post['sku'] != $yzb[0]['sku']) {
  1926. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1927. exit;
  1928. }
  1929. }
  1930. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1931. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1932. exit;
  1933. }
  1934. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1935. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1936. exit;
  1937. }
  1938. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1939. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1940. exit;
  1941. }
  1942. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1943. if (isset($yz[0]['type'])) {
  1944. $post['type'] = $yz[0]['type'];
  1945. }
  1946. if ($post['state'] == 9) //如果选择预设库存
  1947. {
  1948. $this->whlabel->insert($post);
  1949. } else {
  1950. /**
  1951. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1952. if($ljg == 1)
  1953. {
  1954. for($i=0;$i<$order;$i++)
  1955. {
  1956. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1957. $this->whlabel->insert($post);
  1958. }
  1959. }
  1960. **/
  1961. //if($post['warehouse'] == '5')
  1962. //{
  1963. //}
  1964. $yydata = $post;
  1965. $yydata['zh'] = $zh;
  1966. /**
  1967. $wl = $this->apiyy->get_cjlp($yydata);
  1968. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1969. {
  1970. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1971. }
  1972. if($wl['Data'][0]['m_isSucess'] != 1)
  1973. {
  1974. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1975. }
  1976. **/
  1977. for ($i = 0; $i < $order; $i++) {
  1978. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1979. $this->whlabel->insert($post);
  1980. }
  1981. }
  1982. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1983. exit;
  1984. }
  1985. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1986. $this->data['wlshop'] = $wlshop;
  1987. $this->_Template('whlabel_enteradd', $this->data);
  1988. }
  1989. //修改产品
  1990. public function _enteredit($arg_array)
  1991. {
  1992. $dt = 0;
  1993. if (isset($_SESSION['api'])) {
  1994. $user = $this->user->get_api($_SESSION['api']);
  1995. $usp = $user;
  1996. $fgshop = "";
  1997. $sid = "";
  1998. $user = explode('|', trim($user['shop'], '|'));
  1999. foreach ($user as $value) {
  2000. $fgshop .= " shop = " . $value . " or";
  2001. $sid .= " id = " . $value . " or";
  2002. }
  2003. }
  2004. $post = $this->input->post(NULL, TRUE);
  2005. if (isset($post['sku'])) {
  2006. $list = array();
  2007. $num = "";
  2008. $title = "";
  2009. $features = "";
  2010. $id = $this->input->post('id', true);
  2011. $order = $this->input->post('order', true);
  2012. $shop = $this->input->post('shop', true);
  2013. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2014. $post['sku'] = $this->input->post('sku', true);
  2015. $post['sm'] = $this->input->post('sm', true);
  2016. $post['warehouse'] = $this->input->post('warehouse', true);
  2017. $post['purchase'] = $this->input->post('purchase', true);
  2018. $post['retreatwarehouse'] = $post['warehouse'];
  2019. $category = $this->input->post('category', true);
  2020. $list['category'] = $category;
  2021. $list['hairtype'] = $this->input->post('hairtype', true);
  2022. $list['grade'] = $this->input->post('grade', true);
  2023. $size = $this->input->post('size', true);
  2024. $list['size'] = rtrim($size, ',');
  2025. $post['rktype'] = $this->input->post('rktype', true);
  2026. $post['text'] = $this->input->post('text', true);
  2027. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2028. $list['extension'] = $this->input->post('extension', true);
  2029. if ($category == 1297) {
  2030. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2031. }
  2032. if ($category == 1702) {
  2033. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2034. $list['syother'] = $this->input->post('syother', true);
  2035. }
  2036. if ($category == 133) {
  2037. $list['fittype'] = $this->input->post('fittype', true);
  2038. $list['acother'] = $this->input->post('acother', true);
  2039. }
  2040. $list['color'] = $this->input->post('color', true);
  2041. $list['lowe'] = $this->input->post('lowe', true);
  2042. if (!$post['purchase']) {
  2043. $post['purchase'] = 1;
  2044. }
  2045. if ($category == 127) {
  2046. $list['type'] = $this->input->post('type', true);
  2047. $list['headroad'] = $this->input->post('headroad', true);
  2048. $list['density'] = $this->input->post('density', true);
  2049. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2050. $list['lacesize'] = $this->input->post('lacesize', true);
  2051. }
  2052. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2053. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2054. }
  2055. if ($category == 128) {
  2056. $list['lacetype'] = $this->input->post('lacetype', true);
  2057. $list['haircap'] = $this->input->post('haircap', true);
  2058. $list['density'] = $this->input->post('density', true);
  2059. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2060. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2061. $list['wigother'] = $this->input->post('wigother', true);
  2062. $list['wigother1'] = $this->input->post('wigother1', true);
  2063. $list['wigother2'] = $this->input->post('wigother2', true);
  2064. $list['product_related'] = $this->input->post('product_related', true);
  2065. }
  2066. if ($category == 129) {
  2067. $list['wide'] = $this->input->post('wide', true);
  2068. }
  2069. if ($category == 131) {
  2070. $list['gifttype'] = $this->input->post('gifttype', true);
  2071. $list['giftother'] = $this->input->post('giftother', true);
  2072. }
  2073. if ($category == 134) {
  2074. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2075. }
  2076. if ($category == 1297) {
  2077. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2078. $list['sywigother'] = $this->input->post('sywigother', true);
  2079. }
  2080. if ($category == 130 || $category == 133 || $category == 1702) {
  2081. $list['items'] = $this->input->post('items', true);
  2082. $list['weight'] = $this->input->post('weight', true);
  2083. }
  2084. if($category == 130){
  2085. $list['jfother'] = $this->input->post('jfother', true);
  2086. }
  2087. if ($category == 1702) {
  2088. $list['syhairther'] = $this->input->post('syhairther', true);
  2089. }
  2090. foreach ($list as $k => $v) {
  2091. if ($v != 0) {
  2092. $num .= $v;
  2093. $features .= $v . '-';
  2094. $typeclass = $this->typeclass->read($v);
  2095. if ($k != 'size') {
  2096. $title .= $typeclass['title'] . " ";
  2097. }
  2098. }
  2099. }
  2100. $typeclass = $this->typeclass->read($list['size']);
  2101. $title .= $typeclass['title'];
  2102. $time = time();
  2103. $post['title'] = rtrim($title, ' ');
  2104. $post['number'] = $num;
  2105. $post['features'] = '-' . $features;
  2106. $post['time'] = $time; //操作时间
  2107. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2108. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2109. exit;
  2110. }
  2111. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2112. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2113. exit;
  2114. }
  2115. $uid = $this->whlabel->read($id);
  2116. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2117. if ($datanum > 0) {
  2118. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2119. exit;
  2120. }
  2121. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2122. {
  2123. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2124. if ($yza) {
  2125. if ($post['features'] != $yza[0]['features']) {
  2126. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2127. exit;
  2128. }
  2129. }
  2130. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2131. if ($yzb) {
  2132. if ($post['sku'] != $yzb[0]['sku']) {
  2133. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2134. exit;
  2135. }
  2136. }
  2137. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2138. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2139. exit;
  2140. }
  2141. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2142. foreach ($data as $v) {
  2143. $post['id'] = $v['id'];
  2144. $this->whlabel->save($post, $v['id']);
  2145. }
  2146. } else {
  2147. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2148. if ($data > 0) {
  2149. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2150. exit;
  2151. } else {
  2152. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2153. foreach ($data as $v) {
  2154. $post['id'] = $v['id'];
  2155. $this->whlabel->save($post, $v['id']);
  2156. }
  2157. }
  2158. }
  2159. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2160. exit;
  2161. }
  2162. $uid = $this->whlabel->read($arg_array[0]);
  2163. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2164. $this->data['enter'] = $uid;
  2165. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2166. $this->data['wlshop'] = $wlshop;
  2167. $this->_Template('whlabel_enteredit', $this->data);
  2168. }
  2169. //入库浏览
  2170. public function _enter()
  2171. {
  2172. $post = $this->input->post(NULL, TRUE);
  2173. if (isset($post['s'])) {
  2174. $id_arr = $this->input->post('s');
  2175. $id_arr = explode(',', $id_arr);
  2176. if (!$id_arr) {
  2177. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2178. exit;
  2179. }
  2180. //循环删除记录
  2181. foreach ($id_arr as $v) {
  2182. $sid = $this->whlabel->read($v);
  2183. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2184. if ($count > 0) {
  2185. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2186. exit;
  2187. }
  2188. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2189. foreach ($info_list as $va) {
  2190. $this->whlabel->remove($va['id']);
  2191. }
  2192. }
  2193. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2194. exit;
  2195. }
  2196. $sp = array();
  2197. $s = $this->shop->find_all('1=1', 'id,shopname');
  2198. foreach ($s as $v) {
  2199. $sp[$v['id']] = $v['shopname'];
  2200. }
  2201. $wh = array();
  2202. $w = $this->warehouse->find_all('1=1', 'id,title');
  2203. foreach ($w as $v) {
  2204. $wh[$v['id']] = $v['title'];
  2205. }
  2206. if (isset($post['page'])) {
  2207. $page = $this->input->post('page', true);
  2208. $perpage = $this->input->post('perpage', true);
  2209. $category = $this->input->post('category', true);
  2210. $size = $this->input->post('size', true);
  2211. $grade = $this->input->post('grade', true);
  2212. $color = $this->input->post('color', true);
  2213. $lowe = $this->input->post('lowe', true);
  2214. $sku = $this->input->post('sku', true);
  2215. $warehouse = $this->input->post('warehouse', true);
  2216. $purchase = $this->input->post('purchase', true);
  2217. $ktime = $this->input->post('ktime', true);
  2218. $jtime = $this->input->post('jtime', true);
  2219. $ktime = strtotime($ktime);
  2220. $jtime = strtotime($jtime);
  2221. $where = "1=1";
  2222. $gj = "";
  2223. $ck = "";
  2224. if ($category) {
  2225. $where .= " and features like '%-$category-%'";
  2226. }
  2227. if ($size) {
  2228. $where .= " and features like '%-$size-%'";
  2229. }
  2230. if ($grade) {
  2231. $where .= " and features like '%-$grade-%'";
  2232. }
  2233. if ($color) {
  2234. $where .= " and features like '%-$color-%'";
  2235. }
  2236. if ($lowe) {
  2237. $where .= " and features like '%-$lowe-%'";
  2238. }
  2239. if ($warehouse) {
  2240. $where .= " and warehouse = '$warehouse'";
  2241. }
  2242. if ($purchase) {
  2243. $where .= " and purchase = '$purchase'";
  2244. }
  2245. if ($sku) {
  2246. $where .= " and sku like '%$sku%'";
  2247. }
  2248. if ($ktime && $jtime) {
  2249. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2250. }
  2251. //数据排序
  2252. $order_str = "enter desc";
  2253. if (empty($page)) {
  2254. $start = 0;
  2255. $perpage = 1;
  2256. } else {
  2257. $start = ($page - 1) * $perpage;
  2258. }
  2259. //取得信息列表
  2260. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2261. foreach ($info_list as $k => $v) {
  2262. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2263. if ($v['shop'] == '') {
  2264. $s = '通用';
  2265. } else {
  2266. $info_list[$k]['shop'] = '';
  2267. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2268. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2269. }
  2270. }
  2271. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2272. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2273. $info_list[$k]['g'] = $g;
  2274. }
  2275. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2276. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2277. $pagenum = ceil($total / $perpage);
  2278. $over = $total - ($start + $perpage);
  2279. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2280. echo json_encode($rows);
  2281. exit;
  2282. }
  2283. $this->_Template('whlabel_enter', $this->data);
  2284. }
  2285. //出库浏览
  2286. public function _out()
  2287. {
  2288. $post = $this->input->post(NULL, TRUE);
  2289. if (isset($post['page'])) {
  2290. $page = $this->input->post('page', true);
  2291. $perpage = $this->input->post('perpage', true);
  2292. $category = $this->input->post('category', true);
  2293. $size = $this->input->post('size', true);
  2294. $grade = $this->input->post('grade', true);
  2295. $color = $this->input->post('color', true);
  2296. $lowe = $this->input->post('lowe', true);
  2297. $sku = $this->input->post('sku', true);
  2298. $warehouse = $this->input->post('warehouse', true);
  2299. $purchase = $this->input->post('purchase', true);
  2300. $state = $this->input->post('state', true);
  2301. $ktime = $this->input->post('ktime', true);
  2302. $jtime = $this->input->post('jtime', true);
  2303. $ktime = strtotime($ktime);
  2304. $jtime = strtotime($jtime);
  2305. $where = "state=3";
  2306. $gj = "";
  2307. $ck = "";
  2308. if ($category) {
  2309. $where .= " and features like '%-$category-%'";
  2310. }
  2311. if ($size) {
  2312. $where .= " and features like '%-$size-%'";
  2313. }
  2314. if ($grade) {
  2315. $where .= " and features like '%-$grade-%'";
  2316. }
  2317. if ($color) {
  2318. $where .= " and features like '%-$color-%'";
  2319. }
  2320. if ($lowe) {
  2321. $where .= " and features like '%-$lowe-%'";
  2322. }
  2323. if ($state) {
  2324. $where .= " and state = '$state'";
  2325. }
  2326. if ($warehouse) {
  2327. $where .= " and warehouse = '$warehouse'";
  2328. }
  2329. if ($purchase) {
  2330. $where .= " and purchase = '$purchase'";
  2331. }
  2332. if ($sku) {
  2333. $where .= " and sku = '$sku'";
  2334. }
  2335. if ($ktime && $jtime) {
  2336. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2337. }
  2338. //数据排序
  2339. $order_str = "id desc";
  2340. if (empty($page)) {
  2341. $start = 0;
  2342. $perpage = 1;
  2343. } else {
  2344. $start = ($page - 1) * $perpage;
  2345. }
  2346. //取得信息列表
  2347. $info_list = $this->whlabel->find_all($where, 'sku');
  2348. $rows = array();
  2349. $list = array();
  2350. foreach ($info_list as $key => $value) {
  2351. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2352. }
  2353. $rows = array_unique($rows); //删除重复记录
  2354. foreach ($rows as $key => $value) {
  2355. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2356. $ck = $this->warehouse->read($data['warehouse']);
  2357. $warehouse = $ck['title'];
  2358. $gy = $this->purchase->read($data['purchase']);
  2359. $purchase = $gy['purchase'];
  2360. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2361. $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);
  2362. }
  2363. $total = count($list);
  2364. $pagenum = ceil($total / $perpage);
  2365. $over = $total - ($start + $perpage);
  2366. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2367. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2368. echo json_encode($rows);
  2369. exit;
  2370. }
  2371. $this->_Template('whlabel_out', $this->data);
  2372. }
  2373. //出库标签浏览
  2374. public function _label()
  2375. {
  2376. $post = $this->input->post(NULL, TRUE);
  2377. if (isset($post['page'])) {
  2378. $page = $this->input->post('page', true);
  2379. $perpage = $this->input->post('perpage', true);
  2380. $sku = $this->input->post('sku', true);
  2381. $warehouse = $this->input->post('warehouse', true);
  2382. $purchase = $this->input->post('purchase', true);
  2383. $orderinfo = $this->input->post('orderinfo', true);
  2384. $waybill = $this->input->post('waybill', true);
  2385. $category = $this->input->post('category', true);
  2386. $size = $this->input->post('size', true);
  2387. $grade = $this->input->post('grade', true);
  2388. $color = $this->input->post('color', true);
  2389. $lowe = $this->input->post('lowe', true);
  2390. $where = "state=1";
  2391. if ($sku) {
  2392. $where .= " and sku = '$sku'";
  2393. }
  2394. if ($warehouse) {
  2395. $where .= " and warehouse = '$warehouse'";
  2396. }
  2397. if ($purchase) {
  2398. $where .= " and purchase = '$purchase'";
  2399. }
  2400. if ($orderinfo) {
  2401. $where .= " and orderinfo = '$orderinfo'";
  2402. }
  2403. if ($waybill) {
  2404. $where .= " and waybill = '$waybill'";
  2405. }
  2406. if ($category) {
  2407. $where .= " and features like '%-$category-%'";
  2408. }
  2409. if ($size) {
  2410. $where .= " and features like '%-$size-%'";
  2411. }
  2412. if ($grade) {
  2413. $where .= " and features like '%-$grade-%'";
  2414. }
  2415. if ($color) {
  2416. $where .= " and features like '%-$color-%'";
  2417. }
  2418. if ($lowe) {
  2419. $where .= " and features like '%-$lowe-%'";
  2420. }
  2421. //数据排序
  2422. $order_str = "outk desc";
  2423. if (empty($page)) {
  2424. $start = 0;
  2425. $perpage = 1;
  2426. } else {
  2427. $start = ($page - 1) * $perpage;
  2428. }
  2429. //取得信息列表
  2430. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2431. foreach ($info_list as $key => $value) {
  2432. $warehouse = $this->warehouse->read($value['warehouse']);
  2433. $info_list[$key]['warehouse'] = $warehouse['title'];
  2434. $purchase = $this->purchase->read($value['purchase']);
  2435. $info_list[$key]['purchase'] = $purchase['title'];
  2436. if ($value['outk'] != 0) {
  2437. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2438. } else {
  2439. $info_list[$key]['outk'] = "";
  2440. }
  2441. if ($value['orderinfo'] == 0) {
  2442. $info_list[$key]['orderinfo'] = "";
  2443. }
  2444. if ($value['waybill'] == 0) {
  2445. $info_list[$key]['waybill'] = "";
  2446. }
  2447. }
  2448. $total = $this->whlabel->find_count($where);
  2449. $pagenum = ceil($total / $perpage);
  2450. $over = $total - ($start + $perpage);
  2451. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2452. echo json_encode($rows);
  2453. exit;
  2454. }
  2455. $this->_Template('whlabel_label', $this->data);
  2456. }
  2457. //独立站出库订单
  2458. public function _outorder()
  2459. {
  2460. if (isset($_SESSION['api'])) {
  2461. $user = $this->user->get_api($_SESSION['api']);
  2462. $usp = $user;
  2463. $fgshop = "";
  2464. $sid = "";
  2465. $user = explode('|', trim($user['shop'], '|'));
  2466. foreach ($user as $value) {
  2467. $fgshop .= " shop = " . $value . " or";
  2468. $sid .= " id = " . $value . " or";
  2469. }
  2470. } else {
  2471. echo "请重新登录";
  2472. }
  2473. $post = $this->input->post(NULL, TRUE);
  2474. if (isset($post['page'])) {
  2475. $page = $this->input->post('page', true);
  2476. $perpage = $this->input->post('perpage', true);
  2477. $warehouse = $this->input->post('warehouse', true);
  2478. $xztime = $this->input->post('xztime', true);
  2479. $timetk = $this->input->post('timetkk', true);
  2480. $timetj = $this->input->post('timetjj', true);
  2481. $shop = $this->input->post('shop', true);
  2482. $source = $this->input->post('source', true);
  2483. $orderinfo = $this->input->post('orderinfo', true);
  2484. $number = $this->input->post('number', true);
  2485. $sfxh = $this->input->post('sfxh', true);
  2486. $express = $this->input->post('express', true);
  2487. $waybill = $this->input->post('waybill', true);
  2488. $library = $this->input->post('library', true);
  2489. $country = $this->input->post('country', true);
  2490. $so = $this->input->post('so', true);
  2491. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2492. $print = $this->input->post('print', true);
  2493. $state = $this->input->post('state', true);
  2494. $orderurl = $this->input->post('orderurl', true);
  2495. $productid = $this->input->post('productid', true);
  2496. $timetk = strtotime($timetk);
  2497. $timetj = strtotime($timetj);
  2498. /**
  2499. $sj = $this->input->post('sj',true);
  2500. if($sj)
  2501. {
  2502. $sj = $this->input->post('sj',true);
  2503. }
  2504. else
  2505. {
  2506. $sj = "fullorder";
  2507. }
  2508. **/
  2509. $sj = "fullorder";
  2510. $where = "1=1";
  2511. if ($warehouse) {
  2512. $where .= " and type = '$warehouse'";
  2513. }
  2514. if ($timetk && $timetj) {
  2515. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2516. }
  2517. if ($orderinfo) {
  2518. $where .= " and orderinfo = '$orderinfo'";
  2519. }
  2520. if ($number) {
  2521. $where .= " and number = '$number'";
  2522. }
  2523. if ($express) {
  2524. $where .= " and express = '$express'";
  2525. }
  2526. if ($waybill) {
  2527. $where .= " and waybill = '$waybill'";
  2528. }
  2529. if ($library) {
  2530. $where .= " and library = '$library'";
  2531. }
  2532. if ($print) {
  2533. $where .= " and print = '$print'";
  2534. }
  2535. if ($libraryconfirm) {
  2536. $where .= " and libraryconfirm = '$libraryconfirm'";
  2537. }
  2538. if ($state) {
  2539. $where .= " and state = '$state'";
  2540. }
  2541. if ($shop) {
  2542. $where .= " and shop = '$shop'";
  2543. }
  2544. if ($country) {
  2545. $where .= " and country = '$country'";
  2546. }
  2547. if ($sfxh != '') {
  2548. $where .= " and sfxh = '$sfxh'";
  2549. }
  2550. if ($so) {
  2551. $where .= " and shipremarks like '%$so%'";
  2552. }
  2553. if ($source) {
  2554. if ($source == '2d') {
  2555. $where .= " and source >= '2'";
  2556. } else {
  2557. $where .= " and source = '$source'";
  2558. }
  2559. }
  2560. if (isset($_SESSION['api'])) {
  2561. foreach ($user as $value) {
  2562. $fgshop .= " shop = " . $value . " or";
  2563. }
  2564. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2565. }
  2566. if ($orderurl) {
  2567. $url = $this->orderurl->read($orderurl);
  2568. $where .= " and link like '%" . $url['url'] . "%'";
  2569. }
  2570. if($productid){
  2571. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2572. }
  2573. //数据排序
  2574. $order_str = "librarytime desc";
  2575. if (empty($page)) {
  2576. $start = 0;
  2577. $perpage = 1;
  2578. } else {
  2579. $start = ($page - 1) * $perpage;
  2580. }
  2581. //取得信息列表
  2582. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2583. //格式化数据
  2584. foreach ($info_list as $key => $value) {
  2585. $shop = $this->shop->read($value['shop']);
  2586. $info_list[$key]['shop'] = $shop['shopname'];
  2587. $express = $this->express->read($value['express']);
  2588. $info_list[$key]['express'] = $express['servicename'];
  2589. $warehouse = $this->warehouse->read($value['type']);
  2590. $info_list[$key]['type'] = $warehouse['title'];
  2591. if ($value['librarytime'] == '0') {
  2592. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2593. } else {
  2594. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2595. }
  2596. }
  2597. $total = $this->$sj->find_count($where);
  2598. $pagenum = ceil($total / $perpage);
  2599. $over = $total - ($start + $perpage);
  2600. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2601. echo json_encode($rows);
  2602. exit;
  2603. }
  2604. $this->data['express'] = $this->express->find_all();
  2605. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2606. $this->data['wlshop'] = $wlshop;
  2607. $user = $this->user->get_api($_SESSION['api']);
  2608. $powerid = $this->power->read($user['power']);
  2609. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2610. $pid = '';
  2611. foreach ($powertext as $v) {
  2612. $pid .= " id = " . $v . " or";
  2613. }
  2614. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2615. $this->data['fullorderexcel'] = $fullorderexcel;
  2616. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2617. $this->data['orderurl'] = $orderurl;
  2618. $this->_Template('whlabel_outorder', $this->data);
  2619. }
  2620. //tt出库
  2621. public function _toutorder()
  2622. {
  2623. $fgshop = "";
  2624. $sid = "";
  2625. if (isset($_SESSION['api'])) {
  2626. $user = $this->user->get_api($_SESSION['api']);
  2627. $usp = $user;
  2628. $user = explode('|', trim($user['shop'], '|'));
  2629. foreach ($user as $value) {
  2630. $fgshop .= " shop = " . $value . " or";
  2631. $sid .= " id = " . $value . " or";
  2632. }
  2633. } else {
  2634. echo "请重新登录";
  2635. die;
  2636. }
  2637. $post = $this->input->post(NULL, TRUE);
  2638. if (isset($post['page'])) {
  2639. $page = $this->input->post('page', true);
  2640. $perpage = $this->input->post('perpage', true);
  2641. $warehouse = $this->input->post('warehouse', true);
  2642. $xztime = $this->input->post('xztime', true);
  2643. $timetk = $this->input->post('timetkk', true);
  2644. $timetj = $this->input->post('timetjj', true);
  2645. $shop = $this->input->post('shop', true);
  2646. $source = $this->input->post('source', true);
  2647. $orderinfo = $this->input->post('orderinfo', true);
  2648. $number = $this->input->post('number', true);
  2649. $sfxh = $this->input->post('sfxh', true);
  2650. $express = $this->input->post('express', true);
  2651. $waybill = $this->input->post('waybill', true);
  2652. $library = $this->input->post('library', true);
  2653. $country = $this->input->post('country', true);
  2654. $so = $this->input->post('so', true);
  2655. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2656. $print = $this->input->post('print', true);
  2657. $state = $this->input->post('state', true);
  2658. $orderurl = $this->input->post('orderurl', true);
  2659. $timetk = strtotime($timetk);
  2660. $timetj = strtotime($timetj);
  2661. /**
  2662. $sj = $this->input->post('sj',true);
  2663. if($sj)
  2664. {
  2665. $sj = $this->input->post('sj',true);
  2666. }
  2667. else
  2668. {
  2669. $sj = "fullorder";
  2670. }
  2671. **/
  2672. $sj = "fullordertt";
  2673. $where = "1=1";
  2674. if ($warehouse) {
  2675. $where .= " and type = '$warehouse'";
  2676. }
  2677. if ($timetk && $timetj) {
  2678. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2679. }
  2680. if ($orderinfo) {
  2681. $where .= " and orderinfo = '$orderinfo'";
  2682. }
  2683. if ($number) {
  2684. $where .= " and number = '$number'";
  2685. }
  2686. if ($express) {
  2687. $where .= " and express = '$express'";
  2688. }
  2689. if ($waybill) {
  2690. $where .= " and waybill = '$waybill'";
  2691. }
  2692. if ($library) {
  2693. $where .= " and library = '$library'";
  2694. }
  2695. if ($print) {
  2696. $where .= " and print = '$print'";
  2697. }
  2698. if ($libraryconfirm) {
  2699. $where .= " and libraryconfirm = '$libraryconfirm'";
  2700. }
  2701. if ($state) {
  2702. $where .= " and state = '$state'";
  2703. }
  2704. if ($shop) {
  2705. $where .= " and shop = '$shop'";
  2706. }
  2707. if ($country) {
  2708. $where .= " and country = '$country'";
  2709. }
  2710. if ($sfxh != '') {
  2711. $where .= " and sfxh = '$sfxh'";
  2712. }
  2713. if ($so) {
  2714. $where .= " and shipremarks like '%$so%'";
  2715. }
  2716. if ($source) {
  2717. if ($source == '2d') {
  2718. $where .= " and source >= '2'";
  2719. } else {
  2720. $where .= " and source = '$source'";
  2721. }
  2722. }
  2723. if (isset($_SESSION['api'])) {
  2724. foreach ($user as $value) {
  2725. $fgshop .= " shop = " . $value . " or";
  2726. }
  2727. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2728. }
  2729. if ($orderurl) {
  2730. $url = $this->orderurl->read($orderurl);
  2731. $where .= " and link like '%" . $url['url'] . "%'";
  2732. }
  2733. //数据排序
  2734. $order_str = "librarytime desc";
  2735. if (empty($page)) {
  2736. $start = 0;
  2737. $perpage = 1;
  2738. } else {
  2739. $start = ($page - 1) * $perpage;
  2740. }
  2741. //取得信息列表
  2742. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2743. //格式化数据
  2744. foreach ($info_list as $key => $value) {
  2745. $shop = $this->shop->read($value['shop']);
  2746. $info_list[$key]['shop'] = $shop['shopname'];
  2747. $express = $this->express->read($value['express']);
  2748. $info_list[$key]['express'] = $express['servicename'];
  2749. $warehouse = $this->warehouse->read($value['type']);
  2750. $info_list[$key]['type'] = $warehouse['title'];
  2751. if ($value['librarytime'] == '0') {
  2752. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2753. } else {
  2754. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2755. }
  2756. }
  2757. $total = $this->$sj->find_count($where);
  2758. $pagenum = ceil($total / $perpage);
  2759. $over = $total - ($start + $perpage);
  2760. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2761. echo json_encode($rows);
  2762. exit;
  2763. }
  2764. $this->data['express'] = $this->express->find_all();
  2765. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2766. $this->data['wlshop'] = $wlshop;
  2767. $user = $this->user->get_api($_SESSION['api']);
  2768. $powerid = $this->power->read($user['power']);
  2769. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2770. $pid = '';
  2771. foreach ($powertext as $v) {
  2772. $pid .= " id = " . $v . " or";
  2773. }
  2774. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2775. $this->data['fullorderexcel'] = $fullorderexcel;
  2776. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2777. $this->data['orderurl'] = $orderurl;
  2778. $this->_Template('whlabel_toutorder', $this->data);
  2779. }
  2780. //tt出库
  2781. public function _aoutorder()
  2782. {
  2783. if (isset($_SESSION['api'])) {
  2784. $user = $this->user->get_api($_SESSION['api']);
  2785. $usp = $user;
  2786. $fgshop = "";
  2787. $sid = "";
  2788. $user = explode('|', trim($user['shop'], '|'));
  2789. foreach ($user as $value) {
  2790. $fgshop .= " shop = " . $value . " or";
  2791. $sid .= " id = " . $value . " or";
  2792. }
  2793. } else {
  2794. echo "请重新登录";
  2795. }
  2796. $post = $this->input->post(NULL, TRUE);
  2797. if (isset($post['page'])) {
  2798. $page = $this->input->post('page', true);
  2799. $perpage = $this->input->post('perpage', true);
  2800. $warehouse = $this->input->post('warehouse', true);
  2801. $xztime = $this->input->post('xztime', true);
  2802. $timetk = $this->input->post('timetkk', true);
  2803. $timetj = $this->input->post('timetjj', true);
  2804. $shop = $this->input->post('shop', true);
  2805. $source = $this->input->post('source', true);
  2806. $orderinfo = $this->input->post('orderinfo', true);
  2807. $number = $this->input->post('number', true);
  2808. $sfxh = $this->input->post('sfxh', true);
  2809. $express = $this->input->post('express', true);
  2810. $waybill = $this->input->post('waybill', true);
  2811. $library = $this->input->post('library', true);
  2812. $country = $this->input->post('country', true);
  2813. $so = $this->input->post('so', true);
  2814. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2815. $print = $this->input->post('print', true);
  2816. $state = $this->input->post('state', true);
  2817. $orderurl = $this->input->post('orderurl', true);
  2818. $timetk = strtotime($timetk);
  2819. $timetj = strtotime($timetj);
  2820. /**
  2821. $sj = $this->input->post('sj',true);
  2822. if($sj)
  2823. {
  2824. $sj = $this->input->post('sj',true);
  2825. }
  2826. else
  2827. {
  2828. $sj = "fullorder";
  2829. }
  2830. **/
  2831. $sj = "fullorderamz";
  2832. $where = "1=1";
  2833. if ($warehouse) {
  2834. $where .= " and type = '$warehouse'";
  2835. }
  2836. if ($timetk && $timetj) {
  2837. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2838. }
  2839. if ($orderinfo) {
  2840. $where .= " and orderinfo = '$orderinfo'";
  2841. }
  2842. if ($number) {
  2843. $where .= " and number = '$number'";
  2844. }
  2845. if ($express) {
  2846. $where .= " and express = '$express'";
  2847. }
  2848. if ($waybill) {
  2849. $where .= " and waybill = '$waybill'";
  2850. }
  2851. if ($library) {
  2852. $where .= " and library = '$library'";
  2853. }
  2854. if ($print) {
  2855. $where .= " and print = '$print'";
  2856. }
  2857. if ($libraryconfirm) {
  2858. $where .= " and libraryconfirm = '$libraryconfirm'";
  2859. }
  2860. if ($state) {
  2861. $where .= " and state = '$state'";
  2862. }
  2863. if ($shop) {
  2864. $where .= " and shop = '$shop'";
  2865. }
  2866. if ($country) {
  2867. $where .= " and country = '$country'";
  2868. }
  2869. if ($sfxh != '') {
  2870. $where .= " and sfxh = '$sfxh'";
  2871. }
  2872. if ($so) {
  2873. $where .= " and shipremarks like '%$so%'";
  2874. }
  2875. if ($source) {
  2876. if ($source == '2d') {
  2877. $where .= " and source >= '2'";
  2878. } else {
  2879. $where .= " and source = '$source'";
  2880. }
  2881. }
  2882. if (isset($_SESSION['api'])) {
  2883. foreach ($user as $value) {
  2884. $fgshop .= " shop = " . $value . " or";
  2885. }
  2886. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2887. }
  2888. if ($orderurl) {
  2889. $url = $this->orderurl->read($orderurl);
  2890. $where .= " and link like '%" . $url['url'] . "%'";
  2891. }
  2892. //数据排序
  2893. $order_str = "librarytime desc";
  2894. if (empty($page)) {
  2895. $start = 0;
  2896. $perpage = 1;
  2897. } else {
  2898. $start = ($page - 1) * $perpage;
  2899. }
  2900. //取得信息列表
  2901. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2902. //格式化数据
  2903. foreach ($info_list as $key => $value) {
  2904. $shop = $this->shop->read($value['shop']);
  2905. $info_list[$key]['shop'] = $shop['shopname'];
  2906. $express = $this->express->read($value['express']);
  2907. $info_list[$key]['express'] = $express['servicename'];
  2908. $warehouse = $this->warehouse->read($value['type']);
  2909. $info_list[$key]['type'] = $warehouse['title'];
  2910. if ($value['librarytime'] == '0') {
  2911. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2912. } else {
  2913. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2914. }
  2915. }
  2916. $total = $this->$sj->find_count($where);
  2917. $pagenum = ceil($total / $perpage);
  2918. $over = $total - ($start + $perpage);
  2919. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2920. echo json_encode($rows);
  2921. exit;
  2922. }
  2923. $this->data['express'] = $this->express->find_all();
  2924. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2925. $this->data['wlshop'] = $wlshop;
  2926. $user = $this->user->get_api($_SESSION['api']);
  2927. $powerid = $this->power->read($user['power']);
  2928. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2929. $pid = '';
  2930. foreach ($powertext as $v) {
  2931. $pid .= " id = " . $v . " or";
  2932. }
  2933. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2934. $this->data['fullorderexcel'] = $fullorderexcel;
  2935. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2936. $this->data['orderurl'] = $orderurl;
  2937. $this->_Template('whlabel_aoutorder', $this->data);
  2938. }
  2939. //速卖通出库订单
  2940. public function _soutorder()
  2941. {
  2942. if (isset($_SESSION['api'])) {
  2943. $user = $this->user->get_api($_SESSION['api']);
  2944. $usp = $user;
  2945. $fgshop = "";
  2946. $sid = "";
  2947. $user = explode('|', trim($user['shop'], '|'));
  2948. foreach ($user as $value) {
  2949. $sid .= " id = " . $value . " or";
  2950. }
  2951. }
  2952. $post = $this->input->post(NULL, TRUE);
  2953. if (isset($post['page'])) {
  2954. $page = $this->input->post('page', true);
  2955. $perpage = $this->input->post('perpage', true);
  2956. $warehouse = $this->input->post('warehouse', true);
  2957. $xztime = $this->input->post('xztime', true);
  2958. $timetk = $this->input->post('timetkk', true);
  2959. $timetj = $this->input->post('timetjj', true);
  2960. $shop = $this->input->post('shop', true);
  2961. $source = $this->input->post('source', true);
  2962. $orderinfo = $this->input->post('orderinfo', true);
  2963. $number = $this->input->post('number', true);
  2964. $express = $this->input->post('express', true);
  2965. $waybill = $this->input->post('waybill', true);
  2966. $library = $this->input->post('library', true);
  2967. $country = $this->input->post('country', true);
  2968. $sfxh = $this->input->post('sfxh', true);
  2969. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2970. $print = $this->input->post('print', true);
  2971. $state = $this->input->post('state', true);
  2972. $so = $this->input->post('so', true);
  2973. $timetk = strtotime($timetk);
  2974. $timetj = strtotime($timetj);
  2975. /**
  2976. $sj = $this->input->post('sj',true);
  2977. if($sj)
  2978. {
  2979. $sj = $this->input->post('sj',true);
  2980. }
  2981. else
  2982. {
  2983. $sj = "fullorder";
  2984. }
  2985. **/
  2986. $sj = "fullordersmt";
  2987. $where = "1=1";
  2988. if ($warehouse) {
  2989. $where .= " and type = '$warehouse'";
  2990. }
  2991. if ($timetk && $timetj) {
  2992. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2993. }
  2994. if ($orderinfo) {
  2995. $where .= " and orderinfo = '$orderinfo'";
  2996. }
  2997. if ($number) {
  2998. $where .= " and number = '$number'";
  2999. }
  3000. if ($express) {
  3001. $where .= " and express = '$express'";
  3002. }
  3003. if ($waybill) {
  3004. $where .= " and waybill = '$waybill'";
  3005. }
  3006. if ($library) {
  3007. $where .= " and library = '$library'";
  3008. }
  3009. if ($print) {
  3010. $where .= " and print = '$print'";
  3011. }
  3012. if ($libraryconfirm) {
  3013. $where .= " and libraryconfirm = '$libraryconfirm'";
  3014. }
  3015. if ($state) {
  3016. $where .= " and state = '$state'";
  3017. }
  3018. if ($shop) {
  3019. $where .= " and shop = '$shop'";
  3020. }
  3021. if ($sfxh != '') {
  3022. $where .= " and sfxh = '$sfxh'";
  3023. }
  3024. if ($so) {
  3025. $where .= " and shipremarks like '%$so%'";
  3026. }
  3027. if ($source) {
  3028. $where .= " and source = '$source'";
  3029. }
  3030. if ($country) {
  3031. $where .= " and country = '$country'";
  3032. } else {
  3033. if (isset($_SESSION['api'])) {
  3034. foreach ($user as $value) {
  3035. $fgshop .= " shop = " . $value . " or";
  3036. }
  3037. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3038. }
  3039. }
  3040. //数据排序
  3041. $order_str = "librarytime desc";
  3042. if (empty($page)) {
  3043. $start = 0;
  3044. $perpage = 1;
  3045. } else {
  3046. $start = ($page - 1) * $perpage;
  3047. }
  3048. //取得信息列表
  3049. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3050. //格式化数据
  3051. foreach ($info_list as $key => $value) {
  3052. $shop = $this->shop->read($value['shop']);
  3053. $info_list[$key]['shop'] = $shop['shopname'];
  3054. $express = $this->express->read($value['express']);
  3055. $info_list[$key]['express'] = $express['servicename'];
  3056. $warehouse = $this->warehouse->read($value['type']);
  3057. $info_list[$key]['type'] = $warehouse['title'];
  3058. if ($value['librarytime'] == '0') {
  3059. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3060. } else {
  3061. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3062. }
  3063. }
  3064. $total = $this->$sj->find_count($where);
  3065. $pagenum = ceil($total / $perpage);
  3066. $over = $total - ($start + $perpage);
  3067. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3068. echo json_encode($rows);
  3069. exit;
  3070. }
  3071. $this->data['express'] = $this->express->find_all();
  3072. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3073. $this->data['wlshop'] = $wlshop;
  3074. $user = $this->user->get_api($_SESSION['api']);
  3075. $powerid = $this->power->read($user['power']);
  3076. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3077. $pid = '';
  3078. foreach ($powertext as $v) {
  3079. $pid .= " id = " . $v . " or";
  3080. }
  3081. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3082. $this->data['fullorderexcel'] = $fullorderexcel;
  3083. $this->_Template('whlabel_soutorder', $this->data);
  3084. }
  3085. //订单退库
  3086. public function _retreat()
  3087. {
  3088. $post = $this->input->post(NULL, TRUE);
  3089. if (isset($post['page'])) {
  3090. $page = $this->input->post('page', true);
  3091. $perpage = $this->input->post('perpage', true);
  3092. $warehouse = $this->input->post('warehouse', true);
  3093. $timetk = $this->input->post('timetk', true);
  3094. $timetj = $this->input->post('timetj', true);
  3095. $shop = $this->input->post('shop', true);
  3096. $source = $this->input->post('source', true);
  3097. $state = $this->input->post('state', true);
  3098. $review = $this->input->post('review', true);
  3099. $state = $this->input->post('state', true);
  3100. $express = $this->input->post('express', true);
  3101. $orderinfo = $this->input->post('orderinfo', true);
  3102. $user = $this->input->post('user', true);
  3103. $name = $this->input->post('name', true);
  3104. $waybill = $this->input->post('waybill', true);
  3105. $timetk = strtotime($timetk);
  3106. $timetj = strtotime($timetj);
  3107. $where = "(state=206 or state=210) and mergeid = 0";
  3108. if ($warehouse) {
  3109. $where .= " and state = '$warehouse'";
  3110. }
  3111. if ($timetk && $timetj) {
  3112. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3113. }
  3114. if ($shop) {
  3115. $where .= " and shop = '$shop'";
  3116. }
  3117. if ($source) {
  3118. $where .= " and source = '$source'";
  3119. }
  3120. if ($state) {
  3121. $where .= " and state = '$state'";
  3122. }
  3123. if ($review) {
  3124. $where .= " and review = '$review'";
  3125. }
  3126. if ($state) {
  3127. $where .= " and state = '$state'";
  3128. }
  3129. if ($express) {
  3130. $where .= " and express = '$express'";
  3131. }
  3132. if ($orderinfo) {
  3133. $where .= " and orderinfo = '$orderinfo'";
  3134. }
  3135. if ($user) {
  3136. $where .= " and user = '$user'";
  3137. }
  3138. if ($name) {
  3139. $where .= " and name = '$name'";
  3140. }
  3141. if ($waybill) {
  3142. $where .= " and waybill = '$waybill'";
  3143. }
  3144. //数据排序
  3145. $order_str = "id desc";
  3146. if (empty($page)) {
  3147. $start = 0;
  3148. $perpage = 1;
  3149. } else {
  3150. $start = ($page - 1) * $perpage;
  3151. }
  3152. //取得信息列表
  3153. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3154. //格式化数据
  3155. foreach ($info_list as $key => $value) {
  3156. $shop = $this->shop->read($value['shop']);
  3157. $info_list[$key]['shop'] = $shop['shopname'];
  3158. $warehouse = $this->warehouse->read($value['warehouse']);
  3159. $info_list[$key]['warehouse'] = $warehouse['title'];
  3160. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3161. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3162. if ($value['waybill'] == 0) {
  3163. $info_list[$key]['waybill'] = "";
  3164. }
  3165. $express = $this->express->read($value['express']);
  3166. $info_list[$key]['express'] = $express['title'];
  3167. $typeclass = $this->typeclass->read($value['state']);
  3168. $info_list[$key]['state'] = $typeclass['title'];
  3169. }
  3170. $total = $this->fullorder->find_count($where);
  3171. $pagenum = ceil($total / $perpage);
  3172. $over = $total - ($start + $perpage);
  3173. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3174. echo json_encode($rows);
  3175. exit;
  3176. }
  3177. $this->data['express'] = $this->express->find_all();
  3178. $this->_Template('whlabel_retreat', $this->data);
  3179. }
  3180. //退库标签浏览
  3181. public function _retreatlk()
  3182. {
  3183. $post = $this->input->post(NULL, TRUE);
  3184. if (isset($post['page'])) {
  3185. $page = $this->input->post('page', true);
  3186. $perpage = $this->input->post('perpage', true);
  3187. $timetk = $this->input->post('timetk', true);
  3188. $timetj = $this->input->post('timetj', true);
  3189. $sku = $this->input->post('sku', true);
  3190. $warehouse = $this->input->post('warehouse', true);
  3191. $purchase = $this->input->post('purchase', true);
  3192. $orderinfo = $this->input->post('orderinfo', true);
  3193. $waybill = $this->input->post('waybill', true);
  3194. $category = $this->input->post('category', true);
  3195. $size = $this->input->post('size', true);
  3196. $grade = $this->input->post('grade', true);
  3197. $color = $this->input->post('color', true);
  3198. $lowe = $this->input->post('lowe', true);
  3199. $state = $this->input->post('state', true);
  3200. $timetk = strtotime($timetk);
  3201. $timetj = strtotime($timetj);
  3202. $where = "state=2";
  3203. if ($timetk && $timetj) {
  3204. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3205. }
  3206. if ($sku) {
  3207. $where .= " and sku = '$sku'";
  3208. }
  3209. if ($warehouse) {
  3210. $where .= " and warehouse = '$warehouse'";
  3211. }
  3212. if ($purchase) {
  3213. $where .= " and purchase = '$purchase'";
  3214. }
  3215. if ($orderinfo) {
  3216. $where .= " and orderinfo = '$orderinfo'";
  3217. }
  3218. if ($waybill) {
  3219. $where .= " and waybill = '$waybill'";
  3220. }
  3221. if ($category) {
  3222. $where .= " and features like '%-$category-%'";
  3223. }
  3224. if ($size) {
  3225. $where .= " and features like '%-$size-%'";
  3226. }
  3227. if ($grade) {
  3228. $where .= " and features like '%-$grade-%'";
  3229. }
  3230. if ($color) {
  3231. $where .= " and features like '%-$color-%'";
  3232. }
  3233. if ($lowe) {
  3234. $where .= " and features like '%-$lowe-%'";
  3235. }
  3236. //数据排序
  3237. $order_str = "time desc";
  3238. if (empty($page)) {
  3239. $start = 0;
  3240. $perpage = 1;
  3241. } else {
  3242. $start = ($page - 1) * $perpage;
  3243. }
  3244. //取得信息列表
  3245. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3246. foreach ($info_list as $key => $value) {
  3247. $warehouse = $this->warehouse->read($value['warehouse']);
  3248. $info_list[$key]['warehouse'] = $warehouse['title'];
  3249. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3250. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3251. $purchase = $this->purchase->read($value['purchase']);
  3252. $info_list[$key]['purchase'] = $purchase['title'];
  3253. if ($value['outk'] != 0) {
  3254. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3255. } else {
  3256. $info_list[$key]['outk'] = "";
  3257. }
  3258. if ($value['retreat'] != 0) {
  3259. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3260. } else {
  3261. $info_list[$key]['retreat'] = "";
  3262. }
  3263. if ($value['orderinfo'] == 0) {
  3264. $info_list[$key]['orderinfo'] = "";
  3265. }
  3266. if ($value['waybill'] == 0) {
  3267. $info_list[$key]['waybill'] = "";
  3268. }
  3269. }
  3270. $total = $this->whlabel->find_count($where);
  3271. $pagenum = ceil($total / $perpage);
  3272. $over = $total - ($start + $perpage);
  3273. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3274. echo json_encode($rows);
  3275. exit;
  3276. }
  3277. $this->_Template('whlabel_retreatlk', $this->data);
  3278. }
  3279. //更换标签及浏览
  3280. public function _change()
  3281. {
  3282. $post = $this->input->post(NULL, TRUE);
  3283. if (isset($post['page'])) {
  3284. $page = $this->input->post('page', true);
  3285. $perpage = $this->input->post('perpage', true);
  3286. $timetk = $this->input->post('timetk', true);
  3287. $timetj = $this->input->post('timetj', true);
  3288. $label = $this->input->post('label', true);
  3289. $oldlabel = $this->input->post('oldlabel', true);
  3290. $timetk = strtotime($timetk);
  3291. $timetj = strtotime($timetj);
  3292. $where = "state=10 ";
  3293. if ($timetk && $timetj) {
  3294. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3295. }
  3296. if ($label) {
  3297. $where .= " and label = '$label'";
  3298. }
  3299. if ($oldlabel) {
  3300. $where .= " and oldlabel = '$oldlabel'";
  3301. }
  3302. //数据排序
  3303. $order_str = "time asc";
  3304. if (empty($page)) {
  3305. $start = 0;
  3306. $perpage = 1;
  3307. } else {
  3308. $start = ($page - 1) * $perpage;
  3309. }
  3310. //取得信息列表
  3311. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3312. foreach ($info_list as $key => $value) {
  3313. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3314. }
  3315. $total = $this->whlabel->find_count($where);
  3316. $pagenum = ceil($total / $perpage);
  3317. $over = $total - ($start + $perpage);
  3318. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3319. echo json_encode($rows);
  3320. exit;
  3321. }
  3322. $this->_Template('whlabel_change', $this->data);
  3323. }
  3324. //产品标签
  3325. public function _cpbqdc()
  3326. {
  3327. if (isset($_GET['excel'])) {
  3328. $where = "1=1";
  3329. //数据排序
  3330. $order_str = "id desc";
  3331. if (empty($page)) {
  3332. $start = 0;
  3333. $perpage = 1;
  3334. } else {
  3335. $start = ($page - 1) * $perpage;
  3336. }
  3337. $warehouse = $this->input->get('warehouse', true);
  3338. $state = $this->input->get('state', true);
  3339. $timetk = $this->input->get('timetkk', true);
  3340. $timetj = $this->input->get('timetjj', true);
  3341. $timetk = strtotime($timetk);
  3342. $timetj = strtotime($timetj);
  3343. if ($warehouse) {
  3344. $where .= " and warehouse = '$warehouse'";
  3345. }
  3346. if ($state || $state == 0) {
  3347. $where .= " and state = '$state'";
  3348. }
  3349. if ($timetk && $timetj) {
  3350. $where .= " and time > '$timetk' and time < '$timetj'";
  3351. }
  3352. //取得信息列表
  3353. $info_list = $this->whlabel->find_all($where, '*');
  3354. $rows = array();
  3355. $list = array();
  3356. foreach ($info_list as $key => $value) {
  3357. $rows[$value['time']] = $value; //所有数据sku
  3358. }
  3359. foreach ($rows as $value) {
  3360. $warehouse = $this->warehouse->read($value['warehouse']);
  3361. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3362. $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);
  3363. }
  3364. $title = "产品标签统计表";
  3365. $titlename = "<table border=1>
  3366. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3367. <tr align='center'>
  3368. <td>仓库</td>
  3369. <td>SKU</td>
  3370. <td>产品</td>
  3371. <td>入库时间</td>
  3372. <td>操作时间</td>
  3373. <td>备注</td>
  3374. <td>数量</td>
  3375. </tr>
  3376. </table>";
  3377. $filename = $title . ".xls";
  3378. $tail = "";
  3379. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3380. }
  3381. }
  3382. //进销存导出
  3383. public function _exceljxc()
  3384. {
  3385. $classid = $this->classid->sku();
  3386. $pm = $classid;
  3387. $typeclass = array();
  3388. $tc = $this->typeclass->find_all();
  3389. foreach ($tc as $v) {
  3390. $typeclass[$v['id']] = $v;
  3391. }
  3392. $prc = array();
  3393. $purchase = $this->purchase->find_all();
  3394. foreach ($purchase as $k => $v) {
  3395. $prc[$v['id']] = $v['title'];
  3396. }
  3397. if (isset($_GET['excel'])) {
  3398. $where = "sku != 'Preset'";
  3399. //数据排序
  3400. $order_str = "id desc";
  3401. if (empty($page)) {
  3402. $start = 0;
  3403. $perpage = 1;
  3404. } else {
  3405. $start = ($page - 1) * $perpage;
  3406. }
  3407. $category = $this->input->get('category', true);
  3408. $warehouse = $this->input->get('warehouse', true);
  3409. $excelid = $this->input->get('sid', true);
  3410. if ($category) {
  3411. $where .= " and features like '%-$category-%'";
  3412. }
  3413. if ($warehouse) {
  3414. $where .= " and warehouse = '$warehouse'";
  3415. }
  3416. $xzid = '';
  3417. if ($excelid) {
  3418. $excelid = explode(',', trim($excelid, ','));
  3419. foreach ($excelid as $key => $value) {
  3420. $xzid .= " id = " . $value . " or";
  3421. }
  3422. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3423. }
  3424. //取得信息列表
  3425. /**
  3426. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3427. $rows = array();$list = array();
  3428. foreach ($info_list as $key=>$value)
  3429. {
  3430. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3431. }
  3432. **/
  3433. $wt = array();
  3434. $whlabel_type = $this->whlabel_type->find_all();
  3435. foreach ($whlabel_type as $v) {
  3436. $wt[$v['id']] = $v['title'];
  3437. }
  3438. $wh = array();
  3439. $w = $this->warehouse->find_all('1=1', 'id,title');
  3440. foreach ($w as $v) {
  3441. $wh[$v['id']] = $v['title'];
  3442. }
  3443. $list = array();
  3444. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3445. foreach ($rows as $key => $value) {
  3446. if (isset($wt[$value['type']])) {
  3447. $rows[$key]['type'] = $wt[$value['type']];
  3448. } else {
  3449. $rows[$key]['type'] = '未设置';
  3450. }
  3451. $bm = '03';
  3452. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3453. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3454. $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');
  3455. $details = array();
  3456. $cpid = array();
  3457. $cpbz = array();
  3458. $c = 0;
  3459. $g = 0;
  3460. $x = 0;
  3461. $t = 0;
  3462. $s = 0;
  3463. $q = 0;
  3464. foreach ($sd as $k => $v) {
  3465. if ($v['state'] == 0) {
  3466. $c++;
  3467. if ($v['cpid'] != 0) {
  3468. $cpid[$v['cpid']] = $v['cpid'];
  3469. }
  3470. if ($v['cpbz'] != '') {
  3471. $cpbz[$v['cpbz']] = $v['cpbz'];
  3472. }
  3473. }
  3474. if ($v['state'] != 9) {
  3475. $g++;
  3476. }
  3477. if ($v['state'] == 1) {
  3478. $x++;
  3479. }
  3480. if ($v['state'] == 2) {
  3481. $t++;
  3482. }
  3483. if ($v['state'] == 8) {
  3484. $s++;
  3485. }
  3486. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3487. $q++;
  3488. }
  3489. $details[$v['details']] = $v['details'];
  3490. }
  3491. $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'] . '"');
  3492. $rows[$key]['details'] = implode("、", $details);
  3493. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3494. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3495. $number = $value['number'];
  3496. $ftime = time() - 15 * 24 * 3600;
  3497. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3498. $rows[$key]['number'] = $g;
  3499. $rows[$key]['c'] = $c;
  3500. $rows[$key]['x'] = $x;
  3501. $rows[$key]['t'] = $t;
  3502. $rows[$key]['s'] = $s;
  3503. $rows[$key]['q'] = $q;
  3504. $rows[$key]['z'] = $z;
  3505. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3506. $features = explode('-', trim($features, '-'));
  3507. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3508. // $pm = $classid;
  3509. // $jm = $classid;
  3510. // foreach($features as $k=>$v)
  3511. // {
  3512. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3513. // {
  3514. // if($typeclass[$v]['bm'] != '')
  3515. // {
  3516. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3517. // }
  3518. // }
  3519. // if($v != 0)
  3520. // {
  3521. // if(!isset($typeclass[$v]))
  3522. // {
  3523. // continue;
  3524. // }
  3525. // if(isset($pm[$typeclass[$v]['classid']]))
  3526. // {
  3527. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3528. // {
  3529. // $tz = explode('|',$typeclass[$v]['zh']);
  3530. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3531. // }
  3532. // else
  3533. // {
  3534. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3535. // }
  3536. // }
  3537. // if(isset($jm[$typeclass[$v]['classid']]))
  3538. // {
  3539. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3540. // }
  3541. // }
  3542. // }
  3543. // $jm = array_filter($jm);
  3544. // $rows[$key]['bs'] = implode("-",$jm);
  3545. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3546. // $zh = implode(" ",$pm);
  3547. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3548. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3549. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3550. // $rows[$key]['features'] = $zh;
  3551. }
  3552. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3553. $final_list = [];
  3554. foreach ($list as $k => $v) {
  3555. if (empty($v['sku'])) {
  3556. continue;
  3557. }
  3558. $final_list[] = [
  3559. "warehouse" => $v["warehouse"],
  3560. "purchase" => $v["purchase"],
  3561. "details" => $v["details"],
  3562. "cpid" => $v["cpid"],
  3563. "dbcontent" => $v["dbcontent"],
  3564. "sku" => $v["sku"],
  3565. "cs" => $v["bm"],
  3566. "bs" => $v["jm"],
  3567. "title" => $v["title"],
  3568. "features" => $v["pm"],
  3569. "cpbz" => $v["cpbz"],
  3570. "sm" => $v["sm"],
  3571. "type" => $v["type"],
  3572. "number" => $v["number"],
  3573. "c" => $v["c"],
  3574. "x" => $v["x"],
  3575. "t" => $v["t"],
  3576. "s" => $v["s"],
  3577. "q" => $v["q"],
  3578. "z" => $v["z"],
  3579. "weight" => $v['weight'],
  3580. ];
  3581. }
  3582. $title = "总进销存统计表";
  3583. $titlename = "<table border=1>
  3584. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3585. <tr align='center'>
  3586. <td>仓库</td>
  3587. <td>供应商</td>
  3588. <td>位置</td>
  3589. <td>库存编码</td>
  3590. <td>类目</td>
  3591. <td>SKU</td>
  3592. <td>用友编码</td>
  3593. <td>用友料号</td>
  3594. <td>商品名称</td>
  3595. <td>商品中文</td>
  3596. <td>产品备注</td>
  3597. <td>库位负责人</td>
  3598. <td>类型</td>
  3599. <td>入库总量</td>
  3600. <td>库存数量</td>
  3601. <td>销售数量</td>
  3602. <td>退货数量</td>
  3603. <td>删除数量</td>
  3604. <td>其它操作</td>
  3605. <td>占单数量</td>
  3606. <td>重量(g)</td>
  3607. </tr>
  3608. </table>";
  3609. $filename = $title . ".xls";
  3610. $tail = "";
  3611. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3612. }
  3613. }
  3614. //入库导出
  3615. public function _excelr()
  3616. {
  3617. if (isset($_GET['excel'])) {
  3618. $category = $this->input->get('category', true);
  3619. $size = $this->input->get('size', true);
  3620. $grade = $this->input->get('grade', true);
  3621. $color = $this->input->get('color', true);
  3622. $lowe = $this->input->get('lowe', true);
  3623. $sku = $this->input->get('sku', true);
  3624. $warehouse = $this->input->get('warehouse', true);
  3625. $purchase = $this->input->get('purchase', true);
  3626. $ktime = $this->input->get('ktime', true);
  3627. $jtime = $this->input->get('jtime', true);
  3628. $ktime = strtotime($ktime);
  3629. $jtime = strtotime($jtime);
  3630. $where = "1=1";
  3631. $gj = "";
  3632. $ck = "";
  3633. if ($category) {
  3634. $where .= " and features like '%-$category-%'";
  3635. }
  3636. if ($size) {
  3637. $where .= " and features like '%-$size-%'";
  3638. }
  3639. if ($grade) {
  3640. $where .= " and features like '%-$grade-%'";
  3641. }
  3642. if ($color) {
  3643. $where .= " and features like '%-$color-%'";
  3644. }
  3645. if ($lowe) {
  3646. $where .= " and features like '%-$lowe-%'";
  3647. }
  3648. if ($warehouse) {
  3649. $where .= " and warehouse = '$warehouse'";
  3650. }
  3651. if ($purchase) {
  3652. $where .= " and purchase = '$purchase'";
  3653. }
  3654. if ($sku) {
  3655. $where .= " and sku = '$sku'";
  3656. }
  3657. if ($ktime && $jtime) {
  3658. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3659. }
  3660. //数据排序
  3661. $order_str = "id desc";
  3662. if (empty($page)) {
  3663. $start = 0;
  3664. $perpage = 1;
  3665. } else {
  3666. $start = ($page - 1) * $perpage;
  3667. }
  3668. $list = array();
  3669. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3670. foreach ($rows as $value) {
  3671. $ck = $this->warehouse->read($value['warehouse']);
  3672. $warehouse = $ck['title'];
  3673. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3674. $retreatwarehouse = $tkck['title'];
  3675. $gy = $this->purchase->read($value['purchase']);
  3676. $purchase = $gy['title'];
  3677. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3678. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3679. }
  3680. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3681. $titlename = "<table border=1>
  3682. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3683. <tr align='center'>
  3684. <td>仓库</td>
  3685. <td>SKU</td>
  3686. <td>产品</td>
  3687. <td>时间</td>
  3688. <td>数量</td>
  3689. </tr>
  3690. </table>";
  3691. $filename = $title . ".xls";
  3692. $tail = "";
  3693. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  3694. }
  3695. }
  3696. //出库、退库导出
  3697. public function _excelct()
  3698. {
  3699. $classid = $this->classid->sku();
  3700. $pm = $classid;
  3701. $typeclass = array();
  3702. $tc = $this->typeclass->find_all();
  3703. foreach ($tc as $v) {
  3704. $typeclass[$v['id']] = $v;
  3705. }
  3706. $prc = array();
  3707. $purchase = $this->purchase->find_all();
  3708. foreach ($purchase as $k => $v) {
  3709. $prc[$v['id']] = $v['title'];
  3710. }
  3711. if (isset($_GET['excel'])) {
  3712. $wh = array();
  3713. $w = $this->warehouse->find_all('1=1', 'id,title');
  3714. foreach ($w as $v) {
  3715. $wh[$v['id']] = $v['title'];
  3716. }
  3717. $type = $this->input->get('excel', true);
  3718. $category = $this->input->get('category', true);
  3719. $size = $this->input->get('size', true);
  3720. $grade = $this->input->get('grade', true);
  3721. $color = $this->input->get('color', true);
  3722. $lowe = $this->input->get('lowe', true);
  3723. $sku = $this->input->get('sku', true);
  3724. $title = $this->input->get('title', true);
  3725. $warehouse = $this->input->get('warehouse', true);
  3726. $purchase = $this->input->get('purchase', true);
  3727. $lacetype = $this->input->get('lacetype', true);
  3728. $haircap = $this->input->get('haircap', true);
  3729. $lacecolor = $this->input->get('lacecolor', true);
  3730. $density = $this->input->get('density', true);
  3731. $details = $this->input->get('details', true);
  3732. $state = $this->input->get('state', true);
  3733. $shop = $this->input->get('shop', true);
  3734. $hairnumber = $this->input->get('hairnumber', true);
  3735. $type_leixi = $this->input->get('type', true);
  3736. $cpbz = $this->input->get('cpbz', true);
  3737. $sm = $this->input->get('sm', true);
  3738. $sid = $this->input->get('sid', true);
  3739. $ktime = $this->input->get('ktime', true);
  3740. $jtime = $this->input->get('jtime', true);
  3741. $ktime = strtotime($ktime);
  3742. $jtime = strtotime($jtime);
  3743. //$where = " 1=1 ";
  3744. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3745. $where = " sku != '' ";
  3746. $gj = "";
  3747. $ck = "";
  3748. if ($category) {
  3749. $where .= " and features like '%-$category-%'";
  3750. }
  3751. if ($size) {
  3752. $where .= " and features like '%-$size-%'";
  3753. }
  3754. if ($grade) {
  3755. $where .= " and features like '%-$grade-%'";
  3756. }
  3757. if ($color) {
  3758. $where .= " and features like '%-$color-%'";
  3759. }
  3760. if ($lowe) {
  3761. $where .= " and features like '%-$lowe-%'";
  3762. }
  3763. if ($warehouse) {
  3764. $where .= " and warehouse = '$warehouse'";
  3765. }
  3766. if ($purchase) {
  3767. $where .= " and purchase = '$purchase'";
  3768. }
  3769. if ($state) {
  3770. $where .= " and state = '$state'";
  3771. }
  3772. if ($lacetype) {
  3773. $where .= " and features like '%-$lacetype-%'";
  3774. }
  3775. if ($lacecolor) {
  3776. $where .= " and features like '%-$lacecolor-%'";
  3777. }
  3778. if ($density) {
  3779. $where .= " and features like '%-$density-%'";
  3780. }
  3781. if ($haircap) {
  3782. $where .= " and features like '%-$haircap-%'";
  3783. }
  3784. if ($details) {
  3785. $where .= " and details = '$details'";
  3786. }
  3787. if ($shop) {
  3788. $where .= " and shop like '%$shop%'";
  3789. }
  3790. if ($title) {
  3791. $title = trim($title, ' ');
  3792. $title = trim($title, ' ');
  3793. $where .= " and title like '%$title%'";
  3794. }
  3795. if (!empty($hairnumber)) {
  3796. $where .= " and features like '%-128-%' ";
  3797. if ($hairnumber < 0) {
  3798. $class_list = $this->typeclass->find_all('classid = 43');
  3799. foreach ($class_list as $v) {
  3800. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3801. }
  3802. } else {
  3803. $where .= " and features like '%-$hairnumber-%'";
  3804. }
  3805. }
  3806. if ($type_leixi) {
  3807. $where .= " and type = '$type_leixi'";
  3808. }
  3809. if ($cpbz) {
  3810. $where .= " and cpbz like '%$cpbz%' ";
  3811. }
  3812. if ($sm) {
  3813. $where .= " and sm like '%$sm%' ";
  3814. }
  3815. if ($sku) {
  3816. $sku = trim($sku, ' ');
  3817. $sku = trim($sku, ' ');
  3818. $where .= " and sku like '%$sku%'";
  3819. }
  3820. if ($ktime && $jtime) {
  3821. if ($type == 1) {
  3822. $tl = '出库';
  3823. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3824. } else if ($type == 2) {
  3825. $tl = '退库';
  3826. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3827. } else if ($type == 3) {
  3828. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3829. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3830. } else if ($type == 4) {
  3831. $tl = '出库+零售';
  3832. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3833. } else if ($type == 5) {
  3834. $tl = '零售';
  3835. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3836. }
  3837. }
  3838. $sidwhere = '';
  3839. if ($sid) {
  3840. $sd = "";
  3841. $s = explode(',', trim($sid, ','));
  3842. foreach ($s as $value) {
  3843. $sd .= " id = " . $value . " or";
  3844. }
  3845. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3846. }
  3847. //数据排序
  3848. $order_str = "time desc";
  3849. if (empty($page)) {
  3850. $start = 0;
  3851. $perpage = 1;
  3852. } else {
  3853. $start = ($page - 1) * $perpage;
  3854. }
  3855. //取得信息列表
  3856. if ($type != 3 && $type != 5) {
  3857. if ($type == 1 || $type == 4) {
  3858. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3859. foreach ($info_list as $key => $value) {
  3860. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3861. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3862. $warehouse = $this->warehouse->read($value['warehouse']);
  3863. $info_list[$key]['warehouse'] = $warehouse['title'];
  3864. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3865. $features = explode('-', trim($features, '-'));
  3866. $pm = $classid;
  3867. foreach ($features as $k => $v) {
  3868. if ($v != 0) {
  3869. if (!isset($typeclass[$v])) {
  3870. continue;
  3871. }
  3872. if (isset($pm[$typeclass[$v]['classid']])) {
  3873. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3874. $tz = explode('|', $typeclass[$v]['zh']);
  3875. $pm[$typeclass[$v]['classid']] = $tz[0];
  3876. } else {
  3877. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3878. }
  3879. }
  3880. }
  3881. }
  3882. $zh = implode(" ", $pm);
  3883. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3884. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3885. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3886. $info_list[$key]['features'] = $zh;
  3887. }
  3888. $final_list = [];
  3889. foreach($info_list as $k=>$v){
  3890. $number = "";
  3891. if(!empty($v['orderinfo'])){
  3892. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3893. if(!empty($tmp_info['number'])){
  3894. $number = $tmp_info['number'];
  3895. }
  3896. }
  3897. $final_list[] = [
  3898. 'warehouse'=>$v['warehouse'],
  3899. 'purchase'=>$v['purchase'],
  3900. 'sku'=>$v['sku'],
  3901. 'title'=>$v['title'],
  3902. 'features'=>$v['features'],
  3903. 'label'=>$v['label'],
  3904. 'orderinfo'=>$v['orderinfo'],
  3905. 'number'=>$number,
  3906. 'waybill'=>$v['waybill'],
  3907. 'outk'=>$v['outk'],
  3908. ];
  3909. }
  3910. } else {
  3911. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3912. foreach ($info_list as $key => $value) {
  3913. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3914. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3915. $warehouse = $this->warehouse->read($value['warehouse']);
  3916. $info_list[$key]['warehouse'] = $warehouse['title'];
  3917. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3918. $features = explode('-', trim($features, '-'));
  3919. $pm = $classid;
  3920. foreach ($features as $k => $v) {
  3921. if ($v != 0) {
  3922. if (!isset($typeclass[$v])) {
  3923. continue;
  3924. }
  3925. if (isset($pm[$typeclass[$v]['classid']])) {
  3926. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3927. $tz = explode('|', $typeclass[$v]['zh']);
  3928. $pm[$typeclass[$v]['classid']] = $tz[0];
  3929. } else {
  3930. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3931. }
  3932. }
  3933. }
  3934. }
  3935. $zh = implode(" ", $pm);
  3936. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3937. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3938. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3939. $info_list[$key]['features'] = $zh;
  3940. }
  3941. $final_list = [];
  3942. foreach($info_list as $k=>$v){
  3943. $number = "";
  3944. if(!empty($v['orderinfo'])){
  3945. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3946. if(!empty($tmp_info['number'])){
  3947. $number = $tmp_info['number'];
  3948. }
  3949. }
  3950. $final_list[] = [
  3951. 'warehouse'=>$v['warehouse'],
  3952. 'purchase'=>$v['purchase'],
  3953. 'sku'=>$v['sku'],
  3954. 'title'=>$v['title'],
  3955. 'features'=>$v['features'],
  3956. 'label'=>$v['label'],
  3957. 'orderinfo'=>$v['orderinfo'],
  3958. 'number'=>$number,
  3959. 'waybill'=>$v['waybill'],
  3960. 'retreat'=>$v['retreat'],
  3961. ];
  3962. }
  3963. }
  3964. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3965. $titlename = "<table border=1>
  3966. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3967. <tr align='center'>
  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>" . $tl . "时间(中国时间)</td>
  3978. </tr>
  3979. </table>";
  3980. $filename = $title . ".xls";
  3981. $tail = "";
  3982. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3983. } else if ($type == 5) {
  3984. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3985. foreach ($info_list as $key => $value) {
  3986. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3987. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3988. $warehouse = $this->warehouse->read($value['warehouse']);
  3989. $info_list[$key]['warehouse'] = $warehouse['title'];
  3990. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3991. $features = explode('-', trim($features, '-'));
  3992. $pm = $classid;
  3993. foreach ($features as $k => $v) {
  3994. if ($v != 0) {
  3995. if (!isset($typeclass[$v])) {
  3996. continue;
  3997. }
  3998. if (isset($pm[$typeclass[$v]['classid']])) {
  3999. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4000. $tz = explode('|', $typeclass[$v]['zh']);
  4001. $pm[$typeclass[$v]['classid']] = $tz[0];
  4002. } else {
  4003. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4004. }
  4005. }
  4006. }
  4007. }
  4008. $zh = implode(" ", $pm);
  4009. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4010. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4011. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4012. $info_list[$key]['features'] = $zh;
  4013. }
  4014. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4015. $titlename = "<table border=1>
  4016. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4017. <tr align='center'>
  4018. <td>仓库</td>
  4019. <td>供应商</td>
  4020. <td>SKU</td>
  4021. <td>商品名称</td>
  4022. <td>商品中文</td>
  4023. <td>标签</td>
  4024. <td>" . $tl . "时间(中国时间)</td>
  4025. </tr>
  4026. </table>";
  4027. $filename = $title . ".xls";
  4028. $tail = "";
  4029. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4030. } else {
  4031. /**
  4032. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4033. $rows = array();$list = array();
  4034. foreach ($info_list as $key=>$value)
  4035. {
  4036. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4037. }
  4038. **/
  4039. $wh = array();
  4040. $w = $this->warehouse->find_all('1=1', 'id,title');
  4041. foreach ($w as $v) {
  4042. $wh[$v['id']] = $v['title'];
  4043. }
  4044. $wt = array();
  4045. $whlabel_type = $this->whlabel_type->find_all();
  4046. foreach ($whlabel_type as $v) {
  4047. $wt[$v['id']] = $v['title'];
  4048. }
  4049. $classid = $this->classid->sku();
  4050. $list = array();
  4051. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4052. foreach ($rows as $key => $value) {
  4053. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4054. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4055. $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');
  4056. $details = array();
  4057. $cpid = array();
  4058. $cpbz = array();
  4059. $c = 0;
  4060. $g = 0;
  4061. $x = 0;
  4062. $t = 0;
  4063. $s = 0;
  4064. $q = 0;
  4065. foreach ($sd as $k => $v) {
  4066. if ($v['state'] == 0) {
  4067. $c++;
  4068. }
  4069. if ($v['state'] != 9) {
  4070. $g++;
  4071. }
  4072. if ($v['outk'] > 1) {
  4073. $x++;
  4074. }
  4075. if ($v['retreat'] > 0) {
  4076. $t++;
  4077. }
  4078. if ($v['state'] == 8) {
  4079. $s++;
  4080. }
  4081. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4082. $q++;
  4083. }
  4084. $details[$v['details']] = $v['details'];
  4085. if ($v['cpid'] != 0) {
  4086. $cpid[$v['cpid']] = $v['cpid'];
  4087. }
  4088. if ($v['cpbz'] != '') {
  4089. $cpbz[$v['cpbz']] = $v['cpbz'];
  4090. }
  4091. }
  4092. if (isset($wt[$value['type']])) {
  4093. $rows[$key]['type'] = $wt[$value['type']];
  4094. } else {
  4095. $rows[$key]['type'] = '未设置';
  4096. }
  4097. $rows[$key]['details'] = implode("、", $details);
  4098. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4099. $ftime = time() - 15 * 24 * 3600;
  4100. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4101. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4102. $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);
  4103. $rows[$key]['c'] = $c;
  4104. $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);
  4105. $rows[$key]['t'] = $t;
  4106. $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'] . '"');
  4107. $rows[$key]['z'] = $z;
  4108. // $jm = $classid;
  4109. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4110. $features = explode('-', trim($features, '-'));
  4111. // $pm = $classid;
  4112. // foreach ($features as $k => $v) {
  4113. // if ($v != 0) {
  4114. // if (!isset($typeclass[$v])) {
  4115. // continue;
  4116. // }
  4117. // if (isset($pm[$typeclass[$v]['classid']])) {
  4118. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4119. // $tz = explode('|', $typeclass[$v]['zh']);
  4120. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4121. // } else {
  4122. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4123. // }
  4124. // if (isset($jm[$typeclass[$v]['classid']])) {
  4125. // if ($typeclass[$v]['jm']) {
  4126. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4127. // }
  4128. // }
  4129. // }
  4130. // }
  4131. // }
  4132. // $zh = implode(" ", $pm);
  4133. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4134. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4135. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4136. // $rows[$key]['features'] = $zh;
  4137. // $jm = array_filter($jm); //去除空值
  4138. // $jm = implode("-", $jm);
  4139. // $rows[$key]['jm'] = $jm;
  4140. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4141. }
  4142. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4143. // echo "<pre>";
  4144. // print_r($tmp_list);
  4145. // die;
  4146. $final_list =[];
  4147. foreach($tmp_list as $k=>$v){
  4148. $final_list[] = [
  4149. "warehouse"=>$v['warehouse'],
  4150. "purchase"=>$v['purchase'],
  4151. "details"=>trim($v['details'],'、'),
  4152. "cpid"=>$v['cpid'],
  4153. "sku"=>$v['sku'],
  4154. "title"=>$v['title'],
  4155. "features"=>$v['pm'],
  4156. "cpbz"=>$v['cpbz'],
  4157. "sm"=>$v['sm'],
  4158. "type"=>$v['type'],
  4159. "g"=>$v["g"],
  4160. "c"=>$v["c"],
  4161. "x"=>$v["x"],
  4162. "t"=>$v["t"],
  4163. "z"=>$v["z"],
  4164. "jm"=>$v["jm"],
  4165. "weight"=>$v["weight"],
  4166. "asd"=>$v["asd"],
  4167. ];
  4168. }
  4169. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4170. $titlename = "<table border=1>
  4171. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4172. <tr align='center'>
  4173. <td>仓库</td>
  4174. <td>供应商</td>
  4175. <td>位置</td>
  4176. <td>库存编码</td>
  4177. <td>SKU</td>
  4178. <td>商品名称</td>
  4179. <td>商品中文</td>
  4180. <td>产品备注</td>
  4181. <td>说明</td>
  4182. <td>类型</td>
  4183. <td>入库总量</td>
  4184. <td>库存数量</td>
  4185. <td>销售数量</td>
  4186. <td>退货数量</td>
  4187. <td>占单数量</td>
  4188. <td>料号</td>
  4189. <td>重量</td>
  4190. <td>类目</td>
  4191. </tr>
  4192. </table>";
  4193. $filename = $title . ".xls";
  4194. $tail = "";
  4195. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4196. }
  4197. }
  4198. }
  4199. //出库+入库数据整合
  4200. public function _excelcr()
  4201. {
  4202. if (isset($_GET['excel'])) {
  4203. $type = $this->input->get('excel', true);
  4204. $category = $this->input->get('category', true);
  4205. $size = $this->input->get('size', true);
  4206. $grade = $this->input->get('grade', true);
  4207. $color = $this->input->get('color', true);
  4208. $lowe = $this->input->get('lowe', true);
  4209. $sku = $this->input->get('sku', true);
  4210. $warehouse = $this->input->get('warehouse', true);
  4211. $purchase = $this->input->get('purchase', true);
  4212. $state = $this->input->get('state', true);
  4213. $sid = $this->input->get('sid', true);
  4214. $ktime = $this->input->get('ktime', true);
  4215. $jtime = $this->input->get('jtime', true);
  4216. $ktime = strtotime($ktime);
  4217. $jtime = strtotime($jtime);
  4218. $where = "1=1";
  4219. $gj = "";
  4220. $ck = "";
  4221. if ($category) {
  4222. $where .= " and features like '%-$category-%'";
  4223. }
  4224. if ($size) {
  4225. $where .= " and features like '%-$size-%'";
  4226. }
  4227. if ($grade) {
  4228. $where .= " and features like '%-$grade-%'";
  4229. }
  4230. if ($color) {
  4231. $where .= " and features like '%-$color-%'";
  4232. }
  4233. if ($lowe) {
  4234. $where .= " and features like '%-$lowe-%'";
  4235. }
  4236. if ($warehouse) {
  4237. $where .= " and warehouse = '$warehouse'";
  4238. }
  4239. if ($purchase) {
  4240. $where .= " and purchase = '$purchase'";
  4241. }
  4242. if ($state) {
  4243. $where .= " and state = '$state'";
  4244. }
  4245. if ($sku) {
  4246. $where .= " and sku like '%$sku%'";
  4247. }
  4248. if ($ktime && $jtime) {
  4249. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4250. }
  4251. $sidwhere = '';
  4252. if ($sid) {
  4253. $sd = "";
  4254. $s = explode(',', trim($sid, ','));
  4255. foreach ($s as $value) {
  4256. $sd .= " id = " . $value . " or";
  4257. }
  4258. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4259. }
  4260. //取得信息列表
  4261. $timeread = $ktime;
  4262. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4263. $timelist = array();
  4264. for ($i = 0; $i < $timenum; $i++) {
  4265. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4266. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4267. }
  4268. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4269. //echo "<pre>";
  4270. //print_r($info_list);
  4271. //exit();
  4272. $rows = array();
  4273. $list = array();
  4274. foreach ($info_list as $key => $value) {
  4275. $thistime = $timelist;
  4276. if (isset($rows[strtolower($value['sku'])])) {
  4277. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4278. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4279. }
  4280. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4281. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4282. }
  4283. } else {
  4284. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4285. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4286. }
  4287. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4288. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4289. }
  4290. $rows[strtolower($value['sku'])] = $thistime;
  4291. }
  4292. }
  4293. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4294. <head>
  4295. <!--[if gte mso 9]><xml>
  4296. <x:ExcelWorkbook>
  4297. <x:ExcelWorksheets>
  4298. <x:ExcelWorksheet>
  4299. <x:Name>EXCEL</x:Name>
  4300. <x:WorksheetOptions>
  4301. <x:Print>
  4302. <x:ValidPrinterInfo />
  4303. </x:Print>
  4304. </x:WorksheetOptions>
  4305. </x:ExcelWorksheet>
  4306. </x:ExcelWorksheets>
  4307. </x:ExcelWorkbook>
  4308. </xml>
  4309. <![endif]-->
  4310. </head><body>";
  4311. $str .= "<table border=1><tr><td>SKU</td>";
  4312. foreach ($timelist as $k => $v) {
  4313. $str .= "<td>" . $k . "出库</td>";
  4314. $str .= "<td>" . $k . "入库</td>";
  4315. }
  4316. $str .= "</tr></table>";
  4317. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4318. foreach ($rows as $key => $val) {
  4319. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4320. foreach ($val as $k => $v) {
  4321. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4322. if ($val[$k]['r'] > 0) {
  4323. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4324. } else {
  4325. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4326. }
  4327. }
  4328. $str .= "</tr>";
  4329. }
  4330. $str .= "</table>";
  4331. $str .= "</body></html>";
  4332. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4333. header("Content-type: application/octet-stream");
  4334. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4335. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4336. header("Pragma: no-cache");
  4337. header("Expires: 0");
  4338. exit($str);
  4339. }
  4340. }
  4341. //数量调整模板导出
  4342. public function _presetout()
  4343. {
  4344. if (isset($_GET['excel'])) {
  4345. $where = "sku != 'Preset' and purchase != 0";
  4346. //数据排序
  4347. $order_str = "id desc";
  4348. if (empty($page)) {
  4349. $start = 0;
  4350. $perpage = 1;
  4351. } else {
  4352. $start = ($page - 1) * $perpage;
  4353. }
  4354. //取得信息列表
  4355. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4356. $rows = array();
  4357. $list = array();
  4358. foreach ($info_list as $value) {
  4359. $warehouse = $this->warehouse->read($value['warehouse']);
  4360. $number = $value['number'];
  4361. $ftime = time() - 15 * 24 * 3600;
  4362. $purchase = $this->purchase->read($value['purchase']);
  4363. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4364. }
  4365. $title = "库存模板";
  4366. $titlename = "<table border=1>
  4367. <tr align='center'>
  4368. <td>仓库</td>
  4369. <td>供应商编码</td>
  4370. <td>SKU</td>
  4371. <td>增减数量(正数或负数)</td>
  4372. <td>增减备注</td>
  4373. <td>扣减方式:0减少库存1删除库存</td>
  4374. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4375. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4376. </tr>
  4377. </table>";
  4378. $filename = $title . ".xls";
  4379. $tail = "";
  4380. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4381. }
  4382. }
  4383. //数量调整模板导入
  4384. public function _presetedit()
  4385. {
  4386. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4387. $config['upload_path'] = '.' . $dir;
  4388. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4389. $config['allowed_types'] = 'xls|xlsx|csv';
  4390. $config['max_size'] = 10240;
  4391. $this->load->library('upload', $config);
  4392. $this->upload->initialize($config);
  4393. if ($this->upload->do_upload('userfile')) {
  4394. $full_path = $dir . $this->upload->data('file_name');
  4395. $fileName = '.' . $full_path;
  4396. if (!file_exists($fileName)) {
  4397. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4398. exit;
  4399. } else {
  4400. require_once "./data/excel/PHPExcel/IOFactory.php";
  4401. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4402. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4403. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4404. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4405. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4406. ++$column; //如果列数大于26行
  4407. $list = array();
  4408. for ($i = 2; $i <= $row; $i++) // 行数循环
  4409. {
  4410. $data = array();
  4411. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4412. {
  4413. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4414. }
  4415. $list[] = $data;
  4416. }
  4417. }
  4418. $i = 0;
  4419. $j = 0;
  4420. $ed = array();
  4421. foreach ($list as $key => $value) {
  4422. $time = time();
  4423. if ($value['0'] == "") {
  4424. continue;
  4425. }
  4426. $warehouse = $this->warehouse->get_title($value['0']);
  4427. $purchase = $this->purchase->get_bm($value['1']);
  4428. $sku = $value['2'];
  4429. $num = $value['3']; //调整数量
  4430. $text = $value['4']; //扣减说明
  4431. $type = $value['5']; //调整方式0扣减1删除
  4432. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4433. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4434. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4435. if (!$purchase) //如果没有这个SKU
  4436. {
  4437. $ed[] = array($purchase . '-不存在此供应商编码');
  4438. $j++;
  4439. continue;
  4440. }
  4441. if (!$d) //如果没有这个SKU
  4442. {
  4443. $ed[] = array($sku . '-库存中不存在此SKU');
  4444. $j++;
  4445. continue;
  4446. }
  4447. if (!isset($warehouse['id'])) {
  4448. $ed[] = array($sku . '-仓库名错误!');
  4449. $j++;
  4450. continue;
  4451. }
  4452. if ($type != '0' && $type != '1') {
  4453. $ed[] = array($sku . '-扣减方式填写错误!');
  4454. $j++;
  4455. continue;
  4456. }
  4457. if ($num < 0) //扣减库存
  4458. {
  4459. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4460. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4461. $j++;
  4462. continue;
  4463. }
  4464. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4465. if (count($data) < abs($num)) {
  4466. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4467. $j++;
  4468. continue;
  4469. }
  4470. if ($type == 0) //如果扣减方式为 扣减库存
  4471. {
  4472. for ($i = 0; $i < abs($num); $i++) {
  4473. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4474. }
  4475. } else if ($type == 1) {
  4476. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4477. if (count($zt) > 0) {
  4478. $ed[] = array($sku . '-有在途库存无法删除!');
  4479. $j++;
  4480. continue;
  4481. }
  4482. for ($i = 0; $i < abs($num); $i++) {
  4483. $this->whlabel->remove($data[$i]['id']);
  4484. }
  4485. }
  4486. } else if ($num > 0) //增加库存
  4487. {
  4488. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4489. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4490. $j++;
  4491. continue;
  4492. }
  4493. $post['sku'] = $d['sku'];
  4494. $post['shop'] = $d['shop'];
  4495. $post['warehouse'] = $warehouse['id'];
  4496. $post['purchase'] = $purchase['id'];
  4497. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4498. $post['state'] = 0;
  4499. $post['title'] = $d['title'];
  4500. $post['number'] = $d['number'];
  4501. $post['features'] = $d['features'];
  4502. $post['enter'] = $time;
  4503. $post['time'] = $time; //操作时间
  4504. $post['rktype'] = $rktype;
  4505. for ($i = 0; $i < $num; $i++) {
  4506. $post['label'] = time() . rand(100, 999) . $i;
  4507. $this->whlabel->insert($post);
  4508. }
  4509. }
  4510. sleep(1); //防止入库时间一样,需要延迟1秒
  4511. }
  4512. if ($j > 0) {
  4513. $tt = date('Ymd', time());
  4514. $title = '库存导入错误信息-' . $tt;
  4515. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4516. $tail = "\n";
  4517. $filename = $title . ".xls";
  4518. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4519. $dir = '/data/excel/' . $time . '/';
  4520. $file_name = 'error_' . $time . rand(1000, 9999);
  4521. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4522. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4523. fwrite($myfile, $ecl);
  4524. fclose($myfile);
  4525. $error = $dir . $file_name . '.xls';
  4526. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4527. exit;
  4528. } else {
  4529. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4530. exit;
  4531. }
  4532. }
  4533. }
  4534. public function _presetedittwo(){
  4535. $data = $this->input->post(NULL, TRUE);
  4536. if(empty($list)){
  4537. $raw_data = $this->input->raw_input_stream;
  4538. // 解码 JSON
  4539. $data = json_decode($raw_data, true);
  4540. }
  4541. if(empty($data)){
  4542. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4543. }
  4544. $list = [];
  4545. if(isset($data['list'])){
  4546. $list = $data['list'];
  4547. }
  4548. $i = 0;
  4549. $j = 0;
  4550. $ed = array();
  4551. foreach ($list as $key => $value) {
  4552. $time = time();
  4553. if ($value['0'] == "") {
  4554. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4555. $j++;
  4556. continue;
  4557. }
  4558. $warehouse = $this->warehouse->get_title($value['0']);
  4559. if(empty($warehouse)){
  4560. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4561. $j++;
  4562. continue;
  4563. }
  4564. $purchase = $this->purchase->get_bm($value['1']);
  4565. $sku = $value['2'];
  4566. $num = $value['3']; //调整数量
  4567. $text = $value['4']; //扣减说明
  4568. $type = 0; //调整方式0扣减1删除
  4569. $details = empty($value['5'])?'':$value['5']; //库位
  4570. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4571. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4572. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4573. if (!$purchase) //如果没有这个SKU
  4574. {
  4575. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4576. $j++;
  4577. continue;
  4578. }
  4579. if (!$d) //如果没有这个SKU
  4580. {
  4581. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4582. $j++;
  4583. continue;
  4584. }
  4585. if (!isset($warehouse['id'])) {
  4586. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4587. $j++;
  4588. continue;
  4589. }
  4590. if ($type != '0' && $type != '1') {
  4591. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4592. $j++;
  4593. continue;
  4594. }
  4595. if($details != 'DZ001'){
  4596. $kw_info = $this->whlabel->find('warehouse = '.$warehouse['id'].' and sku = "' . $sku . '" and state = 0 and details != "DZ001"');
  4597. //判断是否有货
  4598. if(!empty($kw_info)){
  4599. //判断是否有录入库位了
  4600. if(empty($kw_info['details'])){
  4601. if($kw_info['details'] != $details){
  4602. $ed[] = ['msg'=>$sku . '的在系统中没有库位!'] ;
  4603. $j++;
  4604. continue;
  4605. }
  4606. }else{
  4607. //如果有库位了 但是库位不匹配
  4608. if($kw_info['details'] != $details){
  4609. $ed[] = ['msg'=>$sku . '的系统库位是'.$kw_info['details'].'!'] ;
  4610. $j++;
  4611. continue;
  4612. }
  4613. }
  4614. }
  4615. }
  4616. if ($num < 0) //扣减库存
  4617. {
  4618. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4619. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4620. $j++;
  4621. continue;
  4622. }
  4623. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null)and state = 0 and details = "'. $details .'"');
  4624. if (count($data) < abs($num)) {
  4625. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  4626. $j++;
  4627. continue;
  4628. }
  4629. if ($type == 0) //如果扣减方式为 扣减库存
  4630. {
  4631. for ($i = 0; $i < abs($num); $i++) {
  4632. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4633. }
  4634. } else if ($type == 1) {
  4635. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4636. if (count($zt) > 0) {
  4637. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  4638. $j++;
  4639. continue;
  4640. }
  4641. for ($i = 0; $i < abs($num); $i++) {
  4642. $this->whlabel->remove($data[$i]['id']);
  4643. }
  4644. }
  4645. } else if ($num > 0) //增加库存
  4646. {
  4647. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4648. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4649. $j++;
  4650. continue;
  4651. }
  4652. $post['sku'] = $d['sku'];
  4653. $post['shop'] = $d['shop'];
  4654. $post['warehouse'] = $warehouse['id'];
  4655. $post['purchase'] = $purchase['id'];
  4656. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4657. $post['state'] = 0;
  4658. $post['title'] = $d['title'];
  4659. $post['number'] = $d['number'];
  4660. $post['features'] = $d['features'];
  4661. $post['details'] = $details;
  4662. $post['enter'] = $time;
  4663. $post['time'] = $time; //操作时间
  4664. $post['rktype'] = $rktype;
  4665. $post['sku_master_id'] = $d['sku_master_id'];
  4666. $post['sku_shop_id'] = $d['sku_shop_id'];
  4667. for ($i = 0; $i < $num; $i++) {
  4668. $post['label'] = time() . rand(100, 999) . $i;
  4669. $this->whlabel->insert($post);
  4670. }
  4671. }
  4672. sleep(1); //防止入库时间一样,需要延迟1秒
  4673. }
  4674. if ($j > 0) {
  4675. $tt = date('Ymd', time());
  4676. $title = '库存导入错误信息-' . $tt;
  4677. $error = $title . '.xls';
  4678. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4679. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  4680. exit;
  4681. } else {
  4682. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4683. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4684. exit;
  4685. }
  4686. }
  4687. //笛卡儿积
  4688. function cp($ps, $sets, $list)
  4689. {
  4690. $result = array();
  4691. $j = 0;
  4692. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4693. if ($i == 0) {
  4694. $result = $sets[$i];
  4695. }
  4696. $tmp = array();
  4697. foreach ($result as $res) {
  4698. foreach ($sets[$i + 1] as $set) {
  4699. $tmp[] = $res . ',' . $set;
  4700. }
  4701. }
  4702. $result = $tmp;
  4703. }
  4704. $this->db->trans_begin();
  4705. foreach ($result as $v) {
  4706. $post = array();
  4707. $title = "";
  4708. $num = "";
  4709. $data = explode(',', $v);
  4710. for ($i = 0; $i < count($list); $i++) {
  4711. $post[$list[$i]] = $data[$i];
  4712. $typeclass = $this->typeclass->read($data[$i]);
  4713. $title = $title . $typeclass['title'] . " ";
  4714. if ($data[$i] != 0) {
  4715. $num .= $data[$i]; //所有数据ID拼接
  4716. }
  4717. }
  4718. foreach ($ps as $kp => $vp) {
  4719. $post[$kp] = $vp;
  4720. }
  4721. $post['number'] = $num;
  4722. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4723. if ($info_list) {
  4724. $j++;
  4725. } else {
  4726. $skunum = $this->whlabel->find_count();
  4727. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4728. $post['title'] = rtrim($title, ' ');
  4729. $this->whlabel->insert($post);
  4730. }
  4731. }
  4732. if ($this->db->trans_status() === FALSE) {
  4733. $this->db->trans_commit();
  4734. return NULL;
  4735. } else {
  4736. $this->db->trans_commit();
  4737. return $j;
  4738. }
  4739. }
  4740. public function _kj($arg_array)
  4741. {
  4742. if (isset($_POST['sku'])) {
  4743. $time = time();
  4744. $sku = $this->input->post('sku', true);
  4745. $warehouse = $this->input->post('warehouse', true);
  4746. $num = $this->input->post('num', true);
  4747. $text = $this->input->post('text', true);
  4748. $purchase = $this->input->post('purchase', true);
  4749. $cktype = $this->input->post('cktype', true);
  4750. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4751. if ($cktype != 1 && $text == '') {
  4752. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4753. exit;
  4754. }
  4755. if ($num > count($order)) {
  4756. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4757. exit;
  4758. } else {
  4759. for ($i = 0; $i < $num; $i++) {
  4760. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4761. }
  4762. }
  4763. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4764. exit;
  4765. }
  4766. $uid = $this->whlabel->read($arg_array[0]);
  4767. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4768. $this->data['data'] = $uid;
  4769. $this->_Template('whlabel_kj', $this->data);
  4770. }
  4771. public function _summary($arg_array)
  4772. {
  4773. $prc = array();
  4774. $purchase = $this->purchase->find_all();
  4775. foreach ($purchase as $k => $v) {
  4776. $prc[$v['id']] = $v['title'];
  4777. }
  4778. if (isset($_GET['excel'])) {
  4779. $ktime = $this->input->get('ktime', true);
  4780. $jtime = $this->input->get('jtime', true);
  4781. $ktime = strtotime($ktime);
  4782. $jtime = strtotime($jtime);
  4783. $where = "1=1";
  4784. if ($ktime && $jtime) {
  4785. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4786. }
  4787. //数据排序
  4788. $order_str = "time desc";
  4789. if (empty($page)) {
  4790. $start = 0;
  4791. $perpage = 1;
  4792. } else {
  4793. $start = ($page - 1) * $perpage;
  4794. }
  4795. //取得信息列表
  4796. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4797. foreach ($info_list as $key => $value) {
  4798. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4799. $warehouse = $this->warehouse->read($value['warehouse']);
  4800. $info_list[$key]['warehouse'] = $warehouse['title'];
  4801. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4802. $details = array();
  4803. $cpid = array();
  4804. foreach ($x as $k => $v) {
  4805. if ($v['details'] != '') {
  4806. $details[$v['details']] = $v['details'];
  4807. }
  4808. if ($v['cpid'] != 0) {
  4809. $cpid[$v['cpid']] = $v['cpid'];
  4810. }
  4811. }
  4812. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4813. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4814. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4815. $info_list[$key]['s'] = $s;
  4816. $info_list[$key]['x'] = count($x);
  4817. }
  4818. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4819. $titlename = "<table border=1>
  4820. <tr align='center'>
  4821. <td>仓库</td>
  4822. <td>供应商</td>
  4823. <td>出库位置</td>
  4824. <td>出库编码</td>
  4825. <td>SKU</td>
  4826. <td>产品名</td>
  4827. <td>总剩余库存</td>
  4828. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4829. </tr>
  4830. </table>";
  4831. $filename = $title . ".xls";
  4832. $tail = "";
  4833. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4834. }
  4835. }
  4836. //usps发货清单
  4837. public function _manifest()
  4838. {
  4839. if (isset($_POST['manifest'])) {
  4840. $wltext = $this->input->post('wltext', true);
  4841. $time = time() - 16 * 3600;
  4842. $ptime = strtotime(date('Y-m-d', $time));
  4843. $waybill = array();
  4844. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4845. foreach ($fullorder as $v) {
  4846. $waybill[$v['waybill']] = $v['waybill'];
  4847. }
  4848. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4849. foreach ($fullordersmt as $v) {
  4850. $waybill[$v['waybill']] = $v['waybill'];
  4851. }
  4852. $wltext = explode(';', $wltext);
  4853. foreach ($wltext as $v) {
  4854. if (isset($waybill[$v])) {
  4855. unset($waybill[$v]);
  4856. }
  4857. }
  4858. $data = $this->usps->get_manifest($waybill);
  4859. if (isset($data['Description'])) {
  4860. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4861. exit;
  4862. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4863. $bctime = date('Ymd', time());
  4864. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4865. echo json_encode(array('msg' => $pdf, 'success' => true));
  4866. exit;
  4867. } else {
  4868. echo json_encode(array('msg' => $data, 'success' => false));
  4869. exit;
  4870. }
  4871. }
  4872. }
  4873. public function _pdf($pdf, $title, $bctime)
  4874. {
  4875. $pdf_path = './data/pdf/' . $bctime . '/';
  4876. $file_base64 = $pdf;
  4877. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4878. $file_base64 = base64_decode($file_base64);
  4879. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4880. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4881. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4882. }
  4883. /**
  4884. *
  4885. *
  4886. *
  4887. 进销存占单异常索引
  4888. *
  4889. *
  4890. *
  4891. **/
  4892. public function _abnormal()
  4893. {
  4894. $post = $this->input->post(NULL, TRUE);
  4895. if (isset($post['page'])) {
  4896. $page = $this->input->post('page', true);
  4897. $perpage = $this->input->post('perpage', true);
  4898. $sku = $this->input->post('sku', true);
  4899. $where = "1=1";
  4900. //数据排序
  4901. $order_str = "id desc";
  4902. if (empty($page)) {
  4903. $start = 0;
  4904. $perpage = 1;
  4905. } else {
  4906. $start = ($page - 1) * $perpage;
  4907. }
  4908. //取得信息列表
  4909. $info_list = $this->whlabel->find_all($where, '*');
  4910. $rows = array();
  4911. $list = array();
  4912. foreach ($info_list as $key => $value) {
  4913. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4914. }
  4915. foreach ($rows as $value) {
  4916. $warehouse = $this->warehouse->read($value['warehouse']);
  4917. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4918. $number = $value['number'];
  4919. $ftime = time() - 15 * 24 * 3600;
  4920. if ($value['shop'] != '') {
  4921. $shop = $value['shop'];
  4922. $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');
  4923. $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');
  4924. $order = array_merge($orderdlz, $ordersmt);
  4925. $od = 0;
  4926. $a = '';
  4927. $orid = '';
  4928. foreach ($order as $v) {
  4929. $or = explode('|', ltrim($v['whlabel'], '|'));
  4930. for ($i = 0; $i < count($or); $i++) {
  4931. $orod = explode('-', $or[$i]);
  4932. if ($orod[0] == $number) {
  4933. $od += $orod[1];
  4934. }
  4935. }
  4936. $orid .= $v['number'] . '-';
  4937. }
  4938. } else {
  4939. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4940. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4941. $order = array_merge($orderdlz, $ordersmt);
  4942. $od = 0;
  4943. $a = '';
  4944. $orid = '';
  4945. $qt = array();
  4946. foreach ($order as $v) {
  4947. $or = explode('|', ltrim($v['whlabel'], '|'));
  4948. for ($i = 0; $i < count($or); $i++) {
  4949. $orod = explode('-', $or[$i]);
  4950. if ($orod[0] == $number) {
  4951. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4952. if ($czzs > 0) {
  4953. if (isset($qt[$v['shop']])) {
  4954. if ($qt[$v['shop']] < $orod[1]) {
  4955. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4956. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4957. } else {
  4958. $qt[$v['shop']] -= $orod[1];
  4959. }
  4960. } else {
  4961. $qt[$v['shop']] = $czzs;
  4962. }
  4963. } else {
  4964. $od += $orod[1];
  4965. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4966. }
  4967. }
  4968. }
  4969. }
  4970. }
  4971. $z = $od . '(' . $orid . ')'; //查看订单号
  4972. //$z = $od;
  4973. if ($od > $c) {
  4974. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4975. }
  4976. }
  4977. $listdata = array_slice($list, $start, $perpage);
  4978. $total = count($list);
  4979. $pagenum = ceil($total / $perpage);
  4980. $over = $total - ($start + $perpage);
  4981. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4982. echo json_encode($rows);
  4983. exit;
  4984. }
  4985. $this->_Template('whlabel_abnormal', $this->data);
  4986. }
  4987. /**
  4988. *
  4989. *
  4990. *
  4991. 进销存占单异常索引
  4992. *
  4993. *
  4994. *
  4995. **/
  4996. public function _error()
  4997. {
  4998. $post = $this->input->post(NULL, TRUE);
  4999. if (isset($post['page'])) {
  5000. $page = $this->input->post('page', true);
  5001. $perpage = $this->input->post('perpage', true);
  5002. $sku = $this->input->post('sku', true);
  5003. $warehouse = $this->input->post('warehouse', true);
  5004. $ktime = $this->input->post('ktime', true);
  5005. $jtime = $this->input->post('jtime', true);
  5006. $ktime = strtotime($ktime);
  5007. $jtime = strtotime($jtime);
  5008. $where = "sku != 'Preset'";
  5009. $gj = '';
  5010. if ($sku) {
  5011. $where .= " and sku like '%$sku%'";
  5012. } else {
  5013. if ($ktime && $jtime) {
  5014. $gj = " and time > '$ktime' and time < '$jtime'";
  5015. }
  5016. }
  5017. if ($warehouse) {
  5018. $where .= " and warehouse = '$warehouse'";
  5019. }
  5020. //数据排序
  5021. $order_str = "id desc";
  5022. if (empty($page)) {
  5023. $start = 0;
  5024. $perpage = 1;
  5025. } else {
  5026. $start = ($page - 1) * $perpage;
  5027. }
  5028. //取得信息列表
  5029. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5030. $rows = array();
  5031. $list = array();
  5032. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5033. // foreach ($info_list as $value)
  5034. // {
  5035. // $warehouse = $this->warehouse->read($value['warehouse']);
  5036. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5037. // $number = $value['number'];$ftime = time()-15*24*3600;
  5038. // if($c < 1)
  5039. // {
  5040. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5041. // }
  5042. // }
  5043. $warehouse_list = $this->warehouse->find_all();
  5044. $warehouse_list = array_column($warehouse_list, null, 'id');
  5045. foreach ($info_list as $value) {
  5046. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5047. 'title' => "",
  5048. ];
  5049. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5050. $number = $value['number'];
  5051. $ftime = time() - 15 * 24 * 3600;
  5052. if ($c < 1) {
  5053. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5054. }
  5055. }
  5056. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5057. // $query = $this->db->query($sql);
  5058. // $info_list = $query->result_array();
  5059. // $sql_two = "select title,id from crowd_warehouse";
  5060. // $query_two = $this->db->query($sql_two);
  5061. // $warehouse_list = $query_two->result_array();
  5062. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5063. // foreach ($info_list as $value)
  5064. // {
  5065. // if(isset($warehouse_arr[$value['warehouse']])){
  5066. // $warehouse = $warehouse_arr[$value['warehouse']];
  5067. // }else{
  5068. // $warehouse = [
  5069. // 'id'=>0,
  5070. // 'title'=>"异常",
  5071. // ];
  5072. // }
  5073. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5074. // $number = $value['number'];$ftime = time()-15*24*3600;
  5075. // if($c < 1)
  5076. // {
  5077. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5078. // }
  5079. // }
  5080. $listdata = array_slice($list, $start, $perpage);
  5081. $total = count($list);
  5082. $pagenum = ceil($total / $perpage);
  5083. $over = $total - ($start + $perpage);
  5084. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5085. echo json_encode($rows);
  5086. exit;
  5087. }
  5088. if (isset($post['s'])) {
  5089. $id_arr = $this->input->post('s');
  5090. $id_arr = explode(',', trim($id_arr, ','));
  5091. if (!$id_arr) {
  5092. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5093. exit;
  5094. }
  5095. //循环删除记录
  5096. foreach ($id_arr as $v) {
  5097. $dd = $this->whlabel->read($v);
  5098. if (!isset($dd['id'])) {
  5099. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5100. exit;
  5101. }
  5102. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5103. if (isset($zt[0])) {
  5104. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5105. exit;
  5106. }
  5107. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5108. foreach ($deldd as $vv) {
  5109. $this->whlabel->remove($vv['id']);
  5110. }
  5111. }
  5112. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5113. exit;
  5114. }
  5115. $this->_Template('whlabel_error', $this->data);
  5116. }
  5117. public function _errorexcel()
  5118. {
  5119. $post = $this->input->post(NULL, TRUE);
  5120. if (isset($_GET['page'])) {
  5121. $page = $this->input->get('page', true);
  5122. $perpage = $this->input->get('perpage', true);
  5123. $sku = $this->input->get('sku', true);
  5124. $warehouse = $this->input->get('warehouse', true);
  5125. $ktime = $this->input->get('ktime', true);
  5126. $jtime = $this->input->get('jtime', true);
  5127. $ktime = strtotime($ktime);
  5128. $jtime = strtotime($jtime);
  5129. $where = "sku != 'Preset'";
  5130. $gj = '';
  5131. if ($sku) {
  5132. $where .= " and sku like '%$sku%'";
  5133. } else {
  5134. if ($ktime && $jtime) {
  5135. $gj = " and time > '$ktime' and time < '$jtime'";
  5136. }
  5137. }
  5138. if ($warehouse) {
  5139. $where .= " and warehouse = '$warehouse'";
  5140. }
  5141. //数据排序
  5142. $order_str = "id desc";
  5143. if (empty($page)) {
  5144. $start = 0;
  5145. $perpage = 1;
  5146. } else {
  5147. $start = ($page - 1) * $perpage;
  5148. }
  5149. //取得信息列表
  5150. $rows = array();
  5151. $list = array();
  5152. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5153. foreach ($info_list as $value) {
  5154. $warehouse = $this->warehouse->read($value['warehouse']);
  5155. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5156. $number = $value['number'];
  5157. $ftime = time() - 15 * 24 * 3600;
  5158. if ($c < 1) {
  5159. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5160. }
  5161. }
  5162. $title = "0库存汇总";
  5163. $titlename = "<table border=1>
  5164. <tr align='center'>
  5165. <td>仓库</td>
  5166. <td>SKU</td>
  5167. <td>产品</td>
  5168. <td>当前库存</td>
  5169. </tr>
  5170. </table>";
  5171. $filename = $title . ".xls";
  5172. $tail = "";
  5173. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5174. }
  5175. }
  5176. /**
  5177. *
  5178. *
  5179. * 占单
  5180. *
  5181. *
  5182. **/
  5183. public function _kcyz()
  5184. {
  5185. $post = $this->input->post(NULL, TRUE);
  5186. if (isset($post['warehouse'])) {
  5187. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5188. exit; //不再使用
  5189. $warehouse = $this->input->post('warehouse', true);
  5190. $whlabel = $this->input->post('whlabel', true);
  5191. $id = $this->input->post('id', true);
  5192. $shop = $this->input->post('shop', true);
  5193. $number = $this->input->post('number', true);
  5194. if (!$whlabel || $whlabel == '|') {
  5195. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5196. exit;
  5197. }
  5198. $pp = explode('|', trim($whlabel, '|'));
  5199. $x = 0;
  5200. $save = array();
  5201. foreach ($pp as $va) {
  5202. $num = explode('-', $va);
  5203. if ($number) {
  5204. $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 = '')"); //通用
  5205. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5206. } else {
  5207. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5208. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5209. }
  5210. $x++;
  5211. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5212. $save[] = $x - 1;
  5213. continue; //提前先加X不然出错,所以要减1
  5214. }
  5215. }
  5216. if (isset($save[0])) {
  5217. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5218. exit;
  5219. } else {
  5220. echo json_encode(array('success' => true));
  5221. exit;
  5222. }
  5223. }
  5224. }
  5225. public function _db()
  5226. {
  5227. $post = $this->input->post(NULL, TRUE);
  5228. if (isset($post['page'])) {
  5229. $page = $this->input->post('page', true);
  5230. $perpage = $this->input->post('perpage', true);
  5231. $sku = $this->input->post('sku', true);
  5232. $number = $this->input->post('number', true);
  5233. $warehouse = $this->input->post('warehouse', true);
  5234. $purchase = $this->input->post('purchase', true);
  5235. $orderinfo = $this->input->post('orderinfo', true);
  5236. $waybill = $this->input->post('waybill', true);
  5237. $category = $this->input->post('category', true);
  5238. $size = $this->input->post('size', true);
  5239. $grade = $this->input->post('grade', true);
  5240. $color = $this->input->post('color', true);
  5241. $lowe = $this->input->post('lowe', true);
  5242. $state = $this->input->post('state', true);
  5243. $label = $this->input->post('label', true);
  5244. $timetk = $this->input->post('timetkk', true);
  5245. $timetj = $this->input->post('timetjj', true);
  5246. $timetk = strtotime($timetk);
  5247. $timetj = strtotime($timetj);
  5248. $where = "dbtime > 0";
  5249. if ($timetk && $timetj) {
  5250. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5251. }
  5252. if ($sku) {
  5253. $where .= " and sku = '$sku'";
  5254. }
  5255. if ($warehouse) {
  5256. $where .= " and warehouse = '$warehouse'";
  5257. if ($warehouse == 12) {
  5258. $w = 'specialstock';
  5259. } else {
  5260. $w = 'whlabel';
  5261. }
  5262. }
  5263. if ($purchase) {
  5264. $where .= " and purchase = '$purchase'";
  5265. }
  5266. if ($category) {
  5267. $where .= " and features like '%-$category-%'";
  5268. }
  5269. if ($size) {
  5270. $where .= " and features like '%-$size-%'";
  5271. }
  5272. if ($grade) {
  5273. $where .= " and features like '%-$grade-%'";
  5274. }
  5275. if ($color) {
  5276. $where .= " and features like '%-$color-%'";
  5277. }
  5278. if ($lowe) {
  5279. $where .= " and features like '%-$lowe-%'";
  5280. }
  5281. if ($state != '') {
  5282. $where .= " and state = '$state'";
  5283. }
  5284. //数据排序
  5285. $order_str = "dbtime desc";
  5286. if (empty($page)) {
  5287. $start = 0;
  5288. $perpage = 1;
  5289. } else {
  5290. $start = ($page - 1) * $perpage;
  5291. }
  5292. //取得信息列表
  5293. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5294. foreach ($info_list as $key => $value) {
  5295. $warehouse = $this->$w->read($value['warehouse']);
  5296. $info_list[$key]['warehouse'] = $warehouse['title'];
  5297. $purchase = $this->purchase->read($value['purchase']);
  5298. $info_list[$key]['purchase'] = $purchase['title'];
  5299. if ($value['enter'] != 0) {
  5300. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5301. } else {
  5302. $info_list[$key]['enter'] = "";
  5303. }
  5304. if ($value['dbtime'] != 0) {
  5305. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5306. } else {
  5307. $info_list[$key]['dbtime'] = "";
  5308. }
  5309. if ($value['state'] == 0) {
  5310. $info_list[$key]['state'] = "在库";
  5311. } else if ($value['state'] == 1) {
  5312. $info_list[$key]['state'] = "出库";
  5313. } else if ($value['state'] == 2) {
  5314. $info_list[$key]['state'] = "退库";
  5315. } else if ($value['state'] == 3) {
  5316. $info_list[$key]['state'] = "调拨中";
  5317. } else if ($value['state'] == 4) {
  5318. $info_list[$key]['state'] = "再加工";
  5319. } else if ($value['state'] == 5) {
  5320. $info_list[$key]['state'] = "维修中";
  5321. } else if ($value['state'] == 6) {
  5322. $info_list[$key]['state'] = "盘亏";
  5323. } else if ($value['state'] == 7) {
  5324. $info_list[$key]['state'] = "更换标签";
  5325. } else if ($value['state'] == 8) {
  5326. $info_list[$key]['state'] = "其它";
  5327. } else if ($value['state'] == 9) {
  5328. $info_list[$key]['state'] = "预设";
  5329. }
  5330. }
  5331. $total = $this->whlabel->find_count($where);
  5332. $pagenum = ceil($total / $perpage);
  5333. $over = $total - ($start + $perpage);
  5334. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5335. echo json_encode($rows);
  5336. exit;
  5337. }
  5338. if (isset($post['outsku'])) {
  5339. $time = time();
  5340. $cz = $this->input->post('cz', true);
  5341. $label = $this->input->post('outsku', true);
  5342. $sl = $this->input->post('sl', true);
  5343. $num = $this->input->post('num', true);
  5344. //$warehouse = $this->input->post('warehouse',true);
  5345. if (!$sl) {
  5346. $sl = 1;
  5347. }
  5348. if (!$warehouse) {
  5349. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5350. exit;
  5351. }
  5352. $dblabel = $this->whlabellabel->get_label($label);
  5353. if ($dblabel) {
  5354. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5355. if (count($data) < 1) {
  5356. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5357. exit;
  5358. }
  5359. if (count($data) < $num) {
  5360. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5361. exit;
  5362. }
  5363. for ($i = 0; $i < $sl; $i++) {
  5364. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5365. }
  5366. echo json_encode(array('success' => true));
  5367. exit;
  5368. } else {
  5369. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5370. exit;
  5371. }
  5372. }
  5373. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5374. $this->_Template('whlabel_db', $this->data);
  5375. }
  5376. public function _dbrk()
  5377. {
  5378. $post = $this->input->post(NULL, TRUE);
  5379. if (isset($post['page'])) {
  5380. $page = $this->input->post('page', true);
  5381. $perpage = $this->input->post('perpage', true);
  5382. $sku = $this->input->post('sku', true);
  5383. $number = $this->input->post('number', true);
  5384. $warehouse = $this->input->post('warehouse', true);
  5385. $purchase = $this->input->post('purchase', true);
  5386. $orderinfo = $this->input->post('orderinfo', true);
  5387. $waybill = $this->input->post('waybill', true);
  5388. $category = $this->input->post('category', true);
  5389. $size = $this->input->post('size', true);
  5390. $grade = $this->input->post('grade', true);
  5391. $color = $this->input->post('color', true);
  5392. $lowe = $this->input->post('lowe', true);
  5393. $state = $this->input->post('state', true);
  5394. $label = $this->input->post('label', true);
  5395. $ctime = $this->input->post('ctime', true);
  5396. $timetk = $this->input->post('timetkk', true);
  5397. $timetj = $this->input->post('timetjj', true);
  5398. $timetk = strtotime($timetk);
  5399. $timetj = strtotime($timetj);
  5400. $where = "dbtime > 0";
  5401. if ($timetk && $timetj) {
  5402. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5403. }
  5404. if ($sku) {
  5405. $where .= " and sku = '$sku'";
  5406. }
  5407. if ($warehouse) {
  5408. $where .= " and warehouse = '$warehouse'";
  5409. }
  5410. if ($purchase) {
  5411. $where .= " and purchase = '$purchase'";
  5412. }
  5413. if ($category) {
  5414. $where .= " and features like '%-$category-%'";
  5415. }
  5416. if ($size) {
  5417. $where .= " and features like '%-$size-%'";
  5418. }
  5419. if ($grade) {
  5420. $where .= " and features like '%-$grade-%'";
  5421. }
  5422. if ($color) {
  5423. $where .= " and features like '%-$color-%'";
  5424. }
  5425. if ($lowe) {
  5426. $where .= " and features like '%-$lowe-%'";
  5427. }
  5428. if ($state != '') {
  5429. $where .= " and state = '$state'";
  5430. }
  5431. //数据排序
  5432. $order_str = "dbtime desc";
  5433. if (empty($page)) {
  5434. $start = 0;
  5435. $perpage = 1;
  5436. } else {
  5437. $start = ($page - 1) * $perpage;
  5438. }
  5439. //取得信息列表
  5440. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5441. foreach ($info_list as $key => $value) {
  5442. $warehouse = $this->warehouse->read($value['warehouse']);
  5443. $info_list[$key]['warehouse'] = $warehouse['title'];
  5444. $purchase = $this->purchase->read($value['purchase']);
  5445. $info_list[$key]['purchase'] = $purchase['title'];
  5446. if ($value['enter'] != 0) {
  5447. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5448. } else {
  5449. $info_list[$key]['enter'] = "";
  5450. }
  5451. if ($value['dbtime'] != 0) {
  5452. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5453. } else {
  5454. $info_list[$key]['dbtime'] = "";
  5455. }
  5456. if ($value['state'] == 0) {
  5457. $info_list[$key]['state'] = "在库";
  5458. } else if ($value['state'] == 1) {
  5459. $info_list[$key]['state'] = "出库";
  5460. } else if ($value['state'] == 2) {
  5461. $info_list[$key]['state'] = "退库";
  5462. } else if ($value['state'] == 3) {
  5463. $info_list[$key]['state'] = "调拨中";
  5464. } else if ($value['state'] == 4) {
  5465. $info_list[$key]['state'] = "再加工";
  5466. } else if ($value['state'] == 5) {
  5467. $info_list[$key]['state'] = "维修中";
  5468. } else if ($value['state'] == 6) {
  5469. $info_list[$key]['state'] = "盘亏";
  5470. } else if ($value['state'] == 7) {
  5471. $info_list[$key]['state'] = "更换标签";
  5472. } else if ($value['state'] == 8) {
  5473. $info_list[$key]['state'] = "其它";
  5474. } else if ($value['state'] == 9) {
  5475. $info_list[$key]['state'] = "预设";
  5476. }
  5477. }
  5478. $total = $this->whlabel->find_count($where);
  5479. $pagenum = ceil($total / $perpage);
  5480. $over = $total - ($start + $perpage);
  5481. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5482. echo json_encode($rows);
  5483. exit;
  5484. }
  5485. if (isset($post['rsku'])) {
  5486. $cz = $this->input->post('cz', true);
  5487. $label = $this->input->post('rsku', true);
  5488. $sl = $this->input->post('sl', true);
  5489. $warehouse = $this->input->post('warehouse', true);
  5490. if (!$sl) {
  5491. $sl = 1;
  5492. }
  5493. if (!$warehouse) {
  5494. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5495. exit;
  5496. }
  5497. $dblabel = $this->whlabellabel->get_label($label);
  5498. if ($dblabel) {
  5499. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5500. if (count($data) < 1) {
  5501. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5502. exit;
  5503. }
  5504. if ($sl > count($data)) {
  5505. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5506. exit;
  5507. }
  5508. $time = time();
  5509. for ($i = 0; $i < $sl; $i++) {
  5510. $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']);
  5511. }
  5512. echo json_encode(array('success' => true));
  5513. exit;
  5514. } else {
  5515. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5516. exit;
  5517. }
  5518. }
  5519. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5520. $this->_Template('whlabel_dbrk', $this->data);
  5521. }
  5522. public function _whlabelczdc()
  5523. {
  5524. if (isset($_GET['excel'])) {
  5525. //数据排序
  5526. $order_str = "id desc";
  5527. if (empty($page)) {
  5528. $start = 0;
  5529. $perpage = 1;
  5530. } else {
  5531. $start = ($page - 1) * $perpage;
  5532. }
  5533. $state = $this->input->get('state', true);
  5534. $sku = $this->input->get('sku', true);
  5535. $ctime = $this->input->get('ctime', true);
  5536. $category = $this->input->get('category', true);
  5537. $size = $this->input->get('size', true);
  5538. $grade = $this->input->get('grade', true);
  5539. $color = $this->input->get('color', true);
  5540. $lowe = $this->input->get('lowe', true);
  5541. $timetk = $this->input->get('timetkk', true);
  5542. $timetj = $this->input->get('timetjj', true);
  5543. $timetk = strtotime($timetk);
  5544. $timetj = strtotime($timetj);
  5545. $where = "dbtime > 0";
  5546. if ($timetk && $timetj) {
  5547. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5548. }
  5549. if ($category) {
  5550. $where .= " and features like '%-$category-%'";
  5551. }
  5552. if ($size) {
  5553. $where .= " and features like '%-$size-%'";
  5554. }
  5555. if ($grade) {
  5556. $where .= " and features like '%-$grade-%'";
  5557. }
  5558. if ($color) {
  5559. $where .= " and features like '%-$color-%'";
  5560. }
  5561. if ($lowe) {
  5562. $where .= " and features like '%-$lowe-%'";
  5563. }
  5564. //取得信息列表
  5565. $info_list = $this->whlabel->find_all($where, '*');
  5566. $rows = array();
  5567. $list = array();
  5568. foreach ($info_list as $key => $value) {
  5569. $rows[$value['sku']] = $value; //所有数据sku
  5570. }
  5571. foreach ($rows as $value) {
  5572. $warehouse = $this->warehouse->read($value['warehouse']);
  5573. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5574. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5575. if ($value['orderinfo'] == 0) {
  5576. $info_list[$key]['orderinfo'] = "";
  5577. }
  5578. if ($value['waybill'] == 0) {
  5579. $info_list[$key]['waybill'] = "";
  5580. }
  5581. if ($value['state'] == 0) {
  5582. $value['state'] = "在库";
  5583. } else if ($value['state'] == 3) {
  5584. $value['state'] = "调拨中";
  5585. }
  5586. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5587. }
  5588. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5589. $titlename = "<table border=1>
  5590. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5591. <tr align='center'>
  5592. <td>SKU</td>
  5593. <td>产品</td>
  5594. <td>调拨数量</td>
  5595. <td>入库数量</td>
  5596. </tr>
  5597. </table>";
  5598. $filename = $title . ".xls";
  5599. $tail = "";
  5600. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5601. }
  5602. }
  5603. public function _print($arg_array)
  5604. {
  5605. if (isset($_SESSION['api'])) {
  5606. $user = $this->user->get_api($_SESSION['api']);
  5607. $usp = $user;
  5608. $fgshop = "";
  5609. $sid = "";
  5610. $wid = "";
  5611. $wtype = "";
  5612. $usersp = explode('|', trim($user['shop'], '|'));
  5613. $userwh = explode('|', trim($user['warehouse'], '|'));
  5614. foreach ($usersp as $value) {
  5615. $fgshop .= " shop = " . $value . " or";
  5616. $sid .= " id = " . $value . " or";
  5617. }
  5618. foreach ($userwh as $value) {
  5619. $wid .= " id = " . $value . " or";
  5620. $wtype .= " type = " . $value . " or";
  5621. }
  5622. }
  5623. $post = $this->input->post(NULL, TRUE);
  5624. if (isset($post['tmsku'])) {
  5625. $tmsku = $this->input->post('tmsku', true);
  5626. if (is_numeric($tmsku)) {
  5627. $yyh = $this->whlabellabel->get_label($tmsku);
  5628. } else {
  5629. $yyh = $this->whlabellabel->get_sku($tmsku);
  5630. if(empty($yyh)){
  5631. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5632. if($r['code'] == -1 ){
  5633. echo json_encode(array('success' => false));
  5634. exit;
  5635. }else{
  5636. echo json_encode(array('features' => $r['data'], 'success' => true));
  5637. exit;
  5638. }
  5639. }
  5640. }
  5641. if ($yyh) {
  5642. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5643. exit;
  5644. } else {
  5645. echo json_encode(array('success' => false));
  5646. exit;
  5647. }
  5648. }
  5649. $classid = $this->classid->sku();
  5650. $pm = $classid;
  5651. $scsku = $classid;
  5652. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5653. if (isset($post['warehouse'])) {
  5654. if ($post['warehouse']) {
  5655. $list = array();
  5656. $num = "";
  5657. $title = "";
  5658. $features = "";
  5659. $order = 0;
  5660. $post['shop'] = '';
  5661. $brand = $this->input->post('brand', true);
  5662. if ($brand != '0,') {
  5663. $b = $this->brand->read(rtrim($brand, ','));
  5664. if ($b) {
  5665. $post['shop'] = str_replace('|', ',', $b['shop']);
  5666. }
  5667. }
  5668. $post['details'] = $this->input->post('details', true); //打印数量
  5669. $xbqnum = $this->input->post('xbqnum', true);
  5670. $post['purchase'] = $this->input->post('purchase', true);
  5671. $post['warehouse'] = $this->input->post('warehouse', true);
  5672. $post['purchase'] = $this->input->post('purchase', true);
  5673. $post['retreatwarehouse'] = $post['warehouse'];
  5674. $post['cpbz'] = $this->input->post('cpbz', true);
  5675. $post['state'] = 9;
  5676. $category = $this->input->post('category', true);
  5677. $list['category'] = $category;
  5678. $list['hairtype'] = $this->input->post('hairtype', true);
  5679. $list['grade'] = $this->input->post('grade', true);
  5680. $size = $this->input->post('size', true);
  5681. $list['size'] = rtrim($size, ',');
  5682. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5683. $list['extension'] = $this->input->post('extension', true);
  5684. if ($category == 1297) {
  5685. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5686. }
  5687. if ($category == 1702) {
  5688. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5689. $list['syother'] = $this->input->post('syother', true);
  5690. }
  5691. if ($category == 133) {
  5692. $list['fittype'] = $this->input->post('fittype', true);
  5693. $list['acother'] = $this->input->post('acother', true);
  5694. }
  5695. $list['color'] = $this->input->post('color', true);
  5696. $list['lowe'] = $this->input->post('lowe', true);
  5697. if ($category == 127) {
  5698. $list['type'] = $this->input->post('type', true);
  5699. $list['headroad'] = $this->input->post('headroad', true);
  5700. $list['density'] = $this->input->post('density', true);
  5701. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5702. $list['lacesize'] = $this->input->post('lacesize', true);
  5703. }
  5704. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5705. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5706. }
  5707. if ($category == 128) {
  5708. $list['lacetype'] = $this->input->post('lacetype', true);
  5709. $list['haircap'] = $this->input->post('haircap', true);
  5710. $list['density'] = $this->input->post('density', true);
  5711. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5712. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5713. $list['wigother'] = $this->input->post('wigother', true);
  5714. $list['wigother1'] = $this->input->post('wigother1', true);
  5715. $list['wigother2'] = $this->input->post('wigother2', true);
  5716. $list['product_related'] = $this->input->post('product_related', true);
  5717. }
  5718. if ($category == 129) {
  5719. $list['wide'] = $this->input->post('wide', true);
  5720. }
  5721. if ($category == 131) {
  5722. $list['gifttype'] = $this->input->post('gifttype', true);
  5723. $list['giftother'] = $this->input->post('giftother', true);
  5724. }
  5725. if ($category == 134) {
  5726. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5727. }
  5728. if ($category == 1297) {
  5729. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5730. $list['sywigother'] = $this->input->post('sywigother', true);
  5731. }
  5732. if ($category == 130 || $category == 133 || $category == 1702) {
  5733. $list['items'] = $this->input->post('items', true);
  5734. $list['weight'] = $this->input->post('weight', true);
  5735. }
  5736. if ($category == 1702) {
  5737. $list['syhairther'] = $this->input->post('syhairther', true);
  5738. }
  5739. if($category == 130){
  5740. $list['jfother'] = $this->input->post('jfother', true);
  5741. }
  5742. foreach ($list as $k => $v) {
  5743. if ($v != 0) {
  5744. $num .= $v;
  5745. $features .= $v . '-';
  5746. $post[$k] = $v;
  5747. $typeclass = $this->typeclass->read($v);
  5748. if (isset($pm[$typeclass['classid']])) {
  5749. if (stripos($typeclass['zh'], '|') !== false) {
  5750. $exzh = explode('|', $typeclass['zh']);
  5751. $pm[$typeclass['classid']] = $exzh[0];
  5752. } else {
  5753. $pm[$typeclass['classid']] = $typeclass['zh'];
  5754. }
  5755. }
  5756. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5757. if ($k != 'size') {
  5758. $title .= $typeclass['title'] . " ";
  5759. }
  5760. }
  5761. }
  5762. $typeclass = $this->typeclass->read($list['size']);
  5763. $title .= $typeclass['title'];
  5764. $time = time();
  5765. $post['title'] = rtrim($title, ' ');
  5766. $post['number'] = $num;
  5767. $post['features'] = '-' . $features;
  5768. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5769. $featurespp = explode('-', trim($featurespp, '-'));
  5770. if (isset($featurespp[5])) {
  5771. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5772. } else {
  5773. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5774. }
  5775. $post['enter'] = $time;
  5776. $post['time'] = $time; //操作时间
  5777. $scsku = implode("-", $scsku);
  5778. $zh = implode(" ", $pm);
  5779. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5780. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5781. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5782. $post['sku'] = $bqsku;
  5783. $label = time() . rand(0, 9);
  5784. $post['label'] = $label;
  5785. $cpid = $this->whlabellabel->find_count();
  5786. $post['cpid'] = $cpid + 1;
  5787. $cpid = $post['cpid'];
  5788. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5789. //if($whlabelbarcode)
  5790. //{
  5791. //$post['label'] = $whlabelbarcode['label'];
  5792. //if(!$this->whlabellabel->insert($post))
  5793. //{
  5794. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5795. //}
  5796. //}
  5797. //else
  5798. //{
  5799. $this->db->trans_begin();
  5800. $this->whlabellabel->insert($post);
  5801. //$this->whlabelbarcode->insert($post);
  5802. if ($this->db->trans_status() === TRUE) {
  5803. $this->db->trans_commit();
  5804. } else {
  5805. $this->db->trans_rollback();
  5806. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5807. exit;
  5808. }
  5809. //}
  5810. $warehouse_name = "";
  5811. $warehouse = $post['warehouse'];
  5812. if($warehouse == 12){
  5813. $warehouse_name = "特殊库存库";
  5814. }
  5815. // if($warehouse == 13){
  5816. // $warehouse_name = "许昌仓";
  5817. // }
  5818. // if($warehouse == 5){
  5819. // $warehouse_name = "美国店";
  5820. // }
  5821. // if($warehouse == 16){
  5822. // $warehouse_name = "定制头套仓";
  5823. // }
  5824. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5825. if(!empty($warehouse_name)){
  5826. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5827. }
  5828. $purchase = $this->purchase->read($post['purchase']);
  5829. 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));
  5830. exit; //特殊仓目前不需要仓库选项
  5831. }
  5832. }
  5833. if (isset($_SESSION['api'])) {
  5834. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5835. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5836. $this->data['wlshop'] = $wlshop;
  5837. $this->data['warehouse'] = $warehouse;
  5838. }
  5839. $whlabelwz = $this->whlabelwz->find_all();
  5840. $this->data['whlabelwz'] = $whlabelwz;
  5841. $this->_Template('whlabel_print', $this->data);
  5842. }
  5843. public function _usaprint($arg_array)
  5844. {
  5845. if (isset($_SESSION['api'])) {
  5846. $user = $this->user->get_api($_SESSION['api']);
  5847. $usp = $user;
  5848. $fgshop = "";
  5849. $sid = "";
  5850. $wid = "";
  5851. $wtype = "";
  5852. $usersp = explode('|', trim($user['shop'], '|'));
  5853. $userwh = explode('|', trim($user['warehouse'], '|'));
  5854. foreach ($usersp as $value) {
  5855. $fgshop .= " shop = " . $value . " or";
  5856. $sid .= " id = " . $value . " or";
  5857. }
  5858. foreach ($userwh as $value) {
  5859. $wid .= " id = " . $value . " or";
  5860. $wtype .= " type = " . $value . " or";
  5861. }
  5862. }
  5863. $post = $this->input->post(NULL, TRUE);
  5864. if (isset($post['tmsku'])) {
  5865. $tmsku = $this->input->post('tmsku', true);
  5866. if (is_numeric($tmsku)) {
  5867. $yyh = $this->whlabellabel->get_label($tmsku);
  5868. } else {
  5869. $yyh = $this->whlabellabel->get_sku($tmsku);
  5870. }
  5871. if ($yyh) {
  5872. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5873. exit;
  5874. } else {
  5875. echo json_encode(array('success' => false));
  5876. exit;
  5877. }
  5878. }
  5879. $classid = $this->classid->sku();
  5880. $pm = $classid;
  5881. $scsku = $classid;
  5882. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5883. if (isset($post['warehouse'])) {
  5884. if ($post['warehouse']) {
  5885. $list = array();
  5886. $num = "";
  5887. $title = "";
  5888. $features = "";
  5889. $order = 0;
  5890. $post['shop'] = '';
  5891. $brand = $this->input->post('brand', true);
  5892. if ($brand != '0,') {
  5893. $b = $this->brand->read(rtrim($brand, ','));
  5894. if ($b) {
  5895. $post['shop'] = str_replace('|', ',', $b['shop']);
  5896. }
  5897. }
  5898. $post['details'] = $this->input->post('details', true); //打印数量
  5899. $xbqnum = $this->input->post('xbqnum', true);
  5900. $post['purchase'] = $this->input->post('purchase', true);
  5901. $post['warehouse'] = $this->input->post('warehouse', true);
  5902. $post['purchase'] = $this->input->post('purchase', true);
  5903. $post['retreatwarehouse'] = $post['warehouse'];
  5904. $post['cpbz'] = $this->input->post('cpbz', true);
  5905. $post['state'] = 9;
  5906. $category = $this->input->post('category', true);
  5907. $list['category'] = $category;
  5908. $list['hairtype'] = $this->input->post('hairtype', true);
  5909. $list['grade'] = $this->input->post('grade', true);
  5910. $size = $this->input->post('size', true);
  5911. $list['size'] = rtrim($size, ',');
  5912. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5913. $list['extension'] = $this->input->post('extension', true);
  5914. if ($category == 1297) {
  5915. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5916. }
  5917. if ($category == 1702) {
  5918. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5919. $list['syother'] = $this->input->post('syother', true);
  5920. }
  5921. if ($category == 133) {
  5922. $list['fittype'] = $this->input->post('fittype', true);
  5923. $list['acother'] = $this->input->post('acother', true);
  5924. }
  5925. $list['color'] = $this->input->post('color', true);
  5926. $list['lowe'] = $this->input->post('lowe', true);
  5927. if ($category == 127) {
  5928. $list['type'] = $this->input->post('type', true);
  5929. $list['headroad'] = $this->input->post('headroad', true);
  5930. $list['density'] = $this->input->post('density', true);
  5931. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5932. $list['lacesize'] = $this->input->post('lacesize', true);
  5933. }
  5934. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5935. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5936. }
  5937. if ($category == 128) {
  5938. $list['lacetype'] = $this->input->post('lacetype', true);
  5939. $list['haircap'] = $this->input->post('haircap', true);
  5940. $list['density'] = $this->input->post('density', true);
  5941. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5942. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5943. $list['wigother'] = $this->input->post('wigother', true);
  5944. $list['wigother1'] = $this->input->post('wigother1', true);
  5945. $list['wigother2'] = $this->input->post('wigother2', true);
  5946. $list['product_related'] = $this->input->post('product_related', true);
  5947. }
  5948. if ($category == 129) {
  5949. $list['wide'] = $this->input->post('wide', true);
  5950. }
  5951. if ($category == 131) {
  5952. $list['gifttype'] = $this->input->post('gifttype', true);
  5953. $list['giftother'] = $this->input->post('giftother', true);
  5954. }
  5955. if ($category == 134) {
  5956. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5957. }
  5958. if ($category == 1297) {
  5959. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5960. $list['sywigother'] = $this->input->post('sywigother', true);
  5961. }
  5962. if ($category == 130 || $category == 133 || $category == 1702) {
  5963. $list['items'] = $this->input->post('items', true);
  5964. $list['weight'] = $this->input->post('weight', true);
  5965. }
  5966. if ($category == 1702) {
  5967. $list['syhairther'] = $this->input->post('syhairther', true);
  5968. }
  5969. foreach ($list as $k => $v) {
  5970. if ($v != 0) {
  5971. $num .= $v;
  5972. $features .= $v . '-';
  5973. $post[$k] = $v;
  5974. $typeclass = $this->typeclass->read($v);
  5975. if (isset($pm[$typeclass['classid']])) {
  5976. if (stripos($typeclass['zh'], '|') !== false) {
  5977. $exzh = explode('|', $typeclass['zh']);
  5978. $pm[$typeclass['classid']] = $exzh[0];
  5979. } else {
  5980. $pm[$typeclass['classid']] = $typeclass['zh'];
  5981. }
  5982. }
  5983. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5984. if ($k != 'size') {
  5985. $title .= $typeclass['title'] . " ";
  5986. }
  5987. }
  5988. }
  5989. $typeclass = $this->typeclass->read($list['size']);
  5990. $title .= $typeclass['title'];
  5991. $time = time();
  5992. $post['title'] = rtrim($title, ' ');
  5993. $post['number'] = $num;
  5994. $post['features'] = '-' . $features;
  5995. $fp = $this->whlabel->get_features($post['features']);
  5996. if (!$fp) {
  5997. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5998. exit;
  5999. }
  6000. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6001. $featurespp = explode('-', trim($featurespp, '-'));
  6002. if (isset($featurespp[5])) {
  6003. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6004. } else {
  6005. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6006. }
  6007. $post['enter'] = $time;
  6008. $post['time'] = $time; //操作时间
  6009. $scsku = implode("-", $scsku);
  6010. $zh = implode(" ", $pm);
  6011. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6012. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6013. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6014. $post['sku'] = $fp['sku'];
  6015. $post['label'] = $fp['sku'];
  6016. $cpid = $this->whlabellabel->find_count();
  6017. $post['cpid'] = $cpid + 1;
  6018. $cpid = $post['cpid'];
  6019. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6020. //if($whlabelbarcode)
  6021. //{
  6022. //$post['label'] = $whlabelbarcode['label'];
  6023. //if(!$this->whlabellabel->insert($post))
  6024. //{
  6025. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6026. //}
  6027. //}
  6028. //else
  6029. //{
  6030. $this->db->trans_begin();
  6031. $this->whlabellabel->insert($post);
  6032. //$this->whlabelbarcode->insert($post);
  6033. if ($this->db->trans_status() === TRUE) {
  6034. $this->db->trans_commit();
  6035. } else {
  6036. $this->db->trans_rollback();
  6037. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6038. exit;
  6039. }
  6040. //}
  6041. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6042. $purchase = $this->purchase->read($post['purchase']);
  6043. 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));
  6044. exit; //特殊仓目前不需要仓库选项
  6045. }
  6046. }
  6047. if (isset($_SESSION['api'])) {
  6048. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6049. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6050. $this->data['wlshop'] = $wlshop;
  6051. $this->data['warehouse'] = $warehouse;
  6052. }
  6053. $whlabelwz = $this->whlabelwz->find_all();
  6054. $this->data['whlabelwz'] = $whlabelwz;
  6055. $this->_Template('whlabel_usaprint', $this->data);
  6056. }
  6057. public function _printrk($arg_array)
  6058. {
  6059. $prc = array();
  6060. $purchase = $this->purchase->find_all();
  6061. foreach ($purchase as $k => $v) {
  6062. $prc[$v['id']] = $v['title'];
  6063. }
  6064. $post = $this->input->post(NULL, TRUE);
  6065. if (isset($post['page'])) {
  6066. $page = $this->input->post('page', true);
  6067. $perpage = $this->input->post('perpage', true);
  6068. $sku = $this->input->post('sku', true);
  6069. $bs = $this->input->post('bs', true);
  6070. $number = $this->input->post('number', true);
  6071. $warehouse = $this->input->post('warehouse', true);
  6072. $purchase = $this->input->post('purchase', true);
  6073. $orderinfo = $this->input->post('orderinfo', true);
  6074. $waybill = $this->input->post('waybill', true);
  6075. $category = $this->input->post('category', true);
  6076. $size = $this->input->post('size', true);
  6077. $grade = $this->input->post('grade', true);
  6078. $color = $this->input->post('color', true);
  6079. $lowe = $this->input->post('lowe', true);
  6080. $state = $this->input->post('state', true);
  6081. $label = $this->input->post('label', true);
  6082. $timetk = $this->input->post('ktime', true);
  6083. $timetj = $this->input->post('jtime', true);
  6084. $timetk = strtotime($timetk);
  6085. $timetj = strtotime($timetj);
  6086. $where = "1=1 ";
  6087. if ($timetk && $timetj) {
  6088. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6089. }
  6090. if ($sku) {
  6091. $where .= " and sku = '$sku'";
  6092. }
  6093. if ($bs != '') {
  6094. $where .= " and bs = '$bs'";
  6095. }
  6096. if ($number) {
  6097. $where .= " and number = '$number'";
  6098. }
  6099. if ($warehouse) {
  6100. $where .= " and warehouse = '$warehouse'";
  6101. }
  6102. if ($purchase) {
  6103. $where .= " and purchase = '$purchase'";
  6104. }
  6105. if ($orderinfo) {
  6106. $where .= " and orderinfo = '$orderinfo'";
  6107. }
  6108. if ($waybill) {
  6109. $where .= " and waybill = '$waybill'";
  6110. }
  6111. if ($category) {
  6112. $where .= " and features like '%-$category-%'";
  6113. }
  6114. if ($size) {
  6115. $where .= " and features like '%-$size-%'";
  6116. }
  6117. if ($grade) {
  6118. $where .= " and features like '%-$grade-%'";
  6119. }
  6120. if ($color) {
  6121. $where .= " and features like '%-$color-%'";
  6122. }
  6123. if ($lowe) {
  6124. $where .= " and features like '%-$lowe-%'";
  6125. }
  6126. if ($label) {
  6127. $where .= " and label = '$label'";
  6128. }
  6129. if ($state || $state == 0) {
  6130. $where .= " and state = '$state'";
  6131. }
  6132. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6133. //数据排序
  6134. $order_str = "enter desc";
  6135. if (empty($page)) {
  6136. $start = 0;
  6137. $perpage = 1;
  6138. } else {
  6139. $start = ($page - 1) * $perpage;
  6140. }
  6141. //取得信息列表
  6142. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6143. foreach ($info_list as $key => $value) {
  6144. $warehouse = $this->warehouse->read($value['warehouse']);
  6145. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6146. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6147. if ($value['state'] == 0) {
  6148. $info_list[$key]['state'] = "在库";
  6149. } else if ($value['state'] == 1) {
  6150. $info_list[$key]['state'] = "出库";
  6151. } else if ($value['state'] == 2) {
  6152. $info_list[$key]['state'] = "退库";
  6153. } else if ($value['state'] == 3) {
  6154. $info_list[$key]['state'] = "调拨中";
  6155. } else if ($value['state'] == 4) {
  6156. $info_list[$key]['state'] = "再加工";
  6157. } else if ($value['state'] == 5) {
  6158. $info_list[$key]['state'] = "维修中";
  6159. } else if ($value['state'] == 6) {
  6160. $info_list[$key]['state'] = "盘亏";
  6161. } else if ($value['state'] == 7) {
  6162. $info_list[$key]['state'] = "更换标签";
  6163. } else if ($value['state'] == 8) {
  6164. $info_list[$key]['state'] = "其它";
  6165. } else if ($value['state'] == 9) {
  6166. $info_list[$key]['state'] = "预设";
  6167. } else if ($value['state'] == 10) {
  6168. $info_list[$key]['state'] = "美店零售";
  6169. }
  6170. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6171. }
  6172. $total = $this->$ck->find_count($where);
  6173. $pagenum = ceil($total / $perpage);
  6174. $over = $total - ($start + $perpage);
  6175. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6176. echo json_encode($rows);
  6177. exit;
  6178. }
  6179. if (isset($post['tmsku'])) {
  6180. $time = time();
  6181. $tmsku = $this->input->post('tmsku', true);
  6182. //$post['shop'] = $this->input->post('shop',true);
  6183. $num = $this->input->post('num', true);
  6184. $rktype = $this->input->post('rktype', true);
  6185. if ($num > 200) {
  6186. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6187. exit;
  6188. }
  6189. if (!$rktype) {
  6190. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6191. }
  6192. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6193. /**
  6194. $wz = array();
  6195. foreach ($rk as $key=>$value)
  6196. {
  6197. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6198. }
  6199. if(count($wz) > 1)
  6200. {
  6201. $wz = array_values($wz);
  6202. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6203. }
  6204. **/
  6205. if (isset($rk[0]['purchase'])) {
  6206. $rk = $rk[0];
  6207. $j = 0;
  6208. $post['purchase'] = $rk['purchase'];
  6209. $post['warehouse'] = $rk['warehouse'];
  6210. $post['retreatwarehouse'] = $rk['warehouse'];
  6211. $post['sku'] = $rk['sku'];
  6212. $post['number'] = $rk['number'];
  6213. $post['features'] = $rk['features'];
  6214. $post['title'] = $rk['title'];
  6215. $post['enter'] = $time;
  6216. $post['time'] = $time;
  6217. $post['bs'] = 1;
  6218. $post['shop'] = $rk['shop'];
  6219. $post['details'] = $rk['details'];
  6220. $post['cpid'] = $rk['cpid'];
  6221. $post['cpbz'] = $rk['cpbz'];
  6222. $post['rktype'] = $rktype;
  6223. $warehouse = $this->warehouse->read($rk['warehouse']);
  6224. if ($warehouse['bdck'] == '') {
  6225. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6226. exit;
  6227. } else {
  6228. $bdck = $warehouse['bdck'];
  6229. }
  6230. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6231. if (isset($pdwz['details'])) {
  6232. if ($pdwz['details'] != $post['details']) {
  6233. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6234. }else{
  6235. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6236. exit;
  6237. }
  6238. }
  6239. }
  6240. $post['featurespp'] = $rk['featurespp'];
  6241. if ($post['warehouse'] == '5') {
  6242. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6243. if ($yza) {
  6244. if ($post['features'] != $yza[0]['features']) {
  6245. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6246. exit;
  6247. }
  6248. }
  6249. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6250. if ($yzb) {
  6251. if ($post['sku'] != $yzb[0]['sku']) {
  6252. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6253. exit;
  6254. }
  6255. }
  6256. }
  6257. for ($i = 0; $i < $num; $i++) {
  6258. $post['label'] = time() . rand(100, 999) . $i;
  6259. if ($this->$bdck->insert($post)) {
  6260. $j++;
  6261. }
  6262. }
  6263. /**
  6264. if($post['warehouse'] != 12)
  6265. {
  6266. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6267. }
  6268. **/
  6269. $this->whlabelscanlog->insert([
  6270. 'shop'=>$rk['shop'],
  6271. 'type'=>1,
  6272. 'purchase'=>$rk['purchase'],
  6273. 'sku'=>$rk['sku'],
  6274. 'features'=>$rk['features'],
  6275. 'title'=>$rk['title'],
  6276. 'label'=>$rk['label'],
  6277. 'warehouse'=>$rk['warehouse'],
  6278. 'wlid'=>$rk['id'],
  6279. 'num'=>$num,
  6280. 'addtime'=>time()
  6281. ]);
  6282. if ($j == $num) {
  6283. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6284. exit;
  6285. } else {
  6286. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6287. exit;
  6288. }
  6289. } else {
  6290. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6291. exit;
  6292. }
  6293. }
  6294. $this->_Template('whlabel_printrk', $this->data);
  6295. }
  6296. public function _printxzrk($arg_array)
  6297. {
  6298. $post = $this->input->post(NULL, TRUE);
  6299. if (isset($post['wzid'])) {
  6300. $time = time();
  6301. $id = $this->input->post('wzid', true);
  6302. //$post['shop'] = $this->input->post('shop',true);
  6303. $num = 1;
  6304. $rk = $this->whlabellabel->read($id);
  6305. if (isset($rk['purchase'])) {
  6306. $x = 0;
  6307. $post['purchase'] = $rk['purchase'];
  6308. $post['warehouse'] = $rk['warehouse'];
  6309. $post['retreatwarehouse'] = $rk['warehouse'];
  6310. $post['sku'] = $rk['sku'];
  6311. $post['number'] = $rk['number'];
  6312. $post['features'] = $rk['features'];
  6313. $post['title'] = $rk['title'];
  6314. $post['enter'] = $time;
  6315. $post['time'] = $time;
  6316. $post['bs'] = 1;
  6317. $post['shop'] = $rk['shop'];
  6318. $post['details'] = $rk['details'];
  6319. $post['cpid'] = $rk['cpid'];
  6320. $post['cpbz'] = $rk['cpbz'];
  6321. $warehouse = $this->warehouse->read($rk['warehouse']);
  6322. if ($warehouse['bdck'] == '') {
  6323. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6324. exit;
  6325. } else {
  6326. $bdck = $warehouse['bdck'];
  6327. }
  6328. $post['featurespp'] = $rk['featurespp'];
  6329. $this->db->trans_begin();
  6330. for ($i = 0; $i < $num; $i++) {
  6331. $post['label'] = time() . rand(100, 999) . $i;
  6332. $this->$bdck->insert($post);
  6333. }
  6334. /**
  6335. if($post['warehouse'] != 12)
  6336. {
  6337. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6338. }
  6339. **/
  6340. if ($this->db->trans_status() === TRUE) {
  6341. $this->db->trans_commit();
  6342. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6343. exit;
  6344. } else {
  6345. $this->db->trans_rollback();
  6346. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6347. exit;
  6348. }
  6349. } else {
  6350. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6351. exit;
  6352. }
  6353. }
  6354. }
  6355. public function _printck($arg_array)
  6356. {
  6357. $prc = array();
  6358. $purchase = $this->purchase->find_all();
  6359. foreach ($purchase as $k => $v) {
  6360. $prc[$v['id']] = $v['title'];
  6361. }
  6362. $post = $this->input->post(NULL, TRUE);
  6363. if (isset($post['page'])) {
  6364. $page = $this->input->post('page', true);
  6365. $perpage = $this->input->post('perpage', true);
  6366. $sku = $this->input->post('sku', true);
  6367. $bs = $this->input->post('bs', true);
  6368. $number = $this->input->post('number', true);
  6369. $warehouse = $this->input->post('warehouse', true);
  6370. $purchase = $this->input->post('purchase', true);
  6371. $orderinfo = $this->input->post('orderinfo', true);
  6372. $waybill = $this->input->post('waybill', true);
  6373. $category = $this->input->post('category', true);
  6374. $size = $this->input->post('size', true);
  6375. $grade = $this->input->post('grade', true);
  6376. $color = $this->input->post('color', true);
  6377. $lowe = $this->input->post('lowe', true);
  6378. $state = $this->input->post('state', true);
  6379. $label = $this->input->post('label', true);
  6380. $timetk = $this->input->post('ktime', true);
  6381. $timetj = $this->input->post('jtime', true);
  6382. $timetk = strtotime($timetk);
  6383. $timetj = strtotime($timetj);
  6384. $where = "state=1 ";
  6385. if ($timetk && $timetj) {
  6386. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6387. }
  6388. if ($sku) {
  6389. $where .= " and sku = '$sku'";
  6390. }
  6391. if ($bs != '') {
  6392. $where .= " and bs = '$bs'";
  6393. }
  6394. if ($number) {
  6395. $where .= " and number = '$number'";
  6396. }
  6397. if ($warehouse) {
  6398. $where .= " and warehouse = '$warehouse'";
  6399. }
  6400. if ($purchase) {
  6401. $where .= " and purchase = '$purchase'";
  6402. }
  6403. if ($orderinfo) {
  6404. $where .= " and orderinfo = '$orderinfo'";
  6405. }
  6406. if ($waybill) {
  6407. $where .= " and waybill = '$waybill'";
  6408. }
  6409. if ($category) {
  6410. $where .= " and features like '%-$category-%'";
  6411. }
  6412. if ($size) {
  6413. $where .= " and features like '%-$size-%'";
  6414. }
  6415. if ($grade) {
  6416. $where .= " and features like '%-$grade-%'";
  6417. }
  6418. if ($color) {
  6419. $where .= " and features like '%-$color-%'";
  6420. }
  6421. if ($lowe) {
  6422. $where .= " and features like '%-$lowe-%'";
  6423. }
  6424. if ($label) {
  6425. $where .= " and label = '$label'";
  6426. }
  6427. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6428. //数据排序
  6429. $order_str = "outk desc";
  6430. if (empty($page)) {
  6431. $start = 0;
  6432. $perpage = 1;
  6433. } else {
  6434. $start = ($page - 1) * $perpage;
  6435. }
  6436. //取得信息列表
  6437. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6438. foreach ($info_list as $key => $value) {
  6439. $warehouse = $this->warehouse->read($value['warehouse']);
  6440. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6441. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6442. if ($value['state'] == 0) {
  6443. $info_list[$key]['state'] = "在库";
  6444. } else if ($value['state'] == 1) {
  6445. $info_list[$key]['state'] = "出库";
  6446. } else if ($value['state'] == 2) {
  6447. $info_list[$key]['state'] = "退库";
  6448. } else if ($value['state'] == 3) {
  6449. $info_list[$key]['state'] = "调拨中";
  6450. } else if ($value['state'] == 4) {
  6451. $info_list[$key]['state'] = "再加工";
  6452. } else if ($value['state'] == 5) {
  6453. $info_list[$key]['state'] = "维修中";
  6454. } else if ($value['state'] == 6) {
  6455. $info_list[$key]['state'] = "盘亏";
  6456. } else if ($value['state'] == 7) {
  6457. $info_list[$key]['state'] = "更换标签";
  6458. } else if ($value['state'] == 8) {
  6459. $info_list[$key]['state'] = "其它";
  6460. } else if ($value['state'] == 9) {
  6461. $info_list[$key]['state'] = "预设";
  6462. } else if ($value['state'] == 10) {
  6463. $info_list[$key]['state'] = "美店零售";
  6464. }
  6465. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6466. }
  6467. $total = $this->$ck->find_count($where);
  6468. $pagenum = ceil($total / $perpage);
  6469. $over = $total - ($start + $perpage);
  6470. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6471. echo json_encode($rows);
  6472. exit;
  6473. }
  6474. if (isset($post['tmsku'])) {
  6475. $time = time();
  6476. $tmsku = $this->input->post('tmsku', true);
  6477. //$post['shop'] = $this->input->post('shop',true);
  6478. $num = $this->input->post('num', true);
  6479. $cktype = $this->input->post('cktype', true);
  6480. $label = $this->whlabellabel->get_label($tmsku);
  6481. if (!$cktype) {
  6482. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6483. }
  6484. if (!isset($label['warehouse'])) {
  6485. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6486. exit;
  6487. }
  6488. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6489. $extra_where = "";
  6490. if(!empty($label['details'])){
  6491. $extra_where .= " and details = '" . $label['details'] . "'";
  6492. }
  6493. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6494. if (stripos($label['features'], '-126-') !== false) {
  6495. $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);
  6496. } else {
  6497. $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);
  6498. }
  6499. $j = 0;
  6500. if (count($ck) >= $num) {
  6501. for ($i = 0; $i < $num; $i++) {
  6502. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6503. {
  6504. $j++;
  6505. }
  6506. }
  6507. $this->whlabelscanlog->insert([
  6508. 'shop'=>$label['shop'],
  6509. 'type'=>2,
  6510. 'purchase'=>$label['purchase'],
  6511. 'sku'=>$label['sku'],
  6512. 'features'=>$label['features'],
  6513. 'title'=>$label['title'],
  6514. 'label'=>$label['label'],
  6515. 'warehouse'=>$label['warehouse'],
  6516. 'wlid'=>$label['id'],
  6517. 'num'=>$num,
  6518. 'addtime'=>time()
  6519. ]);
  6520. if ($j == $num) {
  6521. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6522. exit;
  6523. } else {
  6524. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6525. exit;
  6526. }
  6527. } else {
  6528. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6529. exit;
  6530. }
  6531. }
  6532. if(isset($_SESSION['api']))
  6533. {
  6534. $user = $this->user->get_api($_SESSION['api']);
  6535. if(in_array($user['power'],[1,27])){
  6536. $vip = 1;
  6537. }
  6538. }
  6539. else
  6540. {
  6541. $vip = 0;
  6542. header('Location: /');exit;
  6543. }
  6544. $this->data['vip'] = $vip;
  6545. $this->_Template('whlabel_printck', $this->data);
  6546. }
  6547. public function _printexcel()
  6548. {
  6549. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6550. $config['upload_path'] = '.' . $dir;
  6551. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6552. $config['allowed_types'] = 'xls|xlsx|csv';
  6553. $config['max_size'] = 10240;
  6554. $this->load->library('upload', $config);
  6555. $this->upload->initialize($config);
  6556. if ($this->upload->do_upload('userfile')) {
  6557. $full_path = $dir . $this->upload->data('file_name');
  6558. $fileName = '.' . $full_path;
  6559. if (!file_exists($fileName)) {
  6560. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6561. exit;
  6562. } else {
  6563. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6564. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6565. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6566. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6567. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6568. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6569. ++$column; //如果列数大于26行
  6570. $list = array();
  6571. for ($i = 2; $i <= $row; $i++) // 行数循环
  6572. {
  6573. $data = array();
  6574. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6575. {
  6576. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6577. }
  6578. $list[] = $data;
  6579. }
  6580. }
  6581. $ed = array();
  6582. $i = 0;
  6583. $j = 0;
  6584. $dcdata = array();
  6585. $yc = '';
  6586. $cmf_arr = array_column($list, '1');
  6587. array_multisort($cmf_arr, SORT_ASC, $list);
  6588. foreach ($list as $key => $value) {
  6589. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6590. if ($typeclass) {
  6591. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6592. } else {
  6593. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6594. $i++;
  6595. continue;
  6596. }
  6597. }
  6598. if ($i > 0) {
  6599. $yc = $i . '条异常';
  6600. }
  6601. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6602. exit;
  6603. }
  6604. }
  6605. public function _uck()
  6606. {
  6607. if (isset($_GET['excel'])) {
  6608. $tc = array();
  6609. $typeclass = $this->typeclass->find_all();
  6610. foreach ($typeclass as $v) {
  6611. $tc[$v['id']] = $v['zh'];
  6612. }
  6613. $data = array();
  6614. $t = array();
  6615. $rq = '';
  6616. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6617. $ts = $ts / (24 * 3600);
  6618. for ($i = 0; $i < $ts; $i++) {
  6619. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6620. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6621. }
  6622. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6623. foreach ($info_list as $k => $v) {
  6624. $features = explode('-', trim($v['features'], '-'));
  6625. if (!isset($features[3]) || !isset($features[4])) {
  6626. continue;
  6627. }
  6628. $data[$k][0] = $tc[$features[0]]; //类型
  6629. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6630. $data[$k][2] = $tc[$features[4]]; //曲度
  6631. $data[$k][3] = '';
  6632. if (isset($data[$k][1])) {
  6633. $data[$k][3] .= $data[$k][1];
  6634. }
  6635. if (isset($data[$k][2])) {
  6636. $data[$k][3] .= $data[$k][2];
  6637. }
  6638. if (isset($features[5])) {
  6639. $data[$k][3] .= $tc[$features[5]];
  6640. }
  6641. if (isset($features[2])) {
  6642. $data[$k][3] .= $tc[$features[2]];
  6643. }
  6644. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6645. $data[$k][4] = $v['sku'];
  6646. $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())) . '))'); //月初库存
  6647. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6648. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6649. $ztrq = '';
  6650. $ztsl = '';
  6651. if (count($zt) > 0) {
  6652. foreach ($zt as $vv) {
  6653. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6654. $ztsl .= $vv['num'] . '<br>';
  6655. }
  6656. }
  6657. $data[$k][] = trim($ztsl, '<br>');
  6658. $data[$k][] = trim($ztrq, '<br>');
  6659. $byck = 0;
  6660. foreach ($t as $vv) {
  6661. $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));
  6662. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6663. $byck += $sl;
  6664. }
  6665. $data[$k][] = ($byck > 0) ? $byck : '';
  6666. }
  6667. $title = "详情 " . date("Y-m-d", time());
  6668. $titlename = "<table border=1>
  6669. <tr align='center'>
  6670. <td>类别</td>
  6671. <td>颜色</td>
  6672. <td>曲度</td>
  6673. <td>名称</td>
  6674. <td>SKU</td>
  6675. <td>月初库存</td>
  6676. <td>剩余库存</td>
  6677. <td>在途数量</td>
  6678. <td>预达日期</td>" .
  6679. $rq
  6680. . "<td>本月出库</td></tr>
  6681. </table>";
  6682. $filename = $title . ".xls";
  6683. $tail = "";
  6684. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  6685. }
  6686. }
  6687. public function _whlabelexcelzh()
  6688. {
  6689. if (isset($_GET['excel'])) {
  6690. $where = "sku != 'Preset'";
  6691. //数据排序
  6692. $order_str = "id desc";
  6693. if (empty($page)) {
  6694. $start = 0;
  6695. $perpage = 1;
  6696. } else {
  6697. $start = ($page - 1) * $perpage;
  6698. }
  6699. $category = $this->input->get('category', true);
  6700. $warehouse = $this->input->get('warehouse', true);
  6701. $excelid = $this->input->get('sid', true);
  6702. if ($category) {
  6703. $where .= " and features like '%-$category-%'";
  6704. }
  6705. if ($warehouse) {
  6706. $where .= " and warehouse = '$warehouse'";
  6707. }
  6708. $xzid = '';
  6709. if ($excelid) {
  6710. $excelid = explode(',', trim($excelid, ','));
  6711. foreach ($excelid as $key => $value) {
  6712. $xzid .= " id = " . $value . " or";
  6713. }
  6714. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6715. }
  6716. //取得信息列表
  6717. /**
  6718. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6719. $rows = array();$list = array();
  6720. foreach ($info_list as $key=>$value)
  6721. {
  6722. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6723. }
  6724. **/
  6725. $list = array();
  6726. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6727. foreach ($rows as $key => $value) {
  6728. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6729. $zh = '';
  6730. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6731. foreach ($zt as $v) {
  6732. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6733. }
  6734. $zt = array_sum(array_column($zt, 'num'));
  6735. $number = $value['number'];
  6736. $ftime = time() - 15 * 24 * 3600;
  6737. $warehouse = $this->warehouse->read($value['warehouse']);
  6738. $rows[$key]['warehouse'] = $warehouse['title'];
  6739. $rows[$key]['number'] = $c;
  6740. $rows[$key]['features'] = $zh;
  6741. $rows[$key]['hb'] = $c + $zt;
  6742. }
  6743. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6744. $titlename = "<table border=1>
  6745. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6746. <tr align='center'>
  6747. <td>仓库</td>
  6748. <td>SKU</td>
  6749. <td>产品</td>
  6750. <td>库存数量</td>
  6751. <td>在途数量及预达日期</td>
  6752. <td>在途+库存数量</td>
  6753. </tr>
  6754. </table>";
  6755. $filename = $title . ".xls";
  6756. $tail = "";
  6757. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6758. }
  6759. if (isset($_GET['excel'])) {
  6760. $warehouse = $this->input->get('warehouse', true);
  6761. $sku = $this->input->get('sku', true);
  6762. $cz = $this->input->get('cz', true);
  6763. $text = $this->input->post('text', true);
  6764. $xztime = $this->input->get('xztime', true);
  6765. $timetk = $this->input->get('timetk', true);
  6766. $timetj = $this->input->get('timetj', true);
  6767. $timetk = strtotime($timetk);
  6768. $timetj = strtotime($timetj);
  6769. $where = "time = '0' ";
  6770. if ($warehouse) {
  6771. $where .= " and warehouse = '$warehouse'";
  6772. }
  6773. if ($sku) {
  6774. $where .= " and sku = '$sku'";
  6775. }
  6776. if ($text) {
  6777. $where .= " and text like '%$text%'";
  6778. }
  6779. if ($cz != '') {
  6780. $where .= " and cz = '$cz'";
  6781. }
  6782. if ($timetk && $timetj) {
  6783. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6784. }
  6785. //数据排序
  6786. $order_str = $xztime . " desc";
  6787. //取得信息列表
  6788. $zh = array();
  6789. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6790. foreach ($info_list as $v) {
  6791. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6792. $warehouse = $this->warehouse->read($v['warehouse']);
  6793. $v['warehouse'] = $warehouse['title'];
  6794. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6795. $v['stime'] = date('Y-m-d', $v['stime']);
  6796. if (isset($zh[$v['features']])) {
  6797. $zh[$v['features']]['num'] += $v['num'];
  6798. } else {
  6799. $zh[$v['features']] = $v;
  6800. }
  6801. $zh[$v['features']]['features'] = $c;
  6802. }
  6803. $title = "在途数据" . date('Y-m-d', time());
  6804. $titlename = "<table border=1>
  6805. <tr align='center'>
  6806. <td>仓库</td>
  6807. <td>SKU</td>
  6808. <td>名称</td>
  6809. <td>在途数量</td>
  6810. <td>库存数量</td>
  6811. <td>添加在途日期</td>
  6812. <td>预达日期</td>
  6813. <td>备注</td>
  6814. </tr>
  6815. </table>";
  6816. $filename = $title . ".xls";
  6817. $tail = "";
  6818. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6819. }
  6820. }
  6821. public function _fc()
  6822. {
  6823. $vip = 0;
  6824. if (isset($_SESSION['api'])) {
  6825. $user = $this->user->get_api($_SESSION['api']);
  6826. if ($user['vip'] == 1) {
  6827. $vip = 1;
  6828. }
  6829. } else {
  6830. header('Location: /');
  6831. exit;
  6832. }
  6833. $post = $this->input->post(NULL, TRUE);
  6834. if (isset($post['page'])) {
  6835. $page = $this->input->post('page', true);
  6836. $perpage = $this->input->post('perpage', true);
  6837. $category = $this->input->post('category', true);
  6838. $size = $this->input->post('size', true);
  6839. $grade = $this->input->post('grade', true);
  6840. $color = $this->input->post('color', true);
  6841. $lowe = $this->input->post('lowe', true);
  6842. $sku = $this->input->post('sku');
  6843. $title = $this->input->post('title');
  6844. $warehouse = $this->input->post('warehouse', true);
  6845. $usa = $this->input->post('usa', true);
  6846. $purchase = $this->input->post('purchase', true);
  6847. $lacetype = $this->input->post('lacetype', true);
  6848. $haircap = $this->input->post('haircap', true);
  6849. $density = $this->input->post('density', true);
  6850. $details = $this->input->post('details', true);
  6851. $state = $this->input->post('state', true);
  6852. $ktime = $this->input->post('ktime', true);
  6853. $jtime = $this->input->post('jtime', true);
  6854. $ktime = strtotime($ktime);
  6855. $jtime = strtotime($jtime);
  6856. $where = "state = '11'";
  6857. $gj = "";
  6858. $ck = "";
  6859. if ($lacetype) {
  6860. $where .= " and features like '%-$lacetype-%'";
  6861. }
  6862. if ($category) {
  6863. $where .= " and features like '%-$category-%'";
  6864. }
  6865. if ($size) {
  6866. $where .= " and features like '%-$size-%'";
  6867. }
  6868. if ($grade) {
  6869. $where .= " and features like '%-$grade-%'";
  6870. }
  6871. if ($color) {
  6872. $where .= " and features like '%-$color-%'";
  6873. }
  6874. if ($lowe) {
  6875. $where .= " and features like '%-$lowe-%'";
  6876. }
  6877. if ($haircap) {
  6878. $where .= " and features like '%-$haircap-%'";
  6879. }
  6880. if ($density) {
  6881. $where .= " and features like '%-$density-%'";
  6882. }
  6883. if ($usa) {
  6884. if (!$warehouse) {
  6885. $where .= " and (warehouse = '5' or warehouse = '8')";
  6886. }
  6887. }
  6888. if ($warehouse) {
  6889. $where .= " and warehouse = '$warehouse'";
  6890. }
  6891. if ($details) {
  6892. $where .= " and details = '$details'";
  6893. }
  6894. if ($purchase) {
  6895. $where .= " and purchase = '$purchase'";
  6896. }
  6897. if ($state) {
  6898. $where .= " and state = '$state'";
  6899. }
  6900. if ($ktime && $jtime) {
  6901. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6902. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6903. }
  6904. //数据排序
  6905. $order_str = "id desc";
  6906. if (empty($page)) {
  6907. $start = 0;
  6908. $perpage = 1;
  6909. } else {
  6910. $start = ($page - 1) * $perpage;
  6911. }
  6912. if ($sku) {
  6913. $sku = trim($sku, ' ');
  6914. $sku = trim($sku, ' ');
  6915. $where .= " and sku like '%$sku%'";
  6916. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6917. } else if ($title) {
  6918. $title = trim($title, ' ');
  6919. $title = trim($title, ' ');
  6920. $where .= " and title like '%$title%'";
  6921. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6922. } else {
  6923. //$where .= " and time > '$ktime' and time < '$jtime'";
  6924. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6925. }
  6926. //取得信息列表
  6927. $rows = array();
  6928. $list = array();
  6929. foreach ($info_list as $key => $value) {
  6930. $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'] . '"');
  6931. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6932. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6933. $warehouse = $this->warehouse->read($value['warehouse']);
  6934. $info_list[$key]['warehouse'] = $warehouse['title'];
  6935. $info_list[$key]['number'] = $g;
  6936. $info_list[$key]['features'] = $x;
  6937. $info_list[$key]['x'] = $s;
  6938. }
  6939. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6940. $pagenum = ceil($total / $perpage);
  6941. $over = $total - ($start + $perpage);
  6942. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6943. echo json_encode($rows);
  6944. exit;
  6945. }
  6946. $this->data['vip'] = $vip;
  6947. $this->_Template('whlabel_fc', $this->data);
  6948. }
  6949. public function _fcmb()
  6950. {
  6951. $where = "sku != 'Preset'";
  6952. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6953. foreach ($rows as $k => $v) {
  6954. $warehouse = $this->warehouse->read($v['warehouse']);
  6955. $rows[$k]['warehouse'] = $warehouse['title'];
  6956. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6957. $rows[$k]['t'] = '';
  6958. $rows[$k]['n'] = '';
  6959. }
  6960. $title = "封货产品数据导入模板";
  6961. $titlename = "<table border=1>
  6962. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6963. <tr align='center'>
  6964. <td>仓库</td>
  6965. <td>SKU</td>
  6966. <td>产品</td>
  6967. <td>封存产品总数量</td>
  6968. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6969. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6970. </tr>
  6971. </table>";
  6972. $filename = $title . ".xls";
  6973. $tail = "";
  6974. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6975. }
  6976. public function _fcexcel()
  6977. {
  6978. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6979. $config['upload_path'] = '.' . $dir;
  6980. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6981. $config['allowed_types'] = 'xls|xlsx|csv';
  6982. $config['max_size'] = 10240;
  6983. $this->load->library('upload', $config);
  6984. $this->upload->initialize($config);
  6985. if ($this->upload->do_upload('userfile')) {
  6986. $full_path = $dir . $this->upload->data('file_name');
  6987. $fileName = '.' . $full_path;
  6988. if (!file_exists($fileName)) {
  6989. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6990. exit;
  6991. } else {
  6992. libxml_use_internal_errors(true);
  6993. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6994. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6995. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6996. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6997. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6998. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6999. ++$column; //如果列数大于26行
  7000. $list = array();
  7001. for ($i = 2; $i <= $row; $i++) // 行数循环
  7002. {
  7003. $data = array();
  7004. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7005. {
  7006. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7007. }
  7008. $list[] = $data;
  7009. }
  7010. }
  7011. $i = 0;
  7012. $j = 0;
  7013. $ed = array();
  7014. foreach ($list as $key => $value) {
  7015. $time = time();
  7016. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7017. continue;
  7018. }
  7019. $warehouse = $this->warehouse->get_title($value['0']);
  7020. $sku = $value['1'];
  7021. $type = $value['4']; //调整方式0扣减1删除
  7022. $num = $value['5']; //调整数量
  7023. //$text = $value['4'];//扣减说明
  7024. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7025. if (!$d) //如果没有这个SKU
  7026. {
  7027. $ed[] = array($sku . '-库存中不存在此SKU');
  7028. $j++;
  7029. continue;
  7030. }
  7031. if (!isset($warehouse['id'])) {
  7032. $ed[] = array($sku . '-仓库名错误!');
  7033. $j++;
  7034. continue;
  7035. }
  7036. if ($type == 1 || $type == 2) //扣减库存
  7037. {
  7038. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7039. if (count($data) < abs($num)) {
  7040. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7041. $j++;
  7042. continue;
  7043. }
  7044. if ($type == 1) //转入库存
  7045. {
  7046. for ($i = 0; $i < abs($num); $i++) {
  7047. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7048. }
  7049. } else if ($type == 2) //删除
  7050. {
  7051. for ($i = 0; $i < abs($num); $i++) {
  7052. $this->whlabel->remove($data[$i]['id']);
  7053. }
  7054. }
  7055. } else if ($type == 0) //增加库存
  7056. {
  7057. $post['sku'] = $d['sku'];
  7058. $post['shop'] = '';
  7059. $post['warehouse'] = $warehouse['id'];
  7060. $post['purchase'] = $d['purchase'];
  7061. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7062. $post['state'] = 11;
  7063. $post['title'] = $d['title'];
  7064. $post['number'] = $d['number'];
  7065. $post['features'] = $d['features'];
  7066. $post['enter'] = $time;
  7067. $post['time'] = $time; //操作时间
  7068. for ($i = 0; $i < $num; $i++) {
  7069. $post['label'] = time() . rand(100, 999) . $i;
  7070. $this->whlabel->insert($post);
  7071. }
  7072. }
  7073. sleep(1); //防止入库时间一样,需要延迟1秒
  7074. }
  7075. if ($j > 0) {
  7076. $tt = date('Ymd', time());
  7077. $title = '库存导入错误信息-' . $tt;
  7078. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7079. $tail = "\n";
  7080. $filename = $title . ".xls";
  7081. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7082. $dir = '/data/excel/' . $time . '/';
  7083. $file_name = 'error_' . $time . rand(1000, 9999);
  7084. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7085. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7086. fwrite($myfile, $ecl);
  7087. fclose($myfile);
  7088. $error = $dir . $file_name . '.xls';
  7089. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7090. exit;
  7091. } else {
  7092. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7093. exit;
  7094. }
  7095. }
  7096. }
  7097. public function _fcjxc($arg_array)
  7098. {
  7099. if (isset($_GET['excel'])) {
  7100. $category = $this->input->get('category', true);
  7101. $size = $this->input->get('size', true);
  7102. $grade = $this->input->get('grade', true);
  7103. $color = $this->input->get('color', true);
  7104. $lowe = $this->input->get('lowe', true);
  7105. $sku = $this->input->get('sku');
  7106. $title = $this->input->get('title');
  7107. $warehouse = $arg_array[0];
  7108. $usa = $this->input->get('usa', true);
  7109. $purchase = $this->input->get('purchase', true);
  7110. $lacetype = $this->input->get('lacetype', true);
  7111. $haircap = $this->input->get('haircap', true);
  7112. $density = $this->input->get('density', true);
  7113. $title = $this->input->get('title', true);
  7114. $state = $this->input->get('state', true);
  7115. $ktime = $this->input->get('ktime', true);
  7116. $jtime = $this->input->get('jtime', true);
  7117. $where = "state=11";
  7118. $gj = "";
  7119. $ck = "";
  7120. if ($lacetype) {
  7121. $where .= " and features like '%-$lacetype-%'";
  7122. }
  7123. if ($category) {
  7124. $where .= " and features like '%-$category-%'";
  7125. }
  7126. if ($size) {
  7127. $where .= " and features like '%-$size-%'";
  7128. }
  7129. if ($grade) {
  7130. $where .= " and features like '%-$grade-%'";
  7131. }
  7132. if ($color) {
  7133. $where .= " and features like '%-$color-%'";
  7134. }
  7135. if ($lowe) {
  7136. $where .= " and features like '%-$lowe-%'";
  7137. }
  7138. if ($haircap) {
  7139. $where .= " and features like '%-$haircap-%'";
  7140. }
  7141. if ($density) {
  7142. $where .= " and features like '%-$density-%'";
  7143. }
  7144. if ($usa) {
  7145. if (!$warehouse) {
  7146. $where .= " and (warehouse = '5' or warehouse = '8')";
  7147. }
  7148. }
  7149. if ($warehouse) {
  7150. $where .= " and warehouse = '$warehouse'";
  7151. }
  7152. if ($purchase) {
  7153. $where .= " and purchase = '$purchase'";
  7154. }
  7155. if ($state) {
  7156. $where .= " and state = '$state'";
  7157. }
  7158. $order_str = "id desc";
  7159. if ($sku) {
  7160. $sku = trim($sku, ' ');
  7161. $sku = trim($sku, ' ');
  7162. $where .= " and sku like '%$sku%'";
  7163. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7164. } else if ($title) {
  7165. $title = trim($title, ' ');
  7166. $title = trim($title, ' ');
  7167. $where .= " and title like '%$title%'";
  7168. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7169. } else {
  7170. //$where .= " and time > '$ktime' and time < '$jtime'";
  7171. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7172. }
  7173. //取得信息列表
  7174. $rows = array();
  7175. $list = array();
  7176. foreach ($info_list as $key => $value) {
  7177. $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'] . '"');
  7178. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7179. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7180. $rows[$key] = $value;
  7181. $warehouse = $this->warehouse->read($value['warehouse']);
  7182. $rows[$key]['warehouse'] = $warehouse['title'];
  7183. $rows[$key]['features'] = $g;
  7184. $rows[$key]['a'] = $x;
  7185. $rows[$key]['b'] = $s;
  7186. }
  7187. $title = "总统计表";
  7188. $titlename = "<table border=1>
  7189. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7190. <tr align='center'>
  7191. <td>仓库</td>
  7192. <td>SKU</td>
  7193. <td>产品名称</td>
  7194. <td>录入总量</td>
  7195. <td>取出总量</td>
  7196. <td>剩余总量</td>
  7197. </tr>
  7198. </table>";
  7199. $filename = $title . ".xls";
  7200. $tail = "";
  7201. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7202. }
  7203. $vip = 0;
  7204. if (isset($_SESSION['api'])) {
  7205. $user = $this->user->get_api($_SESSION['api']);
  7206. if ($user['vip'] == 1) {
  7207. $vip = 1;
  7208. }
  7209. } else {
  7210. header('Location: /');
  7211. exit;
  7212. }
  7213. $post = $this->input->post(NULL, TRUE);
  7214. if (isset($post['page'])) {
  7215. $page = $this->input->post('page', true);
  7216. $perpage = $this->input->post('perpage', true);
  7217. $category = $this->input->post('category', true);
  7218. $size = $this->input->post('size', true);
  7219. $grade = $this->input->post('grade', true);
  7220. $color = $this->input->post('color', true);
  7221. $lowe = $this->input->post('lowe', true);
  7222. $sku = $this->input->post('sku');
  7223. $title = $this->input->post('title');
  7224. $warehouse = $arg_array[0];
  7225. $usa = $this->input->post('usa', true);
  7226. $purchase = $this->input->post('purchase', true);
  7227. $lacetype = $this->input->post('lacetype', true);
  7228. $haircap = $this->input->post('haircap', true);
  7229. $density = $this->input->post('density', true);
  7230. $title = $this->input->post('title', true);
  7231. $state = $this->input->post('state', true);
  7232. $ktime = $this->input->post('ktime', true);
  7233. $jtime = $this->input->post('jtime', true);
  7234. $ktime = strtotime($ktime);
  7235. $jtime = strtotime($jtime);
  7236. $where = "state=11";
  7237. $gj = "";
  7238. $ck = "";
  7239. if ($lacetype) {
  7240. $where .= " and features like '%-$lacetype-%'";
  7241. }
  7242. if ($category) {
  7243. $where .= " and features like '%-$category-%'";
  7244. }
  7245. if ($size) {
  7246. $where .= " and features like '%-$size-%'";
  7247. }
  7248. if ($grade) {
  7249. $where .= " and features like '%-$grade-%'";
  7250. }
  7251. if ($color) {
  7252. $where .= " and features like '%-$color-%'";
  7253. }
  7254. if ($lowe) {
  7255. $where .= " and features like '%-$lowe-%'";
  7256. }
  7257. if ($haircap) {
  7258. $where .= " and features like '%-$haircap-%'";
  7259. }
  7260. if ($density) {
  7261. $where .= " and features like '%-$density-%'";
  7262. }
  7263. if ($usa) {
  7264. if (!$warehouse) {
  7265. $where .= " and (warehouse = '5' or warehouse = '8')";
  7266. }
  7267. }
  7268. if ($warehouse) {
  7269. $where .= " and warehouse = '$warehouse'";
  7270. }
  7271. if ($purchase) {
  7272. $where .= " and purchase = '$purchase'";
  7273. }
  7274. if ($state) {
  7275. $where .= " and state = '$state'";
  7276. }
  7277. if ($ktime && $jtime) {
  7278. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7279. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7280. }
  7281. //数据排序
  7282. $order_str = "id desc";
  7283. $xs = 0;
  7284. $rows = array();
  7285. $list = array();
  7286. if (empty($page)) {
  7287. $start = 0;
  7288. $perpage = 1;
  7289. } else {
  7290. $start = ($page - 1) * $perpage;
  7291. }
  7292. if ($sku || $title) {
  7293. if ($title) {
  7294. $title = trim($title, ' ');
  7295. $title = trim($title, ' ');
  7296. $where .= " and title like '%$title%'";
  7297. } else {
  7298. $sku = trim($sku, ' ');
  7299. $sku = trim($sku, ' ');
  7300. $where .= " and sku like '%$sku%'";
  7301. }
  7302. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7303. foreach ($info_list as $key => $value) {
  7304. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  7305. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7306. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7307. $rows[$key] = $value;
  7308. $warehouse = $this->warehouse->read($value['warehouse']);
  7309. $rows[$key]['warehouse'] = $warehouse['title'];
  7310. $rows[$key]['features'] = $g;
  7311. $rows[$key]['a'] = $x;
  7312. $rows[$key]['b'] = $s;
  7313. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7314. $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天销量
  7315. $yj = $c / ($xl / 30);
  7316. if ($yj < 7) {
  7317. $rows[$key]['y'] = round($yj) . '天销量';
  7318. } else {
  7319. $rows[$key]['y'] = '正常';
  7320. }
  7321. }
  7322. } else {
  7323. //$where .= " and time > '$ktime' and time < '$jtime'";
  7324. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7325. foreach ($info_list as $key => $value) {
  7326. $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'] . '"');
  7327. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7328. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7329. $zs[$key] = $value;
  7330. $warehouse = $this->warehouse->read($value['warehouse']);
  7331. $zs[$key]['warehouse'] = $warehouse['title'];
  7332. $zs[$key]['features'] = $g;
  7333. $zs[$key]['a'] = $x;
  7334. $zs[$key]['b'] = $s;
  7335. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7336. $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天销量
  7337. $yj = $c / ($xl / 30);
  7338. if ($yj < 7) {
  7339. $zs[$key]['y'] = round($yj) . '天销量';
  7340. $rows[$key] = $zs[$key];
  7341. }
  7342. }
  7343. }
  7344. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7345. $pagenum = ceil($total / $perpage);
  7346. $over = $total - ($start + $perpage);
  7347. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7348. echo json_encode($rows);
  7349. exit;
  7350. }
  7351. $this->data['arg_array'] = $arg_array[0];
  7352. $this->_Template('whlabel_fcjxc', $this->data);
  7353. }
  7354. public function _0kcdel()
  7355. {
  7356. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7357. $config['upload_path'] = '.' . $dir;
  7358. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7359. $config['allowed_types'] = 'xls|xlsx|csv';
  7360. $config['max_size'] = 10240;
  7361. $this->load->library('upload', $config);
  7362. $this->upload->initialize($config);
  7363. if ($this->upload->do_upload('userfile')) {
  7364. $full_path = $dir . $this->upload->data('file_name');
  7365. $fileName = '.' . $full_path;
  7366. if (!file_exists($fileName)) {
  7367. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7368. exit;
  7369. } else {
  7370. require_once "./data/excel/PHPExcel/IOFactory.php";
  7371. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7372. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7373. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7374. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7375. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7376. ++$column; //如果列数大于26行
  7377. $list = array();
  7378. for ($i = 2; $i <= $row; $i++) // 行数循环
  7379. {
  7380. $data = array();
  7381. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7382. {
  7383. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7384. }
  7385. $list[] = $data;
  7386. }
  7387. }
  7388. $i = 0;
  7389. $j = 0;
  7390. $ed = array();
  7391. foreach ($list as $key => $value) {
  7392. $time = time();
  7393. if ($value['0'] == "" || $value['1'] == "") {
  7394. continue;
  7395. }
  7396. $warehouse = $this->warehouse->get_title($value['0']);
  7397. $sku = $value['1'];
  7398. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7399. if (!$d) //如果没有这个SKU
  7400. {
  7401. $ed[] = array($sku . '-库存中不存在此SKU');
  7402. $j++;
  7403. continue;
  7404. }
  7405. if (!isset($warehouse['id'])) {
  7406. $ed[] = array($sku . '-仓库名错误!');
  7407. $j++;
  7408. continue;
  7409. }
  7410. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7411. if ($z < 1) {
  7412. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7413. foreach ($z as $v) {
  7414. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7415. if (count($zt) > 0) {
  7416. $ed[] = array($sku . '-有在途库存无法删除!');
  7417. $j++;
  7418. continue;
  7419. }
  7420. $this->whlabel->remove($v['id']);
  7421. }
  7422. } else {
  7423. $ed[] = array($sku . '-非0库存!');
  7424. $j++;
  7425. continue;
  7426. }
  7427. }
  7428. if ($j > 0) {
  7429. $tt = date('Ymd', time());
  7430. $title = '删除0库存错误信息-' . $tt;
  7431. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7432. $tail = "\n";
  7433. $filename = $title . ".xls";
  7434. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7435. $dir = '/data/excel/' . $time . '/';
  7436. $file_name = 'error_' . $time . rand(1000, 9999);
  7437. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7438. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7439. fwrite($myfile, $ecl);
  7440. fclose($myfile);
  7441. $error = $dir . $file_name . '.xls';
  7442. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7443. exit;
  7444. } else {
  7445. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7446. exit;
  7447. }
  7448. }
  7449. }
  7450. public function _gbhtype()
  7451. {
  7452. $post = $this->input->post(NULL, TRUE);
  7453. if (isset($post['s'])) {
  7454. $n = $this->input->post('n');
  7455. $d = $this->input->post('s');
  7456. if (!$d) {
  7457. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7458. exit;
  7459. }
  7460. $d = explode(',', trim($d, ','));
  7461. $t = $this->whlabel_type->read($n);
  7462. //循环删除记录
  7463. foreach ($d as $v) {
  7464. $u = $this->whlabel->read($v);
  7465. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7466. foreach ($data as $val) {
  7467. $this->whlabel->save(array('type' => $n), $val['id']);
  7468. }
  7469. }
  7470. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7471. }
  7472. }
  7473. //出库、退库导出
  7474. public function _dccrtype()
  7475. {
  7476. $classid = $this->classid->sku();
  7477. $pm = $classid;
  7478. $typeclass = array();
  7479. $tc = $this->typeclass->find_all();
  7480. foreach ($tc as $v) {
  7481. $typeclass[$v['id']] = $v;
  7482. }
  7483. $prc = array();
  7484. $purchase = $this->purchase->find_all();
  7485. foreach ($purchase as $k => $v) {
  7486. $prc[$v['id']] = $v['title'];
  7487. }
  7488. if (isset($_GET['sid'])) {
  7489. $wh = array();
  7490. $w = $this->warehouse->find_all('1=1', 'id,title');
  7491. foreach ($w as $v) {
  7492. $wh[$v['id']] = $v['title'];
  7493. }
  7494. $type = $this->input->get('excel', true);
  7495. $category = $this->input->get('category', true);
  7496. $size = $this->input->get('size', true);
  7497. $grade = $this->input->get('grade', true);
  7498. $color = $this->input->get('color', true);
  7499. $lowe = $this->input->get('lowe', true);
  7500. $sku = $this->input->get('sku', true);
  7501. $warehouse = $this->input->get('warehouse', true);
  7502. $lacetype = $this->input->get('lacetype', true);
  7503. $lacecolor = $this->input->get('lacecolor', true);
  7504. $density = $this->input->get('density', true);
  7505. $haircap = $this->input->get('haircap', true);
  7506. $purchase = $this->input->get('purchase', true);
  7507. $title = $this->input->get('title', true);
  7508. $state = $this->input->get('state', true);
  7509. $sid = $this->input->get('sid', true);
  7510. $ktime = $this->input->get('ktime', true);
  7511. $jtime = $this->input->get('jtime', true);
  7512. $ktime = strtotime($ktime);
  7513. $jtime = strtotime($jtime);
  7514. $where = "1=1";
  7515. $gj = "";
  7516. $ck = "";
  7517. if ($category) {
  7518. $where .= " and features like '%-$category-%'";
  7519. }
  7520. if ($size) {
  7521. $where .= " and features like '%-$size-%'";
  7522. }
  7523. if ($grade) {
  7524. $where .= " and features like '%-$grade-%'";
  7525. }
  7526. if ($color) {
  7527. $where .= " and features like '%-$color-%'";
  7528. }
  7529. if ($lowe) {
  7530. $where .= " and features like '%-$lowe-%'";
  7531. }
  7532. if ($warehouse) {
  7533. $where .= " and warehouse = '$warehouse'";
  7534. }
  7535. if ($purchase) {
  7536. $where .= " and purchase = '$purchase'";
  7537. }
  7538. if ($state) {
  7539. $where .= " and state = '$state'";
  7540. }
  7541. if ($lacetype) {
  7542. $where .= " and features like '%-$lacetype-%'";
  7543. }
  7544. if ($lacecolor) {
  7545. $where .= " and features like '%-$lacecolor-%'";
  7546. }
  7547. if ($density) {
  7548. $where .= " and features like '%-$density-%'";
  7549. }
  7550. if ($haircap) {
  7551. $where .= " and features like '%-$haircap-%'";
  7552. }
  7553. if ($title) {
  7554. $title = trim($title, ' ');
  7555. $title = trim($title, ' ');
  7556. $where .= " and title like '%$title%'";
  7557. }
  7558. if ($sku) {
  7559. $sku = trim($sku, ' ');
  7560. $sku = trim($sku, ' ');
  7561. $where .= " and sku like '%$sku%'";
  7562. }
  7563. if ($ktime && $jtime) {
  7564. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7565. }
  7566. $sidwhere = '';
  7567. if ($sid) {
  7568. $sd = "";
  7569. $s = explode(',', trim($sid, ','));
  7570. foreach ($s as $value) {
  7571. $sd .= " id = " . $value . " or";
  7572. }
  7573. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7574. }
  7575. //数据排序
  7576. $order_str = "time desc";
  7577. if (empty($page)) {
  7578. $start = 0;
  7579. $perpage = 1;
  7580. } else {
  7581. $start = ($page - 1) * $perpage;
  7582. }
  7583. $wh = array();
  7584. $w = $this->warehouse->find_all('1=1', 'id,title');
  7585. foreach ($w as $v) {
  7586. $wh[$v['id']] = $v['title'];
  7587. }
  7588. $wt = array();
  7589. $whlabel_type = $this->whlabel_type->find_all();
  7590. foreach ($whlabel_type as $v) {
  7591. $wt[$v['id']] = $v['title'];
  7592. }
  7593. $classid = $this->classid->sku();
  7594. $list = array();
  7595. $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');
  7596. foreach ($rows_r as $key => $value) {
  7597. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7598. $pm = $classid;
  7599. $jm = $classid;
  7600. $rows_r[$key]['enter'] = '入库';
  7601. $rows_r[$key]['time'] = $value['enter'];
  7602. if ($value['rktype'] == 1) {
  7603. $rows_r[$key]['rktype'] = '采购入库';
  7604. } else if ($value['rktype'] == 2) {
  7605. $rows_r[$key]['rktype'] = '盘盈调整';
  7606. } else if ($value['rktype'] == 3) {
  7607. $rows_r[$key]['rktype'] = '其他调整入库';
  7608. } else if ($value['rktype'] == 4) {
  7609. $rows_r[$key]['rktype'] = '其他调整入库';
  7610. } else if ($value['rktype'] == 5) {
  7611. $rows_r[$key]['rktype'] = '退库入库';
  7612. } else if ($value['rktype'] == 6) {
  7613. $rows_r[$key]['rktype'] = '退货可用入库';
  7614. } else if ($value['rktype'] == 7) {
  7615. $rows_r[$key]['rktype'] = '形态转换入库';
  7616. } else {
  7617. $rows_r[$key]['rktype'] = '';
  7618. }
  7619. $features = explode('-', trim($value['features'], '-'));
  7620. foreach ($features as $v) {
  7621. if (isset($typeclass[$v])) {
  7622. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7623. $pm[$typeclass[$v]['classid']] = $zh[0];
  7624. }
  7625. if (isset($typeclass[$v])) {
  7626. if (isset($jm[$typeclass[$v]['classid']])) {
  7627. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7628. }
  7629. }
  7630. }
  7631. $zh = implode(" ", $pm);
  7632. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7633. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7634. $rows_r[$key]['zh'] = $zh;
  7635. $jm = array_filter($jm);
  7636. $rows_r[$key]['features'] = implode("-", $jm);
  7637. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7638. }
  7639. $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');
  7640. foreach ($rows_c as $key => $value) {
  7641. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7642. $pm = $classid;
  7643. $jm = $classid;
  7644. $rows_c[$key]['time'] = $value['outk'];
  7645. $rows_c[$key]['outk'] = '出库';
  7646. if ($value['cktype'] == 1) {
  7647. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7648. } else if ($value['cktype'] == 2) {
  7649. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7650. } else if ($value['cktype'] == 3) {
  7651. $rows_c[$key]['cktype'] = '盘亏调整';
  7652. } else if ($value['cktype'] == 4) {
  7653. $rows_c[$key]['cktype'] = '其他调整出库';
  7654. } else if ($value['cktype'] == 5) {
  7655. $rows_c[$key]['cktype'] = '形态转换出库';
  7656. } else {
  7657. $rows_c[$key]['cktype'] = '';
  7658. }
  7659. unset($rows_c[$key]['state']);
  7660. $features = explode('-', trim($value['features'], '-'));
  7661. foreach ($features as $v) {
  7662. if (isset($typeclass[$v])) {
  7663. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7664. $pm[$typeclass[$v]['classid']] = $zh[0];
  7665. }
  7666. if (isset($typeclass[$v])) {
  7667. if (isset($jm[$typeclass[$v]['classid']])) {
  7668. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7669. }
  7670. }
  7671. }
  7672. $zh = implode(" ", $pm);
  7673. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7674. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7675. $rows_c[$key]['zh'] = $zh;
  7676. $jm = array_filter($jm);
  7677. $rows_c[$key]['features'] = implode("-", $jm);
  7678. $rows_c[$key]['number'] = 1;
  7679. }
  7680. $merged = $rows_r;
  7681. foreach ($rows_c as $key => $value) {
  7682. if (isset($merged[$key])) {
  7683. $merged[] = $value;
  7684. } else {
  7685. $merged[$key] = $value;
  7686. }
  7687. }
  7688. usort($merged, function ($a, $b) {
  7689. return $a['time'] - $b['time'];
  7690. });
  7691. foreach ($merged as $key => $value) {
  7692. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7693. }
  7694. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7695. $titlename = "<table border=1>
  7696. <tr align='center'>
  7697. <td>仓库</td>
  7698. <td>SKU</td>
  7699. <td>商品名称</td>
  7700. <td>仓库品名</td>
  7701. <td>料号</td>
  7702. <td>时间</td>
  7703. <td>操作</td>
  7704. <td>类型</td>
  7705. <td>数量</td>
  7706. <td>备注</td>
  7707. </tr>
  7708. </table>";
  7709. $filename = $title . ".xlsx";
  7710. $tail = "";
  7711. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  7712. }
  7713. }
  7714. /*************************************处理exceljs导出****************************************************/
  7715. public function _excelrjs(){
  7716. if (isset($_GET['excel'])) {
  7717. $category = $this->input->get('category', true);
  7718. $size = $this->input->get('size', true);
  7719. $grade = $this->input->get('grade', true);
  7720. $color = $this->input->get('color', true);
  7721. $lowe = $this->input->get('lowe', true);
  7722. $sku = $this->input->get('sku', true);
  7723. $warehouse = $this->input->get('warehouse', true);
  7724. $purchase = $this->input->get('purchase', true);
  7725. $ktime = $this->input->get('ktime', true);
  7726. $jtime = $this->input->get('jtime', true);
  7727. $ktime = strtotime($ktime);
  7728. $jtime = strtotime($jtime);
  7729. $where = "1=1";
  7730. $gj = "";
  7731. $ck = "";
  7732. if ($category) {
  7733. $where .= " and features like '%-$category-%'";
  7734. }
  7735. if ($size) {
  7736. $where .= " and features like '%-$size-%'";
  7737. }
  7738. if ($grade) {
  7739. $where .= " and features like '%-$grade-%'";
  7740. }
  7741. if ($color) {
  7742. $where .= " and features like '%-$color-%'";
  7743. }
  7744. if ($lowe) {
  7745. $where .= " and features like '%-$lowe-%'";
  7746. }
  7747. if ($warehouse) {
  7748. $where .= " and warehouse = '$warehouse'";
  7749. }
  7750. if ($purchase) {
  7751. $where .= " and purchase = '$purchase'";
  7752. }
  7753. if ($sku) {
  7754. $where .= " and sku = '$sku'";
  7755. }
  7756. if ($ktime && $jtime) {
  7757. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7758. }
  7759. //数据排序
  7760. $order_str = "id desc";
  7761. if (empty($page)) {
  7762. $start = 0;
  7763. $perpage = 1;
  7764. } else {
  7765. $start = ($page - 1) * $perpage;
  7766. }
  7767. $list = array();
  7768. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7769. foreach ($rows as $value) {
  7770. $ck = $this->warehouse->read($value['warehouse']);
  7771. $warehouse = $ck['title'];
  7772. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7773. $retreatwarehouse = $tkck['title'];
  7774. $gy = $this->purchase->read($value['purchase']);
  7775. $purchase = $gy['title'];
  7776. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7777. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7778. }
  7779. if(empty($list)){
  7780. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7781. }else{
  7782. $final_list = [];
  7783. foreach($list as $v){
  7784. $final_list[] = array_values($v);
  7785. }
  7786. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7787. array_unshift($final_list,[
  7788. "仓库","SKU","商品名称","时间","数量"
  7789. ]);
  7790. array_unshift($final_list,[
  7791. $title,"","","",""
  7792. ]);
  7793. $merges = [
  7794. [
  7795. "s"=>["r"=>0,"c"=>0],
  7796. "e"=>["r"=>0,"c"=>4]
  7797. ]
  7798. ];
  7799. $cols = [
  7800. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7801. ];
  7802. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7803. }
  7804. }
  7805. }
  7806. //出库、退库导出
  7807. public function _excelctjs()
  7808. {
  7809. $classid = $this->classid->sku();
  7810. $pm = $classid;
  7811. $typeclass = array();
  7812. $tc = $this->typeclass->find_all();
  7813. foreach ($tc as $v) {
  7814. $typeclass[$v['id']] = $v;
  7815. }
  7816. $prc = array();
  7817. $purchase = $this->purchase->find_all();
  7818. foreach ($purchase as $k => $v) {
  7819. $prc[$v['id']] = $v['title'];
  7820. }
  7821. if (isset($_GET['excel'])) {
  7822. $wh = array();
  7823. $w = $this->warehouse->find_all('1=1', 'id,title');
  7824. foreach ($w as $v) {
  7825. $wh[$v['id']] = $v['title'];
  7826. }
  7827. $type = $this->input->get('excel', true);
  7828. $category = $this->input->get('category', true);
  7829. $size = $this->input->get('size', true);
  7830. $grade = $this->input->get('grade', true);
  7831. $color = $this->input->get('color', true);
  7832. $lowe = $this->input->get('lowe', true);
  7833. $sku = $this->input->get('sku', true);
  7834. $title = $this->input->get('title', true);
  7835. $warehouse = $this->input->get('warehouse', true);
  7836. $purchase = $this->input->get('purchase', true);
  7837. $lacetype = $this->input->get('lacetype', true);
  7838. $haircap = $this->input->get('haircap', true);
  7839. $lacecolor = $this->input->get('lacecolor', true);
  7840. $density = $this->input->get('density', true);
  7841. $details = $this->input->get('details', true);
  7842. $state = $this->input->get('state', true);
  7843. $shop = $this->input->get('shop', true);
  7844. $hairnumber = $this->input->get('hairnumber', true);
  7845. $type_leixi = $this->input->get('type', true);
  7846. $cpbz = $this->input->get('cpbz', true);
  7847. $sm = $this->input->get('sm', true);
  7848. $sid = $this->input->get('sid', true);
  7849. $ktime = $this->input->get('ktime', true);
  7850. $jtime = $this->input->get('jtime', true);
  7851. $ktime = strtotime($ktime);
  7852. $jtime = strtotime($jtime);
  7853. //$where = " 1=1 ";
  7854. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7855. $where = " sku != '' ";
  7856. $gj = "";
  7857. $ck = "";
  7858. if ($category) {
  7859. $where .= " and features like '%-$category-%'";
  7860. }
  7861. if ($size) {
  7862. $where .= " and features like '%-$size-%'";
  7863. }
  7864. if ($grade) {
  7865. $where .= " and features like '%-$grade-%'";
  7866. }
  7867. if ($color) {
  7868. $where .= " and features like '%-$color-%'";
  7869. }
  7870. if ($lowe) {
  7871. $where .= " and features like '%-$lowe-%'";
  7872. }
  7873. if ($warehouse) {
  7874. $where .= " and warehouse = '$warehouse'";
  7875. }
  7876. if ($purchase) {
  7877. $where .= " and purchase = '$purchase'";
  7878. }
  7879. if ($state) {
  7880. $where .= " and state = '$state'";
  7881. }
  7882. if ($lacetype) {
  7883. $where .= " and features like '%-$lacetype-%'";
  7884. }
  7885. if ($lacecolor) {
  7886. $where .= " and features like '%-$lacecolor-%'";
  7887. }
  7888. if ($density) {
  7889. $where .= " and features like '%-$density-%'";
  7890. }
  7891. if ($haircap) {
  7892. $where .= " and features like '%-$haircap-%'";
  7893. }
  7894. if ($details) {
  7895. $where .= " and details = '$details'";
  7896. }
  7897. if ($shop) {
  7898. $where .= " and shop like '%$shop%'";
  7899. }
  7900. if ($title) {
  7901. $title = trim($title, ' ');
  7902. $title = trim($title, ' ');
  7903. $where .= " and title like '%$title%'";
  7904. }
  7905. if (!empty($hairnumber)) {
  7906. $where .= " and features like '%-128-%' ";
  7907. if ($hairnumber < 0) {
  7908. $class_list = $this->typeclass->find_all('classid = 43');
  7909. foreach ($class_list as $v) {
  7910. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7911. }
  7912. } else {
  7913. $where .= " and features like '%-$hairnumber-%'";
  7914. }
  7915. }
  7916. if ($type_leixi) {
  7917. $where .= " and type = '$type_leixi'";
  7918. }
  7919. if ($cpbz) {
  7920. $where .= " and cpbz like '%$cpbz%' ";
  7921. }
  7922. if ($sm) {
  7923. $where .= " and sm like '%$sm%' ";
  7924. }
  7925. if ($sku) {
  7926. $sku = trim($sku, ' ');
  7927. $sku = trim($sku, ' ');
  7928. $where .= " and sku like '%$sku%'";
  7929. }
  7930. if ($ktime && $jtime) {
  7931. if ($type == 1) {
  7932. $tl = '出库';
  7933. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7934. } else if ($type == 2) {
  7935. $tl = '退库';
  7936. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7937. } else if ($type == 3) {
  7938. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7939. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7940. } else if ($type == 4) {
  7941. $tl = '出库+零售';
  7942. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7943. } else if ($type == 5) {
  7944. $tl = '零售';
  7945. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7946. }
  7947. }
  7948. $sidwhere = '';
  7949. if ($sid) {
  7950. $sd = "";
  7951. $s = explode(',', trim($sid, ','));
  7952. foreach ($s as $value) {
  7953. $sd .= " id = " . $value . " or";
  7954. }
  7955. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7956. }
  7957. //数据排序
  7958. $order_str = "time desc";
  7959. if (empty($page)) {
  7960. $start = 0;
  7961. $perpage = 1;
  7962. } else {
  7963. $start = ($page - 1) * $perpage;
  7964. }
  7965. //取得信息列表
  7966. if ($type != 3 && $type != 5) {
  7967. if ($type == 1 || $type == 4) {
  7968. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7969. foreach ($info_list as $key => $value) {
  7970. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7971. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7972. $warehouse = $this->warehouse->read($value['warehouse']);
  7973. $info_list[$key]['warehouse'] = $warehouse['title'];
  7974. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7975. $features = explode('-', trim($features, '-'));
  7976. $pm = $classid;
  7977. foreach ($features as $k => $v) {
  7978. if ($v != 0) {
  7979. if (!isset($typeclass[$v])) {
  7980. continue;
  7981. }
  7982. if (isset($pm[$typeclass[$v]['classid']])) {
  7983. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7984. $tz = explode('|', $typeclass[$v]['zh']);
  7985. $pm[$typeclass[$v]['classid']] = $tz[0];
  7986. } else {
  7987. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7988. }
  7989. }
  7990. }
  7991. }
  7992. $zh = implode(" ", $pm);
  7993. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7994. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7995. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7996. $info_list[$key]['features'] = $zh;
  7997. }
  7998. $final_list = [];
  7999. foreach($info_list as $k=>$v){
  8000. $number = "";
  8001. if(!empty($v['orderinfo'])){
  8002. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8003. if(!empty($tmp_info['number'])){
  8004. $number = $tmp_info['number'];
  8005. }
  8006. }
  8007. $final_list[] = [
  8008. 'warehouse'=>$v['warehouse'],
  8009. 'purchase'=>$v['purchase'],
  8010. 'sku'=>$v['sku'],
  8011. 'title'=>$v['title'],
  8012. 'features'=>$v['features'],
  8013. 'label'=>$v['label'],
  8014. 'orderinfo'=>$v['orderinfo'],
  8015. 'number'=>$number,
  8016. 'waybill'=>$v['waybill'],
  8017. 'outk'=>$v['outk'],
  8018. ];
  8019. }
  8020. } else {
  8021. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8022. foreach ($info_list as $key => $value) {
  8023. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8024. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8025. $warehouse = $this->warehouse->read($value['warehouse']);
  8026. $info_list[$key]['warehouse'] = $warehouse['title'];
  8027. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8028. $features = explode('-', trim($features, '-'));
  8029. $pm = $classid;
  8030. foreach ($features as $k => $v) {
  8031. if ($v != 0) {
  8032. if (!isset($typeclass[$v])) {
  8033. continue;
  8034. }
  8035. if (isset($pm[$typeclass[$v]['classid']])) {
  8036. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8037. $tz = explode('|', $typeclass[$v]['zh']);
  8038. $pm[$typeclass[$v]['classid']] = $tz[0];
  8039. } else {
  8040. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8041. }
  8042. }
  8043. }
  8044. }
  8045. $zh = implode(" ", $pm);
  8046. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8047. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8048. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8049. $info_list[$key]['features'] = $zh;
  8050. }
  8051. $final_list = [];
  8052. foreach($info_list as $k=>$v){
  8053. $number = "";
  8054. if(!empty($v['orderinfo'])){
  8055. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8056. if(!empty($tmp_info['number'])){
  8057. $number = $tmp_info['number'];
  8058. }
  8059. }
  8060. $final_list[] = [
  8061. 'warehouse'=>$v['warehouse'],
  8062. 'purchase'=>$v['purchase'],
  8063. 'sku'=>$v['sku'],
  8064. 'title'=>$v['title'],
  8065. 'features'=>$v['features'],
  8066. 'label'=>$v['label'],
  8067. 'orderinfo'=>$v['orderinfo'],
  8068. 'number'=>$number,
  8069. 'waybill'=>$v['waybill'],
  8070. 'retreat'=>$v['retreat'],
  8071. ];
  8072. }
  8073. }
  8074. if(empty($final_list)){
  8075. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8076. }else{
  8077. $end_list = [];
  8078. foreach($final_list as $v){
  8079. $end_list[] = array_values($v);
  8080. }
  8081. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8082. array_unshift($end_list,[
  8083. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8084. ]);
  8085. array_unshift($end_list,[
  8086. $title,"","","","","","","","",""
  8087. ]);
  8088. $merges = [
  8089. [
  8090. "s"=>["r"=>0,"c"=>0],
  8091. "e"=>["r"=>0,"c"=>9]
  8092. ]
  8093. ];
  8094. $cols = [
  8095. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8096. ];
  8097. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8098. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8099. ] )));
  8100. }
  8101. } else if ($type == 5) {
  8102. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8103. foreach ($info_list as $key => $value) {
  8104. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8105. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8106. $warehouse = $this->warehouse->read($value['warehouse']);
  8107. $info_list[$key]['warehouse'] = $warehouse['title'];
  8108. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8109. $features = explode('-', trim($features, '-'));
  8110. $pm = $classid;
  8111. foreach ($features as $k => $v) {
  8112. if ($v != 0) {
  8113. if (!isset($typeclass[$v])) {
  8114. continue;
  8115. }
  8116. if (isset($pm[$typeclass[$v]['classid']])) {
  8117. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8118. $tz = explode('|', $typeclass[$v]['zh']);
  8119. $pm[$typeclass[$v]['classid']] = $tz[0];
  8120. } else {
  8121. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8122. }
  8123. }
  8124. }
  8125. }
  8126. $zh = implode(" ", $pm);
  8127. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8128. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8129. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8130. $info_list[$key]['features'] = $zh;
  8131. }
  8132. if(empty($info_list)){
  8133. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8134. }else{
  8135. $final_list = [];
  8136. foreach($info_list as $v){
  8137. $final_list[] = array_values($v);
  8138. }
  8139. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8140. array_unshift($final_list,[
  8141. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8142. ]);
  8143. array_unshift($final_list,[
  8144. $title,"","","","","","",
  8145. ]);
  8146. $merges = [
  8147. [
  8148. "s"=>["r"=>0,"c"=>0],
  8149. "e"=>["r"=>0,"c"=>6]
  8150. ]
  8151. ];
  8152. $cols = [
  8153. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8154. ];
  8155. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8156. }
  8157. } else {
  8158. $wh = array();
  8159. $w = $this->warehouse->find_all('1=1', 'id,title');
  8160. foreach ($w as $v) {
  8161. $wh[$v['id']] = $v['title'];
  8162. }
  8163. $wt = array();
  8164. $whlabel_type = $this->whlabel_type->find_all();
  8165. foreach ($whlabel_type as $v) {
  8166. $wt[$v['id']] = $v['title'];
  8167. }
  8168. $classid = $this->classid->sku();
  8169. $list = array();
  8170. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8171. foreach ($rows as $key => $value) {
  8172. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8173. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8174. $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');
  8175. $details = array();
  8176. $cpid = array();
  8177. $cpbz = array();
  8178. $c = 0;
  8179. $g = 0;
  8180. $x = 0;
  8181. $t = 0;
  8182. $s = 0;
  8183. $q = 0;
  8184. foreach ($sd as $k => $v) {
  8185. if ($v['state'] == 0) {
  8186. $c++;
  8187. }
  8188. if ($v['state'] != 9) {
  8189. $g++;
  8190. }
  8191. if ($v['outk'] > 1) {
  8192. $x++;
  8193. }
  8194. if ($v['retreat'] > 0) {
  8195. $t++;
  8196. }
  8197. if ($v['state'] == 8) {
  8198. $s++;
  8199. }
  8200. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8201. $q++;
  8202. }
  8203. $details[$v['details']] = $v['details'];
  8204. if ($v['cpid'] != 0) {
  8205. $cpid[$v['cpid']] = $v['cpid'];
  8206. }
  8207. if ($v['cpbz'] != '') {
  8208. $cpbz[$v['cpbz']] = $v['cpbz'];
  8209. }
  8210. }
  8211. if (isset($wt[$value['type']])) {
  8212. $rows[$key]['type'] = $wt[$value['type']];
  8213. } else {
  8214. $rows[$key]['type'] = '未设置';
  8215. }
  8216. $rows[$key]['details'] = implode("、", $details);
  8217. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8218. $ftime = time() - 15 * 24 * 3600;
  8219. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8220. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8221. $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);
  8222. $rows[$key]['c'] = $c;
  8223. $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);
  8224. $rows[$key]['t'] = $t;
  8225. $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'] . '"');
  8226. $rows[$key]['z'] = $z;
  8227. // $jm = $classid;
  8228. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8229. $features = explode('-', trim($features, '-'));
  8230. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8231. }
  8232. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8233. $final_list =[];
  8234. foreach($tmp_list as $k=>$v){
  8235. $final_list[] = [
  8236. "warehouse"=>$v['warehouse'],
  8237. "purchase"=>$v['purchase'],
  8238. "details"=>$v['details'],
  8239. "cpid"=>$v['cpid'],
  8240. "sku"=>$v['sku'],
  8241. "title"=>$v['title'],
  8242. "features"=>$v['pm'],
  8243. "cpbz"=>$v['cpbz'],
  8244. "sm"=>$v['sm'],
  8245. "type"=>$v['type'],
  8246. "g"=>$v["g"],
  8247. "c"=>$v["c"],
  8248. "x"=>$v["x"],
  8249. "t"=>$v["t"],
  8250. "z"=>$v["z"],
  8251. "jm"=>$v["jm"],
  8252. "weight"=>$v["weight"],
  8253. "asd"=>$v["asd"],
  8254. ];
  8255. }
  8256. if(empty($final_list)){
  8257. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8258. }else{
  8259. $end_list = [];
  8260. foreach($final_list as $v){
  8261. $end_list[] = array_values($v);
  8262. }
  8263. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8264. array_unshift($end_list,[
  8265. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8266. ]);
  8267. array_unshift($end_list,[
  8268. $title,"","","","","","","","","","","","","","","","","",""
  8269. ]);
  8270. $merges = [
  8271. [
  8272. "s"=>["r"=>0,"c"=>0],
  8273. "e"=>["r"=>0,"c"=>6]
  8274. ]
  8275. ];
  8276. $cols = [
  8277. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8278. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8279. ];
  8280. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8281. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8282. ])));
  8283. }
  8284. }
  8285. }
  8286. }
  8287. public function _exceljxcjs(){
  8288. $classid = $this->classid->sku();
  8289. $pm = $classid;
  8290. $typeclass = array();
  8291. $tc = $this->typeclass->find_all();
  8292. foreach ($tc as $v) {
  8293. $typeclass[$v['id']] = $v;
  8294. }
  8295. $prc = array();
  8296. $purchase = $this->purchase->find_all();
  8297. foreach ($purchase as $k => $v) {
  8298. $prc[$v['id']] = $v['title'];
  8299. }
  8300. if(!isset($_GET['excel'])){
  8301. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8302. }
  8303. $where = "sku != 'Preset'";
  8304. //数据排序
  8305. $order_str = "id desc";
  8306. if (empty($page)) {
  8307. $start = 0;
  8308. $perpage = 1;
  8309. } else {
  8310. $start = ($page - 1) * $perpage;
  8311. }
  8312. $category = $this->input->get('category', true);
  8313. $warehouse = $this->input->get('warehouse', true);
  8314. $excelid = $this->input->get('sid', true);
  8315. if ($category) {
  8316. $where .= " and features like '%-$category-%'";
  8317. }
  8318. if ($warehouse) {
  8319. $where .= " and warehouse = '$warehouse'";
  8320. }
  8321. $xzid = '';
  8322. if ($excelid) {
  8323. $excelid = explode(',', trim($excelid, ','));
  8324. foreach ($excelid as $key => $value) {
  8325. $xzid .= " id = " . $value . " or";
  8326. }
  8327. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8328. }
  8329. $wt = array();
  8330. $whlabel_type = $this->whlabel_type->find_all();
  8331. foreach ($whlabel_type as $v) {
  8332. $wt[$v['id']] = $v['title'];
  8333. }
  8334. $wh = array();
  8335. $w = $this->warehouse->find_all('1=1', 'id,title');
  8336. foreach ($w as $v) {
  8337. $wh[$v['id']] = $v['title'];
  8338. }
  8339. $list = array();
  8340. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8341. foreach ($rows as $key => $value) {
  8342. if (isset($wt[$value['type']])) {
  8343. $rows[$key]['type'] = $wt[$value['type']];
  8344. } else {
  8345. $rows[$key]['type'] = '未设置';
  8346. }
  8347. $bm = '03';
  8348. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8349. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8350. $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');
  8351. $details = array();
  8352. $cpid = array();
  8353. $cpbz = array();
  8354. $c = 0;
  8355. $g = 0;
  8356. $x = 0;
  8357. $t = 0;
  8358. $s = 0;
  8359. $q = 0;
  8360. foreach ($sd as $k => $v) {
  8361. if ($v['state'] == 0) {
  8362. $c++;
  8363. if ($v['cpid'] != 0) {
  8364. $cpid[$v['cpid']] = $v['cpid'];
  8365. }
  8366. if ($v['cpbz'] != '') {
  8367. $cpbz[$v['cpbz']] = $v['cpbz'];
  8368. }
  8369. }
  8370. if ($v['state'] != 9) {
  8371. $g++;
  8372. }
  8373. if ($v['state'] == 1) {
  8374. $x++;
  8375. }
  8376. if ($v['state'] == 2) {
  8377. $t++;
  8378. }
  8379. if ($v['state'] == 8) {
  8380. $s++;
  8381. }
  8382. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8383. $q++;
  8384. }
  8385. $details[$v['details']] = $v['details'];
  8386. }
  8387. $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'] . '"');
  8388. $rows[$key]['details'] = implode("、", $details);
  8389. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8390. $number = $value['number'];
  8391. $ftime = time() - 15 * 24 * 3600;
  8392. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8393. $rows[$key]['number'] = $g;
  8394. $rows[$key]['c'] = $c;
  8395. $rows[$key]['x'] = $x;
  8396. $rows[$key]['t'] = $t;
  8397. $rows[$key]['s'] = $s;
  8398. $rows[$key]['q'] = $q;
  8399. $rows[$key]['z'] = $z;
  8400. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8401. $features = explode('-', trim($features, '-'));
  8402. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8403. }
  8404. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8405. $final_list = [];
  8406. foreach ($list as $k => $v) {
  8407. if (empty($v['sku'])) {
  8408. continue;
  8409. }
  8410. $final_list[] = [
  8411. $v["warehouse"],
  8412. $v["purchase"],
  8413. $v["details"],
  8414. $v["cpid"],
  8415. $v["dbcontent"],
  8416. $v["sku"],
  8417. $v["bm"],
  8418. $v["jm"],
  8419. $v["title"],
  8420. $v["pm"],
  8421. $v["cpbz"],
  8422. $v["sm"],
  8423. $v["type"],
  8424. $v["number"],
  8425. $v["c"],
  8426. $v["x"],
  8427. $v["t"],
  8428. $v["s"],
  8429. $v["q"],
  8430. $v["z"],
  8431. $v['weight'],
  8432. ];
  8433. }
  8434. if(empty($final_list)){
  8435. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8436. }
  8437. $title = "总进销存统计表";
  8438. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8439. $merges = [
  8440. [
  8441. "s"=>["r"=>0,"c"=>0],
  8442. "e"=>["r"=>0,"c"=>21]
  8443. ]
  8444. ];
  8445. $cols = [
  8446. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8447. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8448. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8449. ];
  8450. array_unshift($final_list, $first_row);
  8451. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8452. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8453. }
  8454. public function _summaryjs($arg_array)
  8455. {
  8456. $prc = array();
  8457. $purchase = $this->purchase->find_all();
  8458. foreach ($purchase as $k => $v) {
  8459. $prc[$v['id']] = $v['title'];
  8460. }
  8461. if (isset($_GET['excel'])) {
  8462. $ktime = $this->input->get('ktime', true);
  8463. $jtime = $this->input->get('jtime', true);
  8464. $ktime = strtotime($ktime);
  8465. $jtime = strtotime($jtime);
  8466. $where = "1=1";
  8467. if ($ktime && $jtime) {
  8468. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8469. }
  8470. //数据排序
  8471. $order_str = "time desc";
  8472. if (empty($page)) {
  8473. $start = 0;
  8474. $perpage = 1;
  8475. } else {
  8476. $start = ($page - 1) * $perpage;
  8477. }
  8478. //取得信息列表
  8479. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8480. foreach ($info_list as $key => $value) {
  8481. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8482. $warehouse = $this->warehouse->read($value['warehouse']);
  8483. $info_list[$key]['warehouse'] = $warehouse['title'];
  8484. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8485. $details = array();
  8486. $cpid = array();
  8487. foreach ($x as $k => $v) {
  8488. if ($v['details'] != '') {
  8489. $details[$v['details']] = $v['details'];
  8490. }
  8491. if ($v['cpid'] != 0) {
  8492. $cpid[$v['cpid']] = $v['cpid'];
  8493. }
  8494. }
  8495. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8496. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8497. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8498. $info_list[$key]['s'] = $s;
  8499. $info_list[$key]['x'] = count($x);
  8500. }
  8501. if(empty($info_list)){
  8502. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8503. }
  8504. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8505. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8506. $merges = [
  8507. [
  8508. "s"=>["r"=>0,"c"=>0],
  8509. "e"=>["r"=>0,"c"=>7]
  8510. ]
  8511. ];
  8512. $cols = [
  8513. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8514. ];
  8515. $final_list = [];
  8516. foreach($info_list as $k => $v){
  8517. $final_list[] = array_values($v);
  8518. }
  8519. array_unshift($final_list, $first_row);
  8520. array_unshift($final_list,[
  8521. $title,"","","","","","","","",
  8522. ]);
  8523. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8524. $titlename = "<table border=1>
  8525. <tr align='center'>
  8526. <td>仓库</td>
  8527. <td>供应商</td>
  8528. <td>出库位置</td>
  8529. <td>出库编码</td>
  8530. <td>SKU</td>
  8531. <td>产品名</td>
  8532. <td>总剩余库存</td>
  8533. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8534. </tr>
  8535. </table>";
  8536. $filename = $title . ".xls";
  8537. $tail = "";
  8538. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8539. }
  8540. }
  8541. public function _uckjs()
  8542. {
  8543. if (isset($_GET['excel'])) {
  8544. $tc = array();
  8545. $typeclass = $this->typeclass->find_all();
  8546. foreach ($typeclass as $v) {
  8547. $tc[$v['id']] = $v['zh'];
  8548. }
  8549. $first_row = [
  8550. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8551. ];
  8552. $t = array();
  8553. $rq = '';
  8554. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8555. $ts = $ts / (24 * 3600);
  8556. for ($i = 0; $i < $ts; $i++) {
  8557. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8558. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8559. }
  8560. $day_len = count($t);
  8561. $first_row[] = "本月出库";
  8562. $merges = [
  8563. ];
  8564. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8565. $excel_key = 1;
  8566. $final_list = [];
  8567. foreach ($info_list as $k => $v) {
  8568. $features = explode('-', trim($v['features'], '-'));
  8569. if (!isset($features[3]) || !isset($features[4])) {
  8570. continue;
  8571. }
  8572. $tmp = [];
  8573. $tmp[0] = $tc[$features[0]]; //类型
  8574. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8575. $tmp[2] = $tc[$features[4]]; //曲度
  8576. $tmp[3] = '';
  8577. if (isset($data[$k][1])) {
  8578. $tmp[3] .=$tmp[1];
  8579. }
  8580. if (isset($data[$k][2])) {
  8581. $tmp[3] .= $tmp[2];
  8582. }
  8583. if (isset($features[5])) {
  8584. $tmp[3] .= $tc[$features[5]];
  8585. }
  8586. if (isset($features[2])) {
  8587. $tmp[3] .= $tc[$features[2]];
  8588. }
  8589. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8590. $tmp[4] = $v['sku'];
  8591. $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())) . '))'); //月初库存
  8592. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8593. $tmp[7] ="";
  8594. $tmp[8] ="";
  8595. $byck = 0;
  8596. foreach ($t as $vv) {
  8597. $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));
  8598. $tmp[] = ($sl > 0) ? $sl : '';
  8599. $byck += $sl;
  8600. }
  8601. $tmp[] = ($byck > 0) ? $byck : '';
  8602. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8603. // $ztrq = '';
  8604. // $ztsl = '';
  8605. // if (count($zt) > 0) {
  8606. // foreach ($zt as $vv) {
  8607. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8608. // $ztsl .= $vv['num'] . '<br>';
  8609. // }
  8610. // }
  8611. if(empty($zt)){
  8612. $final_list[] = $tmp;
  8613. $excel_key = $excel_key + 1;
  8614. }else{
  8615. $len = count($zt);
  8616. if($len == 1){
  8617. $tmp[7] = $zt[0]['num'] ;
  8618. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8619. $final_list[] = $tmp;
  8620. $excel_key = $excel_key + 1;
  8621. }else{
  8622. foreach($zt as $vv){
  8623. $tmp[7] = "";
  8624. $tmp[8] = "";
  8625. $tmp[7] = $vv['num'];
  8626. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8627. $final_list[] = $tmp;
  8628. }
  8629. $merges[] = [
  8630. "s"=>["r"=>$excel_key,"c"=>0],
  8631. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8632. ];
  8633. $merges[] = [
  8634. "s"=>["r"=>$excel_key,"c"=>1],
  8635. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8636. ];
  8637. $merges[] = [
  8638. "s"=>["r"=>$excel_key,"c"=>2],
  8639. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8640. ];
  8641. $merges[] = [
  8642. "s"=>["r"=>$excel_key,"c"=>3],
  8643. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8644. ];
  8645. $merges[] = [
  8646. "s"=>["r"=>$excel_key,"c"=>4],
  8647. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8648. ];
  8649. $merges[] = [
  8650. "s"=>["r"=>$excel_key,"c"=>5],
  8651. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8652. ];
  8653. $merges[] = [
  8654. "s"=>["r"=>$excel_key,"c"=>6],
  8655. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8656. ];
  8657. for($i=1;$i<=$day_len;$i++){
  8658. $merges[] = [
  8659. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8660. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8661. ];
  8662. }
  8663. $merges[] = [
  8664. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8665. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8666. ];
  8667. $excel_key = $excel_key + $len;
  8668. }
  8669. }
  8670. }
  8671. $title = "详情 " . date("Y-m-d", time());
  8672. if(empty($final_list)){
  8673. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8674. }
  8675. $cols = [
  8676. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8677. ];
  8678. array_unshift($final_list, $first_row);
  8679. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8680. }
  8681. }
  8682. public function _whlabelexcelzhjs(){
  8683. if(empty($_GET['excel'])){
  8684. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8685. }
  8686. $where = "sku != 'Preset' and sku != '' ";
  8687. //数据排序
  8688. $order_str = "id desc";
  8689. if (empty($page)) {
  8690. $start = 0;
  8691. $perpage = 1;
  8692. } else {
  8693. $start = ($page - 1) * $perpage;
  8694. }
  8695. $category = $this->input->get('category', true);
  8696. $warehouse = $this->input->get('warehouse', true);
  8697. $excelid = $this->input->get('sid', true);
  8698. if ($category) {
  8699. $where .= " and features like '%-$category-%'";
  8700. }
  8701. if ($warehouse) {
  8702. $where .= " and warehouse = '$warehouse'";
  8703. }
  8704. $xzid = '';
  8705. if ($excelid) {
  8706. $excelid = explode(',', trim($excelid, ','));
  8707. foreach ($excelid as $key => $value) {
  8708. $xzid .= " id = " . $value . " or";
  8709. }
  8710. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8711. }
  8712. $merges = [
  8713. [
  8714. "s"=>["r"=>0,"c"=>0],
  8715. "e"=>["r"=>0,"c"=>6]
  8716. ]
  8717. ];
  8718. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8719. $excel_index = 2;
  8720. $final_list = [];
  8721. foreach ($rows as $key => $value) {
  8722. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8723. $zh = '';
  8724. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8725. // foreach ($zt_list as $v) {
  8726. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8727. // }
  8728. $zt = array_sum(array_column($zt_list, 'num'));
  8729. $number = $value['number'];
  8730. $ftime = time() - 15 * 24 * 3600;
  8731. $warehouse = $this->warehouse->read($value['warehouse']);
  8732. // $rows[$key]['warehouse'] = $warehouse['title'];
  8733. // $rows[$key]['number'] = $c;
  8734. // $rows[$key]['features'] = $zh;
  8735. //$rows[$key]['hb'] = $c + $zt;
  8736. $tmp = [];
  8737. $tmp[0] = $warehouse['title'];
  8738. $tmp[1] = $value['sku'];
  8739. $tmp[2] = $value['title'];
  8740. $tmp[3] = $c;
  8741. $tmp[4] = "";
  8742. $tmp[5] = $c + $zt;
  8743. if(empty($zt_list)){
  8744. $tmp[4] = "";
  8745. $final_list[] = $tmp;
  8746. $excel_index = $excel_index + 1;
  8747. }else{
  8748. if(count($zt_list) == 1){
  8749. $tmp[4] = "";
  8750. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8751. $final_list[] = $tmp;
  8752. $excel_index = $excel_index + 1;
  8753. }else{
  8754. $len = count($zt_list);
  8755. foreach ($zt_list as $v){
  8756. $tmp[4] = "";
  8757. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8758. $final_list[] = $tmp;
  8759. }
  8760. $merges[] = [
  8761. "s"=>["r"=>$excel_index,"c"=>0],
  8762. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8763. ];
  8764. $merges[] = [
  8765. "s"=>["r"=>$excel_index,"c"=>1],
  8766. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8767. ];
  8768. $merges[] = [
  8769. "s"=>["r"=>$excel_index,"c"=>2],
  8770. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8771. ];
  8772. $merges[] = [
  8773. "s"=>["r"=>$excel_index,"c"=>3],
  8774. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8775. ];
  8776. $merges[] = [
  8777. "s"=>["r"=>$excel_index,"c"=>5],
  8778. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8779. ];
  8780. $excel_index = $excel_index + $len;
  8781. }
  8782. }
  8783. }
  8784. $first_row = [
  8785. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8786. ];
  8787. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8788. if(empty($final_list)){
  8789. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8790. }
  8791. $cols = [
  8792. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8793. ];
  8794. array_unshift($final_list, $first_row);
  8795. array_unshift($final_list, [
  8796. $title,"","","","",""
  8797. ]);
  8798. $end_list = [];
  8799. foreach ($final_list as $key => $value) {
  8800. $end_list[] = array_values($value);
  8801. }
  8802. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8803. }
  8804. //出库、退库导出
  8805. public function _dccrtypejs()
  8806. {
  8807. $classid = $this->classid->sku();
  8808. $pm = $classid;
  8809. $typeclass = array();
  8810. $tc = $this->typeclass->find_all();
  8811. foreach ($tc as $v) {
  8812. $typeclass[$v['id']] = $v;
  8813. }
  8814. $prc = array();
  8815. $purchase = $this->purchase->find_all();
  8816. foreach ($purchase as $k => $v) {
  8817. $prc[$v['id']] = $v['title'];
  8818. }
  8819. if (isset($_GET['sid'])) {
  8820. $wh = array();
  8821. $w = $this->warehouse->find_all('1=1', 'id,title');
  8822. foreach ($w as $v) {
  8823. $wh[$v['id']] = $v['title'];
  8824. }
  8825. $type = $this->input->get('excel', true);
  8826. $category = $this->input->get('category', true);
  8827. $size = $this->input->get('size', true);
  8828. $grade = $this->input->get('grade', true);
  8829. $color = $this->input->get('color', true);
  8830. $lowe = $this->input->get('lowe', true);
  8831. $sku = $this->input->get('sku', true);
  8832. $warehouse = $this->input->get('warehouse', true);
  8833. $lacetype = $this->input->get('lacetype', true);
  8834. $lacecolor = $this->input->get('lacecolor', true);
  8835. $density = $this->input->get('density', true);
  8836. $haircap = $this->input->get('haircap', true);
  8837. $purchase = $this->input->get('purchase', true);
  8838. $title = $this->input->get('title', true);
  8839. $state = $this->input->get('state', true);
  8840. $sid = $this->input->get('sid', true);
  8841. $ktime = $this->input->get('ktime', true);
  8842. $jtime = $this->input->get('jtime', true);
  8843. $ktime = strtotime($ktime);
  8844. $jtime = strtotime($jtime);
  8845. $where = "1=1";
  8846. $gj = "";
  8847. $ck = "";
  8848. if ($category) {
  8849. $where .= " and features like '%-$category-%'";
  8850. }
  8851. if ($size) {
  8852. $where .= " and features like '%-$size-%'";
  8853. }
  8854. if ($grade) {
  8855. $where .= " and features like '%-$grade-%'";
  8856. }
  8857. if ($color) {
  8858. $where .= " and features like '%-$color-%'";
  8859. }
  8860. if ($lowe) {
  8861. $where .= " and features like '%-$lowe-%'";
  8862. }
  8863. if ($warehouse) {
  8864. $where .= " and warehouse = '$warehouse'";
  8865. }
  8866. if ($purchase) {
  8867. $where .= " and purchase = '$purchase'";
  8868. }
  8869. if ($state) {
  8870. $where .= " and state = '$state'";
  8871. }
  8872. if ($lacetype) {
  8873. $where .= " and features like '%-$lacetype-%'";
  8874. }
  8875. if ($lacecolor) {
  8876. $where .= " and features like '%-$lacecolor-%'";
  8877. }
  8878. if ($density) {
  8879. $where .= " and features like '%-$density-%'";
  8880. }
  8881. if ($haircap) {
  8882. $where .= " and features like '%-$haircap-%'";
  8883. }
  8884. if ($title) {
  8885. $title = trim($title, ' ');
  8886. $title = trim($title, ' ');
  8887. $where .= " and title like '%$title%'";
  8888. }
  8889. if ($sku) {
  8890. $sku = trim($sku, ' ');
  8891. $sku = trim($sku, ' ');
  8892. $where .= " and sku like '%$sku%'";
  8893. }
  8894. if ($ktime && $jtime) {
  8895. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8896. }
  8897. $sidwhere = '';
  8898. if ($sid) {
  8899. $sd = "";
  8900. $s = explode(',', trim($sid, ','));
  8901. foreach ($s as $value) {
  8902. $sd .= " id = " . $value . " or";
  8903. }
  8904. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8905. }
  8906. //数据排序
  8907. $order_str = "time desc";
  8908. if (empty($page)) {
  8909. $start = 0;
  8910. $perpage = 1;
  8911. } else {
  8912. $start = ($page - 1) * $perpage;
  8913. }
  8914. $wh = array();
  8915. $w = $this->warehouse->find_all('1=1', 'id,title');
  8916. foreach ($w as $v) {
  8917. $wh[$v['id']] = $v['title'];
  8918. }
  8919. $wt = array();
  8920. $whlabel_type = $this->whlabel_type->find_all();
  8921. foreach ($whlabel_type as $v) {
  8922. $wt[$v['id']] = $v['title'];
  8923. }
  8924. $classid = $this->classid->sku();
  8925. $list = array();
  8926. $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');
  8927. foreach ($rows_r as $key => $value) {
  8928. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8929. $pm = $classid;
  8930. $jm = $classid;
  8931. $rows_r[$key]['enter'] = '入库';
  8932. $rows_r[$key]['time'] = $value['enter'];
  8933. if ($value['rktype'] == 1) {
  8934. $rows_r[$key]['rktype'] = '采购入库';
  8935. } else if ($value['rktype'] == 2) {
  8936. $rows_r[$key]['rktype'] = '盘盈调整';
  8937. } else if ($value['rktype'] == 3) {
  8938. $rows_r[$key]['rktype'] = '其他调整入库';
  8939. } else if ($value['rktype'] == 4) {
  8940. $rows_r[$key]['rktype'] = '其他调整入库';
  8941. } else if ($value['rktype'] == 5) {
  8942. $rows_r[$key]['rktype'] = '退库入库';
  8943. } else if ($value['rktype'] == 6) {
  8944. $rows_r[$key]['rktype'] = '退货可用入库';
  8945. } else if ($value['rktype'] == 7) {
  8946. $rows_r[$key]['rktype'] = '形态转换入库';
  8947. } else {
  8948. $rows_r[$key]['rktype'] = '';
  8949. }
  8950. $features = explode('-', trim($value['features'], '-'));
  8951. foreach ($features as $v) {
  8952. if (isset($typeclass[$v])) {
  8953. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8954. $pm[$typeclass[$v]['classid']] = $zh[0];
  8955. }
  8956. if (isset($typeclass[$v])) {
  8957. if (isset($jm[$typeclass[$v]['classid']])) {
  8958. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8959. }
  8960. }
  8961. }
  8962. $zh = implode(" ", $pm);
  8963. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8964. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8965. $rows_r[$key]['zh'] = $zh;
  8966. $jm = array_filter($jm);
  8967. $rows_r[$key]['features'] = implode("-", $jm);
  8968. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8969. }
  8970. $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');
  8971. foreach ($rows_c as $key => $value) {
  8972. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8973. $pm = $classid;
  8974. $jm = $classid;
  8975. $rows_c[$key]['time'] = $value['outk'];
  8976. $rows_c[$key]['outk'] = '出库';
  8977. if ($value['cktype'] == 1) {
  8978. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8979. } else if ($value['cktype'] == 2) {
  8980. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8981. } else if ($value['cktype'] == 3) {
  8982. $rows_c[$key]['cktype'] = '盘亏调整';
  8983. } else if ($value['cktype'] == 4) {
  8984. $rows_c[$key]['cktype'] = '其他调整出库';
  8985. } else if ($value['cktype'] == 5) {
  8986. $rows_c[$key]['cktype'] = '形态转换出库';
  8987. } else {
  8988. $rows_c[$key]['cktype'] = '';
  8989. }
  8990. unset($rows_c[$key]['state']);
  8991. $features = explode('-', trim($value['features'], '-'));
  8992. foreach ($features as $v) {
  8993. if (isset($typeclass[$v])) {
  8994. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8995. $pm[$typeclass[$v]['classid']] = $zh[0];
  8996. }
  8997. if (isset($typeclass[$v])) {
  8998. if (isset($jm[$typeclass[$v]['classid']])) {
  8999. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9000. }
  9001. }
  9002. }
  9003. $zh = implode(" ", $pm);
  9004. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9005. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9006. $rows_c[$key]['zh'] = $zh;
  9007. $jm = array_filter($jm);
  9008. $rows_c[$key]['features'] = implode("-", $jm);
  9009. $rows_c[$key]['number'] = 1;
  9010. }
  9011. $merged = $rows_r;
  9012. foreach ($rows_c as $key => $value) {
  9013. if (isset($merged[$key])) {
  9014. $merged[] = $value;
  9015. } else {
  9016. $merged[$key] = $value;
  9017. }
  9018. }
  9019. usort($merged, function ($a, $b) {
  9020. return $a['time'] - $b['time'];
  9021. });
  9022. foreach ($merged as $key => $value) {
  9023. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9024. }
  9025. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9026. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9027. $cols = [
  9028. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9029. ];
  9030. $final_list= [];
  9031. foreach($merged as $key => $value){
  9032. $final_list[] = array_values($value) ;
  9033. }
  9034. if(empty($merged)){
  9035. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9036. }
  9037. array_unshift($final_list, $first_row);
  9038. $end_list = [];
  9039. foreach ($final_list as $key => $value) {
  9040. $end_list[] = array_values($value);
  9041. }
  9042. $merges = [];
  9043. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9044. }
  9045. }
  9046. public function _errorexceljs()
  9047. {
  9048. $post = $this->input->post(NULL, TRUE);
  9049. if (isset($_GET['page'])) {
  9050. $page = $this->input->get('page', true);
  9051. $perpage = $this->input->get('perpage', true);
  9052. $sku = $this->input->get('sku', true);
  9053. $warehouse = $this->input->get('warehouse', true);
  9054. $ktime = $this->input->get('ktime', true);
  9055. $jtime = $this->input->get('jtime', true);
  9056. $ktime = strtotime($ktime);
  9057. $jtime = strtotime($jtime);
  9058. $where = "sku != 'Preset'";
  9059. $gj = '';
  9060. if ($sku) {
  9061. $where .= " and sku like '%$sku%'";
  9062. } else {
  9063. if ($ktime && $jtime) {
  9064. $gj = " and time > '$ktime' and time < '$jtime'";
  9065. }
  9066. }
  9067. if ($warehouse) {
  9068. $where .= " and warehouse = '$warehouse'";
  9069. }
  9070. //数据排序
  9071. $order_str = "id desc";
  9072. if (empty($page)) {
  9073. $start = 0;
  9074. $perpage = 1;
  9075. } else {
  9076. $start = ($page - 1) * $perpage;
  9077. }
  9078. //取得信息列表
  9079. $rows = array();
  9080. $list = array();
  9081. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9082. foreach ($info_list as $value) {
  9083. $warehouse = $this->warehouse->read($value['warehouse']);
  9084. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9085. $number = $value['number'];
  9086. $ftime = time() - 15 * 24 * 3600;
  9087. if ($c < 1) {
  9088. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9089. }
  9090. }
  9091. $title = "0库存汇总";
  9092. $first_row = ["仓库","SKU","产品","当前库存"];
  9093. $cols = [
  9094. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9095. ];
  9096. $final_list= [];
  9097. foreach($list as $key => $value){
  9098. $final_list[] = array_values($value) ;
  9099. }
  9100. if(empty($final_list)){
  9101. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9102. }
  9103. array_unshift($final_list, $first_row);
  9104. $merges = [];
  9105. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9106. }
  9107. }
  9108. }