Cases à cocher buy list

This commit is contained in:
Nicolas Bally 2021-09-16 17:29:12 +02:00
parent 4faade463c
commit bfafa906ce
3 changed files with 20 additions and 16 deletions

View File

@ -235,12 +235,12 @@ class Admin::PriceDocumentsController < ApplicationController
@price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id])
if @price_document.price_document_type.label == "Demande prix"
p_product_ref_id = params[:qte].keys
p_product_ref_qte = params[:qte].values
p_product_ref_id = params[:p_product_ref_ids] - [""]
p_product_ref_qte = params[:qte].permit!.to_hash
p_product_ref_id.each_with_index do |key, i|
if p_product_ref_qte[i].to_i > 0
@price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => key, :qte => p_product_ref_qte[i])
p_product_ref_id.each do |i|
if p_product_ref_qte[i.to_s].to_i > 0
@price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => i, :qte => p_product_ref_qte[i.to_s])
end
end

View File

@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :set_current_p_customer_sheet
#before_action :set_current_p_customer_sheet
@ -33,9 +33,6 @@ class ApplicationController < ActionController::Base
elsif v[:elements]
v[:elements].each do |a,b|
puts "TEST"
puts b[0]
puts "B"
if b[:sub_elements] and b[:sub_elements][sym.to_sym]
@qi_menu_active = k
@qi_menu_sub_menu_active = sym.to_sym
@ -474,6 +471,9 @@ class ApplicationController < ActionController::Base
def current_admin
if @current_admin
return @current_admin
else
if cookies[:admin_remember_token]
if @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token])
@current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token])
@ -482,6 +482,7 @@ class ApplicationController < ActionController::Base
end
end
end

View File

@ -72,7 +72,8 @@
=form_tag new_admin_price_document_path(), :method => "get" do
=hidden_field_tag :"document_type", "Demande prix"
=hidden_field_tag :"price_line_ids[]", ""
=hidden_field_tag :"p_product_ref_ids[]", ""
.freezeTable
%table.table.table-striped.table-hover.table-bordered.data_table
%thead.header
@ -173,6 +174,8 @@
%td.mask
= qte_available
%td.mask
=check_box_tag :"p_product_ref_ids[]", plr.p_product_ref.id
=number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: (bpa_qte - qte_available)
%td.mask