Generate commande achat
This commit is contained in:
parent
e8d66c91d7
commit
ce6a7a6c91
@ -655,4 +655,19 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
@final_consult = PriceDocument.where(price_document_type: PriceDocumentType.find_by_label("Consultation fournisseur")).last
|
@final_consult = PriceDocument.where(price_document_type: PriceDocumentType.find_by_label("Consultation fournisseur")).last
|
||||||
redirect_to :analyse_reponses_admin_price_document
|
redirect_to :analyse_reponses_admin_price_document
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def buy_order_create
|
||||||
|
|
||||||
|
@final_consult = PriceDocument.find(params[:id])
|
||||||
|
price_line_block = PriceLineBlock.new(p_fournisseur: @final_consult.price_line_block.p_fournisseur)
|
||||||
|
price_lines = PriceLine.where(price_line_block: @final_consult.price_line_block)
|
||||||
|
|
||||||
|
@price_document = PriceDocument.new(date: Date.today, price_line_block: price_line_block, doc_ref_id: @final_consult.id, :price_document_type => PriceDocumentType.find_by_label("Commande achat"))
|
||||||
|
price_lines.each do |pl|
|
||||||
|
@price_document.price_line_block.price_lines << PriceLine.new(p_product_ref: pl.p_product_ref, qte: pl.qte, ct_u_price_ht: pl.price_u_ht)
|
||||||
|
end
|
||||||
|
if @price_document.save!
|
||||||
|
redirect_to admin_price_document_path(@price_document)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -371,9 +371,11 @@
|
|||||||
-@price_documents.each do |price_document_consult|
|
-@price_documents.each do |price_document_consult|
|
||||||
|
|
||||||
%h4.ml-2= price_document_consult.p_fournisseur.name
|
%h4.ml-2= price_document_consult.p_fournisseur.name
|
||||||
|
|
||||||
= 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)'
|
||||||
|
= link_to "Generer la commande", buy_order_create_admin_price_document_path(price_document_consult)
|
||||||
.price-lines{"data-document" => price_document_consult.id}
|
.price-lines{"data-document" => price_document_consult.id}
|
||||||
=form.semantic_fields_for :price_line_block do |f|
|
=form.semantic_fields_for :price_line_block do |f|
|
||||||
.mx-2
|
.mx-2
|
||||||
@ -385,40 +387,40 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
: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_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)
|
row.push(qtes[i].valueAsNumber)
|
||||||
row.push(" X ")
|
row.push(" X ")
|
||||||
row.push(names[i].innerText)
|
row.push(names[i].innerText)
|
||||||
row.push(" @ ")
|
row.push(" @ ")
|
||||||
row.push(prices[i].innerText)
|
row.push(prices[i].innerText)
|
||||||
table.push(row.join(' '))
|
table.push(row.join(' '))
|
||||||
})
|
})
|
||||||
copyStringToClipboard(table.join('\r\n'))
|
copyStringToClipboard(table.join('\r\n'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyStringToClipboard (str) {
|
function copyStringToClipboard (str) {
|
||||||
// Create new element
|
// Create new element
|
||||||
var el = document.createElement('textarea');
|
var el = document.createElement('textarea');
|
||||||
// Set value (string to be copied)
|
// Set value (string to be copied)
|
||||||
el.value = str;
|
el.value = str;
|
||||||
// Set non-editable to avoid focus and move outside of view
|
// Set non-editable to avoid focus and move outside of view
|
||||||
el.setAttribute('readonly', '');
|
el.setAttribute('readonly', '');
|
||||||
el.style = {position: 'absolute', left: '-9999px'};
|
el.style = {position: 'absolute', left: '-9999px'};
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
// Select text inside element
|
// Select text inside element
|
||||||
el.select();
|
el.select();
|
||||||
// Copy text to clipboard
|
// Copy text to clipboard
|
||||||
document.execCommand('copy');
|
document.execCommand('copy');
|
||||||
// Remove temporary element
|
// Remove temporary element
|
||||||
document.body.removeChild(el);
|
document.body.removeChild(el);
|
||||||
}
|
}
|
||||||
|
@ -631,6 +631,7 @@ Rails.application.routes.draw do
|
|||||||
get :analyse_reponses
|
get :analyse_reponses
|
||||||
post :analyse_reponses_save
|
post :analyse_reponses_save
|
||||||
get :generate_final_consult
|
get :generate_final_consult
|
||||||
|
get :buy_order_create
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get :search_to_affect
|
get :search_to_affect
|
||||||
|
Reference in New Issue
Block a user