}
return false;
});
+ $(document).on(this.fluidbook.input.clickEvent, '.exportEANXLS', function () {
+ try {
+ $this.exportEANXLS();
+ } catch (err) {
+ console.log(err);
+ }
+ return false;
+ });
$(document).on(this.fluidbook.input.clickEvent, '.emptyCart', function () {
$.confirm({
this.fluidbook.cache.set('cart', this.getItems());
this.fluidbook.cart.updateLinks();
},
+
getItemsReferences: function () {
return this.getItems();
},
+
getItemsNumbers: function () {
return this.getItems().length;
},
+
getAllQuantities: function () {
return this.getItemsNumbers();
},
return ['Image', 'Catalogue', 'Catégorie', 'Ligne', 'Sexe', 'Modèle', 'Couleur', 'Désignation', 'Tailles', 'Tarif', 'PVC', 'PACK'];
},
-
getItems: function () {
var res = [];
var $this = this;
content += '</tbody>';
content += '</table>';
content += '<div class="cart-footer">';
- content += '<div class="fonctions"><a href="#" class="emptyCart">Empty my cart</a><a href="#" class="exportCartPDF">Export my cart (PDF)</a><a href="#" class="exportCartXLS">Export my cart (XLS)</a></div>';
+ var ean = '';
+ if (this.fluidbook.settings.eanReferences) {
+ ean = '<a href="#" class="exportEANXLS">EAN Export (XLS)</a>';
+ }
+ content += '<div class="fonctions"><a href="#" class="emptyCart">Empty my cart</a><a href="#" class="exportCartPDF">Export (PDF)</a><a href="#" class="exportCartXLS">Export (XLS)</a>' + ean + '</div>';
content += '</div>';
return content;
},
+
exportPDF: function () {
var element = $('#pumacarttable').get(0);
}, 2000);
},
- getExportFileName: function () {
+ getExportFileName: function (label) {
+ if (label === undefined) {
+ label = 'Cart';
+ }
var date = new Date();
- return this.fluidbook.settings.title + ' - Cart - ' + date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate();
+ return this.fluidbook.settings.title + ' - ' + label + ' - ' + date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate();
+ },
+
+ exportEANXLS: function () {
+ var $this = this;
+ const workbook = new ExcelJS.Workbook();
+ const sheet = workbook.addWorksheet(this.fluidbook.settings.title);
+ sheet.views = [
+ {state: 'frozen', xSplit: 0, ySplit: 1, topLeftCell: 'A2', activeCell: 'A2'}
+ ];
+ sheet.properties.defaultRowHeight = 15;
+ var columnsLabels = ['Reference', 'Size Description', 'EAN13', 'Season Description', 'Rbu', 'Family', 'Article', 'Model Id', 'Color Id'];
+ var columns = [];
+
+ $.each(columnsLabels, function (k, v) {
+ columns.push({
+ header: v,
+ key: v,
+ numFmt: '@',
+ style: {numFmt: '@', alignment: {vertical: 'middle', horizontal: 'left'}},
+ width: 25,
+ });
+ });
+
+ sheet.columns = columns;
+ $.each(this.getItems(), function (i, ref) {
+ $.each($this.fluidbook.settings.eanReferences, function (k, v) {
+ if (v.Reference === ref) {
+ var row = {};
+ $.each(columnsLabels, function (kk, vv) {
+ row[vv] = v[vv];
+ });
+ sheet.addRow(row);
+ }
+ });
+ });
+ $.each(columnsLabels, function (k, v) {
+ sheet.getColumn(k + 1).numFmt = '@';
+ });
+
+ workbook.xlsx.writeBuffer().then(function (data) {
+ var blob = new Blob([data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
+ const url = window.URL.createObjectURL(blob);
+ const anchor = document.createElement('a');
+ anchor.href = url;
+ anchor.download = $this.getExportFileName('EAN') + '.xlsx';
+ anchor.click();
+ window.URL.revokeObjectURL(url);
+ });
},
exportXLS: function () {