diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ce02913..6441a74 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -126,7 +126,9 @@ class ApplicationController < ActionController::Base set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_grades, "Grades" if PGrade::ACTIVATED set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_powers, "Types de chargeurs" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_zones, "Zones produits" - + set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_cats, "Catégories SORECOP" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_taxes, "taxe SORECOP" + end diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 9a7fccf..49d5d80 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -1,6 +1,7 @@ class PProductRef < ApplicationRecord belongs_to :p_product - + belongs_to :sorecop_cat + has_many :sorecop_taxes, through: :sorecop_cat has_many :p_customer_cats, :through => :p_product has_many :p_product_features diff --git a/app/models/sorecop_cat.rb b/app/models/sorecop_cat.rb index be69dba..a0af0d4 100644 --- a/app/models/sorecop_cat.rb +++ b/app/models/sorecop_cat.rb @@ -1,2 +1,10 @@ class SorecopCat < ApplicationRecord + has_many :p_product_refs + has_many :sorecop_taxes, dependent: :destroy + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :name => {:name => "Catégorie", :reorder => true}, + :actions => {:name => "Actions", :reorder => true} + } end diff --git a/app/models/sorecop_tax.rb b/app/models/sorecop_tax.rb index 9fb2cd7..518bb01 100644 --- a/app/models/sorecop_tax.rb +++ b/app/models/sorecop_tax.rb @@ -1,3 +1,15 @@ class SorecopTax < ApplicationRecord - belongs_to :sorecop_cat_id + belongs_to :sorecop_cat + + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :title => {:name => "Désignation", :reorder => true}, + :critere_min => {:name => "Critère mini (Go)", :reorder => true}, + :critere_max => {:name => "Critère maxi (Go)", :reorder => true}, + :fixed_price => {:name => "Prix forfaitaire", :reorder => true, :format => :boolean}, + :sorecop_cat => {:name => "Catégorie SORECOP", :reorder => false}, + :price => {:name => "Prix", :reorder => false}, + :actions => {:name => "Actions", :reorder => true} + } end diff --git a/app/views/admin/sorecop_taxes/_form.html.haml b/app/views/admin/sorecop_taxes/_form.html.haml index 389bbe6..38654b8 100644 --- a/app/views/admin/sorecop_taxes/_form.html.haml +++ b/app/views/admin/sorecop_taxes/_form.html.haml @@ -2,15 +2,17 @@ .content =f.inputs do - = f.input :critere_min, :label => f.object.label_for(:critere_min) - = f.input :critere_max, :label => f.object.label_for(:critere_max) - = f.input :title, :label => f.object.label_for(:title) - = f.input :fixed_price, :label => f.object.label_for(:fixed_price) - = f.input :sorecop_cat_id, :label => f.object.label_for(:sorecop_cat_id) - + = f.input :sorecop_cat_id, as: :select, collection: SorecopCat.pluck(:name, :id) ,:label => f.object.label_for(:sorecop_cat) + = f.input :title, :label => f.object.label_for(:title) + = f.input :critere_min, :label => f.object.label_for(:critere_min) + = f.input :critere_max, :label => f.object.label_for(:critere_max) + = f.input :price, :label => f.object.label_for(:price) + = f.input :fixed_price, :label => f.object.label_for(:fixed_price) + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" - \ No newline at end of file + diff --git a/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml b/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml index 4a318ec..c35450f 100644 --- a/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml +++ b/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml @@ -1,5 +1,10 @@ %tr#sorecop_tax_row{:id => sorecop_tax.id} -tr = {} + + -tr[:sorecop_cat] = capture do + %td + = sorecop_tax.sorecop_cat.name + -tr[:actions] = capture do %td.actions @@ -13,4 +18,4 @@ - \ No newline at end of file +