update consultation show
This commit is contained in:
parent
74992c6607
commit
4faade463c
@ -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
|
||||||
@ -399,41 +410,45 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
const copyPriceLines = (event) => {
|
const copyPriceLines = (event) => {
|
||||||
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 prices = $(`.price_line_price_u_ht_${priceDocumentId}`)
|
let qtes = $(`.price_line_qte_${priceDocumentId}`)
|
||||||
|
let prices = $(`.price_line_price_u_ht_${priceDocumentId}`)
|
||||||
|
let table = []
|
||||||
|
names.each(function( i ) {
|
||||||
|
let row = []
|
||||||
|
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(names[i].innerText)
|
||||||
|
row.push(" @ ")
|
||||||
|
row.push(prices[i].innerText)
|
||||||
|
table.push(row.join(' '))
|
||||||
|
})
|
||||||
|
copyStringToClipboard(table.join('\r\n'))
|
||||||
|
}
|
||||||
|
|
||||||
let table = []
|
function copyStringToClipboard (str) {
|
||||||
names.each(function( i ) {
|
// Create new element
|
||||||
let row = []
|
var el = document.createElement('textarea');
|
||||||
row.push(qtes[i].valueAsNumber)
|
// Set value (string to be copied)
|
||||||
row.push(" X ")
|
el.value = str;
|
||||||
row.push(names[i].innerText)
|
// Set non-editable to avoid focus and move outside of view
|
||||||
row.push(" @ ")
|
el.setAttribute('readonly', '');
|
||||||
row.push(prices[i].innerText)
|
el.style = {position: 'absolute', left: '-9999px'};
|
||||||
table.push(row.join(' '))
|
document.body.appendChild(el);
|
||||||
})
|
// Select text inside element
|
||||||
copyStringToClipboard(table.join('\r\n'))
|
el.select();
|
||||||
}
|
// Copy text to clipboard
|
||||||
|
document.execCommand('copy');
|
||||||
function copyStringToClipboard (str) {
|
// Remove temporary element
|
||||||
// Create new element
|
document.body.removeChild(el);
|
||||||
var el = document.createElement('textarea');
|
}
|
||||||
// Set value (string to be copied)
|
|
||||||
el.value = str;
|
|
||||||
// Set non-editable to avoid focus and move outside of view
|
|
||||||
el.setAttribute('readonly', '');
|
|
||||||
el.style = {position: 'absolute', left: '-9999px'};
|
|
||||||
document.body.appendChild(el);
|
|
||||||
// Select text inside element
|
|
||||||
el.select();
|
|
||||||
// Copy text to clipboard
|
|
||||||
document.execCommand('copy');
|
|
||||||
// Remove temporary element
|
|
||||||
document.body.removeChild(el);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user