update consultation show

This commit is contained in:
Barnabé 2021-09-16 13:14:15 +02:00
parent 74992c6607
commit 4faade463c

View File

@ -191,6 +191,16 @@
%h3 Lignes de produits %h3 Lignes de produits
.mb-3
- if @price_document.cc_label == "Consultation fournisseur"
= link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => @price_document.id, onclick: 'copyPriceLines(event)'
- existing_order = PriceDocument.where(doc_ref_id: @price_document.id, cc_label: "Commande achat")
- if existing_order.present?
= link_to ic(:eye) + " Afficher la commande", admin_price_document_path(existing_order.first), class: "btn btn-tertiary"
- else
= link_to "Generer la commande", buy_order_create_admin_price_document_path(@price_document), class: "btn btn-primary"
%table.table %table.table
%thead %thead
%tr %tr
@ -213,16 +223,17 @@
%td %td
=price_line.p_product_ref.p_product.s_brand.name =price_line.p_product_ref.p_product.s_brand.name
%td %td{class: "p_product_ref_cc_name_#{@price_document.id}"}
=link_to price_line.p_product_ref.cc_name, edit_admin_p_product_path(price_line.p_product_ref.p_product) if price_line.p_product_ref and price_line.p_product_ref.p_product =link_to price_line.p_product_ref.cc_name, edit_admin_p_product_path(price_line.p_product_ref.p_product) if price_line.p_product_ref and price_line.p_product_ref.p_product
%td.numeraire %td.numeraire{class: "price_line_qte_#{@price_document.id}"}
=price_line.qte =price_line.qte
%td.numeraire %td.numeraire{class: "price_line_price_u_ht_#{@price_document.id}"}
=number_to_currency price_line.price_u_ht =number_to_currency price_line.price_u_ht
@ -382,7 +393,7 @@
= semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form| = semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form|
= form.button "Valider modifications", type: :submit, class: "btn btn-primary m-2" = form.button "Valider modifications", type: :submit, class: "btn btn-primary m-2"
= link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)' = link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)'
- existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id) - existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id, cc_label: "Commande achat")
- if existing_order.present? - if existing_order.present?
= link_to ic(:eye) + " Afficher la commande", admin_price_document_path(existing_order.first), class: "btn btn-tertiary" = link_to ic(:eye) + " Afficher la commande", admin_price_document_path(existing_order.first), class: "btn btn-tertiary"
- else - else
@ -404,13 +415,17 @@
event.preventDefault() event.preventDefault()
let priceDocumentId = event.target.dataset.document let priceDocumentId = event.target.dataset.document
let names = $(`.p_product_ref_cc_name_${priceDocumentId}`) let names = $(`.p_product_ref_cc_name_${priceDocumentId}`)
let qtes = $(`.input_price_line_qte_${priceDocumentId}`) let qtes_input = $(`.input_price_line_qte_${priceDocumentId}`)
let qtes = $(`.price_line_qte_${priceDocumentId}`)
let prices = $(`.price_line_price_u_ht_${priceDocumentId}`) let prices = $(`.price_line_price_u_ht_${priceDocumentId}`)
let table = [] let table = []
names.each(function( i ) { names.each(function( i ) {
let row = [] let row = []
row.push(qtes[i].valueAsNumber) if(qtes_input.length > 0) {
row.push(qtes_input[i].valueAsNumber)
}else{
row.push(qtes[i].innerText.slice(0, -2))
}
row.push(" X ") row.push(" X ")
row.push(names[i].innerText) row.push(names[i].innerText)
row.push(" @ ") row.push(" @ ")