p_customer_sheet Export xls
This commit is contained in:
parent
30ad9d661d
commit
c74863ad27
@ -282,6 +282,10 @@ class Admin::PCustomerSheetsController < ApplicationController
|
||||
|
||||
def export_xls
|
||||
@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|
|
||||
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"]
|
||||
|
@ -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_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},
|
||||
:check_box => {:name => "Export excel", :reorder => false},
|
||||
:actions => {:name => "Actions", :reorder => false},
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,9 @@
|
||||
%td.numeraire
|
||||
=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
|
||||
%td.actions
|
||||
|
@ -179,5 +179,61 @@
|
||||
="-"
|
||||
=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"}
|
||||
×
|
||||
.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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user