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) @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| respond_to do |format|
format.html{ format.html{
} }
end end

View File

@ -1,3 +1,4 @@
-checkbox = false
.qi_header .qi_header
.right .right
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add" =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 =form_tag "", :method => "get", :onsubmit => "" do
-params[:search] =params[:search] || {} -params[:search] =params[:search] || {}
%p Date de consultation :
%table %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 %td
Statut : 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 %table.table.table-striped.table-hover.table-bordered.data_table
%thead.header %thead.header
%tr %tr
-if checkbox
%th %th
%th %th
Produit Produit
%th %th
Référence Référence
%th Qté / %th Qté
%th.mask
=ic("plus-square-o")
%th.mask %th.mask
N° Commande N° Commande
%th.mask %th.mask
@ -63,7 +98,11 @@
%th.mask Date livraison (ETA) %th.mask Date livraison (ETA)
%th.mask %th.mask
Qté commandée Qté nécessaire
%th.mask
Qté en stock
%th.mask
Qté souhaité
%th.mask Commentaire %th.mask Commentaire
%th.mask BPA %th.mask BPA
%th.mask AV BPA %th.mask AV BPA
@ -89,7 +128,9 @@
-ppr_lines = @price_lines.where(:p_product_ref_id => plr.p_product_ref.id) -ppr_lines = @price_lines.where(:p_product_ref_id => plr.p_product_ref.id)
%tr.ref_tr %tr.ref_tr
-if checkbox
%td %td
%td %td
=link_to plr.p_product_ref.p_product.name, [:admin, plr.p_product_ref] =link_to plr.p_product_ref.p_product.name, [:admin, plr.p_product_ref]
%td %td
@ -97,31 +138,50 @@
=plr.p_product_ref.ct_sub_name =plr.p_product_ref.ct_sub_name
=plr.p_product_ref.p_product_color.name if plr.p_product_ref.p_product_color =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 %td
=ppr_lines.sum(:qte)
%td.mask %td.mask
/ %td.mask
%td.mask %td.mask
%td.mask %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 %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
%td.mask %td.mask
=ppr_lines.where(:cc_state => "BPA").sum(:qte) =ppr_lines.where(:cc_state => "BPA").sum(:qte).to_i
%td.mask %td.mask
=ppr_lines.where(:cc_state => "AV BPA").sum(:qte) =ppr_lines.where(:cc_state => "AV BPA").sum(:qte).to_i
%td.mask %td.mask
=ppr_lines.where(:cc_state => "PAS BPA").sum(:qte) =ppr_lines.where(:cc_state => "PAS BPA").sum(:qte).to_i
%tbody.detail
-ppr_lines.each do |price_line| -ppr_lines.each do |price_line|
%tr %tr.details
- if checkbox
%td %td
=check_box_tag :"price_line_ids[]", price_line.id =check_box_tag :"price_line_ids[]", price_line.id
/ %td
%td %td
%td %td
%td %td
@ -144,24 +204,26 @@
%td %td
= l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date = l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date
%td %td
= l price_line.cc_wish_date, :format => "semaine %V (%Y)" = l price_line.cc_wish_date, :format => "semaine %V (%Y)"
%td %td
=price_line.qte =price_line.qte.to_i
%td
%td
%td %td
=price_line.comment =price_line.comment
%td %td
=price_line.qte if price_line.cc_state == "BPA" =price_line.qte.to_i if price_line.cc_state == "BPA"
%td %td
=price_line.qte if price_line.cc_state == "AV BPA" =price_line.qte.to_i if price_line.cc_state == "AV BPA"
%td %td
=price_line.qte if price_line.cc_state == "PAS BPA" =price_line.qte.to_i if price_line.cc_state == "PAS BPA"
-p_product_id = plr.p_product_id -p_product_id = plr.p_product_id
@ -188,8 +250,24 @@
} }
} }
.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')
});