$(document).on(this.fluidbook.input.clickEvent, '#Bastide_cart [data-validate-cart]', function (event) {
event.preventDefault();
- // Use the built-in HTML5 validation to make sure all fields are valid in the cart
- let form = $(this).parents('form');
- let isValid = form[0].reportValidity();
-
- if (isValid) {
- // Originally this was in the link's href but for some reason the validation was
- // skipped and the URL change would always occur, even when using
- // event.preventDefault() / event.stopImmediatePropagation / event.stopPropagation();
- window.location.hash = '/cart/validate';
- }
+ $.ajax('https://bastide-resah.fluidbook.com/fluidbook/order', {
+ method: 'POST',
+ data: {details:$this.getItems()},
+ });
+
+ $this.fluidbook.menu.quickCloseView();
+ $this.openModal("Merci !", '<div class="cart-sent">Vous recevrez un devis ainsi que les conditions générales de vente de la part du RESAH à l’adresse mail que vous avez mentionnée dans un délai d’environ 72h (pensez à vérifier votre dossier spam).<br><br>' +
+ 'La validation de ce devis auprès du RESAH nécessitera l’établissement et l’envoi au RESAH d’un bon de commande valant pour acceptation pleine et entière.<br><br>' +
+ 'Nos équipes commerciales se tiennent à votre disposition : <a href="mailto:resah@bastide-medical.fr">resah@bastide-medical.fr</a></div>', function () {
+
+ });
+
});
},
- // emptyCart: function () {
- // this.items = [];
- // this.updateCart();
- // this.save();
- // resize();
- // },
getCartItemIndex: function (reference) {
let cartItems = this.getItems();
return this.getItems().length;
},
- getItemsForXLS: function () {
- let $this = this;
- let items = [];
-
- $.each(this.getItems(), function (index, cart_item) {
-
- let item = {};
- let cart_reference = cart_item['reference'];
- let data = $this.data[cart_reference]; // Source data matched from spreadsheet
-
- $.each($this.getColumnsForXLS(), function (key, title) {
-
- switch (key) {
- case 'QUANTITY':
- item[key] = cart_item['quantity'];
- break;
- default:
- item[key] = data[key];
- }
- });
-
- items.push(item);
- });
-
- return items;
- },
-
updateCart: function () {
if ($('#Bastide_cart').length > 0) {
$('#Bastide_cart .content').html(this.getCartContent());
</div>
</div>`;
this.fluidbook.menu.viewWrap(view, 'cart');
+ this.fluidbook.menu.openingView(function () {
+
+ }, 'cart');
callback();
},
openMenu: function (p1, p2, callback) {
-
this.fluidbook.menu.quickCloseView();
- // Handle the validation screen when accessed via #/cart/validate
- if (p1 === 'validate') {
- return this.openCartUserDetails(callback);
- }
-
// The cart opens every time an item is added, so the user can pick a colour and quantity
// These URLs use the #/cart/add/xxxxx URL to pass the reference across
if (p1 === 'add' && p2) {
});
},
- openCartUserDetails: function (callback) {
- $('html').removeClass('cart-form-visible'); // Make sure forms are hidden initially
- this.openModal('Mes Coordonnées', this.getCartUserDetailsContent(), function () {
- callback();
- });
- },
-
getColumns: function () {
- // Map of data key names to their display labels - this controls the order of the columns
- // Note: the key names here should match the first row column titles in the spreadsheet
- // This can be overridden by specifying the cart_columns in the "Paramètres panier" field (cartExtraSettings)
- // The format for the setting is:
- // cart_columns=XLS COL NAME|Display label,XLS COL 2|Display label 2
- if (fluidbook.settings.cartColumns) {
- return fluidbook.settings.cartColumns;
- }
-
return {
- 'ARTICLE CODE': 'Réf',
- 'ARTICLE': 'Article',
- 'CONDITIONNEMENT VENTE': 'Conditionnement',
- 'QUANTITY': 'Quantité', // Special case: not part of the data
- 'DELETE': '', // No column label for delete buttons
+ 'CIP': 'CIP',
+ 'REF RESAH': 'Référence RESAH',
+ 'DESIGNATION': 'DESIGNATION',
+ 'PV RESAH HT': 'Prix unitaire HT',
+ 'TVA': 'Taux de TVA',
+ 'ECOTAXE': 'éco Taxe',
+ 'QUANTITY': 'Quantité',
+ 'TOTAL_HT': 'Total HT',
+ 'DELETE': '',
};
},
- getColumnsForXLS: function () {
- // The columns should be the same as for the cart except we skip "DELETE"
- let columns = {};
-
- $.each(this.getColumns(), function (key, title) {
-
- if (key === 'DELETE') return;
-
- columns[key] = title;
- });
-
- return columns;
+ getMenuHeight: function () {
+ return this.fluidbook.resize.hh * 0.95;
},
- // This cart was based off CFOC's, so we're keeping the structure where it's possible to have multiple forms
- getForms: function () {
- return {
- 'default': {
- 'name': {
- 'label': "Nom et Prénom",
- 'type': 'text',
- 'required': true
- },
- 'phone': {
- 'label': "Téléphone",
- 'type': 'text',
- 'required': true
- },
- 'email': {
- 'label': "Email",
- 'type': 'email',
- 'required': true
- },
- 'billing_address': {
- 'label': "Adresse de facturation",
- 'type': 'textarea',
- 'rows': 2,
- 'required': false
- },
- 'message': {
- 'label': "Message",
- 'type': 'textarea',
- 'rows': 3,
- 'required': false
- },
- },
- }
+ getMenuWidth: function () {
+ return $('.cart-sent').length > 0 ? 440 : 1385;
},
getCartContent: function () {
return `<div class="cart-empty">${this.fluidbook.l10n.__('your cart is empty')}</div>`;
}
+ let total_ht;
+ let tva;
+ let eco_taxe;
+ let total_ttc = total_ht = tva = eco_taxe = 0;
+
let $this = this;
let columns = this.getColumns();
- let content =
- `<div class="inner-content">
+ let content = `<div class="inner-content">
<form>
<table id="bastide-cart-table" class="cart-items">
<thead style="text-transform:uppercase">
<tr>
${Object.entries(columns)
- .map(heading => `<th data-name="${heading[0]}">${heading[1]}</th>`)
- .join('')
- }
+ .map(heading => `<th data-name="${heading[0]}">${heading[1]}</th>`)
+ .join('')}
</tr>
</thead>
<tbody>`;
let value = data[key] || '—'; // Fallback for missing values
let output = '';
- switch (key) {
+ let et = $this.parseFloat($this.data[item.reference]['ECOTAXE']);
+ let ht = $this.parseFloat($this.data[item.reference]['PV RESAH HT']) + et;
+ let tht = item.quantity * ht;
+
+ total_ht += tht;
+ eco_taxe += item.quantity * et;
+ tva += $this.parseFloat($this.data[item.reference]['TVA']) * tht * 0.01;
- case 'PRIX':
- output += $this.formatPrice(value);
+ switch (key) {
+ case 'PV RESAH HT':
+ case 'ECOTAXE':
+ output = $this.formatPrice($this.parseFloat(value));
+ break;
+ case 'TOTAL_HT':
+ output += $this.formatPrice(tht);
break;
case 'QUANTITY':
let min_quantity = 1;
content += '</tr>';
});
+ total_ttc = tva + eco_taxe + total_ht;
+
content += '</tbody>';
content += '</table>';
+
+ content += '</form>';
+
+ content += '<hr>';
+
+ content += '<table class="totals">';
+ content += '<tr><td>Montant HT : </td><td>' + this.formatPrice(total_ht) + '</td></tr>';
+ content += '<tr><td>TVA : </td><td>' + this.formatPrice(tva) + '</td></tr>';
+ content += '<tr><td>éco Taxe : </td><td>' + this.formatPrice(eco_taxe) + '</td></tr>';
+ content += '<tr><td>Montant TTC : </td><td>' + this.formatPrice(total_ttc) + '</td></tr>';
+ content += '</table>';
+
+ content += '<div class="clear"></div>';
+
content += `<div class="fonctions">
<a href="#/closeview" class="close-cart">
Compléter ma sélection
</a>
<a href="#" class="validate-cart" data-validate-cart>
- Valider ma Sélection
+ Envoyer ma demande
</a>
</div>`;
- content += '</form>';
- content += '</div><!-- .inner-content -->';
+ content += '<div class="clear"></div>'
- return content;
- },
-
- getCartUserDetailsContent: function () {
-
- let forms = '';
-
- $.each(this.getForms(), function (name, fields) {
- forms += `<form data-name="${name}">`;
-
- $.each(fields, function (field_name, field_details) {
- let required = field_details.required ? 'required' : '';
- let label = field_details.required ? `${field_details.label}*` : field_details.label;
- let field_ID = `${name}_${field_name}`;
-
- forms += `<label for="${field_ID}">${label}</label>`;
-
- switch (field_details.type) {
- case 'textarea':
- forms += `<textarea id="${field_ID}" name="${field_name}" rows="${field_details.rows || 3}" ${required}></textarea>`
- break;
- default:
- forms += `<input id="${field_name}" name="${field_name}" type="${field_details.type}" ${required}>`;
- }
- });
-
- forms += `</form>`;
- });
-
- let content =
- `<div class="inner-content" id="Bastide_user_details">
- <div class="details-form">
- ${forms}
- <div class="required-fields-notice">*Champs obligatoires</div>
- </div><!-- .details-columns -->
- <div class="details-footer fonctions">
- <a href="#/cart" class="back-to-cart">
- Retour à ma Sélection
- </a>
- <a href="#" class="send-cart" data-send-cart>Envoyer ma demande</a>
- </div><!-- .details-footer -->
- <div class="server-response" style="display:none"><!-- placeholder for AJAX response --></div>
- </div><!-- .inner-content -->
- `;
+ content += '<p class="legal">Ce portail vous permet d’obtenir un document quantitatif estimatif.<br>'
+ + 'Vous recevrez un devis ainsi que les conditions générales de vente de la part du RESAH à l’adresse mail que vous avez mentionné dans un délai d’environ 72H.<br>' + 'La validation de ce devis auprès du RESAH nécessitera l’établissement et l’envoi au RESAH d’un bon de commande valant pour acceptation pleine et entière.<br>'
+ + 'Nos équipes commerciales se tiennent à votre disposition : <a href="mailto:resah@bastide-medical.fr">resah@bastide-medical.fr</a></p>';
+ content += '</div><!-- .inner-content -->';
return content;
},
- getMenuWidth: function () {
- return window.location.hash === '#/cart/validate' ? 990 : 1190; // Validate modal is narrower than main cart
- },
formatPrice: function (price) {
}
return price.toLocaleString("fr-FR", {
- style: "currency",
- currency: "EUR",
- minimumFractionDigits: 2,
- maximumFractionDigits: 2
+ style: "currency", currency: "EUR", minimumFractionDigits: 2, maximumFractionDigits: 2
});
},
return 0;
}
s = s.replace(/\s/g, '');
+ s = s.replace(/,/g, '');
return parseFloat(s);
},
};