From bfafa906ce243c4479c5d4875be363c861e7c4c7 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Thu, 16 Sep 2021 17:29:12 +0200 Subject: [PATCH] =?UTF-8?q?Cases=20=C3=A0=20cocher=20buy=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/price_documents_controller.rb | 10 ++++----- app/controllers/application_controller.rb | 21 ++++++++++--------- app/views/admin/buy_lists/index.html.haml | 5 ++++- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 7ca73b2..ce7b3f5 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0e10c2f..ce02913 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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,13 +471,17 @@ class ApplicationController < ActionController::Base def current_admin - 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]) - else - cookies[:admin_remember_token] =nil - end + 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]) + else + cookies[:admin_remember_token] =nil + end + end end diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index cb6bed8..59a005d 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -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