Whlabel.php 308 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084
  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. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else if($arg == 'excelrjs'){
  190. $this->_excelrjs();
  191. } else if($arg == 'excelctjs'){
  192. $this->_excelctjs();
  193. }else if ($arg == 'exceljxcjs') //进销存信息导出
  194. {
  195. $this->_exceljxcjs();
  196. } else if ($arg == 'summaryjs') //汇总导出
  197. {
  198. $this->_summaryjs($arg_array);
  199. }else if($arg == 'uckjs'){
  200. $this->_uckjs();
  201. }else if ($arg == 'whlabelexcelzhjs') {
  202. $this->_whlabelexcelzhjs();
  203. }else if($arg == 'dccrtypejs'){
  204. $this->_dccrtypejs();
  205. }else if($arg == "w_t_cs"){
  206. $this->_w_t_cs(); //首页
  207. }else {
  208. $this->_index();
  209. }
  210. }
  211. public function _w_t_cs(){
  212. $vip = 0;
  213. if (isset($_SESSION['api'])) {
  214. $user = $this->user->get_api($_SESSION['api']);
  215. $fgshop = "";
  216. $sid = "";
  217. $usersp = explode('|', trim($user['shop'], '|'));
  218. foreach ($usersp as $value) {
  219. $fgshop .= " shop = " . $value . " or";
  220. $sid .= " id = " . $value . " or";
  221. }
  222. if ($user['vip'] == 1) {
  223. $vip = 1;
  224. }
  225. } else {
  226. header('Location: /');
  227. exit;
  228. }
  229. $prc = array();
  230. $purchase = $this->purchase->find_all();
  231. foreach ($purchase as $k => $v) {
  232. $prc[$v['id']] = $v['title'];
  233. }
  234. $company = array();
  235. $ct = $this->company->find_all();
  236. foreach ($ct as $k => $v) {
  237. $company[$v['id']] = $v['title'];
  238. }
  239. $sp = array();
  240. $s = $this->shop->find_all('1=1', 'id,shopname');
  241. foreach ($s as $v) {
  242. $sp[$v['id']] = $v['shopname'];
  243. }
  244. $wh = array();
  245. $w = $this->warehouse->find_all('1=1', 'id,title');
  246. foreach ($w as $v) {
  247. $wh[$v['id']] = $v['title'];
  248. }
  249. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  250. $this->data['shop'] = $wlshop;
  251. $this->data['vip'] = $vip;
  252. $this->_Template('whlabel_typejs', $this->data);
  253. }
  254. //管理
  255. public function _index()
  256. {
  257. $post = $this->input->post(NULL, TRUE);
  258. if (isset($post['page'])) {
  259. $page = $this->input->post('page', true);
  260. $perpage = $this->input->post('perpage', true);
  261. $sku = $this->input->post('sku', true);
  262. $number = $this->input->post('number', true);
  263. $warehouse = $this->input->post('warehouse', true);
  264. $purchase = $this->input->post('purchase', true);
  265. $orderinfo = $this->input->post('orderinfo', true);
  266. $waybill = $this->input->post('waybill', true);
  267. $category = $this->input->post('category', true);
  268. $size = $this->input->post('size', true);
  269. $grade = $this->input->post('grade', true);
  270. $color = $this->input->post('color', true);
  271. $lowe = $this->input->post('lowe', true);
  272. $state = $this->input->post('state', true);
  273. $label = $this->input->post('label', true);
  274. $timetk = $this->input->post('timetkk', true);
  275. $timetj = $this->input->post('timetjj', true);
  276. $timetk = strtotime($timetk);
  277. $timetj = strtotime($timetj);
  278. $where = "1=1 ";
  279. if ($timetk && $timetj) {
  280. $where .= " and time > '$timetk' and time < '$timetj'";
  281. }
  282. if ($sku) {
  283. $where .= " and sku = '$sku'";
  284. }
  285. if ($number) {
  286. $where .= " and number = '$number'";
  287. }
  288. if ($warehouse) {
  289. $where .= " and warehouse = '$warehouse'";
  290. }
  291. if ($purchase) {
  292. $where .= " and purchase = '$purchase'";
  293. }
  294. if ($orderinfo) {
  295. $where .= " and orderinfo = '$orderinfo'";
  296. }
  297. if ($waybill) {
  298. $where .= " and waybill = '$waybill'";
  299. }
  300. if ($category) {
  301. $where .= " and features like '%-$category-%'";
  302. }
  303. if ($size) {
  304. $where .= " and features like '%-$size-%'";
  305. }
  306. if ($grade) {
  307. $where .= " and features like '%-$grade-%'";
  308. }
  309. if ($color) {
  310. $where .= " and features like '%-$color-%'";
  311. }
  312. if ($lowe) {
  313. $where .= " and features like '%-$lowe-%'";
  314. }
  315. if ($label) {
  316. $where .= " and label = '$label'";
  317. }
  318. if ($state != '') {
  319. $where .= " and state = '$state'";
  320. }
  321. //数据排序
  322. $order_str = "time desc";
  323. if (empty($page)) {
  324. $start = 0;
  325. $perpage = 1;
  326. } else {
  327. $start = ($page - 1) * $perpage;
  328. }
  329. //取得信息列表
  330. $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);
  331. foreach ($info_list as $key => $value) {
  332. $warehouse = $this->warehouse->read($value['warehouse']);
  333. $info_list[$key]['warehouse'] = $warehouse['title'];
  334. $purchase = $this->purchase->read($value['purchase']);
  335. $info_list[$key]['purchase'] = $purchase['title'];
  336. if ($value['enter'] != 0) {
  337. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  338. } else {
  339. $info_list[$key]['enter'] = "";
  340. }
  341. if ($value['outk'] != 0) {
  342. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  343. } else {
  344. $info_list[$key]['outk'] = "";
  345. }
  346. if ($value['printing'] != 0) {
  347. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  348. } else {
  349. $info_list[$key]['printing'] = "";
  350. }
  351. if ($value['orderinfo'] == 0) {
  352. $info_list[$key]['orderinfo'] = "";
  353. }
  354. if ($value['waybill'] == 0) {
  355. $info_list[$key]['waybill'] = "";
  356. }
  357. if ($value['state'] == 0) {
  358. $info_list[$key]['state'] = "在库";
  359. } else if ($value['state'] == 1) {
  360. $info_list[$key]['state'] = "出库";
  361. } else if ($value['state'] == 2) {
  362. $info_list[$key]['state'] = "退库";
  363. } else if ($value['state'] == 3) {
  364. $info_list[$key]['state'] = "调拨中";
  365. } else if ($value['state'] == 4) {
  366. $info_list[$key]['state'] = "再加工";
  367. } else if ($value['state'] == 5) {
  368. $info_list[$key]['state'] = "维修中";
  369. } else if ($value['state'] == 6) {
  370. $info_list[$key]['state'] = "盘亏";
  371. } else if ($value['state'] == 7) {
  372. $info_list[$key]['state'] = "更换标签";
  373. } else if ($value['state'] == 8) {
  374. $info_list[$key]['state'] = "其它";
  375. } else if ($value['state'] == 9) {
  376. $info_list[$key]['state'] = "预设";
  377. } else if ($value['state'] == 10) {
  378. $info_list[$key]['state'] = "美店零售";
  379. }
  380. if ($value['text'] == "") {
  381. $info_list[$key]['text'] = "";
  382. }
  383. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  384. }
  385. $total = $this->whlabel->find_count($where);
  386. $pagenum = ceil($total / $perpage);
  387. $over = $total - ($start + $perpage);
  388. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  389. echo json_encode($rows);
  390. exit;
  391. }
  392. if (isset($post['outsku'])) {
  393. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  394. $cz = $this->input->post('cz', true);
  395. if ($cz == '1') {
  396. $sku = $this->input->post('outsku', true);
  397. if ($sku) {
  398. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  399. if (count($data) < 1) {
  400. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  401. exit;
  402. }
  403. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  404. echo json_encode(array('success' => true));
  405. exit;
  406. }
  407. } else {
  408. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  409. exit;
  410. $sku = $this->input->post('outsku', true);
  411. if ($sku) {
  412. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  413. if (count($data) < 1) {
  414. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  415. exit;
  416. }
  417. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  418. echo json_encode(array('success' => true));
  419. exit;
  420. }
  421. }
  422. }
  423. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  424. $this->_Template('whlabel', $this->data);
  425. }
  426. //在库标签
  427. public function _existence()
  428. {
  429. $post = $this->input->post(NULL, TRUE);
  430. if (isset($post['s'])) {
  431. $id_arr = $this->input->post('s');
  432. $id_arr = explode(',', $id_arr);
  433. if (!$id_arr) {
  434. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  435. exit;
  436. }
  437. //循环删除记录
  438. foreach ($id_arr as $v) {
  439. $sid = $this->whlabel->read($v);
  440. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  441. if ($count > 0) {
  442. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  443. exit;
  444. }
  445. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  446. if (count($zt) > 0) {
  447. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  448. exit;
  449. }
  450. $this->whlabel->remove($v);
  451. }
  452. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  453. exit;
  454. }
  455. if (isset($post['page'])) {
  456. $page = $this->input->post('page', true);
  457. $perpage = $this->input->post('perpage', true);
  458. $warehouse = $this->input->post('warehouse', true);
  459. $label = $this->input->post('label', true);
  460. $where = "1=1 and state = 0";
  461. if ($warehouse) {
  462. $where .= " and warehouse = '$warehouse'";
  463. }
  464. if ($label) {
  465. $where .= " and label = '$label'";
  466. }
  467. //数据排序
  468. $order_str = "time asc";
  469. if (empty($page)) {
  470. $start = 0;
  471. $perpage = 1;
  472. } else {
  473. $start = ($page - 1) * $perpage;
  474. }
  475. //取得信息列表
  476. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  477. foreach ($info_list as $key => $value) {
  478. if ($value['enter'] != 0) {
  479. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  480. } else {
  481. $info_list[$key]['enter'] = "";
  482. }
  483. if ($value['printing'] != 0) {
  484. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  485. } else {
  486. $info_list[$key]['printing'] = "";
  487. }
  488. }
  489. $total = $this->whlabel->find_count($where);
  490. $pagenum = ceil($total / $perpage);
  491. $over = $total - ($start + $perpage);
  492. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  493. echo json_encode($rows);
  494. exit;
  495. }
  496. $this->_Template('whlabel_existence', $this->data);
  497. }
  498. //进销存浏览
  499. public function _typedy($arg_array)
  500. {
  501. $prc = array();
  502. $purchase = $this->purchase->find_all();
  503. foreach ($purchase as $k => $v) {
  504. $prc[$v['id']] = $v['title'];
  505. }
  506. $post = $this->input->post(NULL, TRUE);
  507. if (isset($post['page'])) {
  508. $page = $this->input->post('page', true);
  509. $perpage = $this->input->post('perpage', true);
  510. $category = $this->input->post('category', true);
  511. $size = $this->input->post('size', true);
  512. $grade = $this->input->post('grade', true);
  513. $color = $this->input->post('color', true);
  514. $lowe = $this->input->post('lowe', true);
  515. $sku = $this->input->post('sku');
  516. $title = $this->input->post('title');
  517. $warehouse = $this->input->post('warehouse', true);
  518. $usa = $this->input->post('usa', true);
  519. $purchase = $this->input->post('purchase', true);
  520. $lacetype = $this->input->post('lacetype', true);
  521. $haircap = $this->input->post('haircap', true);
  522. $density = $this->input->post('density', true);
  523. $details = $this->input->post('details', true);
  524. $state = $this->input->post('state', true);
  525. $lacecolor = $this->input->post('lacecolor', true);
  526. $hairnumber = $this->input->post('hairnumber', true);
  527. $cklx = $this->input->post('cklx', true);
  528. $ktime = $this->input->post('ktime', true);
  529. $jtime = $this->input->post('jtime', true);
  530. $sm = $this->input->post('sm', true);
  531. $cpbz = $this->input->post('cpbz', true);
  532. $type = $this->input->post('type', true);
  533. $ktime = strtotime($ktime);
  534. $jtime = strtotime($jtime);
  535. $where = "1=1";
  536. $gj = "";
  537. $ck = "";
  538. if ($usa) {
  539. if (!$warehouse) {
  540. $where .= " and (warehouse = '5' or warehouse = '8')";
  541. }
  542. }
  543. if ($warehouse) {
  544. $where .= " and warehouse = '$warehouse'";
  545. }
  546. if ($details) {
  547. $where .= " and details = '$details'";
  548. }
  549. if ($purchase) {
  550. $where .= " and purchase = '$purchase'";
  551. }
  552. if (isset($state)) {
  553. if($state >-1){
  554. $where .= " and state = '$state'";
  555. }
  556. }
  557. if ($lacetype) {
  558. $where .= " and features like '%-$lacetype-%'";
  559. }
  560. if ($category) {
  561. $where .= " and features like '%-$category-%'";
  562. }
  563. if ($size) {
  564. $where .= " and features like '%-$size-%'";
  565. }
  566. if ($grade) {
  567. $where .= " and features like '%-$grade-%'";
  568. }
  569. if ($color) {
  570. $where .= " and features like '%-$color-%'";
  571. }
  572. if ($lowe) {
  573. $where .= " and features like '%-$lowe-%'";
  574. }
  575. if ($haircap) {
  576. $where .= " and features like '%-$haircap-%'";
  577. }
  578. if ($density) {
  579. $where .= " and features like '%-$density-%'";
  580. }
  581. if ($lacecolor) {
  582. $where .= " and features like '%-$lacecolor-%'";
  583. }
  584. if($sm){
  585. $where .= " and sm like '%".$sm."%'";
  586. }
  587. if($cpbz){
  588. $where .= " and cpbz like '%".$cpbz."%'";
  589. }
  590. if($type){
  591. $where .= " and type = ".$type."";
  592. }
  593. if (!empty($hairnumber)) {
  594. $where .= " and features like '%-128-%' ";
  595. if ($hairnumber < 0) {
  596. $class_list = $this->typeclass->find_all('classid = 43');
  597. foreach ($class_list as $v) {
  598. $where .= " and features not like '%-" . $v['id'] . "-%'";
  599. }
  600. } else {
  601. $where .= " and features like '%-$hairnumber-%'";
  602. }
  603. }
  604. $where_add = '';
  605. if ($cklx) {
  606. $shop = $this->shop->read($cklx);
  607. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  608. }
  609. if ($ktime && $jtime) {
  610. $gj = " and enter > '$ktime' and enter < '$jtime'";
  611. $ck = " and outk > '$ktime' and outk < '$jtime'";
  612. }
  613. //数据排序
  614. $order_str = "id desc";
  615. if (empty($page)) {
  616. $start = 0;
  617. $perpage = 1;
  618. } else {
  619. $start = ($page - 1) * $perpage;
  620. }
  621. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  622. if ($sku) {
  623. $sku = trim($sku, ' ');
  624. $sku = trim($sku, ' ');
  625. $where .= " and sku like '%$sku%'";
  626. $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);
  627. } else if ($title) {
  628. $title = trim($title, ' ');
  629. $title = trim($title, ' ');
  630. $where .= " and title like '%$title%'";
  631. $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);
  632. } else {
  633. //$where .= " and time > '$ktime' and time < '$jtime'";
  634. $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);
  635. }
  636. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  637. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  638. foreach ($info_list as $k => $v) {
  639. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  640. unset($info_list[$k]['pm']);
  641. unset($info_list[$k]['jm']);
  642. unset($info_list[$k]['bm']);
  643. }
  644. //取得信息列表
  645. $rows = array();
  646. $list = array();
  647. foreach ($info_list as $key => $value) {
  648. $warehouse = $this->warehouse->read($value['warehouse']);
  649. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  650. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  651. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  652. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  653. $info_list[$key]['label'] = $value['sm'];
  654. $number = $value['number'];
  655. $ftime = time() - 15 * 24 * 3600;
  656. $info_list[$key]['warehouse'] = $warehouse['title'];
  657. $info_list[$key]['features'] = count($c);
  658. $z = count($z); //查看订单号
  659. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  660. $ztdata = '';
  661. if (count($zt) > 0) {
  662. foreach ($zt as $vv) {
  663. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  664. }
  665. }
  666. $info_list[$key]['number'] = $ztdata;
  667. $info_list[$key]['sm'] = $z;
  668. $details = array();
  669. $cpid = array();
  670. foreach ($c as $k => $v) {
  671. $details[$v['details']] = $v['details'];
  672. if ($v['cpid'] != 0) {
  673. $cpid[$v['cpid']] = $v['cpid'];
  674. }
  675. }
  676. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  677. if ($value['shop'] != '') {
  678. $shop = explode(',', trim($value['shop'], ','));
  679. $shop = $this->shop->read($shop[0]);
  680. $info_list[$key]['shop'] = $shop['shopname'];
  681. }
  682. }
  683. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  684. $pagenum = ceil($total / $perpage);
  685. $over = $total - ($start + $perpage);
  686. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  687. echo json_encode($rows);
  688. exit;
  689. }
  690. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  691. $this->_Template('whlabel_typedy', $this->data);
  692. }
  693. //进销存浏览
  694. public function _typedy_ck($arg_array)
  695. {
  696. $prc = array();
  697. $purchase = $this->purchase->find_all();
  698. foreach ($purchase as $k => $v) {
  699. $prc[$v['id']] = $v['title'];
  700. }
  701. $post = $this->input->post(NULL, TRUE);
  702. if (isset($post['page'])) {
  703. $page = $this->input->post('page', true);
  704. $perpage = $this->input->post('perpage', true);
  705. $category = $this->input->post('category', true);
  706. $size = $this->input->post('size', true);
  707. $grade = $this->input->post('grade', true);
  708. $color = $this->input->post('color', true);
  709. $lowe = $this->input->post('lowe', true);
  710. $sku = $this->input->post('sku');
  711. $title = $this->input->post('title');
  712. $warehouse = $this->input->post('warehouse', true);
  713. $usa = $this->input->post('usa', true);
  714. $purchase = $this->input->post('purchase', true);
  715. $lacetype = $this->input->post('lacetype', true);
  716. $haircap = $this->input->post('haircap', true);
  717. $density = $this->input->post('density', true);
  718. $details = $this->input->post('details', true);
  719. $state = $this->input->post('state', true);
  720. $lacecolor = $this->input->post('lacecolor', true);
  721. $cklx = $this->input->post('cklx', true);
  722. $ktime = $this->input->post('ktime', true);
  723. $jtime = $this->input->post('jtime', true);
  724. $ktime = strtotime($ktime);
  725. $jtime = strtotime($jtime);
  726. $where = "1=1";
  727. $gj = "";
  728. $ck = "";
  729. if ($lacetype) {
  730. $where .= " and features like '%-$lacetype-%'";
  731. }
  732. if ($category) {
  733. $where .= " and features like '%-$category-%'";
  734. }
  735. if ($size) {
  736. $where .= " and features like '%-$size-%'";
  737. }
  738. if ($grade) {
  739. $where .= " and features like '%-$grade-%'";
  740. }
  741. if ($color) {
  742. $where .= " and features like '%-$color-%'";
  743. }
  744. if ($lowe) {
  745. $where .= " and features like '%-$lowe-%'";
  746. }
  747. if ($haircap) {
  748. $where .= " and features like '%-$haircap-%'";
  749. }
  750. if ($density) {
  751. $where .= " and features like '%-$density-%'";
  752. }
  753. if ($lacecolor) {
  754. $where .= " and features like '%-$lacecolor-%'";
  755. }
  756. if ($usa) {
  757. if (!$warehouse) {
  758. $where .= " and (warehouse = '5' or warehouse = '8')";
  759. }
  760. }
  761. if ($warehouse) {
  762. $where .= " and warehouse = '$warehouse'";
  763. }
  764. if ($details) {
  765. $where .= " and details = '$details'";
  766. }
  767. if ($purchase) {
  768. $where .= " and purchase = '$purchase'";
  769. }
  770. if ($state) {
  771. $where .= " and state = '$state'";
  772. }
  773. $where_add = '';
  774. if ($cklx) {
  775. $shop = $this->shop->read($cklx);
  776. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  777. }
  778. if ($ktime && $jtime) {
  779. $gj = " and enter > '$ktime' and enter < '$jtime'";
  780. $ck = " and outk > '$ktime' and outk < '$jtime'";
  781. }
  782. //数据排序
  783. $order_str = "id desc";
  784. if (empty($page)) {
  785. $start = 0;
  786. $perpage = 1;
  787. } else {
  788. $start = ($page - 1) * $perpage;
  789. }
  790. if ($sku) {
  791. $sku = trim($sku, ' ');
  792. $sku = trim($sku, ' ');
  793. $where .= " and sku like '%$sku%'";
  794. $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);
  795. } else if ($title) {
  796. $title = trim($title, ' ');
  797. $title = trim($title, ' ');
  798. $where .= " and title like '%$title%'";
  799. $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);
  800. } else {
  801. //$where .= " and time > '$ktime' and time < '$jtime'";
  802. $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);
  803. }
  804. //取得信息列表
  805. $rows = array();
  806. $list = array();
  807. foreach ($info_list as $key => $value) {
  808. $warehouse = $this->warehouse->read($value['warehouse']);
  809. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  810. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  811. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  812. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  813. $ftime = time() - 15 * 24 * 3600;
  814. $info_list[$key]['warehouse'] = $warehouse['title'];
  815. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  816. //$z = count($z);//查看订单号
  817. //$info_list[$key]['zd'] = $z;
  818. $details = array();
  819. $cpid = array();
  820. foreach ($c as $k => $v) {
  821. $details[$v['details']] = $v['details'];
  822. if ($v['cpid'] != 0) {
  823. $cpid[$v['cpid']] = $v['cpid'];
  824. }
  825. }
  826. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  827. if ($value['shop'] != '') {
  828. $shop = explode(',', trim($value['shop'], ','));
  829. $shop = $this->shop->read($shop[0]);
  830. $info_list[$key]['shop'] = $shop['shopname'];
  831. }
  832. }
  833. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  834. $pagenum = ceil($total / $perpage);
  835. $over = $total - ($start + $perpage);
  836. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  837. echo json_encode($rows);
  838. exit;
  839. }
  840. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  841. $this->_Template('whlabel_typedy_ck', $this->data);
  842. }
  843. public function _typeck($arg_array)
  844. {
  845. $prc = array();
  846. $purchase = $this->purchase->find_all();
  847. foreach ($purchase as $k => $v) {
  848. $prc[$v['id']] = $v['title'];
  849. }
  850. $post = $this->input->post(NULL, TRUE);
  851. if (isset($post['page'])) {
  852. $page = $this->input->post('page', true);
  853. $perpage = $this->input->post('perpage', true);
  854. $category = $this->input->post('category', true);
  855. $size = $this->input->post('size', true);
  856. $grade = $this->input->post('grade', true);
  857. $color = $this->input->post('color', true);
  858. $lacecolor = $this->input->post('lacecolor', true);
  859. $lowe = $this->input->post('lowe', true);
  860. $sku = $this->input->post('sku');
  861. $title = $this->input->post('title');
  862. $warehouse = 13;
  863. $usa = $this->input->post('usa', true);
  864. $purchase = $this->input->post('purchase', true);
  865. $lacetype = $this->input->post('lacetype', true);
  866. $haircap = $this->input->post('haircap', true);
  867. $density = $this->input->post('density', true);
  868. $details = $this->input->post('details', true);
  869. $state = $this->input->post('state', true);
  870. $ktime = $this->input->post('ktime', true);
  871. $jtime = $this->input->post('jtime', true);
  872. $ktime = strtotime($ktime);
  873. $jtime = strtotime($jtime);
  874. $where = "1=1";
  875. $gj = "";
  876. $ck = "";
  877. if ($lacetype) {
  878. $where .= " and features like '%-$lacetype-%'";
  879. }
  880. if ($category) {
  881. $where .= " and features like '%-$category-%'";
  882. }
  883. if ($size) {
  884. $where .= " and features like '%-$size-%'";
  885. }
  886. if ($grade) {
  887. $where .= " and features like '%-$grade-%'";
  888. }
  889. if ($color) {
  890. $where .= " and features like '%-$color-%'";
  891. }
  892. if ($lacecolor) {
  893. $where .= " and features like '%-$lacecolor-%'";
  894. }
  895. if ($lowe) {
  896. $where .= " and features like '%-$lowe-%'";
  897. }
  898. if ($haircap) {
  899. $where .= " and features like '%-$haircap-%'";
  900. }
  901. if ($density) {
  902. $where .= " and features like '%-$density-%'";
  903. }
  904. if ($warehouse) {
  905. $where .= " and warehouse = '$warehouse'";
  906. }
  907. if ($details) {
  908. $where .= " and details = '$details'";
  909. }
  910. if ($purchase) {
  911. $where .= " and purchase = '$purchase'";
  912. }
  913. if ($state) {
  914. $where .= " and state = '$state'";
  915. }
  916. if ($ktime && $jtime) {
  917. $gj = " and enter > '$ktime' and enter < '$jtime'";
  918. $ck = " and outk > '$ktime' and outk < '$jtime'";
  919. }
  920. //数据排序
  921. $order_str = "id desc";
  922. if (empty($page)) {
  923. $start = 0;
  924. $perpage = 1;
  925. } else {
  926. $start = ($page - 1) * $perpage;
  927. }
  928. if ($sku) {
  929. $sku = trim($sku, ' ');
  930. $sku = trim($sku, ' ');
  931. $where .= " and sku like '%$sku%'";
  932. } else if ($title) {
  933. $title = trim($title, ' ');
  934. $title = trim($title, ' ');
  935. $where .= " and title like '%$title%'";
  936. }
  937. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  938. //取得信息列表
  939. $t = array();
  940. $typeclass = $this->typeclass->find_all();
  941. foreach ($typeclass as $v) {
  942. $t[$v['id']] = $v;
  943. }
  944. $rows = array();
  945. $list = array();
  946. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  947. foreach ($info_list as $key => $value) {
  948. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  949. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  950. $warehouse = $this->warehouse->read($value['warehouse']);
  951. $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');
  952. $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'] . '"');
  953. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  954. $number = $value['number'];
  955. $ftime = time() - 15 * 24 * 3600;
  956. $z = count($z); //查看订单号
  957. $info_list[$key]['warehouse'] = $warehouse['title'];
  958. $info_list[$key]['features'] = count($c);
  959. $info_list[$key]['number'] = $z;
  960. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  961. $details = array();
  962. $cpid = array();
  963. foreach ($c as $k => $v) {
  964. $details[$v['details']] = $v['details'];
  965. if ($v['cpid'] != 0) {
  966. $cpid[$v['cpid']] = $v['cpid'];
  967. }
  968. }
  969. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  970. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  971. unset($info_list[$key]['pm']);
  972. unset($info_list[$key]['jm']);
  973. unset($info_list[$key]['bm']);
  974. }
  975. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  976. $pagenum = ceil($total / $perpage);
  977. $over = $total - ($start + $perpage);
  978. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  979. echo json_encode($rows);
  980. exit;
  981. }
  982. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  983. $this->_Template('whlabel_typeck', $this->data);
  984. }
  985. //进销存导出
  986. public function _whlabeckdc()
  987. {
  988. $prc = array();
  989. $purchase = $this->purchase->find_all();
  990. foreach ($purchase as $k => $v) {
  991. $prc[$v['id']] = $v['title'];
  992. }
  993. if (isset($_GET['excel'])) {
  994. $where = "sku != 'Preset'";
  995. //数据排序
  996. $order_str = "id desc";
  997. if (empty($page)) {
  998. $start = 0;
  999. $perpage = 1;
  1000. } else {
  1001. $start = ($page - 1) * $perpage;
  1002. }
  1003. $category = $this->input->get('category', true);
  1004. $color = $this->input->get('color', true);
  1005. $lowe = $this->input->get('lowe', true);
  1006. $lacetype = $this->input->get('lacetype', true);
  1007. $size = $this->input->get('size', true);
  1008. $density = $this->input->get('density', true);
  1009. $haircap = $this->input->get('haircap', true);
  1010. $sku = $this->input->get('sku', true);
  1011. $details = $this->input->get('details', true);
  1012. $warehouse = 13;
  1013. $excelid = $this->input->get('sid', true);
  1014. if ($category) {
  1015. $where .= " and features like '%-$category-%'";
  1016. }
  1017. if ($color) {
  1018. $where .= " and features like '%-$color-%'";
  1019. }
  1020. if ($lowe) {
  1021. $where .= " and features like '%-$lowe-%'";
  1022. }
  1023. if ($lacetype) {
  1024. $where .= " and features like '%-$lacetype-%'";
  1025. }
  1026. if ($size) {
  1027. $where .= " and features like '%-$size-%'";
  1028. }
  1029. if ($density) {
  1030. $where .= " and features like '%-$density-%'";
  1031. }
  1032. if ($haircap) {
  1033. $where .= " and features like '%-$haircap-%'";
  1034. }
  1035. if ($warehouse) {
  1036. $where .= " and warehouse = '$warehouse'";
  1037. }
  1038. if ($sku) {
  1039. $where .= " and sku like '%$sku%'";
  1040. }
  1041. if ($details) {
  1042. $where .= " and details = '$details'";
  1043. }
  1044. $xzid = '';
  1045. if ($excelid) {
  1046. $excelid = explode(',', trim($excelid, ','));
  1047. foreach ($excelid as $key => $value) {
  1048. $xzid .= " id = " . $value . " or";
  1049. }
  1050. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1051. }
  1052. //取得信息列表
  1053. /**
  1054. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1055. $rows = array();$list = array();
  1056. foreach ($info_list as $key=>$value)
  1057. {
  1058. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1059. }
  1060. **/
  1061. $wh = array();
  1062. $w = $this->warehouse->find_all('1=1', 'id,title');
  1063. foreach ($w as $v) {
  1064. $wh[$v['id']] = $v['title'];
  1065. }
  1066. $tc = array();
  1067. $tcdata = array();
  1068. $list = array();
  1069. $classid = $this->classid->sku();
  1070. $tcall = $this->typeclass->find_all();
  1071. $typeclass = array();
  1072. foreach ($tcall as $v)
  1073. {
  1074. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1075. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1076. }
  1077. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1078. foreach ($rows as $key => $value) {
  1079. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1080. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1081. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1082. $rows[$key]['cpbz'] = $u9_info['bm'];
  1083. $rows[$key]['cs'] = $u9_info['jm'];
  1084. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1085. $details = array();
  1086. $cpid = array();
  1087. $cpbz = array();
  1088. $c = 0;
  1089. $g = 0;
  1090. $x = 0;
  1091. $t = 0;
  1092. $s = 0;
  1093. $q = 0;
  1094. foreach ($sd as $k => $v) {
  1095. if ($v['state'] == 0) {
  1096. $c++;
  1097. }
  1098. if ($v['state'] != 9) {
  1099. $g++;
  1100. }
  1101. if ($v['state'] == 1) {
  1102. $x++;
  1103. }
  1104. if ($v['state'] == 2) {
  1105. $t++;
  1106. }
  1107. if ($v['state'] == 8) {
  1108. $s++;
  1109. }
  1110. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1111. $q++;
  1112. }
  1113. $details[$v['details']] = $v['details'];
  1114. if ($v['cpid'] != 0) {
  1115. $cpid[$v['cpid']] = $v['cpid'];
  1116. }
  1117. if ($v['cpbz'] != '') {
  1118. $cpbz[$v['cpbz']] = $v['cpbz'];
  1119. }
  1120. }
  1121. $rows[$key]['details'] = implode("、", $details);
  1122. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1123. $number = $value['number'];
  1124. $ftime = time() - 15 * 24 * 3600;
  1125. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1126. $rows[$key]['number'] = $g;
  1127. $rows[$key]['features'] = $c;
  1128. $rows[$key]['x'] = $x;
  1129. $rows[$key]['t'] = $t;
  1130. $rows[$key]['s'] = $s;
  1131. $rows[$key]['q'] = $q;
  1132. $rows[$key]['wzsl'] = count($details);
  1133. }
  1134. $title = "进销存统计表" . date('Y-m-d', time());
  1135. $titlename = "<table border=1>
  1136. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1137. <tr align='center'>
  1138. <td>仓库</td>
  1139. <td>供应商</td>
  1140. <td>位置</td>
  1141. <td>库存编码</td>
  1142. <td>SKU</td>
  1143. <td>用友编码</td>
  1144. <td>用友料号</td>
  1145. <td>产品英文名</td>
  1146. <td>产品中文名</td>
  1147. <td>入库总量</td>
  1148. <td>库存数量</td>
  1149. <td>销售数量</td>
  1150. <td>退货数量</td>
  1151. <td>删除数量</td>
  1152. <td>其它操作</td>
  1153. <td>位置数量</td>
  1154. </tr>
  1155. </table>";
  1156. $filename = $title . ".xls";
  1157. $tail = "";
  1158. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1159. }
  1160. }
  1161. public function _type()
  1162. {
  1163. $vip = 0;
  1164. if (isset($_SESSION['api'])) {
  1165. $user = $this->user->get_api($_SESSION['api']);
  1166. $fgshop = "";
  1167. $sid = "";
  1168. $usersp = explode('|', trim($user['shop'], '|'));
  1169. foreach ($usersp as $value) {
  1170. $fgshop .= " shop = " . $value . " or";
  1171. $sid .= " id = " . $value . " or";
  1172. }
  1173. if ($user['vip'] == 1) {
  1174. $vip = 1;
  1175. }
  1176. } else {
  1177. header('Location: /');
  1178. exit;
  1179. }
  1180. $prc = array();
  1181. $purchase = $this->purchase->find_all();
  1182. foreach ($purchase as $k => $v) {
  1183. $prc[$v['id']] = $v['title'];
  1184. }
  1185. $company = array();
  1186. $ct = $this->company->find_all();
  1187. foreach ($ct as $k => $v) {
  1188. $company[$v['id']] = $v['title'];
  1189. }
  1190. $sp = array();
  1191. $s = $this->shop->find_all('1=1', 'id,shopname');
  1192. foreach ($s as $v) {
  1193. $sp[$v['id']] = $v['shopname'];
  1194. }
  1195. $wh = array();
  1196. $w = $this->warehouse->find_all('1=1', 'id,title');
  1197. foreach ($w as $v) {
  1198. $wh[$v['id']] = $v['title'];
  1199. }
  1200. $post = $this->input->post(NULL, TRUE);
  1201. if (isset($post['page'])) {
  1202. $page = $this->input->post('page', true);
  1203. $perpage = $this->input->post('perpage', true);
  1204. $category = $this->input->post('category', true);
  1205. $size = $this->input->post('size', true);
  1206. $grade = $this->input->post('grade', true);
  1207. $color = $this->input->post('color', true);
  1208. $lowe = $this->input->post('lowe', true);
  1209. $sku = $this->input->post('sku');
  1210. $title = $this->input->post('title');
  1211. $warehouse = $this->input->post('warehouse', true);
  1212. $usa = $this->input->post('usa', true);
  1213. $purchase = $this->input->post('purchase', true);
  1214. $lacetype = $this->input->post('lacetype', true);
  1215. $haircap = $this->input->post('haircap', true);
  1216. $density = $this->input->post('density', true);
  1217. $details = $this->input->post('details', true);
  1218. $state = $this->input->post('state', true);
  1219. $shop = $this->input->post('shop', true);
  1220. $lacecolor = $this->input->post('lacecolor', true);
  1221. $hairnumber = $this->input->post('hairnumber', true);
  1222. $type = $this->input->post('type', true);
  1223. $ktime = $this->input->post('ktime', true);
  1224. $jtime = $this->input->post('jtime', true);
  1225. $ktime = strtotime($ktime);
  1226. $jtime = strtotime($jtime);
  1227. $cpbz = $this->input->post('cpbz', true);
  1228. $sm = $this->input->post('sm', true);
  1229. $where = "1=1";
  1230. $gj = "";
  1231. $ck = "";
  1232. if ($usa) {
  1233. if (!$warehouse) {
  1234. $where .= " and (warehouse = '5' or warehouse = '8')";
  1235. }
  1236. }
  1237. if ($warehouse) {
  1238. $where .= " and warehouse = '$warehouse'";
  1239. }
  1240. if ($details) {
  1241. $where .= " and details = '$details'";
  1242. }
  1243. if ($purchase) {
  1244. $where .= " and purchase = '$purchase'";
  1245. }
  1246. if ($state) {
  1247. $where .= " and state = '$state'";
  1248. }
  1249. if ($shop) {
  1250. $where .= " and shop like '%$shop%'";
  1251. }
  1252. if ($type) {
  1253. $where .= " and type = '$type'";
  1254. }
  1255. if ($ktime && $jtime) {
  1256. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1257. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1258. }
  1259. if ($cpbz) {
  1260. $where .= " and cpbz like '%$cpbz%' ";
  1261. }
  1262. if ($sm) {
  1263. $where .= " and sm like '%$sm%' ";
  1264. }
  1265. if ($lacecolor) {
  1266. $where .= " and features like '%-$lacecolor-%'";
  1267. }
  1268. if ($lacetype) {
  1269. $where .= " and features like '%-$lacetype-%'";
  1270. }
  1271. if ($category) {
  1272. $where .= " and features like '%-$category-%'";
  1273. }
  1274. if ($size) {
  1275. $where .= " and features like '%-$size-%'";
  1276. }
  1277. if ($grade) {
  1278. $where .= " and features like '%-$grade-%'";
  1279. }
  1280. if ($color) {
  1281. $where .= " and features like '%-$color-%'";
  1282. }
  1283. if ($lowe) {
  1284. $where .= " and features like '%-$lowe-%'";
  1285. }
  1286. if ($haircap) {
  1287. $where .= " and features like '%-$haircap-%'";
  1288. }
  1289. if ($density) {
  1290. $where .= " and features like '%-$density-%'";
  1291. }
  1292. if (!empty($hairnumber)) {
  1293. $where .= " and features like '%-128-%' ";
  1294. if ($hairnumber < 0) {
  1295. $class_list = $this->typeclass->find_all('classid = 43');
  1296. foreach ($class_list as $v) {
  1297. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1298. }
  1299. } else {
  1300. $where .= " and features like '%-$hairnumber-%'";
  1301. }
  1302. }
  1303. //数据排序
  1304. $order_str = "id desc";
  1305. if (empty($page)) {
  1306. $start = 0;
  1307. $perpage = 1;
  1308. } else {
  1309. $start = ($page - 1) * $perpage;
  1310. }
  1311. $fjnr = '';
  1312. if ($sku) {
  1313. $sku = trim($sku, ' ');
  1314. $sku = trim($sku, ' ');
  1315. $fjnr .= " and sku like '%$sku%'";
  1316. }
  1317. if ($title) {
  1318. $title = trim($title, ' ');
  1319. $title = trim($title, ' ');
  1320. $fjnr .= " and title like '%$title%'";
  1321. }
  1322. $wt = array();
  1323. $whlabel_type = $this->whlabel_type->find_all();
  1324. foreach ($whlabel_type as $v) {
  1325. $wt[$v['id']] = $v['title'];
  1326. }
  1327. //$where .= " and time > '$ktime' and time < '$jtime'";
  1328. $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
  1329. //取得信息列表
  1330. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1331. $rows = array();
  1332. $list = array();
  1333. foreach ($info_list as $key => $value) {
  1334. if (isset($wt[$value['type']])) {
  1335. $info_list[$key]['type'] = $wt[$value['type']];
  1336. } else {
  1337. $info_list[$key]['type'] = '未设置';
  1338. }
  1339. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1340. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1341. $ztdata = '';
  1342. if (count($zt) > 0) {
  1343. foreach ($zt as $vv) {
  1344. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1345. }
  1346. }
  1347. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1348. $cdata = array_filter($qbdata, function ($item) {
  1349. return $item['state'] < 1;
  1350. });
  1351. $c = array_sum(array_column($cdata, 'jnum'));
  1352. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1353. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1354. });
  1355. $g = array_sum(array_column($gdata, 'jnum'));
  1356. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1357. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1358. });
  1359. $x = array_sum(array_column($xdata, 'jnum'));
  1360. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1361. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1362. });
  1363. $t = array_sum(array_column($tdata, 'jnum'));
  1364. // $zdata = array_filter($qbdata, function ($item) {
  1365. // return $item['zd'] != "" && $item['state'] < 1;
  1366. // });
  1367. // $z = array_sum(array_column($zdata, 'jnum'));
  1368. $zdata = array_filter($qbdata, function ($item) {
  1369. return $item['zd'] != "" && $item['state'] < 1;
  1370. });
  1371. $z = array_sum(array_column($zdata, 'jnum'));
  1372. //$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');
  1373. //$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'].'"');
  1374. //$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'].'"');
  1375. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1376. //$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'].'"');
  1377. $details = array();
  1378. $cpid = array();
  1379. $od = array();
  1380. $odid = '';
  1381. $companytitle = '';
  1382. $shop_list = [];
  1383. foreach ($qbdata as $v) {
  1384. if ($v['zd'] != "" && $v['state'] < 1) {
  1385. if (!isset($od[$v['zd']])) {
  1386. $od[$v['zd']] = 1; //所有数据sku
  1387. } else {
  1388. $od[$v['zd']] = $od[$v['zd']] + 1;
  1389. }
  1390. }
  1391. if ($v['state'] < 1) {
  1392. $details[$v['details']] = $v['details'];
  1393. if ($v['cpid'] != 0) {
  1394. $cpid[$v['cpid']] = $v['cpid'];
  1395. }
  1396. }
  1397. if($v['state'] == 0){
  1398. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1399. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1400. }
  1401. if ($v['shop'] != '') {
  1402. $shop = explode(',', trim($v['shop'], ','));
  1403. foreach ($shop as $vv) {
  1404. if (!in_array($vv, $shop_list)) {
  1405. $shop_list[] = $vv;
  1406. }
  1407. }
  1408. }
  1409. }
  1410. }
  1411. foreach ($od as $k => $vv) {
  1412. $odid .= $k . '数量' . $vv;
  1413. }
  1414. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1415. $info_list[$key]['label'] = $value['sm'];
  1416. $number = $value['number'];
  1417. $ftime = time() - 15 * 24 * 3600;
  1418. $z = $z . '(' . $odid . ')'; //查看订单号
  1419. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1420. $info_list[$key]['features'] = $c;
  1421. $info_list[$key]['number'] = $ztdata;
  1422. $info_list[$key]['sm'] = $g;
  1423. $info_list[$key]['x'] = $x;
  1424. $info_list[$key]['t'] = $t;
  1425. $info_list[$key]['z'] = $z;
  1426. /**
  1427. foreach ($cdata as $k=>$v)
  1428. {
  1429. $details[$v['details']] = $v['details'];
  1430. if($v['cpid'] != 0)
  1431. {
  1432. $cpid[$v['cpid']] = $v['cpid'];
  1433. }
  1434. }
  1435. **/
  1436. $info_list[$key]['shop'] = '';
  1437. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1438. // if ($value['shop'] != '') {
  1439. // $shop = explode(',', trim($value['shop'], ','));
  1440. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1441. // }
  1442. $shop_list = array_unique($shop_list);
  1443. $shop_str = '';
  1444. foreach ($shop_list as $v) {
  1445. if(isset($sp[$v])){
  1446. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1447. }
  1448. }
  1449. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1450. /**
  1451. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1452. if(isset($companytitle[0]))
  1453. {
  1454. foreach ($companytitle as $k=>$v)
  1455. {
  1456. if($v['companytitle'] != '')
  1457. {
  1458. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1459. }
  1460. }
  1461. }
  1462. **/
  1463. }
  1464. $final_all_list = [];
  1465. foreach ($info_list as $k => $v) {
  1466. $final_all_list[] = [
  1467. 'id' => $v['id'],
  1468. "warehouse" => $v["warehouse"],
  1469. "purchase" => $v["purchase"],
  1470. "sku" => $v["sku"],
  1471. "title" => $v["title"] . "<br/>" . $v["pm"],
  1472. "details" => $v["details"],
  1473. "shop" => $v["shop"],
  1474. "cpbz" => $v["cpbz"],
  1475. 'label' => $v['label'],
  1476. "type" => $v["type"],
  1477. "features" => $v["features"],
  1478. "number" => $v["number"],
  1479. "sm" => $v["sm"],
  1480. "x" => $v["x"],
  1481. "t" => $v["t"],
  1482. "z" => $v["z"]
  1483. ];
  1484. }
  1485. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1486. $pagenum = ceil($total / $perpage);
  1487. $over = $total - ($start + $perpage);
  1488. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1489. echo json_encode($rows);
  1490. exit;
  1491. }
  1492. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1493. $this->data['shop'] = $wlshop;
  1494. $this->data['vip'] = $vip;
  1495. $this->_Template('whlabel_type', $this->data);
  1496. }
  1497. //美仓进销存浏览
  1498. public function _usatype()
  1499. {
  1500. if (isset($_SESSION['api'])) {
  1501. $user = $this->user->get_api($_SESSION['api']);
  1502. $usp = $user;
  1503. $fgshop = "";
  1504. $sid = "";
  1505. $wid = "";
  1506. $wtype = "";
  1507. $userwh = explode('|', trim($user['warehouse'], '|'));
  1508. foreach ($userwh as $value) {
  1509. $wid .= " id = " . $value . " or";
  1510. $wtype .= " type = " . $value . " or";
  1511. }
  1512. }
  1513. $prc = array();
  1514. $purchase = $this->purchase->find_all();
  1515. foreach ($purchase as $k => $v) {
  1516. $prc[$v['id']] = $v['title'];
  1517. }
  1518. $post = $this->input->post(NULL, TRUE);
  1519. if (isset($post['page'])) {
  1520. $page = $this->input->post('page', true);
  1521. $perpage = $this->input->post('perpage', true);
  1522. $category = $this->input->post('category', true);
  1523. $size = $this->input->post('size', true);
  1524. $grade = $this->input->post('grade', true);
  1525. $color = $this->input->post('color', true);
  1526. $lowe = $this->input->post('lowe', true);
  1527. $sku = $this->input->post('sku');
  1528. $title = $this->input->post('title');
  1529. $warehouse = $this->input->post('warehouse', true);
  1530. $usa = $this->input->post('usa', true);
  1531. $purchase = $this->input->post('purchase', true);
  1532. $lacetype = $this->input->post('lacetype', true);
  1533. $haircap = $this->input->post('haircap', true);
  1534. $density = $this->input->post('density', true);
  1535. $details = $this->input->post('details', true);
  1536. $state = $this->input->post('state', true);
  1537. $lacecolor = $this->input->post('lacecolor', true);
  1538. $cklx = $this->input->post('cklx', true);
  1539. $ktime = $this->input->post('ktime', true);
  1540. $jtime = $this->input->post('jtime', true);
  1541. $ktime = strtotime($ktime);
  1542. $jtime = strtotime($jtime);
  1543. $where = "1=1";
  1544. $gj = "";
  1545. $ck = "";
  1546. if ($lacetype) {
  1547. $where .= " and features like '%-$lacetype-%'";
  1548. }
  1549. if ($category) {
  1550. $where .= " and features like '%-$category-%'";
  1551. }
  1552. if ($size) {
  1553. $where .= " and features like '%-$size-%'";
  1554. }
  1555. if ($grade) {
  1556. $where .= " and features like '%-$grade-%'";
  1557. }
  1558. if ($color) {
  1559. $where .= " and features like '%-$color-%'";
  1560. }
  1561. if ($lowe) {
  1562. $where .= " and features like '%-$lowe-%'";
  1563. }
  1564. if ($haircap) {
  1565. $where .= " and features like '%-$haircap-%'";
  1566. }
  1567. if ($density) {
  1568. $where .= " and features like '%-$density-%'";
  1569. }
  1570. if ($lacecolor) {
  1571. $where .= " and features like '%-$lacecolor-%'";
  1572. }
  1573. if ($usa) {
  1574. if (!$warehouse) {
  1575. $where .= " and (warehouse = '5' or warehouse = '8')";
  1576. }
  1577. }
  1578. if ($warehouse) {
  1579. $where .= " and warehouse = '$warehouse'";
  1580. }
  1581. if ($details) {
  1582. $where .= " and details = '$details'";
  1583. }
  1584. if ($purchase) {
  1585. $where .= " and purchase = '$purchase'";
  1586. }
  1587. if ($state) {
  1588. $where .= " and state = '$state'";
  1589. }
  1590. $where_add = '';
  1591. if ($cklx) {
  1592. $shop = $this->shop->read($cklx);
  1593. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1594. }
  1595. if ($ktime && $jtime) {
  1596. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1597. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1598. }
  1599. //数据排序
  1600. $order_str = "id desc";
  1601. if (empty($page)) {
  1602. $start = 0;
  1603. $perpage = 1;
  1604. } else {
  1605. $start = ($page - 1) * $perpage;
  1606. }
  1607. if ($sku) {
  1608. $sku = trim($sku, ' ');
  1609. $sku = trim($sku, ' ');
  1610. $where .= " and sku like '%$sku%'";
  1611. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1612. } else if ($title) {
  1613. $title = trim($title, ' ');
  1614. $title = trim($title, ' ');
  1615. $where .= " and title like '%$title%'";
  1616. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1617. } else {
  1618. //$where .= " and time > '$ktime' and time < '$jtime'";
  1619. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1620. }
  1621. //取得信息列表
  1622. $rows = array();
  1623. $list = array();
  1624. foreach ($info_list as $key => $value) {
  1625. $warehouse = $this->warehouse->read($value['warehouse']);
  1626. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1627. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1628. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1629. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1630. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1631. $od = array();
  1632. $odid = '';
  1633. foreach ($z as $v) {
  1634. if (!isset($od[$v['zd']])) {
  1635. $od[$v['zd']] = 1; //所有数据sku
  1636. } else {
  1637. $od[$v['zd']] = $od[$v['zd']] + 1;
  1638. }
  1639. }
  1640. foreach ($od as $k => $vv) {
  1641. $odid .= $k . '数量' . $vv . ' ';
  1642. }
  1643. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1644. $info_list[$key]['features'] = $c;
  1645. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1646. $ztdata = '';
  1647. if (count($zt) > 0) {
  1648. foreach ($zt as $vv) {
  1649. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1650. }
  1651. }
  1652. $info_list[$key]['warehouse'] = $ztdata;
  1653. $info_list[$key]['g'] = $g;
  1654. $info_list[$key]['x'] = $x;
  1655. $info_list[$key]['t'] = $t;
  1656. $info_list[$key]['z'] = $z;
  1657. }
  1658. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1659. $pagenum = ceil($total / $perpage);
  1660. $over = $total - ($start + $perpage);
  1661. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1662. echo json_encode($rows);
  1663. exit;
  1664. }
  1665. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1666. $this->data['warehouse'] = $warehouse;
  1667. $this->_Template('whlabel_typeusa', $this->data);
  1668. }
  1669. //美仓进销存浏览
  1670. public function _usatypeapp()
  1671. {
  1672. $post = $this->input->post(NULL, TRUE);
  1673. if (isset($post['page'])) {
  1674. $page = $this->input->post('page', true);
  1675. $perpage = $this->input->post('perpage', true);
  1676. $sku = $this->input->post('sku', true);
  1677. $warehouse = 5;
  1678. $title = $this->input->post('title', true);
  1679. $state = $this->input->post('state', true);
  1680. $ktime = $this->input->post('ktime', true);
  1681. $jtime = $this->input->post('jtime', true);
  1682. $ktime = strtotime($ktime);
  1683. $jtime = strtotime($jtime);
  1684. $where = "1=1";
  1685. $gj = "";
  1686. $ck = "";
  1687. if ($title) {
  1688. $st = explode(' ', trim($title, ' '));
  1689. foreach ($st as $v) {
  1690. $where .= " and title like '%$v%'";
  1691. }
  1692. }
  1693. if ($warehouse) {
  1694. $where .= " and warehouse = '$warehouse'";
  1695. }
  1696. if ($state) {
  1697. $where .= " and state = '$state'";
  1698. }
  1699. if ($sku) {
  1700. $where .= " and sku like '%$sku%'";
  1701. }
  1702. if ($ktime && $jtime) {
  1703. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1704. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1705. }
  1706. //数据排序
  1707. $order_str = "id desc";
  1708. if (empty($page)) {
  1709. $start = 0;
  1710. $perpage = 1;
  1711. } else {
  1712. $start = ($page - 1) * $perpage;
  1713. }
  1714. //取得信息列表
  1715. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1716. $rows = array();
  1717. $list = array();
  1718. foreach ($info_list as $key => $value) {
  1719. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1720. }
  1721. $rowsdq = array_slice($rows, $start, $perpage);
  1722. foreach ($rowsdq as $value) {
  1723. $warehouse = $this->warehouse->read($value['warehouse']);
  1724. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1725. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1726. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1727. $od = array();
  1728. $odid = '';
  1729. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1730. }
  1731. $total = count($rows);
  1732. $pagenum = ceil($total / $perpage);
  1733. $over = $total - ($start + $perpage);
  1734. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1735. echo json_encode($rows);
  1736. exit;
  1737. }
  1738. $this->_Template('phone/p_usatypeapp', $this->data);
  1739. }
  1740. //入库操作
  1741. public function _enteradd()
  1742. {
  1743. $dt = 0;
  1744. if (isset($_SESSION['api'])) {
  1745. $user = $this->user->get_api($_SESSION['api']);
  1746. $usp = $user;
  1747. $fgshop = "";
  1748. $sid = "";
  1749. $user = explode('|', trim($user['shop'], '|'));
  1750. foreach ($user as $value) {
  1751. $fgshop .= " shop = " . $value . " or";
  1752. $sid .= " id = " . $value . " or";
  1753. }
  1754. }
  1755. $tc = $this->typeclass->find_all();
  1756. $typeclass = array();
  1757. foreach ($tc as $v) {
  1758. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1759. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1760. }
  1761. $post = $this->input->post(NULL, TRUE);
  1762. if (isset($post['sku'])) {
  1763. $list = array();
  1764. $num = "";
  1765. $title = "";
  1766. $features = "";
  1767. $order = $this->input->post('order', true);
  1768. $shop = $this->input->post('shop', true);
  1769. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1770. $sku = $this->input->post('sku', true);
  1771. $post['sm'] = $this->input->post('sm', true);
  1772. $post['warehouse'] = $this->input->post('warehouse', true);
  1773. $post['purchase'] = $this->input->post('purchase', true);
  1774. $post['retreatwarehouse'] = $post['warehouse'];
  1775. $post['state'] = $this->input->post('state', true);
  1776. $post['rktype'] = $this->input->post('rktype', true);
  1777. $post['text'] = $this->input->post('text', true);
  1778. $category = $this->input->post('category', true);
  1779. $list['category'] = $category;
  1780. $list['hairtype'] = $this->input->post('hairtype', true);
  1781. $list['grade'] = $this->input->post('grade', true);
  1782. $size = $this->input->post('size', true);
  1783. $xzsku = $this->input->post('xzsku', true);
  1784. $list['size'] = rtrim($size, ',');
  1785. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1786. $list['extension'] = $this->input->post('extension', true);
  1787. if ($category == 1297) {
  1788. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1789. }
  1790. if ($category == 1702) {
  1791. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1792. $list['syother'] = $this->input->post('syother', true);
  1793. }
  1794. if ($category == 133) {
  1795. $list['fittype'] = $this->input->post('fittype', true);
  1796. $list['acother'] = $this->input->post('acother', true);
  1797. }
  1798. $list['color'] = $this->input->post('color', true);
  1799. $list['lowe'] = $this->input->post('lowe', true);
  1800. if (!$post['purchase']) {
  1801. $post['purchase'] = 1;
  1802. }
  1803. if ($category == 127) {
  1804. $list['type'] = $this->input->post('type', true);
  1805. $list['headroad'] = $this->input->post('headroad', true);
  1806. $list['density'] = $this->input->post('density', true);
  1807. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1808. $list['lacesize'] = $this->input->post('lacesize', true);
  1809. }
  1810. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1811. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1812. }
  1813. if ($category == 128) {
  1814. $list['lacetype'] = $this->input->post('lacetype', true);
  1815. $list['haircap'] = $this->input->post('haircap', true);
  1816. $list['density'] = $this->input->post('density', true);
  1817. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1818. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1819. $list['wigother'] = $this->input->post('wigother', true);
  1820. $list['wigother1'] = $this->input->post('wigother1', true);
  1821. $list['wigother2'] = $this->input->post('wigother2', true);
  1822. }
  1823. if ($category == 129) {
  1824. $list['wide'] = $this->input->post('wide', true);
  1825. }
  1826. if ($category == 131) {
  1827. $list['gifttype'] = $this->input->post('gifttype', true);
  1828. $list['giftother'] = $this->input->post('giftother', true);
  1829. }
  1830. if ($category == 134) {
  1831. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1832. }
  1833. if ($category == 1297) {
  1834. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1835. $list['sywigother'] = $this->input->post('sywigother', true);
  1836. }
  1837. if ($category == 130 || $category == 133 || $category == 1702) {
  1838. $list['items'] = $this->input->post('items', true);
  1839. $list['weight'] = $this->input->post('weight', true);
  1840. }
  1841. if ($category == 1702) {
  1842. $list['syhairther'] = $this->input->post('syhairther', true);
  1843. }
  1844. $classid = $this->classid->sku();
  1845. $scsku = $classid;
  1846. $pm = $classid;
  1847. foreach ($list as $k => $v) {
  1848. if ($v != 0) {
  1849. $num .= $v;
  1850. $features .= $v . '-';
  1851. $post[$k] = $v;
  1852. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1853. if ($k != 'size') {
  1854. $title .= $typeclass[$v]['title'] . " ";
  1855. }
  1856. if (isset($pm[$typeclass[$v]['classid']])) {
  1857. if ($typeclass[$v]['title'] == '9A') {
  1858. $pm[$typeclass[$v]['classid']] = '9A';
  1859. } else if ($typeclass[$v]['title'] == '10A') {
  1860. $pm[$typeclass[$v]['classid']] = '10A';
  1861. } else {
  1862. $clzh = $typeclass[$v]['zh'];
  1863. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1864. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1865. $clzh = $clzh[0];
  1866. }
  1867. $pm[$typeclass[$v]['classid']] = $clzh;
  1868. }
  1869. }
  1870. }
  1871. }
  1872. $zh = implode(" ", $pm);
  1873. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1874. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1875. if ($list['size']) {
  1876. $typeclass = $this->typeclass->read($list['size']);
  1877. $title .= $typeclass['title'];
  1878. }
  1879. $time = time();
  1880. if ($xzsku) {
  1881. $scsku = implode("-", $scsku);
  1882. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1883. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1884. $post['sku'] = trim($scsku, ' ');
  1885. } else {
  1886. $post['sku'] = $sku;
  1887. }
  1888. //$post['sku'] = trim($sku,' ');
  1889. $post['title'] = rtrim($title, ' ');
  1890. $post['number'] = $num;
  1891. $post['features'] = '-' . $features;
  1892. $post['enter'] = $time;
  1893. $post['time'] = $time; //操作时间
  1894. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1895. if ($yza) {
  1896. if ($post['features'] != $yza[0]['features']) {
  1897. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1898. exit;
  1899. }
  1900. }
  1901. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1902. if ($yzb) {
  1903. if ($post['sku'] != $yzb[0]['sku']) {
  1904. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1905. exit;
  1906. }
  1907. }
  1908. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1909. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1910. exit;
  1911. }
  1912. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1913. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1914. exit;
  1915. }
  1916. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1917. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1918. exit;
  1919. }
  1920. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1921. if (isset($yz[0]['type'])) {
  1922. $post['type'] = $yz[0]['type'];
  1923. }
  1924. if ($post['state'] == 9) //如果选择预设库存
  1925. {
  1926. $this->whlabel->insert($post);
  1927. } else {
  1928. /**
  1929. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1930. if($ljg == 1)
  1931. {
  1932. for($i=0;$i<$order;$i++)
  1933. {
  1934. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1935. $this->whlabel->insert($post);
  1936. }
  1937. }
  1938. **/
  1939. //if($post['warehouse'] == '5')
  1940. //{
  1941. //}
  1942. $yydata = $post;
  1943. $yydata['zh'] = $zh;
  1944. /**
  1945. $wl = $this->apiyy->get_cjlp($yydata);
  1946. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1947. {
  1948. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1949. }
  1950. if($wl['Data'][0]['m_isSucess'] != 1)
  1951. {
  1952. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1953. }
  1954. **/
  1955. for ($i = 0; $i < $order; $i++) {
  1956. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1957. $this->whlabel->insert($post);
  1958. }
  1959. }
  1960. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1961. exit;
  1962. }
  1963. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1964. $this->data['wlshop'] = $wlshop;
  1965. $this->_Template('whlabel_enteradd', $this->data);
  1966. }
  1967. //修改产品
  1968. public function _enteredit($arg_array)
  1969. {
  1970. $dt = 0;
  1971. if (isset($_SESSION['api'])) {
  1972. $user = $this->user->get_api($_SESSION['api']);
  1973. $usp = $user;
  1974. $fgshop = "";
  1975. $sid = "";
  1976. $user = explode('|', trim($user['shop'], '|'));
  1977. foreach ($user as $value) {
  1978. $fgshop .= " shop = " . $value . " or";
  1979. $sid .= " id = " . $value . " or";
  1980. }
  1981. }
  1982. $post = $this->input->post(NULL, TRUE);
  1983. if (isset($post['sku'])) {
  1984. $list = array();
  1985. $num = "";
  1986. $title = "";
  1987. $features = "";
  1988. $id = $this->input->post('id', true);
  1989. $order = $this->input->post('order', true);
  1990. $shop = $this->input->post('shop', true);
  1991. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1992. $post['sku'] = $this->input->post('sku', true);
  1993. $post['sm'] = $this->input->post('sm', true);
  1994. $post['warehouse'] = $this->input->post('warehouse', true);
  1995. $post['purchase'] = $this->input->post('purchase', true);
  1996. $post['retreatwarehouse'] = $post['warehouse'];
  1997. $category = $this->input->post('category', true);
  1998. $list['category'] = $category;
  1999. $list['hairtype'] = $this->input->post('hairtype', true);
  2000. $list['grade'] = $this->input->post('grade', true);
  2001. $size = $this->input->post('size', true);
  2002. $list['size'] = rtrim($size, ',');
  2003. $post['rktype'] = $this->input->post('rktype', true);
  2004. $post['text'] = $this->input->post('text', true);
  2005. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2006. $list['extension'] = $this->input->post('extension', true);
  2007. if ($category == 1297) {
  2008. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2009. }
  2010. if ($category == 1702) {
  2011. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2012. $list['syother'] = $this->input->post('syother', true);
  2013. }
  2014. if ($category == 133) {
  2015. $list['fittype'] = $this->input->post('fittype', true);
  2016. $list['acother'] = $this->input->post('acother', true);
  2017. }
  2018. $list['color'] = $this->input->post('color', true);
  2019. $list['lowe'] = $this->input->post('lowe', true);
  2020. if (!$post['purchase']) {
  2021. $post['purchase'] = 1;
  2022. }
  2023. if ($category == 127) {
  2024. $list['type'] = $this->input->post('type', true);
  2025. $list['headroad'] = $this->input->post('headroad', true);
  2026. $list['density'] = $this->input->post('density', true);
  2027. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2028. $list['lacesize'] = $this->input->post('lacesize', true);
  2029. }
  2030. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2031. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2032. }
  2033. if ($category == 128) {
  2034. $list['lacetype'] = $this->input->post('lacetype', true);
  2035. $list['haircap'] = $this->input->post('haircap', true);
  2036. $list['density'] = $this->input->post('density', true);
  2037. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2038. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2039. $list['wigother'] = $this->input->post('wigother', true);
  2040. $list['wigother1'] = $this->input->post('wigother1', true);
  2041. $list['wigother2'] = $this->input->post('wigother2', true);
  2042. }
  2043. if ($category == 129) {
  2044. $list['wide'] = $this->input->post('wide', true);
  2045. }
  2046. if ($category == 131) {
  2047. $list['gifttype'] = $this->input->post('gifttype', true);
  2048. $list['giftother'] = $this->input->post('giftother', true);
  2049. }
  2050. if ($category == 134) {
  2051. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2052. }
  2053. if ($category == 1297) {
  2054. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2055. $list['sywigother'] = $this->input->post('sywigother', true);
  2056. }
  2057. if ($category == 130 || $category == 133 || $category == 1702) {
  2058. $list['items'] = $this->input->post('items', true);
  2059. $list['weight'] = $this->input->post('weight', true);
  2060. }
  2061. if ($category == 1702) {
  2062. $list['syhairther'] = $this->input->post('syhairther', true);
  2063. }
  2064. foreach ($list as $k => $v) {
  2065. if ($v != 0) {
  2066. $num .= $v;
  2067. $features .= $v . '-';
  2068. $typeclass = $this->typeclass->read($v);
  2069. if ($k != 'size') {
  2070. $title .= $typeclass['title'] . " ";
  2071. }
  2072. }
  2073. }
  2074. $typeclass = $this->typeclass->read($list['size']);
  2075. $title .= $typeclass['title'];
  2076. $time = time();
  2077. $post['title'] = rtrim($title, ' ');
  2078. $post['number'] = $num;
  2079. $post['features'] = '-' . $features;
  2080. $post['time'] = $time; //操作时间
  2081. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2082. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2083. exit;
  2084. }
  2085. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2086. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2087. exit;
  2088. }
  2089. $uid = $this->whlabel->read($id);
  2090. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2091. if ($datanum > 0) {
  2092. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2093. exit;
  2094. }
  2095. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2096. {
  2097. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2098. if ($yza) {
  2099. if ($post['features'] != $yza[0]['features']) {
  2100. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2101. exit;
  2102. }
  2103. }
  2104. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2105. if ($yzb) {
  2106. if ($post['sku'] != $yzb[0]['sku']) {
  2107. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2108. exit;
  2109. }
  2110. }
  2111. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2112. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2113. exit;
  2114. }
  2115. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2116. foreach ($data as $v) {
  2117. $post['id'] = $v['id'];
  2118. $this->whlabel->save($post, $v['id']);
  2119. }
  2120. } else {
  2121. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2122. if ($data > 0) {
  2123. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2124. exit;
  2125. } else {
  2126. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2127. foreach ($data as $v) {
  2128. $post['id'] = $v['id'];
  2129. $this->whlabel->save($post, $v['id']);
  2130. }
  2131. }
  2132. }
  2133. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2134. exit;
  2135. }
  2136. $uid = $this->whlabel->read($arg_array[0]);
  2137. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2138. $this->data['enter'] = $uid;
  2139. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2140. $this->data['wlshop'] = $wlshop;
  2141. $this->_Template('whlabel_enteredit', $this->data);
  2142. }
  2143. //入库浏览
  2144. public function _enter()
  2145. {
  2146. $post = $this->input->post(NULL, TRUE);
  2147. if (isset($post['s'])) {
  2148. $id_arr = $this->input->post('s');
  2149. $id_arr = explode(',', $id_arr);
  2150. if (!$id_arr) {
  2151. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2152. exit;
  2153. }
  2154. //循环删除记录
  2155. foreach ($id_arr as $v) {
  2156. $sid = $this->whlabel->read($v);
  2157. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2158. if ($count > 0) {
  2159. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2160. exit;
  2161. }
  2162. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2163. foreach ($info_list as $va) {
  2164. $this->whlabel->remove($va['id']);
  2165. }
  2166. }
  2167. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2168. exit;
  2169. }
  2170. $sp = array();
  2171. $s = $this->shop->find_all('1=1', 'id,shopname');
  2172. foreach ($s as $v) {
  2173. $sp[$v['id']] = $v['shopname'];
  2174. }
  2175. $wh = array();
  2176. $w = $this->warehouse->find_all('1=1', 'id,title');
  2177. foreach ($w as $v) {
  2178. $wh[$v['id']] = $v['title'];
  2179. }
  2180. if (isset($post['page'])) {
  2181. $page = $this->input->post('page', true);
  2182. $perpage = $this->input->post('perpage', true);
  2183. $category = $this->input->post('category', true);
  2184. $size = $this->input->post('size', true);
  2185. $grade = $this->input->post('grade', true);
  2186. $color = $this->input->post('color', true);
  2187. $lowe = $this->input->post('lowe', true);
  2188. $sku = $this->input->post('sku', true);
  2189. $warehouse = $this->input->post('warehouse', true);
  2190. $purchase = $this->input->post('purchase', true);
  2191. $ktime = $this->input->post('ktime', true);
  2192. $jtime = $this->input->post('jtime', true);
  2193. $ktime = strtotime($ktime);
  2194. $jtime = strtotime($jtime);
  2195. $where = "1=1";
  2196. $gj = "";
  2197. $ck = "";
  2198. if ($category) {
  2199. $where .= " and features like '%-$category-%'";
  2200. }
  2201. if ($size) {
  2202. $where .= " and features like '%-$size-%'";
  2203. }
  2204. if ($grade) {
  2205. $where .= " and features like '%-$grade-%'";
  2206. }
  2207. if ($color) {
  2208. $where .= " and features like '%-$color-%'";
  2209. }
  2210. if ($lowe) {
  2211. $where .= " and features like '%-$lowe-%'";
  2212. }
  2213. if ($warehouse) {
  2214. $where .= " and warehouse = '$warehouse'";
  2215. }
  2216. if ($purchase) {
  2217. $where .= " and purchase = '$purchase'";
  2218. }
  2219. if ($sku) {
  2220. $where .= " and sku like '%$sku%'";
  2221. }
  2222. if ($ktime && $jtime) {
  2223. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2224. }
  2225. //数据排序
  2226. $order_str = "enter desc";
  2227. if (empty($page)) {
  2228. $start = 0;
  2229. $perpage = 1;
  2230. } else {
  2231. $start = ($page - 1) * $perpage;
  2232. }
  2233. //取得信息列表
  2234. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2235. foreach ($info_list as $k => $v) {
  2236. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2237. if ($v['shop'] == '') {
  2238. $s = '通用';
  2239. } else {
  2240. $info_list[$k]['shop'] = '';
  2241. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2242. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2243. }
  2244. }
  2245. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2246. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2247. $info_list[$k]['g'] = $g;
  2248. }
  2249. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2250. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2251. $pagenum = ceil($total / $perpage);
  2252. $over = $total - ($start + $perpage);
  2253. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2254. echo json_encode($rows);
  2255. exit;
  2256. }
  2257. $this->_Template('whlabel_enter', $this->data);
  2258. }
  2259. //出库浏览
  2260. public function _out()
  2261. {
  2262. $post = $this->input->post(NULL, TRUE);
  2263. if (isset($post['page'])) {
  2264. $page = $this->input->post('page', true);
  2265. $perpage = $this->input->post('perpage', true);
  2266. $category = $this->input->post('category', true);
  2267. $size = $this->input->post('size', true);
  2268. $grade = $this->input->post('grade', true);
  2269. $color = $this->input->post('color', true);
  2270. $lowe = $this->input->post('lowe', true);
  2271. $sku = $this->input->post('sku', true);
  2272. $warehouse = $this->input->post('warehouse', true);
  2273. $purchase = $this->input->post('purchase', true);
  2274. $state = $this->input->post('state', true);
  2275. $ktime = $this->input->post('ktime', true);
  2276. $jtime = $this->input->post('jtime', true);
  2277. $ktime = strtotime($ktime);
  2278. $jtime = strtotime($jtime);
  2279. $where = "state=3";
  2280. $gj = "";
  2281. $ck = "";
  2282. if ($category) {
  2283. $where .= " and features like '%-$category-%'";
  2284. }
  2285. if ($size) {
  2286. $where .= " and features like '%-$size-%'";
  2287. }
  2288. if ($grade) {
  2289. $where .= " and features like '%-$grade-%'";
  2290. }
  2291. if ($color) {
  2292. $where .= " and features like '%-$color-%'";
  2293. }
  2294. if ($lowe) {
  2295. $where .= " and features like '%-$lowe-%'";
  2296. }
  2297. if ($state) {
  2298. $where .= " and state = '$state'";
  2299. }
  2300. if ($warehouse) {
  2301. $where .= " and warehouse = '$warehouse'";
  2302. }
  2303. if ($purchase) {
  2304. $where .= " and purchase = '$purchase'";
  2305. }
  2306. if ($sku) {
  2307. $where .= " and sku = '$sku'";
  2308. }
  2309. if ($ktime && $jtime) {
  2310. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2311. }
  2312. //数据排序
  2313. $order_str = "id desc";
  2314. if (empty($page)) {
  2315. $start = 0;
  2316. $perpage = 1;
  2317. } else {
  2318. $start = ($page - 1) * $perpage;
  2319. }
  2320. //取得信息列表
  2321. $info_list = $this->whlabel->find_all($where, 'sku');
  2322. $rows = array();
  2323. $list = array();
  2324. foreach ($info_list as $key => $value) {
  2325. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2326. }
  2327. $rows = array_unique($rows); //删除重复记录
  2328. foreach ($rows as $key => $value) {
  2329. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2330. $ck = $this->warehouse->read($data['warehouse']);
  2331. $warehouse = $ck['title'];
  2332. $gy = $this->purchase->read($data['purchase']);
  2333. $purchase = $gy['purchase'];
  2334. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2335. $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);
  2336. }
  2337. $total = count($list);
  2338. $pagenum = ceil($total / $perpage);
  2339. $over = $total - ($start + $perpage);
  2340. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2341. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2342. echo json_encode($rows);
  2343. exit;
  2344. }
  2345. $this->_Template('whlabel_out', $this->data);
  2346. }
  2347. //出库标签浏览
  2348. public function _label()
  2349. {
  2350. $post = $this->input->post(NULL, TRUE);
  2351. if (isset($post['page'])) {
  2352. $page = $this->input->post('page', true);
  2353. $perpage = $this->input->post('perpage', true);
  2354. $sku = $this->input->post('sku', true);
  2355. $warehouse = $this->input->post('warehouse', true);
  2356. $purchase = $this->input->post('purchase', true);
  2357. $orderinfo = $this->input->post('orderinfo', true);
  2358. $waybill = $this->input->post('waybill', true);
  2359. $category = $this->input->post('category', true);
  2360. $size = $this->input->post('size', true);
  2361. $grade = $this->input->post('grade', true);
  2362. $color = $this->input->post('color', true);
  2363. $lowe = $this->input->post('lowe', true);
  2364. $where = "state=1";
  2365. if ($sku) {
  2366. $where .= " and sku = '$sku'";
  2367. }
  2368. if ($warehouse) {
  2369. $where .= " and warehouse = '$warehouse'";
  2370. }
  2371. if ($purchase) {
  2372. $where .= " and purchase = '$purchase'";
  2373. }
  2374. if ($orderinfo) {
  2375. $where .= " and orderinfo = '$orderinfo'";
  2376. }
  2377. if ($waybill) {
  2378. $where .= " and waybill = '$waybill'";
  2379. }
  2380. if ($category) {
  2381. $where .= " and features like '%-$category-%'";
  2382. }
  2383. if ($size) {
  2384. $where .= " and features like '%-$size-%'";
  2385. }
  2386. if ($grade) {
  2387. $where .= " and features like '%-$grade-%'";
  2388. }
  2389. if ($color) {
  2390. $where .= " and features like '%-$color-%'";
  2391. }
  2392. if ($lowe) {
  2393. $where .= " and features like '%-$lowe-%'";
  2394. }
  2395. //数据排序
  2396. $order_str = "outk desc";
  2397. if (empty($page)) {
  2398. $start = 0;
  2399. $perpage = 1;
  2400. } else {
  2401. $start = ($page - 1) * $perpage;
  2402. }
  2403. //取得信息列表
  2404. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2405. foreach ($info_list as $key => $value) {
  2406. $warehouse = $this->warehouse->read($value['warehouse']);
  2407. $info_list[$key]['warehouse'] = $warehouse['title'];
  2408. $purchase = $this->purchase->read($value['purchase']);
  2409. $info_list[$key]['purchase'] = $purchase['title'];
  2410. if ($value['outk'] != 0) {
  2411. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2412. } else {
  2413. $info_list[$key]['outk'] = "";
  2414. }
  2415. if ($value['orderinfo'] == 0) {
  2416. $info_list[$key]['orderinfo'] = "";
  2417. }
  2418. if ($value['waybill'] == 0) {
  2419. $info_list[$key]['waybill'] = "";
  2420. }
  2421. }
  2422. $total = $this->whlabel->find_count($where);
  2423. $pagenum = ceil($total / $perpage);
  2424. $over = $total - ($start + $perpage);
  2425. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2426. echo json_encode($rows);
  2427. exit;
  2428. }
  2429. $this->_Template('whlabel_label', $this->data);
  2430. }
  2431. //独立站出库订单
  2432. public function _outorder()
  2433. {
  2434. if (isset($_SESSION['api'])) {
  2435. $user = $this->user->get_api($_SESSION['api']);
  2436. $usp = $user;
  2437. $fgshop = "";
  2438. $sid = "";
  2439. $user = explode('|', trim($user['shop'], '|'));
  2440. foreach ($user as $value) {
  2441. $fgshop .= " shop = " . $value . " or";
  2442. $sid .= " id = " . $value . " or";
  2443. }
  2444. } else {
  2445. echo "请重新登录";
  2446. }
  2447. $post = $this->input->post(NULL, TRUE);
  2448. if (isset($post['page'])) {
  2449. $page = $this->input->post('page', true);
  2450. $perpage = $this->input->post('perpage', true);
  2451. $warehouse = $this->input->post('warehouse', true);
  2452. $xztime = $this->input->post('xztime', true);
  2453. $timetk = $this->input->post('timetkk', true);
  2454. $timetj = $this->input->post('timetjj', true);
  2455. $shop = $this->input->post('shop', true);
  2456. $source = $this->input->post('source', true);
  2457. $orderinfo = $this->input->post('orderinfo', true);
  2458. $number = $this->input->post('number', true);
  2459. $sfxh = $this->input->post('sfxh', true);
  2460. $express = $this->input->post('express', true);
  2461. $waybill = $this->input->post('waybill', true);
  2462. $library = $this->input->post('library', true);
  2463. $country = $this->input->post('country', true);
  2464. $so = $this->input->post('so', true);
  2465. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2466. $print = $this->input->post('print', true);
  2467. $state = $this->input->post('state', true);
  2468. $orderurl = $this->input->post('orderurl', true);
  2469. $productid = $this->input->post('productid', true);
  2470. $timetk = strtotime($timetk);
  2471. $timetj = strtotime($timetj);
  2472. /**
  2473. $sj = $this->input->post('sj',true);
  2474. if($sj)
  2475. {
  2476. $sj = $this->input->post('sj',true);
  2477. }
  2478. else
  2479. {
  2480. $sj = "fullorder";
  2481. }
  2482. **/
  2483. $sj = "fullorder";
  2484. $where = "1=1";
  2485. if ($warehouse) {
  2486. $where .= " and type = '$warehouse'";
  2487. }
  2488. if ($timetk && $timetj) {
  2489. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2490. }
  2491. if ($orderinfo) {
  2492. $where .= " and orderinfo = '$orderinfo'";
  2493. }
  2494. if ($number) {
  2495. $where .= " and number = '$number'";
  2496. }
  2497. if ($express) {
  2498. $where .= " and express = '$express'";
  2499. }
  2500. if ($waybill) {
  2501. $where .= " and waybill = '$waybill'";
  2502. }
  2503. if ($library) {
  2504. $where .= " and library = '$library'";
  2505. }
  2506. if ($print) {
  2507. $where .= " and print = '$print'";
  2508. }
  2509. if ($libraryconfirm) {
  2510. $where .= " and libraryconfirm = '$libraryconfirm'";
  2511. }
  2512. if ($state) {
  2513. $where .= " and state = '$state'";
  2514. }
  2515. if ($shop) {
  2516. $where .= " and shop = '$shop'";
  2517. }
  2518. if ($country) {
  2519. $where .= " and country = '$country'";
  2520. }
  2521. if ($sfxh != '') {
  2522. $where .= " and sfxh = '$sfxh'";
  2523. }
  2524. if ($so) {
  2525. $where .= " and shipremarks like '%$so%'";
  2526. }
  2527. if ($source) {
  2528. if ($source == '2d') {
  2529. $where .= " and source >= '2'";
  2530. } else {
  2531. $where .= " and source = '$source'";
  2532. }
  2533. }
  2534. if (isset($_SESSION['api'])) {
  2535. foreach ($user as $value) {
  2536. $fgshop .= " shop = " . $value . " or";
  2537. }
  2538. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2539. }
  2540. if ($orderurl) {
  2541. $url = $this->orderurl->read($orderurl);
  2542. $where .= " and link like '%" . $url['url'] . "%'";
  2543. }
  2544. if($productid){
  2545. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2546. }
  2547. //数据排序
  2548. $order_str = "librarytime desc";
  2549. if (empty($page)) {
  2550. $start = 0;
  2551. $perpage = 1;
  2552. } else {
  2553. $start = ($page - 1) * $perpage;
  2554. }
  2555. //取得信息列表
  2556. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2557. //格式化数据
  2558. foreach ($info_list as $key => $value) {
  2559. $shop = $this->shop->read($value['shop']);
  2560. $info_list[$key]['shop'] = $shop['shopname'];
  2561. $express = $this->express->read($value['express']);
  2562. $info_list[$key]['express'] = $express['servicename'];
  2563. $warehouse = $this->warehouse->read($value['type']);
  2564. $info_list[$key]['type'] = $warehouse['title'];
  2565. if ($value['librarytime'] == '0') {
  2566. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2567. } else {
  2568. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2569. }
  2570. }
  2571. $total = $this->$sj->find_count($where);
  2572. $pagenum = ceil($total / $perpage);
  2573. $over = $total - ($start + $perpage);
  2574. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2575. echo json_encode($rows);
  2576. exit;
  2577. }
  2578. $this->data['express'] = $this->express->find_all();
  2579. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2580. $this->data['wlshop'] = $wlshop;
  2581. $user = $this->user->get_api($_SESSION['api']);
  2582. $powerid = $this->power->read($user['power']);
  2583. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2584. $pid = '';
  2585. foreach ($powertext as $v) {
  2586. $pid .= " id = " . $v . " or";
  2587. }
  2588. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2589. $this->data['fullorderexcel'] = $fullorderexcel;
  2590. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2591. $this->data['orderurl'] = $orderurl;
  2592. $this->_Template('whlabel_outorder', $this->data);
  2593. }
  2594. //tt出库
  2595. public function _toutorder()
  2596. {
  2597. $fgshop = "";
  2598. $sid = "";
  2599. if (isset($_SESSION['api'])) {
  2600. $user = $this->user->get_api($_SESSION['api']);
  2601. $usp = $user;
  2602. $user = explode('|', trim($user['shop'], '|'));
  2603. foreach ($user as $value) {
  2604. $fgshop .= " shop = " . $value . " or";
  2605. $sid .= " id = " . $value . " or";
  2606. }
  2607. } else {
  2608. echo "请重新登录";
  2609. die;
  2610. }
  2611. $post = $this->input->post(NULL, TRUE);
  2612. if (isset($post['page'])) {
  2613. $page = $this->input->post('page', true);
  2614. $perpage = $this->input->post('perpage', true);
  2615. $warehouse = $this->input->post('warehouse', true);
  2616. $xztime = $this->input->post('xztime', true);
  2617. $timetk = $this->input->post('timetkk', true);
  2618. $timetj = $this->input->post('timetjj', true);
  2619. $shop = $this->input->post('shop', true);
  2620. $source = $this->input->post('source', true);
  2621. $orderinfo = $this->input->post('orderinfo', true);
  2622. $number = $this->input->post('number', true);
  2623. $sfxh = $this->input->post('sfxh', true);
  2624. $express = $this->input->post('express', true);
  2625. $waybill = $this->input->post('waybill', true);
  2626. $library = $this->input->post('library', true);
  2627. $country = $this->input->post('country', true);
  2628. $so = $this->input->post('so', true);
  2629. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2630. $print = $this->input->post('print', true);
  2631. $state = $this->input->post('state', true);
  2632. $orderurl = $this->input->post('orderurl', true);
  2633. $timetk = strtotime($timetk);
  2634. $timetj = strtotime($timetj);
  2635. /**
  2636. $sj = $this->input->post('sj',true);
  2637. if($sj)
  2638. {
  2639. $sj = $this->input->post('sj',true);
  2640. }
  2641. else
  2642. {
  2643. $sj = "fullorder";
  2644. }
  2645. **/
  2646. $sj = "fullordertt";
  2647. $where = "1=1";
  2648. if ($warehouse) {
  2649. $where .= " and type = '$warehouse'";
  2650. }
  2651. if ($timetk && $timetj) {
  2652. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2653. }
  2654. if ($orderinfo) {
  2655. $where .= " and orderinfo = '$orderinfo'";
  2656. }
  2657. if ($number) {
  2658. $where .= " and number = '$number'";
  2659. }
  2660. if ($express) {
  2661. $where .= " and express = '$express'";
  2662. }
  2663. if ($waybill) {
  2664. $where .= " and waybill = '$waybill'";
  2665. }
  2666. if ($library) {
  2667. $where .= " and library = '$library'";
  2668. }
  2669. if ($print) {
  2670. $where .= " and print = '$print'";
  2671. }
  2672. if ($libraryconfirm) {
  2673. $where .= " and libraryconfirm = '$libraryconfirm'";
  2674. }
  2675. if ($state) {
  2676. $where .= " and state = '$state'";
  2677. }
  2678. if ($shop) {
  2679. $where .= " and shop = '$shop'";
  2680. }
  2681. if ($country) {
  2682. $where .= " and country = '$country'";
  2683. }
  2684. if ($sfxh != '') {
  2685. $where .= " and sfxh = '$sfxh'";
  2686. }
  2687. if ($so) {
  2688. $where .= " and shipremarks like '%$so%'";
  2689. }
  2690. if ($source) {
  2691. if ($source == '2d') {
  2692. $where .= " and source >= '2'";
  2693. } else {
  2694. $where .= " and source = '$source'";
  2695. }
  2696. }
  2697. if (isset($_SESSION['api'])) {
  2698. foreach ($user as $value) {
  2699. $fgshop .= " shop = " . $value . " or";
  2700. }
  2701. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2702. }
  2703. if ($orderurl) {
  2704. $url = $this->orderurl->read($orderurl);
  2705. $where .= " and link like '%" . $url['url'] . "%'";
  2706. }
  2707. //数据排序
  2708. $order_str = "librarytime desc";
  2709. if (empty($page)) {
  2710. $start = 0;
  2711. $perpage = 1;
  2712. } else {
  2713. $start = ($page - 1) * $perpage;
  2714. }
  2715. //取得信息列表
  2716. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2717. //格式化数据
  2718. foreach ($info_list as $key => $value) {
  2719. $shop = $this->shop->read($value['shop']);
  2720. $info_list[$key]['shop'] = $shop['shopname'];
  2721. $express = $this->express->read($value['express']);
  2722. $info_list[$key]['express'] = $express['servicename'];
  2723. $warehouse = $this->warehouse->read($value['type']);
  2724. $info_list[$key]['type'] = $warehouse['title'];
  2725. if ($value['librarytime'] == '0') {
  2726. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2727. } else {
  2728. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2729. }
  2730. }
  2731. $total = $this->$sj->find_count($where);
  2732. $pagenum = ceil($total / $perpage);
  2733. $over = $total - ($start + $perpage);
  2734. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2735. echo json_encode($rows);
  2736. exit;
  2737. }
  2738. $this->data['express'] = $this->express->find_all();
  2739. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2740. $this->data['wlshop'] = $wlshop;
  2741. $user = $this->user->get_api($_SESSION['api']);
  2742. $powerid = $this->power->read($user['power']);
  2743. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2744. $pid = '';
  2745. foreach ($powertext as $v) {
  2746. $pid .= " id = " . $v . " or";
  2747. }
  2748. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2749. $this->data['fullorderexcel'] = $fullorderexcel;
  2750. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2751. $this->data['orderurl'] = $orderurl;
  2752. $this->_Template('whlabel_toutorder', $this->data);
  2753. }
  2754. //tt出库
  2755. public function _aoutorder()
  2756. {
  2757. if (isset($_SESSION['api'])) {
  2758. $user = $this->user->get_api($_SESSION['api']);
  2759. $usp = $user;
  2760. $fgshop = "";
  2761. $sid = "";
  2762. $user = explode('|', trim($user['shop'], '|'));
  2763. foreach ($user as $value) {
  2764. $fgshop .= " shop = " . $value . " or";
  2765. $sid .= " id = " . $value . " or";
  2766. }
  2767. } else {
  2768. echo "请重新登录";
  2769. }
  2770. $post = $this->input->post(NULL, TRUE);
  2771. if (isset($post['page'])) {
  2772. $page = $this->input->post('page', true);
  2773. $perpage = $this->input->post('perpage', true);
  2774. $warehouse = $this->input->post('warehouse', true);
  2775. $xztime = $this->input->post('xztime', true);
  2776. $timetk = $this->input->post('timetkk', true);
  2777. $timetj = $this->input->post('timetjj', true);
  2778. $shop = $this->input->post('shop', true);
  2779. $source = $this->input->post('source', true);
  2780. $orderinfo = $this->input->post('orderinfo', true);
  2781. $number = $this->input->post('number', true);
  2782. $sfxh = $this->input->post('sfxh', true);
  2783. $express = $this->input->post('express', true);
  2784. $waybill = $this->input->post('waybill', true);
  2785. $library = $this->input->post('library', true);
  2786. $country = $this->input->post('country', true);
  2787. $so = $this->input->post('so', true);
  2788. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2789. $print = $this->input->post('print', true);
  2790. $state = $this->input->post('state', true);
  2791. $orderurl = $this->input->post('orderurl', true);
  2792. $timetk = strtotime($timetk);
  2793. $timetj = strtotime($timetj);
  2794. /**
  2795. $sj = $this->input->post('sj',true);
  2796. if($sj)
  2797. {
  2798. $sj = $this->input->post('sj',true);
  2799. }
  2800. else
  2801. {
  2802. $sj = "fullorder";
  2803. }
  2804. **/
  2805. $sj = "fullorderamz";
  2806. $where = "1=1";
  2807. if ($warehouse) {
  2808. $where .= " and type = '$warehouse'";
  2809. }
  2810. if ($timetk && $timetj) {
  2811. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2812. }
  2813. if ($orderinfo) {
  2814. $where .= " and orderinfo = '$orderinfo'";
  2815. }
  2816. if ($number) {
  2817. $where .= " and number = '$number'";
  2818. }
  2819. if ($express) {
  2820. $where .= " and express = '$express'";
  2821. }
  2822. if ($waybill) {
  2823. $where .= " and waybill = '$waybill'";
  2824. }
  2825. if ($library) {
  2826. $where .= " and library = '$library'";
  2827. }
  2828. if ($print) {
  2829. $where .= " and print = '$print'";
  2830. }
  2831. if ($libraryconfirm) {
  2832. $where .= " and libraryconfirm = '$libraryconfirm'";
  2833. }
  2834. if ($state) {
  2835. $where .= " and state = '$state'";
  2836. }
  2837. if ($shop) {
  2838. $where .= " and shop = '$shop'";
  2839. }
  2840. if ($country) {
  2841. $where .= " and country = '$country'";
  2842. }
  2843. if ($sfxh != '') {
  2844. $where .= " and sfxh = '$sfxh'";
  2845. }
  2846. if ($so) {
  2847. $where .= " and shipremarks like '%$so%'";
  2848. }
  2849. if ($source) {
  2850. if ($source == '2d') {
  2851. $where .= " and source >= '2'";
  2852. } else {
  2853. $where .= " and source = '$source'";
  2854. }
  2855. }
  2856. if (isset($_SESSION['api'])) {
  2857. foreach ($user as $value) {
  2858. $fgshop .= " shop = " . $value . " or";
  2859. }
  2860. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2861. }
  2862. if ($orderurl) {
  2863. $url = $this->orderurl->read($orderurl);
  2864. $where .= " and link like '%" . $url['url'] . "%'";
  2865. }
  2866. //数据排序
  2867. $order_str = "librarytime desc";
  2868. if (empty($page)) {
  2869. $start = 0;
  2870. $perpage = 1;
  2871. } else {
  2872. $start = ($page - 1) * $perpage;
  2873. }
  2874. //取得信息列表
  2875. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2876. //格式化数据
  2877. foreach ($info_list as $key => $value) {
  2878. $shop = $this->shop->read($value['shop']);
  2879. $info_list[$key]['shop'] = $shop['shopname'];
  2880. $express = $this->express->read($value['express']);
  2881. $info_list[$key]['express'] = $express['servicename'];
  2882. $warehouse = $this->warehouse->read($value['type']);
  2883. $info_list[$key]['type'] = $warehouse['title'];
  2884. if ($value['librarytime'] == '0') {
  2885. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2886. } else {
  2887. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2888. }
  2889. }
  2890. $total = $this->$sj->find_count($where);
  2891. $pagenum = ceil($total / $perpage);
  2892. $over = $total - ($start + $perpage);
  2893. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2894. echo json_encode($rows);
  2895. exit;
  2896. }
  2897. $this->data['express'] = $this->express->find_all();
  2898. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2899. $this->data['wlshop'] = $wlshop;
  2900. $user = $this->user->get_api($_SESSION['api']);
  2901. $powerid = $this->power->read($user['power']);
  2902. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2903. $pid = '';
  2904. foreach ($powertext as $v) {
  2905. $pid .= " id = " . $v . " or";
  2906. }
  2907. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2908. $this->data['fullorderexcel'] = $fullorderexcel;
  2909. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2910. $this->data['orderurl'] = $orderurl;
  2911. $this->_Template('whlabel_aoutorder', $this->data);
  2912. }
  2913. //速卖通出库订单
  2914. public function _soutorder()
  2915. {
  2916. if (isset($_SESSION['api'])) {
  2917. $user = $this->user->get_api($_SESSION['api']);
  2918. $usp = $user;
  2919. $fgshop = "";
  2920. $sid = "";
  2921. $user = explode('|', trim($user['shop'], '|'));
  2922. foreach ($user as $value) {
  2923. $sid .= " id = " . $value . " or";
  2924. }
  2925. }
  2926. $post = $this->input->post(NULL, TRUE);
  2927. if (isset($post['page'])) {
  2928. $page = $this->input->post('page', true);
  2929. $perpage = $this->input->post('perpage', true);
  2930. $warehouse = $this->input->post('warehouse', true);
  2931. $xztime = $this->input->post('xztime', true);
  2932. $timetk = $this->input->post('timetkk', true);
  2933. $timetj = $this->input->post('timetjj', true);
  2934. $shop = $this->input->post('shop', true);
  2935. $source = $this->input->post('source', true);
  2936. $orderinfo = $this->input->post('orderinfo', true);
  2937. $number = $this->input->post('number', true);
  2938. $express = $this->input->post('express', true);
  2939. $waybill = $this->input->post('waybill', true);
  2940. $library = $this->input->post('library', true);
  2941. $country = $this->input->post('country', true);
  2942. $sfxh = $this->input->post('sfxh', true);
  2943. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2944. $print = $this->input->post('print', true);
  2945. $state = $this->input->post('state', true);
  2946. $so = $this->input->post('so', true);
  2947. $timetk = strtotime($timetk);
  2948. $timetj = strtotime($timetj);
  2949. /**
  2950. $sj = $this->input->post('sj',true);
  2951. if($sj)
  2952. {
  2953. $sj = $this->input->post('sj',true);
  2954. }
  2955. else
  2956. {
  2957. $sj = "fullorder";
  2958. }
  2959. **/
  2960. $sj = "fullordersmt";
  2961. $where = "1=1";
  2962. if ($warehouse) {
  2963. $where .= " and type = '$warehouse'";
  2964. }
  2965. if ($timetk && $timetj) {
  2966. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2967. }
  2968. if ($orderinfo) {
  2969. $where .= " and orderinfo = '$orderinfo'";
  2970. }
  2971. if ($number) {
  2972. $where .= " and number = '$number'";
  2973. }
  2974. if ($express) {
  2975. $where .= " and express = '$express'";
  2976. }
  2977. if ($waybill) {
  2978. $where .= " and waybill = '$waybill'";
  2979. }
  2980. if ($library) {
  2981. $where .= " and library = '$library'";
  2982. }
  2983. if ($print) {
  2984. $where .= " and print = '$print'";
  2985. }
  2986. if ($libraryconfirm) {
  2987. $where .= " and libraryconfirm = '$libraryconfirm'";
  2988. }
  2989. if ($state) {
  2990. $where .= " and state = '$state'";
  2991. }
  2992. if ($shop) {
  2993. $where .= " and shop = '$shop'";
  2994. }
  2995. if ($sfxh != '') {
  2996. $where .= " and sfxh = '$sfxh'";
  2997. }
  2998. if ($so) {
  2999. $where .= " and shipremarks like '%$so%'";
  3000. }
  3001. if ($source) {
  3002. $where .= " and source = '$source'";
  3003. }
  3004. if ($country) {
  3005. $where .= " and country = '$country'";
  3006. } else {
  3007. if (isset($_SESSION['api'])) {
  3008. foreach ($user as $value) {
  3009. $fgshop .= " shop = " . $value . " or";
  3010. }
  3011. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3012. }
  3013. }
  3014. //数据排序
  3015. $order_str = "librarytime desc";
  3016. if (empty($page)) {
  3017. $start = 0;
  3018. $perpage = 1;
  3019. } else {
  3020. $start = ($page - 1) * $perpage;
  3021. }
  3022. //取得信息列表
  3023. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3024. //格式化数据
  3025. foreach ($info_list as $key => $value) {
  3026. $shop = $this->shop->read($value['shop']);
  3027. $info_list[$key]['shop'] = $shop['shopname'];
  3028. $express = $this->express->read($value['express']);
  3029. $info_list[$key]['express'] = $express['servicename'];
  3030. $warehouse = $this->warehouse->read($value['type']);
  3031. $info_list[$key]['type'] = $warehouse['title'];
  3032. if ($value['librarytime'] == '0') {
  3033. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3034. } else {
  3035. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3036. }
  3037. }
  3038. $total = $this->$sj->find_count($where);
  3039. $pagenum = ceil($total / $perpage);
  3040. $over = $total - ($start + $perpage);
  3041. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3042. echo json_encode($rows);
  3043. exit;
  3044. }
  3045. $this->data['express'] = $this->express->find_all();
  3046. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3047. $this->data['wlshop'] = $wlshop;
  3048. $user = $this->user->get_api($_SESSION['api']);
  3049. $powerid = $this->power->read($user['power']);
  3050. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3051. $pid = '';
  3052. foreach ($powertext as $v) {
  3053. $pid .= " id = " . $v . " or";
  3054. }
  3055. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3056. $this->data['fullorderexcel'] = $fullorderexcel;
  3057. $this->_Template('whlabel_soutorder', $this->data);
  3058. }
  3059. //订单退库
  3060. public function _retreat()
  3061. {
  3062. $post = $this->input->post(NULL, TRUE);
  3063. if (isset($post['page'])) {
  3064. $page = $this->input->post('page', true);
  3065. $perpage = $this->input->post('perpage', true);
  3066. $warehouse = $this->input->post('warehouse', true);
  3067. $timetk = $this->input->post('timetk', true);
  3068. $timetj = $this->input->post('timetj', true);
  3069. $shop = $this->input->post('shop', true);
  3070. $source = $this->input->post('source', true);
  3071. $state = $this->input->post('state', true);
  3072. $review = $this->input->post('review', true);
  3073. $state = $this->input->post('state', true);
  3074. $express = $this->input->post('express', true);
  3075. $orderinfo = $this->input->post('orderinfo', true);
  3076. $user = $this->input->post('user', true);
  3077. $name = $this->input->post('name', true);
  3078. $waybill = $this->input->post('waybill', true);
  3079. $timetk = strtotime($timetk);
  3080. $timetj = strtotime($timetj);
  3081. $where = "(state=206 or state=210) and mergeid = 0";
  3082. if ($warehouse) {
  3083. $where .= " and state = '$warehouse'";
  3084. }
  3085. if ($timetk && $timetj) {
  3086. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3087. }
  3088. if ($shop) {
  3089. $where .= " and shop = '$shop'";
  3090. }
  3091. if ($source) {
  3092. $where .= " and source = '$source'";
  3093. }
  3094. if ($state) {
  3095. $where .= " and state = '$state'";
  3096. }
  3097. if ($review) {
  3098. $where .= " and review = '$review'";
  3099. }
  3100. if ($state) {
  3101. $where .= " and state = '$state'";
  3102. }
  3103. if ($express) {
  3104. $where .= " and express = '$express'";
  3105. }
  3106. if ($orderinfo) {
  3107. $where .= " and orderinfo = '$orderinfo'";
  3108. }
  3109. if ($user) {
  3110. $where .= " and user = '$user'";
  3111. }
  3112. if ($name) {
  3113. $where .= " and name = '$name'";
  3114. }
  3115. if ($waybill) {
  3116. $where .= " and waybill = '$waybill'";
  3117. }
  3118. //数据排序
  3119. $order_str = "id desc";
  3120. if (empty($page)) {
  3121. $start = 0;
  3122. $perpage = 1;
  3123. } else {
  3124. $start = ($page - 1) * $perpage;
  3125. }
  3126. //取得信息列表
  3127. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3128. //格式化数据
  3129. foreach ($info_list as $key => $value) {
  3130. $shop = $this->shop->read($value['shop']);
  3131. $info_list[$key]['shop'] = $shop['shopname'];
  3132. $warehouse = $this->warehouse->read($value['warehouse']);
  3133. $info_list[$key]['warehouse'] = $warehouse['title'];
  3134. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3135. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3136. if ($value['waybill'] == 0) {
  3137. $info_list[$key]['waybill'] = "";
  3138. }
  3139. $express = $this->express->read($value['express']);
  3140. $info_list[$key]['express'] = $express['title'];
  3141. $typeclass = $this->typeclass->read($value['state']);
  3142. $info_list[$key]['state'] = $typeclass['title'];
  3143. }
  3144. $total = $this->fullorder->find_count($where);
  3145. $pagenum = ceil($total / $perpage);
  3146. $over = $total - ($start + $perpage);
  3147. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3148. echo json_encode($rows);
  3149. exit;
  3150. }
  3151. $this->data['express'] = $this->express->find_all();
  3152. $this->_Template('whlabel_retreat', $this->data);
  3153. }
  3154. //退库标签浏览
  3155. public function _retreatlk()
  3156. {
  3157. $post = $this->input->post(NULL, TRUE);
  3158. if (isset($post['page'])) {
  3159. $page = $this->input->post('page', true);
  3160. $perpage = $this->input->post('perpage', true);
  3161. $timetk = $this->input->post('timetk', true);
  3162. $timetj = $this->input->post('timetj', true);
  3163. $sku = $this->input->post('sku', true);
  3164. $warehouse = $this->input->post('warehouse', true);
  3165. $purchase = $this->input->post('purchase', true);
  3166. $orderinfo = $this->input->post('orderinfo', true);
  3167. $waybill = $this->input->post('waybill', true);
  3168. $category = $this->input->post('category', true);
  3169. $size = $this->input->post('size', true);
  3170. $grade = $this->input->post('grade', true);
  3171. $color = $this->input->post('color', true);
  3172. $lowe = $this->input->post('lowe', true);
  3173. $state = $this->input->post('state', true);
  3174. $timetk = strtotime($timetk);
  3175. $timetj = strtotime($timetj);
  3176. $where = "state=2";
  3177. if ($timetk && $timetj) {
  3178. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3179. }
  3180. if ($sku) {
  3181. $where .= " and sku = '$sku'";
  3182. }
  3183. if ($warehouse) {
  3184. $where .= " and warehouse = '$warehouse'";
  3185. }
  3186. if ($purchase) {
  3187. $where .= " and purchase = '$purchase'";
  3188. }
  3189. if ($orderinfo) {
  3190. $where .= " and orderinfo = '$orderinfo'";
  3191. }
  3192. if ($waybill) {
  3193. $where .= " and waybill = '$waybill'";
  3194. }
  3195. if ($category) {
  3196. $where .= " and features like '%-$category-%'";
  3197. }
  3198. if ($size) {
  3199. $where .= " and features like '%-$size-%'";
  3200. }
  3201. if ($grade) {
  3202. $where .= " and features like '%-$grade-%'";
  3203. }
  3204. if ($color) {
  3205. $where .= " and features like '%-$color-%'";
  3206. }
  3207. if ($lowe) {
  3208. $where .= " and features like '%-$lowe-%'";
  3209. }
  3210. //数据排序
  3211. $order_str = "time desc";
  3212. if (empty($page)) {
  3213. $start = 0;
  3214. $perpage = 1;
  3215. } else {
  3216. $start = ($page - 1) * $perpage;
  3217. }
  3218. //取得信息列表
  3219. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3220. foreach ($info_list as $key => $value) {
  3221. $warehouse = $this->warehouse->read($value['warehouse']);
  3222. $info_list[$key]['warehouse'] = $warehouse['title'];
  3223. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3224. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3225. $purchase = $this->purchase->read($value['purchase']);
  3226. $info_list[$key]['purchase'] = $purchase['title'];
  3227. if ($value['outk'] != 0) {
  3228. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3229. } else {
  3230. $info_list[$key]['outk'] = "";
  3231. }
  3232. if ($value['retreat'] != 0) {
  3233. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3234. } else {
  3235. $info_list[$key]['retreat'] = "";
  3236. }
  3237. if ($value['orderinfo'] == 0) {
  3238. $info_list[$key]['orderinfo'] = "";
  3239. }
  3240. if ($value['waybill'] == 0) {
  3241. $info_list[$key]['waybill'] = "";
  3242. }
  3243. }
  3244. $total = $this->whlabel->find_count($where);
  3245. $pagenum = ceil($total / $perpage);
  3246. $over = $total - ($start + $perpage);
  3247. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3248. echo json_encode($rows);
  3249. exit;
  3250. }
  3251. $this->_Template('whlabel_retreatlk', $this->data);
  3252. }
  3253. //更换标签及浏览
  3254. public function _change()
  3255. {
  3256. $post = $this->input->post(NULL, TRUE);
  3257. if (isset($post['page'])) {
  3258. $page = $this->input->post('page', true);
  3259. $perpage = $this->input->post('perpage', true);
  3260. $timetk = $this->input->post('timetk', true);
  3261. $timetj = $this->input->post('timetj', true);
  3262. $label = $this->input->post('label', true);
  3263. $oldlabel = $this->input->post('oldlabel', true);
  3264. $timetk = strtotime($timetk);
  3265. $timetj = strtotime($timetj);
  3266. $where = "state=10 ";
  3267. if ($timetk && $timetj) {
  3268. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3269. }
  3270. if ($label) {
  3271. $where .= " and label = '$label'";
  3272. }
  3273. if ($oldlabel) {
  3274. $where .= " and oldlabel = '$oldlabel'";
  3275. }
  3276. //数据排序
  3277. $order_str = "time asc";
  3278. if (empty($page)) {
  3279. $start = 0;
  3280. $perpage = 1;
  3281. } else {
  3282. $start = ($page - 1) * $perpage;
  3283. }
  3284. //取得信息列表
  3285. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3286. foreach ($info_list as $key => $value) {
  3287. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3288. }
  3289. $total = $this->whlabel->find_count($where);
  3290. $pagenum = ceil($total / $perpage);
  3291. $over = $total - ($start + $perpage);
  3292. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3293. echo json_encode($rows);
  3294. exit;
  3295. }
  3296. $this->_Template('whlabel_change', $this->data);
  3297. }
  3298. //产品标签
  3299. public function _cpbqdc()
  3300. {
  3301. if (isset($_GET['excel'])) {
  3302. $where = "1=1";
  3303. //数据排序
  3304. $order_str = "id desc";
  3305. if (empty($page)) {
  3306. $start = 0;
  3307. $perpage = 1;
  3308. } else {
  3309. $start = ($page - 1) * $perpage;
  3310. }
  3311. $warehouse = $this->input->get('warehouse', true);
  3312. $state = $this->input->get('state', true);
  3313. $timetk = $this->input->get('timetkk', true);
  3314. $timetj = $this->input->get('timetjj', true);
  3315. $timetk = strtotime($timetk);
  3316. $timetj = strtotime($timetj);
  3317. if ($warehouse) {
  3318. $where .= " and warehouse = '$warehouse'";
  3319. }
  3320. if ($state || $state == 0) {
  3321. $where .= " and state = '$state'";
  3322. }
  3323. if ($timetk && $timetj) {
  3324. $where .= " and time > '$timetk' and time < '$timetj'";
  3325. }
  3326. //取得信息列表
  3327. $info_list = $this->whlabel->find_all($where, '*');
  3328. $rows = array();
  3329. $list = array();
  3330. foreach ($info_list as $key => $value) {
  3331. $rows[$value['time']] = $value; //所有数据sku
  3332. }
  3333. foreach ($rows as $value) {
  3334. $warehouse = $this->warehouse->read($value['warehouse']);
  3335. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3336. $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);
  3337. }
  3338. $title = "产品标签统计表";
  3339. $titlename = "<table border=1>
  3340. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3341. <tr align='center'>
  3342. <td>仓库</td>
  3343. <td>SKU</td>
  3344. <td>产品</td>
  3345. <td>入库时间</td>
  3346. <td>操作时间</td>
  3347. <td>备注</td>
  3348. <td>数量</td>
  3349. </tr>
  3350. </table>";
  3351. $filename = $title . ".xls";
  3352. $tail = "";
  3353. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3354. }
  3355. }
  3356. //进销存导出
  3357. public function _exceljxc()
  3358. {
  3359. $classid = $this->classid->sku();
  3360. $pm = $classid;
  3361. $typeclass = array();
  3362. $tc = $this->typeclass->find_all();
  3363. foreach ($tc as $v) {
  3364. $typeclass[$v['id']] = $v;
  3365. }
  3366. $prc = array();
  3367. $purchase = $this->purchase->find_all();
  3368. foreach ($purchase as $k => $v) {
  3369. $prc[$v['id']] = $v['title'];
  3370. }
  3371. if (isset($_GET['excel'])) {
  3372. $where = "sku != 'Preset'";
  3373. //数据排序
  3374. $order_str = "id desc";
  3375. if (empty($page)) {
  3376. $start = 0;
  3377. $perpage = 1;
  3378. } else {
  3379. $start = ($page - 1) * $perpage;
  3380. }
  3381. $category = $this->input->get('category', true);
  3382. $warehouse = $this->input->get('warehouse', true);
  3383. $excelid = $this->input->get('sid', true);
  3384. if ($category) {
  3385. $where .= " and features like '%-$category-%'";
  3386. }
  3387. if ($warehouse) {
  3388. $where .= " and warehouse = '$warehouse'";
  3389. }
  3390. $xzid = '';
  3391. if ($excelid) {
  3392. $excelid = explode(',', trim($excelid, ','));
  3393. foreach ($excelid as $key => $value) {
  3394. $xzid .= " id = " . $value . " or";
  3395. }
  3396. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3397. }
  3398. //取得信息列表
  3399. /**
  3400. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3401. $rows = array();$list = array();
  3402. foreach ($info_list as $key=>$value)
  3403. {
  3404. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3405. }
  3406. **/
  3407. $wt = array();
  3408. $whlabel_type = $this->whlabel_type->find_all();
  3409. foreach ($whlabel_type as $v) {
  3410. $wt[$v['id']] = $v['title'];
  3411. }
  3412. $wh = array();
  3413. $w = $this->warehouse->find_all('1=1', 'id,title');
  3414. foreach ($w as $v) {
  3415. $wh[$v['id']] = $v['title'];
  3416. }
  3417. $list = array();
  3418. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3419. foreach ($rows as $key => $value) {
  3420. if (isset($wt[$value['type']])) {
  3421. $rows[$key]['type'] = $wt[$value['type']];
  3422. } else {
  3423. $rows[$key]['type'] = '未设置';
  3424. }
  3425. $bm = '03';
  3426. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3427. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3428. $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');
  3429. $details = array();
  3430. $cpid = array();
  3431. $cpbz = array();
  3432. $c = 0;
  3433. $g = 0;
  3434. $x = 0;
  3435. $t = 0;
  3436. $s = 0;
  3437. $q = 0;
  3438. foreach ($sd as $k => $v) {
  3439. if ($v['state'] == 0) {
  3440. $c++;
  3441. if ($v['cpid'] != 0) {
  3442. $cpid[$v['cpid']] = $v['cpid'];
  3443. }
  3444. if ($v['cpbz'] != '') {
  3445. $cpbz[$v['cpbz']] = $v['cpbz'];
  3446. }
  3447. }
  3448. if ($v['state'] != 9) {
  3449. $g++;
  3450. }
  3451. if ($v['state'] == 1) {
  3452. $x++;
  3453. }
  3454. if ($v['state'] == 2) {
  3455. $t++;
  3456. }
  3457. if ($v['state'] == 8) {
  3458. $s++;
  3459. }
  3460. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3461. $q++;
  3462. }
  3463. $details[$v['details']] = $v['details'];
  3464. }
  3465. $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'] . '"');
  3466. $rows[$key]['details'] = implode("、", $details);
  3467. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3468. $number = $value['number'];
  3469. $ftime = time() - 15 * 24 * 3600;
  3470. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3471. $rows[$key]['number'] = $g;
  3472. $rows[$key]['c'] = $c;
  3473. $rows[$key]['x'] = $x;
  3474. $rows[$key]['t'] = $t;
  3475. $rows[$key]['s'] = $s;
  3476. $rows[$key]['q'] = $q;
  3477. $rows[$key]['z'] = $z;
  3478. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3479. $features = explode('-', trim($features, '-'));
  3480. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3481. // $pm = $classid;
  3482. // $jm = $classid;
  3483. // foreach($features as $k=>$v)
  3484. // {
  3485. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3486. // {
  3487. // if($typeclass[$v]['bm'] != '')
  3488. // {
  3489. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3490. // }
  3491. // }
  3492. // if($v != 0)
  3493. // {
  3494. // if(!isset($typeclass[$v]))
  3495. // {
  3496. // continue;
  3497. // }
  3498. // if(isset($pm[$typeclass[$v]['classid']]))
  3499. // {
  3500. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3501. // {
  3502. // $tz = explode('|',$typeclass[$v]['zh']);
  3503. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3504. // }
  3505. // else
  3506. // {
  3507. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3508. // }
  3509. // }
  3510. // if(isset($jm[$typeclass[$v]['classid']]))
  3511. // {
  3512. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3513. // }
  3514. // }
  3515. // }
  3516. // $jm = array_filter($jm);
  3517. // $rows[$key]['bs'] = implode("-",$jm);
  3518. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3519. // $zh = implode(" ",$pm);
  3520. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3521. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3522. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3523. // $rows[$key]['features'] = $zh;
  3524. }
  3525. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3526. $final_list = [];
  3527. foreach ($list as $k => $v) {
  3528. if (empty($v['sku'])) {
  3529. continue;
  3530. }
  3531. $final_list[] = [
  3532. "warehouse" => $v["warehouse"],
  3533. "purchase" => $v["purchase"],
  3534. "details" => $v["details"],
  3535. "cpid" => $v["cpid"],
  3536. "dbcontent" => $v["dbcontent"],
  3537. "sku" => $v["sku"],
  3538. "cs" => $v["bm"],
  3539. "bs" => $v["jm"],
  3540. "title" => $v["title"],
  3541. "features" => $v["pm"],
  3542. "cpbz" => $v["cpbz"],
  3543. "sm" => $v["sm"],
  3544. "type" => $v["type"],
  3545. "number" => $v["number"],
  3546. "c" => $v["c"],
  3547. "x" => $v["x"],
  3548. "t" => $v["t"],
  3549. "s" => $v["s"],
  3550. "q" => $v["q"],
  3551. "z" => $v["z"],
  3552. "weight" => $v['weight'],
  3553. ];
  3554. }
  3555. $title = "总进销存统计表";
  3556. $titlename = "<table border=1>
  3557. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3558. <tr align='center'>
  3559. <td>仓库</td>
  3560. <td>供应商</td>
  3561. <td>位置</td>
  3562. <td>库存编码</td>
  3563. <td>类目</td>
  3564. <td>SKU</td>
  3565. <td>用友编码</td>
  3566. <td>用友料号</td>
  3567. <td>商品名称</td>
  3568. <td>商品中文</td>
  3569. <td>产品备注</td>
  3570. <td>说明</td>
  3571. <td>类型</td>
  3572. <td>入库总量</td>
  3573. <td>库存数量</td>
  3574. <td>销售数量</td>
  3575. <td>退货数量</td>
  3576. <td>删除数量</td>
  3577. <td>其它操作</td>
  3578. <td>占单数量</td>
  3579. <td>重量(g)</td>
  3580. </tr>
  3581. </table>";
  3582. $filename = $title . ".xls";
  3583. $tail = "";
  3584. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3585. }
  3586. }
  3587. //入库导出
  3588. public function _excelr()
  3589. {
  3590. if (isset($_GET['excel'])) {
  3591. $category = $this->input->get('category', true);
  3592. $size = $this->input->get('size', true);
  3593. $grade = $this->input->get('grade', true);
  3594. $color = $this->input->get('color', true);
  3595. $lowe = $this->input->get('lowe', true);
  3596. $sku = $this->input->get('sku', true);
  3597. $warehouse = $this->input->get('warehouse', true);
  3598. $purchase = $this->input->get('purchase', true);
  3599. $ktime = $this->input->get('ktime', true);
  3600. $jtime = $this->input->get('jtime', true);
  3601. $ktime = strtotime($ktime);
  3602. $jtime = strtotime($jtime);
  3603. $where = "1=1";
  3604. $gj = "";
  3605. $ck = "";
  3606. if ($category) {
  3607. $where .= " and features like '%-$category-%'";
  3608. }
  3609. if ($size) {
  3610. $where .= " and features like '%-$size-%'";
  3611. }
  3612. if ($grade) {
  3613. $where .= " and features like '%-$grade-%'";
  3614. }
  3615. if ($color) {
  3616. $where .= " and features like '%-$color-%'";
  3617. }
  3618. if ($lowe) {
  3619. $where .= " and features like '%-$lowe-%'";
  3620. }
  3621. if ($warehouse) {
  3622. $where .= " and warehouse = '$warehouse'";
  3623. }
  3624. if ($purchase) {
  3625. $where .= " and purchase = '$purchase'";
  3626. }
  3627. if ($sku) {
  3628. $where .= " and sku = '$sku'";
  3629. }
  3630. if ($ktime && $jtime) {
  3631. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3632. }
  3633. //数据排序
  3634. $order_str = "id desc";
  3635. if (empty($page)) {
  3636. $start = 0;
  3637. $perpage = 1;
  3638. } else {
  3639. $start = ($page - 1) * $perpage;
  3640. }
  3641. $list = array();
  3642. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3643. foreach ($rows as $value) {
  3644. $ck = $this->warehouse->read($value['warehouse']);
  3645. $warehouse = $ck['title'];
  3646. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3647. $retreatwarehouse = $tkck['title'];
  3648. $gy = $this->purchase->read($value['purchase']);
  3649. $purchase = $gy['title'];
  3650. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3651. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3652. }
  3653. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3654. $titlename = "<table border=1>
  3655. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3656. <tr align='center'>
  3657. <td>仓库</td>
  3658. <td>SKU</td>
  3659. <td>产品</td>
  3660. <td>时间</td>
  3661. <td>数量</td>
  3662. </tr>
  3663. </table>";
  3664. $filename = $title . ".xls";
  3665. $tail = "";
  3666. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3667. }
  3668. }
  3669. //出库、退库导出
  3670. public function _excelct()
  3671. {
  3672. $classid = $this->classid->sku();
  3673. $pm = $classid;
  3674. $typeclass = array();
  3675. $tc = $this->typeclass->find_all();
  3676. foreach ($tc as $v) {
  3677. $typeclass[$v['id']] = $v;
  3678. }
  3679. $prc = array();
  3680. $purchase = $this->purchase->find_all();
  3681. foreach ($purchase as $k => $v) {
  3682. $prc[$v['id']] = $v['title'];
  3683. }
  3684. if (isset($_GET['excel'])) {
  3685. $wh = array();
  3686. $w = $this->warehouse->find_all('1=1', 'id,title');
  3687. foreach ($w as $v) {
  3688. $wh[$v['id']] = $v['title'];
  3689. }
  3690. $type = $this->input->get('excel', true);
  3691. $category = $this->input->get('category', true);
  3692. $size = $this->input->get('size', true);
  3693. $grade = $this->input->get('grade', true);
  3694. $color = $this->input->get('color', true);
  3695. $lowe = $this->input->get('lowe', true);
  3696. $sku = $this->input->get('sku', true);
  3697. $title = $this->input->get('title', true);
  3698. $warehouse = $this->input->get('warehouse', true);
  3699. $purchase = $this->input->get('purchase', true);
  3700. $lacetype = $this->input->get('lacetype', true);
  3701. $haircap = $this->input->get('haircap', true);
  3702. $lacecolor = $this->input->get('lacecolor', true);
  3703. $density = $this->input->get('density', true);
  3704. $details = $this->input->get('details', true);
  3705. $state = $this->input->get('state', true);
  3706. $shop = $this->input->get('shop', true);
  3707. $hairnumber = $this->input->get('hairnumber', true);
  3708. $type_leixi = $this->input->get('type', true);
  3709. $cpbz = $this->input->get('cpbz', true);
  3710. $sm = $this->input->get('sm', true);
  3711. $sid = $this->input->get('sid', true);
  3712. $ktime = $this->input->get('ktime', true);
  3713. $jtime = $this->input->get('jtime', true);
  3714. $ktime = strtotime($ktime);
  3715. $jtime = strtotime($jtime);
  3716. //$where = " 1=1 ";
  3717. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3718. $where = " sku != '' ";
  3719. $gj = "";
  3720. $ck = "";
  3721. if ($category) {
  3722. $where .= " and features like '%-$category-%'";
  3723. }
  3724. if ($size) {
  3725. $where .= " and features like '%-$size-%'";
  3726. }
  3727. if ($grade) {
  3728. $where .= " and features like '%-$grade-%'";
  3729. }
  3730. if ($color) {
  3731. $where .= " and features like '%-$color-%'";
  3732. }
  3733. if ($lowe) {
  3734. $where .= " and features like '%-$lowe-%'";
  3735. }
  3736. if ($warehouse) {
  3737. $where .= " and warehouse = '$warehouse'";
  3738. }
  3739. if ($purchase) {
  3740. $where .= " and purchase = '$purchase'";
  3741. }
  3742. if ($state) {
  3743. $where .= " and state = '$state'";
  3744. }
  3745. if ($lacetype) {
  3746. $where .= " and features like '%-$lacetype-%'";
  3747. }
  3748. if ($lacecolor) {
  3749. $where .= " and features like '%-$lacecolor-%'";
  3750. }
  3751. if ($density) {
  3752. $where .= " and features like '%-$density-%'";
  3753. }
  3754. if ($haircap) {
  3755. $where .= " and features like '%-$haircap-%'";
  3756. }
  3757. if ($details) {
  3758. $where .= " and details = '$details'";
  3759. }
  3760. if ($shop) {
  3761. $where .= " and shop like '%$shop%'";
  3762. }
  3763. if ($title) {
  3764. $title = trim($title, ' ');
  3765. $title = trim($title, ' ');
  3766. $where .= " and title like '%$title%'";
  3767. }
  3768. if (!empty($hairnumber)) {
  3769. $where .= " and features like '%-128-%' ";
  3770. if ($hairnumber < 0) {
  3771. $class_list = $this->typeclass->find_all('classid = 43');
  3772. foreach ($class_list as $v) {
  3773. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3774. }
  3775. } else {
  3776. $where .= " and features like '%-$hairnumber-%'";
  3777. }
  3778. }
  3779. if ($type_leixi) {
  3780. $where .= " and type = '$type_leixi'";
  3781. }
  3782. if ($cpbz) {
  3783. $where .= " and cpbz like '%$cpbz%' ";
  3784. }
  3785. if ($sm) {
  3786. $where .= " and sm like '%$sm%' ";
  3787. }
  3788. if ($sku) {
  3789. $sku = trim($sku, ' ');
  3790. $sku = trim($sku, ' ');
  3791. $where .= " and sku like '%$sku%'";
  3792. }
  3793. if ($ktime && $jtime) {
  3794. if ($type == 1) {
  3795. $tl = '出库';
  3796. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3797. } else if ($type == 2) {
  3798. $tl = '退库';
  3799. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3800. } else if ($type == 3) {
  3801. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3802. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3803. } else if ($type == 4) {
  3804. $tl = '出库+零售';
  3805. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3806. } else if ($type == 5) {
  3807. $tl = '零售';
  3808. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3809. }
  3810. }
  3811. $sidwhere = '';
  3812. if ($sid) {
  3813. $sd = "";
  3814. $s = explode(',', trim($sid, ','));
  3815. foreach ($s as $value) {
  3816. $sd .= " id = " . $value . " or";
  3817. }
  3818. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3819. }
  3820. //数据排序
  3821. $order_str = "time desc";
  3822. if (empty($page)) {
  3823. $start = 0;
  3824. $perpage = 1;
  3825. } else {
  3826. $start = ($page - 1) * $perpage;
  3827. }
  3828. //取得信息列表
  3829. if ($type != 3 && $type != 5) {
  3830. if ($type == 1 || $type == 4) {
  3831. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3832. foreach ($info_list as $key => $value) {
  3833. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3834. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3835. $warehouse = $this->warehouse->read($value['warehouse']);
  3836. $info_list[$key]['warehouse'] = $warehouse['title'];
  3837. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3838. $features = explode('-', trim($features, '-'));
  3839. $pm = $classid;
  3840. foreach ($features as $k => $v) {
  3841. if ($v != 0) {
  3842. if (!isset($typeclass[$v])) {
  3843. continue;
  3844. }
  3845. if (isset($pm[$typeclass[$v]['classid']])) {
  3846. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3847. $tz = explode('|', $typeclass[$v]['zh']);
  3848. $pm[$typeclass[$v]['classid']] = $tz[0];
  3849. } else {
  3850. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3851. }
  3852. }
  3853. }
  3854. }
  3855. $zh = implode(" ", $pm);
  3856. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3857. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3858. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3859. $info_list[$key]['features'] = $zh;
  3860. }
  3861. $final_list = [];
  3862. foreach($info_list as $k=>$v){
  3863. $number = "";
  3864. if(!empty($v['orderinfo'])){
  3865. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3866. if(!empty($tmp_info['number'])){
  3867. $number = $tmp_info['number'];
  3868. }
  3869. }
  3870. $final_list[] = [
  3871. 'warehouse'=>$v['warehouse'],
  3872. 'purchase'=>$v['purchase'],
  3873. 'sku'=>$v['sku'],
  3874. 'title'=>$v['title'],
  3875. 'features'=>$v['features'],
  3876. 'label'=>$v['label'],
  3877. 'orderinfo'=>$v['orderinfo'],
  3878. 'number'=>$number,
  3879. 'waybill'=>$v['waybill'],
  3880. 'outk'=>$v['outk'],
  3881. ];
  3882. }
  3883. } else {
  3884. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3885. foreach ($info_list as $key => $value) {
  3886. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3887. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3888. $warehouse = $this->warehouse->read($value['warehouse']);
  3889. $info_list[$key]['warehouse'] = $warehouse['title'];
  3890. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3891. $features = explode('-', trim($features, '-'));
  3892. $pm = $classid;
  3893. foreach ($features as $k => $v) {
  3894. if ($v != 0) {
  3895. if (!isset($typeclass[$v])) {
  3896. continue;
  3897. }
  3898. if (isset($pm[$typeclass[$v]['classid']])) {
  3899. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3900. $tz = explode('|', $typeclass[$v]['zh']);
  3901. $pm[$typeclass[$v]['classid']] = $tz[0];
  3902. } else {
  3903. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3904. }
  3905. }
  3906. }
  3907. }
  3908. $zh = implode(" ", $pm);
  3909. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3910. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3911. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3912. $info_list[$key]['features'] = $zh;
  3913. }
  3914. $final_list = [];
  3915. foreach($info_list as $k=>$v){
  3916. $number = "";
  3917. if(!empty($v['orderinfo'])){
  3918. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3919. if(!empty($tmp_info['number'])){
  3920. $number = $tmp_info['number'];
  3921. }
  3922. }
  3923. $final_list[] = [
  3924. 'warehouse'=>$v['warehouse'],
  3925. 'purchase'=>$v['purchase'],
  3926. 'sku'=>$v['sku'],
  3927. 'title'=>$v['title'],
  3928. 'features'=>$v['features'],
  3929. 'label'=>$v['label'],
  3930. 'orderinfo'=>$v['orderinfo'],
  3931. 'number'=>$number,
  3932. 'waybill'=>$v['waybill'],
  3933. 'retreat'=>$v['retreat'],
  3934. ];
  3935. }
  3936. }
  3937. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3938. $titlename = "<table border=1>
  3939. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3940. <tr align='center'>
  3941. <td>仓库</td>
  3942. <td>供应商</td>
  3943. <td>SKU</td>
  3944. <td>商品名称</td>
  3945. <td>商品中文</td>
  3946. <td>标签</td>
  3947. <td>订单号</td>
  3948. <td>订单编码</td>
  3949. <td>运单号</td>
  3950. <td>" . $tl . "时间(中国时间)</td>
  3951. </tr>
  3952. </table>";
  3953. $filename = $title . ".xls";
  3954. $tail = "";
  3955. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3956. } else if ($type == 5) {
  3957. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3958. foreach ($info_list as $key => $value) {
  3959. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3960. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3961. $warehouse = $this->warehouse->read($value['warehouse']);
  3962. $info_list[$key]['warehouse'] = $warehouse['title'];
  3963. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3964. $features = explode('-', trim($features, '-'));
  3965. $pm = $classid;
  3966. foreach ($features as $k => $v) {
  3967. if ($v != 0) {
  3968. if (!isset($typeclass[$v])) {
  3969. continue;
  3970. }
  3971. if (isset($pm[$typeclass[$v]['classid']])) {
  3972. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3973. $tz = explode('|', $typeclass[$v]['zh']);
  3974. $pm[$typeclass[$v]['classid']] = $tz[0];
  3975. } else {
  3976. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3977. }
  3978. }
  3979. }
  3980. }
  3981. $zh = implode(" ", $pm);
  3982. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3983. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3984. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3985. $info_list[$key]['features'] = $zh;
  3986. }
  3987. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3988. $titlename = "<table border=1>
  3989. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3990. <tr align='center'>
  3991. <td>仓库</td>
  3992. <td>供应商</td>
  3993. <td>SKU</td>
  3994. <td>商品名称</td>
  3995. <td>商品中文</td>
  3996. <td>标签</td>
  3997. <td>" . $tl . "时间(中国时间)</td>
  3998. </tr>
  3999. </table>";
  4000. $filename = $title . ".xls";
  4001. $tail = "";
  4002. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4003. } else {
  4004. /**
  4005. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4006. $rows = array();$list = array();
  4007. foreach ($info_list as $key=>$value)
  4008. {
  4009. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4010. }
  4011. **/
  4012. $wh = array();
  4013. $w = $this->warehouse->find_all('1=1', 'id,title');
  4014. foreach ($w as $v) {
  4015. $wh[$v['id']] = $v['title'];
  4016. }
  4017. $wt = array();
  4018. $whlabel_type = $this->whlabel_type->find_all();
  4019. foreach ($whlabel_type as $v) {
  4020. $wt[$v['id']] = $v['title'];
  4021. }
  4022. $classid = $this->classid->sku();
  4023. $list = array();
  4024. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4025. foreach ($rows as $key => $value) {
  4026. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4027. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4028. $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');
  4029. $details = array();
  4030. $cpid = array();
  4031. $cpbz = array();
  4032. $c = 0;
  4033. $g = 0;
  4034. $x = 0;
  4035. $t = 0;
  4036. $s = 0;
  4037. $q = 0;
  4038. foreach ($sd as $k => $v) {
  4039. if ($v['state'] == 0) {
  4040. $c++;
  4041. }
  4042. if ($v['state'] != 9) {
  4043. $g++;
  4044. }
  4045. if ($v['outk'] > 1) {
  4046. $x++;
  4047. }
  4048. if ($v['retreat'] > 0) {
  4049. $t++;
  4050. }
  4051. if ($v['state'] == 8) {
  4052. $s++;
  4053. }
  4054. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4055. $q++;
  4056. }
  4057. $details[$v['details']] = $v['details'];
  4058. if ($v['cpid'] != 0) {
  4059. $cpid[$v['cpid']] = $v['cpid'];
  4060. }
  4061. if ($v['cpbz'] != '') {
  4062. $cpbz[$v['cpbz']] = $v['cpbz'];
  4063. }
  4064. }
  4065. if (isset($wt[$value['type']])) {
  4066. $rows[$key]['type'] = $wt[$value['type']];
  4067. } else {
  4068. $rows[$key]['type'] = '未设置';
  4069. }
  4070. $rows[$key]['details'] = implode("、", $details);
  4071. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4072. $ftime = time() - 15 * 24 * 3600;
  4073. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4074. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4075. $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);
  4076. $rows[$key]['c'] = $c;
  4077. $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);
  4078. $rows[$key]['t'] = $t;
  4079. $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'] . '"');
  4080. $rows[$key]['z'] = $z;
  4081. // $jm = $classid;
  4082. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4083. $features = explode('-', trim($features, '-'));
  4084. // $pm = $classid;
  4085. // foreach ($features as $k => $v) {
  4086. // if ($v != 0) {
  4087. // if (!isset($typeclass[$v])) {
  4088. // continue;
  4089. // }
  4090. // if (isset($pm[$typeclass[$v]['classid']])) {
  4091. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4092. // $tz = explode('|', $typeclass[$v]['zh']);
  4093. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4094. // } else {
  4095. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4096. // }
  4097. // if (isset($jm[$typeclass[$v]['classid']])) {
  4098. // if ($typeclass[$v]['jm']) {
  4099. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4100. // }
  4101. // }
  4102. // }
  4103. // }
  4104. // }
  4105. // $zh = implode(" ", $pm);
  4106. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4107. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4108. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4109. // $rows[$key]['features'] = $zh;
  4110. // $jm = array_filter($jm); //去除空值
  4111. // $jm = implode("-", $jm);
  4112. // $rows[$key]['jm'] = $jm;
  4113. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4114. }
  4115. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4116. // echo "<pre>";
  4117. // print_r($tmp_list);
  4118. // die;
  4119. $final_list =[];
  4120. foreach($tmp_list as $k=>$v){
  4121. $final_list[] = [
  4122. "warehouse"=>$v['warehouse'],
  4123. "purchase"=>$v['purchase'],
  4124. "details"=>$v['details'],
  4125. "cpid"=>$v['cpid'],
  4126. "sku"=>$v['sku'],
  4127. "title"=>$v['title'],
  4128. "features"=>$v['pm'],
  4129. "cpbz"=>$v['cpbz'],
  4130. "sm"=>$v['sm'],
  4131. "type"=>$v['type'],
  4132. "g"=>$v["g"],
  4133. "c"=>$v["c"],
  4134. "x"=>$v["x"],
  4135. "t"=>$v["t"],
  4136. "z"=>$v["z"],
  4137. "jm"=>$v["jm"],
  4138. "weight"=>$v["weight"],
  4139. "asd"=>$v["asd"],
  4140. ];
  4141. }
  4142. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4143. $titlename = "<table border=1>
  4144. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4145. <tr align='center'>
  4146. <td>仓库</td>
  4147. <td>供应商</td>
  4148. <td>位置</td>
  4149. <td>库存编码</td>
  4150. <td>SKU</td>
  4151. <td>商品名称</td>
  4152. <td>商品中文</td>
  4153. <td>产品备注</td>
  4154. <td>说明</td>
  4155. <td>类型</td>
  4156. <td>入库总量</td>
  4157. <td>库存数量</td>
  4158. <td>销售数量</td>
  4159. <td>退货数量</td>
  4160. <td>占单数量</td>
  4161. <td>料号</td>
  4162. <td>重量</td>
  4163. <td>类目</td>
  4164. </tr>
  4165. </table>";
  4166. $filename = $title . ".xls";
  4167. $tail = "";
  4168. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4169. }
  4170. }
  4171. }
  4172. //出库+入库数据整合
  4173. public function _excelcr()
  4174. {
  4175. if (isset($_GET['excel'])) {
  4176. $type = $this->input->get('excel', true);
  4177. $category = $this->input->get('category', true);
  4178. $size = $this->input->get('size', true);
  4179. $grade = $this->input->get('grade', true);
  4180. $color = $this->input->get('color', true);
  4181. $lowe = $this->input->get('lowe', true);
  4182. $sku = $this->input->get('sku', true);
  4183. $warehouse = $this->input->get('warehouse', true);
  4184. $purchase = $this->input->get('purchase', true);
  4185. $state = $this->input->get('state', true);
  4186. $sid = $this->input->get('sid', true);
  4187. $ktime = $this->input->get('ktime', true);
  4188. $jtime = $this->input->get('jtime', true);
  4189. $ktime = strtotime($ktime);
  4190. $jtime = strtotime($jtime);
  4191. $where = "1=1";
  4192. $gj = "";
  4193. $ck = "";
  4194. if ($category) {
  4195. $where .= " and features like '%-$category-%'";
  4196. }
  4197. if ($size) {
  4198. $where .= " and features like '%-$size-%'";
  4199. }
  4200. if ($grade) {
  4201. $where .= " and features like '%-$grade-%'";
  4202. }
  4203. if ($color) {
  4204. $where .= " and features like '%-$color-%'";
  4205. }
  4206. if ($lowe) {
  4207. $where .= " and features like '%-$lowe-%'";
  4208. }
  4209. if ($warehouse) {
  4210. $where .= " and warehouse = '$warehouse'";
  4211. }
  4212. if ($purchase) {
  4213. $where .= " and purchase = '$purchase'";
  4214. }
  4215. if ($state) {
  4216. $where .= " and state = '$state'";
  4217. }
  4218. if ($sku) {
  4219. $where .= " and sku like '%$sku%'";
  4220. }
  4221. if ($ktime && $jtime) {
  4222. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4223. }
  4224. $sidwhere = '';
  4225. if ($sid) {
  4226. $sd = "";
  4227. $s = explode(',', trim($sid, ','));
  4228. foreach ($s as $value) {
  4229. $sd .= " id = " . $value . " or";
  4230. }
  4231. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4232. }
  4233. //取得信息列表
  4234. $timeread = $ktime;
  4235. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4236. $timelist = array();
  4237. for ($i = 0; $i < $timenum; $i++) {
  4238. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4239. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4240. }
  4241. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4242. //echo "<pre>";
  4243. //print_r($info_list);
  4244. //exit();
  4245. $rows = array();
  4246. $list = array();
  4247. foreach ($info_list as $key => $value) {
  4248. $thistime = $timelist;
  4249. if (isset($rows[strtolower($value['sku'])])) {
  4250. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4251. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4252. }
  4253. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4254. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4255. }
  4256. } else {
  4257. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4258. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4259. }
  4260. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4261. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4262. }
  4263. $rows[strtolower($value['sku'])] = $thistime;
  4264. }
  4265. }
  4266. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4267. <head>
  4268. <!--[if gte mso 9]><xml>
  4269. <x:ExcelWorkbook>
  4270. <x:ExcelWorksheets>
  4271. <x:ExcelWorksheet>
  4272. <x:Name>EXCEL</x:Name>
  4273. <x:WorksheetOptions>
  4274. <x:Print>
  4275. <x:ValidPrinterInfo />
  4276. </x:Print>
  4277. </x:WorksheetOptions>
  4278. </x:ExcelWorksheet>
  4279. </x:ExcelWorksheets>
  4280. </x:ExcelWorkbook>
  4281. </xml>
  4282. <![endif]-->
  4283. </head><body>";
  4284. $str .= "<table border=1><tr><td>SKU</td>";
  4285. foreach ($timelist as $k => $v) {
  4286. $str .= "<td>" . $k . "出库</td>";
  4287. $str .= "<td>" . $k . "入库</td>";
  4288. }
  4289. $str .= "</tr></table>";
  4290. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4291. foreach ($rows as $key => $val) {
  4292. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4293. foreach ($val as $k => $v) {
  4294. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4295. if ($val[$k]['r'] > 0) {
  4296. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4297. } else {
  4298. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4299. }
  4300. }
  4301. $str .= "</tr>";
  4302. }
  4303. $str .= "</table>";
  4304. $str .= "</body></html>";
  4305. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4306. header("Content-type: application/octet-stream");
  4307. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4308. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4309. header("Pragma: no-cache");
  4310. header("Expires: 0");
  4311. exit($str);
  4312. }
  4313. }
  4314. //数量调整模板导出
  4315. public function _presetout()
  4316. {
  4317. if (isset($_GET['excel'])) {
  4318. $where = "sku != 'Preset' and purchase != 0";
  4319. //数据排序
  4320. $order_str = "id desc";
  4321. if (empty($page)) {
  4322. $start = 0;
  4323. $perpage = 1;
  4324. } else {
  4325. $start = ($page - 1) * $perpage;
  4326. }
  4327. //取得信息列表
  4328. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4329. $rows = array();
  4330. $list = array();
  4331. foreach ($info_list as $value) {
  4332. $warehouse = $this->warehouse->read($value['warehouse']);
  4333. $number = $value['number'];
  4334. $ftime = time() - 15 * 24 * 3600;
  4335. $purchase = $this->purchase->read($value['purchase']);
  4336. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4337. }
  4338. $title = "库存模板";
  4339. $titlename = "<table border=1>
  4340. <tr align='center'>
  4341. <td>仓库</td>
  4342. <td>供应商编码</td>
  4343. <td>SKU</td>
  4344. <td>增减数量(正数或负数)</td>
  4345. <td>增减备注</td>
  4346. <td>扣减方式:0减少库存1删除库存</td>
  4347. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4348. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4349. </tr>
  4350. </table>";
  4351. $filename = $title . ".xls";
  4352. $tail = "";
  4353. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4354. }
  4355. }
  4356. //数量调整模板导入
  4357. public function _presetedit()
  4358. {
  4359. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4360. $config['upload_path'] = '.' . $dir;
  4361. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4362. $config['allowed_types'] = 'xls|xlsx|csv';
  4363. $config['max_size'] = 10240;
  4364. $this->load->library('upload', $config);
  4365. $this->upload->initialize($config);
  4366. if ($this->upload->do_upload('userfile')) {
  4367. $full_path = $dir . $this->upload->data('file_name');
  4368. $fileName = '.' . $full_path;
  4369. if (!file_exists($fileName)) {
  4370. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4371. exit;
  4372. } else {
  4373. require_once "./data/excel/PHPExcel/IOFactory.php";
  4374. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4375. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4376. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4377. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4378. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4379. ++$column; //如果列数大于26行
  4380. $list = array();
  4381. for ($i = 2; $i <= $row; $i++) // 行数循环
  4382. {
  4383. $data = array();
  4384. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4385. {
  4386. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4387. }
  4388. $list[] = $data;
  4389. }
  4390. }
  4391. $i = 0;
  4392. $j = 0;
  4393. $ed = array();
  4394. foreach ($list as $key => $value) {
  4395. $time = time();
  4396. if ($value['0'] == "") {
  4397. continue;
  4398. }
  4399. $warehouse = $this->warehouse->get_title($value['0']);
  4400. $purchase = $this->purchase->get_bm($value['1']);
  4401. $sku = $value['2'];
  4402. $num = $value['3']; //调整数量
  4403. $text = $value['4']; //扣减说明
  4404. $type = $value['5']; //调整方式0扣减1删除
  4405. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4406. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4407. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4408. if (!$purchase) //如果没有这个SKU
  4409. {
  4410. $ed[] = array($purchase . '-不存在此供应商编码');
  4411. $j++;
  4412. continue;
  4413. }
  4414. if (!$d) //如果没有这个SKU
  4415. {
  4416. $ed[] = array($sku . '-库存中不存在此SKU');
  4417. $j++;
  4418. continue;
  4419. }
  4420. if (!isset($warehouse['id'])) {
  4421. $ed[] = array($sku . '-仓库名错误!');
  4422. $j++;
  4423. continue;
  4424. }
  4425. if ($type != '0' && $type != '1') {
  4426. $ed[] = array($sku . '-扣减方式填写错误!');
  4427. $j++;
  4428. continue;
  4429. }
  4430. if ($num < 0) //扣减库存
  4431. {
  4432. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4433. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4434. $j++;
  4435. continue;
  4436. }
  4437. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4438. if (count($data) < abs($num)) {
  4439. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4440. $j++;
  4441. continue;
  4442. }
  4443. if ($type == 0) //如果扣减方式为 扣减库存
  4444. {
  4445. for ($i = 0; $i < abs($num); $i++) {
  4446. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4447. }
  4448. } else if ($type == 1) {
  4449. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4450. if (count($zt) > 0) {
  4451. $ed[] = array($sku . '-有在途库存无法删除!');
  4452. $j++;
  4453. continue;
  4454. }
  4455. for ($i = 0; $i < abs($num); $i++) {
  4456. $this->whlabel->remove($data[$i]['id']);
  4457. }
  4458. }
  4459. } else if ($num > 0) //增加库存
  4460. {
  4461. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4462. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4463. $j++;
  4464. continue;
  4465. }
  4466. $post['sku'] = $d['sku'];
  4467. $post['shop'] = $d['shop'];
  4468. $post['warehouse'] = $warehouse['id'];
  4469. $post['purchase'] = $purchase['id'];
  4470. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4471. $post['state'] = 0;
  4472. $post['title'] = $d['title'];
  4473. $post['number'] = $d['number'];
  4474. $post['features'] = $d['features'];
  4475. $post['enter'] = $time;
  4476. $post['time'] = $time; //操作时间
  4477. $post['rktype'] = $rktype;
  4478. for ($i = 0; $i < $num; $i++) {
  4479. $post['label'] = time() . rand(100, 999) . $i;
  4480. $this->whlabel->insert($post);
  4481. }
  4482. }
  4483. sleep(1); //防止入库时间一样,需要延迟1秒
  4484. }
  4485. if ($j > 0) {
  4486. $tt = date('Ymd', time());
  4487. $title = '库存导入错误信息-' . $tt;
  4488. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4489. $tail = "\n";
  4490. $filename = $title . ".xls";
  4491. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4492. $dir = '/data/excel/' . $time . '/';
  4493. $file_name = 'error_' . $time . rand(1000, 9999);
  4494. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4495. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4496. fwrite($myfile, $ecl);
  4497. fclose($myfile);
  4498. $error = $dir . $file_name . '.xls';
  4499. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4500. exit;
  4501. } else {
  4502. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4503. exit;
  4504. }
  4505. }
  4506. }
  4507. //笛卡儿积
  4508. function cp($ps, $sets, $list)
  4509. {
  4510. $result = array();
  4511. $j = 0;
  4512. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4513. if ($i == 0) {
  4514. $result = $sets[$i];
  4515. }
  4516. $tmp = array();
  4517. foreach ($result as $res) {
  4518. foreach ($sets[$i + 1] as $set) {
  4519. $tmp[] = $res . ',' . $set;
  4520. }
  4521. }
  4522. $result = $tmp;
  4523. }
  4524. $this->db->trans_begin();
  4525. foreach ($result as $v) {
  4526. $post = array();
  4527. $title = "";
  4528. $num = "";
  4529. $data = explode(',', $v);
  4530. for ($i = 0; $i < count($list); $i++) {
  4531. $post[$list[$i]] = $data[$i];
  4532. $typeclass = $this->typeclass->read($data[$i]);
  4533. $title = $title . $typeclass['title'] . " ";
  4534. if ($data[$i] != 0) {
  4535. $num .= $data[$i]; //所有数据ID拼接
  4536. }
  4537. }
  4538. foreach ($ps as $kp => $vp) {
  4539. $post[$kp] = $vp;
  4540. }
  4541. $post['number'] = $num;
  4542. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4543. if ($info_list) {
  4544. $j++;
  4545. } else {
  4546. $skunum = $this->whlabel->find_count();
  4547. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4548. $post['title'] = rtrim($title, ' ');
  4549. $this->whlabel->insert($post);
  4550. }
  4551. }
  4552. if ($this->db->trans_status() === FALSE) {
  4553. $this->db->trans_commit();
  4554. return NULL;
  4555. } else {
  4556. $this->db->trans_commit();
  4557. return $j;
  4558. }
  4559. }
  4560. public function _kj($arg_array)
  4561. {
  4562. if (isset($_POST['sku'])) {
  4563. $time = time();
  4564. $sku = $this->input->post('sku', true);
  4565. $warehouse = $this->input->post('warehouse', true);
  4566. $num = $this->input->post('num', true);
  4567. $text = $this->input->post('text', true);
  4568. $purchase = $this->input->post('purchase', true);
  4569. $cktype = $this->input->post('cktype', true);
  4570. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4571. if ($cktype != 1 && $text == '') {
  4572. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4573. exit;
  4574. }
  4575. if ($num > count($order)) {
  4576. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4577. exit;
  4578. } else {
  4579. for ($i = 0; $i < $num; $i++) {
  4580. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4581. }
  4582. }
  4583. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4584. exit;
  4585. }
  4586. $uid = $this->whlabel->read($arg_array[0]);
  4587. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4588. $this->data['data'] = $uid;
  4589. $this->_Template('whlabel_kj', $this->data);
  4590. }
  4591. public function _summary($arg_array)
  4592. {
  4593. $prc = array();
  4594. $purchase = $this->purchase->find_all();
  4595. foreach ($purchase as $k => $v) {
  4596. $prc[$v['id']] = $v['title'];
  4597. }
  4598. if (isset($_GET['excel'])) {
  4599. $ktime = $this->input->get('ktime', true);
  4600. $jtime = $this->input->get('jtime', true);
  4601. $ktime = strtotime($ktime);
  4602. $jtime = strtotime($jtime);
  4603. $where = "1=1";
  4604. if ($ktime && $jtime) {
  4605. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4606. }
  4607. //数据排序
  4608. $order_str = "time desc";
  4609. if (empty($page)) {
  4610. $start = 0;
  4611. $perpage = 1;
  4612. } else {
  4613. $start = ($page - 1) * $perpage;
  4614. }
  4615. //取得信息列表
  4616. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4617. foreach ($info_list as $key => $value) {
  4618. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4619. $warehouse = $this->warehouse->read($value['warehouse']);
  4620. $info_list[$key]['warehouse'] = $warehouse['title'];
  4621. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4622. $details = array();
  4623. $cpid = array();
  4624. foreach ($x as $k => $v) {
  4625. if ($v['details'] != '') {
  4626. $details[$v['details']] = $v['details'];
  4627. }
  4628. if ($v['cpid'] != 0) {
  4629. $cpid[$v['cpid']] = $v['cpid'];
  4630. }
  4631. }
  4632. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4633. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4634. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4635. $info_list[$key]['s'] = $s;
  4636. $info_list[$key]['x'] = count($x);
  4637. }
  4638. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4639. $titlename = "<table border=1>
  4640. <tr align='center'>
  4641. <td>仓库</td>
  4642. <td>供应商</td>
  4643. <td>出库位置</td>
  4644. <td>出库编码</td>
  4645. <td>SKU</td>
  4646. <td>产品名</td>
  4647. <td>总剩余库存</td>
  4648. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4649. </tr>
  4650. </table>";
  4651. $filename = $title . ".xls";
  4652. $tail = "";
  4653. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4654. }
  4655. }
  4656. //usps发货清单
  4657. public function _manifest()
  4658. {
  4659. if (isset($_POST['manifest'])) {
  4660. $wltext = $this->input->post('wltext', true);
  4661. $time = time() - 16 * 3600;
  4662. $ptime = strtotime(date('Y-m-d', $time));
  4663. $waybill = array();
  4664. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4665. foreach ($fullorder as $v) {
  4666. $waybill[$v['waybill']] = $v['waybill'];
  4667. }
  4668. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4669. foreach ($fullordersmt as $v) {
  4670. $waybill[$v['waybill']] = $v['waybill'];
  4671. }
  4672. $wltext = explode(';', $wltext);
  4673. foreach ($wltext as $v) {
  4674. if (isset($waybill[$v])) {
  4675. unset($waybill[$v]);
  4676. }
  4677. }
  4678. $data = $this->usps->get_manifest($waybill);
  4679. if (isset($data['Description'])) {
  4680. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4681. exit;
  4682. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4683. $bctime = date('Ymd', time());
  4684. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4685. echo json_encode(array('msg' => $pdf, 'success' => true));
  4686. exit;
  4687. } else {
  4688. echo json_encode(array('msg' => $data, 'success' => false));
  4689. exit;
  4690. }
  4691. }
  4692. }
  4693. public function _pdf($pdf, $title, $bctime)
  4694. {
  4695. $pdf_path = './data/pdf/' . $bctime . '/';
  4696. $file_base64 = $pdf;
  4697. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4698. $file_base64 = base64_decode($file_base64);
  4699. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4700. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4701. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4702. }
  4703. /**
  4704. *
  4705. *
  4706. *
  4707. 进销存占单异常索引
  4708. *
  4709. *
  4710. *
  4711. **/
  4712. public function _abnormal()
  4713. {
  4714. $post = $this->input->post(NULL, TRUE);
  4715. if (isset($post['page'])) {
  4716. $page = $this->input->post('page', true);
  4717. $perpage = $this->input->post('perpage', true);
  4718. $sku = $this->input->post('sku', true);
  4719. $where = "1=1";
  4720. //数据排序
  4721. $order_str = "id desc";
  4722. if (empty($page)) {
  4723. $start = 0;
  4724. $perpage = 1;
  4725. } else {
  4726. $start = ($page - 1) * $perpage;
  4727. }
  4728. //取得信息列表
  4729. $info_list = $this->whlabel->find_all($where, '*');
  4730. $rows = array();
  4731. $list = array();
  4732. foreach ($info_list as $key => $value) {
  4733. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4734. }
  4735. foreach ($rows as $value) {
  4736. $warehouse = $this->warehouse->read($value['warehouse']);
  4737. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4738. $number = $value['number'];
  4739. $ftime = time() - 15 * 24 * 3600;
  4740. if ($value['shop'] != '') {
  4741. $shop = $value['shop'];
  4742. $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');
  4743. $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');
  4744. $order = array_merge($orderdlz, $ordersmt);
  4745. $od = 0;
  4746. $a = '';
  4747. $orid = '';
  4748. foreach ($order as $v) {
  4749. $or = explode('|', ltrim($v['whlabel'], '|'));
  4750. for ($i = 0; $i < count($or); $i++) {
  4751. $orod = explode('-', $or[$i]);
  4752. if ($orod[0] == $number) {
  4753. $od += $orod[1];
  4754. }
  4755. }
  4756. $orid .= $v['number'] . '-';
  4757. }
  4758. } else {
  4759. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4760. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4761. $order = array_merge($orderdlz, $ordersmt);
  4762. $od = 0;
  4763. $a = '';
  4764. $orid = '';
  4765. $qt = array();
  4766. foreach ($order as $v) {
  4767. $or = explode('|', ltrim($v['whlabel'], '|'));
  4768. for ($i = 0; $i < count($or); $i++) {
  4769. $orod = explode('-', $or[$i]);
  4770. if ($orod[0] == $number) {
  4771. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4772. if ($czzs > 0) {
  4773. if (isset($qt[$v['shop']])) {
  4774. if ($qt[$v['shop']] < $orod[1]) {
  4775. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4776. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4777. } else {
  4778. $qt[$v['shop']] -= $orod[1];
  4779. }
  4780. } else {
  4781. $qt[$v['shop']] = $czzs;
  4782. }
  4783. } else {
  4784. $od += $orod[1];
  4785. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4786. }
  4787. }
  4788. }
  4789. }
  4790. }
  4791. $z = $od . '(' . $orid . ')'; //查看订单号
  4792. //$z = $od;
  4793. if ($od > $c) {
  4794. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4795. }
  4796. }
  4797. $listdata = array_slice($list, $start, $perpage);
  4798. $total = count($list);
  4799. $pagenum = ceil($total / $perpage);
  4800. $over = $total - ($start + $perpage);
  4801. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4802. echo json_encode($rows);
  4803. exit;
  4804. }
  4805. $this->_Template('whlabel_abnormal', $this->data);
  4806. }
  4807. /**
  4808. *
  4809. *
  4810. *
  4811. 进销存占单异常索引
  4812. *
  4813. *
  4814. *
  4815. **/
  4816. public function _error()
  4817. {
  4818. $post = $this->input->post(NULL, TRUE);
  4819. if (isset($post['page'])) {
  4820. $page = $this->input->post('page', true);
  4821. $perpage = $this->input->post('perpage', true);
  4822. $sku = $this->input->post('sku', true);
  4823. $warehouse = $this->input->post('warehouse', true);
  4824. $ktime = $this->input->post('ktime', true);
  4825. $jtime = $this->input->post('jtime', true);
  4826. $ktime = strtotime($ktime);
  4827. $jtime = strtotime($jtime);
  4828. $where = "sku != 'Preset'";
  4829. $gj = '';
  4830. if ($sku) {
  4831. $where .= " and sku like '%$sku%'";
  4832. } else {
  4833. if ($ktime && $jtime) {
  4834. $gj = " and time > '$ktime' and time < '$jtime'";
  4835. }
  4836. }
  4837. if ($warehouse) {
  4838. $where .= " and warehouse = '$warehouse'";
  4839. }
  4840. //数据排序
  4841. $order_str = "id desc";
  4842. if (empty($page)) {
  4843. $start = 0;
  4844. $perpage = 1;
  4845. } else {
  4846. $start = ($page - 1) * $perpage;
  4847. }
  4848. //取得信息列表
  4849. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4850. $rows = array();
  4851. $list = array();
  4852. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4853. // foreach ($info_list as $value)
  4854. // {
  4855. // $warehouse = $this->warehouse->read($value['warehouse']);
  4856. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4857. // $number = $value['number'];$ftime = time()-15*24*3600;
  4858. // if($c < 1)
  4859. // {
  4860. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4861. // }
  4862. // }
  4863. $warehouse_list = $this->warehouse->find_all();
  4864. $warehouse_list = array_column($warehouse_list, null, 'id');
  4865. foreach ($info_list as $value) {
  4866. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4867. 'title' => "",
  4868. ];
  4869. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4870. $number = $value['number'];
  4871. $ftime = time() - 15 * 24 * 3600;
  4872. if ($c < 1) {
  4873. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4874. }
  4875. }
  4876. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4877. // $query = $this->db->query($sql);
  4878. // $info_list = $query->result_array();
  4879. // $sql_two = "select title,id from crowd_warehouse";
  4880. // $query_two = $this->db->query($sql_two);
  4881. // $warehouse_list = $query_two->result_array();
  4882. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4883. // foreach ($info_list as $value)
  4884. // {
  4885. // if(isset($warehouse_arr[$value['warehouse']])){
  4886. // $warehouse = $warehouse_arr[$value['warehouse']];
  4887. // }else{
  4888. // $warehouse = [
  4889. // 'id'=>0,
  4890. // 'title'=>"异常",
  4891. // ];
  4892. // }
  4893. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4894. // $number = $value['number'];$ftime = time()-15*24*3600;
  4895. // if($c < 1)
  4896. // {
  4897. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4898. // }
  4899. // }
  4900. $listdata = array_slice($list, $start, $perpage);
  4901. $total = count($list);
  4902. $pagenum = ceil($total / $perpage);
  4903. $over = $total - ($start + $perpage);
  4904. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4905. echo json_encode($rows);
  4906. exit;
  4907. }
  4908. if (isset($post['s'])) {
  4909. $id_arr = $this->input->post('s');
  4910. $id_arr = explode(',', trim($id_arr, ','));
  4911. if (!$id_arr) {
  4912. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4913. exit;
  4914. }
  4915. //循环删除记录
  4916. foreach ($id_arr as $v) {
  4917. $dd = $this->whlabel->read($v);
  4918. if (!isset($dd['id'])) {
  4919. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4920. exit;
  4921. }
  4922. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4923. if (isset($zt[0])) {
  4924. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4925. exit;
  4926. }
  4927. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4928. foreach ($deldd as $vv) {
  4929. $this->whlabel->remove($vv['id']);
  4930. }
  4931. }
  4932. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4933. exit;
  4934. }
  4935. $this->_Template('whlabel_error', $this->data);
  4936. }
  4937. public function _errorexcel()
  4938. {
  4939. $post = $this->input->post(NULL, TRUE);
  4940. if (isset($_GET['page'])) {
  4941. $page = $this->input->get('page', true);
  4942. $perpage = $this->input->get('perpage', true);
  4943. $sku = $this->input->get('sku', true);
  4944. $warehouse = $this->input->get('warehouse', true);
  4945. $ktime = $this->input->get('ktime', true);
  4946. $jtime = $this->input->get('jtime', true);
  4947. $ktime = strtotime($ktime);
  4948. $jtime = strtotime($jtime);
  4949. $where = "sku != 'Preset'";
  4950. $gj = '';
  4951. if ($sku) {
  4952. $where .= " and sku like '%$sku%'";
  4953. } else {
  4954. if ($ktime && $jtime) {
  4955. $gj = " and time > '$ktime' and time < '$jtime'";
  4956. }
  4957. }
  4958. if ($warehouse) {
  4959. $where .= " and warehouse = '$warehouse'";
  4960. }
  4961. //数据排序
  4962. $order_str = "id desc";
  4963. if (empty($page)) {
  4964. $start = 0;
  4965. $perpage = 1;
  4966. } else {
  4967. $start = ($page - 1) * $perpage;
  4968. }
  4969. //取得信息列表
  4970. $rows = array();
  4971. $list = array();
  4972. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4973. foreach ($info_list as $value) {
  4974. $warehouse = $this->warehouse->read($value['warehouse']);
  4975. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4976. $number = $value['number'];
  4977. $ftime = time() - 15 * 24 * 3600;
  4978. if ($c < 1) {
  4979. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4980. }
  4981. }
  4982. $title = "0库存汇总";
  4983. $titlename = "<table border=1>
  4984. <tr align='center'>
  4985. <td>仓库</td>
  4986. <td>SKU</td>
  4987. <td>产品</td>
  4988. <td>当前库存</td>
  4989. </tr>
  4990. </table>";
  4991. $filename = $title . ".xls";
  4992. $tail = "";
  4993. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4994. }
  4995. }
  4996. /**
  4997. *
  4998. *
  4999. * 占单
  5000. *
  5001. *
  5002. **/
  5003. public function _kcyz()
  5004. {
  5005. $post = $this->input->post(NULL, TRUE);
  5006. if (isset($post['warehouse'])) {
  5007. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5008. exit; //不再使用
  5009. $warehouse = $this->input->post('warehouse', true);
  5010. $whlabel = $this->input->post('whlabel', true);
  5011. $id = $this->input->post('id', true);
  5012. $shop = $this->input->post('shop', true);
  5013. $number = $this->input->post('number', true);
  5014. if (!$whlabel || $whlabel == '|') {
  5015. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5016. exit;
  5017. }
  5018. $pp = explode('|', trim($whlabel, '|'));
  5019. $x = 0;
  5020. $save = array();
  5021. foreach ($pp as $va) {
  5022. $num = explode('-', $va);
  5023. if ($number) {
  5024. $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 = '')"); //通用
  5025. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5026. } else {
  5027. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5028. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5029. }
  5030. $x++;
  5031. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5032. $save[] = $x - 1;
  5033. continue; //提前先加X不然出错,所以要减1
  5034. }
  5035. }
  5036. if (isset($save[0])) {
  5037. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5038. exit;
  5039. } else {
  5040. echo json_encode(array('success' => true));
  5041. exit;
  5042. }
  5043. }
  5044. }
  5045. public function _db()
  5046. {
  5047. $post = $this->input->post(NULL, TRUE);
  5048. if (isset($post['page'])) {
  5049. $page = $this->input->post('page', true);
  5050. $perpage = $this->input->post('perpage', true);
  5051. $sku = $this->input->post('sku', true);
  5052. $number = $this->input->post('number', true);
  5053. $warehouse = $this->input->post('warehouse', true);
  5054. $purchase = $this->input->post('purchase', true);
  5055. $orderinfo = $this->input->post('orderinfo', true);
  5056. $waybill = $this->input->post('waybill', true);
  5057. $category = $this->input->post('category', true);
  5058. $size = $this->input->post('size', true);
  5059. $grade = $this->input->post('grade', true);
  5060. $color = $this->input->post('color', true);
  5061. $lowe = $this->input->post('lowe', true);
  5062. $state = $this->input->post('state', true);
  5063. $label = $this->input->post('label', true);
  5064. $timetk = $this->input->post('timetkk', true);
  5065. $timetj = $this->input->post('timetjj', true);
  5066. $timetk = strtotime($timetk);
  5067. $timetj = strtotime($timetj);
  5068. $where = "dbtime > 0";
  5069. if ($timetk && $timetj) {
  5070. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5071. }
  5072. if ($sku) {
  5073. $where .= " and sku = '$sku'";
  5074. }
  5075. if ($warehouse) {
  5076. $where .= " and warehouse = '$warehouse'";
  5077. if ($warehouse == 12) {
  5078. $w = 'specialstock';
  5079. } else {
  5080. $w = 'whlabel';
  5081. }
  5082. }
  5083. if ($purchase) {
  5084. $where .= " and purchase = '$purchase'";
  5085. }
  5086. if ($category) {
  5087. $where .= " and features like '%-$category-%'";
  5088. }
  5089. if ($size) {
  5090. $where .= " and features like '%-$size-%'";
  5091. }
  5092. if ($grade) {
  5093. $where .= " and features like '%-$grade-%'";
  5094. }
  5095. if ($color) {
  5096. $where .= " and features like '%-$color-%'";
  5097. }
  5098. if ($lowe) {
  5099. $where .= " and features like '%-$lowe-%'";
  5100. }
  5101. if ($state != '') {
  5102. $where .= " and state = '$state'";
  5103. }
  5104. //数据排序
  5105. $order_str = "dbtime desc";
  5106. if (empty($page)) {
  5107. $start = 0;
  5108. $perpage = 1;
  5109. } else {
  5110. $start = ($page - 1) * $perpage;
  5111. }
  5112. //取得信息列表
  5113. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5114. foreach ($info_list as $key => $value) {
  5115. $warehouse = $this->$w->read($value['warehouse']);
  5116. $info_list[$key]['warehouse'] = $warehouse['title'];
  5117. $purchase = $this->purchase->read($value['purchase']);
  5118. $info_list[$key]['purchase'] = $purchase['title'];
  5119. if ($value['enter'] != 0) {
  5120. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5121. } else {
  5122. $info_list[$key]['enter'] = "";
  5123. }
  5124. if ($value['dbtime'] != 0) {
  5125. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5126. } else {
  5127. $info_list[$key]['dbtime'] = "";
  5128. }
  5129. if ($value['state'] == 0) {
  5130. $info_list[$key]['state'] = "在库";
  5131. } else if ($value['state'] == 1) {
  5132. $info_list[$key]['state'] = "出库";
  5133. } else if ($value['state'] == 2) {
  5134. $info_list[$key]['state'] = "退库";
  5135. } else if ($value['state'] == 3) {
  5136. $info_list[$key]['state'] = "调拨中";
  5137. } else if ($value['state'] == 4) {
  5138. $info_list[$key]['state'] = "再加工";
  5139. } else if ($value['state'] == 5) {
  5140. $info_list[$key]['state'] = "维修中";
  5141. } else if ($value['state'] == 6) {
  5142. $info_list[$key]['state'] = "盘亏";
  5143. } else if ($value['state'] == 7) {
  5144. $info_list[$key]['state'] = "更换标签";
  5145. } else if ($value['state'] == 8) {
  5146. $info_list[$key]['state'] = "其它";
  5147. } else if ($value['state'] == 9) {
  5148. $info_list[$key]['state'] = "预设";
  5149. }
  5150. }
  5151. $total = $this->whlabel->find_count($where);
  5152. $pagenum = ceil($total / $perpage);
  5153. $over = $total - ($start + $perpage);
  5154. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5155. echo json_encode($rows);
  5156. exit;
  5157. }
  5158. if (isset($post['outsku'])) {
  5159. $time = time();
  5160. $cz = $this->input->post('cz', true);
  5161. $label = $this->input->post('outsku', true);
  5162. $sl = $this->input->post('sl', true);
  5163. $num = $this->input->post('num', true);
  5164. //$warehouse = $this->input->post('warehouse',true);
  5165. if (!$sl) {
  5166. $sl = 1;
  5167. }
  5168. if (!$warehouse) {
  5169. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5170. exit;
  5171. }
  5172. $dblabel = $this->whlabellabel->get_label($label);
  5173. if ($dblabel) {
  5174. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5175. if (count($data) < 1) {
  5176. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5177. exit;
  5178. }
  5179. if (count($data) < $num) {
  5180. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5181. exit;
  5182. }
  5183. for ($i = 0; $i < $sl; $i++) {
  5184. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5185. }
  5186. echo json_encode(array('success' => true));
  5187. exit;
  5188. } else {
  5189. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5190. exit;
  5191. }
  5192. }
  5193. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5194. $this->_Template('whlabel_db', $this->data);
  5195. }
  5196. public function _dbrk()
  5197. {
  5198. $post = $this->input->post(NULL, TRUE);
  5199. if (isset($post['page'])) {
  5200. $page = $this->input->post('page', true);
  5201. $perpage = $this->input->post('perpage', true);
  5202. $sku = $this->input->post('sku', true);
  5203. $number = $this->input->post('number', true);
  5204. $warehouse = $this->input->post('warehouse', true);
  5205. $purchase = $this->input->post('purchase', true);
  5206. $orderinfo = $this->input->post('orderinfo', true);
  5207. $waybill = $this->input->post('waybill', true);
  5208. $category = $this->input->post('category', true);
  5209. $size = $this->input->post('size', true);
  5210. $grade = $this->input->post('grade', true);
  5211. $color = $this->input->post('color', true);
  5212. $lowe = $this->input->post('lowe', true);
  5213. $state = $this->input->post('state', true);
  5214. $label = $this->input->post('label', true);
  5215. $ctime = $this->input->post('ctime', true);
  5216. $timetk = $this->input->post('timetkk', true);
  5217. $timetj = $this->input->post('timetjj', true);
  5218. $timetk = strtotime($timetk);
  5219. $timetj = strtotime($timetj);
  5220. $where = "dbtime > 0";
  5221. if ($timetk && $timetj) {
  5222. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5223. }
  5224. if ($sku) {
  5225. $where .= " and sku = '$sku'";
  5226. }
  5227. if ($warehouse) {
  5228. $where .= " and warehouse = '$warehouse'";
  5229. }
  5230. if ($purchase) {
  5231. $where .= " and purchase = '$purchase'";
  5232. }
  5233. if ($category) {
  5234. $where .= " and features like '%-$category-%'";
  5235. }
  5236. if ($size) {
  5237. $where .= " and features like '%-$size-%'";
  5238. }
  5239. if ($grade) {
  5240. $where .= " and features like '%-$grade-%'";
  5241. }
  5242. if ($color) {
  5243. $where .= " and features like '%-$color-%'";
  5244. }
  5245. if ($lowe) {
  5246. $where .= " and features like '%-$lowe-%'";
  5247. }
  5248. if ($state != '') {
  5249. $where .= " and state = '$state'";
  5250. }
  5251. //数据排序
  5252. $order_str = "dbtime desc";
  5253. if (empty($page)) {
  5254. $start = 0;
  5255. $perpage = 1;
  5256. } else {
  5257. $start = ($page - 1) * $perpage;
  5258. }
  5259. //取得信息列表
  5260. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5261. foreach ($info_list as $key => $value) {
  5262. $warehouse = $this->warehouse->read($value['warehouse']);
  5263. $info_list[$key]['warehouse'] = $warehouse['title'];
  5264. $purchase = $this->purchase->read($value['purchase']);
  5265. $info_list[$key]['purchase'] = $purchase['title'];
  5266. if ($value['enter'] != 0) {
  5267. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5268. } else {
  5269. $info_list[$key]['enter'] = "";
  5270. }
  5271. if ($value['dbtime'] != 0) {
  5272. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5273. } else {
  5274. $info_list[$key]['dbtime'] = "";
  5275. }
  5276. if ($value['state'] == 0) {
  5277. $info_list[$key]['state'] = "在库";
  5278. } else if ($value['state'] == 1) {
  5279. $info_list[$key]['state'] = "出库";
  5280. } else if ($value['state'] == 2) {
  5281. $info_list[$key]['state'] = "退库";
  5282. } else if ($value['state'] == 3) {
  5283. $info_list[$key]['state'] = "调拨中";
  5284. } else if ($value['state'] == 4) {
  5285. $info_list[$key]['state'] = "再加工";
  5286. } else if ($value['state'] == 5) {
  5287. $info_list[$key]['state'] = "维修中";
  5288. } else if ($value['state'] == 6) {
  5289. $info_list[$key]['state'] = "盘亏";
  5290. } else if ($value['state'] == 7) {
  5291. $info_list[$key]['state'] = "更换标签";
  5292. } else if ($value['state'] == 8) {
  5293. $info_list[$key]['state'] = "其它";
  5294. } else if ($value['state'] == 9) {
  5295. $info_list[$key]['state'] = "预设";
  5296. }
  5297. }
  5298. $total = $this->whlabel->find_count($where);
  5299. $pagenum = ceil($total / $perpage);
  5300. $over = $total - ($start + $perpage);
  5301. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5302. echo json_encode($rows);
  5303. exit;
  5304. }
  5305. if (isset($post['rsku'])) {
  5306. $cz = $this->input->post('cz', true);
  5307. $label = $this->input->post('rsku', true);
  5308. $sl = $this->input->post('sl', true);
  5309. $warehouse = $this->input->post('warehouse', true);
  5310. if (!$sl) {
  5311. $sl = 1;
  5312. }
  5313. if (!$warehouse) {
  5314. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5315. exit;
  5316. }
  5317. $dblabel = $this->whlabellabel->get_label($label);
  5318. if ($dblabel) {
  5319. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5320. if (count($data) < 1) {
  5321. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5322. exit;
  5323. }
  5324. if ($sl > count($data)) {
  5325. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5326. exit;
  5327. }
  5328. $time = time();
  5329. for ($i = 0; $i < $sl; $i++) {
  5330. $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']);
  5331. }
  5332. echo json_encode(array('success' => true));
  5333. exit;
  5334. } else {
  5335. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5336. exit;
  5337. }
  5338. }
  5339. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5340. $this->_Template('whlabel_dbrk', $this->data);
  5341. }
  5342. public function _whlabelczdc()
  5343. {
  5344. if (isset($_GET['excel'])) {
  5345. //数据排序
  5346. $order_str = "id desc";
  5347. if (empty($page)) {
  5348. $start = 0;
  5349. $perpage = 1;
  5350. } else {
  5351. $start = ($page - 1) * $perpage;
  5352. }
  5353. $state = $this->input->get('state', true);
  5354. $sku = $this->input->get('sku', true);
  5355. $ctime = $this->input->get('ctime', true);
  5356. $category = $this->input->get('category', true);
  5357. $size = $this->input->get('size', true);
  5358. $grade = $this->input->get('grade', true);
  5359. $color = $this->input->get('color', true);
  5360. $lowe = $this->input->get('lowe', true);
  5361. $timetk = $this->input->get('timetkk', true);
  5362. $timetj = $this->input->get('timetjj', true);
  5363. $timetk = strtotime($timetk);
  5364. $timetj = strtotime($timetj);
  5365. $where = "dbtime > 0";
  5366. if ($timetk && $timetj) {
  5367. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5368. }
  5369. if ($category) {
  5370. $where .= " and features like '%-$category-%'";
  5371. }
  5372. if ($size) {
  5373. $where .= " and features like '%-$size-%'";
  5374. }
  5375. if ($grade) {
  5376. $where .= " and features like '%-$grade-%'";
  5377. }
  5378. if ($color) {
  5379. $where .= " and features like '%-$color-%'";
  5380. }
  5381. if ($lowe) {
  5382. $where .= " and features like '%-$lowe-%'";
  5383. }
  5384. //取得信息列表
  5385. $info_list = $this->whlabel->find_all($where, '*');
  5386. $rows = array();
  5387. $list = array();
  5388. foreach ($info_list as $key => $value) {
  5389. $rows[$value['sku']] = $value; //所有数据sku
  5390. }
  5391. foreach ($rows as $value) {
  5392. $warehouse = $this->warehouse->read($value['warehouse']);
  5393. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5394. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5395. if ($value['orderinfo'] == 0) {
  5396. $info_list[$key]['orderinfo'] = "";
  5397. }
  5398. if ($value['waybill'] == 0) {
  5399. $info_list[$key]['waybill'] = "";
  5400. }
  5401. if ($value['state'] == 0) {
  5402. $value['state'] = "在库";
  5403. } else if ($value['state'] == 3) {
  5404. $value['state'] = "调拨中";
  5405. }
  5406. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5407. }
  5408. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5409. $titlename = "<table border=1>
  5410. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5411. <tr align='center'>
  5412. <td>SKU</td>
  5413. <td>产品</td>
  5414. <td>调拨数量</td>
  5415. <td>入库数量</td>
  5416. </tr>
  5417. </table>";
  5418. $filename = $title . ".xls";
  5419. $tail = "";
  5420. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5421. }
  5422. }
  5423. public function _print($arg_array)
  5424. {
  5425. if (isset($_SESSION['api'])) {
  5426. $user = $this->user->get_api($_SESSION['api']);
  5427. $usp = $user;
  5428. $fgshop = "";
  5429. $sid = "";
  5430. $wid = "";
  5431. $wtype = "";
  5432. $usersp = explode('|', trim($user['shop'], '|'));
  5433. $userwh = explode('|', trim($user['warehouse'], '|'));
  5434. foreach ($usersp as $value) {
  5435. $fgshop .= " shop = " . $value . " or";
  5436. $sid .= " id = " . $value . " or";
  5437. }
  5438. foreach ($userwh as $value) {
  5439. $wid .= " id = " . $value . " or";
  5440. $wtype .= " type = " . $value . " or";
  5441. }
  5442. }
  5443. $post = $this->input->post(NULL, TRUE);
  5444. if (isset($post['tmsku'])) {
  5445. $tmsku = $this->input->post('tmsku', true);
  5446. if (is_numeric($tmsku)) {
  5447. $yyh = $this->whlabellabel->get_label($tmsku);
  5448. } else {
  5449. $yyh = $this->whlabellabel->get_sku($tmsku);
  5450. }
  5451. if ($yyh) {
  5452. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5453. exit;
  5454. } else {
  5455. echo json_encode(array('success' => false));
  5456. exit;
  5457. }
  5458. }
  5459. $classid = $this->classid->sku();
  5460. $pm = $classid;
  5461. $scsku = $classid;
  5462. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5463. if (isset($post['warehouse'])) {
  5464. if ($post['warehouse']) {
  5465. $list = array();
  5466. $num = "";
  5467. $title = "";
  5468. $features = "";
  5469. $order = 0;
  5470. $post['shop'] = '';
  5471. $brand = $this->input->post('brand', true);
  5472. if ($brand != '0,') {
  5473. $b = $this->brand->read(rtrim($brand, ','));
  5474. if ($b) {
  5475. $post['shop'] = str_replace('|', ',', $b['shop']);
  5476. }
  5477. }
  5478. $post['details'] = $this->input->post('details', true); //打印数量
  5479. $xbqnum = $this->input->post('xbqnum', true);
  5480. $post['purchase'] = $this->input->post('purchase', true);
  5481. $post['warehouse'] = $this->input->post('warehouse', true);
  5482. $post['purchase'] = $this->input->post('purchase', true);
  5483. $post['retreatwarehouse'] = $post['warehouse'];
  5484. $post['cpbz'] = $this->input->post('cpbz', true);
  5485. $post['state'] = 9;
  5486. $category = $this->input->post('category', true);
  5487. $list['category'] = $category;
  5488. $list['hairtype'] = $this->input->post('hairtype', true);
  5489. $list['grade'] = $this->input->post('grade', true);
  5490. $size = $this->input->post('size', true);
  5491. $list['size'] = rtrim($size, ',');
  5492. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5493. $list['extension'] = $this->input->post('extension', true);
  5494. if ($category == 1297) {
  5495. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5496. }
  5497. if ($category == 1702) {
  5498. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5499. $list['syother'] = $this->input->post('syother', true);
  5500. }
  5501. if ($category == 133) {
  5502. $list['fittype'] = $this->input->post('fittype', true);
  5503. $list['acother'] = $this->input->post('acother', true);
  5504. }
  5505. $list['color'] = $this->input->post('color', true);
  5506. $list['lowe'] = $this->input->post('lowe', true);
  5507. if ($category == 127) {
  5508. $list['type'] = $this->input->post('type', true);
  5509. $list['headroad'] = $this->input->post('headroad', true);
  5510. $list['density'] = $this->input->post('density', true);
  5511. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5512. $list['lacesize'] = $this->input->post('lacesize', true);
  5513. }
  5514. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5515. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5516. }
  5517. if ($category == 128) {
  5518. $list['lacetype'] = $this->input->post('lacetype', true);
  5519. $list['haircap'] = $this->input->post('haircap', true);
  5520. $list['density'] = $this->input->post('density', true);
  5521. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5522. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5523. $list['wigother'] = $this->input->post('wigother', true);
  5524. $list['wigother1'] = $this->input->post('wigother1', true);
  5525. $list['wigother2'] = $this->input->post('wigother2', true);
  5526. }
  5527. if ($category == 129) {
  5528. $list['wide'] = $this->input->post('wide', true);
  5529. }
  5530. if ($category == 131) {
  5531. $list['gifttype'] = $this->input->post('gifttype', true);
  5532. $list['giftother'] = $this->input->post('giftother', true);
  5533. }
  5534. if ($category == 134) {
  5535. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5536. }
  5537. if ($category == 1297) {
  5538. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5539. $list['sywigother'] = $this->input->post('sywigother', true);
  5540. }
  5541. if ($category == 130 || $category == 133 || $category == 1702) {
  5542. $list['items'] = $this->input->post('items', true);
  5543. $list['weight'] = $this->input->post('weight', true);
  5544. }
  5545. if ($category == 1702) {
  5546. $list['syhairther'] = $this->input->post('syhairther', true);
  5547. }
  5548. foreach ($list as $k => $v) {
  5549. if ($v != 0) {
  5550. $num .= $v;
  5551. $features .= $v . '-';
  5552. $post[$k] = $v;
  5553. $typeclass = $this->typeclass->read($v);
  5554. if (isset($pm[$typeclass['classid']])) {
  5555. if (stripos($typeclass['zh'], '|') !== false) {
  5556. $exzh = explode('|', $typeclass['zh']);
  5557. $pm[$typeclass['classid']] = $exzh[0];
  5558. } else {
  5559. $pm[$typeclass['classid']] = $typeclass['zh'];
  5560. }
  5561. }
  5562. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5563. if ($k != 'size') {
  5564. $title .= $typeclass['title'] . " ";
  5565. }
  5566. }
  5567. }
  5568. $typeclass = $this->typeclass->read($list['size']);
  5569. $title .= $typeclass['title'];
  5570. $time = time();
  5571. $post['title'] = rtrim($title, ' ');
  5572. $post['number'] = $num;
  5573. $post['features'] = '-' . $features;
  5574. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5575. $featurespp = explode('-', trim($featurespp, '-'));
  5576. if (isset($featurespp[5])) {
  5577. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5578. } else {
  5579. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5580. }
  5581. $post['enter'] = $time;
  5582. $post['time'] = $time; //操作时间
  5583. $scsku = implode("-", $scsku);
  5584. $zh = implode(" ", $pm);
  5585. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5586. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5587. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5588. $post['sku'] = $bqsku;
  5589. $label = time() . rand(0, 9);
  5590. $post['label'] = $label;
  5591. $cpid = $this->whlabellabel->find_count();
  5592. $post['cpid'] = $cpid + 1;
  5593. $cpid = $post['cpid'];
  5594. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5595. //if($whlabelbarcode)
  5596. //{
  5597. //$post['label'] = $whlabelbarcode['label'];
  5598. //if(!$this->whlabellabel->insert($post))
  5599. //{
  5600. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5601. //}
  5602. //}
  5603. //else
  5604. //{
  5605. $this->db->trans_begin();
  5606. $this->whlabellabel->insert($post);
  5607. //$this->whlabelbarcode->insert($post);
  5608. if ($this->db->trans_status() === TRUE) {
  5609. $this->db->trans_commit();
  5610. } else {
  5611. $this->db->trans_rollback();
  5612. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5613. exit;
  5614. }
  5615. //}
  5616. $warehouse_name = "";
  5617. $warehouse = $post['warehouse'];
  5618. if($warehouse == 12){
  5619. $warehouse_name = "特殊库存库";
  5620. }
  5621. // if($warehouse == 13){
  5622. // $warehouse_name = "许昌仓";
  5623. // }
  5624. // if($warehouse == 5){
  5625. // $warehouse_name = "美国店";
  5626. // }
  5627. // if($warehouse == 16){
  5628. // $warehouse_name = "定制头套仓";
  5629. // }
  5630. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5631. if(!empty($warehouse_name)){
  5632. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5633. }
  5634. $purchase = $this->purchase->read($post['purchase']);
  5635. 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));
  5636. exit; //特殊仓目前不需要仓库选项
  5637. }
  5638. }
  5639. if (isset($_SESSION['api'])) {
  5640. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5641. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5642. $this->data['wlshop'] = $wlshop;
  5643. $this->data['warehouse'] = $warehouse;
  5644. }
  5645. $whlabelwz = $this->whlabelwz->find_all();
  5646. $this->data['whlabelwz'] = $whlabelwz;
  5647. $this->_Template('whlabel_print', $this->data);
  5648. }
  5649. public function _usaprint($arg_array)
  5650. {
  5651. if (isset($_SESSION['api'])) {
  5652. $user = $this->user->get_api($_SESSION['api']);
  5653. $usp = $user;
  5654. $fgshop = "";
  5655. $sid = "";
  5656. $wid = "";
  5657. $wtype = "";
  5658. $usersp = explode('|', trim($user['shop'], '|'));
  5659. $userwh = explode('|', trim($user['warehouse'], '|'));
  5660. foreach ($usersp as $value) {
  5661. $fgshop .= " shop = " . $value . " or";
  5662. $sid .= " id = " . $value . " or";
  5663. }
  5664. foreach ($userwh as $value) {
  5665. $wid .= " id = " . $value . " or";
  5666. $wtype .= " type = " . $value . " or";
  5667. }
  5668. }
  5669. $post = $this->input->post(NULL, TRUE);
  5670. if (isset($post['tmsku'])) {
  5671. $tmsku = $this->input->post('tmsku', true);
  5672. if (is_numeric($tmsku)) {
  5673. $yyh = $this->whlabellabel->get_label($tmsku);
  5674. } else {
  5675. $yyh = $this->whlabellabel->get_sku($tmsku);
  5676. }
  5677. if ($yyh) {
  5678. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5679. exit;
  5680. } else {
  5681. echo json_encode(array('success' => false));
  5682. exit;
  5683. }
  5684. }
  5685. $classid = $this->classid->sku();
  5686. $pm = $classid;
  5687. $scsku = $classid;
  5688. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5689. if (isset($post['warehouse'])) {
  5690. if ($post['warehouse']) {
  5691. $list = array();
  5692. $num = "";
  5693. $title = "";
  5694. $features = "";
  5695. $order = 0;
  5696. $post['shop'] = '';
  5697. $brand = $this->input->post('brand', true);
  5698. if ($brand != '0,') {
  5699. $b = $this->brand->read(rtrim($brand, ','));
  5700. if ($b) {
  5701. $post['shop'] = str_replace('|', ',', $b['shop']);
  5702. }
  5703. }
  5704. $post['details'] = $this->input->post('details', true); //打印数量
  5705. $xbqnum = $this->input->post('xbqnum', true);
  5706. $post['purchase'] = $this->input->post('purchase', true);
  5707. $post['warehouse'] = $this->input->post('warehouse', true);
  5708. $post['purchase'] = $this->input->post('purchase', true);
  5709. $post['retreatwarehouse'] = $post['warehouse'];
  5710. $post['cpbz'] = $this->input->post('cpbz', true);
  5711. $post['state'] = 9;
  5712. $category = $this->input->post('category', true);
  5713. $list['category'] = $category;
  5714. $list['hairtype'] = $this->input->post('hairtype', true);
  5715. $list['grade'] = $this->input->post('grade', true);
  5716. $size = $this->input->post('size', true);
  5717. $list['size'] = rtrim($size, ',');
  5718. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5719. $list['extension'] = $this->input->post('extension', true);
  5720. if ($category == 1297) {
  5721. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5722. }
  5723. if ($category == 1702) {
  5724. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5725. $list['syother'] = $this->input->post('syother', true);
  5726. }
  5727. if ($category == 133) {
  5728. $list['fittype'] = $this->input->post('fittype', true);
  5729. $list['acother'] = $this->input->post('acother', true);
  5730. }
  5731. $list['color'] = $this->input->post('color', true);
  5732. $list['lowe'] = $this->input->post('lowe', true);
  5733. if ($category == 127) {
  5734. $list['type'] = $this->input->post('type', true);
  5735. $list['headroad'] = $this->input->post('headroad', true);
  5736. $list['density'] = $this->input->post('density', true);
  5737. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5738. $list['lacesize'] = $this->input->post('lacesize', true);
  5739. }
  5740. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5741. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5742. }
  5743. if ($category == 128) {
  5744. $list['lacetype'] = $this->input->post('lacetype', true);
  5745. $list['haircap'] = $this->input->post('haircap', true);
  5746. $list['density'] = $this->input->post('density', true);
  5747. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5748. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5749. $list['wigother'] = $this->input->post('wigother', true);
  5750. $list['wigother1'] = $this->input->post('wigother1', true);
  5751. $list['wigother2'] = $this->input->post('wigother2', true);
  5752. }
  5753. if ($category == 129) {
  5754. $list['wide'] = $this->input->post('wide', true);
  5755. }
  5756. if ($category == 131) {
  5757. $list['gifttype'] = $this->input->post('gifttype', true);
  5758. $list['giftother'] = $this->input->post('giftother', true);
  5759. }
  5760. if ($category == 134) {
  5761. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5762. }
  5763. if ($category == 1297) {
  5764. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5765. $list['sywigother'] = $this->input->post('sywigother', true);
  5766. }
  5767. if ($category == 130 || $category == 133 || $category == 1702) {
  5768. $list['items'] = $this->input->post('items', true);
  5769. $list['weight'] = $this->input->post('weight', true);
  5770. }
  5771. if ($category == 1702) {
  5772. $list['syhairther'] = $this->input->post('syhairther', true);
  5773. }
  5774. foreach ($list as $k => $v) {
  5775. if ($v != 0) {
  5776. $num .= $v;
  5777. $features .= $v . '-';
  5778. $post[$k] = $v;
  5779. $typeclass = $this->typeclass->read($v);
  5780. if (isset($pm[$typeclass['classid']])) {
  5781. if (stripos($typeclass['zh'], '|') !== false) {
  5782. $exzh = explode('|', $typeclass['zh']);
  5783. $pm[$typeclass['classid']] = $exzh[0];
  5784. } else {
  5785. $pm[$typeclass['classid']] = $typeclass['zh'];
  5786. }
  5787. }
  5788. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5789. if ($k != 'size') {
  5790. $title .= $typeclass['title'] . " ";
  5791. }
  5792. }
  5793. }
  5794. $typeclass = $this->typeclass->read($list['size']);
  5795. $title .= $typeclass['title'];
  5796. $time = time();
  5797. $post['title'] = rtrim($title, ' ');
  5798. $post['number'] = $num;
  5799. $post['features'] = '-' . $features;
  5800. $fp = $this->whlabel->get_features($post['features']);
  5801. if (!$fp) {
  5802. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5803. exit;
  5804. }
  5805. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5806. $featurespp = explode('-', trim($featurespp, '-'));
  5807. if (isset($featurespp[5])) {
  5808. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5809. } else {
  5810. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5811. }
  5812. $post['enter'] = $time;
  5813. $post['time'] = $time; //操作时间
  5814. $scsku = implode("-", $scsku);
  5815. $zh = implode(" ", $pm);
  5816. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5817. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5818. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5819. $post['sku'] = $fp['sku'];
  5820. $post['label'] = $fp['sku'];
  5821. $cpid = $this->whlabellabel->find_count();
  5822. $post['cpid'] = $cpid + 1;
  5823. $cpid = $post['cpid'];
  5824. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5825. //if($whlabelbarcode)
  5826. //{
  5827. //$post['label'] = $whlabelbarcode['label'];
  5828. //if(!$this->whlabellabel->insert($post))
  5829. //{
  5830. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5831. //}
  5832. //}
  5833. //else
  5834. //{
  5835. $this->db->trans_begin();
  5836. $this->whlabellabel->insert($post);
  5837. //$this->whlabelbarcode->insert($post);
  5838. if ($this->db->trans_status() === TRUE) {
  5839. $this->db->trans_commit();
  5840. } else {
  5841. $this->db->trans_rollback();
  5842. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5843. exit;
  5844. }
  5845. //}
  5846. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5847. $purchase = $this->purchase->read($post['purchase']);
  5848. 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));
  5849. exit; //特殊仓目前不需要仓库选项
  5850. }
  5851. }
  5852. if (isset($_SESSION['api'])) {
  5853. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5854. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5855. $this->data['wlshop'] = $wlshop;
  5856. $this->data['warehouse'] = $warehouse;
  5857. }
  5858. $whlabelwz = $this->whlabelwz->find_all();
  5859. $this->data['whlabelwz'] = $whlabelwz;
  5860. $this->_Template('whlabel_usaprint', $this->data);
  5861. }
  5862. public function _printrk($arg_array)
  5863. {
  5864. $prc = array();
  5865. $purchase = $this->purchase->find_all();
  5866. foreach ($purchase as $k => $v) {
  5867. $prc[$v['id']] = $v['title'];
  5868. }
  5869. $post = $this->input->post(NULL, TRUE);
  5870. if (isset($post['page'])) {
  5871. $page = $this->input->post('page', true);
  5872. $perpage = $this->input->post('perpage', true);
  5873. $sku = $this->input->post('sku', true);
  5874. $bs = $this->input->post('bs', true);
  5875. $number = $this->input->post('number', true);
  5876. $warehouse = $this->input->post('warehouse', true);
  5877. $purchase = $this->input->post('purchase', true);
  5878. $orderinfo = $this->input->post('orderinfo', true);
  5879. $waybill = $this->input->post('waybill', true);
  5880. $category = $this->input->post('category', true);
  5881. $size = $this->input->post('size', true);
  5882. $grade = $this->input->post('grade', true);
  5883. $color = $this->input->post('color', true);
  5884. $lowe = $this->input->post('lowe', true);
  5885. $state = $this->input->post('state', true);
  5886. $label = $this->input->post('label', true);
  5887. $timetk = $this->input->post('ktime', true);
  5888. $timetj = $this->input->post('jtime', true);
  5889. $timetk = strtotime($timetk);
  5890. $timetj = strtotime($timetj);
  5891. $where = "1=1 ";
  5892. if ($timetk && $timetj) {
  5893. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5894. }
  5895. if ($sku) {
  5896. $where .= " and sku = '$sku'";
  5897. }
  5898. if ($bs != '') {
  5899. $where .= " and bs = '$bs'";
  5900. }
  5901. if ($number) {
  5902. $where .= " and number = '$number'";
  5903. }
  5904. if ($warehouse) {
  5905. $where .= " and warehouse = '$warehouse'";
  5906. }
  5907. if ($purchase) {
  5908. $where .= " and purchase = '$purchase'";
  5909. }
  5910. if ($orderinfo) {
  5911. $where .= " and orderinfo = '$orderinfo'";
  5912. }
  5913. if ($waybill) {
  5914. $where .= " and waybill = '$waybill'";
  5915. }
  5916. if ($category) {
  5917. $where .= " and features like '%-$category-%'";
  5918. }
  5919. if ($size) {
  5920. $where .= " and features like '%-$size-%'";
  5921. }
  5922. if ($grade) {
  5923. $where .= " and features like '%-$grade-%'";
  5924. }
  5925. if ($color) {
  5926. $where .= " and features like '%-$color-%'";
  5927. }
  5928. if ($lowe) {
  5929. $where .= " and features like '%-$lowe-%'";
  5930. }
  5931. if ($label) {
  5932. $where .= " and label = '$label'";
  5933. }
  5934. if ($state || $state == 0) {
  5935. $where .= " and state = '$state'";
  5936. }
  5937. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5938. //数据排序
  5939. $order_str = "enter desc";
  5940. if (empty($page)) {
  5941. $start = 0;
  5942. $perpage = 1;
  5943. } else {
  5944. $start = ($page - 1) * $perpage;
  5945. }
  5946. //取得信息列表
  5947. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5948. foreach ($info_list as $key => $value) {
  5949. $warehouse = $this->warehouse->read($value['warehouse']);
  5950. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5951. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5952. if ($value['state'] == 0) {
  5953. $info_list[$key]['state'] = "在库";
  5954. } else if ($value['state'] == 1) {
  5955. $info_list[$key]['state'] = "出库";
  5956. } else if ($value['state'] == 2) {
  5957. $info_list[$key]['state'] = "退库";
  5958. } else if ($value['state'] == 3) {
  5959. $info_list[$key]['state'] = "调拨中";
  5960. } else if ($value['state'] == 4) {
  5961. $info_list[$key]['state'] = "再加工";
  5962. } else if ($value['state'] == 5) {
  5963. $info_list[$key]['state'] = "维修中";
  5964. } else if ($value['state'] == 6) {
  5965. $info_list[$key]['state'] = "盘亏";
  5966. } else if ($value['state'] == 7) {
  5967. $info_list[$key]['state'] = "更换标签";
  5968. } else if ($value['state'] == 8) {
  5969. $info_list[$key]['state'] = "其它";
  5970. } else if ($value['state'] == 9) {
  5971. $info_list[$key]['state'] = "预设";
  5972. } else if ($value['state'] == 10) {
  5973. $info_list[$key]['state'] = "美店零售";
  5974. }
  5975. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5976. }
  5977. $total = $this->$ck->find_count($where);
  5978. $pagenum = ceil($total / $perpage);
  5979. $over = $total - ($start + $perpage);
  5980. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5981. echo json_encode($rows);
  5982. exit;
  5983. }
  5984. if (isset($post['tmsku'])) {
  5985. $time = time();
  5986. $tmsku = $this->input->post('tmsku', true);
  5987. //$post['shop'] = $this->input->post('shop',true);
  5988. $num = $this->input->post('num', true);
  5989. $rktype = $this->input->post('rktype', true);
  5990. if ($num > 200) {
  5991. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5992. exit;
  5993. }
  5994. if (!$rktype) {
  5995. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5996. }
  5997. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5998. /**
  5999. $wz = array();
  6000. foreach ($rk as $key=>$value)
  6001. {
  6002. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6003. }
  6004. if(count($wz) > 1)
  6005. {
  6006. $wz = array_values($wz);
  6007. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6008. }
  6009. **/
  6010. if (isset($rk[0]['purchase'])) {
  6011. $rk = $rk[0];
  6012. $j = 0;
  6013. $post['purchase'] = $rk['purchase'];
  6014. $post['warehouse'] = $rk['warehouse'];
  6015. $post['retreatwarehouse'] = $rk['warehouse'];
  6016. $post['sku'] = $rk['sku'];
  6017. $post['number'] = $rk['number'];
  6018. $post['features'] = $rk['features'];
  6019. $post['title'] = $rk['title'];
  6020. $post['enter'] = $time;
  6021. $post['time'] = $time;
  6022. $post['bs'] = 1;
  6023. $post['shop'] = $rk['shop'];
  6024. $post['details'] = $rk['details'];
  6025. $post['cpid'] = $rk['cpid'];
  6026. $post['cpbz'] = $rk['cpbz'];
  6027. //$post['rktype'] = $rktype;
  6028. $warehouse = $this->warehouse->read($rk['warehouse']);
  6029. if ($warehouse['bdck'] == '') {
  6030. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6031. exit;
  6032. } else {
  6033. $bdck = $warehouse['bdck'];
  6034. }
  6035. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6036. if (isset($pdwz['details'])) {
  6037. if ($pdwz['details'] != $post['details']) {
  6038. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6039. exit;
  6040. }
  6041. }
  6042. $post['featurespp'] = $rk['featurespp'];
  6043. if ($post['warehouse'] == '5') {
  6044. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6045. if ($yza) {
  6046. if ($post['features'] != $yza[0]['features']) {
  6047. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6048. exit;
  6049. }
  6050. }
  6051. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6052. if ($yzb) {
  6053. if ($post['sku'] != $yzb[0]['sku']) {
  6054. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6055. exit;
  6056. }
  6057. }
  6058. }
  6059. for ($i = 0; $i < $num; $i++) {
  6060. $post['label'] = time() . rand(100, 999) . $i;
  6061. if ($this->$bdck->insert($post)) {
  6062. $j++;
  6063. }
  6064. }
  6065. /**
  6066. if($post['warehouse'] != 12)
  6067. {
  6068. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6069. }
  6070. **/
  6071. if ($j == $num) {
  6072. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6073. exit;
  6074. } else {
  6075. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6076. exit;
  6077. }
  6078. } else {
  6079. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6080. exit;
  6081. }
  6082. }
  6083. $this->_Template('whlabel_printrk', $this->data);
  6084. }
  6085. public function _printxzrk($arg_array)
  6086. {
  6087. $post = $this->input->post(NULL, TRUE);
  6088. if (isset($post['wzid'])) {
  6089. $time = time();
  6090. $id = $this->input->post('wzid', true);
  6091. //$post['shop'] = $this->input->post('shop',true);
  6092. $num = 1;
  6093. $rk = $this->whlabellabel->read($id);
  6094. if (isset($rk['purchase'])) {
  6095. $x = 0;
  6096. $post['purchase'] = $rk['purchase'];
  6097. $post['warehouse'] = $rk['warehouse'];
  6098. $post['retreatwarehouse'] = $rk['warehouse'];
  6099. $post['sku'] = $rk['sku'];
  6100. $post['number'] = $rk['number'];
  6101. $post['features'] = $rk['features'];
  6102. $post['title'] = $rk['title'];
  6103. $post['enter'] = $time;
  6104. $post['time'] = $time;
  6105. $post['bs'] = 1;
  6106. $post['shop'] = $rk['shop'];
  6107. $post['details'] = $rk['details'];
  6108. $post['cpid'] = $rk['cpid'];
  6109. $post['cpbz'] = $rk['cpbz'];
  6110. $warehouse = $this->warehouse->read($rk['warehouse']);
  6111. if ($warehouse['bdck'] == '') {
  6112. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6113. exit;
  6114. } else {
  6115. $bdck = $warehouse['bdck'];
  6116. }
  6117. $post['featurespp'] = $rk['featurespp'];
  6118. $this->db->trans_begin();
  6119. for ($i = 0; $i < $num; $i++) {
  6120. $post['label'] = time() . rand(100, 999) . $i;
  6121. $this->$bdck->insert($post);
  6122. }
  6123. /**
  6124. if($post['warehouse'] != 12)
  6125. {
  6126. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6127. }
  6128. **/
  6129. if ($this->db->trans_status() === TRUE) {
  6130. $this->db->trans_commit();
  6131. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6132. exit;
  6133. } else {
  6134. $this->db->trans_rollback();
  6135. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6136. exit;
  6137. }
  6138. } else {
  6139. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6140. exit;
  6141. }
  6142. }
  6143. }
  6144. public function _printck($arg_array)
  6145. {
  6146. $prc = array();
  6147. $purchase = $this->purchase->find_all();
  6148. foreach ($purchase as $k => $v) {
  6149. $prc[$v['id']] = $v['title'];
  6150. }
  6151. $post = $this->input->post(NULL, TRUE);
  6152. if (isset($post['page'])) {
  6153. $page = $this->input->post('page', true);
  6154. $perpage = $this->input->post('perpage', true);
  6155. $sku = $this->input->post('sku', true);
  6156. $bs = $this->input->post('bs', true);
  6157. $number = $this->input->post('number', true);
  6158. $warehouse = $this->input->post('warehouse', true);
  6159. $purchase = $this->input->post('purchase', true);
  6160. $orderinfo = $this->input->post('orderinfo', true);
  6161. $waybill = $this->input->post('waybill', true);
  6162. $category = $this->input->post('category', true);
  6163. $size = $this->input->post('size', true);
  6164. $grade = $this->input->post('grade', true);
  6165. $color = $this->input->post('color', true);
  6166. $lowe = $this->input->post('lowe', true);
  6167. $state = $this->input->post('state', true);
  6168. $label = $this->input->post('label', true);
  6169. $timetk = $this->input->post('ktime', true);
  6170. $timetj = $this->input->post('jtime', true);
  6171. $timetk = strtotime($timetk);
  6172. $timetj = strtotime($timetj);
  6173. $where = "state=1 ";
  6174. if ($timetk && $timetj) {
  6175. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6176. }
  6177. if ($sku) {
  6178. $where .= " and sku = '$sku'";
  6179. }
  6180. if ($bs != '') {
  6181. $where .= " and bs = '$bs'";
  6182. }
  6183. if ($number) {
  6184. $where .= " and number = '$number'";
  6185. }
  6186. if ($warehouse) {
  6187. $where .= " and warehouse = '$warehouse'";
  6188. }
  6189. if ($purchase) {
  6190. $where .= " and purchase = '$purchase'";
  6191. }
  6192. if ($orderinfo) {
  6193. $where .= " and orderinfo = '$orderinfo'";
  6194. }
  6195. if ($waybill) {
  6196. $where .= " and waybill = '$waybill'";
  6197. }
  6198. if ($category) {
  6199. $where .= " and features like '%-$category-%'";
  6200. }
  6201. if ($size) {
  6202. $where .= " and features like '%-$size-%'";
  6203. }
  6204. if ($grade) {
  6205. $where .= " and features like '%-$grade-%'";
  6206. }
  6207. if ($color) {
  6208. $where .= " and features like '%-$color-%'";
  6209. }
  6210. if ($lowe) {
  6211. $where .= " and features like '%-$lowe-%'";
  6212. }
  6213. if ($label) {
  6214. $where .= " and label = '$label'";
  6215. }
  6216. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6217. //数据排序
  6218. $order_str = "outk desc";
  6219. if (empty($page)) {
  6220. $start = 0;
  6221. $perpage = 1;
  6222. } else {
  6223. $start = ($page - 1) * $perpage;
  6224. }
  6225. //取得信息列表
  6226. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6227. foreach ($info_list as $key => $value) {
  6228. $warehouse = $this->warehouse->read($value['warehouse']);
  6229. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6230. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6231. if ($value['state'] == 0) {
  6232. $info_list[$key]['state'] = "在库";
  6233. } else if ($value['state'] == 1) {
  6234. $info_list[$key]['state'] = "出库";
  6235. } else if ($value['state'] == 2) {
  6236. $info_list[$key]['state'] = "退库";
  6237. } else if ($value['state'] == 3) {
  6238. $info_list[$key]['state'] = "调拨中";
  6239. } else if ($value['state'] == 4) {
  6240. $info_list[$key]['state'] = "再加工";
  6241. } else if ($value['state'] == 5) {
  6242. $info_list[$key]['state'] = "维修中";
  6243. } else if ($value['state'] == 6) {
  6244. $info_list[$key]['state'] = "盘亏";
  6245. } else if ($value['state'] == 7) {
  6246. $info_list[$key]['state'] = "更换标签";
  6247. } else if ($value['state'] == 8) {
  6248. $info_list[$key]['state'] = "其它";
  6249. } else if ($value['state'] == 9) {
  6250. $info_list[$key]['state'] = "预设";
  6251. } else if ($value['state'] == 10) {
  6252. $info_list[$key]['state'] = "美店零售";
  6253. }
  6254. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6255. }
  6256. $total = $this->$ck->find_count($where);
  6257. $pagenum = ceil($total / $perpage);
  6258. $over = $total - ($start + $perpage);
  6259. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6260. echo json_encode($rows);
  6261. exit;
  6262. }
  6263. if (isset($post['tmsku'])) {
  6264. $time = time();
  6265. $tmsku = $this->input->post('tmsku', true);
  6266. //$post['shop'] = $this->input->post('shop',true);
  6267. $num = $this->input->post('num', true);
  6268. $cktype = $this->input->post('cktype', true);
  6269. $label = $this->whlabellabel->get_label($tmsku);
  6270. if (!$cktype) {
  6271. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6272. }
  6273. if (!isset($label['warehouse'])) {
  6274. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6275. exit;
  6276. }
  6277. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6278. if (stripos($label['features'], '-126-') !== false) {
  6279. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6280. } else {
  6281. $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 = ''");
  6282. }
  6283. $j = 0;
  6284. if (count($ck) >= $num) {
  6285. for ($i = 0; $i < $num; $i++) {
  6286. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6287. {
  6288. $j++;
  6289. }
  6290. }
  6291. if ($j == $num) {
  6292. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6293. exit;
  6294. } else {
  6295. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6296. exit;
  6297. }
  6298. } else {
  6299. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6300. exit;
  6301. }
  6302. }
  6303. if(isset($_SESSION['api']))
  6304. {
  6305. $user = $this->user->get_api($_SESSION['api']);
  6306. if(in_array($user['power'],[1,27])){
  6307. $vip = 1;
  6308. }
  6309. }
  6310. else
  6311. {
  6312. $vip = 0;
  6313. header('Location: /');exit;
  6314. }
  6315. $this->data['vip'] = $vip;
  6316. $this->_Template('whlabel_printck', $this->data);
  6317. }
  6318. public function _printexcel()
  6319. {
  6320. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6321. $config['upload_path'] = '.' . $dir;
  6322. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6323. $config['allowed_types'] = 'xls|xlsx|csv';
  6324. $config['max_size'] = 10240;
  6325. $this->load->library('upload', $config);
  6326. $this->upload->initialize($config);
  6327. if ($this->upload->do_upload('userfile')) {
  6328. $full_path = $dir . $this->upload->data('file_name');
  6329. $fileName = '.' . $full_path;
  6330. if (!file_exists($fileName)) {
  6331. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6332. exit;
  6333. } else {
  6334. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6335. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6336. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6337. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6338. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6339. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6340. ++$column; //如果列数大于26行
  6341. $list = array();
  6342. for ($i = 2; $i <= $row; $i++) // 行数循环
  6343. {
  6344. $data = array();
  6345. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6346. {
  6347. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6348. }
  6349. $list[] = $data;
  6350. }
  6351. }
  6352. $ed = array();
  6353. $i = 0;
  6354. $j = 0;
  6355. $dcdata = array();
  6356. $yc = '';
  6357. $cmf_arr = array_column($list, '1');
  6358. array_multisort($cmf_arr, SORT_ASC, $list);
  6359. foreach ($list as $key => $value) {
  6360. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6361. if ($typeclass) {
  6362. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6363. } else {
  6364. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6365. $i++;
  6366. continue;
  6367. }
  6368. }
  6369. if ($i > 0) {
  6370. $yc = $i . '条异常';
  6371. }
  6372. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6373. exit;
  6374. }
  6375. }
  6376. public function _uck()
  6377. {
  6378. if (isset($_GET['excel'])) {
  6379. $tc = array();
  6380. $typeclass = $this->typeclass->find_all();
  6381. foreach ($typeclass as $v) {
  6382. $tc[$v['id']] = $v['zh'];
  6383. }
  6384. $data = array();
  6385. $t = array();
  6386. $rq = '';
  6387. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6388. $ts = $ts / (24 * 3600);
  6389. for ($i = 0; $i < $ts; $i++) {
  6390. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6391. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6392. }
  6393. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6394. foreach ($info_list as $k => $v) {
  6395. $features = explode('-', trim($v['features'], '-'));
  6396. if (!isset($features[3]) || !isset($features[4])) {
  6397. continue;
  6398. }
  6399. $data[$k][0] = $tc[$features[0]]; //类型
  6400. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6401. $data[$k][2] = $tc[$features[4]]; //曲度
  6402. $data[$k][3] = '';
  6403. if (isset($data[$k][1])) {
  6404. $data[$k][3] .= $data[$k][1];
  6405. }
  6406. if (isset($data[$k][2])) {
  6407. $data[$k][3] .= $data[$k][2];
  6408. }
  6409. if (isset($features[5])) {
  6410. $data[$k][3] .= $tc[$features[5]];
  6411. }
  6412. if (isset($features[2])) {
  6413. $data[$k][3] .= $tc[$features[2]];
  6414. }
  6415. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6416. $data[$k][4] = $v['sku'];
  6417. $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())) . '))'); //月初库存
  6418. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6419. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6420. $ztrq = '';
  6421. $ztsl = '';
  6422. if (count($zt) > 0) {
  6423. foreach ($zt as $vv) {
  6424. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6425. $ztsl .= $vv['num'] . '<br>';
  6426. }
  6427. }
  6428. $data[$k][] = trim($ztsl, '<br>');
  6429. $data[$k][] = trim($ztrq, '<br>');
  6430. $byck = 0;
  6431. foreach ($t as $vv) {
  6432. $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));
  6433. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6434. $byck += $sl;
  6435. }
  6436. $data[$k][] = ($byck > 0) ? $byck : '';
  6437. }
  6438. $title = "详情 " . date("Y-m-d", time());
  6439. $titlename = "<table border=1>
  6440. <tr align='center'>
  6441. <td>类别</td>
  6442. <td>颜色</td>
  6443. <td>曲度</td>
  6444. <td>名称</td>
  6445. <td>SKU</td>
  6446. <td>月初库存</td>
  6447. <td>剩余库存</td>
  6448. <td>在途数量</td>
  6449. <td>预达日期</td>" .
  6450. $rq
  6451. . "<td>本月出库</td></tr>
  6452. </table>";
  6453. $filename = $title . ".xls";
  6454. $tail = "";
  6455. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6456. }
  6457. }
  6458. public function _whlabelexcelzh()
  6459. {
  6460. if (isset($_GET['excel'])) {
  6461. $where = "sku != 'Preset'";
  6462. //数据排序
  6463. $order_str = "id desc";
  6464. if (empty($page)) {
  6465. $start = 0;
  6466. $perpage = 1;
  6467. } else {
  6468. $start = ($page - 1) * $perpage;
  6469. }
  6470. $category = $this->input->get('category', true);
  6471. $warehouse = $this->input->get('warehouse', true);
  6472. $excelid = $this->input->get('sid', true);
  6473. if ($category) {
  6474. $where .= " and features like '%-$category-%'";
  6475. }
  6476. if ($warehouse) {
  6477. $where .= " and warehouse = '$warehouse'";
  6478. }
  6479. $xzid = '';
  6480. if ($excelid) {
  6481. $excelid = explode(',', trim($excelid, ','));
  6482. foreach ($excelid as $key => $value) {
  6483. $xzid .= " id = " . $value . " or";
  6484. }
  6485. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6486. }
  6487. //取得信息列表
  6488. /**
  6489. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6490. $rows = array();$list = array();
  6491. foreach ($info_list as $key=>$value)
  6492. {
  6493. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6494. }
  6495. **/
  6496. $list = array();
  6497. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6498. foreach ($rows as $key => $value) {
  6499. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6500. $zh = '';
  6501. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6502. foreach ($zt as $v) {
  6503. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6504. }
  6505. $zt = array_sum(array_column($zt, 'num'));
  6506. $number = $value['number'];
  6507. $ftime = time() - 15 * 24 * 3600;
  6508. $warehouse = $this->warehouse->read($value['warehouse']);
  6509. $rows[$key]['warehouse'] = $warehouse['title'];
  6510. $rows[$key]['number'] = $c;
  6511. $rows[$key]['features'] = $zh;
  6512. $rows[$key]['hb'] = $c + $zt;
  6513. }
  6514. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6515. $titlename = "<table border=1>
  6516. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6517. <tr align='center'>
  6518. <td>仓库</td>
  6519. <td>SKU</td>
  6520. <td>产品</td>
  6521. <td>库存数量</td>
  6522. <td>在途数量及预达日期</td>
  6523. <td>在途+库存数量</td>
  6524. </tr>
  6525. </table>";
  6526. $filename = $title . ".xls";
  6527. $tail = "";
  6528. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6529. }
  6530. if (isset($_GET['excel'])) {
  6531. $warehouse = $this->input->get('warehouse', true);
  6532. $sku = $this->input->get('sku', true);
  6533. $cz = $this->input->get('cz', true);
  6534. $text = $this->input->post('text', true);
  6535. $xztime = $this->input->get('xztime', true);
  6536. $timetk = $this->input->get('timetk', true);
  6537. $timetj = $this->input->get('timetj', true);
  6538. $timetk = strtotime($timetk);
  6539. $timetj = strtotime($timetj);
  6540. $where = "time = '0' ";
  6541. if ($warehouse) {
  6542. $where .= " and warehouse = '$warehouse'";
  6543. }
  6544. if ($sku) {
  6545. $where .= " and sku = '$sku'";
  6546. }
  6547. if ($text) {
  6548. $where .= " and text like '%$text%'";
  6549. }
  6550. if ($cz != '') {
  6551. $where .= " and cz = '$cz'";
  6552. }
  6553. if ($timetk && $timetj) {
  6554. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6555. }
  6556. //数据排序
  6557. $order_str = $xztime . " desc";
  6558. //取得信息列表
  6559. $zh = array();
  6560. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6561. foreach ($info_list as $v) {
  6562. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6563. $warehouse = $this->warehouse->read($v['warehouse']);
  6564. $v['warehouse'] = $warehouse['title'];
  6565. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6566. $v['stime'] = date('Y-m-d', $v['stime']);
  6567. if (isset($zh[$v['features']])) {
  6568. $zh[$v['features']]['num'] += $v['num'];
  6569. } else {
  6570. $zh[$v['features']] = $v;
  6571. }
  6572. $zh[$v['features']]['features'] = $c;
  6573. }
  6574. $title = "在途数据" . date('Y-m-d', time());
  6575. $titlename = "<table border=1>
  6576. <tr align='center'>
  6577. <td>仓库</td>
  6578. <td>SKU</td>
  6579. <td>名称</td>
  6580. <td>在途数量</td>
  6581. <td>库存数量</td>
  6582. <td>添加在途日期</td>
  6583. <td>预达日期</td>
  6584. <td>备注</td>
  6585. </tr>
  6586. </table>";
  6587. $filename = $title . ".xls";
  6588. $tail = "";
  6589. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6590. }
  6591. }
  6592. public function _fc()
  6593. {
  6594. $vip = 0;
  6595. if (isset($_SESSION['api'])) {
  6596. $user = $this->user->get_api($_SESSION['api']);
  6597. if ($user['vip'] == 1) {
  6598. $vip = 1;
  6599. }
  6600. } else {
  6601. header('Location: /');
  6602. exit;
  6603. }
  6604. $post = $this->input->post(NULL, TRUE);
  6605. if (isset($post['page'])) {
  6606. $page = $this->input->post('page', true);
  6607. $perpage = $this->input->post('perpage', true);
  6608. $category = $this->input->post('category', true);
  6609. $size = $this->input->post('size', true);
  6610. $grade = $this->input->post('grade', true);
  6611. $color = $this->input->post('color', true);
  6612. $lowe = $this->input->post('lowe', true);
  6613. $sku = $this->input->post('sku');
  6614. $title = $this->input->post('title');
  6615. $warehouse = $this->input->post('warehouse', true);
  6616. $usa = $this->input->post('usa', true);
  6617. $purchase = $this->input->post('purchase', true);
  6618. $lacetype = $this->input->post('lacetype', true);
  6619. $haircap = $this->input->post('haircap', true);
  6620. $density = $this->input->post('density', true);
  6621. $details = $this->input->post('details', true);
  6622. $state = $this->input->post('state', true);
  6623. $ktime = $this->input->post('ktime', true);
  6624. $jtime = $this->input->post('jtime', true);
  6625. $ktime = strtotime($ktime);
  6626. $jtime = strtotime($jtime);
  6627. $where = "state = '11'";
  6628. $gj = "";
  6629. $ck = "";
  6630. if ($lacetype) {
  6631. $where .= " and features like '%-$lacetype-%'";
  6632. }
  6633. if ($category) {
  6634. $where .= " and features like '%-$category-%'";
  6635. }
  6636. if ($size) {
  6637. $where .= " and features like '%-$size-%'";
  6638. }
  6639. if ($grade) {
  6640. $where .= " and features like '%-$grade-%'";
  6641. }
  6642. if ($color) {
  6643. $where .= " and features like '%-$color-%'";
  6644. }
  6645. if ($lowe) {
  6646. $where .= " and features like '%-$lowe-%'";
  6647. }
  6648. if ($haircap) {
  6649. $where .= " and features like '%-$haircap-%'";
  6650. }
  6651. if ($density) {
  6652. $where .= " and features like '%-$density-%'";
  6653. }
  6654. if ($usa) {
  6655. if (!$warehouse) {
  6656. $where .= " and (warehouse = '5' or warehouse = '8')";
  6657. }
  6658. }
  6659. if ($warehouse) {
  6660. $where .= " and warehouse = '$warehouse'";
  6661. }
  6662. if ($details) {
  6663. $where .= " and details = '$details'";
  6664. }
  6665. if ($purchase) {
  6666. $where .= " and purchase = '$purchase'";
  6667. }
  6668. if ($state) {
  6669. $where .= " and state = '$state'";
  6670. }
  6671. if ($ktime && $jtime) {
  6672. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6673. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6674. }
  6675. //数据排序
  6676. $order_str = "id desc";
  6677. if (empty($page)) {
  6678. $start = 0;
  6679. $perpage = 1;
  6680. } else {
  6681. $start = ($page - 1) * $perpage;
  6682. }
  6683. if ($sku) {
  6684. $sku = trim($sku, ' ');
  6685. $sku = trim($sku, ' ');
  6686. $where .= " and sku like '%$sku%'";
  6687. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6688. } else if ($title) {
  6689. $title = trim($title, ' ');
  6690. $title = trim($title, ' ');
  6691. $where .= " and title like '%$title%'";
  6692. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6693. } else {
  6694. //$where .= " and time > '$ktime' and time < '$jtime'";
  6695. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6696. }
  6697. //取得信息列表
  6698. $rows = array();
  6699. $list = array();
  6700. foreach ($info_list as $key => $value) {
  6701. $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'] . '"');
  6702. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6703. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6704. $warehouse = $this->warehouse->read($value['warehouse']);
  6705. $info_list[$key]['warehouse'] = $warehouse['title'];
  6706. $info_list[$key]['number'] = $g;
  6707. $info_list[$key]['features'] = $x;
  6708. $info_list[$key]['x'] = $s;
  6709. }
  6710. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6711. $pagenum = ceil($total / $perpage);
  6712. $over = $total - ($start + $perpage);
  6713. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6714. echo json_encode($rows);
  6715. exit;
  6716. }
  6717. $this->data['vip'] = $vip;
  6718. $this->_Template('whlabel_fc', $this->data);
  6719. }
  6720. public function _fcmb()
  6721. {
  6722. $where = "sku != 'Preset'";
  6723. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6724. foreach ($rows as $k => $v) {
  6725. $warehouse = $this->warehouse->read($v['warehouse']);
  6726. $rows[$k]['warehouse'] = $warehouse['title'];
  6727. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6728. $rows[$k]['t'] = '';
  6729. $rows[$k]['n'] = '';
  6730. }
  6731. $title = "封货产品数据导入模板";
  6732. $titlename = "<table border=1>
  6733. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6734. <tr align='center'>
  6735. <td>仓库</td>
  6736. <td>SKU</td>
  6737. <td>产品</td>
  6738. <td>封存产品总数量</td>
  6739. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6740. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6741. </tr>
  6742. </table>";
  6743. $filename = $title . ".xls";
  6744. $tail = "";
  6745. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6746. }
  6747. public function _fcexcel()
  6748. {
  6749. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6750. $config['upload_path'] = '.' . $dir;
  6751. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6752. $config['allowed_types'] = 'xls|xlsx|csv';
  6753. $config['max_size'] = 10240;
  6754. $this->load->library('upload', $config);
  6755. $this->upload->initialize($config);
  6756. if ($this->upload->do_upload('userfile')) {
  6757. $full_path = $dir . $this->upload->data('file_name');
  6758. $fileName = '.' . $full_path;
  6759. if (!file_exists($fileName)) {
  6760. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6761. exit;
  6762. } else {
  6763. libxml_use_internal_errors(true);
  6764. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6765. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6766. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6767. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6768. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6769. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6770. ++$column; //如果列数大于26行
  6771. $list = array();
  6772. for ($i = 2; $i <= $row; $i++) // 行数循环
  6773. {
  6774. $data = array();
  6775. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6776. {
  6777. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6778. }
  6779. $list[] = $data;
  6780. }
  6781. }
  6782. $i = 0;
  6783. $j = 0;
  6784. $ed = array();
  6785. foreach ($list as $key => $value) {
  6786. $time = time();
  6787. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6788. continue;
  6789. }
  6790. $warehouse = $this->warehouse->get_title($value['0']);
  6791. $sku = $value['1'];
  6792. $type = $value['4']; //调整方式0扣减1删除
  6793. $num = $value['5']; //调整数量
  6794. //$text = $value['4'];//扣减说明
  6795. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6796. if (!$d) //如果没有这个SKU
  6797. {
  6798. $ed[] = array($sku . '-库存中不存在此SKU');
  6799. $j++;
  6800. continue;
  6801. }
  6802. if (!isset($warehouse['id'])) {
  6803. $ed[] = array($sku . '-仓库名错误!');
  6804. $j++;
  6805. continue;
  6806. }
  6807. if ($type == 1 || $type == 2) //扣减库存
  6808. {
  6809. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6810. if (count($data) < abs($num)) {
  6811. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6812. $j++;
  6813. continue;
  6814. }
  6815. if ($type == 1) //转入库存
  6816. {
  6817. for ($i = 0; $i < abs($num); $i++) {
  6818. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6819. }
  6820. } else if ($type == 2) //删除
  6821. {
  6822. for ($i = 0; $i < abs($num); $i++) {
  6823. $this->whlabel->remove($data[$i]['id']);
  6824. }
  6825. }
  6826. } else if ($type == 0) //增加库存
  6827. {
  6828. $post['sku'] = $d['sku'];
  6829. $post['shop'] = '';
  6830. $post['warehouse'] = $warehouse['id'];
  6831. $post['purchase'] = $d['purchase'];
  6832. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6833. $post['state'] = 11;
  6834. $post['title'] = $d['title'];
  6835. $post['number'] = $d['number'];
  6836. $post['features'] = $d['features'];
  6837. $post['enter'] = $time;
  6838. $post['time'] = $time; //操作时间
  6839. for ($i = 0; $i < $num; $i++) {
  6840. $post['label'] = time() . rand(100, 999) . $i;
  6841. $this->whlabel->insert($post);
  6842. }
  6843. }
  6844. sleep(1); //防止入库时间一样,需要延迟1秒
  6845. }
  6846. if ($j > 0) {
  6847. $tt = date('Ymd', time());
  6848. $title = '库存导入错误信息-' . $tt;
  6849. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6850. $tail = "\n";
  6851. $filename = $title . ".xls";
  6852. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6853. $dir = '/data/excel/' . $time . '/';
  6854. $file_name = 'error_' . $time . rand(1000, 9999);
  6855. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6856. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6857. fwrite($myfile, $ecl);
  6858. fclose($myfile);
  6859. $error = $dir . $file_name . '.xls';
  6860. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6861. exit;
  6862. } else {
  6863. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6864. exit;
  6865. }
  6866. }
  6867. }
  6868. public function _fcjxc($arg_array)
  6869. {
  6870. if (isset($_GET['excel'])) {
  6871. $category = $this->input->get('category', true);
  6872. $size = $this->input->get('size', true);
  6873. $grade = $this->input->get('grade', true);
  6874. $color = $this->input->get('color', true);
  6875. $lowe = $this->input->get('lowe', true);
  6876. $sku = $this->input->get('sku');
  6877. $title = $this->input->get('title');
  6878. $warehouse = $arg_array[0];
  6879. $usa = $this->input->get('usa', true);
  6880. $purchase = $this->input->get('purchase', true);
  6881. $lacetype = $this->input->get('lacetype', true);
  6882. $haircap = $this->input->get('haircap', true);
  6883. $density = $this->input->get('density', true);
  6884. $title = $this->input->get('title', true);
  6885. $state = $this->input->get('state', true);
  6886. $ktime = $this->input->get('ktime', true);
  6887. $jtime = $this->input->get('jtime', true);
  6888. $where = "state=11";
  6889. $gj = "";
  6890. $ck = "";
  6891. if ($lacetype) {
  6892. $where .= " and features like '%-$lacetype-%'";
  6893. }
  6894. if ($category) {
  6895. $where .= " and features like '%-$category-%'";
  6896. }
  6897. if ($size) {
  6898. $where .= " and features like '%-$size-%'";
  6899. }
  6900. if ($grade) {
  6901. $where .= " and features like '%-$grade-%'";
  6902. }
  6903. if ($color) {
  6904. $where .= " and features like '%-$color-%'";
  6905. }
  6906. if ($lowe) {
  6907. $where .= " and features like '%-$lowe-%'";
  6908. }
  6909. if ($haircap) {
  6910. $where .= " and features like '%-$haircap-%'";
  6911. }
  6912. if ($density) {
  6913. $where .= " and features like '%-$density-%'";
  6914. }
  6915. if ($usa) {
  6916. if (!$warehouse) {
  6917. $where .= " and (warehouse = '5' or warehouse = '8')";
  6918. }
  6919. }
  6920. if ($warehouse) {
  6921. $where .= " and warehouse = '$warehouse'";
  6922. }
  6923. if ($purchase) {
  6924. $where .= " and purchase = '$purchase'";
  6925. }
  6926. if ($state) {
  6927. $where .= " and state = '$state'";
  6928. }
  6929. $order_str = "id desc";
  6930. if ($sku) {
  6931. $sku = trim($sku, ' ');
  6932. $sku = trim($sku, ' ');
  6933. $where .= " and sku like '%$sku%'";
  6934. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6935. } else if ($title) {
  6936. $title = trim($title, ' ');
  6937. $title = trim($title, ' ');
  6938. $where .= " and title like '%$title%'";
  6939. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6940. } else {
  6941. //$where .= " and time > '$ktime' and time < '$jtime'";
  6942. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6943. }
  6944. //取得信息列表
  6945. $rows = array();
  6946. $list = array();
  6947. foreach ($info_list as $key => $value) {
  6948. $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'] . '"');
  6949. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6950. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6951. $rows[$key] = $value;
  6952. $warehouse = $this->warehouse->read($value['warehouse']);
  6953. $rows[$key]['warehouse'] = $warehouse['title'];
  6954. $rows[$key]['features'] = $g;
  6955. $rows[$key]['a'] = $x;
  6956. $rows[$key]['b'] = $s;
  6957. }
  6958. $title = "总统计表";
  6959. $titlename = "<table border=1>
  6960. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6961. <tr align='center'>
  6962. <td>仓库</td>
  6963. <td>SKU</td>
  6964. <td>产品名称</td>
  6965. <td>录入总量</td>
  6966. <td>取出总量</td>
  6967. <td>剩余总量</td>
  6968. </tr>
  6969. </table>";
  6970. $filename = $title . ".xls";
  6971. $tail = "";
  6972. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6973. }
  6974. $vip = 0;
  6975. if (isset($_SESSION['api'])) {
  6976. $user = $this->user->get_api($_SESSION['api']);
  6977. if ($user['vip'] == 1) {
  6978. $vip = 1;
  6979. }
  6980. } else {
  6981. header('Location: /');
  6982. exit;
  6983. }
  6984. $post = $this->input->post(NULL, TRUE);
  6985. if (isset($post['page'])) {
  6986. $page = $this->input->post('page', true);
  6987. $perpage = $this->input->post('perpage', true);
  6988. $category = $this->input->post('category', true);
  6989. $size = $this->input->post('size', true);
  6990. $grade = $this->input->post('grade', true);
  6991. $color = $this->input->post('color', true);
  6992. $lowe = $this->input->post('lowe', true);
  6993. $sku = $this->input->post('sku');
  6994. $title = $this->input->post('title');
  6995. $warehouse = $arg_array[0];
  6996. $usa = $this->input->post('usa', true);
  6997. $purchase = $this->input->post('purchase', true);
  6998. $lacetype = $this->input->post('lacetype', true);
  6999. $haircap = $this->input->post('haircap', true);
  7000. $density = $this->input->post('density', true);
  7001. $title = $this->input->post('title', true);
  7002. $state = $this->input->post('state', true);
  7003. $ktime = $this->input->post('ktime', true);
  7004. $jtime = $this->input->post('jtime', true);
  7005. $ktime = strtotime($ktime);
  7006. $jtime = strtotime($jtime);
  7007. $where = "state=11";
  7008. $gj = "";
  7009. $ck = "";
  7010. if ($lacetype) {
  7011. $where .= " and features like '%-$lacetype-%'";
  7012. }
  7013. if ($category) {
  7014. $where .= " and features like '%-$category-%'";
  7015. }
  7016. if ($size) {
  7017. $where .= " and features like '%-$size-%'";
  7018. }
  7019. if ($grade) {
  7020. $where .= " and features like '%-$grade-%'";
  7021. }
  7022. if ($color) {
  7023. $where .= " and features like '%-$color-%'";
  7024. }
  7025. if ($lowe) {
  7026. $where .= " and features like '%-$lowe-%'";
  7027. }
  7028. if ($haircap) {
  7029. $where .= " and features like '%-$haircap-%'";
  7030. }
  7031. if ($density) {
  7032. $where .= " and features like '%-$density-%'";
  7033. }
  7034. if ($usa) {
  7035. if (!$warehouse) {
  7036. $where .= " and (warehouse = '5' or warehouse = '8')";
  7037. }
  7038. }
  7039. if ($warehouse) {
  7040. $where .= " and warehouse = '$warehouse'";
  7041. }
  7042. if ($purchase) {
  7043. $where .= " and purchase = '$purchase'";
  7044. }
  7045. if ($state) {
  7046. $where .= " and state = '$state'";
  7047. }
  7048. if ($ktime && $jtime) {
  7049. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7050. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7051. }
  7052. //数据排序
  7053. $order_str = "id desc";
  7054. $xs = 0;
  7055. $rows = array();
  7056. $list = array();
  7057. if (empty($page)) {
  7058. $start = 0;
  7059. $perpage = 1;
  7060. } else {
  7061. $start = ($page - 1) * $perpage;
  7062. }
  7063. if ($sku || $title) {
  7064. if ($title) {
  7065. $title = trim($title, ' ');
  7066. $title = trim($title, ' ');
  7067. $where .= " and title like '%$title%'";
  7068. } else {
  7069. $sku = trim($sku, ' ');
  7070. $sku = trim($sku, ' ');
  7071. $where .= " and sku like '%$sku%'";
  7072. }
  7073. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7074. foreach ($info_list as $key => $value) {
  7075. $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'] . '"');
  7076. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7077. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7078. $rows[$key] = $value;
  7079. $warehouse = $this->warehouse->read($value['warehouse']);
  7080. $rows[$key]['warehouse'] = $warehouse['title'];
  7081. $rows[$key]['features'] = $g;
  7082. $rows[$key]['a'] = $x;
  7083. $rows[$key]['b'] = $s;
  7084. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7085. $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天销量
  7086. $yj = $c / ($xl / 30);
  7087. if ($yj < 7) {
  7088. $rows[$key]['y'] = round($yj) . '天销量';
  7089. } else {
  7090. $rows[$key]['y'] = '正常';
  7091. }
  7092. }
  7093. } else {
  7094. //$where .= " and time > '$ktime' and time < '$jtime'";
  7095. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7096. foreach ($info_list as $key => $value) {
  7097. $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'] . '"');
  7098. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7099. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7100. $zs[$key] = $value;
  7101. $warehouse = $this->warehouse->read($value['warehouse']);
  7102. $zs[$key]['warehouse'] = $warehouse['title'];
  7103. $zs[$key]['features'] = $g;
  7104. $zs[$key]['a'] = $x;
  7105. $zs[$key]['b'] = $s;
  7106. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7107. $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天销量
  7108. $yj = $c / ($xl / 30);
  7109. if ($yj < 7) {
  7110. $zs[$key]['y'] = round($yj) . '天销量';
  7111. $rows[$key] = $zs[$key];
  7112. }
  7113. }
  7114. }
  7115. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7116. $pagenum = ceil($total / $perpage);
  7117. $over = $total - ($start + $perpage);
  7118. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7119. echo json_encode($rows);
  7120. exit;
  7121. }
  7122. $this->data['arg_array'] = $arg_array[0];
  7123. $this->_Template('whlabel_fcjxc', $this->data);
  7124. }
  7125. public function _0kcdel()
  7126. {
  7127. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7128. $config['upload_path'] = '.' . $dir;
  7129. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7130. $config['allowed_types'] = 'xls|xlsx|csv';
  7131. $config['max_size'] = 10240;
  7132. $this->load->library('upload', $config);
  7133. $this->upload->initialize($config);
  7134. if ($this->upload->do_upload('userfile')) {
  7135. $full_path = $dir . $this->upload->data('file_name');
  7136. $fileName = '.' . $full_path;
  7137. if (!file_exists($fileName)) {
  7138. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7139. exit;
  7140. } else {
  7141. require_once "./data/excel/PHPExcel/IOFactory.php";
  7142. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7143. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7144. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7145. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7146. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7147. ++$column; //如果列数大于26行
  7148. $list = array();
  7149. for ($i = 2; $i <= $row; $i++) // 行数循环
  7150. {
  7151. $data = array();
  7152. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7153. {
  7154. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7155. }
  7156. $list[] = $data;
  7157. }
  7158. }
  7159. $i = 0;
  7160. $j = 0;
  7161. $ed = array();
  7162. foreach ($list as $key => $value) {
  7163. $time = time();
  7164. if ($value['0'] == "" || $value['1'] == "") {
  7165. continue;
  7166. }
  7167. $warehouse = $this->warehouse->get_title($value['0']);
  7168. $sku = $value['1'];
  7169. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7170. if (!$d) //如果没有这个SKU
  7171. {
  7172. $ed[] = array($sku . '-库存中不存在此SKU');
  7173. $j++;
  7174. continue;
  7175. }
  7176. if (!isset($warehouse['id'])) {
  7177. $ed[] = array($sku . '-仓库名错误!');
  7178. $j++;
  7179. continue;
  7180. }
  7181. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7182. if ($z < 1) {
  7183. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7184. foreach ($z as $v) {
  7185. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7186. if (count($zt) > 0) {
  7187. $ed[] = array($sku . '-有在途库存无法删除!');
  7188. $j++;
  7189. continue;
  7190. }
  7191. $this->whlabel->remove($v['id']);
  7192. }
  7193. } else {
  7194. $ed[] = array($sku . '-非0库存!');
  7195. $j++;
  7196. continue;
  7197. }
  7198. }
  7199. if ($j > 0) {
  7200. $tt = date('Ymd', time());
  7201. $title = '删除0库存错误信息-' . $tt;
  7202. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7203. $tail = "\n";
  7204. $filename = $title . ".xls";
  7205. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7206. $dir = '/data/excel/' . $time . '/';
  7207. $file_name = 'error_' . $time . rand(1000, 9999);
  7208. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7209. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7210. fwrite($myfile, $ecl);
  7211. fclose($myfile);
  7212. $error = $dir . $file_name . '.xls';
  7213. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7214. exit;
  7215. } else {
  7216. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7217. exit;
  7218. }
  7219. }
  7220. }
  7221. public function _gbhtype()
  7222. {
  7223. $post = $this->input->post(NULL, TRUE);
  7224. if (isset($post['s'])) {
  7225. $n = $this->input->post('n');
  7226. $d = $this->input->post('s');
  7227. if (!$d) {
  7228. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7229. exit;
  7230. }
  7231. $d = explode(',', trim($d, ','));
  7232. $t = $this->whlabel_type->read($n);
  7233. //循环删除记录
  7234. foreach ($d as $v) {
  7235. $u = $this->whlabel->read($v);
  7236. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7237. foreach ($data as $val) {
  7238. $this->whlabel->save(array('type' => $n), $val['id']);
  7239. }
  7240. }
  7241. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7242. }
  7243. }
  7244. //出库、退库导出
  7245. public function _dccrtype()
  7246. {
  7247. $classid = $this->classid->sku();
  7248. $pm = $classid;
  7249. $typeclass = array();
  7250. $tc = $this->typeclass->find_all();
  7251. foreach ($tc as $v) {
  7252. $typeclass[$v['id']] = $v;
  7253. }
  7254. $prc = array();
  7255. $purchase = $this->purchase->find_all();
  7256. foreach ($purchase as $k => $v) {
  7257. $prc[$v['id']] = $v['title'];
  7258. }
  7259. if (isset($_GET['sid'])) {
  7260. $wh = array();
  7261. $w = $this->warehouse->find_all('1=1', 'id,title');
  7262. foreach ($w as $v) {
  7263. $wh[$v['id']] = $v['title'];
  7264. }
  7265. $type = $this->input->get('excel', true);
  7266. $category = $this->input->get('category', true);
  7267. $size = $this->input->get('size', true);
  7268. $grade = $this->input->get('grade', true);
  7269. $color = $this->input->get('color', true);
  7270. $lowe = $this->input->get('lowe', true);
  7271. $sku = $this->input->get('sku', true);
  7272. $warehouse = $this->input->get('warehouse', true);
  7273. $lacetype = $this->input->get('lacetype', true);
  7274. $lacecolor = $this->input->get('lacecolor', true);
  7275. $density = $this->input->get('density', true);
  7276. $haircap = $this->input->get('haircap', true);
  7277. $purchase = $this->input->get('purchase', true);
  7278. $title = $this->input->get('title', true);
  7279. $state = $this->input->get('state', true);
  7280. $sid = $this->input->get('sid', true);
  7281. $ktime = $this->input->get('ktime', true);
  7282. $jtime = $this->input->get('jtime', true);
  7283. $ktime = strtotime($ktime);
  7284. $jtime = strtotime($jtime);
  7285. $where = "1=1";
  7286. $gj = "";
  7287. $ck = "";
  7288. if ($category) {
  7289. $where .= " and features like '%-$category-%'";
  7290. }
  7291. if ($size) {
  7292. $where .= " and features like '%-$size-%'";
  7293. }
  7294. if ($grade) {
  7295. $where .= " and features like '%-$grade-%'";
  7296. }
  7297. if ($color) {
  7298. $where .= " and features like '%-$color-%'";
  7299. }
  7300. if ($lowe) {
  7301. $where .= " and features like '%-$lowe-%'";
  7302. }
  7303. if ($warehouse) {
  7304. $where .= " and warehouse = '$warehouse'";
  7305. }
  7306. if ($purchase) {
  7307. $where .= " and purchase = '$purchase'";
  7308. }
  7309. if ($state) {
  7310. $where .= " and state = '$state'";
  7311. }
  7312. if ($lacetype) {
  7313. $where .= " and features like '%-$lacetype-%'";
  7314. }
  7315. if ($lacecolor) {
  7316. $where .= " and features like '%-$lacecolor-%'";
  7317. }
  7318. if ($density) {
  7319. $where .= " and features like '%-$density-%'";
  7320. }
  7321. if ($haircap) {
  7322. $where .= " and features like '%-$haircap-%'";
  7323. }
  7324. if ($title) {
  7325. $title = trim($title, ' ');
  7326. $title = trim($title, ' ');
  7327. $where .= " and title like '%$title%'";
  7328. }
  7329. if ($sku) {
  7330. $sku = trim($sku, ' ');
  7331. $sku = trim($sku, ' ');
  7332. $where .= " and sku like '%$sku%'";
  7333. }
  7334. if ($ktime && $jtime) {
  7335. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7336. }
  7337. $sidwhere = '';
  7338. if ($sid) {
  7339. $sd = "";
  7340. $s = explode(',', trim($sid, ','));
  7341. foreach ($s as $value) {
  7342. $sd .= " id = " . $value . " or";
  7343. }
  7344. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7345. }
  7346. //数据排序
  7347. $order_str = "time desc";
  7348. if (empty($page)) {
  7349. $start = 0;
  7350. $perpage = 1;
  7351. } else {
  7352. $start = ($page - 1) * $perpage;
  7353. }
  7354. $wh = array();
  7355. $w = $this->warehouse->find_all('1=1', 'id,title');
  7356. foreach ($w as $v) {
  7357. $wh[$v['id']] = $v['title'];
  7358. }
  7359. $wt = array();
  7360. $whlabel_type = $this->whlabel_type->find_all();
  7361. foreach ($whlabel_type as $v) {
  7362. $wt[$v['id']] = $v['title'];
  7363. }
  7364. $classid = $this->classid->sku();
  7365. $list = array();
  7366. $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');
  7367. foreach ($rows_r as $key => $value) {
  7368. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7369. $pm = $classid;
  7370. $jm = $classid;
  7371. $rows_r[$key]['enter'] = '入库';
  7372. $rows_r[$key]['time'] = $value['enter'];
  7373. if ($value['rktype'] == 1) {
  7374. $rows_r[$key]['rktype'] = '采购入库';
  7375. } else if ($value['rktype'] == 2) {
  7376. $rows_r[$key]['rktype'] = '盘盈调整';
  7377. } else if ($value['rktype'] == 3) {
  7378. $rows_r[$key]['rktype'] = '其他调整入库';
  7379. } else if ($value['rktype'] == 4) {
  7380. $rows_r[$key]['rktype'] = '其他调整入库';
  7381. } else if ($value['rktype'] == 5) {
  7382. $rows_r[$key]['rktype'] = '退库入库';
  7383. } else if ($value['rktype'] == 6) {
  7384. $rows_r[$key]['rktype'] = '退货可用入库';
  7385. } else if ($value['rktype'] == 7) {
  7386. $rows_r[$key]['rktype'] = '形态转换入库';
  7387. } else {
  7388. $rows_r[$key]['rktype'] = '';
  7389. }
  7390. $features = explode('-', trim($value['features'], '-'));
  7391. foreach ($features as $v) {
  7392. if (isset($typeclass[$v])) {
  7393. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7394. $pm[$typeclass[$v]['classid']] = $zh[0];
  7395. }
  7396. if (isset($typeclass[$v])) {
  7397. if (isset($jm[$typeclass[$v]['classid']])) {
  7398. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7399. }
  7400. }
  7401. }
  7402. $zh = implode(" ", $pm);
  7403. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7404. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7405. $rows_r[$key]['zh'] = $zh;
  7406. $jm = array_filter($jm);
  7407. $rows_r[$key]['features'] = implode("-", $jm);
  7408. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7409. }
  7410. $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');
  7411. foreach ($rows_c as $key => $value) {
  7412. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7413. $pm = $classid;
  7414. $jm = $classid;
  7415. $rows_c[$key]['time'] = $value['outk'];
  7416. $rows_c[$key]['outk'] = '出库';
  7417. if ($value['cktype'] == 1) {
  7418. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7419. } else if ($value['cktype'] == 2) {
  7420. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7421. } else if ($value['cktype'] == 3) {
  7422. $rows_c[$key]['cktype'] = '盘亏调整';
  7423. } else if ($value['cktype'] == 4) {
  7424. $rows_c[$key]['cktype'] = '其他调整出库';
  7425. } else if ($value['cktype'] == 5) {
  7426. $rows_c[$key]['cktype'] = '形态转换出库';
  7427. } else {
  7428. $rows_c[$key]['cktype'] = '';
  7429. }
  7430. unset($rows_c[$key]['state']);
  7431. $features = explode('-', trim($value['features'], '-'));
  7432. foreach ($features as $v) {
  7433. if (isset($typeclass[$v])) {
  7434. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7435. $pm[$typeclass[$v]['classid']] = $zh[0];
  7436. }
  7437. if (isset($typeclass[$v])) {
  7438. if (isset($jm[$typeclass[$v]['classid']])) {
  7439. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7440. }
  7441. }
  7442. }
  7443. $zh = implode(" ", $pm);
  7444. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7445. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7446. $rows_c[$key]['zh'] = $zh;
  7447. $jm = array_filter($jm);
  7448. $rows_c[$key]['features'] = implode("-", $jm);
  7449. $rows_c[$key]['number'] = 1;
  7450. }
  7451. $merged = $rows_r;
  7452. foreach ($rows_c as $key => $value) {
  7453. if (isset($merged[$key])) {
  7454. $merged[] = $value;
  7455. } else {
  7456. $merged[$key] = $value;
  7457. }
  7458. }
  7459. usort($merged, function ($a, $b) {
  7460. return $a['time'] - $b['time'];
  7461. });
  7462. foreach ($merged as $key => $value) {
  7463. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7464. }
  7465. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7466. $titlename = "<table border=1>
  7467. <tr align='center'>
  7468. <td>仓库</td>
  7469. <td>SKU</td>
  7470. <td>商品名称</td>
  7471. <td>仓库品名</td>
  7472. <td>料号</td>
  7473. <td>时间</td>
  7474. <td>操作</td>
  7475. <td>类型</td>
  7476. <td>数量</td>
  7477. <td>备注</td>
  7478. </tr>
  7479. </table>";
  7480. $filename = $title . ".xlsx";
  7481. $tail = "";
  7482. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7483. }
  7484. }
  7485. /*************************************处理exceljs导出****************************************************/
  7486. public function _excelrjs(){
  7487. if (isset($_GET['excel'])) {
  7488. $category = $this->input->get('category', true);
  7489. $size = $this->input->get('size', true);
  7490. $grade = $this->input->get('grade', true);
  7491. $color = $this->input->get('color', true);
  7492. $lowe = $this->input->get('lowe', true);
  7493. $sku = $this->input->get('sku', true);
  7494. $warehouse = $this->input->get('warehouse', true);
  7495. $purchase = $this->input->get('purchase', true);
  7496. $ktime = $this->input->get('ktime', true);
  7497. $jtime = $this->input->get('jtime', true);
  7498. $ktime = strtotime($ktime);
  7499. $jtime = strtotime($jtime);
  7500. $where = "1=1";
  7501. $gj = "";
  7502. $ck = "";
  7503. if ($category) {
  7504. $where .= " and features like '%-$category-%'";
  7505. }
  7506. if ($size) {
  7507. $where .= " and features like '%-$size-%'";
  7508. }
  7509. if ($grade) {
  7510. $where .= " and features like '%-$grade-%'";
  7511. }
  7512. if ($color) {
  7513. $where .= " and features like '%-$color-%'";
  7514. }
  7515. if ($lowe) {
  7516. $where .= " and features like '%-$lowe-%'";
  7517. }
  7518. if ($warehouse) {
  7519. $where .= " and warehouse = '$warehouse'";
  7520. }
  7521. if ($purchase) {
  7522. $where .= " and purchase = '$purchase'";
  7523. }
  7524. if ($sku) {
  7525. $where .= " and sku = '$sku'";
  7526. }
  7527. if ($ktime && $jtime) {
  7528. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7529. }
  7530. //数据排序
  7531. $order_str = "id desc";
  7532. if (empty($page)) {
  7533. $start = 0;
  7534. $perpage = 1;
  7535. } else {
  7536. $start = ($page - 1) * $perpage;
  7537. }
  7538. $list = array();
  7539. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7540. foreach ($rows as $value) {
  7541. $ck = $this->warehouse->read($value['warehouse']);
  7542. $warehouse = $ck['title'];
  7543. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7544. $retreatwarehouse = $tkck['title'];
  7545. $gy = $this->purchase->read($value['purchase']);
  7546. $purchase = $gy['title'];
  7547. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7548. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7549. }
  7550. if(empty($list)){
  7551. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7552. }else{
  7553. $final_list = [];
  7554. foreach($list as $v){
  7555. $final_list[] = array_values($v);
  7556. }
  7557. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7558. array_unshift($final_list,[
  7559. "仓库","SKU","商品名称","时间","数量"
  7560. ]);
  7561. array_unshift($final_list,[
  7562. $title,"","","",""
  7563. ]);
  7564. $merges = [
  7565. [
  7566. "s"=>["r"=>0,"c"=>0],
  7567. "e"=>["r"=>0,"c"=>4]
  7568. ]
  7569. ];
  7570. $cols = [
  7571. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7572. ];
  7573. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7574. }
  7575. }
  7576. }
  7577. //出库、退库导出
  7578. public function _excelctjs()
  7579. {
  7580. $classid = $this->classid->sku();
  7581. $pm = $classid;
  7582. $typeclass = array();
  7583. $tc = $this->typeclass->find_all();
  7584. foreach ($tc as $v) {
  7585. $typeclass[$v['id']] = $v;
  7586. }
  7587. $prc = array();
  7588. $purchase = $this->purchase->find_all();
  7589. foreach ($purchase as $k => $v) {
  7590. $prc[$v['id']] = $v['title'];
  7591. }
  7592. if (isset($_GET['excel'])) {
  7593. $wh = array();
  7594. $w = $this->warehouse->find_all('1=1', 'id,title');
  7595. foreach ($w as $v) {
  7596. $wh[$v['id']] = $v['title'];
  7597. }
  7598. $type = $this->input->get('excel', true);
  7599. $category = $this->input->get('category', true);
  7600. $size = $this->input->get('size', true);
  7601. $grade = $this->input->get('grade', true);
  7602. $color = $this->input->get('color', true);
  7603. $lowe = $this->input->get('lowe', true);
  7604. $sku = $this->input->get('sku', true);
  7605. $title = $this->input->get('title', true);
  7606. $warehouse = $this->input->get('warehouse', true);
  7607. $purchase = $this->input->get('purchase', true);
  7608. $lacetype = $this->input->get('lacetype', true);
  7609. $haircap = $this->input->get('haircap', true);
  7610. $lacecolor = $this->input->get('lacecolor', true);
  7611. $density = $this->input->get('density', true);
  7612. $details = $this->input->get('details', true);
  7613. $state = $this->input->get('state', true);
  7614. $shop = $this->input->get('shop', true);
  7615. $hairnumber = $this->input->get('hairnumber', true);
  7616. $type_leixi = $this->input->get('type', true);
  7617. $cpbz = $this->input->get('cpbz', true);
  7618. $sm = $this->input->get('sm', true);
  7619. $sid = $this->input->get('sid', true);
  7620. $ktime = $this->input->get('ktime', true);
  7621. $jtime = $this->input->get('jtime', true);
  7622. $ktime = strtotime($ktime);
  7623. $jtime = strtotime($jtime);
  7624. //$where = " 1=1 ";
  7625. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7626. $where = " sku != '' ";
  7627. $gj = "";
  7628. $ck = "";
  7629. if ($category) {
  7630. $where .= " and features like '%-$category-%'";
  7631. }
  7632. if ($size) {
  7633. $where .= " and features like '%-$size-%'";
  7634. }
  7635. if ($grade) {
  7636. $where .= " and features like '%-$grade-%'";
  7637. }
  7638. if ($color) {
  7639. $where .= " and features like '%-$color-%'";
  7640. }
  7641. if ($lowe) {
  7642. $where .= " and features like '%-$lowe-%'";
  7643. }
  7644. if ($warehouse) {
  7645. $where .= " and warehouse = '$warehouse'";
  7646. }
  7647. if ($purchase) {
  7648. $where .= " and purchase = '$purchase'";
  7649. }
  7650. if ($state) {
  7651. $where .= " and state = '$state'";
  7652. }
  7653. if ($lacetype) {
  7654. $where .= " and features like '%-$lacetype-%'";
  7655. }
  7656. if ($lacecolor) {
  7657. $where .= " and features like '%-$lacecolor-%'";
  7658. }
  7659. if ($density) {
  7660. $where .= " and features like '%-$density-%'";
  7661. }
  7662. if ($haircap) {
  7663. $where .= " and features like '%-$haircap-%'";
  7664. }
  7665. if ($details) {
  7666. $where .= " and details = '$details'";
  7667. }
  7668. if ($shop) {
  7669. $where .= " and shop like '%$shop%'";
  7670. }
  7671. if ($title) {
  7672. $title = trim($title, ' ');
  7673. $title = trim($title, ' ');
  7674. $where .= " and title like '%$title%'";
  7675. }
  7676. if (!empty($hairnumber)) {
  7677. $where .= " and features like '%-128-%' ";
  7678. if ($hairnumber < 0) {
  7679. $class_list = $this->typeclass->find_all('classid = 43');
  7680. foreach ($class_list as $v) {
  7681. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7682. }
  7683. } else {
  7684. $where .= " and features like '%-$hairnumber-%'";
  7685. }
  7686. }
  7687. if ($type_leixi) {
  7688. $where .= " and type = '$type_leixi'";
  7689. }
  7690. if ($cpbz) {
  7691. $where .= " and cpbz like '%$cpbz%' ";
  7692. }
  7693. if ($sm) {
  7694. $where .= " and sm like '%$sm%' ";
  7695. }
  7696. if ($sku) {
  7697. $sku = trim($sku, ' ');
  7698. $sku = trim($sku, ' ');
  7699. $where .= " and sku like '%$sku%'";
  7700. }
  7701. if ($ktime && $jtime) {
  7702. if ($type == 1) {
  7703. $tl = '出库';
  7704. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7705. } else if ($type == 2) {
  7706. $tl = '退库';
  7707. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7708. } else if ($type == 3) {
  7709. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7710. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7711. } else if ($type == 4) {
  7712. $tl = '出库+零售';
  7713. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7714. } else if ($type == 5) {
  7715. $tl = '零售';
  7716. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7717. }
  7718. }
  7719. $sidwhere = '';
  7720. if ($sid) {
  7721. $sd = "";
  7722. $s = explode(',', trim($sid, ','));
  7723. foreach ($s as $value) {
  7724. $sd .= " id = " . $value . " or";
  7725. }
  7726. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7727. }
  7728. //数据排序
  7729. $order_str = "time desc";
  7730. if (empty($page)) {
  7731. $start = 0;
  7732. $perpage = 1;
  7733. } else {
  7734. $start = ($page - 1) * $perpage;
  7735. }
  7736. //取得信息列表
  7737. if ($type != 3 && $type != 5) {
  7738. if ($type == 1 || $type == 4) {
  7739. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7740. foreach ($info_list as $key => $value) {
  7741. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7742. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7743. $warehouse = $this->warehouse->read($value['warehouse']);
  7744. $info_list[$key]['warehouse'] = $warehouse['title'];
  7745. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7746. $features = explode('-', trim($features, '-'));
  7747. $pm = $classid;
  7748. foreach ($features as $k => $v) {
  7749. if ($v != 0) {
  7750. if (!isset($typeclass[$v])) {
  7751. continue;
  7752. }
  7753. if (isset($pm[$typeclass[$v]['classid']])) {
  7754. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7755. $tz = explode('|', $typeclass[$v]['zh']);
  7756. $pm[$typeclass[$v]['classid']] = $tz[0];
  7757. } else {
  7758. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7759. }
  7760. }
  7761. }
  7762. }
  7763. $zh = implode(" ", $pm);
  7764. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7765. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7766. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7767. $info_list[$key]['features'] = $zh;
  7768. }
  7769. $final_list = [];
  7770. foreach($info_list as $k=>$v){
  7771. $number = "";
  7772. if(!empty($v['orderinfo'])){
  7773. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7774. if(!empty($tmp_info['number'])){
  7775. $number = $tmp_info['number'];
  7776. }
  7777. }
  7778. $final_list[] = [
  7779. 'warehouse'=>$v['warehouse'],
  7780. 'purchase'=>$v['purchase'],
  7781. 'sku'=>$v['sku'],
  7782. 'title'=>$v['title'],
  7783. 'features'=>$v['features'],
  7784. 'label'=>$v['label'],
  7785. 'orderinfo'=>$v['orderinfo'],
  7786. 'number'=>$number,
  7787. 'waybill'=>$v['waybill'],
  7788. 'outk'=>$v['outk'],
  7789. ];
  7790. }
  7791. } else {
  7792. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7793. foreach ($info_list as $key => $value) {
  7794. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7795. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7796. $warehouse = $this->warehouse->read($value['warehouse']);
  7797. $info_list[$key]['warehouse'] = $warehouse['title'];
  7798. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7799. $features = explode('-', trim($features, '-'));
  7800. $pm = $classid;
  7801. foreach ($features as $k => $v) {
  7802. if ($v != 0) {
  7803. if (!isset($typeclass[$v])) {
  7804. continue;
  7805. }
  7806. if (isset($pm[$typeclass[$v]['classid']])) {
  7807. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7808. $tz = explode('|', $typeclass[$v]['zh']);
  7809. $pm[$typeclass[$v]['classid']] = $tz[0];
  7810. } else {
  7811. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7812. }
  7813. }
  7814. }
  7815. }
  7816. $zh = implode(" ", $pm);
  7817. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7818. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7819. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7820. $info_list[$key]['features'] = $zh;
  7821. }
  7822. $final_list = [];
  7823. foreach($info_list as $k=>$v){
  7824. $number = "";
  7825. if(!empty($v['orderinfo'])){
  7826. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7827. if(!empty($tmp_info['number'])){
  7828. $number = $tmp_info['number'];
  7829. }
  7830. }
  7831. $final_list[] = [
  7832. 'warehouse'=>$v['warehouse'],
  7833. 'purchase'=>$v['purchase'],
  7834. 'sku'=>$v['sku'],
  7835. 'title'=>$v['title'],
  7836. 'features'=>$v['features'],
  7837. 'label'=>$v['label'],
  7838. 'orderinfo'=>$v['orderinfo'],
  7839. 'number'=>$number,
  7840. 'waybill'=>$v['waybill'],
  7841. 'retreat'=>$v['retreat'],
  7842. ];
  7843. }
  7844. }
  7845. if(empty($final_list)){
  7846. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7847. }else{
  7848. $end_list = [];
  7849. foreach($final_list as $v){
  7850. $end_list[] = array_values($v);
  7851. }
  7852. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  7853. array_unshift($end_list,[
  7854. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  7855. ]);
  7856. array_unshift($end_list,[
  7857. $title,"","","","","","","","",""
  7858. ]);
  7859. $merges = [
  7860. [
  7861. "s"=>["r"=>0,"c"=>0],
  7862. "e"=>["r"=>0,"c"=>9]
  7863. ]
  7864. ];
  7865. $cols = [
  7866. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  7867. ];
  7868. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  7869. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  7870. ] )));
  7871. }
  7872. } else if ($type == 5) {
  7873. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  7874. foreach ($info_list as $key => $value) {
  7875. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7876. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7877. $warehouse = $this->warehouse->read($value['warehouse']);
  7878. $info_list[$key]['warehouse'] = $warehouse['title'];
  7879. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7880. $features = explode('-', trim($features, '-'));
  7881. $pm = $classid;
  7882. foreach ($features as $k => $v) {
  7883. if ($v != 0) {
  7884. if (!isset($typeclass[$v])) {
  7885. continue;
  7886. }
  7887. if (isset($pm[$typeclass[$v]['classid']])) {
  7888. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7889. $tz = explode('|', $typeclass[$v]['zh']);
  7890. $pm[$typeclass[$v]['classid']] = $tz[0];
  7891. } else {
  7892. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7893. }
  7894. }
  7895. }
  7896. }
  7897. $zh = implode(" ", $pm);
  7898. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7899. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7900. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7901. $info_list[$key]['features'] = $zh;
  7902. }
  7903. if(empty($info_list)){
  7904. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7905. }else{
  7906. $final_list = [];
  7907. foreach($info_list as $v){
  7908. $final_list[] = array_values($v);
  7909. }
  7910. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  7911. array_unshift($final_list,[
  7912. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  7913. ]);
  7914. array_unshift($final_list,[
  7915. $title,"","","","","","",
  7916. ]);
  7917. $merges = [
  7918. [
  7919. "s"=>["r"=>0,"c"=>0],
  7920. "e"=>["r"=>0,"c"=>6]
  7921. ]
  7922. ];
  7923. $cols = [
  7924. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  7925. ];
  7926. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  7927. }
  7928. } else {
  7929. $wh = array();
  7930. $w = $this->warehouse->find_all('1=1', 'id,title');
  7931. foreach ($w as $v) {
  7932. $wh[$v['id']] = $v['title'];
  7933. }
  7934. $wt = array();
  7935. $whlabel_type = $this->whlabel_type->find_all();
  7936. foreach ($whlabel_type as $v) {
  7937. $wt[$v['id']] = $v['title'];
  7938. }
  7939. $classid = $this->classid->sku();
  7940. $list = array();
  7941. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  7942. foreach ($rows as $key => $value) {
  7943. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7944. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7945. $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');
  7946. $details = array();
  7947. $cpid = array();
  7948. $cpbz = array();
  7949. $c = 0;
  7950. $g = 0;
  7951. $x = 0;
  7952. $t = 0;
  7953. $s = 0;
  7954. $q = 0;
  7955. foreach ($sd as $k => $v) {
  7956. if ($v['state'] == 0) {
  7957. $c++;
  7958. }
  7959. if ($v['state'] != 9) {
  7960. $g++;
  7961. }
  7962. if ($v['outk'] > 1) {
  7963. $x++;
  7964. }
  7965. if ($v['retreat'] > 0) {
  7966. $t++;
  7967. }
  7968. if ($v['state'] == 8) {
  7969. $s++;
  7970. }
  7971. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  7972. $q++;
  7973. }
  7974. $details[$v['details']] = $v['details'];
  7975. if ($v['cpid'] != 0) {
  7976. $cpid[$v['cpid']] = $v['cpid'];
  7977. }
  7978. if ($v['cpbz'] != '') {
  7979. $cpbz[$v['cpbz']] = $v['cpbz'];
  7980. }
  7981. }
  7982. if (isset($wt[$value['type']])) {
  7983. $rows[$key]['type'] = $wt[$value['type']];
  7984. } else {
  7985. $rows[$key]['type'] = '未设置';
  7986. }
  7987. $rows[$key]['details'] = implode("、", $details);
  7988. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  7989. $ftime = time() - 15 * 24 * 3600;
  7990. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  7991. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  7992. $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);
  7993. $rows[$key]['c'] = $c;
  7994. $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);
  7995. $rows[$key]['t'] = $t;
  7996. $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'] . '"');
  7997. $rows[$key]['z'] = $z;
  7998. // $jm = $classid;
  7999. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8000. $features = explode('-', trim($features, '-'));
  8001. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8002. }
  8003. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8004. $final_list =[];
  8005. foreach($tmp_list as $k=>$v){
  8006. $final_list[] = [
  8007. "warehouse"=>$v['warehouse'],
  8008. "purchase"=>$v['purchase'],
  8009. "details"=>$v['details'],
  8010. "cpid"=>$v['cpid'],
  8011. "sku"=>$v['sku'],
  8012. "title"=>$v['title'],
  8013. "features"=>$v['pm'],
  8014. "cpbz"=>$v['cpbz'],
  8015. "sm"=>$v['sm'],
  8016. "type"=>$v['type'],
  8017. "g"=>$v["g"],
  8018. "c"=>$v["c"],
  8019. "x"=>$v["x"],
  8020. "t"=>$v["t"],
  8021. "z"=>$v["z"],
  8022. "jm"=>$v["jm"],
  8023. "weight"=>$v["weight"],
  8024. "asd"=>$v["asd"],
  8025. ];
  8026. }
  8027. if(empty($final_list)){
  8028. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8029. }else{
  8030. $end_list = [];
  8031. foreach($final_list as $v){
  8032. $end_list[] = array_values($v);
  8033. }
  8034. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8035. array_unshift($end_list,[
  8036. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8037. ]);
  8038. array_unshift($end_list,[
  8039. $title,"","","","","","","","","","","","","","","","","",""
  8040. ]);
  8041. $merges = [
  8042. [
  8043. "s"=>["r"=>0,"c"=>0],
  8044. "e"=>["r"=>0,"c"=>6]
  8045. ]
  8046. ];
  8047. $cols = [
  8048. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8049. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8050. ];
  8051. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8052. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8053. ])));
  8054. }
  8055. }
  8056. }
  8057. }
  8058. public function _exceljxcjs(){
  8059. $classid = $this->classid->sku();
  8060. $pm = $classid;
  8061. $typeclass = array();
  8062. $tc = $this->typeclass->find_all();
  8063. foreach ($tc as $v) {
  8064. $typeclass[$v['id']] = $v;
  8065. }
  8066. $prc = array();
  8067. $purchase = $this->purchase->find_all();
  8068. foreach ($purchase as $k => $v) {
  8069. $prc[$v['id']] = $v['title'];
  8070. }
  8071. if(!isset($_GET['excel'])){
  8072. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8073. }
  8074. $where = "sku != 'Preset'";
  8075. //数据排序
  8076. $order_str = "id desc";
  8077. if (empty($page)) {
  8078. $start = 0;
  8079. $perpage = 1;
  8080. } else {
  8081. $start = ($page - 1) * $perpage;
  8082. }
  8083. $category = $this->input->get('category', true);
  8084. $warehouse = $this->input->get('warehouse', true);
  8085. $excelid = $this->input->get('sid', true);
  8086. if ($category) {
  8087. $where .= " and features like '%-$category-%'";
  8088. }
  8089. if ($warehouse) {
  8090. $where .= " and warehouse = '$warehouse'";
  8091. }
  8092. $xzid = '';
  8093. if ($excelid) {
  8094. $excelid = explode(',', trim($excelid, ','));
  8095. foreach ($excelid as $key => $value) {
  8096. $xzid .= " id = " . $value . " or";
  8097. }
  8098. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8099. }
  8100. $wt = array();
  8101. $whlabel_type = $this->whlabel_type->find_all();
  8102. foreach ($whlabel_type as $v) {
  8103. $wt[$v['id']] = $v['title'];
  8104. }
  8105. $wh = array();
  8106. $w = $this->warehouse->find_all('1=1', 'id,title');
  8107. foreach ($w as $v) {
  8108. $wh[$v['id']] = $v['title'];
  8109. }
  8110. $list = array();
  8111. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8112. foreach ($rows as $key => $value) {
  8113. if (isset($wt[$value['type']])) {
  8114. $rows[$key]['type'] = $wt[$value['type']];
  8115. } else {
  8116. $rows[$key]['type'] = '未设置';
  8117. }
  8118. $bm = '03';
  8119. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8120. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8121. $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');
  8122. $details = array();
  8123. $cpid = array();
  8124. $cpbz = array();
  8125. $c = 0;
  8126. $g = 0;
  8127. $x = 0;
  8128. $t = 0;
  8129. $s = 0;
  8130. $q = 0;
  8131. foreach ($sd as $k => $v) {
  8132. if ($v['state'] == 0) {
  8133. $c++;
  8134. if ($v['cpid'] != 0) {
  8135. $cpid[$v['cpid']] = $v['cpid'];
  8136. }
  8137. if ($v['cpbz'] != '') {
  8138. $cpbz[$v['cpbz']] = $v['cpbz'];
  8139. }
  8140. }
  8141. if ($v['state'] != 9) {
  8142. $g++;
  8143. }
  8144. if ($v['state'] == 1) {
  8145. $x++;
  8146. }
  8147. if ($v['state'] == 2) {
  8148. $t++;
  8149. }
  8150. if ($v['state'] == 8) {
  8151. $s++;
  8152. }
  8153. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8154. $q++;
  8155. }
  8156. $details[$v['details']] = $v['details'];
  8157. }
  8158. $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'] . '"');
  8159. $rows[$key]['details'] = implode("、", $details);
  8160. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8161. $number = $value['number'];
  8162. $ftime = time() - 15 * 24 * 3600;
  8163. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8164. $rows[$key]['number'] = $g;
  8165. $rows[$key]['c'] = $c;
  8166. $rows[$key]['x'] = $x;
  8167. $rows[$key]['t'] = $t;
  8168. $rows[$key]['s'] = $s;
  8169. $rows[$key]['q'] = $q;
  8170. $rows[$key]['z'] = $z;
  8171. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8172. $features = explode('-', trim($features, '-'));
  8173. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8174. }
  8175. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8176. $final_list = [];
  8177. foreach ($list as $k => $v) {
  8178. if (empty($v['sku'])) {
  8179. continue;
  8180. }
  8181. $final_list[] = [
  8182. $v["warehouse"],
  8183. $v["purchase"],
  8184. $v["details"],
  8185. $v["cpid"],
  8186. $v["dbcontent"],
  8187. $v["sku"],
  8188. $v["bm"],
  8189. $v["jm"],
  8190. $v["title"],
  8191. $v["pm"],
  8192. $v["cpbz"],
  8193. $v["sm"],
  8194. $v["type"],
  8195. $v["number"],
  8196. $v["c"],
  8197. $v["x"],
  8198. $v["t"],
  8199. $v["s"],
  8200. $v["q"],
  8201. $v["z"],
  8202. $v['weight'],
  8203. ];
  8204. }
  8205. if(empty($final_list)){
  8206. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8207. }
  8208. $title = "总进销存统计表";
  8209. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8210. $merges = [
  8211. [
  8212. "s"=>["r"=>0,"c"=>0],
  8213. "e"=>["r"=>0,"c"=>21]
  8214. ]
  8215. ];
  8216. $cols = [
  8217. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8218. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8219. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8220. ];
  8221. array_unshift($final_list, $first_row);
  8222. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8223. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8224. }
  8225. public function _summaryjs($arg_array)
  8226. {
  8227. $prc = array();
  8228. $purchase = $this->purchase->find_all();
  8229. foreach ($purchase as $k => $v) {
  8230. $prc[$v['id']] = $v['title'];
  8231. }
  8232. if (isset($_GET['excel'])) {
  8233. $ktime = $this->input->get('ktime', true);
  8234. $jtime = $this->input->get('jtime', true);
  8235. $ktime = strtotime($ktime);
  8236. $jtime = strtotime($jtime);
  8237. $where = "1=1";
  8238. if ($ktime && $jtime) {
  8239. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8240. }
  8241. //数据排序
  8242. $order_str = "time desc";
  8243. if (empty($page)) {
  8244. $start = 0;
  8245. $perpage = 1;
  8246. } else {
  8247. $start = ($page - 1) * $perpage;
  8248. }
  8249. //取得信息列表
  8250. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8251. foreach ($info_list as $key => $value) {
  8252. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8253. $warehouse = $this->warehouse->read($value['warehouse']);
  8254. $info_list[$key]['warehouse'] = $warehouse['title'];
  8255. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8256. $details = array();
  8257. $cpid = array();
  8258. foreach ($x as $k => $v) {
  8259. if ($v['details'] != '') {
  8260. $details[$v['details']] = $v['details'];
  8261. }
  8262. if ($v['cpid'] != 0) {
  8263. $cpid[$v['cpid']] = $v['cpid'];
  8264. }
  8265. }
  8266. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8267. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8268. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8269. $info_list[$key]['s'] = $s;
  8270. $info_list[$key]['x'] = count($x);
  8271. }
  8272. if(empty($info_list)){
  8273. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8274. }
  8275. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8276. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8277. $merges = [
  8278. [
  8279. "s"=>["r"=>0,"c"=>0],
  8280. "e"=>["r"=>0,"c"=>7]
  8281. ]
  8282. ];
  8283. $cols = [
  8284. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8285. ];
  8286. $final_list = [];
  8287. foreach($info_list as $k => $v){
  8288. $final_list[] = array_values($v);
  8289. }
  8290. array_unshift($final_list, $first_row);
  8291. array_unshift($final_list,[
  8292. $title,"","","","","","","","",
  8293. ]);
  8294. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8295. $titlename = "<table border=1>
  8296. <tr align='center'>
  8297. <td>仓库</td>
  8298. <td>供应商</td>
  8299. <td>出库位置</td>
  8300. <td>出库编码</td>
  8301. <td>SKU</td>
  8302. <td>产品名</td>
  8303. <td>总剩余库存</td>
  8304. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8305. </tr>
  8306. </table>";
  8307. $filename = $title . ".xls";
  8308. $tail = "";
  8309. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8310. }
  8311. }
  8312. public function _uckjs()
  8313. {
  8314. if (isset($_GET['excel'])) {
  8315. $tc = array();
  8316. $typeclass = $this->typeclass->find_all();
  8317. foreach ($typeclass as $v) {
  8318. $tc[$v['id']] = $v['zh'];
  8319. }
  8320. $first_row = [
  8321. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8322. ];
  8323. $t = array();
  8324. $rq = '';
  8325. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8326. $ts = $ts / (24 * 3600);
  8327. for ($i = 0; $i < $ts; $i++) {
  8328. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8329. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8330. }
  8331. $day_len = count($t);
  8332. $first_row[] = "本月出库";
  8333. $merges = [
  8334. ];
  8335. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8336. $excel_key = 1;
  8337. $final_list = [];
  8338. foreach ($info_list as $k => $v) {
  8339. $features = explode('-', trim($v['features'], '-'));
  8340. if (!isset($features[3]) || !isset($features[4])) {
  8341. continue;
  8342. }
  8343. $tmp = [];
  8344. $tmp[0] = $tc[$features[0]]; //类型
  8345. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8346. $tmp[2] = $tc[$features[4]]; //曲度
  8347. $tmp[3] = '';
  8348. if (isset($data[$k][1])) {
  8349. $tmp[3] .=$tmp[1];
  8350. }
  8351. if (isset($data[$k][2])) {
  8352. $tmp[3] .= $tmp[2];
  8353. }
  8354. if (isset($features[5])) {
  8355. $tmp[3] .= $tc[$features[5]];
  8356. }
  8357. if (isset($features[2])) {
  8358. $tmp[3] .= $tc[$features[2]];
  8359. }
  8360. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8361. $tmp[4] = $v['sku'];
  8362. $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())) . '))'); //月初库存
  8363. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8364. $tmp[7] ="";
  8365. $tmp[8] ="";
  8366. $byck = 0;
  8367. foreach ($t as $vv) {
  8368. $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));
  8369. $tmp[] = ($sl > 0) ? $sl : '';
  8370. $byck += $sl;
  8371. }
  8372. $tmp[] = ($byck > 0) ? $byck : '';
  8373. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8374. // $ztrq = '';
  8375. // $ztsl = '';
  8376. // if (count($zt) > 0) {
  8377. // foreach ($zt as $vv) {
  8378. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8379. // $ztsl .= $vv['num'] . '<br>';
  8380. // }
  8381. // }
  8382. if(empty($zt)){
  8383. $final_list[] = $tmp;
  8384. $excel_key = $excel_key + 1;
  8385. }else{
  8386. $len = count($zt);
  8387. if($len == 1){
  8388. $tmp[7] = $zt[0]['num'] ;
  8389. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8390. $final_list[] = $tmp;
  8391. $excel_key = $excel_key + 1;
  8392. }else{
  8393. foreach($zt as $vv){
  8394. $tmp[7] = "";
  8395. $tmp[8] = "";
  8396. $tmp[7] = $vv['num'];
  8397. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8398. $final_list[] = $tmp;
  8399. }
  8400. $merges[] = [
  8401. "s"=>["r"=>$excel_key,"c"=>0],
  8402. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8403. ];
  8404. $merges[] = [
  8405. "s"=>["r"=>$excel_key,"c"=>1],
  8406. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8407. ];
  8408. $merges[] = [
  8409. "s"=>["r"=>$excel_key,"c"=>2],
  8410. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8411. ];
  8412. $merges[] = [
  8413. "s"=>["r"=>$excel_key,"c"=>3],
  8414. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8415. ];
  8416. $merges[] = [
  8417. "s"=>["r"=>$excel_key,"c"=>4],
  8418. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8419. ];
  8420. $merges[] = [
  8421. "s"=>["r"=>$excel_key,"c"=>5],
  8422. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8423. ];
  8424. $merges[] = [
  8425. "s"=>["r"=>$excel_key,"c"=>6],
  8426. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8427. ];
  8428. for($i=1;$i<=$day_len;$i++){
  8429. $merges[] = [
  8430. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8431. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8432. ];
  8433. }
  8434. $merges[] = [
  8435. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8436. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8437. ];
  8438. $excel_key = $excel_key + $len;
  8439. }
  8440. }
  8441. }
  8442. $title = "详情 " . date("Y-m-d", time());
  8443. if(empty($final_list)){
  8444. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8445. }
  8446. $cols = [
  8447. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8448. ];
  8449. array_unshift($final_list, $first_row);
  8450. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8451. }
  8452. }
  8453. public function _whlabelexcelzhjs(){
  8454. if(empty($_GET['excel'])){
  8455. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8456. }
  8457. $where = "sku != 'Preset' and sku != '' ";
  8458. //数据排序
  8459. $order_str = "id desc";
  8460. if (empty($page)) {
  8461. $start = 0;
  8462. $perpage = 1;
  8463. } else {
  8464. $start = ($page - 1) * $perpage;
  8465. }
  8466. $category = $this->input->get('category', true);
  8467. $warehouse = $this->input->get('warehouse', true);
  8468. $excelid = $this->input->get('sid', true);
  8469. if ($category) {
  8470. $where .= " and features like '%-$category-%'";
  8471. }
  8472. if ($warehouse) {
  8473. $where .= " and warehouse = '$warehouse'";
  8474. }
  8475. $xzid = '';
  8476. if ($excelid) {
  8477. $excelid = explode(',', trim($excelid, ','));
  8478. foreach ($excelid as $key => $value) {
  8479. $xzid .= " id = " . $value . " or";
  8480. }
  8481. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8482. }
  8483. $merges = [
  8484. [
  8485. "s"=>["r"=>0,"c"=>0],
  8486. "e"=>["r"=>0,"c"=>6]
  8487. ]
  8488. ];
  8489. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8490. $excel_index = 2;
  8491. $final_list = [];
  8492. foreach ($rows as $key => $value) {
  8493. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8494. $zh = '';
  8495. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8496. // foreach ($zt_list as $v) {
  8497. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8498. // }
  8499. $zt = array_sum(array_column($zt_list, 'num'));
  8500. $number = $value['number'];
  8501. $ftime = time() - 15 * 24 * 3600;
  8502. $warehouse = $this->warehouse->read($value['warehouse']);
  8503. // $rows[$key]['warehouse'] = $warehouse['title'];
  8504. // $rows[$key]['number'] = $c;
  8505. // $rows[$key]['features'] = $zh;
  8506. //$rows[$key]['hb'] = $c + $zt;
  8507. $tmp = [];
  8508. $tmp[0] = $warehouse['title'];
  8509. $tmp[1] = $value['sku'];
  8510. $tmp[2] = $value['title'];
  8511. $tmp[3] = $c;
  8512. $tmp[4] = "";
  8513. $tmp[5] = $c + $zt;
  8514. if(empty($zt_list)){
  8515. $tmp[4] = "";
  8516. $final_list[] = $tmp;
  8517. $excel_index = $excel_index + 1;
  8518. }else{
  8519. if(count($zt_list) == 1){
  8520. $tmp[4] = "";
  8521. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8522. $final_list[] = $tmp;
  8523. $excel_index = $excel_index + 1;
  8524. }else{
  8525. $len = count($zt_list);
  8526. foreach ($zt_list as $v){
  8527. $tmp[4] = "";
  8528. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8529. $final_list[] = $tmp;
  8530. }
  8531. $merges[] = [
  8532. "s"=>["r"=>$excel_index,"c"=>0],
  8533. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8534. ];
  8535. $merges[] = [
  8536. "s"=>["r"=>$excel_index,"c"=>1],
  8537. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8538. ];
  8539. $merges[] = [
  8540. "s"=>["r"=>$excel_index,"c"=>2],
  8541. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8542. ];
  8543. $merges[] = [
  8544. "s"=>["r"=>$excel_index,"c"=>3],
  8545. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8546. ];
  8547. $merges[] = [
  8548. "s"=>["r"=>$excel_index,"c"=>5],
  8549. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8550. ];
  8551. $excel_index = $excel_index + $len;
  8552. }
  8553. }
  8554. }
  8555. $first_row = [
  8556. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8557. ];
  8558. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8559. if(empty($final_list)){
  8560. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8561. }
  8562. $cols = [
  8563. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8564. ];
  8565. array_unshift($final_list, $first_row);
  8566. array_unshift($final_list, [
  8567. $title,"","","","",""
  8568. ]);
  8569. $end_list = [];
  8570. foreach ($final_list as $key => $value) {
  8571. $end_list[] = array_values($value);
  8572. }
  8573. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8574. }
  8575. //出库、退库导出
  8576. public function _dccrtypejs()
  8577. {
  8578. $classid = $this->classid->sku();
  8579. $pm = $classid;
  8580. $typeclass = array();
  8581. $tc = $this->typeclass->find_all();
  8582. foreach ($tc as $v) {
  8583. $typeclass[$v['id']] = $v;
  8584. }
  8585. $prc = array();
  8586. $purchase = $this->purchase->find_all();
  8587. foreach ($purchase as $k => $v) {
  8588. $prc[$v['id']] = $v['title'];
  8589. }
  8590. if (isset($_GET['sid'])) {
  8591. $wh = array();
  8592. $w = $this->warehouse->find_all('1=1', 'id,title');
  8593. foreach ($w as $v) {
  8594. $wh[$v['id']] = $v['title'];
  8595. }
  8596. $type = $this->input->get('excel', true);
  8597. $category = $this->input->get('category', true);
  8598. $size = $this->input->get('size', true);
  8599. $grade = $this->input->get('grade', true);
  8600. $color = $this->input->get('color', true);
  8601. $lowe = $this->input->get('lowe', true);
  8602. $sku = $this->input->get('sku', true);
  8603. $warehouse = $this->input->get('warehouse', true);
  8604. $lacetype = $this->input->get('lacetype', true);
  8605. $lacecolor = $this->input->get('lacecolor', true);
  8606. $density = $this->input->get('density', true);
  8607. $haircap = $this->input->get('haircap', true);
  8608. $purchase = $this->input->get('purchase', true);
  8609. $title = $this->input->get('title', true);
  8610. $state = $this->input->get('state', true);
  8611. $sid = $this->input->get('sid', true);
  8612. $ktime = $this->input->get('ktime', true);
  8613. $jtime = $this->input->get('jtime', true);
  8614. $ktime = strtotime($ktime);
  8615. $jtime = strtotime($jtime);
  8616. $where = "1=1";
  8617. $gj = "";
  8618. $ck = "";
  8619. if ($category) {
  8620. $where .= " and features like '%-$category-%'";
  8621. }
  8622. if ($size) {
  8623. $where .= " and features like '%-$size-%'";
  8624. }
  8625. if ($grade) {
  8626. $where .= " and features like '%-$grade-%'";
  8627. }
  8628. if ($color) {
  8629. $where .= " and features like '%-$color-%'";
  8630. }
  8631. if ($lowe) {
  8632. $where .= " and features like '%-$lowe-%'";
  8633. }
  8634. if ($warehouse) {
  8635. $where .= " and warehouse = '$warehouse'";
  8636. }
  8637. if ($purchase) {
  8638. $where .= " and purchase = '$purchase'";
  8639. }
  8640. if ($state) {
  8641. $where .= " and state = '$state'";
  8642. }
  8643. if ($lacetype) {
  8644. $where .= " and features like '%-$lacetype-%'";
  8645. }
  8646. if ($lacecolor) {
  8647. $where .= " and features like '%-$lacecolor-%'";
  8648. }
  8649. if ($density) {
  8650. $where .= " and features like '%-$density-%'";
  8651. }
  8652. if ($haircap) {
  8653. $where .= " and features like '%-$haircap-%'";
  8654. }
  8655. if ($title) {
  8656. $title = trim($title, ' ');
  8657. $title = trim($title, ' ');
  8658. $where .= " and title like '%$title%'";
  8659. }
  8660. if ($sku) {
  8661. $sku = trim($sku, ' ');
  8662. $sku = trim($sku, ' ');
  8663. $where .= " and sku like '%$sku%'";
  8664. }
  8665. if ($ktime && $jtime) {
  8666. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8667. }
  8668. $sidwhere = '';
  8669. if ($sid) {
  8670. $sd = "";
  8671. $s = explode(',', trim($sid, ','));
  8672. foreach ($s as $value) {
  8673. $sd .= " id = " . $value . " or";
  8674. }
  8675. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8676. }
  8677. //数据排序
  8678. $order_str = "time desc";
  8679. if (empty($page)) {
  8680. $start = 0;
  8681. $perpage = 1;
  8682. } else {
  8683. $start = ($page - 1) * $perpage;
  8684. }
  8685. $wh = array();
  8686. $w = $this->warehouse->find_all('1=1', 'id,title');
  8687. foreach ($w as $v) {
  8688. $wh[$v['id']] = $v['title'];
  8689. }
  8690. $wt = array();
  8691. $whlabel_type = $this->whlabel_type->find_all();
  8692. foreach ($whlabel_type as $v) {
  8693. $wt[$v['id']] = $v['title'];
  8694. }
  8695. $classid = $this->classid->sku();
  8696. $list = array();
  8697. $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');
  8698. foreach ($rows_r as $key => $value) {
  8699. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8700. $pm = $classid;
  8701. $jm = $classid;
  8702. $rows_r[$key]['enter'] = '入库';
  8703. $rows_r[$key]['time'] = $value['enter'];
  8704. if ($value['rktype'] == 1) {
  8705. $rows_r[$key]['rktype'] = '采购入库';
  8706. } else if ($value['rktype'] == 2) {
  8707. $rows_r[$key]['rktype'] = '盘盈调整';
  8708. } else if ($value['rktype'] == 3) {
  8709. $rows_r[$key]['rktype'] = '其他调整入库';
  8710. } else if ($value['rktype'] == 4) {
  8711. $rows_r[$key]['rktype'] = '其他调整入库';
  8712. } else if ($value['rktype'] == 5) {
  8713. $rows_r[$key]['rktype'] = '退库入库';
  8714. } else if ($value['rktype'] == 6) {
  8715. $rows_r[$key]['rktype'] = '退货可用入库';
  8716. } else if ($value['rktype'] == 7) {
  8717. $rows_r[$key]['rktype'] = '形态转换入库';
  8718. } else {
  8719. $rows_r[$key]['rktype'] = '';
  8720. }
  8721. $features = explode('-', trim($value['features'], '-'));
  8722. foreach ($features as $v) {
  8723. if (isset($typeclass[$v])) {
  8724. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8725. $pm[$typeclass[$v]['classid']] = $zh[0];
  8726. }
  8727. if (isset($typeclass[$v])) {
  8728. if (isset($jm[$typeclass[$v]['classid']])) {
  8729. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8730. }
  8731. }
  8732. }
  8733. $zh = implode(" ", $pm);
  8734. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8735. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8736. $rows_r[$key]['zh'] = $zh;
  8737. $jm = array_filter($jm);
  8738. $rows_r[$key]['features'] = implode("-", $jm);
  8739. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8740. }
  8741. $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');
  8742. foreach ($rows_c as $key => $value) {
  8743. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8744. $pm = $classid;
  8745. $jm = $classid;
  8746. $rows_c[$key]['time'] = $value['outk'];
  8747. $rows_c[$key]['outk'] = '出库';
  8748. if ($value['cktype'] == 1) {
  8749. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8750. } else if ($value['cktype'] == 2) {
  8751. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8752. } else if ($value['cktype'] == 3) {
  8753. $rows_c[$key]['cktype'] = '盘亏调整';
  8754. } else if ($value['cktype'] == 4) {
  8755. $rows_c[$key]['cktype'] = '其他调整出库';
  8756. } else if ($value['cktype'] == 5) {
  8757. $rows_c[$key]['cktype'] = '形态转换出库';
  8758. } else {
  8759. $rows_c[$key]['cktype'] = '';
  8760. }
  8761. unset($rows_c[$key]['state']);
  8762. $features = explode('-', trim($value['features'], '-'));
  8763. foreach ($features as $v) {
  8764. if (isset($typeclass[$v])) {
  8765. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8766. $pm[$typeclass[$v]['classid']] = $zh[0];
  8767. }
  8768. if (isset($typeclass[$v])) {
  8769. if (isset($jm[$typeclass[$v]['classid']])) {
  8770. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8771. }
  8772. }
  8773. }
  8774. $zh = implode(" ", $pm);
  8775. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8776. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8777. $rows_c[$key]['zh'] = $zh;
  8778. $jm = array_filter($jm);
  8779. $rows_c[$key]['features'] = implode("-", $jm);
  8780. $rows_c[$key]['number'] = 1;
  8781. }
  8782. $merged = $rows_r;
  8783. foreach ($rows_c as $key => $value) {
  8784. if (isset($merged[$key])) {
  8785. $merged[] = $value;
  8786. } else {
  8787. $merged[$key] = $value;
  8788. }
  8789. }
  8790. usort($merged, function ($a, $b) {
  8791. return $a['time'] - $b['time'];
  8792. });
  8793. foreach ($merged as $key => $value) {
  8794. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8795. }
  8796. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8797. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8798. $cols = [
  8799. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8800. ];
  8801. $final_list= [];
  8802. foreach($merged as $key => $value){
  8803. $final_list[] = array_values($value) ;
  8804. }
  8805. if(empty($merged)){
  8806. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8807. }
  8808. array_unshift($final_list, $first_row);
  8809. $end_list = [];
  8810. foreach ($final_list as $key => $value) {
  8811. $end_list[] = array_values($value);
  8812. }
  8813. $merges = [];
  8814. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8815. }
  8816. }
  8817. }