buy_list upgrade

This commit is contained in:
Barnabé 2021-08-31 19:10:18 +02:00
parent ed02337d27
commit a8ffef1833
2 changed files with 197 additions and 73 deletions

View File

@ -14,11 +14,57 @@ class Admin::BuyListsController < ApplicationController
@price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids)
if params[:search][:s_brand].present? && params[:search][:s_brand] != ""
@price_lines = @price_lines.joins(p_product_ref: :p_product).where("s_brand_id = ?", params[:search][:s_brand])
end
if params[:search][:state].present? && params[:search][:state] != ""
@p_customer_sheets = @p_customer_sheets.where(:state => params[:search][:state])
@price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids)
@price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids)
end
if params[:search][:p_customer_code].present?
@p_customer_sheets = @p_customer_sheets.joins(:p_customer).where("code LIKE ?", params[:search][:p_customer_code])
@price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids)
@price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids)
end
date_regex = /^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](19|20)\d\d$/i
params[:start] = Date.today.beginning_of_month.strftime('%d/%m/%Y') if !params[:start]
if params[:start] and params[:start] =~ date_regex
#fsfds = sdfsfd
@start = Date.parse(params[:start]).beginning_of_day
params[:start]= @start.strftime('%d/%m/%Y')
else
@start = nil
end
if true
params[:stop] = Date.today.end_of_month.strftime('%d/%m/%Y') if !params[:stop]
if params[:stop].to_s != "" # and params[:stop] =~ date_regex
@stop = Date.parse(params[:stop]).end_of_day
params[:stop]= @stop.strftime('%d/%m/%Y')
else
@stop = nil
end
end
@price_lines = @price_lines.where("price_lines.cc_creation_date >= ?", @start) if @start
@price_lines = @price_lines.where("price_lines.cc_creation_date <= ?", @stop.end_of_day) if @stop
respond_to do |format|
format.html{
}
end

View File

@ -1,3 +1,4 @@
-checkbox = false
.qi_header
.right
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add"
@ -10,16 +11,48 @@
=form_tag "", :method => "get", :onsubmit => "" do
-params[:search] =params[:search] || {}
%p Date de consultation :
%table
%tr
%tr.form-inline
%td
Début
%td.input-group
=text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début"
.input-group-append
%span.input-group-text{:onclick => "$(this).prev('input').val('');"}
=ic(:times)
%td.pl-4
Fin
%td.input-group
=text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin"
.input-group-append
%span.input-group-text{:onclick => "$(this).prev('input').val('');"}
=ic(:times)
%td
Statut :
=select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state])
=select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]), class: "custom-select"
%td
Marque :
=select_tag "search[s_brand]", options_for_select([["",""],["Aucune","null"]]+SBrand.pluck(:name, :id), params[:search][:s_brand]), class: "custom-select"
%td
Code client :
=text_field_tag "search[p_customer_code]", params[:search][:p_customer_code],:class => "form-control"
%tr.form-inline
%td{width: "110px"}
%td.right.mx-4
-if @start and @stop
=link_to "< Mois précédent",request.query_parameters.merge({start: ((@start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary"
%td{width: "20px"}
%td.mr-auto
-if @start and @stop
=link_to "Mois suivant >",request.query_parameters.merge({start: ((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary"
=link_to ic(:search)+" Rechercher", "#", :class => "btn btn-default btn-qi-search", :onclick => "$(this).closest('form').submit();$(this).html('...');return false;"
@ -44,13 +77,15 @@
%table.table.table-striped.table-hover.table-bordered.data_table
%thead.header
%tr
%th
-if checkbox
%th
%th
Produit
%th
Référence
%th Qté
/ %th Qté
%th.mask
=ic("plus-square-o")
%th.mask
N° Commande
%th.mask
@ -63,7 +98,11 @@
%th.mask Date livraison (ETA)
%th.mask
Qté commandée
Qté nécessaire
%th.mask
Qté en stock
%th.mask
Qté souhaité
%th.mask Commentaire
%th.mask BPA
%th.mask AV BPA
@ -89,7 +128,9 @@
-ppr_lines = @price_lines.where(:p_product_ref_id => plr.p_product_ref.id)
%tr.ref_tr
%td
-if checkbox
%td
%td
=link_to plr.p_product_ref.p_product.name, [:admin, plr.p_product_ref]
%td
@ -97,79 +138,100 @@
=plr.p_product_ref.ct_sub_name
=plr.p_product_ref.p_product_color.name if plr.p_product_ref.p_product_color
%td.plus
=link_to ic("plus-square-o"), "#"
%td
=ppr_lines.sum(:qte)
%td.mask
/ %td.mask
%td.mask
%td.mask
%td.mask
%td.mask
%td.mask
&#8721
=ppr_lines.sum(:qte).to_i
%br
%span.asap
=ic(:fire)
=ppr_lines.asap_triage(10).first
%br
%span.non-asap
=ic(:hourglass)
=ppr_lines.asap_triage(10).last
%td.mask
= LineStock.where(p_product_ref_id: plr.p_product_ref.id).sum(:qte_available).to_i
%td.mask
=text_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input"
%td.mask
%td.mask
=ppr_lines.where(:cc_state => "BPA").sum(:qte)
=ppr_lines.where(:cc_state => "BPA").sum(:qte).to_i
%td.mask
=ppr_lines.where(:cc_state => "AV BPA").sum(:qte)
=ppr_lines.where(:cc_state => "AV BPA").sum(:qte).to_i
%td.mask
=ppr_lines.where(:cc_state => "PAS BPA").sum(:qte)
=ppr_lines.where(:cc_state => "PAS BPA").sum(:qte).to_i
-ppr_lines.each do |price_line|
%tr
%td
=check_box_tag :"price_line_ids[]", price_line.id
%td
%td
%td
%td
=link_to [:admin, price_line.price_line_block.price_lineable] do
=price_line.price_line_block.price_lineable.id
=price_line.price_line_block.price_lineable.past_id
%td
=link_to price_line.p_customer.show_name, [:admin, price_line.p_customer]
%td
=state_helper price_line.price_line_block.price_lineable.state
%td
= l price_line.cc_creation_date, :format => :short_date
%td
= l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date
%td
= l price_line.cc_wish_date, :format => "semaine %V (%Y)"
%td
=price_line.qte
%td
=price_line.comment
%td
=price_line.qte if price_line.cc_state == "BPA"
%td
=price_line.qte if price_line.cc_state == "AV BPA"
%td
=price_line.qte if price_line.cc_state == "PAS BPA"
%tbody.detail
-ppr_lines.each do |price_line|
%tr.details
- if checkbox
%td
=check_box_tag :"price_line_ids[]", price_line.id
/ %td
%td
%td
%td
%td
=link_to [:admin, price_line.price_line_block.price_lineable] do
=price_line.price_line_block.price_lineable.id
=price_line.price_line_block.price_lineable.past_id
%td
=link_to price_line.p_customer.show_name, [:admin, price_line.p_customer]
%td
=state_helper price_line.price_line_block.price_lineable.state
%td
= l price_line.cc_creation_date, :format => :short_date
%td
= l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date
%td
= l price_line.cc_wish_date, :format => "semaine %V (%Y)"
%td
=price_line.qte.to_i
%td
%td
%td
=price_line.comment
%td
=price_line.qte.to_i if price_line.cc_state == "BPA"
%td
=price_line.qte.to_i if price_line.cc_state == "AV BPA"
%td
=price_line.qte.to_i if price_line.cc_state == "PAS BPA"
-p_product_id = plr.p_product_id
%tr
-nbr_td.times.each do
%td
=submit_tag "Créer une demande de prix", :class => "btn btn-primary"
%tr
-nbr_td.times.each do
%td
=submit_tag "Créer une demande de prix", :class => "btn btn-primary"
@ -187,10 +249,26 @@
border-bottom:3px solid red;
}
}
.asap {
color: red;
}
.non-asap {
color: darkblue;
}
.small-input {
max-width: 100px;
}
:javascript
$('.plus').click(function(event){
console.log(event.currentTarget);
$(event.currentTarget).parent().parent().next('tbody.detail').toggle();
$(event.currentTarget).find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o')
});