Whlabel.php 315 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297
  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 == 'presetedittwo') //预设库存导入
  141. {
  142. $this->_presetedittwo($arg_array);
  143. } else if ($arg == 'summary') //汇总导出
  144. {
  145. $this->_summary($arg_array);
  146. } else if ($arg == 'manifest') //usps发货清单
  147. {
  148. $this->_manifest();
  149. } else if ($arg == 'abnormal') //占单异常
  150. {
  151. $this->_abnormal();
  152. } else if ($arg == 'error') //0库存SKU
  153. {
  154. $this->_error();
  155. } else if ($arg == 'errorexcel') //0库存SKU导出
  156. {
  157. $this->_errorexcel();
  158. } else if ($arg == 'db') {
  159. $this->_db();
  160. } else if ($arg == 'dbrk') {
  161. $this->_dbrk();
  162. } else if ($arg == 'whlabelczdc') {
  163. $this->_whlabelczdc();
  164. } else if ($arg == 'print') {
  165. $this->_print($arg_array);
  166. } else if ($arg == 'usaprint') {
  167. $this->_usaprint($arg_array);
  168. } else if ($arg == 'printck') {
  169. $this->_printck($arg_array);
  170. } else if ($arg == 'printrk') {
  171. $this->_printrk($arg_array);
  172. } else if ($arg == 'printxzrk') {
  173. $this->_printxzrk($arg_array);
  174. } else if ($arg == 'printexcel') {
  175. $this->_printexcel($arg_array);
  176. } else if ($arg == 'uck') {
  177. $this->_uck();
  178. } else if ($arg == 'whlabelexcelzh') {
  179. $this->_whlabelexcelzh();
  180. } else if ($arg == 'fc') {
  181. $this->_fc();
  182. } else if ($arg == 'fcmb') {
  183. $this->_fcmb();
  184. } else if ($arg == 'fcexcel') {
  185. $this->_fcexcel();
  186. } else if ($arg == 'fcjxc') {
  187. $this->_fcjxc($arg_array);
  188. } else if ($arg == '0kcdel') {
  189. $this->_0kcdel(); //导表删除0库存
  190. } else if ($arg == 'gbhtype') {
  191. $this->_gbhtype(); //更改备货状态
  192. } else if($arg == 'excelrjs'){
  193. $this->_excelrjs();
  194. } else if($arg == 'excelctjs'){
  195. $this->_excelctjs();
  196. }else if ($arg == 'exceljxcjs') //进销存信息导出
  197. {
  198. $this->_exceljxcjs();
  199. } else if ($arg == 'summaryjs') //汇总导出
  200. {
  201. $this->_summaryjs($arg_array);
  202. }else if($arg == 'uckjs'){
  203. $this->_uckjs();
  204. }else if ($arg == 'whlabelexcelzhjs') {
  205. $this->_whlabelexcelzhjs();
  206. }else if($arg == 'dccrtypejs'){
  207. $this->_dccrtypejs();
  208. }else if($arg == 'errorexceljs'){
  209. $this->_errorexceljs();
  210. }else if($arg == "w_t_cs"){
  211. $this->_w_t_cs(); //首页
  212. }else {
  213. $this->_index();
  214. }
  215. }
  216. public function _w_t_cs(){
  217. $vip = 0;
  218. if (isset($_SESSION['api'])) {
  219. $user = $this->user->get_api($_SESSION['api']);
  220. $fgshop = "";
  221. $sid = "";
  222. $usersp = explode('|', trim($user['shop'], '|'));
  223. foreach ($usersp as $value) {
  224. $fgshop .= " shop = " . $value . " or";
  225. $sid .= " id = " . $value . " or";
  226. }
  227. if ($user['vip'] == 1) {
  228. $vip = 1;
  229. }
  230. } else {
  231. header('Location: /');
  232. exit;
  233. }
  234. $prc = array();
  235. $purchase = $this->purchase->find_all();
  236. foreach ($purchase as $k => $v) {
  237. $prc[$v['id']] = $v['title'];
  238. }
  239. $company = array();
  240. $ct = $this->company->find_all();
  241. foreach ($ct as $k => $v) {
  242. $company[$v['id']] = $v['title'];
  243. }
  244. $sp = array();
  245. $s = $this->shop->find_all('1=1', 'id,shopname');
  246. foreach ($s as $v) {
  247. $sp[$v['id']] = $v['shopname'];
  248. }
  249. $wh = array();
  250. $w = $this->warehouse->find_all('1=1', 'id,title');
  251. foreach ($w as $v) {
  252. $wh[$v['id']] = $v['title'];
  253. }
  254. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  255. $this->data['shop'] = $wlshop;
  256. $this->data['vip'] = $vip;
  257. $this->_Template('whlabel_typejs', $this->data);
  258. }
  259. //管理
  260. public function _index()
  261. {
  262. $post = $this->input->post(NULL, TRUE);
  263. if (isset($post['page'])) {
  264. $page = $this->input->post('page', true);
  265. $perpage = $this->input->post('perpage', true);
  266. $sku = $this->input->post('sku', true);
  267. $number = $this->input->post('number', true);
  268. $warehouse = $this->input->post('warehouse', true);
  269. $purchase = $this->input->post('purchase', true);
  270. $orderinfo = $this->input->post('orderinfo', true);
  271. $waybill = $this->input->post('waybill', true);
  272. $category = $this->input->post('category', true);
  273. $size = $this->input->post('size', true);
  274. $grade = $this->input->post('grade', true);
  275. $color = $this->input->post('color', true);
  276. $lowe = $this->input->post('lowe', true);
  277. $state = $this->input->post('state', true);
  278. $label = $this->input->post('label', true);
  279. $timetk = $this->input->post('timetkk', true);
  280. $timetj = $this->input->post('timetjj', true);
  281. $timetk = strtotime($timetk);
  282. $timetj = strtotime($timetj);
  283. $where = "1=1 ";
  284. if ($timetk && $timetj) {
  285. $where .= " and time > '$timetk' and time < '$timetj'";
  286. }
  287. if ($sku) {
  288. $where .= " and sku = '$sku'";
  289. }
  290. if ($number) {
  291. $where .= " and number = '$number'";
  292. }
  293. if ($warehouse) {
  294. $where .= " and warehouse = '$warehouse'";
  295. }
  296. if ($purchase) {
  297. $where .= " and purchase = '$purchase'";
  298. }
  299. if ($orderinfo) {
  300. $where .= " and orderinfo = '$orderinfo'";
  301. }
  302. if ($waybill) {
  303. $where .= " and waybill = '$waybill'";
  304. }
  305. if ($category) {
  306. $where .= " and features like '%-$category-%'";
  307. }
  308. if ($size) {
  309. $where .= " and features like '%-$size-%'";
  310. }
  311. if ($grade) {
  312. $where .= " and features like '%-$grade-%'";
  313. }
  314. if ($color) {
  315. $where .= " and features like '%-$color-%'";
  316. }
  317. if ($lowe) {
  318. $where .= " and features like '%-$lowe-%'";
  319. }
  320. if ($label) {
  321. $where .= " and label = '$label'";
  322. }
  323. if ($state != '') {
  324. $where .= " and state = '$state'";
  325. }
  326. //数据排序
  327. $order_str = "time desc";
  328. if (empty($page)) {
  329. $start = 0;
  330. $perpage = 1;
  331. } else {
  332. $start = ($page - 1) * $perpage;
  333. }
  334. //取得信息列表
  335. $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);
  336. foreach ($info_list as $key => $value) {
  337. $warehouse = $this->warehouse->read($value['warehouse']);
  338. $info_list[$key]['warehouse'] = $warehouse['title'];
  339. $purchase = $this->purchase->read($value['purchase']);
  340. $info_list[$key]['purchase'] = $purchase['title'];
  341. if ($value['enter'] != 0) {
  342. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  343. } else {
  344. $info_list[$key]['enter'] = "";
  345. }
  346. if ($value['outk'] != 0) {
  347. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  348. } else {
  349. $info_list[$key]['outk'] = "";
  350. }
  351. if ($value['printing'] != 0) {
  352. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  353. } else {
  354. $info_list[$key]['printing'] = "";
  355. }
  356. if ($value['orderinfo'] == 0) {
  357. $info_list[$key]['orderinfo'] = "";
  358. }
  359. if ($value['waybill'] == 0) {
  360. $info_list[$key]['waybill'] = "";
  361. }
  362. if ($value['state'] == 0) {
  363. $info_list[$key]['state'] = "在库";
  364. } else if ($value['state'] == 1) {
  365. $info_list[$key]['state'] = "出库";
  366. } else if ($value['state'] == 2) {
  367. $info_list[$key]['state'] = "退库";
  368. } else if ($value['state'] == 3) {
  369. $info_list[$key]['state'] = "调拨中";
  370. } else if ($value['state'] == 4) {
  371. $info_list[$key]['state'] = "再加工";
  372. } else if ($value['state'] == 5) {
  373. $info_list[$key]['state'] = "维修中";
  374. } else if ($value['state'] == 6) {
  375. $info_list[$key]['state'] = "盘亏";
  376. } else if ($value['state'] == 7) {
  377. $info_list[$key]['state'] = "更换标签";
  378. } else if ($value['state'] == 8) {
  379. $info_list[$key]['state'] = "其它";
  380. } else if ($value['state'] == 9) {
  381. $info_list[$key]['state'] = "预设";
  382. } else if ($value['state'] == 10) {
  383. $info_list[$key]['state'] = "美店零售";
  384. }
  385. if ($value['text'] == "") {
  386. $info_list[$key]['text'] = "";
  387. }
  388. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  389. }
  390. $total = $this->whlabel->find_count($where);
  391. $pagenum = ceil($total / $perpage);
  392. $over = $total - ($start + $perpage);
  393. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  394. echo json_encode($rows);
  395. exit;
  396. }
  397. if (isset($post['outsku'])) {
  398. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  399. $cz = $this->input->post('cz', true);
  400. if ($cz == '1') {
  401. $sku = $this->input->post('outsku', true);
  402. if ($sku) {
  403. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  404. if (count($data) < 1) {
  405. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  406. exit;
  407. }
  408. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  409. echo json_encode(array('success' => true));
  410. exit;
  411. }
  412. } else {
  413. $sku = $this->input->post('outsku', true);
  414. if ($sku) {
  415. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  416. if (count($data) < 1) {
  417. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  418. exit;
  419. }
  420. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  421. echo json_encode(array('success' => true));
  422. exit;
  423. }
  424. }
  425. }
  426. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  427. $this->_Template('whlabel', $this->data);
  428. }
  429. //在库标签
  430. public function _existence()
  431. {
  432. $post = $this->input->post(NULL, TRUE);
  433. if (isset($post['s'])) {
  434. $id_arr = $this->input->post('s');
  435. $id_arr = explode(',', $id_arr);
  436. if (!$id_arr) {
  437. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  438. exit;
  439. }
  440. //循环删除记录
  441. foreach ($id_arr as $v) {
  442. $sid = $this->whlabel->read($v);
  443. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  444. if ($count > 0) {
  445. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  446. exit;
  447. }
  448. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  449. if (count($zt) > 0) {
  450. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  451. exit;
  452. }
  453. $this->whlabel->remove($v);
  454. }
  455. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  456. exit;
  457. }
  458. if (isset($post['page'])) {
  459. $page = $this->input->post('page', true);
  460. $perpage = $this->input->post('perpage', true);
  461. $warehouse = $this->input->post('warehouse', true);
  462. $label = $this->input->post('label', true);
  463. $where = "1=1 and state = 0";
  464. if ($warehouse) {
  465. $where .= " and warehouse = '$warehouse'";
  466. }
  467. if ($label) {
  468. $where .= " and label = '$label'";
  469. }
  470. //数据排序
  471. $order_str = "time asc";
  472. if (empty($page)) {
  473. $start = 0;
  474. $perpage = 1;
  475. } else {
  476. $start = ($page - 1) * $perpage;
  477. }
  478. //取得信息列表
  479. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  480. foreach ($info_list as $key => $value) {
  481. if ($value['enter'] != 0) {
  482. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  483. } else {
  484. $info_list[$key]['enter'] = "";
  485. }
  486. if ($value['printing'] != 0) {
  487. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  488. } else {
  489. $info_list[$key]['printing'] = "";
  490. }
  491. }
  492. $total = $this->whlabel->find_count($where);
  493. $pagenum = ceil($total / $perpage);
  494. $over = $total - ($start + $perpage);
  495. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  496. echo json_encode($rows);
  497. exit;
  498. }
  499. $this->_Template('whlabel_existence', $this->data);
  500. }
  501. //进销存浏览
  502. public function _typedy($arg_array)
  503. {
  504. $prc = array();
  505. $purchase = $this->purchase->find_all();
  506. foreach ($purchase as $k => $v) {
  507. $prc[$v['id']] = $v['title'];
  508. }
  509. $post = $this->input->post(NULL, TRUE);
  510. if (isset($post['page'])) {
  511. $page = $this->input->post('page', true);
  512. $perpage = $this->input->post('perpage', true);
  513. $category = $this->input->post('category', true);
  514. $size = $this->input->post('size', true);
  515. $grade = $this->input->post('grade', true);
  516. $color = $this->input->post('color', true);
  517. $lowe = $this->input->post('lowe', true);
  518. $sku = $this->input->post('sku');
  519. $title = $this->input->post('title');
  520. $warehouse = $this->input->post('warehouse', true);
  521. $usa = $this->input->post('usa', true);
  522. $purchase = $this->input->post('purchase', true);
  523. $lacetype = $this->input->post('lacetype', true);
  524. $haircap = $this->input->post('haircap', true);
  525. $density = $this->input->post('density', true);
  526. $details = $this->input->post('details', true);
  527. $state = $this->input->post('state', true);
  528. $lacecolor = $this->input->post('lacecolor', true);
  529. $hairnumber = $this->input->post('hairnumber', true);
  530. $cklx = $this->input->post('cklx', true);
  531. $ktime = $this->input->post('ktime', true);
  532. $jtime = $this->input->post('jtime', true);
  533. $sm = $this->input->post('sm', true);
  534. $cpbz = $this->input->post('cpbz', true);
  535. $type = $this->input->post('type', true);
  536. $ktime = strtotime($ktime);
  537. $jtime = strtotime($jtime);
  538. $where = "1=1";
  539. $gj = "";
  540. $ck = "";
  541. if ($usa) {
  542. if (!$warehouse) {
  543. $where .= " and (warehouse = '5' or warehouse = '8')";
  544. }
  545. }
  546. if ($warehouse) {
  547. $where .= " and warehouse = '$warehouse'";
  548. }
  549. if ($details) {
  550. $where .= " and details = '$details'";
  551. }
  552. if ($purchase) {
  553. $where .= " and purchase = '$purchase'";
  554. }
  555. if (isset($state)) {
  556. if($state >-1){
  557. $where .= " and state = '$state'";
  558. }
  559. }
  560. if ($lacetype) {
  561. $where .= " and features like '%-$lacetype-%'";
  562. }
  563. if ($category) {
  564. $where .= " and features like '%-$category-%'";
  565. }
  566. if ($size) {
  567. $where .= " and features like '%-$size-%'";
  568. }
  569. if ($grade) {
  570. $where .= " and features like '%-$grade-%'";
  571. }
  572. if ($color) {
  573. $where .= " and features like '%-$color-%'";
  574. }
  575. if ($lowe) {
  576. $where .= " and features like '%-$lowe-%'";
  577. }
  578. if ($haircap) {
  579. $where .= " and features like '%-$haircap-%'";
  580. }
  581. if ($density) {
  582. $where .= " and features like '%-$density-%'";
  583. }
  584. if ($lacecolor) {
  585. $where .= " and features like '%-$lacecolor-%'";
  586. }
  587. if($sm){
  588. $where .= " and sm like '%".$sm."%'";
  589. }
  590. if($cpbz){
  591. $where .= " and cpbz like '%".$cpbz."%'";
  592. }
  593. if($type){
  594. $where .= " and type = ".$type."";
  595. }
  596. if (!empty($hairnumber)) {
  597. $where .= " and features like '%-128-%' ";
  598. if ($hairnumber < 0) {
  599. $class_list = $this->typeclass->find_all('classid = 43');
  600. foreach ($class_list as $v) {
  601. $where .= " and features not like '%-" . $v['id'] . "-%'";
  602. }
  603. } else {
  604. $where .= " and features like '%-$hairnumber-%'";
  605. }
  606. }
  607. $where_add = '';
  608. if ($cklx) {
  609. $shop = $this->shop->read($cklx);
  610. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  611. }
  612. if ($ktime && $jtime) {
  613. $gj = " and enter > '$ktime' and enter < '$jtime'";
  614. $ck = " and outk > '$ktime' and outk < '$jtime'";
  615. }
  616. //数据排序
  617. $order_str = "id desc";
  618. if (empty($page)) {
  619. $start = 0;
  620. $perpage = 1;
  621. } else {
  622. $start = ($page - 1) * $perpage;
  623. }
  624. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  625. if ($sku) {
  626. $sku = trim($sku, ' ');
  627. $sku = trim($sku, ' ');
  628. $where .= " and sku like '%$sku%'";
  629. $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);
  630. } else if ($title) {
  631. $title = trim($title, ' ');
  632. $title = trim($title, ' ');
  633. $where .= " and title like '%$title%'";
  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. } else {
  636. //$where .= " and time > '$ktime' and time < '$jtime'";
  637. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  638. }
  639. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  640. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  641. foreach ($info_list as $k => $v) {
  642. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  643. unset($info_list[$k]['pm']);
  644. unset($info_list[$k]['jm']);
  645. unset($info_list[$k]['bm']);
  646. }
  647. //取得信息列表
  648. $rows = array();
  649. $list = array();
  650. foreach ($info_list as $key => $value) {
  651. $warehouse = $this->warehouse->read($value['warehouse']);
  652. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  653. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  654. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  655. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  656. $info_list[$key]['label'] = $value['sm'];
  657. $number = $value['number'];
  658. $ftime = time() - 15 * 24 * 3600;
  659. $info_list[$key]['warehouse'] = $warehouse['title'];
  660. $info_list[$key]['features'] = count($c);
  661. $z = count($z); //查看订单号
  662. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  663. $ztdata = '';
  664. if (count($zt) > 0) {
  665. foreach ($zt as $vv) {
  666. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  667. }
  668. }
  669. $info_list[$key]['number'] = $ztdata;
  670. $info_list[$key]['sm'] = $z;
  671. $details = array();
  672. $cpid = array();
  673. foreach ($c as $k => $v) {
  674. $details[$v['details']] = $v['details'];
  675. if ($v['cpid'] != 0) {
  676. $cpid[$v['cpid']] = $v['cpid'];
  677. }
  678. }
  679. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  680. if ($value['shop'] != '') {
  681. $shop = explode(',', trim($value['shop'], ','));
  682. $shop = $this->shop->read($shop[0]);
  683. $info_list[$key]['shop'] = $shop['shopname'];
  684. }
  685. }
  686. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  687. $pagenum = ceil($total / $perpage);
  688. $over = $total - ($start + $perpage);
  689. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  690. echo json_encode($rows);
  691. exit;
  692. }
  693. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  694. $this->_Template('whlabel_typedy', $this->data);
  695. }
  696. //进销存浏览
  697. public function _typedy_ck($arg_array)
  698. {
  699. $prc = array();
  700. $purchase = $this->purchase->find_all();
  701. foreach ($purchase as $k => $v) {
  702. $prc[$v['id']] = $v['title'];
  703. }
  704. $post = $this->input->post(NULL, TRUE);
  705. if (isset($post['page'])) {
  706. $page = $this->input->post('page', true);
  707. $perpage = $this->input->post('perpage', true);
  708. $category = $this->input->post('category', true);
  709. $size = $this->input->post('size', true);
  710. $grade = $this->input->post('grade', true);
  711. $color = $this->input->post('color', true);
  712. $lowe = $this->input->post('lowe', true);
  713. $sku = $this->input->post('sku');
  714. $title = $this->input->post('title');
  715. $warehouse = $this->input->post('warehouse', true);
  716. $usa = $this->input->post('usa', true);
  717. $purchase = $this->input->post('purchase', true);
  718. $lacetype = $this->input->post('lacetype', true);
  719. $haircap = $this->input->post('haircap', true);
  720. $density = $this->input->post('density', true);
  721. $details = $this->input->post('details', true);
  722. $state = $this->input->post('state', true);
  723. $lacecolor = $this->input->post('lacecolor', true);
  724. $cklx = $this->input->post('cklx', true);
  725. $ktime = $this->input->post('ktime', true);
  726. $jtime = $this->input->post('jtime', true);
  727. $ktime = strtotime($ktime);
  728. $jtime = strtotime($jtime);
  729. $where = "1=1";
  730. $gj = "";
  731. $ck = "";
  732. if ($lacetype) {
  733. $where .= " and features like '%-$lacetype-%'";
  734. }
  735. if ($category) {
  736. $where .= " and features like '%-$category-%'";
  737. }
  738. if ($size) {
  739. $where .= " and features like '%-$size-%'";
  740. }
  741. if ($grade) {
  742. $where .= " and features like '%-$grade-%'";
  743. }
  744. if ($color) {
  745. $where .= " and features like '%-$color-%'";
  746. }
  747. if ($lowe) {
  748. $where .= " and features like '%-$lowe-%'";
  749. }
  750. if ($haircap) {
  751. $where .= " and features like '%-$haircap-%'";
  752. }
  753. if ($density) {
  754. $where .= " and features like '%-$density-%'";
  755. }
  756. if ($lacecolor) {
  757. $where .= " and features like '%-$lacecolor-%'";
  758. }
  759. if ($usa) {
  760. if (!$warehouse) {
  761. $where .= " and (warehouse = '5' or warehouse = '8')";
  762. }
  763. }
  764. if ($warehouse) {
  765. $where .= " and warehouse = '$warehouse'";
  766. }
  767. if ($details) {
  768. $where .= " and details = '$details'";
  769. }
  770. if ($purchase) {
  771. $where .= " and purchase = '$purchase'";
  772. }
  773. if ($state) {
  774. $where .= " and state = '$state'";
  775. }
  776. $where_add = '';
  777. if ($cklx) {
  778. $shop = $this->shop->read($cklx);
  779. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  780. }
  781. if ($ktime && $jtime) {
  782. $gj = " and enter > '$ktime' and enter < '$jtime'";
  783. $ck = " and outk > '$ktime' and outk < '$jtime'";
  784. }
  785. //数据排序
  786. $order_str = "id desc";
  787. if (empty($page)) {
  788. $start = 0;
  789. $perpage = 1;
  790. } else {
  791. $start = ($page - 1) * $perpage;
  792. }
  793. if ($sku) {
  794. $sku = trim($sku, ' ');
  795. $sku = trim($sku, ' ');
  796. $where .= " and sku like '%$sku%'";
  797. $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);
  798. } else if ($title) {
  799. $title = trim($title, ' ');
  800. $title = trim($title, ' ');
  801. $where .= " and title like '%$title%'";
  802. $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);
  803. } else {
  804. //$where .= " and time > '$ktime' and time < '$jtime'";
  805. $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);
  806. }
  807. //取得信息列表
  808. $rows = array();
  809. $list = array();
  810. foreach ($info_list as $key => $value) {
  811. $warehouse = $this->warehouse->read($value['warehouse']);
  812. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  813. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  814. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  815. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  816. $ftime = time() - 15 * 24 * 3600;
  817. $info_list[$key]['warehouse'] = $warehouse['title'];
  818. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  819. //$z = count($z);//查看订单号
  820. //$info_list[$key]['zd'] = $z;
  821. $details = array();
  822. $cpid = array();
  823. foreach ($c as $k => $v) {
  824. $details[$v['details']] = $v['details'];
  825. if ($v['cpid'] != 0) {
  826. $cpid[$v['cpid']] = $v['cpid'];
  827. }
  828. }
  829. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  830. if ($value['shop'] != '') {
  831. $shop = explode(',', trim($value['shop'], ','));
  832. $shop = $this->shop->read($shop[0]);
  833. $info_list[$key]['shop'] = $shop['shopname'];
  834. }
  835. }
  836. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  837. $pagenum = ceil($total / $perpage);
  838. $over = $total - ($start + $perpage);
  839. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  840. echo json_encode($rows);
  841. exit;
  842. }
  843. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  844. $this->_Template('whlabel_typedy_ck', $this->data);
  845. }
  846. public function _typeck($arg_array)
  847. {
  848. $prc = array();
  849. $purchase = $this->purchase->find_all();
  850. foreach ($purchase as $k => $v) {
  851. $prc[$v['id']] = $v['title'];
  852. }
  853. $post = $this->input->post(NULL, TRUE);
  854. if (isset($post['page'])) {
  855. $page = $this->input->post('page', true);
  856. $perpage = $this->input->post('perpage', true);
  857. $category = $this->input->post('category', true);
  858. $size = $this->input->post('size', true);
  859. $grade = $this->input->post('grade', true);
  860. $color = $this->input->post('color', true);
  861. $lacecolor = $this->input->post('lacecolor', true);
  862. $lowe = $this->input->post('lowe', true);
  863. $sku = $this->input->post('sku');
  864. $title = $this->input->post('title');
  865. $warehouse = 13;
  866. $usa = $this->input->post('usa', true);
  867. $purchase = $this->input->post('purchase', true);
  868. $lacetype = $this->input->post('lacetype', true);
  869. $haircap = $this->input->post('haircap', true);
  870. $density = $this->input->post('density', true);
  871. $details = $this->input->post('details', true);
  872. $state = $this->input->post('state', true);
  873. $ktime = $this->input->post('ktime', true);
  874. $jtime = $this->input->post('jtime', true);
  875. $ktime = strtotime($ktime);
  876. $jtime = strtotime($jtime);
  877. $where = "1=1";
  878. $gj = "";
  879. $ck = "";
  880. if ($lacetype) {
  881. $where .= " and features like '%-$lacetype-%'";
  882. }
  883. if ($category) {
  884. $where .= " and features like '%-$category-%'";
  885. }
  886. if ($size) {
  887. $where .= " and features like '%-$size-%'";
  888. }
  889. if ($grade) {
  890. $where .= " and features like '%-$grade-%'";
  891. }
  892. if ($color) {
  893. $where .= " and features like '%-$color-%'";
  894. }
  895. if ($lacecolor) {
  896. $where .= " and features like '%-$lacecolor-%'";
  897. }
  898. if ($lowe) {
  899. $where .= " and features like '%-$lowe-%'";
  900. }
  901. if ($haircap) {
  902. $where .= " and features like '%-$haircap-%'";
  903. }
  904. if ($density) {
  905. $where .= " and features like '%-$density-%'";
  906. }
  907. if ($warehouse) {
  908. $where .= " and warehouse = '$warehouse'";
  909. }
  910. if ($details) {
  911. $where .= " and details = '$details'";
  912. }
  913. if ($purchase) {
  914. $where .= " and purchase = '$purchase'";
  915. }
  916. if ($state) {
  917. $where .= " and state = '$state'";
  918. }
  919. if ($ktime && $jtime) {
  920. $gj = " and enter > '$ktime' and enter < '$jtime'";
  921. $ck = " and outk > '$ktime' and outk < '$jtime'";
  922. }
  923. //数据排序
  924. $order_str = "id desc";
  925. if (empty($page)) {
  926. $start = 0;
  927. $perpage = 1;
  928. } else {
  929. $start = ($page - 1) * $perpage;
  930. }
  931. if ($sku) {
  932. $sku = trim($sku, ' ');
  933. $sku = trim($sku, ' ');
  934. $where .= " and sku like '%$sku%'";
  935. } else if ($title) {
  936. $title = trim($title, ' ');
  937. $title = trim($title, ' ');
  938. $where .= " and title like '%$title%'";
  939. }
  940. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  941. //取得信息列表
  942. $t = array();
  943. $typeclass = $this->typeclass->find_all();
  944. foreach ($typeclass as $v) {
  945. $t[$v['id']] = $v;
  946. }
  947. $rows = array();
  948. $list = array();
  949. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  950. foreach ($info_list as $key => $value) {
  951. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  952. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  953. $warehouse = $this->warehouse->read($value['warehouse']);
  954. $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');
  955. $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'] . '"');
  956. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  957. $number = $value['number'];
  958. $ftime = time() - 15 * 24 * 3600;
  959. $z = count($z); //查看订单号
  960. $info_list[$key]['warehouse'] = $warehouse['title'];
  961. $info_list[$key]['features'] = count($c);
  962. $info_list[$key]['number'] = $z;
  963. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  964. $details = array();
  965. $cpid = array();
  966. foreach ($c as $k => $v) {
  967. $details[$v['details']] = $v['details'];
  968. if ($v['cpid'] != 0) {
  969. $cpid[$v['cpid']] = $v['cpid'];
  970. }
  971. }
  972. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  973. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  974. unset($info_list[$key]['pm']);
  975. unset($info_list[$key]['jm']);
  976. unset($info_list[$key]['bm']);
  977. }
  978. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  979. $pagenum = ceil($total / $perpage);
  980. $over = $total - ($start + $perpage);
  981. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  982. echo json_encode($rows);
  983. exit;
  984. }
  985. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  986. $this->_Template('whlabel_typeck', $this->data);
  987. }
  988. //进销存导出
  989. public function _whlabeckdc()
  990. {
  991. $prc = array();
  992. $purchase = $this->purchase->find_all();
  993. foreach ($purchase as $k => $v) {
  994. $prc[$v['id']] = $v['title'];
  995. }
  996. if (isset($_GET['excel'])) {
  997. $where = "sku != 'Preset'";
  998. //数据排序
  999. $order_str = "id desc";
  1000. if (empty($page)) {
  1001. $start = 0;
  1002. $perpage = 1;
  1003. } else {
  1004. $start = ($page - 1) * $perpage;
  1005. }
  1006. $category = $this->input->get('category', true);
  1007. $color = $this->input->get('color', true);
  1008. $lowe = $this->input->get('lowe', true);
  1009. $lacetype = $this->input->get('lacetype', true);
  1010. $size = $this->input->get('size', true);
  1011. $density = $this->input->get('density', true);
  1012. $haircap = $this->input->get('haircap', true);
  1013. $sku = $this->input->get('sku', true);
  1014. $details = $this->input->get('details', true);
  1015. $warehouse = 13;
  1016. $excelid = $this->input->get('sid', true);
  1017. if ($category) {
  1018. $where .= " and features like '%-$category-%'";
  1019. }
  1020. if ($color) {
  1021. $where .= " and features like '%-$color-%'";
  1022. }
  1023. if ($lowe) {
  1024. $where .= " and features like '%-$lowe-%'";
  1025. }
  1026. if ($lacetype) {
  1027. $where .= " and features like '%-$lacetype-%'";
  1028. }
  1029. if ($size) {
  1030. $where .= " and features like '%-$size-%'";
  1031. }
  1032. if ($density) {
  1033. $where .= " and features like '%-$density-%'";
  1034. }
  1035. if ($haircap) {
  1036. $where .= " and features like '%-$haircap-%'";
  1037. }
  1038. if ($warehouse) {
  1039. $where .= " and warehouse = '$warehouse'";
  1040. }
  1041. if ($sku) {
  1042. $where .= " and sku like '%$sku%'";
  1043. }
  1044. if ($details) {
  1045. $where .= " and details = '$details'";
  1046. }
  1047. $xzid = '';
  1048. if ($excelid) {
  1049. $excelid = explode(',', trim($excelid, ','));
  1050. foreach ($excelid as $key => $value) {
  1051. $xzid .= " id = " . $value . " or";
  1052. }
  1053. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1054. }
  1055. //取得信息列表
  1056. /**
  1057. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1058. $rows = array();$list = array();
  1059. foreach ($info_list as $key=>$value)
  1060. {
  1061. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1062. }
  1063. **/
  1064. $wh = array();
  1065. $w = $this->warehouse->find_all('1=1', 'id,title');
  1066. foreach ($w as $v) {
  1067. $wh[$v['id']] = $v['title'];
  1068. }
  1069. $tc = array();
  1070. $tcdata = array();
  1071. $list = array();
  1072. $classid = $this->classid->sku();
  1073. $tcall = $this->typeclass->find_all();
  1074. $typeclass = array();
  1075. foreach ($tcall as $v)
  1076. {
  1077. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1078. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1079. }
  1080. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1081. foreach ($rows as $key => $value) {
  1082. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1083. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1084. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1085. $rows[$key]['cpbz'] = $u9_info['bm'];
  1086. $rows[$key]['cs'] = $u9_info['jm'];
  1087. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1088. $details = array();
  1089. $cpid = array();
  1090. $cpbz = array();
  1091. $c = 0;
  1092. $g = 0;
  1093. $x = 0;
  1094. $t = 0;
  1095. $s = 0;
  1096. $q = 0;
  1097. foreach ($sd as $k => $v) {
  1098. if ($v['state'] == 0) {
  1099. $c++;
  1100. }
  1101. if ($v['state'] != 9) {
  1102. $g++;
  1103. }
  1104. if ($v['state'] == 1) {
  1105. $x++;
  1106. }
  1107. if ($v['state'] == 2) {
  1108. $t++;
  1109. }
  1110. if ($v['state'] == 8) {
  1111. $s++;
  1112. }
  1113. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1114. $q++;
  1115. }
  1116. $details[$v['details']] = $v['details'];
  1117. if ($v['cpid'] != 0) {
  1118. $cpid[$v['cpid']] = $v['cpid'];
  1119. }
  1120. if ($v['cpbz'] != '') {
  1121. $cpbz[$v['cpbz']] = $v['cpbz'];
  1122. }
  1123. }
  1124. $rows[$key]['details'] = implode("、", $details);
  1125. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1126. $number = $value['number'];
  1127. $ftime = time() - 15 * 24 * 3600;
  1128. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1129. $rows[$key]['number'] = $g;
  1130. $rows[$key]['features'] = $c;
  1131. $rows[$key]['x'] = $x;
  1132. $rows[$key]['t'] = $t;
  1133. $rows[$key]['s'] = $s;
  1134. $rows[$key]['q'] = $q;
  1135. $rows[$key]['wzsl'] = count($details);
  1136. }
  1137. $title = "进销存统计表" . date('Y-m-d', time());
  1138. $titlename = "<table border=1>
  1139. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1140. <tr align='center'>
  1141. <td>仓库</td>
  1142. <td>供应商</td>
  1143. <td>位置</td>
  1144. <td>库存编码</td>
  1145. <td>SKU</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. <td>删除数量</td>
  1155. <td>其它操作</td>
  1156. <td>位置数量</td>
  1157. </tr>
  1158. </table>";
  1159. $filename = $title . ".xls";
  1160. $tail = "";
  1161. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1162. }
  1163. }
  1164. public function _type()
  1165. {
  1166. $vip = 0;
  1167. if (isset($_SESSION['api'])) {
  1168. $user = $this->user->get_api($_SESSION['api']);
  1169. $fgshop = "";
  1170. $sid = "";
  1171. $usersp = explode('|', trim($user['shop'], '|'));
  1172. foreach ($usersp as $value) {
  1173. $fgshop .= " shop = " . $value . " or";
  1174. $sid .= " id = " . $value . " or";
  1175. }
  1176. if ($user['vip'] == 1) {
  1177. $vip = 1;
  1178. }
  1179. } else {
  1180. header('Location: /');
  1181. exit;
  1182. }
  1183. $prc = array();
  1184. $purchase = $this->purchase->find_all();
  1185. foreach ($purchase as $k => $v) {
  1186. $prc[$v['id']] = $v['title'];
  1187. }
  1188. $company = array();
  1189. $ct = $this->company->find_all();
  1190. foreach ($ct as $k => $v) {
  1191. $company[$v['id']] = $v['title'];
  1192. }
  1193. $sp = array();
  1194. $s = $this->shop->find_all('1=1', 'id,shopname');
  1195. foreach ($s as $v) {
  1196. $sp[$v['id']] = $v['shopname'];
  1197. }
  1198. $wh = array();
  1199. $w = $this->warehouse->find_all('1=1', 'id,title');
  1200. foreach ($w as $v) {
  1201. $wh[$v['id']] = $v['title'];
  1202. }
  1203. $post = $this->input->post(NULL, TRUE);
  1204. if (isset($post['page'])) {
  1205. $page = $this->input->post('page', true);
  1206. $perpage = $this->input->post('perpage', true);
  1207. $category = $this->input->post('category', true);
  1208. $size = $this->input->post('size', true);
  1209. $grade = $this->input->post('grade', true);
  1210. $color = $this->input->post('color', true);
  1211. $lowe = $this->input->post('lowe', true);
  1212. $sku = $this->input->post('sku');
  1213. $title = $this->input->post('title');
  1214. $warehouse = $this->input->post('warehouse', true);
  1215. $usa = $this->input->post('usa', true);
  1216. $purchase = $this->input->post('purchase', true);
  1217. $lacetype = $this->input->post('lacetype', true);
  1218. $haircap = $this->input->post('haircap', true);
  1219. $density = $this->input->post('density', true);
  1220. $details = $this->input->post('details', true);
  1221. $state = $this->input->post('state', true);
  1222. $shop = $this->input->post('shop', true);
  1223. $lacecolor = $this->input->post('lacecolor', true);
  1224. $hairnumber = $this->input->post('hairnumber', true);
  1225. $type = $this->input->post('type', true);
  1226. $ktime = $this->input->post('ktime', true);
  1227. $jtime = $this->input->post('jtime', true);
  1228. $ktime = strtotime($ktime);
  1229. $jtime = strtotime($jtime);
  1230. $cpbz = $this->input->post('cpbz', true);
  1231. $sm = $this->input->post('sm', true);
  1232. $where = "1=1";
  1233. $gj = "";
  1234. $ck = "";
  1235. if ($usa) {
  1236. if (!$warehouse) {
  1237. $where .= " and (warehouse = '5' or warehouse = '8')";
  1238. }
  1239. }
  1240. if ($warehouse) {
  1241. $where .= " and warehouse = '$warehouse'";
  1242. }
  1243. if ($details) {
  1244. $where .= " and details = '$details'";
  1245. }
  1246. if ($purchase) {
  1247. $where .= " and purchase = '$purchase'";
  1248. }
  1249. if ($state) {
  1250. $where .= " and state = '$state'";
  1251. }
  1252. if ($shop) {
  1253. $where .= " and shop like '%$shop%'";
  1254. }
  1255. if ($type) {
  1256. $where .= " and type = '$type'";
  1257. }
  1258. if ($ktime && $jtime) {
  1259. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1260. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1261. }
  1262. if ($cpbz) {
  1263. $where .= " and cpbz like '%$cpbz%' ";
  1264. }
  1265. if ($sm) {
  1266. $where .= " and sm like '%$sm%' ";
  1267. }
  1268. if ($lacecolor) {
  1269. $where .= " and features like '%-$lacecolor-%'";
  1270. }
  1271. if ($lacetype) {
  1272. $where .= " and features like '%-$lacetype-%'";
  1273. }
  1274. if ($category) {
  1275. $where .= " and features like '%-$category-%'";
  1276. }
  1277. if ($size) {
  1278. $where .= " and features like '%-$size-%'";
  1279. }
  1280. if ($grade) {
  1281. $where .= " and features like '%-$grade-%'";
  1282. }
  1283. if ($color) {
  1284. $where .= " and features like '%-$color-%'";
  1285. }
  1286. if ($lowe) {
  1287. $where .= " and features like '%-$lowe-%'";
  1288. }
  1289. if ($haircap) {
  1290. $where .= " and features like '%-$haircap-%'";
  1291. }
  1292. if ($density) {
  1293. $where .= " and features like '%-$density-%'";
  1294. }
  1295. if (!empty($hairnumber)) {
  1296. $where .= " and features like '%-128-%' ";
  1297. if ($hairnumber < 0) {
  1298. $class_list = $this->typeclass->find_all('classid = 43');
  1299. foreach ($class_list as $v) {
  1300. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1301. }
  1302. } else {
  1303. $where .= " and features like '%-$hairnumber-%'";
  1304. }
  1305. }
  1306. //数据排序
  1307. $order_str = "id desc";
  1308. if (empty($page)) {
  1309. $start = 0;
  1310. $perpage = 1;
  1311. } else {
  1312. $start = ($page - 1) * $perpage;
  1313. }
  1314. $fjnr = '';
  1315. if ($sku) {
  1316. $sku = trim($sku, ' ');
  1317. $sku = trim($sku, ' ');
  1318. $fjnr .= " and sku like '%$sku%'";
  1319. }
  1320. if ($title) {
  1321. $title = trim($title, ' ');
  1322. $title = trim($title, ' ');
  1323. $fjnr .= " and title like '%$title%'";
  1324. }
  1325. $wt = array();
  1326. $whlabel_type = $this->whlabel_type->find_all();
  1327. foreach ($whlabel_type as $v) {
  1328. $wt[$v['id']] = $v['title'];
  1329. }
  1330. //$where .= " and time > '$ktime' and time < '$jtime'";
  1331. $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
  1332. //取得信息列表
  1333. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1334. $rows = array();
  1335. $list = array();
  1336. foreach ($info_list as $key => $value) {
  1337. if (isset($wt[$value['type']])) {
  1338. $info_list[$key]['type'] = $wt[$value['type']];
  1339. } else {
  1340. $info_list[$key]['type'] = '未设置';
  1341. }
  1342. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1343. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1344. $ztdata = '';
  1345. if (count($zt) > 0) {
  1346. foreach ($zt as $vv) {
  1347. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1348. }
  1349. }
  1350. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1351. $cdata = array_filter($qbdata, function ($item) {
  1352. return $item['state'] < 1;
  1353. });
  1354. $c = array_sum(array_column($cdata, 'jnum'));
  1355. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1356. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1357. });
  1358. $g = array_sum(array_column($gdata, 'jnum'));
  1359. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1360. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1361. });
  1362. $x = array_sum(array_column($xdata, 'jnum'));
  1363. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1364. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1365. });
  1366. $t = array_sum(array_column($tdata, 'jnum'));
  1367. // $zdata = array_filter($qbdata, function ($item) {
  1368. // return $item['zd'] != "" && $item['state'] < 1;
  1369. // });
  1370. // $z = array_sum(array_column($zdata, 'jnum'));
  1371. $zdata = array_filter($qbdata, function ($item) {
  1372. return $item['zd'] != "" && $item['state'] < 1;
  1373. });
  1374. $z = array_sum(array_column($zdata, 'jnum'));
  1375. //$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');
  1376. //$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'].'"');
  1377. //$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'].'"');
  1378. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1379. //$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'].'"');
  1380. $details = array();
  1381. $cpid = array();
  1382. $od = array();
  1383. $odid = '';
  1384. $companytitle = '';
  1385. $shop_list = [];
  1386. foreach ($qbdata as $v) {
  1387. if ($v['zd'] != "" && $v['state'] < 1) {
  1388. if (!isset($od[$v['zd']])) {
  1389. $od[$v['zd']] = 1; //所有数据sku
  1390. } else {
  1391. $od[$v['zd']] = $od[$v['zd']] + 1;
  1392. }
  1393. }
  1394. if ($v['state'] < 1) {
  1395. $details[$v['details']] = $v['details'];
  1396. if ($v['cpid'] != 0) {
  1397. $cpid[$v['cpid']] = $v['cpid'];
  1398. }
  1399. }
  1400. if($v['state'] == 0){
  1401. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1402. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1403. }
  1404. if ($v['shop'] != '') {
  1405. $shop = explode(',', trim($v['shop'], ','));
  1406. foreach ($shop as $vv) {
  1407. if (!in_array($vv, $shop_list)) {
  1408. $shop_list[] = $vv;
  1409. }
  1410. }
  1411. }
  1412. }
  1413. }
  1414. foreach ($od as $k => $vv) {
  1415. $odid .= $k . '数量' . $vv;
  1416. }
  1417. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1418. $info_list[$key]['label'] = $value['sm'];
  1419. $number = $value['number'];
  1420. $ftime = time() - 15 * 24 * 3600;
  1421. $z = $z . '(' . $odid . ')'; //查看订单号
  1422. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1423. $info_list[$key]['features'] = $c;
  1424. $info_list[$key]['number'] = $ztdata;
  1425. $info_list[$key]['sm'] = $g;
  1426. $info_list[$key]['x'] = $x;
  1427. $info_list[$key]['t'] = $t;
  1428. $info_list[$key]['z'] = $z;
  1429. /**
  1430. foreach ($cdata as $k=>$v)
  1431. {
  1432. $details[$v['details']] = $v['details'];
  1433. if($v['cpid'] != 0)
  1434. {
  1435. $cpid[$v['cpid']] = $v['cpid'];
  1436. }
  1437. }
  1438. **/
  1439. $info_list[$key]['shop'] = '';
  1440. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1441. // if ($value['shop'] != '') {
  1442. // $shop = explode(',', trim($value['shop'], ','));
  1443. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1444. // }
  1445. $shop_list = array_unique($shop_list);
  1446. $shop_str = '';
  1447. foreach ($shop_list as $v) {
  1448. if(isset($sp[$v])){
  1449. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1450. }
  1451. }
  1452. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1453. /**
  1454. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1455. if(isset($companytitle[0]))
  1456. {
  1457. foreach ($companytitle as $k=>$v)
  1458. {
  1459. if($v['companytitle'] != '')
  1460. {
  1461. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1462. }
  1463. }
  1464. }
  1465. **/
  1466. }
  1467. $final_all_list = [];
  1468. foreach ($info_list as $k => $v) {
  1469. $final_all_list[] = [
  1470. 'id' => $v['id'],
  1471. "warehouse" => $v["warehouse"],
  1472. "purchase" => $v["purchase"],
  1473. "sku" => $v["sku"],
  1474. "title" => $v["title"] . "<br/>" . $v["pm"],
  1475. "details" => $v["details"],
  1476. "shop" => $v["shop"],
  1477. "cpbz" => $v["cpbz"],
  1478. 'label' => $v['label'],
  1479. "type" => $v["type"],
  1480. "features" => $v["features"],
  1481. "number" => $v["number"],
  1482. "sm" => $v["sm"],
  1483. "x" => $v["x"],
  1484. "t" => $v["t"],
  1485. "z" => $v["z"]
  1486. ];
  1487. }
  1488. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1489. $pagenum = ceil($total / $perpage);
  1490. $over = $total - ($start + $perpage);
  1491. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1492. echo json_encode($rows);
  1493. exit;
  1494. }
  1495. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1496. $this->data['shop'] = $wlshop;
  1497. $this->data['vip'] = $vip;
  1498. $this->_Template('whlabel_type', $this->data);
  1499. }
  1500. //美仓进销存浏览
  1501. public function _usatype()
  1502. {
  1503. if (isset($_SESSION['api'])) {
  1504. $user = $this->user->get_api($_SESSION['api']);
  1505. $usp = $user;
  1506. $fgshop = "";
  1507. $sid = "";
  1508. $wid = "";
  1509. $wtype = "";
  1510. $userwh = explode('|', trim($user['warehouse'], '|'));
  1511. foreach ($userwh as $value) {
  1512. $wid .= " id = " . $value . " or";
  1513. $wtype .= " type = " . $value . " or";
  1514. }
  1515. }
  1516. $prc = array();
  1517. $purchase = $this->purchase->find_all();
  1518. foreach ($purchase as $k => $v) {
  1519. $prc[$v['id']] = $v['title'];
  1520. }
  1521. $post = $this->input->post(NULL, TRUE);
  1522. if (isset($post['page'])) {
  1523. $page = $this->input->post('page', true);
  1524. $perpage = $this->input->post('perpage', true);
  1525. $category = $this->input->post('category', true);
  1526. $size = $this->input->post('size', true);
  1527. $grade = $this->input->post('grade', true);
  1528. $color = $this->input->post('color', true);
  1529. $lowe = $this->input->post('lowe', true);
  1530. $sku = $this->input->post('sku');
  1531. $title = $this->input->post('title');
  1532. $warehouse = $this->input->post('warehouse', true);
  1533. $usa = $this->input->post('usa', true);
  1534. $purchase = $this->input->post('purchase', true);
  1535. $lacetype = $this->input->post('lacetype', true);
  1536. $haircap = $this->input->post('haircap', true);
  1537. $density = $this->input->post('density', true);
  1538. $details = $this->input->post('details', true);
  1539. $state = $this->input->post('state', true);
  1540. $lacecolor = $this->input->post('lacecolor', true);
  1541. $cklx = $this->input->post('cklx', true);
  1542. $ktime = $this->input->post('ktime', true);
  1543. $jtime = $this->input->post('jtime', true);
  1544. $ktime = strtotime($ktime);
  1545. $jtime = strtotime($jtime);
  1546. $where = "1=1";
  1547. $gj = "";
  1548. $ck = "";
  1549. if ($lacetype) {
  1550. $where .= " and features like '%-$lacetype-%'";
  1551. }
  1552. if ($category) {
  1553. $where .= " and features like '%-$category-%'";
  1554. }
  1555. if ($size) {
  1556. $where .= " and features like '%-$size-%'";
  1557. }
  1558. if ($grade) {
  1559. $where .= " and features like '%-$grade-%'";
  1560. }
  1561. if ($color) {
  1562. $where .= " and features like '%-$color-%'";
  1563. }
  1564. if ($lowe) {
  1565. $where .= " and features like '%-$lowe-%'";
  1566. }
  1567. if ($haircap) {
  1568. $where .= " and features like '%-$haircap-%'";
  1569. }
  1570. if ($density) {
  1571. $where .= " and features like '%-$density-%'";
  1572. }
  1573. if ($lacecolor) {
  1574. $where .= " and features like '%-$lacecolor-%'";
  1575. }
  1576. if ($usa) {
  1577. if (!$warehouse) {
  1578. $where .= " and (warehouse = '5' or warehouse = '8')";
  1579. }
  1580. }
  1581. if ($warehouse) {
  1582. $where .= " and warehouse = '$warehouse'";
  1583. }
  1584. if ($details) {
  1585. $where .= " and details = '$details'";
  1586. }
  1587. if ($purchase) {
  1588. $where .= " and purchase = '$purchase'";
  1589. }
  1590. if ($state) {
  1591. $where .= " and state = '$state'";
  1592. }
  1593. $where_add = '';
  1594. if ($cklx) {
  1595. $shop = $this->shop->read($cklx);
  1596. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1597. }
  1598. if ($ktime && $jtime) {
  1599. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1600. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1601. }
  1602. //数据排序
  1603. $order_str = "id desc";
  1604. if (empty($page)) {
  1605. $start = 0;
  1606. $perpage = 1;
  1607. } else {
  1608. $start = ($page - 1) * $perpage;
  1609. }
  1610. if ($sku) {
  1611. $sku = trim($sku, ' ');
  1612. $sku = trim($sku, ' ');
  1613. $where .= " and sku like '%$sku%'";
  1614. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1615. } else if ($title) {
  1616. $title = trim($title, ' ');
  1617. $title = trim($title, ' ');
  1618. $where .= " and title like '%$title%'";
  1619. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1620. } else {
  1621. //$where .= " and time > '$ktime' and time < '$jtime'";
  1622. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1623. }
  1624. //取得信息列表
  1625. $rows = array();
  1626. $list = array();
  1627. foreach ($info_list as $key => $value) {
  1628. $warehouse = $this->warehouse->read($value['warehouse']);
  1629. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1630. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1631. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1632. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1633. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1634. $od = array();
  1635. $odid = '';
  1636. foreach ($z as $v) {
  1637. if (!isset($od[$v['zd']])) {
  1638. $od[$v['zd']] = 1; //所有数据sku
  1639. } else {
  1640. $od[$v['zd']] = $od[$v['zd']] + 1;
  1641. }
  1642. }
  1643. foreach ($od as $k => $vv) {
  1644. $odid .= $k . '数量' . $vv . ' ';
  1645. }
  1646. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1647. $info_list[$key]['features'] = $c;
  1648. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1649. $ztdata = '';
  1650. if (count($zt) > 0) {
  1651. foreach ($zt as $vv) {
  1652. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1653. }
  1654. }
  1655. $info_list[$key]['warehouse'] = $ztdata;
  1656. $info_list[$key]['g'] = $g;
  1657. $info_list[$key]['x'] = $x;
  1658. $info_list[$key]['t'] = $t;
  1659. $info_list[$key]['z'] = $z;
  1660. }
  1661. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1662. $pagenum = ceil($total / $perpage);
  1663. $over = $total - ($start + $perpage);
  1664. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1665. echo json_encode($rows);
  1666. exit;
  1667. }
  1668. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1669. $this->data['warehouse'] = $warehouse;
  1670. $this->_Template('whlabel_typeusa', $this->data);
  1671. }
  1672. //美仓进销存浏览
  1673. public function _usatypeapp()
  1674. {
  1675. $post = $this->input->post(NULL, TRUE);
  1676. if (isset($post['page'])) {
  1677. $page = $this->input->post('page', true);
  1678. $perpage = $this->input->post('perpage', true);
  1679. $sku = $this->input->post('sku', true);
  1680. $warehouse = 5;
  1681. $title = $this->input->post('title', true);
  1682. $state = $this->input->post('state', true);
  1683. $ktime = $this->input->post('ktime', true);
  1684. $jtime = $this->input->post('jtime', true);
  1685. $ktime = strtotime($ktime);
  1686. $jtime = strtotime($jtime);
  1687. $where = "1=1";
  1688. $gj = "";
  1689. $ck = "";
  1690. if ($title) {
  1691. $st = explode(' ', trim($title, ' '));
  1692. foreach ($st as $v) {
  1693. $where .= " and title like '%$v%'";
  1694. }
  1695. }
  1696. if ($warehouse) {
  1697. $where .= " and warehouse = '$warehouse'";
  1698. }
  1699. if ($state) {
  1700. $where .= " and state = '$state'";
  1701. }
  1702. if ($sku) {
  1703. $where .= " and sku like '%$sku%'";
  1704. }
  1705. if ($ktime && $jtime) {
  1706. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1707. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1708. }
  1709. //数据排序
  1710. $order_str = "id desc";
  1711. if (empty($page)) {
  1712. $start = 0;
  1713. $perpage = 1;
  1714. } else {
  1715. $start = ($page - 1) * $perpage;
  1716. }
  1717. //取得信息列表
  1718. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1719. $rows = array();
  1720. $list = array();
  1721. foreach ($info_list as $key => $value) {
  1722. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1723. }
  1724. $rowsdq = array_slice($rows, $start, $perpage);
  1725. foreach ($rowsdq as $value) {
  1726. $warehouse = $this->warehouse->read($value['warehouse']);
  1727. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1728. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1729. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1730. $od = array();
  1731. $odid = '';
  1732. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1733. }
  1734. $total = count($rows);
  1735. $pagenum = ceil($total / $perpage);
  1736. $over = $total - ($start + $perpage);
  1737. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1738. echo json_encode($rows);
  1739. exit;
  1740. }
  1741. $this->_Template('phone/p_usatypeapp', $this->data);
  1742. }
  1743. //入库操作
  1744. public function _enteradd()
  1745. {
  1746. $dt = 0;
  1747. if (isset($_SESSION['api'])) {
  1748. $user = $this->user->get_api($_SESSION['api']);
  1749. $usp = $user;
  1750. $fgshop = "";
  1751. $sid = "";
  1752. $user = explode('|', trim($user['shop'], '|'));
  1753. foreach ($user as $value) {
  1754. $fgshop .= " shop = " . $value . " or";
  1755. $sid .= " id = " . $value . " or";
  1756. }
  1757. }
  1758. $tc = $this->typeclass->find_all();
  1759. $typeclass = array();
  1760. foreach ($tc as $v) {
  1761. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1762. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1763. }
  1764. $post = $this->input->post(NULL, TRUE);
  1765. if (isset($post['sku'])) {
  1766. $list = array();
  1767. $num = "";
  1768. $title = "";
  1769. $features = "";
  1770. $order = $this->input->post('order', true);
  1771. $shop = $this->input->post('shop', true);
  1772. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1773. $sku = $this->input->post('sku', true);
  1774. $post['sm'] = $this->input->post('sm', true);
  1775. $post['warehouse'] = $this->input->post('warehouse', true);
  1776. $post['purchase'] = $this->input->post('purchase', true);
  1777. $post['retreatwarehouse'] = $post['warehouse'];
  1778. $post['state'] = $this->input->post('state', true);
  1779. $post['rktype'] = $this->input->post('rktype', true);
  1780. $post['text'] = $this->input->post('text', true);
  1781. $category = $this->input->post('category', true);
  1782. $list['category'] = $category;
  1783. $list['hairtype'] = $this->input->post('hairtype', true);
  1784. $list['grade'] = $this->input->post('grade', true);
  1785. $size = $this->input->post('size', true);
  1786. $xzsku = $this->input->post('xzsku', true);
  1787. $list['size'] = rtrim($size, ',');
  1788. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1789. $list['extension'] = $this->input->post('extension', true);
  1790. if ($category == 1297) {
  1791. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1792. }
  1793. if ($category == 1702) {
  1794. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1795. $list['syother'] = $this->input->post('syother', true);
  1796. }
  1797. if ($category == 133) {
  1798. $list['fittype'] = $this->input->post('fittype', true);
  1799. $list['acother'] = $this->input->post('acother', true);
  1800. }
  1801. $list['color'] = $this->input->post('color', true);
  1802. $list['lowe'] = $this->input->post('lowe', true);
  1803. if (!$post['purchase']) {
  1804. $post['purchase'] = 1;
  1805. }
  1806. if ($category == 127) {
  1807. $list['type'] = $this->input->post('type', true);
  1808. $list['headroad'] = $this->input->post('headroad', true);
  1809. $list['density'] = $this->input->post('density', true);
  1810. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1811. $list['lacesize'] = $this->input->post('lacesize', true);
  1812. }
  1813. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1814. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1815. }
  1816. if ($category == 128) {
  1817. $list['lacetype'] = $this->input->post('lacetype', true);
  1818. $list['haircap'] = $this->input->post('haircap', true);
  1819. $list['density'] = $this->input->post('density', true);
  1820. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1821. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1822. $list['wigother'] = $this->input->post('wigother', true);
  1823. $list['wigother1'] = $this->input->post('wigother1', true);
  1824. $list['wigother2'] = $this->input->post('wigother2', true);
  1825. }
  1826. if ($category == 129) {
  1827. $list['wide'] = $this->input->post('wide', true);
  1828. }
  1829. if ($category == 131) {
  1830. $list['gifttype'] = $this->input->post('gifttype', true);
  1831. $list['giftother'] = $this->input->post('giftother', true);
  1832. }
  1833. if ($category == 134) {
  1834. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1835. }
  1836. if ($category == 1297) {
  1837. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1838. $list['sywigother'] = $this->input->post('sywigother', true);
  1839. }
  1840. if ($category == 130 || $category == 133 || $category == 1702) {
  1841. $list['items'] = $this->input->post('items', true);
  1842. $list['weight'] = $this->input->post('weight', true);
  1843. }
  1844. if ($category == 1702) {
  1845. $list['syhairther'] = $this->input->post('syhairther', true);
  1846. }
  1847. $classid = $this->classid->sku();
  1848. $scsku = $classid;
  1849. $pm = $classid;
  1850. foreach ($list as $k => $v) {
  1851. if ($v != 0) {
  1852. $num .= $v;
  1853. $features .= $v . '-';
  1854. $post[$k] = $v;
  1855. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1856. if ($k != 'size') {
  1857. $title .= $typeclass[$v]['title'] . " ";
  1858. }
  1859. if (isset($pm[$typeclass[$v]['classid']])) {
  1860. if ($typeclass[$v]['title'] == '9A') {
  1861. $pm[$typeclass[$v]['classid']] = '9A';
  1862. } else if ($typeclass[$v]['title'] == '10A') {
  1863. $pm[$typeclass[$v]['classid']] = '10A';
  1864. } else {
  1865. $clzh = $typeclass[$v]['zh'];
  1866. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1867. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1868. $clzh = $clzh[0];
  1869. }
  1870. $pm[$typeclass[$v]['classid']] = $clzh;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. $zh = implode(" ", $pm);
  1876. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1877. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1878. if ($list['size']) {
  1879. $typeclass = $this->typeclass->read($list['size']);
  1880. $title .= $typeclass['title'];
  1881. }
  1882. $time = time();
  1883. if ($xzsku) {
  1884. $scsku = implode("-", $scsku);
  1885. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1886. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1887. $post['sku'] = trim($scsku, ' ');
  1888. } else {
  1889. $post['sku'] = $sku;
  1890. }
  1891. //$post['sku'] = trim($sku,' ');
  1892. $post['title'] = rtrim($title, ' ');
  1893. $post['number'] = $num;
  1894. $post['features'] = '-' . $features;
  1895. $post['enter'] = $time;
  1896. $post['time'] = $time; //操作时间
  1897. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1898. if ($yza) {
  1899. if ($post['features'] != $yza[0]['features']) {
  1900. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1901. exit;
  1902. }
  1903. }
  1904. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1905. if ($yzb) {
  1906. if ($post['sku'] != $yzb[0]['sku']) {
  1907. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1908. exit;
  1909. }
  1910. }
  1911. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1912. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1913. exit;
  1914. }
  1915. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1916. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1917. exit;
  1918. }
  1919. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1920. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1921. exit;
  1922. }
  1923. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1924. if (isset($yz[0]['type'])) {
  1925. $post['type'] = $yz[0]['type'];
  1926. }
  1927. if ($post['state'] == 9) //如果选择预设库存
  1928. {
  1929. $this->whlabel->insert($post);
  1930. } else {
  1931. /**
  1932. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1933. if($ljg == 1)
  1934. {
  1935. for($i=0;$i<$order;$i++)
  1936. {
  1937. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1938. $this->whlabel->insert($post);
  1939. }
  1940. }
  1941. **/
  1942. //if($post['warehouse'] == '5')
  1943. //{
  1944. //}
  1945. $yydata = $post;
  1946. $yydata['zh'] = $zh;
  1947. /**
  1948. $wl = $this->apiyy->get_cjlp($yydata);
  1949. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1950. {
  1951. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1952. }
  1953. if($wl['Data'][0]['m_isSucess'] != 1)
  1954. {
  1955. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1956. }
  1957. **/
  1958. for ($i = 0; $i < $order; $i++) {
  1959. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1960. $this->whlabel->insert($post);
  1961. }
  1962. }
  1963. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1964. exit;
  1965. }
  1966. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1967. $this->data['wlshop'] = $wlshop;
  1968. $this->_Template('whlabel_enteradd', $this->data);
  1969. }
  1970. //修改产品
  1971. public function _enteredit($arg_array)
  1972. {
  1973. $dt = 0;
  1974. if (isset($_SESSION['api'])) {
  1975. $user = $this->user->get_api($_SESSION['api']);
  1976. $usp = $user;
  1977. $fgshop = "";
  1978. $sid = "";
  1979. $user = explode('|', trim($user['shop'], '|'));
  1980. foreach ($user as $value) {
  1981. $fgshop .= " shop = " . $value . " or";
  1982. $sid .= " id = " . $value . " or";
  1983. }
  1984. }
  1985. $post = $this->input->post(NULL, TRUE);
  1986. if (isset($post['sku'])) {
  1987. $list = array();
  1988. $num = "";
  1989. $title = "";
  1990. $features = "";
  1991. $id = $this->input->post('id', true);
  1992. $order = $this->input->post('order', true);
  1993. $shop = $this->input->post('shop', true);
  1994. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1995. $post['sku'] = $this->input->post('sku', true);
  1996. $post['sm'] = $this->input->post('sm', true);
  1997. $post['warehouse'] = $this->input->post('warehouse', true);
  1998. $post['purchase'] = $this->input->post('purchase', true);
  1999. $post['retreatwarehouse'] = $post['warehouse'];
  2000. $category = $this->input->post('category', true);
  2001. $list['category'] = $category;
  2002. $list['hairtype'] = $this->input->post('hairtype', true);
  2003. $list['grade'] = $this->input->post('grade', true);
  2004. $size = $this->input->post('size', true);
  2005. $list['size'] = rtrim($size, ',');
  2006. $post['rktype'] = $this->input->post('rktype', true);
  2007. $post['text'] = $this->input->post('text', true);
  2008. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2009. $list['extension'] = $this->input->post('extension', true);
  2010. if ($category == 1297) {
  2011. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2012. }
  2013. if ($category == 1702) {
  2014. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2015. $list['syother'] = $this->input->post('syother', true);
  2016. }
  2017. if ($category == 133) {
  2018. $list['fittype'] = $this->input->post('fittype', true);
  2019. $list['acother'] = $this->input->post('acother', true);
  2020. }
  2021. $list['color'] = $this->input->post('color', true);
  2022. $list['lowe'] = $this->input->post('lowe', true);
  2023. if (!$post['purchase']) {
  2024. $post['purchase'] = 1;
  2025. }
  2026. if ($category == 127) {
  2027. $list['type'] = $this->input->post('type', true);
  2028. $list['headroad'] = $this->input->post('headroad', true);
  2029. $list['density'] = $this->input->post('density', true);
  2030. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2031. $list['lacesize'] = $this->input->post('lacesize', true);
  2032. }
  2033. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2034. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2035. }
  2036. if ($category == 128) {
  2037. $list['lacetype'] = $this->input->post('lacetype', true);
  2038. $list['haircap'] = $this->input->post('haircap', true);
  2039. $list['density'] = $this->input->post('density', true);
  2040. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2041. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2042. $list['wigother'] = $this->input->post('wigother', true);
  2043. $list['wigother1'] = $this->input->post('wigother1', true);
  2044. $list['wigother2'] = $this->input->post('wigother2', true);
  2045. }
  2046. if ($category == 129) {
  2047. $list['wide'] = $this->input->post('wide', true);
  2048. }
  2049. if ($category == 131) {
  2050. $list['gifttype'] = $this->input->post('gifttype', true);
  2051. $list['giftother'] = $this->input->post('giftother', true);
  2052. }
  2053. if ($category == 134) {
  2054. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2055. }
  2056. if ($category == 1297) {
  2057. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2058. $list['sywigother'] = $this->input->post('sywigother', true);
  2059. }
  2060. if ($category == 130 || $category == 133 || $category == 1702) {
  2061. $list['items'] = $this->input->post('items', true);
  2062. $list['weight'] = $this->input->post('weight', true);
  2063. }
  2064. if ($category == 1702) {
  2065. $list['syhairther'] = $this->input->post('syhairther', true);
  2066. }
  2067. foreach ($list as $k => $v) {
  2068. if ($v != 0) {
  2069. $num .= $v;
  2070. $features .= $v . '-';
  2071. $typeclass = $this->typeclass->read($v);
  2072. if ($k != 'size') {
  2073. $title .= $typeclass['title'] . " ";
  2074. }
  2075. }
  2076. }
  2077. $typeclass = $this->typeclass->read($list['size']);
  2078. $title .= $typeclass['title'];
  2079. $time = time();
  2080. $post['title'] = rtrim($title, ' ');
  2081. $post['number'] = $num;
  2082. $post['features'] = '-' . $features;
  2083. $post['time'] = $time; //操作时间
  2084. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2085. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2086. exit;
  2087. }
  2088. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2089. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2090. exit;
  2091. }
  2092. $uid = $this->whlabel->read($id);
  2093. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2094. if ($datanum > 0) {
  2095. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2096. exit;
  2097. }
  2098. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2099. {
  2100. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2101. if ($yza) {
  2102. if ($post['features'] != $yza[0]['features']) {
  2103. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2104. exit;
  2105. }
  2106. }
  2107. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2108. if ($yzb) {
  2109. if ($post['sku'] != $yzb[0]['sku']) {
  2110. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2111. exit;
  2112. }
  2113. }
  2114. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2115. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2116. exit;
  2117. }
  2118. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2119. foreach ($data as $v) {
  2120. $post['id'] = $v['id'];
  2121. $this->whlabel->save($post, $v['id']);
  2122. }
  2123. } else {
  2124. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2125. if ($data > 0) {
  2126. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2127. exit;
  2128. } else {
  2129. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2130. foreach ($data as $v) {
  2131. $post['id'] = $v['id'];
  2132. $this->whlabel->save($post, $v['id']);
  2133. }
  2134. }
  2135. }
  2136. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2137. exit;
  2138. }
  2139. $uid = $this->whlabel->read($arg_array[0]);
  2140. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2141. $this->data['enter'] = $uid;
  2142. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2143. $this->data['wlshop'] = $wlshop;
  2144. $this->_Template('whlabel_enteredit', $this->data);
  2145. }
  2146. //入库浏览
  2147. public function _enter()
  2148. {
  2149. $post = $this->input->post(NULL, TRUE);
  2150. if (isset($post['s'])) {
  2151. $id_arr = $this->input->post('s');
  2152. $id_arr = explode(',', $id_arr);
  2153. if (!$id_arr) {
  2154. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2155. exit;
  2156. }
  2157. //循环删除记录
  2158. foreach ($id_arr as $v) {
  2159. $sid = $this->whlabel->read($v);
  2160. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2161. if ($count > 0) {
  2162. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2163. exit;
  2164. }
  2165. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2166. foreach ($info_list as $va) {
  2167. $this->whlabel->remove($va['id']);
  2168. }
  2169. }
  2170. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2171. exit;
  2172. }
  2173. $sp = array();
  2174. $s = $this->shop->find_all('1=1', 'id,shopname');
  2175. foreach ($s as $v) {
  2176. $sp[$v['id']] = $v['shopname'];
  2177. }
  2178. $wh = array();
  2179. $w = $this->warehouse->find_all('1=1', 'id,title');
  2180. foreach ($w as $v) {
  2181. $wh[$v['id']] = $v['title'];
  2182. }
  2183. if (isset($post['page'])) {
  2184. $page = $this->input->post('page', true);
  2185. $perpage = $this->input->post('perpage', true);
  2186. $category = $this->input->post('category', true);
  2187. $size = $this->input->post('size', true);
  2188. $grade = $this->input->post('grade', true);
  2189. $color = $this->input->post('color', true);
  2190. $lowe = $this->input->post('lowe', true);
  2191. $sku = $this->input->post('sku', true);
  2192. $warehouse = $this->input->post('warehouse', true);
  2193. $purchase = $this->input->post('purchase', true);
  2194. $ktime = $this->input->post('ktime', true);
  2195. $jtime = $this->input->post('jtime', true);
  2196. $ktime = strtotime($ktime);
  2197. $jtime = strtotime($jtime);
  2198. $where = "1=1";
  2199. $gj = "";
  2200. $ck = "";
  2201. if ($category) {
  2202. $where .= " and features like '%-$category-%'";
  2203. }
  2204. if ($size) {
  2205. $where .= " and features like '%-$size-%'";
  2206. }
  2207. if ($grade) {
  2208. $where .= " and features like '%-$grade-%'";
  2209. }
  2210. if ($color) {
  2211. $where .= " and features like '%-$color-%'";
  2212. }
  2213. if ($lowe) {
  2214. $where .= " and features like '%-$lowe-%'";
  2215. }
  2216. if ($warehouse) {
  2217. $where .= " and warehouse = '$warehouse'";
  2218. }
  2219. if ($purchase) {
  2220. $where .= " and purchase = '$purchase'";
  2221. }
  2222. if ($sku) {
  2223. $where .= " and sku like '%$sku%'";
  2224. }
  2225. if ($ktime && $jtime) {
  2226. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2227. }
  2228. //数据排序
  2229. $order_str = "enter desc";
  2230. if (empty($page)) {
  2231. $start = 0;
  2232. $perpage = 1;
  2233. } else {
  2234. $start = ($page - 1) * $perpage;
  2235. }
  2236. //取得信息列表
  2237. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2238. foreach ($info_list as $k => $v) {
  2239. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2240. if ($v['shop'] == '') {
  2241. $s = '通用';
  2242. } else {
  2243. $info_list[$k]['shop'] = '';
  2244. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2245. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2246. }
  2247. }
  2248. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2249. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2250. $info_list[$k]['g'] = $g;
  2251. }
  2252. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2253. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2254. $pagenum = ceil($total / $perpage);
  2255. $over = $total - ($start + $perpage);
  2256. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2257. echo json_encode($rows);
  2258. exit;
  2259. }
  2260. $this->_Template('whlabel_enter', $this->data);
  2261. }
  2262. //出库浏览
  2263. public function _out()
  2264. {
  2265. $post = $this->input->post(NULL, TRUE);
  2266. if (isset($post['page'])) {
  2267. $page = $this->input->post('page', true);
  2268. $perpage = $this->input->post('perpage', true);
  2269. $category = $this->input->post('category', true);
  2270. $size = $this->input->post('size', true);
  2271. $grade = $this->input->post('grade', true);
  2272. $color = $this->input->post('color', true);
  2273. $lowe = $this->input->post('lowe', true);
  2274. $sku = $this->input->post('sku', true);
  2275. $warehouse = $this->input->post('warehouse', true);
  2276. $purchase = $this->input->post('purchase', true);
  2277. $state = $this->input->post('state', true);
  2278. $ktime = $this->input->post('ktime', true);
  2279. $jtime = $this->input->post('jtime', true);
  2280. $ktime = strtotime($ktime);
  2281. $jtime = strtotime($jtime);
  2282. $where = "state=3";
  2283. $gj = "";
  2284. $ck = "";
  2285. if ($category) {
  2286. $where .= " and features like '%-$category-%'";
  2287. }
  2288. if ($size) {
  2289. $where .= " and features like '%-$size-%'";
  2290. }
  2291. if ($grade) {
  2292. $where .= " and features like '%-$grade-%'";
  2293. }
  2294. if ($color) {
  2295. $where .= " and features like '%-$color-%'";
  2296. }
  2297. if ($lowe) {
  2298. $where .= " and features like '%-$lowe-%'";
  2299. }
  2300. if ($state) {
  2301. $where .= " and state = '$state'";
  2302. }
  2303. if ($warehouse) {
  2304. $where .= " and warehouse = '$warehouse'";
  2305. }
  2306. if ($purchase) {
  2307. $where .= " and purchase = '$purchase'";
  2308. }
  2309. if ($sku) {
  2310. $where .= " and sku = '$sku'";
  2311. }
  2312. if ($ktime && $jtime) {
  2313. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2314. }
  2315. //数据排序
  2316. $order_str = "id desc";
  2317. if (empty($page)) {
  2318. $start = 0;
  2319. $perpage = 1;
  2320. } else {
  2321. $start = ($page - 1) * $perpage;
  2322. }
  2323. //取得信息列表
  2324. $info_list = $this->whlabel->find_all($where, 'sku');
  2325. $rows = array();
  2326. $list = array();
  2327. foreach ($info_list as $key => $value) {
  2328. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2329. }
  2330. $rows = array_unique($rows); //删除重复记录
  2331. foreach ($rows as $key => $value) {
  2332. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2333. $ck = $this->warehouse->read($data['warehouse']);
  2334. $warehouse = $ck['title'];
  2335. $gy = $this->purchase->read($data['purchase']);
  2336. $purchase = $gy['purchase'];
  2337. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2338. $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);
  2339. }
  2340. $total = count($list);
  2341. $pagenum = ceil($total / $perpage);
  2342. $over = $total - ($start + $perpage);
  2343. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2344. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2345. echo json_encode($rows);
  2346. exit;
  2347. }
  2348. $this->_Template('whlabel_out', $this->data);
  2349. }
  2350. //出库标签浏览
  2351. public function _label()
  2352. {
  2353. $post = $this->input->post(NULL, TRUE);
  2354. if (isset($post['page'])) {
  2355. $page = $this->input->post('page', true);
  2356. $perpage = $this->input->post('perpage', true);
  2357. $sku = $this->input->post('sku', true);
  2358. $warehouse = $this->input->post('warehouse', true);
  2359. $purchase = $this->input->post('purchase', true);
  2360. $orderinfo = $this->input->post('orderinfo', true);
  2361. $waybill = $this->input->post('waybill', true);
  2362. $category = $this->input->post('category', true);
  2363. $size = $this->input->post('size', true);
  2364. $grade = $this->input->post('grade', true);
  2365. $color = $this->input->post('color', true);
  2366. $lowe = $this->input->post('lowe', true);
  2367. $where = "state=1";
  2368. if ($sku) {
  2369. $where .= " and sku = '$sku'";
  2370. }
  2371. if ($warehouse) {
  2372. $where .= " and warehouse = '$warehouse'";
  2373. }
  2374. if ($purchase) {
  2375. $where .= " and purchase = '$purchase'";
  2376. }
  2377. if ($orderinfo) {
  2378. $where .= " and orderinfo = '$orderinfo'";
  2379. }
  2380. if ($waybill) {
  2381. $where .= " and waybill = '$waybill'";
  2382. }
  2383. if ($category) {
  2384. $where .= " and features like '%-$category-%'";
  2385. }
  2386. if ($size) {
  2387. $where .= " and features like '%-$size-%'";
  2388. }
  2389. if ($grade) {
  2390. $where .= " and features like '%-$grade-%'";
  2391. }
  2392. if ($color) {
  2393. $where .= " and features like '%-$color-%'";
  2394. }
  2395. if ($lowe) {
  2396. $where .= " and features like '%-$lowe-%'";
  2397. }
  2398. //数据排序
  2399. $order_str = "outk desc";
  2400. if (empty($page)) {
  2401. $start = 0;
  2402. $perpage = 1;
  2403. } else {
  2404. $start = ($page - 1) * $perpage;
  2405. }
  2406. //取得信息列表
  2407. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2408. foreach ($info_list as $key => $value) {
  2409. $warehouse = $this->warehouse->read($value['warehouse']);
  2410. $info_list[$key]['warehouse'] = $warehouse['title'];
  2411. $purchase = $this->purchase->read($value['purchase']);
  2412. $info_list[$key]['purchase'] = $purchase['title'];
  2413. if ($value['outk'] != 0) {
  2414. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2415. } else {
  2416. $info_list[$key]['outk'] = "";
  2417. }
  2418. if ($value['orderinfo'] == 0) {
  2419. $info_list[$key]['orderinfo'] = "";
  2420. }
  2421. if ($value['waybill'] == 0) {
  2422. $info_list[$key]['waybill'] = "";
  2423. }
  2424. }
  2425. $total = $this->whlabel->find_count($where);
  2426. $pagenum = ceil($total / $perpage);
  2427. $over = $total - ($start + $perpage);
  2428. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2429. echo json_encode($rows);
  2430. exit;
  2431. }
  2432. $this->_Template('whlabel_label', $this->data);
  2433. }
  2434. //独立站出库订单
  2435. public function _outorder()
  2436. {
  2437. if (isset($_SESSION['api'])) {
  2438. $user = $this->user->get_api($_SESSION['api']);
  2439. $usp = $user;
  2440. $fgshop = "";
  2441. $sid = "";
  2442. $user = explode('|', trim($user['shop'], '|'));
  2443. foreach ($user as $value) {
  2444. $fgshop .= " shop = " . $value . " or";
  2445. $sid .= " id = " . $value . " or";
  2446. }
  2447. } else {
  2448. echo "请重新登录";
  2449. }
  2450. $post = $this->input->post(NULL, TRUE);
  2451. if (isset($post['page'])) {
  2452. $page = $this->input->post('page', true);
  2453. $perpage = $this->input->post('perpage', true);
  2454. $warehouse = $this->input->post('warehouse', true);
  2455. $xztime = $this->input->post('xztime', true);
  2456. $timetk = $this->input->post('timetkk', true);
  2457. $timetj = $this->input->post('timetjj', true);
  2458. $shop = $this->input->post('shop', true);
  2459. $source = $this->input->post('source', true);
  2460. $orderinfo = $this->input->post('orderinfo', true);
  2461. $number = $this->input->post('number', true);
  2462. $sfxh = $this->input->post('sfxh', true);
  2463. $express = $this->input->post('express', true);
  2464. $waybill = $this->input->post('waybill', true);
  2465. $library = $this->input->post('library', true);
  2466. $country = $this->input->post('country', true);
  2467. $so = $this->input->post('so', true);
  2468. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2469. $print = $this->input->post('print', true);
  2470. $state = $this->input->post('state', true);
  2471. $orderurl = $this->input->post('orderurl', true);
  2472. $productid = $this->input->post('productid', true);
  2473. $timetk = strtotime($timetk);
  2474. $timetj = strtotime($timetj);
  2475. /**
  2476. $sj = $this->input->post('sj',true);
  2477. if($sj)
  2478. {
  2479. $sj = $this->input->post('sj',true);
  2480. }
  2481. else
  2482. {
  2483. $sj = "fullorder";
  2484. }
  2485. **/
  2486. $sj = "fullorder";
  2487. $where = "1=1";
  2488. if ($warehouse) {
  2489. $where .= " and type = '$warehouse'";
  2490. }
  2491. if ($timetk && $timetj) {
  2492. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2493. }
  2494. if ($orderinfo) {
  2495. $where .= " and orderinfo = '$orderinfo'";
  2496. }
  2497. if ($number) {
  2498. $where .= " and number = '$number'";
  2499. }
  2500. if ($express) {
  2501. $where .= " and express = '$express'";
  2502. }
  2503. if ($waybill) {
  2504. $where .= " and waybill = '$waybill'";
  2505. }
  2506. if ($library) {
  2507. $where .= " and library = '$library'";
  2508. }
  2509. if ($print) {
  2510. $where .= " and print = '$print'";
  2511. }
  2512. if ($libraryconfirm) {
  2513. $where .= " and libraryconfirm = '$libraryconfirm'";
  2514. }
  2515. if ($state) {
  2516. $where .= " and state = '$state'";
  2517. }
  2518. if ($shop) {
  2519. $where .= " and shop = '$shop'";
  2520. }
  2521. if ($country) {
  2522. $where .= " and country = '$country'";
  2523. }
  2524. if ($sfxh != '') {
  2525. $where .= " and sfxh = '$sfxh'";
  2526. }
  2527. if ($so) {
  2528. $where .= " and shipremarks like '%$so%'";
  2529. }
  2530. if ($source) {
  2531. if ($source == '2d') {
  2532. $where .= " and source >= '2'";
  2533. } else {
  2534. $where .= " and source = '$source'";
  2535. }
  2536. }
  2537. if (isset($_SESSION['api'])) {
  2538. foreach ($user as $value) {
  2539. $fgshop .= " shop = " . $value . " or";
  2540. }
  2541. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2542. }
  2543. if ($orderurl) {
  2544. $url = $this->orderurl->read($orderurl);
  2545. $where .= " and link like '%" . $url['url'] . "%'";
  2546. }
  2547. if($productid){
  2548. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2549. }
  2550. //数据排序
  2551. $order_str = "librarytime desc";
  2552. if (empty($page)) {
  2553. $start = 0;
  2554. $perpage = 1;
  2555. } else {
  2556. $start = ($page - 1) * $perpage;
  2557. }
  2558. //取得信息列表
  2559. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2560. //格式化数据
  2561. foreach ($info_list as $key => $value) {
  2562. $shop = $this->shop->read($value['shop']);
  2563. $info_list[$key]['shop'] = $shop['shopname'];
  2564. $express = $this->express->read($value['express']);
  2565. $info_list[$key]['express'] = $express['servicename'];
  2566. $warehouse = $this->warehouse->read($value['type']);
  2567. $info_list[$key]['type'] = $warehouse['title'];
  2568. if ($value['librarytime'] == '0') {
  2569. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2570. } else {
  2571. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2572. }
  2573. }
  2574. $total = $this->$sj->find_count($where);
  2575. $pagenum = ceil($total / $perpage);
  2576. $over = $total - ($start + $perpage);
  2577. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2578. echo json_encode($rows);
  2579. exit;
  2580. }
  2581. $this->data['express'] = $this->express->find_all();
  2582. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2583. $this->data['wlshop'] = $wlshop;
  2584. $user = $this->user->get_api($_SESSION['api']);
  2585. $powerid = $this->power->read($user['power']);
  2586. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2587. $pid = '';
  2588. foreach ($powertext as $v) {
  2589. $pid .= " id = " . $v . " or";
  2590. }
  2591. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2592. $this->data['fullorderexcel'] = $fullorderexcel;
  2593. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2594. $this->data['orderurl'] = $orderurl;
  2595. $this->_Template('whlabel_outorder', $this->data);
  2596. }
  2597. //tt出库
  2598. public function _toutorder()
  2599. {
  2600. $fgshop = "";
  2601. $sid = "";
  2602. if (isset($_SESSION['api'])) {
  2603. $user = $this->user->get_api($_SESSION['api']);
  2604. $usp = $user;
  2605. $user = explode('|', trim($user['shop'], '|'));
  2606. foreach ($user as $value) {
  2607. $fgshop .= " shop = " . $value . " or";
  2608. $sid .= " id = " . $value . " or";
  2609. }
  2610. } else {
  2611. echo "请重新登录";
  2612. die;
  2613. }
  2614. $post = $this->input->post(NULL, TRUE);
  2615. if (isset($post['page'])) {
  2616. $page = $this->input->post('page', true);
  2617. $perpage = $this->input->post('perpage', true);
  2618. $warehouse = $this->input->post('warehouse', true);
  2619. $xztime = $this->input->post('xztime', true);
  2620. $timetk = $this->input->post('timetkk', true);
  2621. $timetj = $this->input->post('timetjj', true);
  2622. $shop = $this->input->post('shop', true);
  2623. $source = $this->input->post('source', true);
  2624. $orderinfo = $this->input->post('orderinfo', true);
  2625. $number = $this->input->post('number', true);
  2626. $sfxh = $this->input->post('sfxh', true);
  2627. $express = $this->input->post('express', true);
  2628. $waybill = $this->input->post('waybill', true);
  2629. $library = $this->input->post('library', true);
  2630. $country = $this->input->post('country', true);
  2631. $so = $this->input->post('so', true);
  2632. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2633. $print = $this->input->post('print', true);
  2634. $state = $this->input->post('state', true);
  2635. $orderurl = $this->input->post('orderurl', true);
  2636. $timetk = strtotime($timetk);
  2637. $timetj = strtotime($timetj);
  2638. /**
  2639. $sj = $this->input->post('sj',true);
  2640. if($sj)
  2641. {
  2642. $sj = $this->input->post('sj',true);
  2643. }
  2644. else
  2645. {
  2646. $sj = "fullorder";
  2647. }
  2648. **/
  2649. $sj = "fullordertt";
  2650. $where = "1=1";
  2651. if ($warehouse) {
  2652. $where .= " and type = '$warehouse'";
  2653. }
  2654. if ($timetk && $timetj) {
  2655. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2656. }
  2657. if ($orderinfo) {
  2658. $where .= " and orderinfo = '$orderinfo'";
  2659. }
  2660. if ($number) {
  2661. $where .= " and number = '$number'";
  2662. }
  2663. if ($express) {
  2664. $where .= " and express = '$express'";
  2665. }
  2666. if ($waybill) {
  2667. $where .= " and waybill = '$waybill'";
  2668. }
  2669. if ($library) {
  2670. $where .= " and library = '$library'";
  2671. }
  2672. if ($print) {
  2673. $where .= " and print = '$print'";
  2674. }
  2675. if ($libraryconfirm) {
  2676. $where .= " and libraryconfirm = '$libraryconfirm'";
  2677. }
  2678. if ($state) {
  2679. $where .= " and state = '$state'";
  2680. }
  2681. if ($shop) {
  2682. $where .= " and shop = '$shop'";
  2683. }
  2684. if ($country) {
  2685. $where .= " and country = '$country'";
  2686. }
  2687. if ($sfxh != '') {
  2688. $where .= " and sfxh = '$sfxh'";
  2689. }
  2690. if ($so) {
  2691. $where .= " and shipremarks like '%$so%'";
  2692. }
  2693. if ($source) {
  2694. if ($source == '2d') {
  2695. $where .= " and source >= '2'";
  2696. } else {
  2697. $where .= " and source = '$source'";
  2698. }
  2699. }
  2700. if (isset($_SESSION['api'])) {
  2701. foreach ($user as $value) {
  2702. $fgshop .= " shop = " . $value . " or";
  2703. }
  2704. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2705. }
  2706. if ($orderurl) {
  2707. $url = $this->orderurl->read($orderurl);
  2708. $where .= " and link like '%" . $url['url'] . "%'";
  2709. }
  2710. //数据排序
  2711. $order_str = "librarytime desc";
  2712. if (empty($page)) {
  2713. $start = 0;
  2714. $perpage = 1;
  2715. } else {
  2716. $start = ($page - 1) * $perpage;
  2717. }
  2718. //取得信息列表
  2719. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2720. //格式化数据
  2721. foreach ($info_list as $key => $value) {
  2722. $shop = $this->shop->read($value['shop']);
  2723. $info_list[$key]['shop'] = $shop['shopname'];
  2724. $express = $this->express->read($value['express']);
  2725. $info_list[$key]['express'] = $express['servicename'];
  2726. $warehouse = $this->warehouse->read($value['type']);
  2727. $info_list[$key]['type'] = $warehouse['title'];
  2728. if ($value['librarytime'] == '0') {
  2729. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2730. } else {
  2731. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2732. }
  2733. }
  2734. $total = $this->$sj->find_count($where);
  2735. $pagenum = ceil($total / $perpage);
  2736. $over = $total - ($start + $perpage);
  2737. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2738. echo json_encode($rows);
  2739. exit;
  2740. }
  2741. $this->data['express'] = $this->express->find_all();
  2742. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2743. $this->data['wlshop'] = $wlshop;
  2744. $user = $this->user->get_api($_SESSION['api']);
  2745. $powerid = $this->power->read($user['power']);
  2746. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2747. $pid = '';
  2748. foreach ($powertext as $v) {
  2749. $pid .= " id = " . $v . " or";
  2750. }
  2751. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2752. $this->data['fullorderexcel'] = $fullorderexcel;
  2753. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2754. $this->data['orderurl'] = $orderurl;
  2755. $this->_Template('whlabel_toutorder', $this->data);
  2756. }
  2757. //tt出库
  2758. public function _aoutorder()
  2759. {
  2760. if (isset($_SESSION['api'])) {
  2761. $user = $this->user->get_api($_SESSION['api']);
  2762. $usp = $user;
  2763. $fgshop = "";
  2764. $sid = "";
  2765. $user = explode('|', trim($user['shop'], '|'));
  2766. foreach ($user as $value) {
  2767. $fgshop .= " shop = " . $value . " or";
  2768. $sid .= " id = " . $value . " or";
  2769. }
  2770. } else {
  2771. echo "请重新登录";
  2772. }
  2773. $post = $this->input->post(NULL, TRUE);
  2774. if (isset($post['page'])) {
  2775. $page = $this->input->post('page', true);
  2776. $perpage = $this->input->post('perpage', true);
  2777. $warehouse = $this->input->post('warehouse', true);
  2778. $xztime = $this->input->post('xztime', true);
  2779. $timetk = $this->input->post('timetkk', true);
  2780. $timetj = $this->input->post('timetjj', true);
  2781. $shop = $this->input->post('shop', true);
  2782. $source = $this->input->post('source', true);
  2783. $orderinfo = $this->input->post('orderinfo', true);
  2784. $number = $this->input->post('number', true);
  2785. $sfxh = $this->input->post('sfxh', true);
  2786. $express = $this->input->post('express', true);
  2787. $waybill = $this->input->post('waybill', true);
  2788. $library = $this->input->post('library', true);
  2789. $country = $this->input->post('country', true);
  2790. $so = $this->input->post('so', true);
  2791. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2792. $print = $this->input->post('print', true);
  2793. $state = $this->input->post('state', true);
  2794. $orderurl = $this->input->post('orderurl', true);
  2795. $timetk = strtotime($timetk);
  2796. $timetj = strtotime($timetj);
  2797. /**
  2798. $sj = $this->input->post('sj',true);
  2799. if($sj)
  2800. {
  2801. $sj = $this->input->post('sj',true);
  2802. }
  2803. else
  2804. {
  2805. $sj = "fullorder";
  2806. }
  2807. **/
  2808. $sj = "fullorderamz";
  2809. $where = "1=1";
  2810. if ($warehouse) {
  2811. $where .= " and type = '$warehouse'";
  2812. }
  2813. if ($timetk && $timetj) {
  2814. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2815. }
  2816. if ($orderinfo) {
  2817. $where .= " and orderinfo = '$orderinfo'";
  2818. }
  2819. if ($number) {
  2820. $where .= " and number = '$number'";
  2821. }
  2822. if ($express) {
  2823. $where .= " and express = '$express'";
  2824. }
  2825. if ($waybill) {
  2826. $where .= " and waybill = '$waybill'";
  2827. }
  2828. if ($library) {
  2829. $where .= " and library = '$library'";
  2830. }
  2831. if ($print) {
  2832. $where .= " and print = '$print'";
  2833. }
  2834. if ($libraryconfirm) {
  2835. $where .= " and libraryconfirm = '$libraryconfirm'";
  2836. }
  2837. if ($state) {
  2838. $where .= " and state = '$state'";
  2839. }
  2840. if ($shop) {
  2841. $where .= " and shop = '$shop'";
  2842. }
  2843. if ($country) {
  2844. $where .= " and country = '$country'";
  2845. }
  2846. if ($sfxh != '') {
  2847. $where .= " and sfxh = '$sfxh'";
  2848. }
  2849. if ($so) {
  2850. $where .= " and shipremarks like '%$so%'";
  2851. }
  2852. if ($source) {
  2853. if ($source == '2d') {
  2854. $where .= " and source >= '2'";
  2855. } else {
  2856. $where .= " and source = '$source'";
  2857. }
  2858. }
  2859. if (isset($_SESSION['api'])) {
  2860. foreach ($user as $value) {
  2861. $fgshop .= " shop = " . $value . " or";
  2862. }
  2863. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2864. }
  2865. if ($orderurl) {
  2866. $url = $this->orderurl->read($orderurl);
  2867. $where .= " and link like '%" . $url['url'] . "%'";
  2868. }
  2869. //数据排序
  2870. $order_str = "librarytime desc";
  2871. if (empty($page)) {
  2872. $start = 0;
  2873. $perpage = 1;
  2874. } else {
  2875. $start = ($page - 1) * $perpage;
  2876. }
  2877. //取得信息列表
  2878. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2879. //格式化数据
  2880. foreach ($info_list as $key => $value) {
  2881. $shop = $this->shop->read($value['shop']);
  2882. $info_list[$key]['shop'] = $shop['shopname'];
  2883. $express = $this->express->read($value['express']);
  2884. $info_list[$key]['express'] = $express['servicename'];
  2885. $warehouse = $this->warehouse->read($value['type']);
  2886. $info_list[$key]['type'] = $warehouse['title'];
  2887. if ($value['librarytime'] == '0') {
  2888. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2889. } else {
  2890. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2891. }
  2892. }
  2893. $total = $this->$sj->find_count($where);
  2894. $pagenum = ceil($total / $perpage);
  2895. $over = $total - ($start + $perpage);
  2896. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2897. echo json_encode($rows);
  2898. exit;
  2899. }
  2900. $this->data['express'] = $this->express->find_all();
  2901. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2902. $this->data['wlshop'] = $wlshop;
  2903. $user = $this->user->get_api($_SESSION['api']);
  2904. $powerid = $this->power->read($user['power']);
  2905. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2906. $pid = '';
  2907. foreach ($powertext as $v) {
  2908. $pid .= " id = " . $v . " or";
  2909. }
  2910. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2911. $this->data['fullorderexcel'] = $fullorderexcel;
  2912. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2913. $this->data['orderurl'] = $orderurl;
  2914. $this->_Template('whlabel_aoutorder', $this->data);
  2915. }
  2916. //速卖通出库订单
  2917. public function _soutorder()
  2918. {
  2919. if (isset($_SESSION['api'])) {
  2920. $user = $this->user->get_api($_SESSION['api']);
  2921. $usp = $user;
  2922. $fgshop = "";
  2923. $sid = "";
  2924. $user = explode('|', trim($user['shop'], '|'));
  2925. foreach ($user as $value) {
  2926. $sid .= " id = " . $value . " or";
  2927. }
  2928. }
  2929. $post = $this->input->post(NULL, TRUE);
  2930. if (isset($post['page'])) {
  2931. $page = $this->input->post('page', true);
  2932. $perpage = $this->input->post('perpage', true);
  2933. $warehouse = $this->input->post('warehouse', true);
  2934. $xztime = $this->input->post('xztime', true);
  2935. $timetk = $this->input->post('timetkk', true);
  2936. $timetj = $this->input->post('timetjj', true);
  2937. $shop = $this->input->post('shop', true);
  2938. $source = $this->input->post('source', true);
  2939. $orderinfo = $this->input->post('orderinfo', true);
  2940. $number = $this->input->post('number', true);
  2941. $express = $this->input->post('express', true);
  2942. $waybill = $this->input->post('waybill', true);
  2943. $library = $this->input->post('library', true);
  2944. $country = $this->input->post('country', true);
  2945. $sfxh = $this->input->post('sfxh', true);
  2946. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2947. $print = $this->input->post('print', true);
  2948. $state = $this->input->post('state', true);
  2949. $so = $this->input->post('so', true);
  2950. $timetk = strtotime($timetk);
  2951. $timetj = strtotime($timetj);
  2952. /**
  2953. $sj = $this->input->post('sj',true);
  2954. if($sj)
  2955. {
  2956. $sj = $this->input->post('sj',true);
  2957. }
  2958. else
  2959. {
  2960. $sj = "fullorder";
  2961. }
  2962. **/
  2963. $sj = "fullordersmt";
  2964. $where = "1=1";
  2965. if ($warehouse) {
  2966. $where .= " and type = '$warehouse'";
  2967. }
  2968. if ($timetk && $timetj) {
  2969. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2970. }
  2971. if ($orderinfo) {
  2972. $where .= " and orderinfo = '$orderinfo'";
  2973. }
  2974. if ($number) {
  2975. $where .= " and number = '$number'";
  2976. }
  2977. if ($express) {
  2978. $where .= " and express = '$express'";
  2979. }
  2980. if ($waybill) {
  2981. $where .= " and waybill = '$waybill'";
  2982. }
  2983. if ($library) {
  2984. $where .= " and library = '$library'";
  2985. }
  2986. if ($print) {
  2987. $where .= " and print = '$print'";
  2988. }
  2989. if ($libraryconfirm) {
  2990. $where .= " and libraryconfirm = '$libraryconfirm'";
  2991. }
  2992. if ($state) {
  2993. $where .= " and state = '$state'";
  2994. }
  2995. if ($shop) {
  2996. $where .= " and shop = '$shop'";
  2997. }
  2998. if ($sfxh != '') {
  2999. $where .= " and sfxh = '$sfxh'";
  3000. }
  3001. if ($so) {
  3002. $where .= " and shipremarks like '%$so%'";
  3003. }
  3004. if ($source) {
  3005. $where .= " and source = '$source'";
  3006. }
  3007. if ($country) {
  3008. $where .= " and country = '$country'";
  3009. } else {
  3010. if (isset($_SESSION['api'])) {
  3011. foreach ($user as $value) {
  3012. $fgshop .= " shop = " . $value . " or";
  3013. }
  3014. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3015. }
  3016. }
  3017. //数据排序
  3018. $order_str = "librarytime desc";
  3019. if (empty($page)) {
  3020. $start = 0;
  3021. $perpage = 1;
  3022. } else {
  3023. $start = ($page - 1) * $perpage;
  3024. }
  3025. //取得信息列表
  3026. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3027. //格式化数据
  3028. foreach ($info_list as $key => $value) {
  3029. $shop = $this->shop->read($value['shop']);
  3030. $info_list[$key]['shop'] = $shop['shopname'];
  3031. $express = $this->express->read($value['express']);
  3032. $info_list[$key]['express'] = $express['servicename'];
  3033. $warehouse = $this->warehouse->read($value['type']);
  3034. $info_list[$key]['type'] = $warehouse['title'];
  3035. if ($value['librarytime'] == '0') {
  3036. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3037. } else {
  3038. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3039. }
  3040. }
  3041. $total = $this->$sj->find_count($where);
  3042. $pagenum = ceil($total / $perpage);
  3043. $over = $total - ($start + $perpage);
  3044. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3045. echo json_encode($rows);
  3046. exit;
  3047. }
  3048. $this->data['express'] = $this->express->find_all();
  3049. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3050. $this->data['wlshop'] = $wlshop;
  3051. $user = $this->user->get_api($_SESSION['api']);
  3052. $powerid = $this->power->read($user['power']);
  3053. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3054. $pid = '';
  3055. foreach ($powertext as $v) {
  3056. $pid .= " id = " . $v . " or";
  3057. }
  3058. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3059. $this->data['fullorderexcel'] = $fullorderexcel;
  3060. $this->_Template('whlabel_soutorder', $this->data);
  3061. }
  3062. //订单退库
  3063. public function _retreat()
  3064. {
  3065. $post = $this->input->post(NULL, TRUE);
  3066. if (isset($post['page'])) {
  3067. $page = $this->input->post('page', true);
  3068. $perpage = $this->input->post('perpage', true);
  3069. $warehouse = $this->input->post('warehouse', true);
  3070. $timetk = $this->input->post('timetk', true);
  3071. $timetj = $this->input->post('timetj', true);
  3072. $shop = $this->input->post('shop', true);
  3073. $source = $this->input->post('source', true);
  3074. $state = $this->input->post('state', true);
  3075. $review = $this->input->post('review', true);
  3076. $state = $this->input->post('state', true);
  3077. $express = $this->input->post('express', true);
  3078. $orderinfo = $this->input->post('orderinfo', true);
  3079. $user = $this->input->post('user', true);
  3080. $name = $this->input->post('name', true);
  3081. $waybill = $this->input->post('waybill', true);
  3082. $timetk = strtotime($timetk);
  3083. $timetj = strtotime($timetj);
  3084. $where = "(state=206 or state=210) and mergeid = 0";
  3085. if ($warehouse) {
  3086. $where .= " and state = '$warehouse'";
  3087. }
  3088. if ($timetk && $timetj) {
  3089. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3090. }
  3091. if ($shop) {
  3092. $where .= " and shop = '$shop'";
  3093. }
  3094. if ($source) {
  3095. $where .= " and source = '$source'";
  3096. }
  3097. if ($state) {
  3098. $where .= " and state = '$state'";
  3099. }
  3100. if ($review) {
  3101. $where .= " and review = '$review'";
  3102. }
  3103. if ($state) {
  3104. $where .= " and state = '$state'";
  3105. }
  3106. if ($express) {
  3107. $where .= " and express = '$express'";
  3108. }
  3109. if ($orderinfo) {
  3110. $where .= " and orderinfo = '$orderinfo'";
  3111. }
  3112. if ($user) {
  3113. $where .= " and user = '$user'";
  3114. }
  3115. if ($name) {
  3116. $where .= " and name = '$name'";
  3117. }
  3118. if ($waybill) {
  3119. $where .= " and waybill = '$waybill'";
  3120. }
  3121. //数据排序
  3122. $order_str = "id desc";
  3123. if (empty($page)) {
  3124. $start = 0;
  3125. $perpage = 1;
  3126. } else {
  3127. $start = ($page - 1) * $perpage;
  3128. }
  3129. //取得信息列表
  3130. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3131. //格式化数据
  3132. foreach ($info_list as $key => $value) {
  3133. $shop = $this->shop->read($value['shop']);
  3134. $info_list[$key]['shop'] = $shop['shopname'];
  3135. $warehouse = $this->warehouse->read($value['warehouse']);
  3136. $info_list[$key]['warehouse'] = $warehouse['title'];
  3137. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3138. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3139. if ($value['waybill'] == 0) {
  3140. $info_list[$key]['waybill'] = "";
  3141. }
  3142. $express = $this->express->read($value['express']);
  3143. $info_list[$key]['express'] = $express['title'];
  3144. $typeclass = $this->typeclass->read($value['state']);
  3145. $info_list[$key]['state'] = $typeclass['title'];
  3146. }
  3147. $total = $this->fullorder->find_count($where);
  3148. $pagenum = ceil($total / $perpage);
  3149. $over = $total - ($start + $perpage);
  3150. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3151. echo json_encode($rows);
  3152. exit;
  3153. }
  3154. $this->data['express'] = $this->express->find_all();
  3155. $this->_Template('whlabel_retreat', $this->data);
  3156. }
  3157. //退库标签浏览
  3158. public function _retreatlk()
  3159. {
  3160. $post = $this->input->post(NULL, TRUE);
  3161. if (isset($post['page'])) {
  3162. $page = $this->input->post('page', true);
  3163. $perpage = $this->input->post('perpage', true);
  3164. $timetk = $this->input->post('timetk', true);
  3165. $timetj = $this->input->post('timetj', true);
  3166. $sku = $this->input->post('sku', true);
  3167. $warehouse = $this->input->post('warehouse', true);
  3168. $purchase = $this->input->post('purchase', true);
  3169. $orderinfo = $this->input->post('orderinfo', true);
  3170. $waybill = $this->input->post('waybill', true);
  3171. $category = $this->input->post('category', true);
  3172. $size = $this->input->post('size', true);
  3173. $grade = $this->input->post('grade', true);
  3174. $color = $this->input->post('color', true);
  3175. $lowe = $this->input->post('lowe', true);
  3176. $state = $this->input->post('state', true);
  3177. $timetk = strtotime($timetk);
  3178. $timetj = strtotime($timetj);
  3179. $where = "state=2";
  3180. if ($timetk && $timetj) {
  3181. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3182. }
  3183. if ($sku) {
  3184. $where .= " and sku = '$sku'";
  3185. }
  3186. if ($warehouse) {
  3187. $where .= " and warehouse = '$warehouse'";
  3188. }
  3189. if ($purchase) {
  3190. $where .= " and purchase = '$purchase'";
  3191. }
  3192. if ($orderinfo) {
  3193. $where .= " and orderinfo = '$orderinfo'";
  3194. }
  3195. if ($waybill) {
  3196. $where .= " and waybill = '$waybill'";
  3197. }
  3198. if ($category) {
  3199. $where .= " and features like '%-$category-%'";
  3200. }
  3201. if ($size) {
  3202. $where .= " and features like '%-$size-%'";
  3203. }
  3204. if ($grade) {
  3205. $where .= " and features like '%-$grade-%'";
  3206. }
  3207. if ($color) {
  3208. $where .= " and features like '%-$color-%'";
  3209. }
  3210. if ($lowe) {
  3211. $where .= " and features like '%-$lowe-%'";
  3212. }
  3213. //数据排序
  3214. $order_str = "time desc";
  3215. if (empty($page)) {
  3216. $start = 0;
  3217. $perpage = 1;
  3218. } else {
  3219. $start = ($page - 1) * $perpage;
  3220. }
  3221. //取得信息列表
  3222. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3223. foreach ($info_list as $key => $value) {
  3224. $warehouse = $this->warehouse->read($value['warehouse']);
  3225. $info_list[$key]['warehouse'] = $warehouse['title'];
  3226. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3227. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3228. $purchase = $this->purchase->read($value['purchase']);
  3229. $info_list[$key]['purchase'] = $purchase['title'];
  3230. if ($value['outk'] != 0) {
  3231. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3232. } else {
  3233. $info_list[$key]['outk'] = "";
  3234. }
  3235. if ($value['retreat'] != 0) {
  3236. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3237. } else {
  3238. $info_list[$key]['retreat'] = "";
  3239. }
  3240. if ($value['orderinfo'] == 0) {
  3241. $info_list[$key]['orderinfo'] = "";
  3242. }
  3243. if ($value['waybill'] == 0) {
  3244. $info_list[$key]['waybill'] = "";
  3245. }
  3246. }
  3247. $total = $this->whlabel->find_count($where);
  3248. $pagenum = ceil($total / $perpage);
  3249. $over = $total - ($start + $perpage);
  3250. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3251. echo json_encode($rows);
  3252. exit;
  3253. }
  3254. $this->_Template('whlabel_retreatlk', $this->data);
  3255. }
  3256. //更换标签及浏览
  3257. public function _change()
  3258. {
  3259. $post = $this->input->post(NULL, TRUE);
  3260. if (isset($post['page'])) {
  3261. $page = $this->input->post('page', true);
  3262. $perpage = $this->input->post('perpage', true);
  3263. $timetk = $this->input->post('timetk', true);
  3264. $timetj = $this->input->post('timetj', true);
  3265. $label = $this->input->post('label', true);
  3266. $oldlabel = $this->input->post('oldlabel', true);
  3267. $timetk = strtotime($timetk);
  3268. $timetj = strtotime($timetj);
  3269. $where = "state=10 ";
  3270. if ($timetk && $timetj) {
  3271. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3272. }
  3273. if ($label) {
  3274. $where .= " and label = '$label'";
  3275. }
  3276. if ($oldlabel) {
  3277. $where .= " and oldlabel = '$oldlabel'";
  3278. }
  3279. //数据排序
  3280. $order_str = "time asc";
  3281. if (empty($page)) {
  3282. $start = 0;
  3283. $perpage = 1;
  3284. } else {
  3285. $start = ($page - 1) * $perpage;
  3286. }
  3287. //取得信息列表
  3288. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3289. foreach ($info_list as $key => $value) {
  3290. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3291. }
  3292. $total = $this->whlabel->find_count($where);
  3293. $pagenum = ceil($total / $perpage);
  3294. $over = $total - ($start + $perpage);
  3295. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3296. echo json_encode($rows);
  3297. exit;
  3298. }
  3299. $this->_Template('whlabel_change', $this->data);
  3300. }
  3301. //产品标签
  3302. public function _cpbqdc()
  3303. {
  3304. if (isset($_GET['excel'])) {
  3305. $where = "1=1";
  3306. //数据排序
  3307. $order_str = "id desc";
  3308. if (empty($page)) {
  3309. $start = 0;
  3310. $perpage = 1;
  3311. } else {
  3312. $start = ($page - 1) * $perpage;
  3313. }
  3314. $warehouse = $this->input->get('warehouse', true);
  3315. $state = $this->input->get('state', true);
  3316. $timetk = $this->input->get('timetkk', true);
  3317. $timetj = $this->input->get('timetjj', true);
  3318. $timetk = strtotime($timetk);
  3319. $timetj = strtotime($timetj);
  3320. if ($warehouse) {
  3321. $where .= " and warehouse = '$warehouse'";
  3322. }
  3323. if ($state || $state == 0) {
  3324. $where .= " and state = '$state'";
  3325. }
  3326. if ($timetk && $timetj) {
  3327. $where .= " and time > '$timetk' and time < '$timetj'";
  3328. }
  3329. //取得信息列表
  3330. $info_list = $this->whlabel->find_all($where, '*');
  3331. $rows = array();
  3332. $list = array();
  3333. foreach ($info_list as $key => $value) {
  3334. $rows[$value['time']] = $value; //所有数据sku
  3335. }
  3336. foreach ($rows as $value) {
  3337. $warehouse = $this->warehouse->read($value['warehouse']);
  3338. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3339. $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);
  3340. }
  3341. $title = "产品标签统计表";
  3342. $titlename = "<table border=1>
  3343. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3344. <tr align='center'>
  3345. <td>仓库</td>
  3346. <td>SKU</td>
  3347. <td>产品</td>
  3348. <td>入库时间</td>
  3349. <td>操作时间</td>
  3350. <td>备注</td>
  3351. <td>数量</td>
  3352. </tr>
  3353. </table>";
  3354. $filename = $title . ".xls";
  3355. $tail = "";
  3356. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3357. }
  3358. }
  3359. //进销存导出
  3360. public function _exceljxc()
  3361. {
  3362. $classid = $this->classid->sku();
  3363. $pm = $classid;
  3364. $typeclass = array();
  3365. $tc = $this->typeclass->find_all();
  3366. foreach ($tc as $v) {
  3367. $typeclass[$v['id']] = $v;
  3368. }
  3369. $prc = array();
  3370. $purchase = $this->purchase->find_all();
  3371. foreach ($purchase as $k => $v) {
  3372. $prc[$v['id']] = $v['title'];
  3373. }
  3374. if (isset($_GET['excel'])) {
  3375. $where = "sku != 'Preset'";
  3376. //数据排序
  3377. $order_str = "id desc";
  3378. if (empty($page)) {
  3379. $start = 0;
  3380. $perpage = 1;
  3381. } else {
  3382. $start = ($page - 1) * $perpage;
  3383. }
  3384. $category = $this->input->get('category', true);
  3385. $warehouse = $this->input->get('warehouse', true);
  3386. $excelid = $this->input->get('sid', true);
  3387. if ($category) {
  3388. $where .= " and features like '%-$category-%'";
  3389. }
  3390. if ($warehouse) {
  3391. $where .= " and warehouse = '$warehouse'";
  3392. }
  3393. $xzid = '';
  3394. if ($excelid) {
  3395. $excelid = explode(',', trim($excelid, ','));
  3396. foreach ($excelid as $key => $value) {
  3397. $xzid .= " id = " . $value . " or";
  3398. }
  3399. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3400. }
  3401. //取得信息列表
  3402. /**
  3403. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3404. $rows = array();$list = array();
  3405. foreach ($info_list as $key=>$value)
  3406. {
  3407. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3408. }
  3409. **/
  3410. $wt = array();
  3411. $whlabel_type = $this->whlabel_type->find_all();
  3412. foreach ($whlabel_type as $v) {
  3413. $wt[$v['id']] = $v['title'];
  3414. }
  3415. $wh = array();
  3416. $w = $this->warehouse->find_all('1=1', 'id,title');
  3417. foreach ($w as $v) {
  3418. $wh[$v['id']] = $v['title'];
  3419. }
  3420. $list = array();
  3421. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3422. foreach ($rows as $key => $value) {
  3423. if (isset($wt[$value['type']])) {
  3424. $rows[$key]['type'] = $wt[$value['type']];
  3425. } else {
  3426. $rows[$key]['type'] = '未设置';
  3427. }
  3428. $bm = '03';
  3429. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3430. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3431. $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');
  3432. $details = array();
  3433. $cpid = array();
  3434. $cpbz = array();
  3435. $c = 0;
  3436. $g = 0;
  3437. $x = 0;
  3438. $t = 0;
  3439. $s = 0;
  3440. $q = 0;
  3441. foreach ($sd as $k => $v) {
  3442. if ($v['state'] == 0) {
  3443. $c++;
  3444. if ($v['cpid'] != 0) {
  3445. $cpid[$v['cpid']] = $v['cpid'];
  3446. }
  3447. if ($v['cpbz'] != '') {
  3448. $cpbz[$v['cpbz']] = $v['cpbz'];
  3449. }
  3450. }
  3451. if ($v['state'] != 9) {
  3452. $g++;
  3453. }
  3454. if ($v['state'] == 1) {
  3455. $x++;
  3456. }
  3457. if ($v['state'] == 2) {
  3458. $t++;
  3459. }
  3460. if ($v['state'] == 8) {
  3461. $s++;
  3462. }
  3463. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3464. $q++;
  3465. }
  3466. $details[$v['details']] = $v['details'];
  3467. }
  3468. $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'] . '"');
  3469. $rows[$key]['details'] = implode("、", $details);
  3470. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3471. $number = $value['number'];
  3472. $ftime = time() - 15 * 24 * 3600;
  3473. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3474. $rows[$key]['number'] = $g;
  3475. $rows[$key]['c'] = $c;
  3476. $rows[$key]['x'] = $x;
  3477. $rows[$key]['t'] = $t;
  3478. $rows[$key]['s'] = $s;
  3479. $rows[$key]['q'] = $q;
  3480. $rows[$key]['z'] = $z;
  3481. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3482. $features = explode('-', trim($features, '-'));
  3483. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3484. // $pm = $classid;
  3485. // $jm = $classid;
  3486. // foreach($features as $k=>$v)
  3487. // {
  3488. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3489. // {
  3490. // if($typeclass[$v]['bm'] != '')
  3491. // {
  3492. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3493. // }
  3494. // }
  3495. // if($v != 0)
  3496. // {
  3497. // if(!isset($typeclass[$v]))
  3498. // {
  3499. // continue;
  3500. // }
  3501. // if(isset($pm[$typeclass[$v]['classid']]))
  3502. // {
  3503. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3504. // {
  3505. // $tz = explode('|',$typeclass[$v]['zh']);
  3506. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3507. // }
  3508. // else
  3509. // {
  3510. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3511. // }
  3512. // }
  3513. // if(isset($jm[$typeclass[$v]['classid']]))
  3514. // {
  3515. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3516. // }
  3517. // }
  3518. // }
  3519. // $jm = array_filter($jm);
  3520. // $rows[$key]['bs'] = implode("-",$jm);
  3521. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3522. // $zh = implode(" ",$pm);
  3523. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3524. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3525. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3526. // $rows[$key]['features'] = $zh;
  3527. }
  3528. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3529. $final_list = [];
  3530. foreach ($list as $k => $v) {
  3531. if (empty($v['sku'])) {
  3532. continue;
  3533. }
  3534. $final_list[] = [
  3535. "warehouse" => $v["warehouse"],
  3536. "purchase" => $v["purchase"],
  3537. "details" => $v["details"],
  3538. "cpid" => $v["cpid"],
  3539. "dbcontent" => $v["dbcontent"],
  3540. "sku" => $v["sku"],
  3541. "cs" => $v["bm"],
  3542. "bs" => $v["jm"],
  3543. "title" => $v["title"],
  3544. "features" => $v["pm"],
  3545. "cpbz" => $v["cpbz"],
  3546. "sm" => $v["sm"],
  3547. "type" => $v["type"],
  3548. "number" => $v["number"],
  3549. "c" => $v["c"],
  3550. "x" => $v["x"],
  3551. "t" => $v["t"],
  3552. "s" => $v["s"],
  3553. "q" => $v["q"],
  3554. "z" => $v["z"],
  3555. "weight" => $v['weight'],
  3556. ];
  3557. }
  3558. $title = "总进销存统计表";
  3559. $titlename = "<table border=1>
  3560. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3561. <tr align='center'>
  3562. <td>仓库</td>
  3563. <td>供应商</td>
  3564. <td>位置</td>
  3565. <td>库存编码</td>
  3566. <td>类目</td>
  3567. <td>SKU</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>删除数量</td>
  3580. <td>其它操作</td>
  3581. <td>占单数量</td>
  3582. <td>重量(g)</td>
  3583. </tr>
  3584. </table>";
  3585. $filename = $title . ".xls";
  3586. $tail = "";
  3587. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3588. }
  3589. }
  3590. //入库导出
  3591. public function _excelr()
  3592. {
  3593. if (isset($_GET['excel'])) {
  3594. $category = $this->input->get('category', true);
  3595. $size = $this->input->get('size', true);
  3596. $grade = $this->input->get('grade', true);
  3597. $color = $this->input->get('color', true);
  3598. $lowe = $this->input->get('lowe', true);
  3599. $sku = $this->input->get('sku', true);
  3600. $warehouse = $this->input->get('warehouse', true);
  3601. $purchase = $this->input->get('purchase', true);
  3602. $ktime = $this->input->get('ktime', true);
  3603. $jtime = $this->input->get('jtime', true);
  3604. $ktime = strtotime($ktime);
  3605. $jtime = strtotime($jtime);
  3606. $where = "1=1";
  3607. $gj = "";
  3608. $ck = "";
  3609. if ($category) {
  3610. $where .= " and features like '%-$category-%'";
  3611. }
  3612. if ($size) {
  3613. $where .= " and features like '%-$size-%'";
  3614. }
  3615. if ($grade) {
  3616. $where .= " and features like '%-$grade-%'";
  3617. }
  3618. if ($color) {
  3619. $where .= " and features like '%-$color-%'";
  3620. }
  3621. if ($lowe) {
  3622. $where .= " and features like '%-$lowe-%'";
  3623. }
  3624. if ($warehouse) {
  3625. $where .= " and warehouse = '$warehouse'";
  3626. }
  3627. if ($purchase) {
  3628. $where .= " and purchase = '$purchase'";
  3629. }
  3630. if ($sku) {
  3631. $where .= " and sku = '$sku'";
  3632. }
  3633. if ($ktime && $jtime) {
  3634. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3635. }
  3636. //数据排序
  3637. $order_str = "id desc";
  3638. if (empty($page)) {
  3639. $start = 0;
  3640. $perpage = 1;
  3641. } else {
  3642. $start = ($page - 1) * $perpage;
  3643. }
  3644. $list = array();
  3645. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3646. foreach ($rows as $value) {
  3647. $ck = $this->warehouse->read($value['warehouse']);
  3648. $warehouse = $ck['title'];
  3649. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3650. $retreatwarehouse = $tkck['title'];
  3651. $gy = $this->purchase->read($value['purchase']);
  3652. $purchase = $gy['title'];
  3653. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3654. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3655. }
  3656. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3657. $titlename = "<table border=1>
  3658. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3659. <tr align='center'>
  3660. <td>仓库</td>
  3661. <td>SKU</td>
  3662. <td>产品</td>
  3663. <td>时间</td>
  3664. <td>数量</td>
  3665. </tr>
  3666. </table>";
  3667. $filename = $title . ".xls";
  3668. $tail = "";
  3669. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3670. }
  3671. }
  3672. //出库、退库导出
  3673. public function _excelct()
  3674. {
  3675. $classid = $this->classid->sku();
  3676. $pm = $classid;
  3677. $typeclass = array();
  3678. $tc = $this->typeclass->find_all();
  3679. foreach ($tc as $v) {
  3680. $typeclass[$v['id']] = $v;
  3681. }
  3682. $prc = array();
  3683. $purchase = $this->purchase->find_all();
  3684. foreach ($purchase as $k => $v) {
  3685. $prc[$v['id']] = $v['title'];
  3686. }
  3687. if (isset($_GET['excel'])) {
  3688. $wh = array();
  3689. $w = $this->warehouse->find_all('1=1', 'id,title');
  3690. foreach ($w as $v) {
  3691. $wh[$v['id']] = $v['title'];
  3692. }
  3693. $type = $this->input->get('excel', true);
  3694. $category = $this->input->get('category', true);
  3695. $size = $this->input->get('size', true);
  3696. $grade = $this->input->get('grade', true);
  3697. $color = $this->input->get('color', true);
  3698. $lowe = $this->input->get('lowe', true);
  3699. $sku = $this->input->get('sku', true);
  3700. $title = $this->input->get('title', true);
  3701. $warehouse = $this->input->get('warehouse', true);
  3702. $purchase = $this->input->get('purchase', true);
  3703. $lacetype = $this->input->get('lacetype', true);
  3704. $haircap = $this->input->get('haircap', true);
  3705. $lacecolor = $this->input->get('lacecolor', true);
  3706. $density = $this->input->get('density', true);
  3707. $details = $this->input->get('details', true);
  3708. $state = $this->input->get('state', true);
  3709. $shop = $this->input->get('shop', true);
  3710. $hairnumber = $this->input->get('hairnumber', true);
  3711. $type_leixi = $this->input->get('type', true);
  3712. $cpbz = $this->input->get('cpbz', true);
  3713. $sm = $this->input->get('sm', true);
  3714. $sid = $this->input->get('sid', true);
  3715. $ktime = $this->input->get('ktime', true);
  3716. $jtime = $this->input->get('jtime', true);
  3717. $ktime = strtotime($ktime);
  3718. $jtime = strtotime($jtime);
  3719. //$where = " 1=1 ";
  3720. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3721. $where = " sku != '' ";
  3722. $gj = "";
  3723. $ck = "";
  3724. if ($category) {
  3725. $where .= " and features like '%-$category-%'";
  3726. }
  3727. if ($size) {
  3728. $where .= " and features like '%-$size-%'";
  3729. }
  3730. if ($grade) {
  3731. $where .= " and features like '%-$grade-%'";
  3732. }
  3733. if ($color) {
  3734. $where .= " and features like '%-$color-%'";
  3735. }
  3736. if ($lowe) {
  3737. $where .= " and features like '%-$lowe-%'";
  3738. }
  3739. if ($warehouse) {
  3740. $where .= " and warehouse = '$warehouse'";
  3741. }
  3742. if ($purchase) {
  3743. $where .= " and purchase = '$purchase'";
  3744. }
  3745. if ($state) {
  3746. $where .= " and state = '$state'";
  3747. }
  3748. if ($lacetype) {
  3749. $where .= " and features like '%-$lacetype-%'";
  3750. }
  3751. if ($lacecolor) {
  3752. $where .= " and features like '%-$lacecolor-%'";
  3753. }
  3754. if ($density) {
  3755. $where .= " and features like '%-$density-%'";
  3756. }
  3757. if ($haircap) {
  3758. $where .= " and features like '%-$haircap-%'";
  3759. }
  3760. if ($details) {
  3761. $where .= " and details = '$details'";
  3762. }
  3763. if ($shop) {
  3764. $where .= " and shop like '%$shop%'";
  3765. }
  3766. if ($title) {
  3767. $title = trim($title, ' ');
  3768. $title = trim($title, ' ');
  3769. $where .= " and title like '%$title%'";
  3770. }
  3771. if (!empty($hairnumber)) {
  3772. $where .= " and features like '%-128-%' ";
  3773. if ($hairnumber < 0) {
  3774. $class_list = $this->typeclass->find_all('classid = 43');
  3775. foreach ($class_list as $v) {
  3776. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3777. }
  3778. } else {
  3779. $where .= " and features like '%-$hairnumber-%'";
  3780. }
  3781. }
  3782. if ($type_leixi) {
  3783. $where .= " and type = '$type_leixi'";
  3784. }
  3785. if ($cpbz) {
  3786. $where .= " and cpbz like '%$cpbz%' ";
  3787. }
  3788. if ($sm) {
  3789. $where .= " and sm like '%$sm%' ";
  3790. }
  3791. if ($sku) {
  3792. $sku = trim($sku, ' ');
  3793. $sku = trim($sku, ' ');
  3794. $where .= " and sku like '%$sku%'";
  3795. }
  3796. if ($ktime && $jtime) {
  3797. if ($type == 1) {
  3798. $tl = '出库';
  3799. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3800. } else if ($type == 2) {
  3801. $tl = '退库';
  3802. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3803. } else if ($type == 3) {
  3804. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3805. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3806. } else if ($type == 4) {
  3807. $tl = '出库+零售';
  3808. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3809. } else if ($type == 5) {
  3810. $tl = '零售';
  3811. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3812. }
  3813. }
  3814. $sidwhere = '';
  3815. if ($sid) {
  3816. $sd = "";
  3817. $s = explode(',', trim($sid, ','));
  3818. foreach ($s as $value) {
  3819. $sd .= " id = " . $value . " or";
  3820. }
  3821. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3822. }
  3823. //数据排序
  3824. $order_str = "time desc";
  3825. if (empty($page)) {
  3826. $start = 0;
  3827. $perpage = 1;
  3828. } else {
  3829. $start = ($page - 1) * $perpage;
  3830. }
  3831. //取得信息列表
  3832. if ($type != 3 && $type != 5) {
  3833. if ($type == 1 || $type == 4) {
  3834. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3835. foreach ($info_list as $key => $value) {
  3836. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3837. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3838. $warehouse = $this->warehouse->read($value['warehouse']);
  3839. $info_list[$key]['warehouse'] = $warehouse['title'];
  3840. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3841. $features = explode('-', trim($features, '-'));
  3842. $pm = $classid;
  3843. foreach ($features as $k => $v) {
  3844. if ($v != 0) {
  3845. if (!isset($typeclass[$v])) {
  3846. continue;
  3847. }
  3848. if (isset($pm[$typeclass[$v]['classid']])) {
  3849. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3850. $tz = explode('|', $typeclass[$v]['zh']);
  3851. $pm[$typeclass[$v]['classid']] = $tz[0];
  3852. } else {
  3853. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3854. }
  3855. }
  3856. }
  3857. }
  3858. $zh = implode(" ", $pm);
  3859. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3860. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3861. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3862. $info_list[$key]['features'] = $zh;
  3863. }
  3864. $final_list = [];
  3865. foreach($info_list as $k=>$v){
  3866. $number = "";
  3867. if(!empty($v['orderinfo'])){
  3868. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3869. if(!empty($tmp_info['number'])){
  3870. $number = $tmp_info['number'];
  3871. }
  3872. }
  3873. $final_list[] = [
  3874. 'warehouse'=>$v['warehouse'],
  3875. 'purchase'=>$v['purchase'],
  3876. 'sku'=>$v['sku'],
  3877. 'title'=>$v['title'],
  3878. 'features'=>$v['features'],
  3879. 'label'=>$v['label'],
  3880. 'orderinfo'=>$v['orderinfo'],
  3881. 'number'=>$number,
  3882. 'waybill'=>$v['waybill'],
  3883. 'outk'=>$v['outk'],
  3884. ];
  3885. }
  3886. } else {
  3887. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3888. foreach ($info_list as $key => $value) {
  3889. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3890. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3891. $warehouse = $this->warehouse->read($value['warehouse']);
  3892. $info_list[$key]['warehouse'] = $warehouse['title'];
  3893. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3894. $features = explode('-', trim($features, '-'));
  3895. $pm = $classid;
  3896. foreach ($features as $k => $v) {
  3897. if ($v != 0) {
  3898. if (!isset($typeclass[$v])) {
  3899. continue;
  3900. }
  3901. if (isset($pm[$typeclass[$v]['classid']])) {
  3902. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3903. $tz = explode('|', $typeclass[$v]['zh']);
  3904. $pm[$typeclass[$v]['classid']] = $tz[0];
  3905. } else {
  3906. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3907. }
  3908. }
  3909. }
  3910. }
  3911. $zh = implode(" ", $pm);
  3912. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3913. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3914. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3915. $info_list[$key]['features'] = $zh;
  3916. }
  3917. $final_list = [];
  3918. foreach($info_list as $k=>$v){
  3919. $number = "";
  3920. if(!empty($v['orderinfo'])){
  3921. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3922. if(!empty($tmp_info['number'])){
  3923. $number = $tmp_info['number'];
  3924. }
  3925. }
  3926. $final_list[] = [
  3927. 'warehouse'=>$v['warehouse'],
  3928. 'purchase'=>$v['purchase'],
  3929. 'sku'=>$v['sku'],
  3930. 'title'=>$v['title'],
  3931. 'features'=>$v['features'],
  3932. 'label'=>$v['label'],
  3933. 'orderinfo'=>$v['orderinfo'],
  3934. 'number'=>$number,
  3935. 'waybill'=>$v['waybill'],
  3936. 'retreat'=>$v['retreat'],
  3937. ];
  3938. }
  3939. }
  3940. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3941. $titlename = "<table border=1>
  3942. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3943. <tr align='center'>
  3944. <td>仓库</td>
  3945. <td>供应商</td>
  3946. <td>SKU</td>
  3947. <td>商品名称</td>
  3948. <td>商品中文</td>
  3949. <td>标签</td>
  3950. <td>订单号</td>
  3951. <td>订单编码</td>
  3952. <td>运单号</td>
  3953. <td>" . $tl . "时间(中国时间)</td>
  3954. </tr>
  3955. </table>";
  3956. $filename = $title . ".xls";
  3957. $tail = "";
  3958. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3959. } else if ($type == 5) {
  3960. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3961. foreach ($info_list as $key => $value) {
  3962. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3963. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3964. $warehouse = $this->warehouse->read($value['warehouse']);
  3965. $info_list[$key]['warehouse'] = $warehouse['title'];
  3966. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3967. $features = explode('-', trim($features, '-'));
  3968. $pm = $classid;
  3969. foreach ($features as $k => $v) {
  3970. if ($v != 0) {
  3971. if (!isset($typeclass[$v])) {
  3972. continue;
  3973. }
  3974. if (isset($pm[$typeclass[$v]['classid']])) {
  3975. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3976. $tz = explode('|', $typeclass[$v]['zh']);
  3977. $pm[$typeclass[$v]['classid']] = $tz[0];
  3978. } else {
  3979. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3980. }
  3981. }
  3982. }
  3983. }
  3984. $zh = implode(" ", $pm);
  3985. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3986. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3987. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3988. $info_list[$key]['features'] = $zh;
  3989. }
  3990. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3991. $titlename = "<table border=1>
  3992. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3993. <tr align='center'>
  3994. <td>仓库</td>
  3995. <td>供应商</td>
  3996. <td>SKU</td>
  3997. <td>商品名称</td>
  3998. <td>商品中文</td>
  3999. <td>标签</td>
  4000. <td>" . $tl . "时间(中国时间)</td>
  4001. </tr>
  4002. </table>";
  4003. $filename = $title . ".xls";
  4004. $tail = "";
  4005. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4006. } else {
  4007. /**
  4008. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4009. $rows = array();$list = array();
  4010. foreach ($info_list as $key=>$value)
  4011. {
  4012. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4013. }
  4014. **/
  4015. $wh = array();
  4016. $w = $this->warehouse->find_all('1=1', 'id,title');
  4017. foreach ($w as $v) {
  4018. $wh[$v['id']] = $v['title'];
  4019. }
  4020. $wt = array();
  4021. $whlabel_type = $this->whlabel_type->find_all();
  4022. foreach ($whlabel_type as $v) {
  4023. $wt[$v['id']] = $v['title'];
  4024. }
  4025. $classid = $this->classid->sku();
  4026. $list = array();
  4027. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4028. foreach ($rows as $key => $value) {
  4029. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4030. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4031. $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');
  4032. $details = array();
  4033. $cpid = array();
  4034. $cpbz = array();
  4035. $c = 0;
  4036. $g = 0;
  4037. $x = 0;
  4038. $t = 0;
  4039. $s = 0;
  4040. $q = 0;
  4041. foreach ($sd as $k => $v) {
  4042. if ($v['state'] == 0) {
  4043. $c++;
  4044. }
  4045. if ($v['state'] != 9) {
  4046. $g++;
  4047. }
  4048. if ($v['outk'] > 1) {
  4049. $x++;
  4050. }
  4051. if ($v['retreat'] > 0) {
  4052. $t++;
  4053. }
  4054. if ($v['state'] == 8) {
  4055. $s++;
  4056. }
  4057. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4058. $q++;
  4059. }
  4060. $details[$v['details']] = $v['details'];
  4061. if ($v['cpid'] != 0) {
  4062. $cpid[$v['cpid']] = $v['cpid'];
  4063. }
  4064. if ($v['cpbz'] != '') {
  4065. $cpbz[$v['cpbz']] = $v['cpbz'];
  4066. }
  4067. }
  4068. if (isset($wt[$value['type']])) {
  4069. $rows[$key]['type'] = $wt[$value['type']];
  4070. } else {
  4071. $rows[$key]['type'] = '未设置';
  4072. }
  4073. $rows[$key]['details'] = implode("、", $details);
  4074. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4075. $ftime = time() - 15 * 24 * 3600;
  4076. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4077. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4078. $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);
  4079. $rows[$key]['c'] = $c;
  4080. $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);
  4081. $rows[$key]['t'] = $t;
  4082. $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'] . '"');
  4083. $rows[$key]['z'] = $z;
  4084. // $jm = $classid;
  4085. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4086. $features = explode('-', trim($features, '-'));
  4087. // $pm = $classid;
  4088. // foreach ($features as $k => $v) {
  4089. // if ($v != 0) {
  4090. // if (!isset($typeclass[$v])) {
  4091. // continue;
  4092. // }
  4093. // if (isset($pm[$typeclass[$v]['classid']])) {
  4094. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4095. // $tz = explode('|', $typeclass[$v]['zh']);
  4096. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4097. // } else {
  4098. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4099. // }
  4100. // if (isset($jm[$typeclass[$v]['classid']])) {
  4101. // if ($typeclass[$v]['jm']) {
  4102. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4103. // }
  4104. // }
  4105. // }
  4106. // }
  4107. // }
  4108. // $zh = implode(" ", $pm);
  4109. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4110. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4111. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4112. // $rows[$key]['features'] = $zh;
  4113. // $jm = array_filter($jm); //去除空值
  4114. // $jm = implode("-", $jm);
  4115. // $rows[$key]['jm'] = $jm;
  4116. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4117. }
  4118. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4119. // echo "<pre>";
  4120. // print_r($tmp_list);
  4121. // die;
  4122. $final_list =[];
  4123. foreach($tmp_list as $k=>$v){
  4124. $final_list[] = [
  4125. "warehouse"=>$v['warehouse'],
  4126. "purchase"=>$v['purchase'],
  4127. "details"=>$v['details'],
  4128. "cpid"=>$v['cpid'],
  4129. "sku"=>$v['sku'],
  4130. "title"=>$v['title'],
  4131. "features"=>$v['pm'],
  4132. "cpbz"=>$v['cpbz'],
  4133. "sm"=>$v['sm'],
  4134. "type"=>$v['type'],
  4135. "g"=>$v["g"],
  4136. "c"=>$v["c"],
  4137. "x"=>$v["x"],
  4138. "t"=>$v["t"],
  4139. "z"=>$v["z"],
  4140. "jm"=>$v["jm"],
  4141. "weight"=>$v["weight"],
  4142. "asd"=>$v["asd"],
  4143. ];
  4144. }
  4145. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4146. $titlename = "<table border=1>
  4147. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4148. <tr align='center'>
  4149. <td>仓库</td>
  4150. <td>供应商</td>
  4151. <td>位置</td>
  4152. <td>库存编码</td>
  4153. <td>SKU</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. <td>料号</td>
  4165. <td>重量</td>
  4166. <td>类目</td>
  4167. </tr>
  4168. </table>";
  4169. $filename = $title . ".xls";
  4170. $tail = "";
  4171. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4172. }
  4173. }
  4174. }
  4175. //出库+入库数据整合
  4176. public function _excelcr()
  4177. {
  4178. if (isset($_GET['excel'])) {
  4179. $type = $this->input->get('excel', true);
  4180. $category = $this->input->get('category', true);
  4181. $size = $this->input->get('size', true);
  4182. $grade = $this->input->get('grade', true);
  4183. $color = $this->input->get('color', true);
  4184. $lowe = $this->input->get('lowe', true);
  4185. $sku = $this->input->get('sku', true);
  4186. $warehouse = $this->input->get('warehouse', true);
  4187. $purchase = $this->input->get('purchase', true);
  4188. $state = $this->input->get('state', true);
  4189. $sid = $this->input->get('sid', true);
  4190. $ktime = $this->input->get('ktime', true);
  4191. $jtime = $this->input->get('jtime', true);
  4192. $ktime = strtotime($ktime);
  4193. $jtime = strtotime($jtime);
  4194. $where = "1=1";
  4195. $gj = "";
  4196. $ck = "";
  4197. if ($category) {
  4198. $where .= " and features like '%-$category-%'";
  4199. }
  4200. if ($size) {
  4201. $where .= " and features like '%-$size-%'";
  4202. }
  4203. if ($grade) {
  4204. $where .= " and features like '%-$grade-%'";
  4205. }
  4206. if ($color) {
  4207. $where .= " and features like '%-$color-%'";
  4208. }
  4209. if ($lowe) {
  4210. $where .= " and features like '%-$lowe-%'";
  4211. }
  4212. if ($warehouse) {
  4213. $where .= " and warehouse = '$warehouse'";
  4214. }
  4215. if ($purchase) {
  4216. $where .= " and purchase = '$purchase'";
  4217. }
  4218. if ($state) {
  4219. $where .= " and state = '$state'";
  4220. }
  4221. if ($sku) {
  4222. $where .= " and sku like '%$sku%'";
  4223. }
  4224. if ($ktime && $jtime) {
  4225. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4226. }
  4227. $sidwhere = '';
  4228. if ($sid) {
  4229. $sd = "";
  4230. $s = explode(',', trim($sid, ','));
  4231. foreach ($s as $value) {
  4232. $sd .= " id = " . $value . " or";
  4233. }
  4234. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4235. }
  4236. //取得信息列表
  4237. $timeread = $ktime;
  4238. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4239. $timelist = array();
  4240. for ($i = 0; $i < $timenum; $i++) {
  4241. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4242. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4243. }
  4244. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4245. //echo "<pre>";
  4246. //print_r($info_list);
  4247. //exit();
  4248. $rows = array();
  4249. $list = array();
  4250. foreach ($info_list as $key => $value) {
  4251. $thistime = $timelist;
  4252. if (isset($rows[strtolower($value['sku'])])) {
  4253. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4254. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4255. }
  4256. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4257. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4258. }
  4259. } else {
  4260. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4261. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4262. }
  4263. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4264. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4265. }
  4266. $rows[strtolower($value['sku'])] = $thistime;
  4267. }
  4268. }
  4269. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4270. <head>
  4271. <!--[if gte mso 9]><xml>
  4272. <x:ExcelWorkbook>
  4273. <x:ExcelWorksheets>
  4274. <x:ExcelWorksheet>
  4275. <x:Name>EXCEL</x:Name>
  4276. <x:WorksheetOptions>
  4277. <x:Print>
  4278. <x:ValidPrinterInfo />
  4279. </x:Print>
  4280. </x:WorksheetOptions>
  4281. </x:ExcelWorksheet>
  4282. </x:ExcelWorksheets>
  4283. </x:ExcelWorkbook>
  4284. </xml>
  4285. <![endif]-->
  4286. </head><body>";
  4287. $str .= "<table border=1><tr><td>SKU</td>";
  4288. foreach ($timelist as $k => $v) {
  4289. $str .= "<td>" . $k . "出库</td>";
  4290. $str .= "<td>" . $k . "入库</td>";
  4291. }
  4292. $str .= "</tr></table>";
  4293. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4294. foreach ($rows as $key => $val) {
  4295. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4296. foreach ($val as $k => $v) {
  4297. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4298. if ($val[$k]['r'] > 0) {
  4299. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4300. } else {
  4301. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4302. }
  4303. }
  4304. $str .= "</tr>";
  4305. }
  4306. $str .= "</table>";
  4307. $str .= "</body></html>";
  4308. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4309. header("Content-type: application/octet-stream");
  4310. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4311. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4312. header("Pragma: no-cache");
  4313. header("Expires: 0");
  4314. exit($str);
  4315. }
  4316. }
  4317. //数量调整模板导出
  4318. public function _presetout()
  4319. {
  4320. if (isset($_GET['excel'])) {
  4321. $where = "sku != 'Preset' and purchase != 0";
  4322. //数据排序
  4323. $order_str = "id desc";
  4324. if (empty($page)) {
  4325. $start = 0;
  4326. $perpage = 1;
  4327. } else {
  4328. $start = ($page - 1) * $perpage;
  4329. }
  4330. //取得信息列表
  4331. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4332. $rows = array();
  4333. $list = array();
  4334. foreach ($info_list as $value) {
  4335. $warehouse = $this->warehouse->read($value['warehouse']);
  4336. $number = $value['number'];
  4337. $ftime = time() - 15 * 24 * 3600;
  4338. $purchase = $this->purchase->read($value['purchase']);
  4339. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4340. }
  4341. $title = "库存模板";
  4342. $titlename = "<table border=1>
  4343. <tr align='center'>
  4344. <td>仓库</td>
  4345. <td>供应商编码</td>
  4346. <td>SKU</td>
  4347. <td>增减数量(正数或负数)</td>
  4348. <td>增减备注</td>
  4349. <td>扣减方式:0减少库存1删除库存</td>
  4350. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4351. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4352. </tr>
  4353. </table>";
  4354. $filename = $title . ".xls";
  4355. $tail = "";
  4356. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4357. }
  4358. }
  4359. //数量调整模板导入
  4360. public function _presetedit()
  4361. {
  4362. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4363. $config['upload_path'] = '.' . $dir;
  4364. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4365. $config['allowed_types'] = 'xls|xlsx|csv';
  4366. $config['max_size'] = 10240;
  4367. $this->load->library('upload', $config);
  4368. $this->upload->initialize($config);
  4369. if ($this->upload->do_upload('userfile')) {
  4370. $full_path = $dir . $this->upload->data('file_name');
  4371. $fileName = '.' . $full_path;
  4372. if (!file_exists($fileName)) {
  4373. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4374. exit;
  4375. } else {
  4376. require_once "./data/excel/PHPExcel/IOFactory.php";
  4377. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4378. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4379. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4380. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4381. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4382. ++$column; //如果列数大于26行
  4383. $list = array();
  4384. for ($i = 2; $i <= $row; $i++) // 行数循环
  4385. {
  4386. $data = array();
  4387. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4388. {
  4389. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4390. }
  4391. $list[] = $data;
  4392. }
  4393. }
  4394. $i = 0;
  4395. $j = 0;
  4396. $ed = array();
  4397. foreach ($list as $key => $value) {
  4398. $time = time();
  4399. if ($value['0'] == "") {
  4400. continue;
  4401. }
  4402. $warehouse = $this->warehouse->get_title($value['0']);
  4403. $purchase = $this->purchase->get_bm($value['1']);
  4404. $sku = $value['2'];
  4405. $num = $value['3']; //调整数量
  4406. $text = $value['4']; //扣减说明
  4407. $type = $value['5']; //调整方式0扣减1删除
  4408. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4409. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4410. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4411. if (!$purchase) //如果没有这个SKU
  4412. {
  4413. $ed[] = array($purchase . '-不存在此供应商编码');
  4414. $j++;
  4415. continue;
  4416. }
  4417. if (!$d) //如果没有这个SKU
  4418. {
  4419. $ed[] = array($sku . '-库存中不存在此SKU');
  4420. $j++;
  4421. continue;
  4422. }
  4423. if (!isset($warehouse['id'])) {
  4424. $ed[] = array($sku . '-仓库名错误!');
  4425. $j++;
  4426. continue;
  4427. }
  4428. if ($type != '0' && $type != '1') {
  4429. $ed[] = array($sku . '-扣减方式填写错误!');
  4430. $j++;
  4431. continue;
  4432. }
  4433. if ($num < 0) //扣减库存
  4434. {
  4435. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4436. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4437. $j++;
  4438. continue;
  4439. }
  4440. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4441. if (count($data) < abs($num)) {
  4442. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4443. $j++;
  4444. continue;
  4445. }
  4446. if ($type == 0) //如果扣减方式为 扣减库存
  4447. {
  4448. for ($i = 0; $i < abs($num); $i++) {
  4449. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4450. }
  4451. } else if ($type == 1) {
  4452. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4453. if (count($zt) > 0) {
  4454. $ed[] = array($sku . '-有在途库存无法删除!');
  4455. $j++;
  4456. continue;
  4457. }
  4458. for ($i = 0; $i < abs($num); $i++) {
  4459. $this->whlabel->remove($data[$i]['id']);
  4460. }
  4461. }
  4462. } else if ($num > 0) //增加库存
  4463. {
  4464. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4465. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4466. $j++;
  4467. continue;
  4468. }
  4469. $post['sku'] = $d['sku'];
  4470. $post['shop'] = $d['shop'];
  4471. $post['warehouse'] = $warehouse['id'];
  4472. $post['purchase'] = $purchase['id'];
  4473. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4474. $post['state'] = 0;
  4475. $post['title'] = $d['title'];
  4476. $post['number'] = $d['number'];
  4477. $post['features'] = $d['features'];
  4478. $post['enter'] = $time;
  4479. $post['time'] = $time; //操作时间
  4480. $post['rktype'] = $rktype;
  4481. for ($i = 0; $i < $num; $i++) {
  4482. $post['label'] = time() . rand(100, 999) . $i;
  4483. $this->whlabel->insert($post);
  4484. }
  4485. }
  4486. sleep(1); //防止入库时间一样,需要延迟1秒
  4487. }
  4488. if ($j > 0) {
  4489. $tt = date('Ymd', time());
  4490. $title = '库存导入错误信息-' . $tt;
  4491. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4492. $tail = "\n";
  4493. $filename = $title . ".xls";
  4494. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4495. $dir = '/data/excel/' . $time . '/';
  4496. $file_name = 'error_' . $time . rand(1000, 9999);
  4497. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4498. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4499. fwrite($myfile, $ecl);
  4500. fclose($myfile);
  4501. $error = $dir . $file_name . '.xls';
  4502. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4503. exit;
  4504. } else {
  4505. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4506. exit;
  4507. }
  4508. }
  4509. }
  4510. public function _presetedittwo(){
  4511. $data = $this->input->post(NULL, TRUE);
  4512. if(empty($list)){
  4513. $raw_data = $this->input->raw_input_stream;
  4514. // 解码 JSON
  4515. $data = json_decode($raw_data, true);
  4516. }
  4517. if(empty($data)){
  4518. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4519. }
  4520. $list = [];
  4521. if(isset($data['list'])){
  4522. $list = $data['list'];
  4523. }
  4524. $i = 0;
  4525. $j = 0;
  4526. $ed = array();
  4527. foreach ($list as $key => $value) {
  4528. $time = time();
  4529. if ($value['0'] == "") {
  4530. continue;
  4531. }
  4532. $warehouse = $this->warehouse->get_title($value['0']);
  4533. $purchase = $this->purchase->get_bm($value['1']);
  4534. $sku = $value['2'];
  4535. $num = $value['3']; //调整数量
  4536. $text = $value['4']; //扣减说明
  4537. $type = $value['5']; //调整方式0扣减1删除
  4538. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4539. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4540. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4541. if (!$purchase) //如果没有这个SKU
  4542. {
  4543. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4544. $j++;
  4545. continue;
  4546. }
  4547. if (!$d) //如果没有这个SKU
  4548. {
  4549. $ed[] = array($sku . '-库存中不存在此SKU');
  4550. $j++;
  4551. continue;
  4552. }
  4553. if (!isset($warehouse['id'])) {
  4554. $ed[] = array($sku . '-仓库名错误!');
  4555. $j++;
  4556. continue;
  4557. }
  4558. if ($type != '0' && $type != '1') {
  4559. $ed[] = array($sku . '-扣减方式填写错误!');
  4560. $j++;
  4561. continue;
  4562. }
  4563. if ($num < 0) //扣减库存
  4564. {
  4565. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4566. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4567. $j++;
  4568. continue;
  4569. }
  4570. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4571. if (count($data) < abs($num)) {
  4572. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4573. $j++;
  4574. continue;
  4575. }
  4576. if ($type == 0) //如果扣减方式为 扣减库存
  4577. {
  4578. for ($i = 0; $i < abs($num); $i++) {
  4579. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4580. }
  4581. } else if ($type == 1) {
  4582. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4583. if (count($zt) > 0) {
  4584. $ed[] = array($sku . '-有在途库存无法删除!');
  4585. $j++;
  4586. continue;
  4587. }
  4588. for ($i = 0; $i < abs($num); $i++) {
  4589. $this->whlabel->remove($data[$i]['id']);
  4590. }
  4591. }
  4592. } else if ($num > 0) //增加库存
  4593. {
  4594. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4595. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4596. $j++;
  4597. continue;
  4598. }
  4599. $post['sku'] = $d['sku'];
  4600. $post['shop'] = $d['shop'];
  4601. $post['warehouse'] = $warehouse['id'];
  4602. $post['purchase'] = $purchase['id'];
  4603. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4604. $post['state'] = 0;
  4605. $post['title'] = $d['title'];
  4606. $post['number'] = $d['number'];
  4607. $post['features'] = $d['features'];
  4608. $post['enter'] = $time;
  4609. $post['time'] = $time; //操作时间
  4610. $post['rktype'] = $rktype;
  4611. $post['sku_master_id'] = $d['sku_master_id'];
  4612. $post['sku_shop_id'] = $d['sku_shop_id'];
  4613. for ($i = 0; $i < $num; $i++) {
  4614. $post['label'] = time() . rand(100, 999) . $i;
  4615. $this->whlabel->insert($post);
  4616. }
  4617. }
  4618. sleep(1); //防止入库时间一样,需要延迟1秒
  4619. }
  4620. if ($j > 0) {
  4621. $tt = date('Ymd', time());
  4622. $title = '库存导入错误信息-' . $tt;
  4623. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4624. $tail = "\n";
  4625. $filename = $title . ".xls";
  4626. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4627. $dir = '/data/excel/' . $time . '/';
  4628. $file_name = 'error_' . $time . rand(1000, 9999);
  4629. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4630. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4631. fwrite($myfile, $ecl);
  4632. fclose($myfile);
  4633. $error = $dir . $file_name . '.xls';
  4634. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4635. exit;
  4636. } else {
  4637. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4638. exit;
  4639. }
  4640. }
  4641. //笛卡儿积
  4642. function cp($ps, $sets, $list)
  4643. {
  4644. $result = array();
  4645. $j = 0;
  4646. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4647. if ($i == 0) {
  4648. $result = $sets[$i];
  4649. }
  4650. $tmp = array();
  4651. foreach ($result as $res) {
  4652. foreach ($sets[$i + 1] as $set) {
  4653. $tmp[] = $res . ',' . $set;
  4654. }
  4655. }
  4656. $result = $tmp;
  4657. }
  4658. $this->db->trans_begin();
  4659. foreach ($result as $v) {
  4660. $post = array();
  4661. $title = "";
  4662. $num = "";
  4663. $data = explode(',', $v);
  4664. for ($i = 0; $i < count($list); $i++) {
  4665. $post[$list[$i]] = $data[$i];
  4666. $typeclass = $this->typeclass->read($data[$i]);
  4667. $title = $title . $typeclass['title'] . " ";
  4668. if ($data[$i] != 0) {
  4669. $num .= $data[$i]; //所有数据ID拼接
  4670. }
  4671. }
  4672. foreach ($ps as $kp => $vp) {
  4673. $post[$kp] = $vp;
  4674. }
  4675. $post['number'] = $num;
  4676. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4677. if ($info_list) {
  4678. $j++;
  4679. } else {
  4680. $skunum = $this->whlabel->find_count();
  4681. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4682. $post['title'] = rtrim($title, ' ');
  4683. $this->whlabel->insert($post);
  4684. }
  4685. }
  4686. if ($this->db->trans_status() === FALSE) {
  4687. $this->db->trans_commit();
  4688. return NULL;
  4689. } else {
  4690. $this->db->trans_commit();
  4691. return $j;
  4692. }
  4693. }
  4694. public function _kj($arg_array)
  4695. {
  4696. if (isset($_POST['sku'])) {
  4697. $time = time();
  4698. $sku = $this->input->post('sku', true);
  4699. $warehouse = $this->input->post('warehouse', true);
  4700. $num = $this->input->post('num', true);
  4701. $text = $this->input->post('text', true);
  4702. $purchase = $this->input->post('purchase', true);
  4703. $cktype = $this->input->post('cktype', true);
  4704. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4705. if ($cktype != 1 && $text == '') {
  4706. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4707. exit;
  4708. }
  4709. if ($num > count($order)) {
  4710. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4711. exit;
  4712. } else {
  4713. for ($i = 0; $i < $num; $i++) {
  4714. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4715. }
  4716. }
  4717. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4718. exit;
  4719. }
  4720. $uid = $this->whlabel->read($arg_array[0]);
  4721. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4722. $this->data['data'] = $uid;
  4723. $this->_Template('whlabel_kj', $this->data);
  4724. }
  4725. public function _summary($arg_array)
  4726. {
  4727. $prc = array();
  4728. $purchase = $this->purchase->find_all();
  4729. foreach ($purchase as $k => $v) {
  4730. $prc[$v['id']] = $v['title'];
  4731. }
  4732. if (isset($_GET['excel'])) {
  4733. $ktime = $this->input->get('ktime', true);
  4734. $jtime = $this->input->get('jtime', true);
  4735. $ktime = strtotime($ktime);
  4736. $jtime = strtotime($jtime);
  4737. $where = "1=1";
  4738. if ($ktime && $jtime) {
  4739. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4740. }
  4741. //数据排序
  4742. $order_str = "time desc";
  4743. if (empty($page)) {
  4744. $start = 0;
  4745. $perpage = 1;
  4746. } else {
  4747. $start = ($page - 1) * $perpage;
  4748. }
  4749. //取得信息列表
  4750. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4751. foreach ($info_list as $key => $value) {
  4752. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4753. $warehouse = $this->warehouse->read($value['warehouse']);
  4754. $info_list[$key]['warehouse'] = $warehouse['title'];
  4755. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4756. $details = array();
  4757. $cpid = array();
  4758. foreach ($x as $k => $v) {
  4759. if ($v['details'] != '') {
  4760. $details[$v['details']] = $v['details'];
  4761. }
  4762. if ($v['cpid'] != 0) {
  4763. $cpid[$v['cpid']] = $v['cpid'];
  4764. }
  4765. }
  4766. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4767. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4768. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4769. $info_list[$key]['s'] = $s;
  4770. $info_list[$key]['x'] = count($x);
  4771. }
  4772. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4773. $titlename = "<table border=1>
  4774. <tr align='center'>
  4775. <td>仓库</td>
  4776. <td>供应商</td>
  4777. <td>出库位置</td>
  4778. <td>出库编码</td>
  4779. <td>SKU</td>
  4780. <td>产品名</td>
  4781. <td>总剩余库存</td>
  4782. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4783. </tr>
  4784. </table>";
  4785. $filename = $title . ".xls";
  4786. $tail = "";
  4787. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4788. }
  4789. }
  4790. //usps发货清单
  4791. public function _manifest()
  4792. {
  4793. if (isset($_POST['manifest'])) {
  4794. $wltext = $this->input->post('wltext', true);
  4795. $time = time() - 16 * 3600;
  4796. $ptime = strtotime(date('Y-m-d', $time));
  4797. $waybill = array();
  4798. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4799. foreach ($fullorder as $v) {
  4800. $waybill[$v['waybill']] = $v['waybill'];
  4801. }
  4802. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4803. foreach ($fullordersmt as $v) {
  4804. $waybill[$v['waybill']] = $v['waybill'];
  4805. }
  4806. $wltext = explode(';', $wltext);
  4807. foreach ($wltext as $v) {
  4808. if (isset($waybill[$v])) {
  4809. unset($waybill[$v]);
  4810. }
  4811. }
  4812. $data = $this->usps->get_manifest($waybill);
  4813. if (isset($data['Description'])) {
  4814. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4815. exit;
  4816. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4817. $bctime = date('Ymd', time());
  4818. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4819. echo json_encode(array('msg' => $pdf, 'success' => true));
  4820. exit;
  4821. } else {
  4822. echo json_encode(array('msg' => $data, 'success' => false));
  4823. exit;
  4824. }
  4825. }
  4826. }
  4827. public function _pdf($pdf, $title, $bctime)
  4828. {
  4829. $pdf_path = './data/pdf/' . $bctime . '/';
  4830. $file_base64 = $pdf;
  4831. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4832. $file_base64 = base64_decode($file_base64);
  4833. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4834. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4835. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4836. }
  4837. /**
  4838. *
  4839. *
  4840. *
  4841. 进销存占单异常索引
  4842. *
  4843. *
  4844. *
  4845. **/
  4846. public function _abnormal()
  4847. {
  4848. $post = $this->input->post(NULL, TRUE);
  4849. if (isset($post['page'])) {
  4850. $page = $this->input->post('page', true);
  4851. $perpage = $this->input->post('perpage', true);
  4852. $sku = $this->input->post('sku', true);
  4853. $where = "1=1";
  4854. //数据排序
  4855. $order_str = "id desc";
  4856. if (empty($page)) {
  4857. $start = 0;
  4858. $perpage = 1;
  4859. } else {
  4860. $start = ($page - 1) * $perpage;
  4861. }
  4862. //取得信息列表
  4863. $info_list = $this->whlabel->find_all($where, '*');
  4864. $rows = array();
  4865. $list = array();
  4866. foreach ($info_list as $key => $value) {
  4867. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4868. }
  4869. foreach ($rows as $value) {
  4870. $warehouse = $this->warehouse->read($value['warehouse']);
  4871. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4872. $number = $value['number'];
  4873. $ftime = time() - 15 * 24 * 3600;
  4874. if ($value['shop'] != '') {
  4875. $shop = $value['shop'];
  4876. $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');
  4877. $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');
  4878. $order = array_merge($orderdlz, $ordersmt);
  4879. $od = 0;
  4880. $a = '';
  4881. $orid = '';
  4882. foreach ($order as $v) {
  4883. $or = explode('|', ltrim($v['whlabel'], '|'));
  4884. for ($i = 0; $i < count($or); $i++) {
  4885. $orod = explode('-', $or[$i]);
  4886. if ($orod[0] == $number) {
  4887. $od += $orod[1];
  4888. }
  4889. }
  4890. $orid .= $v['number'] . '-';
  4891. }
  4892. } else {
  4893. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4894. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4895. $order = array_merge($orderdlz, $ordersmt);
  4896. $od = 0;
  4897. $a = '';
  4898. $orid = '';
  4899. $qt = array();
  4900. foreach ($order as $v) {
  4901. $or = explode('|', ltrim($v['whlabel'], '|'));
  4902. for ($i = 0; $i < count($or); $i++) {
  4903. $orod = explode('-', $or[$i]);
  4904. if ($orod[0] == $number) {
  4905. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4906. if ($czzs > 0) {
  4907. if (isset($qt[$v['shop']])) {
  4908. if ($qt[$v['shop']] < $orod[1]) {
  4909. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4910. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4911. } else {
  4912. $qt[$v['shop']] -= $orod[1];
  4913. }
  4914. } else {
  4915. $qt[$v['shop']] = $czzs;
  4916. }
  4917. } else {
  4918. $od += $orod[1];
  4919. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4920. }
  4921. }
  4922. }
  4923. }
  4924. }
  4925. $z = $od . '(' . $orid . ')'; //查看订单号
  4926. //$z = $od;
  4927. if ($od > $c) {
  4928. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4929. }
  4930. }
  4931. $listdata = array_slice($list, $start, $perpage);
  4932. $total = count($list);
  4933. $pagenum = ceil($total / $perpage);
  4934. $over = $total - ($start + $perpage);
  4935. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4936. echo json_encode($rows);
  4937. exit;
  4938. }
  4939. $this->_Template('whlabel_abnormal', $this->data);
  4940. }
  4941. /**
  4942. *
  4943. *
  4944. *
  4945. 进销存占单异常索引
  4946. *
  4947. *
  4948. *
  4949. **/
  4950. public function _error()
  4951. {
  4952. $post = $this->input->post(NULL, TRUE);
  4953. if (isset($post['page'])) {
  4954. $page = $this->input->post('page', true);
  4955. $perpage = $this->input->post('perpage', true);
  4956. $sku = $this->input->post('sku', true);
  4957. $warehouse = $this->input->post('warehouse', true);
  4958. $ktime = $this->input->post('ktime', true);
  4959. $jtime = $this->input->post('jtime', true);
  4960. $ktime = strtotime($ktime);
  4961. $jtime = strtotime($jtime);
  4962. $where = "sku != 'Preset'";
  4963. $gj = '';
  4964. if ($sku) {
  4965. $where .= " and sku like '%$sku%'";
  4966. } else {
  4967. if ($ktime && $jtime) {
  4968. $gj = " and time > '$ktime' and time < '$jtime'";
  4969. }
  4970. }
  4971. if ($warehouse) {
  4972. $where .= " and warehouse = '$warehouse'";
  4973. }
  4974. //数据排序
  4975. $order_str = "id desc";
  4976. if (empty($page)) {
  4977. $start = 0;
  4978. $perpage = 1;
  4979. } else {
  4980. $start = ($page - 1) * $perpage;
  4981. }
  4982. //取得信息列表
  4983. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4984. $rows = array();
  4985. $list = array();
  4986. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4987. // foreach ($info_list as $value)
  4988. // {
  4989. // $warehouse = $this->warehouse->read($value['warehouse']);
  4990. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4991. // $number = $value['number'];$ftime = time()-15*24*3600;
  4992. // if($c < 1)
  4993. // {
  4994. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4995. // }
  4996. // }
  4997. $warehouse_list = $this->warehouse->find_all();
  4998. $warehouse_list = array_column($warehouse_list, null, 'id');
  4999. foreach ($info_list as $value) {
  5000. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5001. 'title' => "",
  5002. ];
  5003. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5004. $number = $value['number'];
  5005. $ftime = time() - 15 * 24 * 3600;
  5006. if ($c < 1) {
  5007. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5008. }
  5009. }
  5010. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5011. // $query = $this->db->query($sql);
  5012. // $info_list = $query->result_array();
  5013. // $sql_two = "select title,id from crowd_warehouse";
  5014. // $query_two = $this->db->query($sql_two);
  5015. // $warehouse_list = $query_two->result_array();
  5016. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5017. // foreach ($info_list as $value)
  5018. // {
  5019. // if(isset($warehouse_arr[$value['warehouse']])){
  5020. // $warehouse = $warehouse_arr[$value['warehouse']];
  5021. // }else{
  5022. // $warehouse = [
  5023. // 'id'=>0,
  5024. // 'title'=>"异常",
  5025. // ];
  5026. // }
  5027. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5028. // $number = $value['number'];$ftime = time()-15*24*3600;
  5029. // if($c < 1)
  5030. // {
  5031. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5032. // }
  5033. // }
  5034. $listdata = array_slice($list, $start, $perpage);
  5035. $total = count($list);
  5036. $pagenum = ceil($total / $perpage);
  5037. $over = $total - ($start + $perpage);
  5038. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5039. echo json_encode($rows);
  5040. exit;
  5041. }
  5042. if (isset($post['s'])) {
  5043. $id_arr = $this->input->post('s');
  5044. $id_arr = explode(',', trim($id_arr, ','));
  5045. if (!$id_arr) {
  5046. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5047. exit;
  5048. }
  5049. //循环删除记录
  5050. foreach ($id_arr as $v) {
  5051. $dd = $this->whlabel->read($v);
  5052. if (!isset($dd['id'])) {
  5053. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5054. exit;
  5055. }
  5056. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5057. if (isset($zt[0])) {
  5058. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5059. exit;
  5060. }
  5061. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5062. foreach ($deldd as $vv) {
  5063. $this->whlabel->remove($vv['id']);
  5064. }
  5065. }
  5066. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5067. exit;
  5068. }
  5069. $this->_Template('whlabel_error', $this->data);
  5070. }
  5071. public function _errorexcel()
  5072. {
  5073. $post = $this->input->post(NULL, TRUE);
  5074. if (isset($_GET['page'])) {
  5075. $page = $this->input->get('page', true);
  5076. $perpage = $this->input->get('perpage', true);
  5077. $sku = $this->input->get('sku', true);
  5078. $warehouse = $this->input->get('warehouse', true);
  5079. $ktime = $this->input->get('ktime', true);
  5080. $jtime = $this->input->get('jtime', true);
  5081. $ktime = strtotime($ktime);
  5082. $jtime = strtotime($jtime);
  5083. $where = "sku != 'Preset'";
  5084. $gj = '';
  5085. if ($sku) {
  5086. $where .= " and sku like '%$sku%'";
  5087. } else {
  5088. if ($ktime && $jtime) {
  5089. $gj = " and time > '$ktime' and time < '$jtime'";
  5090. }
  5091. }
  5092. if ($warehouse) {
  5093. $where .= " and warehouse = '$warehouse'";
  5094. }
  5095. //数据排序
  5096. $order_str = "id desc";
  5097. if (empty($page)) {
  5098. $start = 0;
  5099. $perpage = 1;
  5100. } else {
  5101. $start = ($page - 1) * $perpage;
  5102. }
  5103. //取得信息列表
  5104. $rows = array();
  5105. $list = array();
  5106. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5107. foreach ($info_list as $value) {
  5108. $warehouse = $this->warehouse->read($value['warehouse']);
  5109. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5110. $number = $value['number'];
  5111. $ftime = time() - 15 * 24 * 3600;
  5112. if ($c < 1) {
  5113. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5114. }
  5115. }
  5116. $title = "0库存汇总";
  5117. $titlename = "<table border=1>
  5118. <tr align='center'>
  5119. <td>仓库</td>
  5120. <td>SKU</td>
  5121. <td>产品</td>
  5122. <td>当前库存</td>
  5123. </tr>
  5124. </table>";
  5125. $filename = $title . ".xls";
  5126. $tail = "";
  5127. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5128. }
  5129. }
  5130. /**
  5131. *
  5132. *
  5133. * 占单
  5134. *
  5135. *
  5136. **/
  5137. public function _kcyz()
  5138. {
  5139. $post = $this->input->post(NULL, TRUE);
  5140. if (isset($post['warehouse'])) {
  5141. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5142. exit; //不再使用
  5143. $warehouse = $this->input->post('warehouse', true);
  5144. $whlabel = $this->input->post('whlabel', true);
  5145. $id = $this->input->post('id', true);
  5146. $shop = $this->input->post('shop', true);
  5147. $number = $this->input->post('number', true);
  5148. if (!$whlabel || $whlabel == '|') {
  5149. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5150. exit;
  5151. }
  5152. $pp = explode('|', trim($whlabel, '|'));
  5153. $x = 0;
  5154. $save = array();
  5155. foreach ($pp as $va) {
  5156. $num = explode('-', $va);
  5157. if ($number) {
  5158. $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 = '')"); //通用
  5159. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5160. } else {
  5161. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5162. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5163. }
  5164. $x++;
  5165. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5166. $save[] = $x - 1;
  5167. continue; //提前先加X不然出错,所以要减1
  5168. }
  5169. }
  5170. if (isset($save[0])) {
  5171. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5172. exit;
  5173. } else {
  5174. echo json_encode(array('success' => true));
  5175. exit;
  5176. }
  5177. }
  5178. }
  5179. public function _db()
  5180. {
  5181. $post = $this->input->post(NULL, TRUE);
  5182. if (isset($post['page'])) {
  5183. $page = $this->input->post('page', true);
  5184. $perpage = $this->input->post('perpage', true);
  5185. $sku = $this->input->post('sku', true);
  5186. $number = $this->input->post('number', true);
  5187. $warehouse = $this->input->post('warehouse', true);
  5188. $purchase = $this->input->post('purchase', true);
  5189. $orderinfo = $this->input->post('orderinfo', true);
  5190. $waybill = $this->input->post('waybill', true);
  5191. $category = $this->input->post('category', true);
  5192. $size = $this->input->post('size', true);
  5193. $grade = $this->input->post('grade', true);
  5194. $color = $this->input->post('color', true);
  5195. $lowe = $this->input->post('lowe', true);
  5196. $state = $this->input->post('state', true);
  5197. $label = $this->input->post('label', true);
  5198. $timetk = $this->input->post('timetkk', true);
  5199. $timetj = $this->input->post('timetjj', true);
  5200. $timetk = strtotime($timetk);
  5201. $timetj = strtotime($timetj);
  5202. $where = "dbtime > 0";
  5203. if ($timetk && $timetj) {
  5204. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5205. }
  5206. if ($sku) {
  5207. $where .= " and sku = '$sku'";
  5208. }
  5209. if ($warehouse) {
  5210. $where .= " and warehouse = '$warehouse'";
  5211. if ($warehouse == 12) {
  5212. $w = 'specialstock';
  5213. } else {
  5214. $w = 'whlabel';
  5215. }
  5216. }
  5217. if ($purchase) {
  5218. $where .= " and purchase = '$purchase'";
  5219. }
  5220. if ($category) {
  5221. $where .= " and features like '%-$category-%'";
  5222. }
  5223. if ($size) {
  5224. $where .= " and features like '%-$size-%'";
  5225. }
  5226. if ($grade) {
  5227. $where .= " and features like '%-$grade-%'";
  5228. }
  5229. if ($color) {
  5230. $where .= " and features like '%-$color-%'";
  5231. }
  5232. if ($lowe) {
  5233. $where .= " and features like '%-$lowe-%'";
  5234. }
  5235. if ($state != '') {
  5236. $where .= " and state = '$state'";
  5237. }
  5238. //数据排序
  5239. $order_str = "dbtime desc";
  5240. if (empty($page)) {
  5241. $start = 0;
  5242. $perpage = 1;
  5243. } else {
  5244. $start = ($page - 1) * $perpage;
  5245. }
  5246. //取得信息列表
  5247. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5248. foreach ($info_list as $key => $value) {
  5249. $warehouse = $this->$w->read($value['warehouse']);
  5250. $info_list[$key]['warehouse'] = $warehouse['title'];
  5251. $purchase = $this->purchase->read($value['purchase']);
  5252. $info_list[$key]['purchase'] = $purchase['title'];
  5253. if ($value['enter'] != 0) {
  5254. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5255. } else {
  5256. $info_list[$key]['enter'] = "";
  5257. }
  5258. if ($value['dbtime'] != 0) {
  5259. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5260. } else {
  5261. $info_list[$key]['dbtime'] = "";
  5262. }
  5263. if ($value['state'] == 0) {
  5264. $info_list[$key]['state'] = "在库";
  5265. } else if ($value['state'] == 1) {
  5266. $info_list[$key]['state'] = "出库";
  5267. } else if ($value['state'] == 2) {
  5268. $info_list[$key]['state'] = "退库";
  5269. } else if ($value['state'] == 3) {
  5270. $info_list[$key]['state'] = "调拨中";
  5271. } else if ($value['state'] == 4) {
  5272. $info_list[$key]['state'] = "再加工";
  5273. } else if ($value['state'] == 5) {
  5274. $info_list[$key]['state'] = "维修中";
  5275. } else if ($value['state'] == 6) {
  5276. $info_list[$key]['state'] = "盘亏";
  5277. } else if ($value['state'] == 7) {
  5278. $info_list[$key]['state'] = "更换标签";
  5279. } else if ($value['state'] == 8) {
  5280. $info_list[$key]['state'] = "其它";
  5281. } else if ($value['state'] == 9) {
  5282. $info_list[$key]['state'] = "预设";
  5283. }
  5284. }
  5285. $total = $this->whlabel->find_count($where);
  5286. $pagenum = ceil($total / $perpage);
  5287. $over = $total - ($start + $perpage);
  5288. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5289. echo json_encode($rows);
  5290. exit;
  5291. }
  5292. if (isset($post['outsku'])) {
  5293. $time = time();
  5294. $cz = $this->input->post('cz', true);
  5295. $label = $this->input->post('outsku', true);
  5296. $sl = $this->input->post('sl', true);
  5297. $num = $this->input->post('num', true);
  5298. //$warehouse = $this->input->post('warehouse',true);
  5299. if (!$sl) {
  5300. $sl = 1;
  5301. }
  5302. if (!$warehouse) {
  5303. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5304. exit;
  5305. }
  5306. $dblabel = $this->whlabellabel->get_label($label);
  5307. if ($dblabel) {
  5308. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5309. if (count($data) < 1) {
  5310. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5311. exit;
  5312. }
  5313. if (count($data) < $num) {
  5314. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5315. exit;
  5316. }
  5317. for ($i = 0; $i < $sl; $i++) {
  5318. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5319. }
  5320. echo json_encode(array('success' => true));
  5321. exit;
  5322. } else {
  5323. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5324. exit;
  5325. }
  5326. }
  5327. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5328. $this->_Template('whlabel_db', $this->data);
  5329. }
  5330. public function _dbrk()
  5331. {
  5332. $post = $this->input->post(NULL, TRUE);
  5333. if (isset($post['page'])) {
  5334. $page = $this->input->post('page', true);
  5335. $perpage = $this->input->post('perpage', true);
  5336. $sku = $this->input->post('sku', true);
  5337. $number = $this->input->post('number', true);
  5338. $warehouse = $this->input->post('warehouse', true);
  5339. $purchase = $this->input->post('purchase', true);
  5340. $orderinfo = $this->input->post('orderinfo', true);
  5341. $waybill = $this->input->post('waybill', true);
  5342. $category = $this->input->post('category', true);
  5343. $size = $this->input->post('size', true);
  5344. $grade = $this->input->post('grade', true);
  5345. $color = $this->input->post('color', true);
  5346. $lowe = $this->input->post('lowe', true);
  5347. $state = $this->input->post('state', true);
  5348. $label = $this->input->post('label', true);
  5349. $ctime = $this->input->post('ctime', true);
  5350. $timetk = $this->input->post('timetkk', true);
  5351. $timetj = $this->input->post('timetjj', true);
  5352. $timetk = strtotime($timetk);
  5353. $timetj = strtotime($timetj);
  5354. $where = "dbtime > 0";
  5355. if ($timetk && $timetj) {
  5356. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5357. }
  5358. if ($sku) {
  5359. $where .= " and sku = '$sku'";
  5360. }
  5361. if ($warehouse) {
  5362. $where .= " and warehouse = '$warehouse'";
  5363. }
  5364. if ($purchase) {
  5365. $where .= " and purchase = '$purchase'";
  5366. }
  5367. if ($category) {
  5368. $where .= " and features like '%-$category-%'";
  5369. }
  5370. if ($size) {
  5371. $where .= " and features like '%-$size-%'";
  5372. }
  5373. if ($grade) {
  5374. $where .= " and features like '%-$grade-%'";
  5375. }
  5376. if ($color) {
  5377. $where .= " and features like '%-$color-%'";
  5378. }
  5379. if ($lowe) {
  5380. $where .= " and features like '%-$lowe-%'";
  5381. }
  5382. if ($state != '') {
  5383. $where .= " and state = '$state'";
  5384. }
  5385. //数据排序
  5386. $order_str = "dbtime desc";
  5387. if (empty($page)) {
  5388. $start = 0;
  5389. $perpage = 1;
  5390. } else {
  5391. $start = ($page - 1) * $perpage;
  5392. }
  5393. //取得信息列表
  5394. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5395. foreach ($info_list as $key => $value) {
  5396. $warehouse = $this->warehouse->read($value['warehouse']);
  5397. $info_list[$key]['warehouse'] = $warehouse['title'];
  5398. $purchase = $this->purchase->read($value['purchase']);
  5399. $info_list[$key]['purchase'] = $purchase['title'];
  5400. if ($value['enter'] != 0) {
  5401. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5402. } else {
  5403. $info_list[$key]['enter'] = "";
  5404. }
  5405. if ($value['dbtime'] != 0) {
  5406. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5407. } else {
  5408. $info_list[$key]['dbtime'] = "";
  5409. }
  5410. if ($value['state'] == 0) {
  5411. $info_list[$key]['state'] = "在库";
  5412. } else if ($value['state'] == 1) {
  5413. $info_list[$key]['state'] = "出库";
  5414. } else if ($value['state'] == 2) {
  5415. $info_list[$key]['state'] = "退库";
  5416. } else if ($value['state'] == 3) {
  5417. $info_list[$key]['state'] = "调拨中";
  5418. } else if ($value['state'] == 4) {
  5419. $info_list[$key]['state'] = "再加工";
  5420. } else if ($value['state'] == 5) {
  5421. $info_list[$key]['state'] = "维修中";
  5422. } else if ($value['state'] == 6) {
  5423. $info_list[$key]['state'] = "盘亏";
  5424. } else if ($value['state'] == 7) {
  5425. $info_list[$key]['state'] = "更换标签";
  5426. } else if ($value['state'] == 8) {
  5427. $info_list[$key]['state'] = "其它";
  5428. } else if ($value['state'] == 9) {
  5429. $info_list[$key]['state'] = "预设";
  5430. }
  5431. }
  5432. $total = $this->whlabel->find_count($where);
  5433. $pagenum = ceil($total / $perpage);
  5434. $over = $total - ($start + $perpage);
  5435. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5436. echo json_encode($rows);
  5437. exit;
  5438. }
  5439. if (isset($post['rsku'])) {
  5440. $cz = $this->input->post('cz', true);
  5441. $label = $this->input->post('rsku', true);
  5442. $sl = $this->input->post('sl', true);
  5443. $warehouse = $this->input->post('warehouse', true);
  5444. if (!$sl) {
  5445. $sl = 1;
  5446. }
  5447. if (!$warehouse) {
  5448. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5449. exit;
  5450. }
  5451. $dblabel = $this->whlabellabel->get_label($label);
  5452. if ($dblabel) {
  5453. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5454. if (count($data) < 1) {
  5455. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5456. exit;
  5457. }
  5458. if ($sl > count($data)) {
  5459. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5460. exit;
  5461. }
  5462. $time = time();
  5463. for ($i = 0; $i < $sl; $i++) {
  5464. $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']);
  5465. }
  5466. echo json_encode(array('success' => true));
  5467. exit;
  5468. } else {
  5469. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5470. exit;
  5471. }
  5472. }
  5473. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5474. $this->_Template('whlabel_dbrk', $this->data);
  5475. }
  5476. public function _whlabelczdc()
  5477. {
  5478. if (isset($_GET['excel'])) {
  5479. //数据排序
  5480. $order_str = "id desc";
  5481. if (empty($page)) {
  5482. $start = 0;
  5483. $perpage = 1;
  5484. } else {
  5485. $start = ($page - 1) * $perpage;
  5486. }
  5487. $state = $this->input->get('state', true);
  5488. $sku = $this->input->get('sku', true);
  5489. $ctime = $this->input->get('ctime', true);
  5490. $category = $this->input->get('category', true);
  5491. $size = $this->input->get('size', true);
  5492. $grade = $this->input->get('grade', true);
  5493. $color = $this->input->get('color', true);
  5494. $lowe = $this->input->get('lowe', true);
  5495. $timetk = $this->input->get('timetkk', true);
  5496. $timetj = $this->input->get('timetjj', true);
  5497. $timetk = strtotime($timetk);
  5498. $timetj = strtotime($timetj);
  5499. $where = "dbtime > 0";
  5500. if ($timetk && $timetj) {
  5501. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5502. }
  5503. if ($category) {
  5504. $where .= " and features like '%-$category-%'";
  5505. }
  5506. if ($size) {
  5507. $where .= " and features like '%-$size-%'";
  5508. }
  5509. if ($grade) {
  5510. $where .= " and features like '%-$grade-%'";
  5511. }
  5512. if ($color) {
  5513. $where .= " and features like '%-$color-%'";
  5514. }
  5515. if ($lowe) {
  5516. $where .= " and features like '%-$lowe-%'";
  5517. }
  5518. //取得信息列表
  5519. $info_list = $this->whlabel->find_all($where, '*');
  5520. $rows = array();
  5521. $list = array();
  5522. foreach ($info_list as $key => $value) {
  5523. $rows[$value['sku']] = $value; //所有数据sku
  5524. }
  5525. foreach ($rows as $value) {
  5526. $warehouse = $this->warehouse->read($value['warehouse']);
  5527. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5528. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5529. if ($value['orderinfo'] == 0) {
  5530. $info_list[$key]['orderinfo'] = "";
  5531. }
  5532. if ($value['waybill'] == 0) {
  5533. $info_list[$key]['waybill'] = "";
  5534. }
  5535. if ($value['state'] == 0) {
  5536. $value['state'] = "在库";
  5537. } else if ($value['state'] == 3) {
  5538. $value['state'] = "调拨中";
  5539. }
  5540. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5541. }
  5542. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5543. $titlename = "<table border=1>
  5544. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5545. <tr align='center'>
  5546. <td>SKU</td>
  5547. <td>产品</td>
  5548. <td>调拨数量</td>
  5549. <td>入库数量</td>
  5550. </tr>
  5551. </table>";
  5552. $filename = $title . ".xls";
  5553. $tail = "";
  5554. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5555. }
  5556. }
  5557. public function _print($arg_array)
  5558. {
  5559. if (isset($_SESSION['api'])) {
  5560. $user = $this->user->get_api($_SESSION['api']);
  5561. $usp = $user;
  5562. $fgshop = "";
  5563. $sid = "";
  5564. $wid = "";
  5565. $wtype = "";
  5566. $usersp = explode('|', trim($user['shop'], '|'));
  5567. $userwh = explode('|', trim($user['warehouse'], '|'));
  5568. foreach ($usersp as $value) {
  5569. $fgshop .= " shop = " . $value . " or";
  5570. $sid .= " id = " . $value . " or";
  5571. }
  5572. foreach ($userwh as $value) {
  5573. $wid .= " id = " . $value . " or";
  5574. $wtype .= " type = " . $value . " or";
  5575. }
  5576. }
  5577. $post = $this->input->post(NULL, TRUE);
  5578. if (isset($post['tmsku'])) {
  5579. $tmsku = $this->input->post('tmsku', true);
  5580. if (is_numeric($tmsku)) {
  5581. $yyh = $this->whlabellabel->get_label($tmsku);
  5582. } else {
  5583. $yyh = $this->whlabellabel->get_sku($tmsku);
  5584. }
  5585. if ($yyh) {
  5586. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5587. exit;
  5588. } else {
  5589. echo json_encode(array('success' => false));
  5590. exit;
  5591. }
  5592. }
  5593. $classid = $this->classid->sku();
  5594. $pm = $classid;
  5595. $scsku = $classid;
  5596. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5597. if (isset($post['warehouse'])) {
  5598. if ($post['warehouse']) {
  5599. $list = array();
  5600. $num = "";
  5601. $title = "";
  5602. $features = "";
  5603. $order = 0;
  5604. $post['shop'] = '';
  5605. $brand = $this->input->post('brand', true);
  5606. if ($brand != '0,') {
  5607. $b = $this->brand->read(rtrim($brand, ','));
  5608. if ($b) {
  5609. $post['shop'] = str_replace('|', ',', $b['shop']);
  5610. }
  5611. }
  5612. $post['details'] = $this->input->post('details', true); //打印数量
  5613. $xbqnum = $this->input->post('xbqnum', true);
  5614. $post['purchase'] = $this->input->post('purchase', true);
  5615. $post['warehouse'] = $this->input->post('warehouse', true);
  5616. $post['purchase'] = $this->input->post('purchase', true);
  5617. $post['retreatwarehouse'] = $post['warehouse'];
  5618. $post['cpbz'] = $this->input->post('cpbz', true);
  5619. $post['state'] = 9;
  5620. $category = $this->input->post('category', true);
  5621. $list['category'] = $category;
  5622. $list['hairtype'] = $this->input->post('hairtype', true);
  5623. $list['grade'] = $this->input->post('grade', true);
  5624. $size = $this->input->post('size', true);
  5625. $list['size'] = rtrim($size, ',');
  5626. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5627. $list['extension'] = $this->input->post('extension', true);
  5628. if ($category == 1297) {
  5629. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5630. }
  5631. if ($category == 1702) {
  5632. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5633. $list['syother'] = $this->input->post('syother', true);
  5634. }
  5635. if ($category == 133) {
  5636. $list['fittype'] = $this->input->post('fittype', true);
  5637. $list['acother'] = $this->input->post('acother', true);
  5638. }
  5639. $list['color'] = $this->input->post('color', true);
  5640. $list['lowe'] = $this->input->post('lowe', true);
  5641. if ($category == 127) {
  5642. $list['type'] = $this->input->post('type', true);
  5643. $list['headroad'] = $this->input->post('headroad', true);
  5644. $list['density'] = $this->input->post('density', true);
  5645. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5646. $list['lacesize'] = $this->input->post('lacesize', true);
  5647. }
  5648. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5649. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5650. }
  5651. if ($category == 128) {
  5652. $list['lacetype'] = $this->input->post('lacetype', true);
  5653. $list['haircap'] = $this->input->post('haircap', true);
  5654. $list['density'] = $this->input->post('density', true);
  5655. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5656. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5657. $list['wigother'] = $this->input->post('wigother', true);
  5658. $list['wigother1'] = $this->input->post('wigother1', true);
  5659. $list['wigother2'] = $this->input->post('wigother2', true);
  5660. }
  5661. if ($category == 129) {
  5662. $list['wide'] = $this->input->post('wide', true);
  5663. }
  5664. if ($category == 131) {
  5665. $list['gifttype'] = $this->input->post('gifttype', true);
  5666. $list['giftother'] = $this->input->post('giftother', true);
  5667. }
  5668. if ($category == 134) {
  5669. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5670. }
  5671. if ($category == 1297) {
  5672. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5673. $list['sywigother'] = $this->input->post('sywigother', true);
  5674. }
  5675. if ($category == 130 || $category == 133 || $category == 1702) {
  5676. $list['items'] = $this->input->post('items', true);
  5677. $list['weight'] = $this->input->post('weight', true);
  5678. }
  5679. if ($category == 1702) {
  5680. $list['syhairther'] = $this->input->post('syhairther', true);
  5681. }
  5682. foreach ($list as $k => $v) {
  5683. if ($v != 0) {
  5684. $num .= $v;
  5685. $features .= $v . '-';
  5686. $post[$k] = $v;
  5687. $typeclass = $this->typeclass->read($v);
  5688. if (isset($pm[$typeclass['classid']])) {
  5689. if (stripos($typeclass['zh'], '|') !== false) {
  5690. $exzh = explode('|', $typeclass['zh']);
  5691. $pm[$typeclass['classid']] = $exzh[0];
  5692. } else {
  5693. $pm[$typeclass['classid']] = $typeclass['zh'];
  5694. }
  5695. }
  5696. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5697. if ($k != 'size') {
  5698. $title .= $typeclass['title'] . " ";
  5699. }
  5700. }
  5701. }
  5702. $typeclass = $this->typeclass->read($list['size']);
  5703. $title .= $typeclass['title'];
  5704. $time = time();
  5705. $post['title'] = rtrim($title, ' ');
  5706. $post['number'] = $num;
  5707. $post['features'] = '-' . $features;
  5708. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5709. $featurespp = explode('-', trim($featurespp, '-'));
  5710. if (isset($featurespp[5])) {
  5711. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5712. } else {
  5713. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5714. }
  5715. $post['enter'] = $time;
  5716. $post['time'] = $time; //操作时间
  5717. $scsku = implode("-", $scsku);
  5718. $zh = implode(" ", $pm);
  5719. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5720. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5721. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5722. $post['sku'] = $bqsku;
  5723. $label = time() . rand(0, 9);
  5724. $post['label'] = $label;
  5725. $cpid = $this->whlabellabel->find_count();
  5726. $post['cpid'] = $cpid + 1;
  5727. $cpid = $post['cpid'];
  5728. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5729. //if($whlabelbarcode)
  5730. //{
  5731. //$post['label'] = $whlabelbarcode['label'];
  5732. //if(!$this->whlabellabel->insert($post))
  5733. //{
  5734. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5735. //}
  5736. //}
  5737. //else
  5738. //{
  5739. $this->db->trans_begin();
  5740. $this->whlabellabel->insert($post);
  5741. //$this->whlabelbarcode->insert($post);
  5742. if ($this->db->trans_status() === TRUE) {
  5743. $this->db->trans_commit();
  5744. } else {
  5745. $this->db->trans_rollback();
  5746. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5747. exit;
  5748. }
  5749. //}
  5750. $warehouse_name = "";
  5751. $warehouse = $post['warehouse'];
  5752. if($warehouse == 12){
  5753. $warehouse_name = "特殊库存库";
  5754. }
  5755. // if($warehouse == 13){
  5756. // $warehouse_name = "许昌仓";
  5757. // }
  5758. // if($warehouse == 5){
  5759. // $warehouse_name = "美国店";
  5760. // }
  5761. // if($warehouse == 16){
  5762. // $warehouse_name = "定制头套仓";
  5763. // }
  5764. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5765. if(!empty($warehouse_name)){
  5766. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5767. }
  5768. $purchase = $this->purchase->read($post['purchase']);
  5769. 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));
  5770. exit; //特殊仓目前不需要仓库选项
  5771. }
  5772. }
  5773. if (isset($_SESSION['api'])) {
  5774. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5775. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5776. $this->data['wlshop'] = $wlshop;
  5777. $this->data['warehouse'] = $warehouse;
  5778. }
  5779. $whlabelwz = $this->whlabelwz->find_all();
  5780. $this->data['whlabelwz'] = $whlabelwz;
  5781. $this->_Template('whlabel_print', $this->data);
  5782. }
  5783. public function _usaprint($arg_array)
  5784. {
  5785. if (isset($_SESSION['api'])) {
  5786. $user = $this->user->get_api($_SESSION['api']);
  5787. $usp = $user;
  5788. $fgshop = "";
  5789. $sid = "";
  5790. $wid = "";
  5791. $wtype = "";
  5792. $usersp = explode('|', trim($user['shop'], '|'));
  5793. $userwh = explode('|', trim($user['warehouse'], '|'));
  5794. foreach ($usersp as $value) {
  5795. $fgshop .= " shop = " . $value . " or";
  5796. $sid .= " id = " . $value . " or";
  5797. }
  5798. foreach ($userwh as $value) {
  5799. $wid .= " id = " . $value . " or";
  5800. $wtype .= " type = " . $value . " or";
  5801. }
  5802. }
  5803. $post = $this->input->post(NULL, TRUE);
  5804. if (isset($post['tmsku'])) {
  5805. $tmsku = $this->input->post('tmsku', true);
  5806. if (is_numeric($tmsku)) {
  5807. $yyh = $this->whlabellabel->get_label($tmsku);
  5808. } else {
  5809. $yyh = $this->whlabellabel->get_sku($tmsku);
  5810. }
  5811. if ($yyh) {
  5812. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5813. exit;
  5814. } else {
  5815. echo json_encode(array('success' => false));
  5816. exit;
  5817. }
  5818. }
  5819. $classid = $this->classid->sku();
  5820. $pm = $classid;
  5821. $scsku = $classid;
  5822. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5823. if (isset($post['warehouse'])) {
  5824. if ($post['warehouse']) {
  5825. $list = array();
  5826. $num = "";
  5827. $title = "";
  5828. $features = "";
  5829. $order = 0;
  5830. $post['shop'] = '';
  5831. $brand = $this->input->post('brand', true);
  5832. if ($brand != '0,') {
  5833. $b = $this->brand->read(rtrim($brand, ','));
  5834. if ($b) {
  5835. $post['shop'] = str_replace('|', ',', $b['shop']);
  5836. }
  5837. }
  5838. $post['details'] = $this->input->post('details', true); //打印数量
  5839. $xbqnum = $this->input->post('xbqnum', true);
  5840. $post['purchase'] = $this->input->post('purchase', true);
  5841. $post['warehouse'] = $this->input->post('warehouse', true);
  5842. $post['purchase'] = $this->input->post('purchase', true);
  5843. $post['retreatwarehouse'] = $post['warehouse'];
  5844. $post['cpbz'] = $this->input->post('cpbz', true);
  5845. $post['state'] = 9;
  5846. $category = $this->input->post('category', true);
  5847. $list['category'] = $category;
  5848. $list['hairtype'] = $this->input->post('hairtype', true);
  5849. $list['grade'] = $this->input->post('grade', true);
  5850. $size = $this->input->post('size', true);
  5851. $list['size'] = rtrim($size, ',');
  5852. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5853. $list['extension'] = $this->input->post('extension', true);
  5854. if ($category == 1297) {
  5855. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5856. }
  5857. if ($category == 1702) {
  5858. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5859. $list['syother'] = $this->input->post('syother', true);
  5860. }
  5861. if ($category == 133) {
  5862. $list['fittype'] = $this->input->post('fittype', true);
  5863. $list['acother'] = $this->input->post('acother', true);
  5864. }
  5865. $list['color'] = $this->input->post('color', true);
  5866. $list['lowe'] = $this->input->post('lowe', true);
  5867. if ($category == 127) {
  5868. $list['type'] = $this->input->post('type', true);
  5869. $list['headroad'] = $this->input->post('headroad', true);
  5870. $list['density'] = $this->input->post('density', true);
  5871. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5872. $list['lacesize'] = $this->input->post('lacesize', true);
  5873. }
  5874. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5875. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5876. }
  5877. if ($category == 128) {
  5878. $list['lacetype'] = $this->input->post('lacetype', true);
  5879. $list['haircap'] = $this->input->post('haircap', true);
  5880. $list['density'] = $this->input->post('density', true);
  5881. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5882. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5883. $list['wigother'] = $this->input->post('wigother', true);
  5884. $list['wigother1'] = $this->input->post('wigother1', true);
  5885. $list['wigother2'] = $this->input->post('wigother2', true);
  5886. }
  5887. if ($category == 129) {
  5888. $list['wide'] = $this->input->post('wide', true);
  5889. }
  5890. if ($category == 131) {
  5891. $list['gifttype'] = $this->input->post('gifttype', true);
  5892. $list['giftother'] = $this->input->post('giftother', true);
  5893. }
  5894. if ($category == 134) {
  5895. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5896. }
  5897. if ($category == 1297) {
  5898. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5899. $list['sywigother'] = $this->input->post('sywigother', true);
  5900. }
  5901. if ($category == 130 || $category == 133 || $category == 1702) {
  5902. $list['items'] = $this->input->post('items', true);
  5903. $list['weight'] = $this->input->post('weight', true);
  5904. }
  5905. if ($category == 1702) {
  5906. $list['syhairther'] = $this->input->post('syhairther', true);
  5907. }
  5908. foreach ($list as $k => $v) {
  5909. if ($v != 0) {
  5910. $num .= $v;
  5911. $features .= $v . '-';
  5912. $post[$k] = $v;
  5913. $typeclass = $this->typeclass->read($v);
  5914. if (isset($pm[$typeclass['classid']])) {
  5915. if (stripos($typeclass['zh'], '|') !== false) {
  5916. $exzh = explode('|', $typeclass['zh']);
  5917. $pm[$typeclass['classid']] = $exzh[0];
  5918. } else {
  5919. $pm[$typeclass['classid']] = $typeclass['zh'];
  5920. }
  5921. }
  5922. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5923. if ($k != 'size') {
  5924. $title .= $typeclass['title'] . " ";
  5925. }
  5926. }
  5927. }
  5928. $typeclass = $this->typeclass->read($list['size']);
  5929. $title .= $typeclass['title'];
  5930. $time = time();
  5931. $post['title'] = rtrim($title, ' ');
  5932. $post['number'] = $num;
  5933. $post['features'] = '-' . $features;
  5934. $fp = $this->whlabel->get_features($post['features']);
  5935. if (!$fp) {
  5936. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5937. exit;
  5938. }
  5939. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5940. $featurespp = explode('-', trim($featurespp, '-'));
  5941. if (isset($featurespp[5])) {
  5942. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5943. } else {
  5944. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5945. }
  5946. $post['enter'] = $time;
  5947. $post['time'] = $time; //操作时间
  5948. $scsku = implode("-", $scsku);
  5949. $zh = implode(" ", $pm);
  5950. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5951. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5952. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5953. $post['sku'] = $fp['sku'];
  5954. $post['label'] = $fp['sku'];
  5955. $cpid = $this->whlabellabel->find_count();
  5956. $post['cpid'] = $cpid + 1;
  5957. $cpid = $post['cpid'];
  5958. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5959. //if($whlabelbarcode)
  5960. //{
  5961. //$post['label'] = $whlabelbarcode['label'];
  5962. //if(!$this->whlabellabel->insert($post))
  5963. //{
  5964. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5965. //}
  5966. //}
  5967. //else
  5968. //{
  5969. $this->db->trans_begin();
  5970. $this->whlabellabel->insert($post);
  5971. //$this->whlabelbarcode->insert($post);
  5972. if ($this->db->trans_status() === TRUE) {
  5973. $this->db->trans_commit();
  5974. } else {
  5975. $this->db->trans_rollback();
  5976. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5977. exit;
  5978. }
  5979. //}
  5980. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5981. $purchase = $this->purchase->read($post['purchase']);
  5982. 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));
  5983. exit; //特殊仓目前不需要仓库选项
  5984. }
  5985. }
  5986. if (isset($_SESSION['api'])) {
  5987. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5988. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5989. $this->data['wlshop'] = $wlshop;
  5990. $this->data['warehouse'] = $warehouse;
  5991. }
  5992. $whlabelwz = $this->whlabelwz->find_all();
  5993. $this->data['whlabelwz'] = $whlabelwz;
  5994. $this->_Template('whlabel_usaprint', $this->data);
  5995. }
  5996. public function _printrk($arg_array)
  5997. {
  5998. $prc = array();
  5999. $purchase = $this->purchase->find_all();
  6000. foreach ($purchase as $k => $v) {
  6001. $prc[$v['id']] = $v['title'];
  6002. }
  6003. $post = $this->input->post(NULL, TRUE);
  6004. if (isset($post['page'])) {
  6005. $page = $this->input->post('page', true);
  6006. $perpage = $this->input->post('perpage', true);
  6007. $sku = $this->input->post('sku', true);
  6008. $bs = $this->input->post('bs', true);
  6009. $number = $this->input->post('number', true);
  6010. $warehouse = $this->input->post('warehouse', true);
  6011. $purchase = $this->input->post('purchase', true);
  6012. $orderinfo = $this->input->post('orderinfo', true);
  6013. $waybill = $this->input->post('waybill', true);
  6014. $category = $this->input->post('category', true);
  6015. $size = $this->input->post('size', true);
  6016. $grade = $this->input->post('grade', true);
  6017. $color = $this->input->post('color', true);
  6018. $lowe = $this->input->post('lowe', true);
  6019. $state = $this->input->post('state', true);
  6020. $label = $this->input->post('label', true);
  6021. $timetk = $this->input->post('ktime', true);
  6022. $timetj = $this->input->post('jtime', true);
  6023. $timetk = strtotime($timetk);
  6024. $timetj = strtotime($timetj);
  6025. $where = "1=1 ";
  6026. if ($timetk && $timetj) {
  6027. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6028. }
  6029. if ($sku) {
  6030. $where .= " and sku = '$sku'";
  6031. }
  6032. if ($bs != '') {
  6033. $where .= " and bs = '$bs'";
  6034. }
  6035. if ($number) {
  6036. $where .= " and number = '$number'";
  6037. }
  6038. if ($warehouse) {
  6039. $where .= " and warehouse = '$warehouse'";
  6040. }
  6041. if ($purchase) {
  6042. $where .= " and purchase = '$purchase'";
  6043. }
  6044. if ($orderinfo) {
  6045. $where .= " and orderinfo = '$orderinfo'";
  6046. }
  6047. if ($waybill) {
  6048. $where .= " and waybill = '$waybill'";
  6049. }
  6050. if ($category) {
  6051. $where .= " and features like '%-$category-%'";
  6052. }
  6053. if ($size) {
  6054. $where .= " and features like '%-$size-%'";
  6055. }
  6056. if ($grade) {
  6057. $where .= " and features like '%-$grade-%'";
  6058. }
  6059. if ($color) {
  6060. $where .= " and features like '%-$color-%'";
  6061. }
  6062. if ($lowe) {
  6063. $where .= " and features like '%-$lowe-%'";
  6064. }
  6065. if ($label) {
  6066. $where .= " and label = '$label'";
  6067. }
  6068. if ($state || $state == 0) {
  6069. $where .= " and state = '$state'";
  6070. }
  6071. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6072. //数据排序
  6073. $order_str = "enter desc";
  6074. if (empty($page)) {
  6075. $start = 0;
  6076. $perpage = 1;
  6077. } else {
  6078. $start = ($page - 1) * $perpage;
  6079. }
  6080. //取得信息列表
  6081. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6082. foreach ($info_list as $key => $value) {
  6083. $warehouse = $this->warehouse->read($value['warehouse']);
  6084. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6085. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6086. if ($value['state'] == 0) {
  6087. $info_list[$key]['state'] = "在库";
  6088. } else if ($value['state'] == 1) {
  6089. $info_list[$key]['state'] = "出库";
  6090. } else if ($value['state'] == 2) {
  6091. $info_list[$key]['state'] = "退库";
  6092. } else if ($value['state'] == 3) {
  6093. $info_list[$key]['state'] = "调拨中";
  6094. } else if ($value['state'] == 4) {
  6095. $info_list[$key]['state'] = "再加工";
  6096. } else if ($value['state'] == 5) {
  6097. $info_list[$key]['state'] = "维修中";
  6098. } else if ($value['state'] == 6) {
  6099. $info_list[$key]['state'] = "盘亏";
  6100. } else if ($value['state'] == 7) {
  6101. $info_list[$key]['state'] = "更换标签";
  6102. } else if ($value['state'] == 8) {
  6103. $info_list[$key]['state'] = "其它";
  6104. } else if ($value['state'] == 9) {
  6105. $info_list[$key]['state'] = "预设";
  6106. } else if ($value['state'] == 10) {
  6107. $info_list[$key]['state'] = "美店零售";
  6108. }
  6109. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6110. }
  6111. $total = $this->$ck->find_count($where);
  6112. $pagenum = ceil($total / $perpage);
  6113. $over = $total - ($start + $perpage);
  6114. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6115. echo json_encode($rows);
  6116. exit;
  6117. }
  6118. if (isset($post['tmsku'])) {
  6119. $time = time();
  6120. $tmsku = $this->input->post('tmsku', true);
  6121. //$post['shop'] = $this->input->post('shop',true);
  6122. $num = $this->input->post('num', true);
  6123. $rktype = $this->input->post('rktype', true);
  6124. if ($num > 200) {
  6125. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6126. exit;
  6127. }
  6128. if (!$rktype) {
  6129. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6130. }
  6131. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6132. /**
  6133. $wz = array();
  6134. foreach ($rk as $key=>$value)
  6135. {
  6136. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6137. }
  6138. if(count($wz) > 1)
  6139. {
  6140. $wz = array_values($wz);
  6141. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6142. }
  6143. **/
  6144. if (isset($rk[0]['purchase'])) {
  6145. $rk = $rk[0];
  6146. $j = 0;
  6147. $post['purchase'] = $rk['purchase'];
  6148. $post['warehouse'] = $rk['warehouse'];
  6149. $post['retreatwarehouse'] = $rk['warehouse'];
  6150. $post['sku'] = $rk['sku'];
  6151. $post['number'] = $rk['number'];
  6152. $post['features'] = $rk['features'];
  6153. $post['title'] = $rk['title'];
  6154. $post['enter'] = $time;
  6155. $post['time'] = $time;
  6156. $post['bs'] = 1;
  6157. $post['shop'] = $rk['shop'];
  6158. $post['details'] = $rk['details'];
  6159. $post['cpid'] = $rk['cpid'];
  6160. $post['cpbz'] = $rk['cpbz'];
  6161. //$post['rktype'] = $rktype;
  6162. $warehouse = $this->warehouse->read($rk['warehouse']);
  6163. if ($warehouse['bdck'] == '') {
  6164. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6165. exit;
  6166. } else {
  6167. $bdck = $warehouse['bdck'];
  6168. }
  6169. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6170. if (isset($pdwz['details'])) {
  6171. if ($pdwz['details'] != $post['details']) {
  6172. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6173. exit;
  6174. }
  6175. }
  6176. $post['featurespp'] = $rk['featurespp'];
  6177. if ($post['warehouse'] == '5') {
  6178. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6179. if ($yza) {
  6180. if ($post['features'] != $yza[0]['features']) {
  6181. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6182. exit;
  6183. }
  6184. }
  6185. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6186. if ($yzb) {
  6187. if ($post['sku'] != $yzb[0]['sku']) {
  6188. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6189. exit;
  6190. }
  6191. }
  6192. }
  6193. for ($i = 0; $i < $num; $i++) {
  6194. $post['label'] = time() . rand(100, 999) . $i;
  6195. if ($this->$bdck->insert($post)) {
  6196. $j++;
  6197. }
  6198. }
  6199. /**
  6200. if($post['warehouse'] != 12)
  6201. {
  6202. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6203. }
  6204. **/
  6205. if ($j == $num) {
  6206. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6207. exit;
  6208. } else {
  6209. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6210. exit;
  6211. }
  6212. } else {
  6213. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6214. exit;
  6215. }
  6216. }
  6217. $this->_Template('whlabel_printrk', $this->data);
  6218. }
  6219. public function _printxzrk($arg_array)
  6220. {
  6221. $post = $this->input->post(NULL, TRUE);
  6222. if (isset($post['wzid'])) {
  6223. $time = time();
  6224. $id = $this->input->post('wzid', true);
  6225. //$post['shop'] = $this->input->post('shop',true);
  6226. $num = 1;
  6227. $rk = $this->whlabellabel->read($id);
  6228. if (isset($rk['purchase'])) {
  6229. $x = 0;
  6230. $post['purchase'] = $rk['purchase'];
  6231. $post['warehouse'] = $rk['warehouse'];
  6232. $post['retreatwarehouse'] = $rk['warehouse'];
  6233. $post['sku'] = $rk['sku'];
  6234. $post['number'] = $rk['number'];
  6235. $post['features'] = $rk['features'];
  6236. $post['title'] = $rk['title'];
  6237. $post['enter'] = $time;
  6238. $post['time'] = $time;
  6239. $post['bs'] = 1;
  6240. $post['shop'] = $rk['shop'];
  6241. $post['details'] = $rk['details'];
  6242. $post['cpid'] = $rk['cpid'];
  6243. $post['cpbz'] = $rk['cpbz'];
  6244. $warehouse = $this->warehouse->read($rk['warehouse']);
  6245. if ($warehouse['bdck'] == '') {
  6246. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6247. exit;
  6248. } else {
  6249. $bdck = $warehouse['bdck'];
  6250. }
  6251. $post['featurespp'] = $rk['featurespp'];
  6252. $this->db->trans_begin();
  6253. for ($i = 0; $i < $num; $i++) {
  6254. $post['label'] = time() . rand(100, 999) . $i;
  6255. $this->$bdck->insert($post);
  6256. }
  6257. /**
  6258. if($post['warehouse'] != 12)
  6259. {
  6260. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6261. }
  6262. **/
  6263. if ($this->db->trans_status() === TRUE) {
  6264. $this->db->trans_commit();
  6265. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6266. exit;
  6267. } else {
  6268. $this->db->trans_rollback();
  6269. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6270. exit;
  6271. }
  6272. } else {
  6273. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6274. exit;
  6275. }
  6276. }
  6277. }
  6278. public function _printck($arg_array)
  6279. {
  6280. $prc = array();
  6281. $purchase = $this->purchase->find_all();
  6282. foreach ($purchase as $k => $v) {
  6283. $prc[$v['id']] = $v['title'];
  6284. }
  6285. $post = $this->input->post(NULL, TRUE);
  6286. if (isset($post['page'])) {
  6287. $page = $this->input->post('page', true);
  6288. $perpage = $this->input->post('perpage', true);
  6289. $sku = $this->input->post('sku', true);
  6290. $bs = $this->input->post('bs', true);
  6291. $number = $this->input->post('number', true);
  6292. $warehouse = $this->input->post('warehouse', true);
  6293. $purchase = $this->input->post('purchase', true);
  6294. $orderinfo = $this->input->post('orderinfo', true);
  6295. $waybill = $this->input->post('waybill', true);
  6296. $category = $this->input->post('category', true);
  6297. $size = $this->input->post('size', true);
  6298. $grade = $this->input->post('grade', true);
  6299. $color = $this->input->post('color', true);
  6300. $lowe = $this->input->post('lowe', true);
  6301. $state = $this->input->post('state', true);
  6302. $label = $this->input->post('label', true);
  6303. $timetk = $this->input->post('ktime', true);
  6304. $timetj = $this->input->post('jtime', true);
  6305. $timetk = strtotime($timetk);
  6306. $timetj = strtotime($timetj);
  6307. $where = "state=1 ";
  6308. if ($timetk && $timetj) {
  6309. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6310. }
  6311. if ($sku) {
  6312. $where .= " and sku = '$sku'";
  6313. }
  6314. if ($bs != '') {
  6315. $where .= " and bs = '$bs'";
  6316. }
  6317. if ($number) {
  6318. $where .= " and number = '$number'";
  6319. }
  6320. if ($warehouse) {
  6321. $where .= " and warehouse = '$warehouse'";
  6322. }
  6323. if ($purchase) {
  6324. $where .= " and purchase = '$purchase'";
  6325. }
  6326. if ($orderinfo) {
  6327. $where .= " and orderinfo = '$orderinfo'";
  6328. }
  6329. if ($waybill) {
  6330. $where .= " and waybill = '$waybill'";
  6331. }
  6332. if ($category) {
  6333. $where .= " and features like '%-$category-%'";
  6334. }
  6335. if ($size) {
  6336. $where .= " and features like '%-$size-%'";
  6337. }
  6338. if ($grade) {
  6339. $where .= " and features like '%-$grade-%'";
  6340. }
  6341. if ($color) {
  6342. $where .= " and features like '%-$color-%'";
  6343. }
  6344. if ($lowe) {
  6345. $where .= " and features like '%-$lowe-%'";
  6346. }
  6347. if ($label) {
  6348. $where .= " and label = '$label'";
  6349. }
  6350. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6351. //数据排序
  6352. $order_str = "outk desc";
  6353. if (empty($page)) {
  6354. $start = 0;
  6355. $perpage = 1;
  6356. } else {
  6357. $start = ($page - 1) * $perpage;
  6358. }
  6359. //取得信息列表
  6360. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6361. foreach ($info_list as $key => $value) {
  6362. $warehouse = $this->warehouse->read($value['warehouse']);
  6363. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6364. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6365. if ($value['state'] == 0) {
  6366. $info_list[$key]['state'] = "在库";
  6367. } else if ($value['state'] == 1) {
  6368. $info_list[$key]['state'] = "出库";
  6369. } else if ($value['state'] == 2) {
  6370. $info_list[$key]['state'] = "退库";
  6371. } else if ($value['state'] == 3) {
  6372. $info_list[$key]['state'] = "调拨中";
  6373. } else if ($value['state'] == 4) {
  6374. $info_list[$key]['state'] = "再加工";
  6375. } else if ($value['state'] == 5) {
  6376. $info_list[$key]['state'] = "维修中";
  6377. } else if ($value['state'] == 6) {
  6378. $info_list[$key]['state'] = "盘亏";
  6379. } else if ($value['state'] == 7) {
  6380. $info_list[$key]['state'] = "更换标签";
  6381. } else if ($value['state'] == 8) {
  6382. $info_list[$key]['state'] = "其它";
  6383. } else if ($value['state'] == 9) {
  6384. $info_list[$key]['state'] = "预设";
  6385. } else if ($value['state'] == 10) {
  6386. $info_list[$key]['state'] = "美店零售";
  6387. }
  6388. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6389. }
  6390. $total = $this->$ck->find_count($where);
  6391. $pagenum = ceil($total / $perpage);
  6392. $over = $total - ($start + $perpage);
  6393. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6394. echo json_encode($rows);
  6395. exit;
  6396. }
  6397. if (isset($post['tmsku'])) {
  6398. $time = time();
  6399. $tmsku = $this->input->post('tmsku', true);
  6400. //$post['shop'] = $this->input->post('shop',true);
  6401. $num = $this->input->post('num', true);
  6402. $cktype = $this->input->post('cktype', true);
  6403. $label = $this->whlabellabel->get_label($tmsku);
  6404. if (!$cktype) {
  6405. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6406. }
  6407. if (!isset($label['warehouse'])) {
  6408. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6409. exit;
  6410. }
  6411. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6412. if (stripos($label['features'], '-126-') !== false) {
  6413. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6414. } else {
  6415. $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 = ''");
  6416. }
  6417. $j = 0;
  6418. if (count($ck) >= $num) {
  6419. for ($i = 0; $i < $num; $i++) {
  6420. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6421. {
  6422. $j++;
  6423. }
  6424. }
  6425. if ($j == $num) {
  6426. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6427. exit;
  6428. } else {
  6429. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6430. exit;
  6431. }
  6432. } else {
  6433. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6434. exit;
  6435. }
  6436. }
  6437. if(isset($_SESSION['api']))
  6438. {
  6439. $user = $this->user->get_api($_SESSION['api']);
  6440. if(in_array($user['power'],[1,27])){
  6441. $vip = 1;
  6442. }
  6443. }
  6444. else
  6445. {
  6446. $vip = 0;
  6447. header('Location: /');exit;
  6448. }
  6449. $this->data['vip'] = $vip;
  6450. $this->_Template('whlabel_printck', $this->data);
  6451. }
  6452. public function _printexcel()
  6453. {
  6454. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6455. $config['upload_path'] = '.' . $dir;
  6456. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6457. $config['allowed_types'] = 'xls|xlsx|csv';
  6458. $config['max_size'] = 10240;
  6459. $this->load->library('upload', $config);
  6460. $this->upload->initialize($config);
  6461. if ($this->upload->do_upload('userfile')) {
  6462. $full_path = $dir . $this->upload->data('file_name');
  6463. $fileName = '.' . $full_path;
  6464. if (!file_exists($fileName)) {
  6465. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6466. exit;
  6467. } else {
  6468. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6469. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6470. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6471. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6472. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6473. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6474. ++$column; //如果列数大于26行
  6475. $list = array();
  6476. for ($i = 2; $i <= $row; $i++) // 行数循环
  6477. {
  6478. $data = array();
  6479. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6480. {
  6481. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6482. }
  6483. $list[] = $data;
  6484. }
  6485. }
  6486. $ed = array();
  6487. $i = 0;
  6488. $j = 0;
  6489. $dcdata = array();
  6490. $yc = '';
  6491. $cmf_arr = array_column($list, '1');
  6492. array_multisort($cmf_arr, SORT_ASC, $list);
  6493. foreach ($list as $key => $value) {
  6494. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6495. if ($typeclass) {
  6496. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6497. } else {
  6498. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6499. $i++;
  6500. continue;
  6501. }
  6502. }
  6503. if ($i > 0) {
  6504. $yc = $i . '条异常';
  6505. }
  6506. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6507. exit;
  6508. }
  6509. }
  6510. public function _uck()
  6511. {
  6512. if (isset($_GET['excel'])) {
  6513. $tc = array();
  6514. $typeclass = $this->typeclass->find_all();
  6515. foreach ($typeclass as $v) {
  6516. $tc[$v['id']] = $v['zh'];
  6517. }
  6518. $data = array();
  6519. $t = array();
  6520. $rq = '';
  6521. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6522. $ts = $ts / (24 * 3600);
  6523. for ($i = 0; $i < $ts; $i++) {
  6524. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6525. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6526. }
  6527. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6528. foreach ($info_list as $k => $v) {
  6529. $features = explode('-', trim($v['features'], '-'));
  6530. if (!isset($features[3]) || !isset($features[4])) {
  6531. continue;
  6532. }
  6533. $data[$k][0] = $tc[$features[0]]; //类型
  6534. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6535. $data[$k][2] = $tc[$features[4]]; //曲度
  6536. $data[$k][3] = '';
  6537. if (isset($data[$k][1])) {
  6538. $data[$k][3] .= $data[$k][1];
  6539. }
  6540. if (isset($data[$k][2])) {
  6541. $data[$k][3] .= $data[$k][2];
  6542. }
  6543. if (isset($features[5])) {
  6544. $data[$k][3] .= $tc[$features[5]];
  6545. }
  6546. if (isset($features[2])) {
  6547. $data[$k][3] .= $tc[$features[2]];
  6548. }
  6549. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6550. $data[$k][4] = $v['sku'];
  6551. $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())) . '))'); //月初库存
  6552. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6553. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6554. $ztrq = '';
  6555. $ztsl = '';
  6556. if (count($zt) > 0) {
  6557. foreach ($zt as $vv) {
  6558. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6559. $ztsl .= $vv['num'] . '<br>';
  6560. }
  6561. }
  6562. $data[$k][] = trim($ztsl, '<br>');
  6563. $data[$k][] = trim($ztrq, '<br>');
  6564. $byck = 0;
  6565. foreach ($t as $vv) {
  6566. $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));
  6567. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6568. $byck += $sl;
  6569. }
  6570. $data[$k][] = ($byck > 0) ? $byck : '';
  6571. }
  6572. $title = "详情 " . date("Y-m-d", time());
  6573. $titlename = "<table border=1>
  6574. <tr align='center'>
  6575. <td>类别</td>
  6576. <td>颜色</td>
  6577. <td>曲度</td>
  6578. <td>名称</td>
  6579. <td>SKU</td>
  6580. <td>月初库存</td>
  6581. <td>剩余库存</td>
  6582. <td>在途数量</td>
  6583. <td>预达日期</td>" .
  6584. $rq
  6585. . "<td>本月出库</td></tr>
  6586. </table>";
  6587. $filename = $title . ".xls";
  6588. $tail = "";
  6589. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6590. }
  6591. }
  6592. public function _whlabelexcelzh()
  6593. {
  6594. if (isset($_GET['excel'])) {
  6595. $where = "sku != 'Preset'";
  6596. //数据排序
  6597. $order_str = "id desc";
  6598. if (empty($page)) {
  6599. $start = 0;
  6600. $perpage = 1;
  6601. } else {
  6602. $start = ($page - 1) * $perpage;
  6603. }
  6604. $category = $this->input->get('category', true);
  6605. $warehouse = $this->input->get('warehouse', true);
  6606. $excelid = $this->input->get('sid', true);
  6607. if ($category) {
  6608. $where .= " and features like '%-$category-%'";
  6609. }
  6610. if ($warehouse) {
  6611. $where .= " and warehouse = '$warehouse'";
  6612. }
  6613. $xzid = '';
  6614. if ($excelid) {
  6615. $excelid = explode(',', trim($excelid, ','));
  6616. foreach ($excelid as $key => $value) {
  6617. $xzid .= " id = " . $value . " or";
  6618. }
  6619. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6620. }
  6621. //取得信息列表
  6622. /**
  6623. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6624. $rows = array();$list = array();
  6625. foreach ($info_list as $key=>$value)
  6626. {
  6627. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6628. }
  6629. **/
  6630. $list = array();
  6631. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6632. foreach ($rows as $key => $value) {
  6633. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6634. $zh = '';
  6635. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6636. foreach ($zt as $v) {
  6637. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6638. }
  6639. $zt = array_sum(array_column($zt, 'num'));
  6640. $number = $value['number'];
  6641. $ftime = time() - 15 * 24 * 3600;
  6642. $warehouse = $this->warehouse->read($value['warehouse']);
  6643. $rows[$key]['warehouse'] = $warehouse['title'];
  6644. $rows[$key]['number'] = $c;
  6645. $rows[$key]['features'] = $zh;
  6646. $rows[$key]['hb'] = $c + $zt;
  6647. }
  6648. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6649. $titlename = "<table border=1>
  6650. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6651. <tr align='center'>
  6652. <td>仓库</td>
  6653. <td>SKU</td>
  6654. <td>产品</td>
  6655. <td>库存数量</td>
  6656. <td>在途数量及预达日期</td>
  6657. <td>在途+库存数量</td>
  6658. </tr>
  6659. </table>";
  6660. $filename = $title . ".xls";
  6661. $tail = "";
  6662. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6663. }
  6664. if (isset($_GET['excel'])) {
  6665. $warehouse = $this->input->get('warehouse', true);
  6666. $sku = $this->input->get('sku', true);
  6667. $cz = $this->input->get('cz', true);
  6668. $text = $this->input->post('text', true);
  6669. $xztime = $this->input->get('xztime', true);
  6670. $timetk = $this->input->get('timetk', true);
  6671. $timetj = $this->input->get('timetj', true);
  6672. $timetk = strtotime($timetk);
  6673. $timetj = strtotime($timetj);
  6674. $where = "time = '0' ";
  6675. if ($warehouse) {
  6676. $where .= " and warehouse = '$warehouse'";
  6677. }
  6678. if ($sku) {
  6679. $where .= " and sku = '$sku'";
  6680. }
  6681. if ($text) {
  6682. $where .= " and text like '%$text%'";
  6683. }
  6684. if ($cz != '') {
  6685. $where .= " and cz = '$cz'";
  6686. }
  6687. if ($timetk && $timetj) {
  6688. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6689. }
  6690. //数据排序
  6691. $order_str = $xztime . " desc";
  6692. //取得信息列表
  6693. $zh = array();
  6694. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6695. foreach ($info_list as $v) {
  6696. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6697. $warehouse = $this->warehouse->read($v['warehouse']);
  6698. $v['warehouse'] = $warehouse['title'];
  6699. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6700. $v['stime'] = date('Y-m-d', $v['stime']);
  6701. if (isset($zh[$v['features']])) {
  6702. $zh[$v['features']]['num'] += $v['num'];
  6703. } else {
  6704. $zh[$v['features']] = $v;
  6705. }
  6706. $zh[$v['features']]['features'] = $c;
  6707. }
  6708. $title = "在途数据" . date('Y-m-d', time());
  6709. $titlename = "<table border=1>
  6710. <tr align='center'>
  6711. <td>仓库</td>
  6712. <td>SKU</td>
  6713. <td>名称</td>
  6714. <td>在途数量</td>
  6715. <td>库存数量</td>
  6716. <td>添加在途日期</td>
  6717. <td>预达日期</td>
  6718. <td>备注</td>
  6719. </tr>
  6720. </table>";
  6721. $filename = $title . ".xls";
  6722. $tail = "";
  6723. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6724. }
  6725. }
  6726. public function _fc()
  6727. {
  6728. $vip = 0;
  6729. if (isset($_SESSION['api'])) {
  6730. $user = $this->user->get_api($_SESSION['api']);
  6731. if ($user['vip'] == 1) {
  6732. $vip = 1;
  6733. }
  6734. } else {
  6735. header('Location: /');
  6736. exit;
  6737. }
  6738. $post = $this->input->post(NULL, TRUE);
  6739. if (isset($post['page'])) {
  6740. $page = $this->input->post('page', true);
  6741. $perpage = $this->input->post('perpage', true);
  6742. $category = $this->input->post('category', true);
  6743. $size = $this->input->post('size', true);
  6744. $grade = $this->input->post('grade', true);
  6745. $color = $this->input->post('color', true);
  6746. $lowe = $this->input->post('lowe', true);
  6747. $sku = $this->input->post('sku');
  6748. $title = $this->input->post('title');
  6749. $warehouse = $this->input->post('warehouse', true);
  6750. $usa = $this->input->post('usa', true);
  6751. $purchase = $this->input->post('purchase', true);
  6752. $lacetype = $this->input->post('lacetype', true);
  6753. $haircap = $this->input->post('haircap', true);
  6754. $density = $this->input->post('density', true);
  6755. $details = $this->input->post('details', true);
  6756. $state = $this->input->post('state', true);
  6757. $ktime = $this->input->post('ktime', true);
  6758. $jtime = $this->input->post('jtime', true);
  6759. $ktime = strtotime($ktime);
  6760. $jtime = strtotime($jtime);
  6761. $where = "state = '11'";
  6762. $gj = "";
  6763. $ck = "";
  6764. if ($lacetype) {
  6765. $where .= " and features like '%-$lacetype-%'";
  6766. }
  6767. if ($category) {
  6768. $where .= " and features like '%-$category-%'";
  6769. }
  6770. if ($size) {
  6771. $where .= " and features like '%-$size-%'";
  6772. }
  6773. if ($grade) {
  6774. $where .= " and features like '%-$grade-%'";
  6775. }
  6776. if ($color) {
  6777. $where .= " and features like '%-$color-%'";
  6778. }
  6779. if ($lowe) {
  6780. $where .= " and features like '%-$lowe-%'";
  6781. }
  6782. if ($haircap) {
  6783. $where .= " and features like '%-$haircap-%'";
  6784. }
  6785. if ($density) {
  6786. $where .= " and features like '%-$density-%'";
  6787. }
  6788. if ($usa) {
  6789. if (!$warehouse) {
  6790. $where .= " and (warehouse = '5' or warehouse = '8')";
  6791. }
  6792. }
  6793. if ($warehouse) {
  6794. $where .= " and warehouse = '$warehouse'";
  6795. }
  6796. if ($details) {
  6797. $where .= " and details = '$details'";
  6798. }
  6799. if ($purchase) {
  6800. $where .= " and purchase = '$purchase'";
  6801. }
  6802. if ($state) {
  6803. $where .= " and state = '$state'";
  6804. }
  6805. if ($ktime && $jtime) {
  6806. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6807. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6808. }
  6809. //数据排序
  6810. $order_str = "id desc";
  6811. if (empty($page)) {
  6812. $start = 0;
  6813. $perpage = 1;
  6814. } else {
  6815. $start = ($page - 1) * $perpage;
  6816. }
  6817. if ($sku) {
  6818. $sku = trim($sku, ' ');
  6819. $sku = trim($sku, ' ');
  6820. $where .= " and sku like '%$sku%'";
  6821. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6822. } else if ($title) {
  6823. $title = trim($title, ' ');
  6824. $title = trim($title, ' ');
  6825. $where .= " and title like '%$title%'";
  6826. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6827. } else {
  6828. //$where .= " and time > '$ktime' and time < '$jtime'";
  6829. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6830. }
  6831. //取得信息列表
  6832. $rows = array();
  6833. $list = array();
  6834. foreach ($info_list as $key => $value) {
  6835. $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'] . '"');
  6836. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6837. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6838. $warehouse = $this->warehouse->read($value['warehouse']);
  6839. $info_list[$key]['warehouse'] = $warehouse['title'];
  6840. $info_list[$key]['number'] = $g;
  6841. $info_list[$key]['features'] = $x;
  6842. $info_list[$key]['x'] = $s;
  6843. }
  6844. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6845. $pagenum = ceil($total / $perpage);
  6846. $over = $total - ($start + $perpage);
  6847. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6848. echo json_encode($rows);
  6849. exit;
  6850. }
  6851. $this->data['vip'] = $vip;
  6852. $this->_Template('whlabel_fc', $this->data);
  6853. }
  6854. public function _fcmb()
  6855. {
  6856. $where = "sku != 'Preset'";
  6857. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6858. foreach ($rows as $k => $v) {
  6859. $warehouse = $this->warehouse->read($v['warehouse']);
  6860. $rows[$k]['warehouse'] = $warehouse['title'];
  6861. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6862. $rows[$k]['t'] = '';
  6863. $rows[$k]['n'] = '';
  6864. }
  6865. $title = "封货产品数据导入模板";
  6866. $titlename = "<table border=1>
  6867. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6868. <tr align='center'>
  6869. <td>仓库</td>
  6870. <td>SKU</td>
  6871. <td>产品</td>
  6872. <td>封存产品总数量</td>
  6873. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6874. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6875. </tr>
  6876. </table>";
  6877. $filename = $title . ".xls";
  6878. $tail = "";
  6879. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6880. }
  6881. public function _fcexcel()
  6882. {
  6883. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6884. $config['upload_path'] = '.' . $dir;
  6885. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6886. $config['allowed_types'] = 'xls|xlsx|csv';
  6887. $config['max_size'] = 10240;
  6888. $this->load->library('upload', $config);
  6889. $this->upload->initialize($config);
  6890. if ($this->upload->do_upload('userfile')) {
  6891. $full_path = $dir . $this->upload->data('file_name');
  6892. $fileName = '.' . $full_path;
  6893. if (!file_exists($fileName)) {
  6894. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6895. exit;
  6896. } else {
  6897. libxml_use_internal_errors(true);
  6898. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6899. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6900. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6901. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6902. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6903. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6904. ++$column; //如果列数大于26行
  6905. $list = array();
  6906. for ($i = 2; $i <= $row; $i++) // 行数循环
  6907. {
  6908. $data = array();
  6909. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6910. {
  6911. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6912. }
  6913. $list[] = $data;
  6914. }
  6915. }
  6916. $i = 0;
  6917. $j = 0;
  6918. $ed = array();
  6919. foreach ($list as $key => $value) {
  6920. $time = time();
  6921. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6922. continue;
  6923. }
  6924. $warehouse = $this->warehouse->get_title($value['0']);
  6925. $sku = $value['1'];
  6926. $type = $value['4']; //调整方式0扣减1删除
  6927. $num = $value['5']; //调整数量
  6928. //$text = $value['4'];//扣减说明
  6929. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6930. if (!$d) //如果没有这个SKU
  6931. {
  6932. $ed[] = array($sku . '-库存中不存在此SKU');
  6933. $j++;
  6934. continue;
  6935. }
  6936. if (!isset($warehouse['id'])) {
  6937. $ed[] = array($sku . '-仓库名错误!');
  6938. $j++;
  6939. continue;
  6940. }
  6941. if ($type == 1 || $type == 2) //扣减库存
  6942. {
  6943. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6944. if (count($data) < abs($num)) {
  6945. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6946. $j++;
  6947. continue;
  6948. }
  6949. if ($type == 1) //转入库存
  6950. {
  6951. for ($i = 0; $i < abs($num); $i++) {
  6952. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6953. }
  6954. } else if ($type == 2) //删除
  6955. {
  6956. for ($i = 0; $i < abs($num); $i++) {
  6957. $this->whlabel->remove($data[$i]['id']);
  6958. }
  6959. }
  6960. } else if ($type == 0) //增加库存
  6961. {
  6962. $post['sku'] = $d['sku'];
  6963. $post['shop'] = '';
  6964. $post['warehouse'] = $warehouse['id'];
  6965. $post['purchase'] = $d['purchase'];
  6966. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6967. $post['state'] = 11;
  6968. $post['title'] = $d['title'];
  6969. $post['number'] = $d['number'];
  6970. $post['features'] = $d['features'];
  6971. $post['enter'] = $time;
  6972. $post['time'] = $time; //操作时间
  6973. for ($i = 0; $i < $num; $i++) {
  6974. $post['label'] = time() . rand(100, 999) . $i;
  6975. $this->whlabel->insert($post);
  6976. }
  6977. }
  6978. sleep(1); //防止入库时间一样,需要延迟1秒
  6979. }
  6980. if ($j > 0) {
  6981. $tt = date('Ymd', time());
  6982. $title = '库存导入错误信息-' . $tt;
  6983. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6984. $tail = "\n";
  6985. $filename = $title . ".xls";
  6986. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6987. $dir = '/data/excel/' . $time . '/';
  6988. $file_name = 'error_' . $time . rand(1000, 9999);
  6989. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6990. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6991. fwrite($myfile, $ecl);
  6992. fclose($myfile);
  6993. $error = $dir . $file_name . '.xls';
  6994. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6995. exit;
  6996. } else {
  6997. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6998. exit;
  6999. }
  7000. }
  7001. }
  7002. public function _fcjxc($arg_array)
  7003. {
  7004. if (isset($_GET['excel'])) {
  7005. $category = $this->input->get('category', true);
  7006. $size = $this->input->get('size', true);
  7007. $grade = $this->input->get('grade', true);
  7008. $color = $this->input->get('color', true);
  7009. $lowe = $this->input->get('lowe', true);
  7010. $sku = $this->input->get('sku');
  7011. $title = $this->input->get('title');
  7012. $warehouse = $arg_array[0];
  7013. $usa = $this->input->get('usa', true);
  7014. $purchase = $this->input->get('purchase', true);
  7015. $lacetype = $this->input->get('lacetype', true);
  7016. $haircap = $this->input->get('haircap', true);
  7017. $density = $this->input->get('density', true);
  7018. $title = $this->input->get('title', true);
  7019. $state = $this->input->get('state', true);
  7020. $ktime = $this->input->get('ktime', true);
  7021. $jtime = $this->input->get('jtime', true);
  7022. $where = "state=11";
  7023. $gj = "";
  7024. $ck = "";
  7025. if ($lacetype) {
  7026. $where .= " and features like '%-$lacetype-%'";
  7027. }
  7028. if ($category) {
  7029. $where .= " and features like '%-$category-%'";
  7030. }
  7031. if ($size) {
  7032. $where .= " and features like '%-$size-%'";
  7033. }
  7034. if ($grade) {
  7035. $where .= " and features like '%-$grade-%'";
  7036. }
  7037. if ($color) {
  7038. $where .= " and features like '%-$color-%'";
  7039. }
  7040. if ($lowe) {
  7041. $where .= " and features like '%-$lowe-%'";
  7042. }
  7043. if ($haircap) {
  7044. $where .= " and features like '%-$haircap-%'";
  7045. }
  7046. if ($density) {
  7047. $where .= " and features like '%-$density-%'";
  7048. }
  7049. if ($usa) {
  7050. if (!$warehouse) {
  7051. $where .= " and (warehouse = '5' or warehouse = '8')";
  7052. }
  7053. }
  7054. if ($warehouse) {
  7055. $where .= " and warehouse = '$warehouse'";
  7056. }
  7057. if ($purchase) {
  7058. $where .= " and purchase = '$purchase'";
  7059. }
  7060. if ($state) {
  7061. $where .= " and state = '$state'";
  7062. }
  7063. $order_str = "id desc";
  7064. if ($sku) {
  7065. $sku = trim($sku, ' ');
  7066. $sku = trim($sku, ' ');
  7067. $where .= " and sku like '%$sku%'";
  7068. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7069. } else if ($title) {
  7070. $title = trim($title, ' ');
  7071. $title = trim($title, ' ');
  7072. $where .= " and title like '%$title%'";
  7073. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7074. } else {
  7075. //$where .= " and time > '$ktime' and time < '$jtime'";
  7076. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7077. }
  7078. //取得信息列表
  7079. $rows = array();
  7080. $list = array();
  7081. foreach ($info_list as $key => $value) {
  7082. $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'] . '"');
  7083. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7084. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7085. $rows[$key] = $value;
  7086. $warehouse = $this->warehouse->read($value['warehouse']);
  7087. $rows[$key]['warehouse'] = $warehouse['title'];
  7088. $rows[$key]['features'] = $g;
  7089. $rows[$key]['a'] = $x;
  7090. $rows[$key]['b'] = $s;
  7091. }
  7092. $title = "总统计表";
  7093. $titlename = "<table border=1>
  7094. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7095. <tr align='center'>
  7096. <td>仓库</td>
  7097. <td>SKU</td>
  7098. <td>产品名称</td>
  7099. <td>录入总量</td>
  7100. <td>取出总量</td>
  7101. <td>剩余总量</td>
  7102. </tr>
  7103. </table>";
  7104. $filename = $title . ".xls";
  7105. $tail = "";
  7106. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7107. }
  7108. $vip = 0;
  7109. if (isset($_SESSION['api'])) {
  7110. $user = $this->user->get_api($_SESSION['api']);
  7111. if ($user['vip'] == 1) {
  7112. $vip = 1;
  7113. }
  7114. } else {
  7115. header('Location: /');
  7116. exit;
  7117. }
  7118. $post = $this->input->post(NULL, TRUE);
  7119. if (isset($post['page'])) {
  7120. $page = $this->input->post('page', true);
  7121. $perpage = $this->input->post('perpage', true);
  7122. $category = $this->input->post('category', true);
  7123. $size = $this->input->post('size', true);
  7124. $grade = $this->input->post('grade', true);
  7125. $color = $this->input->post('color', true);
  7126. $lowe = $this->input->post('lowe', true);
  7127. $sku = $this->input->post('sku');
  7128. $title = $this->input->post('title');
  7129. $warehouse = $arg_array[0];
  7130. $usa = $this->input->post('usa', true);
  7131. $purchase = $this->input->post('purchase', true);
  7132. $lacetype = $this->input->post('lacetype', true);
  7133. $haircap = $this->input->post('haircap', true);
  7134. $density = $this->input->post('density', true);
  7135. $title = $this->input->post('title', true);
  7136. $state = $this->input->post('state', true);
  7137. $ktime = $this->input->post('ktime', true);
  7138. $jtime = $this->input->post('jtime', true);
  7139. $ktime = strtotime($ktime);
  7140. $jtime = strtotime($jtime);
  7141. $where = "state=11";
  7142. $gj = "";
  7143. $ck = "";
  7144. if ($lacetype) {
  7145. $where .= " and features like '%-$lacetype-%'";
  7146. }
  7147. if ($category) {
  7148. $where .= " and features like '%-$category-%'";
  7149. }
  7150. if ($size) {
  7151. $where .= " and features like '%-$size-%'";
  7152. }
  7153. if ($grade) {
  7154. $where .= " and features like '%-$grade-%'";
  7155. }
  7156. if ($color) {
  7157. $where .= " and features like '%-$color-%'";
  7158. }
  7159. if ($lowe) {
  7160. $where .= " and features like '%-$lowe-%'";
  7161. }
  7162. if ($haircap) {
  7163. $where .= " and features like '%-$haircap-%'";
  7164. }
  7165. if ($density) {
  7166. $where .= " and features like '%-$density-%'";
  7167. }
  7168. if ($usa) {
  7169. if (!$warehouse) {
  7170. $where .= " and (warehouse = '5' or warehouse = '8')";
  7171. }
  7172. }
  7173. if ($warehouse) {
  7174. $where .= " and warehouse = '$warehouse'";
  7175. }
  7176. if ($purchase) {
  7177. $where .= " and purchase = '$purchase'";
  7178. }
  7179. if ($state) {
  7180. $where .= " and state = '$state'";
  7181. }
  7182. if ($ktime && $jtime) {
  7183. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7184. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7185. }
  7186. //数据排序
  7187. $order_str = "id desc";
  7188. $xs = 0;
  7189. $rows = array();
  7190. $list = array();
  7191. if (empty($page)) {
  7192. $start = 0;
  7193. $perpage = 1;
  7194. } else {
  7195. $start = ($page - 1) * $perpage;
  7196. }
  7197. if ($sku || $title) {
  7198. if ($title) {
  7199. $title = trim($title, ' ');
  7200. $title = trim($title, ' ');
  7201. $where .= " and title like '%$title%'";
  7202. } else {
  7203. $sku = trim($sku, ' ');
  7204. $sku = trim($sku, ' ');
  7205. $where .= " and sku like '%$sku%'";
  7206. }
  7207. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7208. foreach ($info_list as $key => $value) {
  7209. $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'] . '"');
  7210. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7211. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7212. $rows[$key] = $value;
  7213. $warehouse = $this->warehouse->read($value['warehouse']);
  7214. $rows[$key]['warehouse'] = $warehouse['title'];
  7215. $rows[$key]['features'] = $g;
  7216. $rows[$key]['a'] = $x;
  7217. $rows[$key]['b'] = $s;
  7218. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7219. $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天销量
  7220. $yj = $c / ($xl / 30);
  7221. if ($yj < 7) {
  7222. $rows[$key]['y'] = round($yj) . '天销量';
  7223. } else {
  7224. $rows[$key]['y'] = '正常';
  7225. }
  7226. }
  7227. } else {
  7228. //$where .= " and time > '$ktime' and time < '$jtime'";
  7229. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7230. foreach ($info_list as $key => $value) {
  7231. $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'] . '"');
  7232. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7233. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7234. $zs[$key] = $value;
  7235. $warehouse = $this->warehouse->read($value['warehouse']);
  7236. $zs[$key]['warehouse'] = $warehouse['title'];
  7237. $zs[$key]['features'] = $g;
  7238. $zs[$key]['a'] = $x;
  7239. $zs[$key]['b'] = $s;
  7240. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7241. $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天销量
  7242. $yj = $c / ($xl / 30);
  7243. if ($yj < 7) {
  7244. $zs[$key]['y'] = round($yj) . '天销量';
  7245. $rows[$key] = $zs[$key];
  7246. }
  7247. }
  7248. }
  7249. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7250. $pagenum = ceil($total / $perpage);
  7251. $over = $total - ($start + $perpage);
  7252. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7253. echo json_encode($rows);
  7254. exit;
  7255. }
  7256. $this->data['arg_array'] = $arg_array[0];
  7257. $this->_Template('whlabel_fcjxc', $this->data);
  7258. }
  7259. public function _0kcdel()
  7260. {
  7261. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7262. $config['upload_path'] = '.' . $dir;
  7263. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7264. $config['allowed_types'] = 'xls|xlsx|csv';
  7265. $config['max_size'] = 10240;
  7266. $this->load->library('upload', $config);
  7267. $this->upload->initialize($config);
  7268. if ($this->upload->do_upload('userfile')) {
  7269. $full_path = $dir . $this->upload->data('file_name');
  7270. $fileName = '.' . $full_path;
  7271. if (!file_exists($fileName)) {
  7272. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7273. exit;
  7274. } else {
  7275. require_once "./data/excel/PHPExcel/IOFactory.php";
  7276. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7277. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7278. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7279. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7280. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7281. ++$column; //如果列数大于26行
  7282. $list = array();
  7283. for ($i = 2; $i <= $row; $i++) // 行数循环
  7284. {
  7285. $data = array();
  7286. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7287. {
  7288. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7289. }
  7290. $list[] = $data;
  7291. }
  7292. }
  7293. $i = 0;
  7294. $j = 0;
  7295. $ed = array();
  7296. foreach ($list as $key => $value) {
  7297. $time = time();
  7298. if ($value['0'] == "" || $value['1'] == "") {
  7299. continue;
  7300. }
  7301. $warehouse = $this->warehouse->get_title($value['0']);
  7302. $sku = $value['1'];
  7303. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7304. if (!$d) //如果没有这个SKU
  7305. {
  7306. $ed[] = array($sku . '-库存中不存在此SKU');
  7307. $j++;
  7308. continue;
  7309. }
  7310. if (!isset($warehouse['id'])) {
  7311. $ed[] = array($sku . '-仓库名错误!');
  7312. $j++;
  7313. continue;
  7314. }
  7315. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7316. if ($z < 1) {
  7317. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7318. foreach ($z as $v) {
  7319. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7320. if (count($zt) > 0) {
  7321. $ed[] = array($sku . '-有在途库存无法删除!');
  7322. $j++;
  7323. continue;
  7324. }
  7325. $this->whlabel->remove($v['id']);
  7326. }
  7327. } else {
  7328. $ed[] = array($sku . '-非0库存!');
  7329. $j++;
  7330. continue;
  7331. }
  7332. }
  7333. if ($j > 0) {
  7334. $tt = date('Ymd', time());
  7335. $title = '删除0库存错误信息-' . $tt;
  7336. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7337. $tail = "\n";
  7338. $filename = $title . ".xls";
  7339. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7340. $dir = '/data/excel/' . $time . '/';
  7341. $file_name = 'error_' . $time . rand(1000, 9999);
  7342. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7343. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7344. fwrite($myfile, $ecl);
  7345. fclose($myfile);
  7346. $error = $dir . $file_name . '.xls';
  7347. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7348. exit;
  7349. } else {
  7350. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7351. exit;
  7352. }
  7353. }
  7354. }
  7355. public function _gbhtype()
  7356. {
  7357. $post = $this->input->post(NULL, TRUE);
  7358. if (isset($post['s'])) {
  7359. $n = $this->input->post('n');
  7360. $d = $this->input->post('s');
  7361. if (!$d) {
  7362. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7363. exit;
  7364. }
  7365. $d = explode(',', trim($d, ','));
  7366. $t = $this->whlabel_type->read($n);
  7367. //循环删除记录
  7368. foreach ($d as $v) {
  7369. $u = $this->whlabel->read($v);
  7370. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7371. foreach ($data as $val) {
  7372. $this->whlabel->save(array('type' => $n), $val['id']);
  7373. }
  7374. }
  7375. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7376. }
  7377. }
  7378. //出库、退库导出
  7379. public function _dccrtype()
  7380. {
  7381. $classid = $this->classid->sku();
  7382. $pm = $classid;
  7383. $typeclass = array();
  7384. $tc = $this->typeclass->find_all();
  7385. foreach ($tc as $v) {
  7386. $typeclass[$v['id']] = $v;
  7387. }
  7388. $prc = array();
  7389. $purchase = $this->purchase->find_all();
  7390. foreach ($purchase as $k => $v) {
  7391. $prc[$v['id']] = $v['title'];
  7392. }
  7393. if (isset($_GET['sid'])) {
  7394. $wh = array();
  7395. $w = $this->warehouse->find_all('1=1', 'id,title');
  7396. foreach ($w as $v) {
  7397. $wh[$v['id']] = $v['title'];
  7398. }
  7399. $type = $this->input->get('excel', true);
  7400. $category = $this->input->get('category', true);
  7401. $size = $this->input->get('size', true);
  7402. $grade = $this->input->get('grade', true);
  7403. $color = $this->input->get('color', true);
  7404. $lowe = $this->input->get('lowe', true);
  7405. $sku = $this->input->get('sku', true);
  7406. $warehouse = $this->input->get('warehouse', true);
  7407. $lacetype = $this->input->get('lacetype', true);
  7408. $lacecolor = $this->input->get('lacecolor', true);
  7409. $density = $this->input->get('density', true);
  7410. $haircap = $this->input->get('haircap', true);
  7411. $purchase = $this->input->get('purchase', true);
  7412. $title = $this->input->get('title', true);
  7413. $state = $this->input->get('state', true);
  7414. $sid = $this->input->get('sid', true);
  7415. $ktime = $this->input->get('ktime', true);
  7416. $jtime = $this->input->get('jtime', true);
  7417. $ktime = strtotime($ktime);
  7418. $jtime = strtotime($jtime);
  7419. $where = "1=1";
  7420. $gj = "";
  7421. $ck = "";
  7422. if ($category) {
  7423. $where .= " and features like '%-$category-%'";
  7424. }
  7425. if ($size) {
  7426. $where .= " and features like '%-$size-%'";
  7427. }
  7428. if ($grade) {
  7429. $where .= " and features like '%-$grade-%'";
  7430. }
  7431. if ($color) {
  7432. $where .= " and features like '%-$color-%'";
  7433. }
  7434. if ($lowe) {
  7435. $where .= " and features like '%-$lowe-%'";
  7436. }
  7437. if ($warehouse) {
  7438. $where .= " and warehouse = '$warehouse'";
  7439. }
  7440. if ($purchase) {
  7441. $where .= " and purchase = '$purchase'";
  7442. }
  7443. if ($state) {
  7444. $where .= " and state = '$state'";
  7445. }
  7446. if ($lacetype) {
  7447. $where .= " and features like '%-$lacetype-%'";
  7448. }
  7449. if ($lacecolor) {
  7450. $where .= " and features like '%-$lacecolor-%'";
  7451. }
  7452. if ($density) {
  7453. $where .= " and features like '%-$density-%'";
  7454. }
  7455. if ($haircap) {
  7456. $where .= " and features like '%-$haircap-%'";
  7457. }
  7458. if ($title) {
  7459. $title = trim($title, ' ');
  7460. $title = trim($title, ' ');
  7461. $where .= " and title like '%$title%'";
  7462. }
  7463. if ($sku) {
  7464. $sku = trim($sku, ' ');
  7465. $sku = trim($sku, ' ');
  7466. $where .= " and sku like '%$sku%'";
  7467. }
  7468. if ($ktime && $jtime) {
  7469. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7470. }
  7471. $sidwhere = '';
  7472. if ($sid) {
  7473. $sd = "";
  7474. $s = explode(',', trim($sid, ','));
  7475. foreach ($s as $value) {
  7476. $sd .= " id = " . $value . " or";
  7477. }
  7478. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7479. }
  7480. //数据排序
  7481. $order_str = "time desc";
  7482. if (empty($page)) {
  7483. $start = 0;
  7484. $perpage = 1;
  7485. } else {
  7486. $start = ($page - 1) * $perpage;
  7487. }
  7488. $wh = array();
  7489. $w = $this->warehouse->find_all('1=1', 'id,title');
  7490. foreach ($w as $v) {
  7491. $wh[$v['id']] = $v['title'];
  7492. }
  7493. $wt = array();
  7494. $whlabel_type = $this->whlabel_type->find_all();
  7495. foreach ($whlabel_type as $v) {
  7496. $wt[$v['id']] = $v['title'];
  7497. }
  7498. $classid = $this->classid->sku();
  7499. $list = array();
  7500. $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');
  7501. foreach ($rows_r as $key => $value) {
  7502. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7503. $pm = $classid;
  7504. $jm = $classid;
  7505. $rows_r[$key]['enter'] = '入库';
  7506. $rows_r[$key]['time'] = $value['enter'];
  7507. if ($value['rktype'] == 1) {
  7508. $rows_r[$key]['rktype'] = '采购入库';
  7509. } else if ($value['rktype'] == 2) {
  7510. $rows_r[$key]['rktype'] = '盘盈调整';
  7511. } else if ($value['rktype'] == 3) {
  7512. $rows_r[$key]['rktype'] = '其他调整入库';
  7513. } else if ($value['rktype'] == 4) {
  7514. $rows_r[$key]['rktype'] = '其他调整入库';
  7515. } else if ($value['rktype'] == 5) {
  7516. $rows_r[$key]['rktype'] = '退库入库';
  7517. } else if ($value['rktype'] == 6) {
  7518. $rows_r[$key]['rktype'] = '退货可用入库';
  7519. } else if ($value['rktype'] == 7) {
  7520. $rows_r[$key]['rktype'] = '形态转换入库';
  7521. } else {
  7522. $rows_r[$key]['rktype'] = '';
  7523. }
  7524. $features = explode('-', trim($value['features'], '-'));
  7525. foreach ($features as $v) {
  7526. if (isset($typeclass[$v])) {
  7527. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7528. $pm[$typeclass[$v]['classid']] = $zh[0];
  7529. }
  7530. if (isset($typeclass[$v])) {
  7531. if (isset($jm[$typeclass[$v]['classid']])) {
  7532. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7533. }
  7534. }
  7535. }
  7536. $zh = implode(" ", $pm);
  7537. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7538. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7539. $rows_r[$key]['zh'] = $zh;
  7540. $jm = array_filter($jm);
  7541. $rows_r[$key]['features'] = implode("-", $jm);
  7542. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7543. }
  7544. $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');
  7545. foreach ($rows_c as $key => $value) {
  7546. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7547. $pm = $classid;
  7548. $jm = $classid;
  7549. $rows_c[$key]['time'] = $value['outk'];
  7550. $rows_c[$key]['outk'] = '出库';
  7551. if ($value['cktype'] == 1) {
  7552. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7553. } else if ($value['cktype'] == 2) {
  7554. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7555. } else if ($value['cktype'] == 3) {
  7556. $rows_c[$key]['cktype'] = '盘亏调整';
  7557. } else if ($value['cktype'] == 4) {
  7558. $rows_c[$key]['cktype'] = '其他调整出库';
  7559. } else if ($value['cktype'] == 5) {
  7560. $rows_c[$key]['cktype'] = '形态转换出库';
  7561. } else {
  7562. $rows_c[$key]['cktype'] = '';
  7563. }
  7564. unset($rows_c[$key]['state']);
  7565. $features = explode('-', trim($value['features'], '-'));
  7566. foreach ($features as $v) {
  7567. if (isset($typeclass[$v])) {
  7568. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7569. $pm[$typeclass[$v]['classid']] = $zh[0];
  7570. }
  7571. if (isset($typeclass[$v])) {
  7572. if (isset($jm[$typeclass[$v]['classid']])) {
  7573. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7574. }
  7575. }
  7576. }
  7577. $zh = implode(" ", $pm);
  7578. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7579. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7580. $rows_c[$key]['zh'] = $zh;
  7581. $jm = array_filter($jm);
  7582. $rows_c[$key]['features'] = implode("-", $jm);
  7583. $rows_c[$key]['number'] = 1;
  7584. }
  7585. $merged = $rows_r;
  7586. foreach ($rows_c as $key => $value) {
  7587. if (isset($merged[$key])) {
  7588. $merged[] = $value;
  7589. } else {
  7590. $merged[$key] = $value;
  7591. }
  7592. }
  7593. usort($merged, function ($a, $b) {
  7594. return $a['time'] - $b['time'];
  7595. });
  7596. foreach ($merged as $key => $value) {
  7597. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7598. }
  7599. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7600. $titlename = "<table border=1>
  7601. <tr align='center'>
  7602. <td>仓库</td>
  7603. <td>SKU</td>
  7604. <td>商品名称</td>
  7605. <td>仓库品名</td>
  7606. <td>料号</td>
  7607. <td>时间</td>
  7608. <td>操作</td>
  7609. <td>类型</td>
  7610. <td>数量</td>
  7611. <td>备注</td>
  7612. </tr>
  7613. </table>";
  7614. $filename = $title . ".xlsx";
  7615. $tail = "";
  7616. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7617. }
  7618. }
  7619. /*************************************处理exceljs导出****************************************************/
  7620. public function _excelrjs(){
  7621. if (isset($_GET['excel'])) {
  7622. $category = $this->input->get('category', true);
  7623. $size = $this->input->get('size', true);
  7624. $grade = $this->input->get('grade', true);
  7625. $color = $this->input->get('color', true);
  7626. $lowe = $this->input->get('lowe', true);
  7627. $sku = $this->input->get('sku', true);
  7628. $warehouse = $this->input->get('warehouse', true);
  7629. $purchase = $this->input->get('purchase', true);
  7630. $ktime = $this->input->get('ktime', true);
  7631. $jtime = $this->input->get('jtime', true);
  7632. $ktime = strtotime($ktime);
  7633. $jtime = strtotime($jtime);
  7634. $where = "1=1";
  7635. $gj = "";
  7636. $ck = "";
  7637. if ($category) {
  7638. $where .= " and features like '%-$category-%'";
  7639. }
  7640. if ($size) {
  7641. $where .= " and features like '%-$size-%'";
  7642. }
  7643. if ($grade) {
  7644. $where .= " and features like '%-$grade-%'";
  7645. }
  7646. if ($color) {
  7647. $where .= " and features like '%-$color-%'";
  7648. }
  7649. if ($lowe) {
  7650. $where .= " and features like '%-$lowe-%'";
  7651. }
  7652. if ($warehouse) {
  7653. $where .= " and warehouse = '$warehouse'";
  7654. }
  7655. if ($purchase) {
  7656. $where .= " and purchase = '$purchase'";
  7657. }
  7658. if ($sku) {
  7659. $where .= " and sku = '$sku'";
  7660. }
  7661. if ($ktime && $jtime) {
  7662. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7663. }
  7664. //数据排序
  7665. $order_str = "id desc";
  7666. if (empty($page)) {
  7667. $start = 0;
  7668. $perpage = 1;
  7669. } else {
  7670. $start = ($page - 1) * $perpage;
  7671. }
  7672. $list = array();
  7673. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7674. foreach ($rows as $value) {
  7675. $ck = $this->warehouse->read($value['warehouse']);
  7676. $warehouse = $ck['title'];
  7677. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7678. $retreatwarehouse = $tkck['title'];
  7679. $gy = $this->purchase->read($value['purchase']);
  7680. $purchase = $gy['title'];
  7681. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7682. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7683. }
  7684. if(empty($list)){
  7685. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7686. }else{
  7687. $final_list = [];
  7688. foreach($list as $v){
  7689. $final_list[] = array_values($v);
  7690. }
  7691. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7692. array_unshift($final_list,[
  7693. "仓库","SKU","商品名称","时间","数量"
  7694. ]);
  7695. array_unshift($final_list,[
  7696. $title,"","","",""
  7697. ]);
  7698. $merges = [
  7699. [
  7700. "s"=>["r"=>0,"c"=>0],
  7701. "e"=>["r"=>0,"c"=>4]
  7702. ]
  7703. ];
  7704. $cols = [
  7705. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7706. ];
  7707. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7708. }
  7709. }
  7710. }
  7711. //出库、退库导出
  7712. public function _excelctjs()
  7713. {
  7714. $classid = $this->classid->sku();
  7715. $pm = $classid;
  7716. $typeclass = array();
  7717. $tc = $this->typeclass->find_all();
  7718. foreach ($tc as $v) {
  7719. $typeclass[$v['id']] = $v;
  7720. }
  7721. $prc = array();
  7722. $purchase = $this->purchase->find_all();
  7723. foreach ($purchase as $k => $v) {
  7724. $prc[$v['id']] = $v['title'];
  7725. }
  7726. if (isset($_GET['excel'])) {
  7727. $wh = array();
  7728. $w = $this->warehouse->find_all('1=1', 'id,title');
  7729. foreach ($w as $v) {
  7730. $wh[$v['id']] = $v['title'];
  7731. }
  7732. $type = $this->input->get('excel', true);
  7733. $category = $this->input->get('category', true);
  7734. $size = $this->input->get('size', true);
  7735. $grade = $this->input->get('grade', true);
  7736. $color = $this->input->get('color', true);
  7737. $lowe = $this->input->get('lowe', true);
  7738. $sku = $this->input->get('sku', true);
  7739. $title = $this->input->get('title', true);
  7740. $warehouse = $this->input->get('warehouse', true);
  7741. $purchase = $this->input->get('purchase', true);
  7742. $lacetype = $this->input->get('lacetype', true);
  7743. $haircap = $this->input->get('haircap', true);
  7744. $lacecolor = $this->input->get('lacecolor', true);
  7745. $density = $this->input->get('density', true);
  7746. $details = $this->input->get('details', true);
  7747. $state = $this->input->get('state', true);
  7748. $shop = $this->input->get('shop', true);
  7749. $hairnumber = $this->input->get('hairnumber', true);
  7750. $type_leixi = $this->input->get('type', true);
  7751. $cpbz = $this->input->get('cpbz', true);
  7752. $sm = $this->input->get('sm', true);
  7753. $sid = $this->input->get('sid', true);
  7754. $ktime = $this->input->get('ktime', true);
  7755. $jtime = $this->input->get('jtime', true);
  7756. $ktime = strtotime($ktime);
  7757. $jtime = strtotime($jtime);
  7758. //$where = " 1=1 ";
  7759. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7760. $where = " sku != '' ";
  7761. $gj = "";
  7762. $ck = "";
  7763. if ($category) {
  7764. $where .= " and features like '%-$category-%'";
  7765. }
  7766. if ($size) {
  7767. $where .= " and features like '%-$size-%'";
  7768. }
  7769. if ($grade) {
  7770. $where .= " and features like '%-$grade-%'";
  7771. }
  7772. if ($color) {
  7773. $where .= " and features like '%-$color-%'";
  7774. }
  7775. if ($lowe) {
  7776. $where .= " and features like '%-$lowe-%'";
  7777. }
  7778. if ($warehouse) {
  7779. $where .= " and warehouse = '$warehouse'";
  7780. }
  7781. if ($purchase) {
  7782. $where .= " and purchase = '$purchase'";
  7783. }
  7784. if ($state) {
  7785. $where .= " and state = '$state'";
  7786. }
  7787. if ($lacetype) {
  7788. $where .= " and features like '%-$lacetype-%'";
  7789. }
  7790. if ($lacecolor) {
  7791. $where .= " and features like '%-$lacecolor-%'";
  7792. }
  7793. if ($density) {
  7794. $where .= " and features like '%-$density-%'";
  7795. }
  7796. if ($haircap) {
  7797. $where .= " and features like '%-$haircap-%'";
  7798. }
  7799. if ($details) {
  7800. $where .= " and details = '$details'";
  7801. }
  7802. if ($shop) {
  7803. $where .= " and shop like '%$shop%'";
  7804. }
  7805. if ($title) {
  7806. $title = trim($title, ' ');
  7807. $title = trim($title, ' ');
  7808. $where .= " and title like '%$title%'";
  7809. }
  7810. if (!empty($hairnumber)) {
  7811. $where .= " and features like '%-128-%' ";
  7812. if ($hairnumber < 0) {
  7813. $class_list = $this->typeclass->find_all('classid = 43');
  7814. foreach ($class_list as $v) {
  7815. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7816. }
  7817. } else {
  7818. $where .= " and features like '%-$hairnumber-%'";
  7819. }
  7820. }
  7821. if ($type_leixi) {
  7822. $where .= " and type = '$type_leixi'";
  7823. }
  7824. if ($cpbz) {
  7825. $where .= " and cpbz like '%$cpbz%' ";
  7826. }
  7827. if ($sm) {
  7828. $where .= " and sm like '%$sm%' ";
  7829. }
  7830. if ($sku) {
  7831. $sku = trim($sku, ' ');
  7832. $sku = trim($sku, ' ');
  7833. $where .= " and sku like '%$sku%'";
  7834. }
  7835. if ($ktime && $jtime) {
  7836. if ($type == 1) {
  7837. $tl = '出库';
  7838. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7839. } else if ($type == 2) {
  7840. $tl = '退库';
  7841. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7842. } else if ($type == 3) {
  7843. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7844. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7845. } else if ($type == 4) {
  7846. $tl = '出库+零售';
  7847. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7848. } else if ($type == 5) {
  7849. $tl = '零售';
  7850. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7851. }
  7852. }
  7853. $sidwhere = '';
  7854. if ($sid) {
  7855. $sd = "";
  7856. $s = explode(',', trim($sid, ','));
  7857. foreach ($s as $value) {
  7858. $sd .= " id = " . $value . " or";
  7859. }
  7860. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7861. }
  7862. //数据排序
  7863. $order_str = "time desc";
  7864. if (empty($page)) {
  7865. $start = 0;
  7866. $perpage = 1;
  7867. } else {
  7868. $start = ($page - 1) * $perpage;
  7869. }
  7870. //取得信息列表
  7871. if ($type != 3 && $type != 5) {
  7872. if ($type == 1 || $type == 4) {
  7873. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,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. $final_list = [];
  7904. foreach($info_list as $k=>$v){
  7905. $number = "";
  7906. if(!empty($v['orderinfo'])){
  7907. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7908. if(!empty($tmp_info['number'])){
  7909. $number = $tmp_info['number'];
  7910. }
  7911. }
  7912. $final_list[] = [
  7913. 'warehouse'=>$v['warehouse'],
  7914. 'purchase'=>$v['purchase'],
  7915. 'sku'=>$v['sku'],
  7916. 'title'=>$v['title'],
  7917. 'features'=>$v['features'],
  7918. 'label'=>$v['label'],
  7919. 'orderinfo'=>$v['orderinfo'],
  7920. 'number'=>$number,
  7921. 'waybill'=>$v['waybill'],
  7922. 'outk'=>$v['outk'],
  7923. ];
  7924. }
  7925. } else {
  7926. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7927. foreach ($info_list as $key => $value) {
  7928. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7929. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7930. $warehouse = $this->warehouse->read($value['warehouse']);
  7931. $info_list[$key]['warehouse'] = $warehouse['title'];
  7932. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7933. $features = explode('-', trim($features, '-'));
  7934. $pm = $classid;
  7935. foreach ($features as $k => $v) {
  7936. if ($v != 0) {
  7937. if (!isset($typeclass[$v])) {
  7938. continue;
  7939. }
  7940. if (isset($pm[$typeclass[$v]['classid']])) {
  7941. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7942. $tz = explode('|', $typeclass[$v]['zh']);
  7943. $pm[$typeclass[$v]['classid']] = $tz[0];
  7944. } else {
  7945. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7946. }
  7947. }
  7948. }
  7949. }
  7950. $zh = implode(" ", $pm);
  7951. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7952. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7953. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7954. $info_list[$key]['features'] = $zh;
  7955. }
  7956. $final_list = [];
  7957. foreach($info_list as $k=>$v){
  7958. $number = "";
  7959. if(!empty($v['orderinfo'])){
  7960. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7961. if(!empty($tmp_info['number'])){
  7962. $number = $tmp_info['number'];
  7963. }
  7964. }
  7965. $final_list[] = [
  7966. 'warehouse'=>$v['warehouse'],
  7967. 'purchase'=>$v['purchase'],
  7968. 'sku'=>$v['sku'],
  7969. 'title'=>$v['title'],
  7970. 'features'=>$v['features'],
  7971. 'label'=>$v['label'],
  7972. 'orderinfo'=>$v['orderinfo'],
  7973. 'number'=>$number,
  7974. 'waybill'=>$v['waybill'],
  7975. 'retreat'=>$v['retreat'],
  7976. ];
  7977. }
  7978. }
  7979. if(empty($final_list)){
  7980. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7981. }else{
  7982. $end_list = [];
  7983. foreach($final_list as $v){
  7984. $end_list[] = array_values($v);
  7985. }
  7986. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  7987. array_unshift($end_list,[
  7988. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  7989. ]);
  7990. array_unshift($end_list,[
  7991. $title,"","","","","","","","",""
  7992. ]);
  7993. $merges = [
  7994. [
  7995. "s"=>["r"=>0,"c"=>0],
  7996. "e"=>["r"=>0,"c"=>9]
  7997. ]
  7998. ];
  7999. $cols = [
  8000. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8001. ];
  8002. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8003. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8004. ] )));
  8005. }
  8006. } else if ($type == 5) {
  8007. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8008. foreach ($info_list as $key => $value) {
  8009. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8010. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8011. $warehouse = $this->warehouse->read($value['warehouse']);
  8012. $info_list[$key]['warehouse'] = $warehouse['title'];
  8013. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8014. $features = explode('-', trim($features, '-'));
  8015. $pm = $classid;
  8016. foreach ($features as $k => $v) {
  8017. if ($v != 0) {
  8018. if (!isset($typeclass[$v])) {
  8019. continue;
  8020. }
  8021. if (isset($pm[$typeclass[$v]['classid']])) {
  8022. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8023. $tz = explode('|', $typeclass[$v]['zh']);
  8024. $pm[$typeclass[$v]['classid']] = $tz[0];
  8025. } else {
  8026. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8027. }
  8028. }
  8029. }
  8030. }
  8031. $zh = implode(" ", $pm);
  8032. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8033. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8034. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8035. $info_list[$key]['features'] = $zh;
  8036. }
  8037. if(empty($info_list)){
  8038. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8039. }else{
  8040. $final_list = [];
  8041. foreach($info_list as $v){
  8042. $final_list[] = array_values($v);
  8043. }
  8044. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8045. array_unshift($final_list,[
  8046. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8047. ]);
  8048. array_unshift($final_list,[
  8049. $title,"","","","","","",
  8050. ]);
  8051. $merges = [
  8052. [
  8053. "s"=>["r"=>0,"c"=>0],
  8054. "e"=>["r"=>0,"c"=>6]
  8055. ]
  8056. ];
  8057. $cols = [
  8058. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8059. ];
  8060. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8061. }
  8062. } else {
  8063. $wh = array();
  8064. $w = $this->warehouse->find_all('1=1', 'id,title');
  8065. foreach ($w as $v) {
  8066. $wh[$v['id']] = $v['title'];
  8067. }
  8068. $wt = array();
  8069. $whlabel_type = $this->whlabel_type->find_all();
  8070. foreach ($whlabel_type as $v) {
  8071. $wt[$v['id']] = $v['title'];
  8072. }
  8073. $classid = $this->classid->sku();
  8074. $list = array();
  8075. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8076. foreach ($rows as $key => $value) {
  8077. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8078. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8079. $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');
  8080. $details = array();
  8081. $cpid = array();
  8082. $cpbz = array();
  8083. $c = 0;
  8084. $g = 0;
  8085. $x = 0;
  8086. $t = 0;
  8087. $s = 0;
  8088. $q = 0;
  8089. foreach ($sd as $k => $v) {
  8090. if ($v['state'] == 0) {
  8091. $c++;
  8092. }
  8093. if ($v['state'] != 9) {
  8094. $g++;
  8095. }
  8096. if ($v['outk'] > 1) {
  8097. $x++;
  8098. }
  8099. if ($v['retreat'] > 0) {
  8100. $t++;
  8101. }
  8102. if ($v['state'] == 8) {
  8103. $s++;
  8104. }
  8105. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8106. $q++;
  8107. }
  8108. $details[$v['details']] = $v['details'];
  8109. if ($v['cpid'] != 0) {
  8110. $cpid[$v['cpid']] = $v['cpid'];
  8111. }
  8112. if ($v['cpbz'] != '') {
  8113. $cpbz[$v['cpbz']] = $v['cpbz'];
  8114. }
  8115. }
  8116. if (isset($wt[$value['type']])) {
  8117. $rows[$key]['type'] = $wt[$value['type']];
  8118. } else {
  8119. $rows[$key]['type'] = '未设置';
  8120. }
  8121. $rows[$key]['details'] = implode("、", $details);
  8122. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8123. $ftime = time() - 15 * 24 * 3600;
  8124. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8125. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8126. $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);
  8127. $rows[$key]['c'] = $c;
  8128. $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);
  8129. $rows[$key]['t'] = $t;
  8130. $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'] . '"');
  8131. $rows[$key]['z'] = $z;
  8132. // $jm = $classid;
  8133. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8134. $features = explode('-', trim($features, '-'));
  8135. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8136. }
  8137. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8138. $final_list =[];
  8139. foreach($tmp_list as $k=>$v){
  8140. $final_list[] = [
  8141. "warehouse"=>$v['warehouse'],
  8142. "purchase"=>$v['purchase'],
  8143. "details"=>$v['details'],
  8144. "cpid"=>$v['cpid'],
  8145. "sku"=>$v['sku'],
  8146. "title"=>$v['title'],
  8147. "features"=>$v['pm'],
  8148. "cpbz"=>$v['cpbz'],
  8149. "sm"=>$v['sm'],
  8150. "type"=>$v['type'],
  8151. "g"=>$v["g"],
  8152. "c"=>$v["c"],
  8153. "x"=>$v["x"],
  8154. "t"=>$v["t"],
  8155. "z"=>$v["z"],
  8156. "jm"=>$v["jm"],
  8157. "weight"=>$v["weight"],
  8158. "asd"=>$v["asd"],
  8159. ];
  8160. }
  8161. if(empty($final_list)){
  8162. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8163. }else{
  8164. $end_list = [];
  8165. foreach($final_list as $v){
  8166. $end_list[] = array_values($v);
  8167. }
  8168. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8169. array_unshift($end_list,[
  8170. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8171. ]);
  8172. array_unshift($end_list,[
  8173. $title,"","","","","","","","","","","","","","","","","",""
  8174. ]);
  8175. $merges = [
  8176. [
  8177. "s"=>["r"=>0,"c"=>0],
  8178. "e"=>["r"=>0,"c"=>6]
  8179. ]
  8180. ];
  8181. $cols = [
  8182. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8183. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8184. ];
  8185. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8186. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8187. ])));
  8188. }
  8189. }
  8190. }
  8191. }
  8192. public function _exceljxcjs(){
  8193. $classid = $this->classid->sku();
  8194. $pm = $classid;
  8195. $typeclass = array();
  8196. $tc = $this->typeclass->find_all();
  8197. foreach ($tc as $v) {
  8198. $typeclass[$v['id']] = $v;
  8199. }
  8200. $prc = array();
  8201. $purchase = $this->purchase->find_all();
  8202. foreach ($purchase as $k => $v) {
  8203. $prc[$v['id']] = $v['title'];
  8204. }
  8205. if(!isset($_GET['excel'])){
  8206. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8207. }
  8208. $where = "sku != 'Preset'";
  8209. //数据排序
  8210. $order_str = "id desc";
  8211. if (empty($page)) {
  8212. $start = 0;
  8213. $perpage = 1;
  8214. } else {
  8215. $start = ($page - 1) * $perpage;
  8216. }
  8217. $category = $this->input->get('category', true);
  8218. $warehouse = $this->input->get('warehouse', true);
  8219. $excelid = $this->input->get('sid', true);
  8220. if ($category) {
  8221. $where .= " and features like '%-$category-%'";
  8222. }
  8223. if ($warehouse) {
  8224. $where .= " and warehouse = '$warehouse'";
  8225. }
  8226. $xzid = '';
  8227. if ($excelid) {
  8228. $excelid = explode(',', trim($excelid, ','));
  8229. foreach ($excelid as $key => $value) {
  8230. $xzid .= " id = " . $value . " or";
  8231. }
  8232. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8233. }
  8234. $wt = array();
  8235. $whlabel_type = $this->whlabel_type->find_all();
  8236. foreach ($whlabel_type as $v) {
  8237. $wt[$v['id']] = $v['title'];
  8238. }
  8239. $wh = array();
  8240. $w = $this->warehouse->find_all('1=1', 'id,title');
  8241. foreach ($w as $v) {
  8242. $wh[$v['id']] = $v['title'];
  8243. }
  8244. $list = array();
  8245. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8246. foreach ($rows as $key => $value) {
  8247. if (isset($wt[$value['type']])) {
  8248. $rows[$key]['type'] = $wt[$value['type']];
  8249. } else {
  8250. $rows[$key]['type'] = '未设置';
  8251. }
  8252. $bm = '03';
  8253. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8254. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8255. $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');
  8256. $details = array();
  8257. $cpid = array();
  8258. $cpbz = array();
  8259. $c = 0;
  8260. $g = 0;
  8261. $x = 0;
  8262. $t = 0;
  8263. $s = 0;
  8264. $q = 0;
  8265. foreach ($sd as $k => $v) {
  8266. if ($v['state'] == 0) {
  8267. $c++;
  8268. if ($v['cpid'] != 0) {
  8269. $cpid[$v['cpid']] = $v['cpid'];
  8270. }
  8271. if ($v['cpbz'] != '') {
  8272. $cpbz[$v['cpbz']] = $v['cpbz'];
  8273. }
  8274. }
  8275. if ($v['state'] != 9) {
  8276. $g++;
  8277. }
  8278. if ($v['state'] == 1) {
  8279. $x++;
  8280. }
  8281. if ($v['state'] == 2) {
  8282. $t++;
  8283. }
  8284. if ($v['state'] == 8) {
  8285. $s++;
  8286. }
  8287. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8288. $q++;
  8289. }
  8290. $details[$v['details']] = $v['details'];
  8291. }
  8292. $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'] . '"');
  8293. $rows[$key]['details'] = implode("、", $details);
  8294. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8295. $number = $value['number'];
  8296. $ftime = time() - 15 * 24 * 3600;
  8297. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8298. $rows[$key]['number'] = $g;
  8299. $rows[$key]['c'] = $c;
  8300. $rows[$key]['x'] = $x;
  8301. $rows[$key]['t'] = $t;
  8302. $rows[$key]['s'] = $s;
  8303. $rows[$key]['q'] = $q;
  8304. $rows[$key]['z'] = $z;
  8305. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8306. $features = explode('-', trim($features, '-'));
  8307. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8308. }
  8309. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8310. $final_list = [];
  8311. foreach ($list as $k => $v) {
  8312. if (empty($v['sku'])) {
  8313. continue;
  8314. }
  8315. $final_list[] = [
  8316. $v["warehouse"],
  8317. $v["purchase"],
  8318. $v["details"],
  8319. $v["cpid"],
  8320. $v["dbcontent"],
  8321. $v["sku"],
  8322. $v["bm"],
  8323. $v["jm"],
  8324. $v["title"],
  8325. $v["pm"],
  8326. $v["cpbz"],
  8327. $v["sm"],
  8328. $v["type"],
  8329. $v["number"],
  8330. $v["c"],
  8331. $v["x"],
  8332. $v["t"],
  8333. $v["s"],
  8334. $v["q"],
  8335. $v["z"],
  8336. $v['weight'],
  8337. ];
  8338. }
  8339. if(empty($final_list)){
  8340. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8341. }
  8342. $title = "总进销存统计表";
  8343. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8344. $merges = [
  8345. [
  8346. "s"=>["r"=>0,"c"=>0],
  8347. "e"=>["r"=>0,"c"=>21]
  8348. ]
  8349. ];
  8350. $cols = [
  8351. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8352. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8353. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8354. ];
  8355. array_unshift($final_list, $first_row);
  8356. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8357. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8358. }
  8359. public function _summaryjs($arg_array)
  8360. {
  8361. $prc = array();
  8362. $purchase = $this->purchase->find_all();
  8363. foreach ($purchase as $k => $v) {
  8364. $prc[$v['id']] = $v['title'];
  8365. }
  8366. if (isset($_GET['excel'])) {
  8367. $ktime = $this->input->get('ktime', true);
  8368. $jtime = $this->input->get('jtime', true);
  8369. $ktime = strtotime($ktime);
  8370. $jtime = strtotime($jtime);
  8371. $where = "1=1";
  8372. if ($ktime && $jtime) {
  8373. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8374. }
  8375. //数据排序
  8376. $order_str = "time desc";
  8377. if (empty($page)) {
  8378. $start = 0;
  8379. $perpage = 1;
  8380. } else {
  8381. $start = ($page - 1) * $perpage;
  8382. }
  8383. //取得信息列表
  8384. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8385. foreach ($info_list as $key => $value) {
  8386. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8387. $warehouse = $this->warehouse->read($value['warehouse']);
  8388. $info_list[$key]['warehouse'] = $warehouse['title'];
  8389. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8390. $details = array();
  8391. $cpid = array();
  8392. foreach ($x as $k => $v) {
  8393. if ($v['details'] != '') {
  8394. $details[$v['details']] = $v['details'];
  8395. }
  8396. if ($v['cpid'] != 0) {
  8397. $cpid[$v['cpid']] = $v['cpid'];
  8398. }
  8399. }
  8400. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8401. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8402. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8403. $info_list[$key]['s'] = $s;
  8404. $info_list[$key]['x'] = count($x);
  8405. }
  8406. if(empty($info_list)){
  8407. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8408. }
  8409. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8410. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8411. $merges = [
  8412. [
  8413. "s"=>["r"=>0,"c"=>0],
  8414. "e"=>["r"=>0,"c"=>7]
  8415. ]
  8416. ];
  8417. $cols = [
  8418. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8419. ];
  8420. $final_list = [];
  8421. foreach($info_list as $k => $v){
  8422. $final_list[] = array_values($v);
  8423. }
  8424. array_unshift($final_list, $first_row);
  8425. array_unshift($final_list,[
  8426. $title,"","","","","","","","",
  8427. ]);
  8428. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8429. $titlename = "<table border=1>
  8430. <tr align='center'>
  8431. <td>仓库</td>
  8432. <td>供应商</td>
  8433. <td>出库位置</td>
  8434. <td>出库编码</td>
  8435. <td>SKU</td>
  8436. <td>产品名</td>
  8437. <td>总剩余库存</td>
  8438. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8439. </tr>
  8440. </table>";
  8441. $filename = $title . ".xls";
  8442. $tail = "";
  8443. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8444. }
  8445. }
  8446. public function _uckjs()
  8447. {
  8448. if (isset($_GET['excel'])) {
  8449. $tc = array();
  8450. $typeclass = $this->typeclass->find_all();
  8451. foreach ($typeclass as $v) {
  8452. $tc[$v['id']] = $v['zh'];
  8453. }
  8454. $first_row = [
  8455. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8456. ];
  8457. $t = array();
  8458. $rq = '';
  8459. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8460. $ts = $ts / (24 * 3600);
  8461. for ($i = 0; $i < $ts; $i++) {
  8462. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8463. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8464. }
  8465. $day_len = count($t);
  8466. $first_row[] = "本月出库";
  8467. $merges = [
  8468. ];
  8469. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8470. $excel_key = 1;
  8471. $final_list = [];
  8472. foreach ($info_list as $k => $v) {
  8473. $features = explode('-', trim($v['features'], '-'));
  8474. if (!isset($features[3]) || !isset($features[4])) {
  8475. continue;
  8476. }
  8477. $tmp = [];
  8478. $tmp[0] = $tc[$features[0]]; //类型
  8479. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8480. $tmp[2] = $tc[$features[4]]; //曲度
  8481. $tmp[3] = '';
  8482. if (isset($data[$k][1])) {
  8483. $tmp[3] .=$tmp[1];
  8484. }
  8485. if (isset($data[$k][2])) {
  8486. $tmp[3] .= $tmp[2];
  8487. }
  8488. if (isset($features[5])) {
  8489. $tmp[3] .= $tc[$features[5]];
  8490. }
  8491. if (isset($features[2])) {
  8492. $tmp[3] .= $tc[$features[2]];
  8493. }
  8494. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8495. $tmp[4] = $v['sku'];
  8496. $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())) . '))'); //月初库存
  8497. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8498. $tmp[7] ="";
  8499. $tmp[8] ="";
  8500. $byck = 0;
  8501. foreach ($t as $vv) {
  8502. $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));
  8503. $tmp[] = ($sl > 0) ? $sl : '';
  8504. $byck += $sl;
  8505. }
  8506. $tmp[] = ($byck > 0) ? $byck : '';
  8507. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8508. // $ztrq = '';
  8509. // $ztsl = '';
  8510. // if (count($zt) > 0) {
  8511. // foreach ($zt as $vv) {
  8512. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8513. // $ztsl .= $vv['num'] . '<br>';
  8514. // }
  8515. // }
  8516. if(empty($zt)){
  8517. $final_list[] = $tmp;
  8518. $excel_key = $excel_key + 1;
  8519. }else{
  8520. $len = count($zt);
  8521. if($len == 1){
  8522. $tmp[7] = $zt[0]['num'] ;
  8523. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8524. $final_list[] = $tmp;
  8525. $excel_key = $excel_key + 1;
  8526. }else{
  8527. foreach($zt as $vv){
  8528. $tmp[7] = "";
  8529. $tmp[8] = "";
  8530. $tmp[7] = $vv['num'];
  8531. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8532. $final_list[] = $tmp;
  8533. }
  8534. $merges[] = [
  8535. "s"=>["r"=>$excel_key,"c"=>0],
  8536. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8537. ];
  8538. $merges[] = [
  8539. "s"=>["r"=>$excel_key,"c"=>1],
  8540. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8541. ];
  8542. $merges[] = [
  8543. "s"=>["r"=>$excel_key,"c"=>2],
  8544. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8545. ];
  8546. $merges[] = [
  8547. "s"=>["r"=>$excel_key,"c"=>3],
  8548. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8549. ];
  8550. $merges[] = [
  8551. "s"=>["r"=>$excel_key,"c"=>4],
  8552. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8553. ];
  8554. $merges[] = [
  8555. "s"=>["r"=>$excel_key,"c"=>5],
  8556. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8557. ];
  8558. $merges[] = [
  8559. "s"=>["r"=>$excel_key,"c"=>6],
  8560. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8561. ];
  8562. for($i=1;$i<=$day_len;$i++){
  8563. $merges[] = [
  8564. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8565. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8566. ];
  8567. }
  8568. $merges[] = [
  8569. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8570. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8571. ];
  8572. $excel_key = $excel_key + $len;
  8573. }
  8574. }
  8575. }
  8576. $title = "详情 " . date("Y-m-d", time());
  8577. if(empty($final_list)){
  8578. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8579. }
  8580. $cols = [
  8581. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8582. ];
  8583. array_unshift($final_list, $first_row);
  8584. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8585. }
  8586. }
  8587. public function _whlabelexcelzhjs(){
  8588. if(empty($_GET['excel'])){
  8589. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8590. }
  8591. $where = "sku != 'Preset' and sku != '' ";
  8592. //数据排序
  8593. $order_str = "id desc";
  8594. if (empty($page)) {
  8595. $start = 0;
  8596. $perpage = 1;
  8597. } else {
  8598. $start = ($page - 1) * $perpage;
  8599. }
  8600. $category = $this->input->get('category', true);
  8601. $warehouse = $this->input->get('warehouse', true);
  8602. $excelid = $this->input->get('sid', true);
  8603. if ($category) {
  8604. $where .= " and features like '%-$category-%'";
  8605. }
  8606. if ($warehouse) {
  8607. $where .= " and warehouse = '$warehouse'";
  8608. }
  8609. $xzid = '';
  8610. if ($excelid) {
  8611. $excelid = explode(',', trim($excelid, ','));
  8612. foreach ($excelid as $key => $value) {
  8613. $xzid .= " id = " . $value . " or";
  8614. }
  8615. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8616. }
  8617. $merges = [
  8618. [
  8619. "s"=>["r"=>0,"c"=>0],
  8620. "e"=>["r"=>0,"c"=>6]
  8621. ]
  8622. ];
  8623. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8624. $excel_index = 2;
  8625. $final_list = [];
  8626. foreach ($rows as $key => $value) {
  8627. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8628. $zh = '';
  8629. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8630. // foreach ($zt_list as $v) {
  8631. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8632. // }
  8633. $zt = array_sum(array_column($zt_list, 'num'));
  8634. $number = $value['number'];
  8635. $ftime = time() - 15 * 24 * 3600;
  8636. $warehouse = $this->warehouse->read($value['warehouse']);
  8637. // $rows[$key]['warehouse'] = $warehouse['title'];
  8638. // $rows[$key]['number'] = $c;
  8639. // $rows[$key]['features'] = $zh;
  8640. //$rows[$key]['hb'] = $c + $zt;
  8641. $tmp = [];
  8642. $tmp[0] = $warehouse['title'];
  8643. $tmp[1] = $value['sku'];
  8644. $tmp[2] = $value['title'];
  8645. $tmp[3] = $c;
  8646. $tmp[4] = "";
  8647. $tmp[5] = $c + $zt;
  8648. if(empty($zt_list)){
  8649. $tmp[4] = "";
  8650. $final_list[] = $tmp;
  8651. $excel_index = $excel_index + 1;
  8652. }else{
  8653. if(count($zt_list) == 1){
  8654. $tmp[4] = "";
  8655. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8656. $final_list[] = $tmp;
  8657. $excel_index = $excel_index + 1;
  8658. }else{
  8659. $len = count($zt_list);
  8660. foreach ($zt_list as $v){
  8661. $tmp[4] = "";
  8662. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8663. $final_list[] = $tmp;
  8664. }
  8665. $merges[] = [
  8666. "s"=>["r"=>$excel_index,"c"=>0],
  8667. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8668. ];
  8669. $merges[] = [
  8670. "s"=>["r"=>$excel_index,"c"=>1],
  8671. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8672. ];
  8673. $merges[] = [
  8674. "s"=>["r"=>$excel_index,"c"=>2],
  8675. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8676. ];
  8677. $merges[] = [
  8678. "s"=>["r"=>$excel_index,"c"=>3],
  8679. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8680. ];
  8681. $merges[] = [
  8682. "s"=>["r"=>$excel_index,"c"=>5],
  8683. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8684. ];
  8685. $excel_index = $excel_index + $len;
  8686. }
  8687. }
  8688. }
  8689. $first_row = [
  8690. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8691. ];
  8692. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8693. if(empty($final_list)){
  8694. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8695. }
  8696. $cols = [
  8697. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8698. ];
  8699. array_unshift($final_list, $first_row);
  8700. array_unshift($final_list, [
  8701. $title,"","","","",""
  8702. ]);
  8703. $end_list = [];
  8704. foreach ($final_list as $key => $value) {
  8705. $end_list[] = array_values($value);
  8706. }
  8707. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8708. }
  8709. //出库、退库导出
  8710. public function _dccrtypejs()
  8711. {
  8712. $classid = $this->classid->sku();
  8713. $pm = $classid;
  8714. $typeclass = array();
  8715. $tc = $this->typeclass->find_all();
  8716. foreach ($tc as $v) {
  8717. $typeclass[$v['id']] = $v;
  8718. }
  8719. $prc = array();
  8720. $purchase = $this->purchase->find_all();
  8721. foreach ($purchase as $k => $v) {
  8722. $prc[$v['id']] = $v['title'];
  8723. }
  8724. if (isset($_GET['sid'])) {
  8725. $wh = array();
  8726. $w = $this->warehouse->find_all('1=1', 'id,title');
  8727. foreach ($w as $v) {
  8728. $wh[$v['id']] = $v['title'];
  8729. }
  8730. $type = $this->input->get('excel', true);
  8731. $category = $this->input->get('category', true);
  8732. $size = $this->input->get('size', true);
  8733. $grade = $this->input->get('grade', true);
  8734. $color = $this->input->get('color', true);
  8735. $lowe = $this->input->get('lowe', true);
  8736. $sku = $this->input->get('sku', true);
  8737. $warehouse = $this->input->get('warehouse', true);
  8738. $lacetype = $this->input->get('lacetype', true);
  8739. $lacecolor = $this->input->get('lacecolor', true);
  8740. $density = $this->input->get('density', true);
  8741. $haircap = $this->input->get('haircap', true);
  8742. $purchase = $this->input->get('purchase', true);
  8743. $title = $this->input->get('title', true);
  8744. $state = $this->input->get('state', true);
  8745. $sid = $this->input->get('sid', true);
  8746. $ktime = $this->input->get('ktime', true);
  8747. $jtime = $this->input->get('jtime', true);
  8748. $ktime = strtotime($ktime);
  8749. $jtime = strtotime($jtime);
  8750. $where = "1=1";
  8751. $gj = "";
  8752. $ck = "";
  8753. if ($category) {
  8754. $where .= " and features like '%-$category-%'";
  8755. }
  8756. if ($size) {
  8757. $where .= " and features like '%-$size-%'";
  8758. }
  8759. if ($grade) {
  8760. $where .= " and features like '%-$grade-%'";
  8761. }
  8762. if ($color) {
  8763. $where .= " and features like '%-$color-%'";
  8764. }
  8765. if ($lowe) {
  8766. $where .= " and features like '%-$lowe-%'";
  8767. }
  8768. if ($warehouse) {
  8769. $where .= " and warehouse = '$warehouse'";
  8770. }
  8771. if ($purchase) {
  8772. $where .= " and purchase = '$purchase'";
  8773. }
  8774. if ($state) {
  8775. $where .= " and state = '$state'";
  8776. }
  8777. if ($lacetype) {
  8778. $where .= " and features like '%-$lacetype-%'";
  8779. }
  8780. if ($lacecolor) {
  8781. $where .= " and features like '%-$lacecolor-%'";
  8782. }
  8783. if ($density) {
  8784. $where .= " and features like '%-$density-%'";
  8785. }
  8786. if ($haircap) {
  8787. $where .= " and features like '%-$haircap-%'";
  8788. }
  8789. if ($title) {
  8790. $title = trim($title, ' ');
  8791. $title = trim($title, ' ');
  8792. $where .= " and title like '%$title%'";
  8793. }
  8794. if ($sku) {
  8795. $sku = trim($sku, ' ');
  8796. $sku = trim($sku, ' ');
  8797. $where .= " and sku like '%$sku%'";
  8798. }
  8799. if ($ktime && $jtime) {
  8800. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8801. }
  8802. $sidwhere = '';
  8803. if ($sid) {
  8804. $sd = "";
  8805. $s = explode(',', trim($sid, ','));
  8806. foreach ($s as $value) {
  8807. $sd .= " id = " . $value . " or";
  8808. }
  8809. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8810. }
  8811. //数据排序
  8812. $order_str = "time desc";
  8813. if (empty($page)) {
  8814. $start = 0;
  8815. $perpage = 1;
  8816. } else {
  8817. $start = ($page - 1) * $perpage;
  8818. }
  8819. $wh = array();
  8820. $w = $this->warehouse->find_all('1=1', 'id,title');
  8821. foreach ($w as $v) {
  8822. $wh[$v['id']] = $v['title'];
  8823. }
  8824. $wt = array();
  8825. $whlabel_type = $this->whlabel_type->find_all();
  8826. foreach ($whlabel_type as $v) {
  8827. $wt[$v['id']] = $v['title'];
  8828. }
  8829. $classid = $this->classid->sku();
  8830. $list = array();
  8831. $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');
  8832. foreach ($rows_r as $key => $value) {
  8833. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8834. $pm = $classid;
  8835. $jm = $classid;
  8836. $rows_r[$key]['enter'] = '入库';
  8837. $rows_r[$key]['time'] = $value['enter'];
  8838. if ($value['rktype'] == 1) {
  8839. $rows_r[$key]['rktype'] = '采购入库';
  8840. } else if ($value['rktype'] == 2) {
  8841. $rows_r[$key]['rktype'] = '盘盈调整';
  8842. } else if ($value['rktype'] == 3) {
  8843. $rows_r[$key]['rktype'] = '其他调整入库';
  8844. } else if ($value['rktype'] == 4) {
  8845. $rows_r[$key]['rktype'] = '其他调整入库';
  8846. } else if ($value['rktype'] == 5) {
  8847. $rows_r[$key]['rktype'] = '退库入库';
  8848. } else if ($value['rktype'] == 6) {
  8849. $rows_r[$key]['rktype'] = '退货可用入库';
  8850. } else if ($value['rktype'] == 7) {
  8851. $rows_r[$key]['rktype'] = '形态转换入库';
  8852. } else {
  8853. $rows_r[$key]['rktype'] = '';
  8854. }
  8855. $features = explode('-', trim($value['features'], '-'));
  8856. foreach ($features as $v) {
  8857. if (isset($typeclass[$v])) {
  8858. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8859. $pm[$typeclass[$v]['classid']] = $zh[0];
  8860. }
  8861. if (isset($typeclass[$v])) {
  8862. if (isset($jm[$typeclass[$v]['classid']])) {
  8863. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8864. }
  8865. }
  8866. }
  8867. $zh = implode(" ", $pm);
  8868. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8869. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8870. $rows_r[$key]['zh'] = $zh;
  8871. $jm = array_filter($jm);
  8872. $rows_r[$key]['features'] = implode("-", $jm);
  8873. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8874. }
  8875. $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');
  8876. foreach ($rows_c as $key => $value) {
  8877. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8878. $pm = $classid;
  8879. $jm = $classid;
  8880. $rows_c[$key]['time'] = $value['outk'];
  8881. $rows_c[$key]['outk'] = '出库';
  8882. if ($value['cktype'] == 1) {
  8883. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8884. } else if ($value['cktype'] == 2) {
  8885. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8886. } else if ($value['cktype'] == 3) {
  8887. $rows_c[$key]['cktype'] = '盘亏调整';
  8888. } else if ($value['cktype'] == 4) {
  8889. $rows_c[$key]['cktype'] = '其他调整出库';
  8890. } else if ($value['cktype'] == 5) {
  8891. $rows_c[$key]['cktype'] = '形态转换出库';
  8892. } else {
  8893. $rows_c[$key]['cktype'] = '';
  8894. }
  8895. unset($rows_c[$key]['state']);
  8896. $features = explode('-', trim($value['features'], '-'));
  8897. foreach ($features as $v) {
  8898. if (isset($typeclass[$v])) {
  8899. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8900. $pm[$typeclass[$v]['classid']] = $zh[0];
  8901. }
  8902. if (isset($typeclass[$v])) {
  8903. if (isset($jm[$typeclass[$v]['classid']])) {
  8904. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8905. }
  8906. }
  8907. }
  8908. $zh = implode(" ", $pm);
  8909. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8910. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8911. $rows_c[$key]['zh'] = $zh;
  8912. $jm = array_filter($jm);
  8913. $rows_c[$key]['features'] = implode("-", $jm);
  8914. $rows_c[$key]['number'] = 1;
  8915. }
  8916. $merged = $rows_r;
  8917. foreach ($rows_c as $key => $value) {
  8918. if (isset($merged[$key])) {
  8919. $merged[] = $value;
  8920. } else {
  8921. $merged[$key] = $value;
  8922. }
  8923. }
  8924. usort($merged, function ($a, $b) {
  8925. return $a['time'] - $b['time'];
  8926. });
  8927. foreach ($merged as $key => $value) {
  8928. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8929. }
  8930. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8931. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8932. $cols = [
  8933. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8934. ];
  8935. $final_list= [];
  8936. foreach($merged as $key => $value){
  8937. $final_list[] = array_values($value) ;
  8938. }
  8939. if(empty($merged)){
  8940. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8941. }
  8942. array_unshift($final_list, $first_row);
  8943. $end_list = [];
  8944. foreach ($final_list as $key => $value) {
  8945. $end_list[] = array_values($value);
  8946. }
  8947. $merges = [];
  8948. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8949. }
  8950. }
  8951. public function _errorexceljs()
  8952. {
  8953. $post = $this->input->post(NULL, TRUE);
  8954. if (isset($_GET['page'])) {
  8955. $page = $this->input->get('page', true);
  8956. $perpage = $this->input->get('perpage', true);
  8957. $sku = $this->input->get('sku', true);
  8958. $warehouse = $this->input->get('warehouse', true);
  8959. $ktime = $this->input->get('ktime', true);
  8960. $jtime = $this->input->get('jtime', true);
  8961. $ktime = strtotime($ktime);
  8962. $jtime = strtotime($jtime);
  8963. $where = "sku != 'Preset'";
  8964. $gj = '';
  8965. if ($sku) {
  8966. $where .= " and sku like '%$sku%'";
  8967. } else {
  8968. if ($ktime && $jtime) {
  8969. $gj = " and time > '$ktime' and time < '$jtime'";
  8970. }
  8971. }
  8972. if ($warehouse) {
  8973. $where .= " and warehouse = '$warehouse'";
  8974. }
  8975. //数据排序
  8976. $order_str = "id desc";
  8977. if (empty($page)) {
  8978. $start = 0;
  8979. $perpage = 1;
  8980. } else {
  8981. $start = ($page - 1) * $perpage;
  8982. }
  8983. //取得信息列表
  8984. $rows = array();
  8985. $list = array();
  8986. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  8987. foreach ($info_list as $value) {
  8988. $warehouse = $this->warehouse->read($value['warehouse']);
  8989. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  8990. $number = $value['number'];
  8991. $ftime = time() - 15 * 24 * 3600;
  8992. if ($c < 1) {
  8993. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  8994. }
  8995. }
  8996. $title = "0库存汇总";
  8997. $first_row = ["仓库","SKU","产品","当前库存"];
  8998. $cols = [
  8999. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9000. ];
  9001. $final_list= [];
  9002. foreach($list as $key => $value){
  9003. $final_list[] = array_values($value) ;
  9004. }
  9005. if(empty($final_list)){
  9006. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9007. }
  9008. array_unshift($final_list, $first_row);
  9009. $merges = [];
  9010. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9011. }
  9012. }
  9013. }