This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.

492 lines
20 KiB
Plaintext

.qi_header
.right
-if @price_document.price_document_type_id == 1
=#link_to ic("bar-chart")+" analyse des réponses", analyse_reponses_admin_price_document_path(@price_document), class: "btn btn-primary"
-if @price_document.price_document_type_id == 6 and !@price_document.stock_ok
= link_to i(:pencil), edit_admin_price_document_path(:id => @price_document.id, :public_edit => true) if !@price_document.stock_ok
= diag do
= link_to i(:pencil), edit_admin_price_document_path(@price_document)
= link_to i(:eye), admin_price_document_path(@price_document.id), :remote => false, :target => "_blank"
= link_to i(:download), print_admin_price_document_path(@price_document.token), :remote => false, :target => "_blank" if !PriceLineBlock::PURCHASE_BLOCKS.include?(@price_document.block_type)
=breadcrumb first_title: "Commandes", second_title: @price_document.label, second_link: admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id), record: @price_document.d_number
.qi_row
=#debug @price_document.price_line_block.price_lines.count
%table.table.table-striped
-if @price_document.label == "Réponse fournisseur"
%tr
%td
Nom fournisseur saisi
%td
=@price_document.public_fournisseur_name
-if @price_document.p_fournisseur
%tr
%td
Fournisseur
%td
=link_to @price_document.p_fournisseur.name, [:admin, @price_document.p_fournisseur] if @price_document.p_fournisseur
-if @price_document.d_number?
%tr
%td Numéro
%td=@price_document.d_number
%tr
%td Date
%td=l @price_document.date, :format => :date
-if @price_document.label == "Demande prix"
%tr
%td
Avancement (%)
%td
=@price_document.avancement.to_s + " %"
%tr
%td
Désignation
%td
=@price_document.list_designaton
%tr
%td Date de fin de consultation :
%td
=l @price_document.end_date if @price_document.end_date
%tr
%td Commentaire
%td
=simple_format @price_document.dp_comment
%tr
%td
Envoyé à
%td
=simple_format @price_document.acheteur_text
%tr
%td
Lien pour consultation
%td
=link_to consult_admin_price_document_url(:id => @price_document.f_token, :lang => nil), consult_admin_price_document_url(:id => @price_document.f_token, :lang => nil)
.qi_row
.qi_pannel.qi_plain.padding
-if false
=debug @price_document
-if true
-price_line_block = @price_document.price_line_block
=#render price_line_block
-else
-params[:search][:per_page] = params[:search][:per_page] || 5000
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@price_lines = @price_document.price_line_block.price_lines
-@price_lines = sort_by_sorting(@price_lines, "created_at DESC")
-@price_lines = @price_lines.page(page).per(per_page)
%br
.clear
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_lines, :key => "reponses-prix-show"}
-if @price_document.label != "Demande prix" and @price_document.label != "Réponse fournisseur"
-if current_admin and current_admin.id == 1
-enable_stat = false
-if enable_stat
%table.table
%tr
%th Archivé ?
%td
= diag do
-if @price_document.archived
Oui
=link_to "Désarchiver", unarchive_now_admin_price_document_path(@price_document.id)
-else
=link_to "Archiver", archive_now_admin_price_document_path(@price_document.id)
%tr
%th Id bloc
%td=price_line_block.id
%tr
%th Cout block
%td=price_line_block.cc_cost_ht
-params[:search][:per_page] = params[:search][:per_page] || 5000
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@stat_lines = @price_document.stat_lines.order("date DESC, created_at DESC")
-@stat_lines = sort_by_sorting(@stat_lines, "created_at DESC")
-@stat_lines = @stat_lines.page(page).per(per_page)
%br
=link_to "Générer les stats", generate_stat_lines_admin_price_document_path(@price_document), :class => "btn btn-primary"
%table.table
%tr
%th
HT
%td
=number_to_currency @stat_lines.sum(:tot_amount_ht)
%tr
%th
TTC
%td
=number_to_currency @stat_lines.sum(:tot_amount_ttc)
%tr
%th
Coût HT
%td
=number_to_currency @stat_lines.sum(:cost_ht)
.clear
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @stat_lines}
%h3 Lignes de produits
.mb-3
- if @price_document.cc_label == "Consultation fournisseur"
= link_to ic(:clipboard) + " Copier le texte", "#", 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
%thead
%tr
%th ID
%th Référence
%th Marque
%th Désignation
%th Qté
%th Qté saisie
%th P.U. HT
%th TVA
%th Montant HT
%th Actions
-price_line_block.price_lines.each do |price_line|
%tbody
%tr{id: "price_line_row_#{price_line.id}"}
%td{style: "background-color: #{id_color(price_line)}", id: "price_line_#{price_line.id}_id", onclick: "$('.p_articles_#{price_line.id}').toggle('800','swing');"}
="##{price_line.id}"
%td
=price_line.ref
%td
=price_line.p_product_ref.p_product.s_brand.name
%td{id: "price_line_#{price_line.id}_p_product_ref_cc_name"}
=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{id: "price_line_#{price_line.id}_qte"}
=price_line.qte
%td.numeraire{id: "price_line_#{price_line.id}_affected_qty"}
=price_line.affected_qty
%td.numeraire{id: "price_line_#{price_line.id}_price_u_ht"}
=number_to_currency price_line.price_u_ht
%td.numeraire
=price_line.tva_account_value.to_s+"%"
%td.numeraire
=number_to_currency price_line.tot_amount_ht
%td.actions
= link_to i(:"trash-o"), admin_price_line_path(price_line), method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_price_line_path(price_line), :remote => true
= link_to i(:eye), admin_price_line_path(price_line), :remote => true
= link_to i(:"mobile-alt"), add_p_article_admin_price_lines_path(p_product_ref_id: price_line.p_product_ref.id, price_line_id: price_line.id), :remote => true if @price_document.price_document_type_id != 6 and price_line.p_product_ref.p_product.stockable and price_line.p_product_ref.p_product.with_serial_number and !price_line_block.stock_ok
= i(:"mobile-alt", {style: "color: rgb(143 143 143 / 80%)"}) if price_line_block.stock_ok
-price_line.p_articles.each do |p_article|
%tr{class: "p_articles_lines p_articles_#{price_line.id}"}
%td
%td="##{p_article.id}"
%td=p_article.p_product_ref.name
%td
- p_article.p_article_serial_nums.each do |sn|
="#{sn.p_serial_num_type.name} - #{sn.value} /"
.qi_row
-if current_admin.has_permission?("show-costs")
%p
-if @price_document.price_document_type_id == 6 #"Facture achat"
-# =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok and @price_document.stock_generable
-# =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok and !@price_document.stock_generable
=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok if @qty_in_br >= @qty_to_reach
=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok if @qty_in_br < @qty_to_reach
-elsif @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5
-# %p
-# Coût :
-# =number_to_currency @price_document.cost_ht
-# %p
-# Marge :
-# =number_to_currency @price_document.marge_ht
-if !@price_document.cost_ok
=link_to "Mettre à jour les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary", id: "generate_stock_button_price_document_#{@price_document.id}" if !@price_document.stock_ok and @price_document.stock_generable
=link_to "Mettre à jour les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary disabled", id: "generate_stock_button_price_document_#{@price_document.id}" if !@price_document.stock_ok and !@price_document.stock_generable
-if @price_document.d_number
-if @price_document.cc_label == "Commande achat"
%p=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary"
%p=link_to "Générer la facture", facture_achat_admin_price_document_path(@price_document), :class => "btn btn-primary"
-if @facture_achat_childrens.present?
%h3 Facture Achat
-params[:search][:per_page] = params[:search][:per_page] || 5000
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@facture_achat_childrens = @facture_achat_childrens.order("date DESC, created_at DESC")
-#@line_stocks = sort_by_sorting(@line_stocks, "created_at DESC")
-@facture_achat_childrens = @facture_achat_childrens.page(page).per(per_page)
%br
.clear
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @facture_achat_childrens}
-if @price_document.cc_label == "Commande achat"
=render :partial => "admin/price_documents/relicats", :locals => {:bca => @price_document}
-if false
-if @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 and !@price_document.cost_ok
%table.table.table-striped.table-hover.table-bordered
%thead
%tr
%th Produit
%th Quantité dans cette pièce comptable
%th Quantité restante
%th
-@price_document.price_line_block.price_lines.all.each do |pl|
-if pl.p_product_ref
-if pl.p_product_ref.assembled
-pl.p_product_ref.p_product_assembleds.all.each do |ppa|
%tr
%td
=ppa.p_product_ref.cc_name
%td
=@a = (pl.qte.to_f * ppa.qte.to_f).to_f
%td
=link_to admin_line_stocks_path(:p_product_ref_id => ppa.p_product_ref.id) do
=@b = LineStock.where(:p_product_ref_id => ppa.p_product_ref_id).sum(:qte_available).to_f
%td
-if @a > @b
.red=ic :warning
-else
%tr
%td
=pl.p_product_ref.cc_name
%td
=@a = pl.qte.to_f
%td
=link_to admin_line_stocks_path(:p_product_ref_id => pl.p_product_ref.id) do
=@b = LineStock.where(:p_product_ref_id => pl.p_product_ref_id).sum(:qte_available).to_f
%td
-if pl.p_product_ref.stocked and @a > @b
.red=ic :warning
-if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5
-if @price_document.price_line_block.stock_ok
%h3 Stocks générés
#bills
-params[:search][:per_page] = params[:search][:per_page] || 5000
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@line_stocks = @price_document.line_stocks.order("date DESC, created_at DESC")
-if params[:price_document_ids]
-@line_stocks = @line_stocks.where(:id => params[:price_document_ids])
-@line_stocks = sort_by_sorting(@line_stocks, "created_at DESC")
-@line_stocks = @line_stocks.page(page).per(per_page)
%br
.clear
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @line_stocks}
-if @price_document.price_line_block.br_ok
%h3 Bons de reception générés
#bills
-params[:search][:per_page] = params[:search][:per_page] || 5000
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@price_documents = PriceDocument.where(facture_achat_id: @price_document.id).order("date DESC, created_at DESC")
-# -if params[:price_document_ids]
-# -@line_stocks = @line_stocks.where(:id => params[:price_document_ids])
-@price_documents = sort_by_sorting(@price_documents, "created_at DESC")
-@price_documents = @price_documents.page(page).per(per_page)
%br
.clear
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents}
-if @price_document.label == "Demande prix"
%h3.ml-2 Réponses fournisseur
#bills
-params[:search][:per_page] = params[:search][:per_page] || 5000
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Réponse fournisseur").id)
-@price_documents = sort_by_sorting(@price_documents, "created_at DESC")
-@price_documents = @price_documents.page(page).per(per_page)
%br
.clear
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"}
-@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Consultation fournisseur").id)
%h3.ml-2 Consultations fournisseur :
#consult
-if @price_documents.empty?
.qi_pannel.qi_plain.padding
Pas de consultation générée.
%br
Vous devez d'abord Selectionner les prix sur le page d'analyse :
=link_to ic("bar-chart")+" analyse des réponses", analyse_reponses_admin_price_document_path(@price_document), class: "btn btn-primary"
puis Generer les consultations
-@price_documents.each do |price_document_consult|
- if price_document_consult.p_fournisseur
%h4.ml-2= price_document_consult.p_fournisseur.name
- else
%h4.ml-2=link_to ic('pencil') + " rapprocher le fournisseur", match_p_fournisseur_admin_price_document_path(price_document_consult), remote: true
= 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"
= link_to ic(:clipboard) + " Copier le texte", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)'
- existing_order = PriceDocument.where(doc_ref_id: price_document_consult.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_consult), class: "btn btn-primary"
.price-lines{"data-document" => price_document_consult.id}
=form.semantic_fields_for :price_line_block do |f|
.mx-2
=f.semantic_fields_for :price_lines do |form|
=render partial: "admin/price_lines/form_consult", locals: {form: form}
-params[:search][:per_page] = params[:search][:per_page] || 5000
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Consultation fournisseur").id)
-@price_documents = sort_by_sorting(@price_documents, "created_at DESC")
-@price_documents = @price_documents.page(page).per(per_page)
%br
%h4.ml-2 Liste des consultations fournisseurs
.clear
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"}
:javascript
$('.p_articles_lines').hide();
const copyPriceLines = (event) => {
event.preventDefault()
let priceDocumentId = event.target.dataset.document
let names = $(`.p_product_ref_cc_name_${priceDocumentId}`)
let qtes_input = $(`.input_price_line_qte_${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'))
}
function copyStringToClipboard (str) {
// Create new element
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);
}