316 lines
14 KiB
Plaintext
316 lines
14 KiB
Plaintext
.qi_header
|
|
=breadcrumb second_title: "Demande de prix #{@price_document.d_number} - #{@price_document.list_designaton}", second_link: admin_price_document_path(@price_document) , last_element: "Analyse de des réponses"
|
|
|
|
-unmatched_fournisseur = 0
|
|
=semantic_form_for [:admin, @price_document],url: analyse_reponses_save_admin_price_document_path, method: :post, :html => {:class => "qi_price_form"}, :remote => false do |form|
|
|
=form.semantic_fields_for :price_line_block do |f|
|
|
- price_line_block = f.object
|
|
.qi_pannel.padding.new_table_container
|
|
.table-slider
|
|
.inner
|
|
|
|
.table-area{:style => "overflow:auto;"}
|
|
.table-area-inner
|
|
.freezeTable
|
|
%table.table.table-striped.table-hover.table-bordered.data_table
|
|
%thead.header
|
|
%tr
|
|
-nb_resp = @price_document_responses.count
|
|
%th{colspan: 12}
|
|
Consultation
|
|
%th{colspan: nb_resp}
|
|
Fournisseurs
|
|
.btn.btn-light.mx-4#reset-radio
|
|
reset
|
|
.legend.d-flex
|
|
légende :
|
|
.inlie-block.d-flex.flex-wrap.justify-content-end
|
|
.mx-2.red
|
|
= ic("diamond") + " Spot detecté !"
|
|
.mx-2.green
|
|
= ic("money") + " Meilleur prix"
|
|
.mx-2.red
|
|
= ic(:times) + " Alerte marge basse"
|
|
.mx-2.green
|
|
= ic(:check) + " Marge ok"
|
|
.mx-2.orange
|
|
= ic(:warning) + " Alerte Qté"
|
|
.mx-2.info
|
|
= ic('info-circle') + " Commentaire fournisseur"
|
|
%tr
|
|
%th
|
|
Qté à
|
|
%br
|
|
satisfaire
|
|
%th
|
|
Qté consultée
|
|
%th
|
|
Produit
|
|
%th
|
|
Référence
|
|
%th
|
|
Couleur
|
|
%th
|
|
Type
|
|
%br
|
|
chargeur
|
|
%th
|
|
Target hors
|
|
%br
|
|
Sorecop
|
|
%th
|
|
Px d'achat
|
|
%br
|
|
référence
|
|
%th
|
|
Marge
|
|
%br
|
|
théorique
|
|
%br
|
|
référence
|
|
%br
|
|
par zone
|
|
%th
|
|
Fours.
|
|
%br
|
|
de référence
|
|
%th
|
|
Date
|
|
%br
|
|
px référence
|
|
%th.limit
|
|
Spec
|
|
|
|
-@price_document_responses.each do |resp|
|
|
%th
|
|
-if resp.p_fournisseur
|
|
=resp.p_fournisseur.name
|
|
-else
|
|
-unmatched_fournisseur += 1
|
|
nom renseigné par le fournisseur :
|
|
%br
|
|
="(#{resp.public_fournisseur_name})"
|
|
%br
|
|
=link_to ic('pencil') + " rapprocher le fournisseur", match_p_fournisseur_admin_price_document_path(resp), remote: true
|
|
|
|
|
|
%tbody
|
|
-# price_lines = f.object.price_lines
|
|
-price_lines_child_index = {}
|
|
-consult_price_lines = @price_document.price_line_block.price_lines
|
|
=f.semantic_fields_for :price_lines do |form|
|
|
- price_line = form.object
|
|
-#price_lines = @price_document.price_line_block.price_lines
|
|
-#price_lines.each do |price_line|
|
|
%tr
|
|
%td
|
|
=# ATTENTION ! On a plus accès direct aux commandes qui on engendré cette demande de prix. donc plus accès aux délais différent entre les différentes commades pour une ref donée
|
|
/ ∑
|
|
/ =price_line.qte.to_i
|
|
/ %br
|
|
- if price_line.cc_wish_date.present? && price_line.cc_wish_date < Date.today + 20.days
|
|
%span.red
|
|
=ic(:fire)
|
|
=price_line.qte.to_i
|
|
- else
|
|
%span.darkblue
|
|
=ic(:hourglass)
|
|
=price_line.qte.to_i
|
|
%td.ref_tr
|
|
Qté en comm
|
|
%td
|
|
= price_line.p_product_ref.p_product.name
|
|
%td
|
|
=link_to [:admin, price_line.p_product_ref] do
|
|
= price_line.p_product_ref.ct_sub_name
|
|
= price_line.p_product_ref.p_product_color.name
|
|
|
|
%td
|
|
= price_line.p_product_ref.p_product_color.color if price_line.p_product_ref and price_line.p_product_ref.p_product_color
|
|
%td
|
|
= price_line.p_product_power.name if price_line.p_product_power
|
|
%td
|
|
/ Target hors Sorecop
|
|
%td
|
|
/ Px d'achat de référence
|
|
%td
|
|
/ Marge théorique de référence par zone
|
|
%td
|
|
/ Fournisseurs de référence
|
|
%td
|
|
/ Date du px de référence
|
|
%td.limit
|
|
/ spec
|
|
|
|
=#form.input :price_line_resp_ids, collection: PriceLine.where(:price_line_ref_id => form.object.id).all, as: :check_boxes , :member_label => :id
|
|
|
|
-#NICO : j'ai commenté l'input qu'on a fait ensemble, par contre, pour toute la suite, j'ai en fait fait un copié collé du rendu de cet inpu ou j'ai remis les champs dynamics en correspondance.
|
|
|
|
|
|
-#NICO : j'ai créé un hash plus haut, vide, qui va me permettre de faire correspondre à chaque ID de price_line leur index dans le nested form (qui est différent, une itération, de l'ID de l'élement... Là c'est la magie de rails.)
|
|
- price_lines_child_index[form.object.id.to_s] = form.options[:child_index]
|
|
-best_price = PriceLine.where(price_line_ref_id: price_line.id).where("ct_u_price_ht > 0").order(:ct_u_price_ht).ids
|
|
-#Nico : je commence, pour chaque price line, par faire une checkbox vide. J'aurais pu faire un checkbox tag mais par facilité j'ai copé l'HTML dans HTML2HAML et je suis partid du résultat. Les checkboxes sont ensuite dans ta boucle
|
|
%input{:autocomplete => "off", :id => "price_document[price_line_block_attributes][price_lines_attributes][#{form.options[:child_index] }]_price_line_resp_ids_none", :name => "price_document[price_line_block_attributes][price_lines_attributes][#{form.options[:child_index] }][price_line_resp_ids][]", :type => "hidden", :value => ""}/
|
|
|
|
=#{}"price doc id : #{@price_document_responses.ids}"
|
|
|
|
- @price_document_responses.each do |resp|
|
|
-line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first
|
|
-cell = []
|
|
|
|
- if line.qte_available.to_i > 0
|
|
- if line.id == best_price[0]
|
|
-cell << "<span class=green>#{ic(:money)} Meilleur prix</span>"
|
|
- if line.qte_available >= price_line.qte.to_i
|
|
- cell << "Qté dispo : #{line.qte_available.to_i}"
|
|
- else
|
|
- cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})"
|
|
- cell << "PA: #{line.ct_u_price_ht} €"
|
|
- # mp = calcul de la marge prévisionelle TODO
|
|
- line.id.odd? ? mp = 0.17 : mp = 0.11
|
|
- if false
|
|
-if mp > 0.15
|
|
- cell << "<span class=green>#{ic(:check)} MP: #{mp * 100} %</span>"
|
|
-else
|
|
- cell << "#{ic(:times, class: "red")} MP: #{mp * 100} %"
|
|
-else
|
|
- cell << "<span class=red>pas dispo</span>"
|
|
-if line.comment.present?
|
|
- display_comment = ""
|
|
- if line.comment.length > 10
|
|
- display_comment = "#{line.comment[0..10]} (..)"
|
|
- else
|
|
- display_comment = line.comment
|
|
- cell << "<span class='info'>#{ic('info-circle')} #{display_comment}<span class='info-text-top'>#{line.comment}</span></span>"
|
|
|
|
%td.p-0{class: ("best-price" if line.id == best_price[0])}
|
|
=# "reponse price_line ID : #{line.id}"
|
|
=# "price line origine : #{line.price_line_ref_id}" #NICO : simple contrôle, je récupère facilement par là l'ID de la price Line concernée.
|
|
|
|
-#NICO : si on a un price_line_ref_id, j'ajoute la case à cocher. Je récupère l'index de nested form dans mon hash, et je passe en value le line.id
|
|
-if line.price_line_ref_id.to_s != ""
|
|
%input.seletable_price{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/
|
|
%label.p-2.m-auto{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"}
|
|
=sanitize(cell.join('<br>'))
|
|
|
|
|
|
=# radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "seletable_price"
|
|
=# label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('<br>')), class: "p-2 m-auto"
|
|
|
|
- if unmatched_fournisseur == 0
|
|
=submit_tag 'valider la selection', class: "btn btn-primary ml-4"
|
|
- else
|
|
%button.btn.btn-primary.ml-4{"type" => "button", "data-toggle" => "modal", "data-target" => "#unmatched-fournisseur"}
|
|
Valider la selection
|
|
.modal.fade#unmatched-fournisseur{"tab-index" => "-1", "role" => "dialog", "aria-labelledby" => "Raprochement Fournisseur", "aria-hidden" => "true"}
|
|
.modal-dialog{role: "dialog"}
|
|
.modal-content
|
|
.modal-header
|
|
%h5.modal-title
|
|
Rapprochement du fournisseur
|
|
%button.close{"data-dismiss" => "modal", "aria-label" => "Close"}
|
|
%span{"aria-hidden" => "true"}
|
|
×
|
|
.modal-body
|
|
Il reste des fournisseurs à prapprocher avant de pouvoir valider.
|
|
.modal-footer
|
|
%button.btn.btn-light{"data-dismiss" => "modal"}
|
|
Close
|
|
- if PriceDocument.where(doc_ref_id: @price_document, price_document_type: PriceDocumentType.find_by_label("Consultation fournisseur")).empty?
|
|
=link_to "Generer les consultations", generate_final_consult_admin_price_document_path, class: "btn btn-primary ml-4 mt-4"
|
|
|
|
=link_to "Acceder aux consultations", admin_price_document_path(@price_document, anchor: "consult"), class: "btn btn-primary ml-4 mt-4"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:scss
|
|
.seletable_price {
|
|
position: absolute;
|
|
transform: scale(0);
|
|
}
|
|
|
|
.seletable_price + label {
|
|
display: block;
|
|
min-height: 105px;
|
|
cursor: pointer;
|
|
box-sizing: border-box;
|
|
width: 100%;
|
|
text-align: left;
|
|
|
|
&:hover{
|
|
background:linear-gradient(to top, #efefef 5%, #fdfdfd 100%);
|
|
background-color:#5cb811;
|
|
}
|
|
&:active{
|
|
position:relative;
|
|
top:1px;
|
|
}
|
|
}
|
|
|
|
.seletable_priceOLD:checked + label {
|
|
background-color: green !important;
|
|
border-radius: 1em;
|
|
border: darkgreen solid 0.2em;
|
|
mix-blend-mode: difference;
|
|
}
|
|
.seletable_price:checked + label{
|
|
box-shadow:inset 0px 1px 0px 0px #caefab;
|
|
background:linear-gradient(to bottom, #77d42a 5%, #5cb811 100%);
|
|
background-color:#77d42a;
|
|
border-radius:6px;
|
|
border:1px solid #268a16;
|
|
display:inline-block;
|
|
cursor:pointer;
|
|
color:#306108;
|
|
font-family:Arial;
|
|
font-size:15px;
|
|
font-weight:bold;
|
|
padding:6px 24px;
|
|
text-decoration:none;
|
|
text-shadow:0px 1px 0px #aade7c;
|
|
|
|
&:hover{
|
|
background:linear-gradient(to bottom, #5cb811 5%, #77d42a 100%);
|
|
background-color:#5cb811;
|
|
}
|
|
}
|
|
|
|
.best-price{
|
|
background-color: #b4f99e !important;
|
|
}
|
|
|
|
.limit {
|
|
border-right:3px solid green !important;
|
|
}
|
|
|
|
.red {
|
|
color: red;
|
|
}
|
|
.green {
|
|
color: green;
|
|
}
|
|
.orange {
|
|
color: orange;
|
|
}
|
|
|
|
|
|
.darkblue {
|
|
color: darkblue;
|
|
}
|
|
|
|
.small-input {
|
|
max-width: 100px;
|
|
}
|
|
|
|
:javascript
|
|
$( "#reset-radio" ).click(function(event){
|
|
$('input:checkbox').prop('checked',false);
|
|
})
|