p_customer_sheet Export xls

This commit is contained in:
Barnabé 2021-09-20 19:13:46 +02:00
parent 30ad9d661d
commit c74863ad27
4 changed files with 67 additions and 4 deletions

View File

@ -282,6 +282,10 @@ class Admin::PCustomerSheetsController < ApplicationController
def export_xls def export_xls
@p_customer_sheets = PCustomerSheet.all @p_customer_sheets = PCustomerSheet.all
if params[:p_customer_sheet_ids].present?
@p_customer_sheets = PCustomerSheet.where(id: params[:p_customer_sheet_ids])
end
respond_to do |format| respond_to do |format|
format.csv { format.csv {
@headers = ["BUID", "DATE", "NUMERO", "CLIENT", "REFERENCE", "EAN", "DESIGNATION", "QTE", "PRIX 1", "PRIX 2", "DEEE", "SORECOP", "FOURNISSEUR", "CODE ARTICLE MAG", "NomMarque", "Code Douanier", "Type SORECOP"] @headers = ["BUID", "DATE", "NUMERO", "CLIENT", "REFERENCE", "EAN", "DESIGNATION", "QTE", "PRIX 1", "PRIX 2", "DEEE", "SORECOP", "FOURNISSEUR", "CODE ARTICLE MAG", "NomMarque", "Code Douanier", "Type SORECOP"]

View File

@ -40,6 +40,7 @@ class PCustomerSheet < ApplicationRecord
:tot_amount_ht => {:name => "Total HT", :reorder => true, :sort_name => "cc_tot_amount_ht", :sort_name => "p_customer_sheets.cc_tot_amount_ht"}, :tot_amount_ht => {:name => "Total HT", :reorder => true, :sort_name => "cc_tot_amount_ht", :sort_name => "p_customer_sheets.cc_tot_amount_ht"},
:tot_amount_ttc => {:name => "Total TTC", :reorder => true, :sort_name => "cc_tot_amount_ttc", :sort_name => "p_customer_sheets.cc_tot_amount_ttc"}, :tot_amount_ttc => {:name => "Total TTC", :reorder => true, :sort_name => "cc_tot_amount_ttc", :sort_name => "p_customer_sheets.cc_tot_amount_ttc"},
:state => {:name => "Statut", :reorder => false, :as => :state}, :state => {:name => "Statut", :reorder => false, :as => :state},
:check_box => {:name => "Export excel", :reorder => false},
:actions => {:name => "Actions", :reorder => false}, :actions => {:name => "Actions", :reorder => false},
} }

View File

@ -43,9 +43,11 @@
-tr[:tot_amount_ttc] = capture do -tr[:tot_amount_ttc] = capture do
%td.numeraire %td.numeraire
=number_to_currency p_customer_sheet.cc_tot_amount_ttc =number_to_currency p_customer_sheet.cc_tot_amount_ttc
-tr[:check_box] = capture do
%td
=check_box_tag "p_customer_sheet_ids[]", p_customer_sheet.id, false, data: { client: p_customer_sheet.p_customer.id }, id: "p_customer_sheet_id_checkbox_#{p_customer_sheet.id}"
-tr[:actions] = capture do -tr[:actions] = capture do
%td.actions %td.actions
-if p_customer_sheet.state == "brouillon" and p_customer_sheet.demande_type.to_s == "Brouillon" -if p_customer_sheet.state == "brouillon" and p_customer_sheet.demande_type.to_s == "Brouillon"

View File

@ -179,5 +179,61 @@
="-" ="-"
=link_to ic(:times)+" Supprimer ce filtre", params.permit!.merge({ :active_kpi => nil, :p_customer_sheet_ids => nil}) =link_to ic(:times)+" Supprimer ce filtre", params.permit!.merge({ :active_kpi => nil, :p_customer_sheet_ids => nil})
%div
=form_tag export_xls_admin_p_customer_sheets_path(format: :csv), id: 'export-form', :method => "get" do
.table
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_customer_sheets}
%button.btn.btn-primary.ml-4{onclick: "checkMultipleClient()"}
=ic("file-excel-o")
Export Xls
.modal.fade#multi-client-export{"tab-index" => "-1", "role" => "dialog", "aria-labelledby" => "Raprochement Fournisseur", "aria-hidden" => "true"}
.modal-dialog{role: "dialog"}
.modal-content
.modal-header
%h5.modal-title
Export Excel
%button.close{"data-dismiss" => "modal", "aria-label" => "Close"}
%span{"aria-hidden" => "true"}
&times;
.modal-body
Attention !
%br
%br
Selection de plusieurs clients détécté
%br
Vous avez selectionné des commandes liées à différents clients.
%br
Etes-vous sûr ?
.modal-footer
%button.btn.btn-light{"data-dismiss" => "modal"}
Annuler l'export
%button.btn.btn-primary{"data-dismiss" => "modal", onclick: "submitExport()"}
=ic("file-excel-o")
Confirmer
:javascript
function submitExport() {
$('#export-form').submit()
}
function checkDiff(arr) {
return arr.every(e => e == arr[0]);
}
const checkMultipleClient = () => {
let arr = []
$('.table input[type=checkbox]').each(function( i ) {
if ( this.checked === true)
arr.push($(this).data('client'))
})
if (checkDiff(arr) === false) {
$('#multi-client-export').modal('show')
} else {
submitExport()
}
}
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_customer_sheets}