From: Vincent Vanwaelscappel Date: Mon, 22 Apr 2024 16:22:27 +0000 (+0200) Subject: wip #6875 @4 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=36c760d36bfce9b7d6c83f786a831d39a1c4d880;p=fluidbook-html5.git wip #6875 @4 --- diff --git a/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah.js b/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah.js index dad3fdd8..e328558e 100644 --- a/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah.js +++ b/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah.js @@ -31,25 +31,21 @@ FluidbookCartBastideResah.prototype = { $(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 !", '
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).

' + + '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.

' + + 'Nos équipes commerciales se tiennent à votre disposition : resah@bastide-medical.fr
', function () { + + }); + }); }, - // emptyCart: function () { - // this.items = []; - // this.updateCart(); - // this.save(); - // resize(); - // }, getCartItemIndex: function (reference) { let cartItems = this.getItems(); @@ -115,33 +111,6 @@ FluidbookCartBastideResah.prototype = { 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()); @@ -161,18 +130,15 @@ FluidbookCartBastideResah.prototype = { `; 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) { @@ -187,79 +153,26 @@ FluidbookCartBastideResah.prototype = { }); }, - 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 () { @@ -267,19 +180,22 @@ FluidbookCartBastideResah.prototype = { return `
${this.fluidbook.l10n.__('your cart is empty')}
`; } + 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 = - `
+ let content = `
${Object.entries(columns) - .map(heading => ``) - .join('') - } + .map(heading => ``) + .join('')} `; @@ -294,10 +210,21 @@ FluidbookCartBastideResah.prototype = { 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; @@ -340,72 +267,44 @@ FluidbookCartBastideResah.prototype = { content += ''; }); + total_ttc = tva + eco_taxe + total_ht; + content += ''; content += '
${heading[1]}${heading[1]}
'; + + content += '
'; + + content += '
'; + + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += '
Montant HT : ' + this.formatPrice(total_ht) + '
TVA : ' + this.formatPrice(tva) + '
éco Taxe : ' + this.formatPrice(eco_taxe) + '
Montant TTC : ' + this.formatPrice(total_ttc) + '
'; + + content += '
'; + content += ``; - content += ''; - content += '
'; + content += '
' - return content; - }, - - getCartUserDetailsContent: function () { - - let forms = ''; - - $.each(this.getForms(), function (name, fields) { - forms += `
`; - - $.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 += ``; - - switch (field_details.type) { - case 'textarea': - forms += `` - break; - default: - forms += ``; - } - }); - - forms += `
`; - }); - - let content = - `
-
- ${forms} -
*Champs obligatoires
-
- - -
- `; + content += ''; + content += '
'; return content; }, - getMenuWidth: function () { - return window.location.hash === '#/cart/validate' ? 990 : 1190; // Validate modal is narrower than main cart - }, formatPrice: function (price) { @@ -414,10 +313,7 @@ FluidbookCartBastideResah.prototype = { } return price.toLocaleString("fr-FR", { - style: "currency", - currency: "EUR", - minimumFractionDigits: 2, - maximumFractionDigits: 2 + style: "currency", currency: "EUR", minimumFractionDigits: 2, maximumFractionDigits: 2 }); }, @@ -429,6 +325,7 @@ FluidbookCartBastideResah.prototype = { return 0; } s = s.replace(/\s/g, ''); + s = s.replace(/,/g, ''); return parseFloat(s); }, }; diff --git a/js/libs/fluidbook/fluidbook.cart.js b/js/libs/fluidbook/fluidbook.cart.js index a70c0ce9..9343682d 100644 --- a/js/libs/fluidbook/fluidbook.cart.js +++ b/js/libs/fluidbook/fluidbook.cart.js @@ -187,11 +187,24 @@ FluidbookCart.prototype = { return 1024; }, + getMenuHeight: function () { + try { + return this.instance.getMenuHeight(); + } catch (e) { + + } + return this.fluidbook.resize.hh * 0.8; + }, + getSavedData: function () { return this.fluidbook.cache.get('cart', {}) - }, saveData: function (data) { + }, + + saveData: function (data) { this.fluidbook.cache.set('cart', data); - }, createInstance: function () { + }, + + createInstance: function () { switch (this.fluidbook.settings.basketManager) { case "Remarkable": return new FluidbookCartRemarkable(this); diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index e0b1b4e2..3708eea5 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -891,6 +891,7 @@ FluidbookMenu.prototype = { break; case 'cart': w = this.fluidbook.cart.getMenuWidth(); + h=this.fluidbook.cart.getMenuHeight(); if (ww < w) { fullscreen = true; } diff --git a/style/cart/bastide-resah-cart.less b/style/cart/bastide-resah-cart.less index 2aba15bb..5b6d24ca 100644 --- a/style/cart/bastide-resah-cart.less +++ b/style/cart/bastide-resah-cart.less @@ -34,6 +34,22 @@ min-width: 320px; font-size: 18px; + .cart-sent { + padding: 20px 50px; + font-size: 16px; + text-align: left; + + a { + color: @menu-background !important; + text-decoration: underline; + } + } + + * { + font-family: 'Roboto Condensed', sans-serif !important; + } + + @media (max-width: 1060px) { font-size: 15px; } @@ -45,7 +61,7 @@ } .caption { - padding: 30px 20px; + padding: 30px 35px 30px 35px; height: auto; } @@ -60,11 +76,44 @@ margin: 0 auto; position: relative; + p.legal { + clear: both; + font-size: 12px; + text-align: left; + padding: 30px 0; + + a { + color: @menu-background; + text-decoration: underline; + } + } + @media @breakpoint_table { width: 90%; } } + hr { + margin: 20px 0; + } + + + .totals { + float: right; + width: 33%; + font-size: 14px; + + td { + text-transform: uppercase; + text-align: right; + padding: 5px; + } + + tr:last-child td { + font-weight: bold; + } + } + // Main table table.cart-items { width: 100%; @@ -84,7 +133,7 @@ th { color: #fff; font-weight: bold; - text-align: left; + text-align: center; } th, td { @@ -207,6 +256,7 @@ font-size: 1em; width: 100%; } + input, select, textarea { background-color: #fff; font-family: inherit; @@ -297,7 +347,12 @@ } + .clear { + clear: both; + } + .fonctions { + display: flex; align-items: center; justify-content: flex-end;