diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 564d597..1ee4dde 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -28,9 +28,6 @@ class Admin::PProductRefsController < ApplicationController @p_product_refs = @p_product_refs.joins(:fournisseur_product_refs).where("fournisseur_product_refs.ref LIKE ?","%#{params[:search][:fournisseur_ref]}%") end - if params[:search][:global].to_s != "" - @p_product_refs = PProductRef.global_search(params[:search][:global]) - end if params[:search][:p_product_ref_cat_id].to_s != "" if params[:search][:p_product_ref_cat_id].to_s == "null" @@ -42,13 +39,11 @@ class Admin::PProductRefsController < ApplicationController if params[:search][:s_brand_id].to_s != "" + @p_product_refs = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}) + end - @p_product_refs = @p_product_refs.where(:s_brand => params[:search][:s_brand_id]) - puts "£££££££££££££££££££££££££££££££££££££" - puts "£££££££££££££££££££££££££££££££££££££" - puts SBrand.find(params[:search][:s_brand_id]).id.to_s + ' ' +SBrand.find(params[:search][:s_brand_id]).name - puts "£££££££££££££££££££££££££££££££££££££" - puts "£££££££££££££££££££££££££££££££££££££" + if params[:search][:global].to_s != "" + @p_product_refs = PProductRef.global_search(params[:search][:global]) end @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") diff --git a/app/models/s_brand.rb b/app/models/s_brand.rb index c5db009..10fa791 100644 --- a/app/models/s_brand.rb +++ b/app/models/s_brand.rb @@ -1,4 +1,5 @@ class SBrand < ApplicationRecord - + has_many :p_products + has_many :p_product_refs, through: :p_products validates :name, :presence => true, :uniqueness => true end diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index e4564ec..bc2bd0f 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -15,25 +15,24 @@ %table %tr - -if false - %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" - - %td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur" - - %td{style: "min-width: 500px;"} .input-group =text_field_tag "search[global]", params[:search][:global],:class => "form-control", :placeholder => "Marque, modèle, couleur, code..." .input-group-append{:onclick => "$(this).prev('input').val('');"} - .btn.btn-outline-primary + .btn.btn-outline-dark =ic(:times) %table %tr - %td - Actif : - %td - =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]), class: "custom-select" + -if false + %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" + + %td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur" + + %td + Actif : + %td + =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]), class: "custom-select" %td Catégorie : %td