]> _ Git - pmi.git/commitdiff
wip #5788 @6:30 correction bug panier/affichage tarif/revoir l'affichage dynamique...
authorsoufiane <soufiane@cubedesigners.com>
Tue, 6 Jun 2023 16:23:07 +0000 (18:23 +0200)
committersoufiane <soufiane@cubedesigners.com>
Tue, 6 Jun 2023 16:23:07 +0000 (18:23 +0200)
15 files changed:
app/Http/Controllers/AjaxController.php
app/Models/Client.php
public/images/icon-angle-down.svg [new file with mode: 0644]
public/images/icon-radio-checked.svg [new file with mode: 0644]
public/images/icon-radio.svg [new file with mode: 0644]
resources/js/app.js
resources/js/components/CartItem.vue
resources/js/product-details.js
resources/js/tippy-config.js [new file with mode: 0644]
resources/views/components/cart-add.blade.php
resources/views/components/item-cart.blade.php
resources/views/pages/paniers_enregistres.blade.php
resources/views/pages/product-detail.blade.php
resources/views/partials/product-link.blade.php
webpack.mix.js

index 9f06090466959fbc7b03a89c6911af53822b17d5..fbd857846b864074a5088e4b23b1c33701a7616b 100644 (file)
@@ -149,7 +149,6 @@ class AjaxController extends CubistFrontController
 
     public function cart(Request $request)
     {
-
         $request->validate([
             'action' => 'required|string', // add/update/delete
             'id' => 'required|numeric',
index bd32260640055d83423ecd381e6ea527898b3075..272da8879c1828f72d24cd340fcec8d67933b55b 100644 (file)
@@ -85,7 +85,7 @@ class Client extends CubistMagicAbstractModel
         $this->addField(['name' => 'discount',
             'label' => 'Remise',
             'type' => 'select_from_array',
-            'options' => ['A','B','C','D','E'],
+            'options' => ['A' => 'A','B' => 'B','C' => 'C','D' => 'D','E' => 'E'],
             'allows_null' => false,
             'default' => 'A',
             'column' => true,
@@ -107,6 +107,7 @@ class Client extends CubistMagicAbstractModel
 
     public static function discountArray($categoryProduct) {
         $categoryClient = self::getClientConnected()->discount ?? 'A';
+        //dd(self::getClientConnected());
         $category_array = [
             'A' => 0,
             'B' => 5,
@@ -125,7 +126,7 @@ class Client extends CubistMagicAbstractModel
         $discount_array = array_combine($discount_array_save_keys,$discount_array);
 
         if($categoryProduct && $categoryClient) {
-            return $discount_array[$categoryClient][$categoryProduct];
+            return $discount_array[$categoryProduct][$categoryClient];
         }
 
         return null;
diff --git a/public/images/icon-angle-down.svg b/public/images/icon-angle-down.svg
new file mode 100644 (file)
index 0000000..14082e3
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="15.121" height="8.112" viewBox="0 0 15.121 8.112">
+  <path id="Tracé_226" data-name="Tracé 226" d="M.5,3.85,6.65,10a.48.48,0,0,0,.7,0L13.5,3.85" transform="translate(0.561 -2.789)" fill="none" stroke="#182f4c" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
+</svg>
diff --git a/public/images/icon-radio-checked.svg b/public/images/icon-radio-checked.svg
new file mode 100644 (file)
index 0000000..88f96ab
--- /dev/null
@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+    <g id="Ellipse_35" data-name="Ellipse 35" fill="#fff" stroke="#6b7285" stroke-width="1.5">
+        <circle cx="8" cy="8" r="8" stroke="none"/>
+        <circle cx="8" cy="8" r="7.25" fill="none"/>
+    </g>
+    <g transform="translate(4,4)">
+        <circle id="Ellipse_37" data-name="Ellipse 37" cx="4" cy="4" r="4" fill="#0eaada" />
+    </g>
+</svg>
diff --git a/public/images/icon-radio.svg b/public/images/icon-radio.svg
new file mode 100644 (file)
index 0000000..571f7f9
--- /dev/null
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+  <g id="Ellipse_35" data-name="Ellipse 35" fill="#fff" stroke="#6b7285" stroke-width="1.5">
+    <circle cx="8" cy="8" r="8" stroke="none"/>
+    <circle cx="8" cy="8" r="7.25" fill="none"/>
+  </g>
+</svg>
index 2d74912b0eaf308718e14555d97ae71afb9711c1..ad873287404c566d9e55dfa2e0291c03e40815c0 100644 (file)
@@ -96,8 +96,8 @@ const app = new Vue({
     mounted() {
         eventBus.$on('add-item', data => {
             data.action = 'add';
-            data.ref = this.ref ?? data.ref;
-            data.price = this.price;
+            data.ref = data.ref !== "" ? data.ref : this.ref;
+            data.price = data.price !== undefined ? data.price : this.price;
             this.saveCart(data);
         });
 
@@ -162,7 +162,7 @@ const app = new Vue({
         priceDiscount() {
             let discount = this.discount ?? 0
             let newValue = (this.price * discount) / 100
-            return this.price - newValue.toFixed(2)
+            return (this.price - newValue).toFixed(2)
         }
     },
 
@@ -648,12 +648,14 @@ $(document).on('click', 'button.cart-add', function () {
     $(this).find('.add').addClass('hidden');
     $(this).find('.added').removeClass('hidden').addClass('inline-flex');
     var id = parseInt($(this).attr('data-product-id')),
-        ref = $(this).attr('data-ref')
+        ref = $(this).attr('data-ref'),
+        price = $(this).attr('data-price')
 
     eventBus.$emit('add-item', {
         id: id,
         quantity: 1,
-        ref: ref
+        ref: ref,
+        price: price
     });
 
     clearTimeout(time);
index e5270b45fc0129a9cbb59320f1b936ee210213c8..ec5b50b21408803f125b7ae1b45da19b66dcfc70 100644 (file)
@@ -6,7 +6,6 @@
         </a>
         <div class="cart-item-text pl-6 xs:pl-0 leading-relaxed flex-grow">
             <a :href="item.URL" class="block text-navy font-display">
-
                 <span class="text-grey-dark" v-if="item.ref">{{ item.ref }}</span>
                 <span class="text-grey-dark" v-else>{{ item.reference }}</span>
                 <br>
@@ -16,7 +15,7 @@
                 <span class="mr-2">Quantité</span>
                 <number-input v-model="item.quantity" :min="1" inline center controls></number-input>
             </div>
-            <div v-if="!isNaN(item.price)" :class="{ 'line-through' : item.discount > 0 }">
+            <div v-if="!isNaN(parseFloat(item.price))" :class="{ 'line-through' : item.discount > 0 }">
                 <span class="text-navy">{{ Number.parseFloat(price).toFixed(2) }}<span>€ HT</span></span>
             </div>
             <div v-if="item.discount > 0">
index e8c71627abb42807cba50593775c23f2d50dd145..47d08e27aeb411a294a3d7fa3d70cb40a320fe6d 100644 (file)
@@ -1,24 +1,3 @@
-import tippy from 'tippy.js'
-
-tippy('[data-tooltip]', {
-    arrow: true,
-    arrowType: 'sharp',
-    animation: 'shift-away',
-    content: function (el) {
-        return el.getAttribute('data-tooltip');
-    },
-    flipBehavior: ["top", "bottom"],
-    theme: 'custom',
-    placement: 'top',
-
-    popperOptions: {
-        modifiers: {
-            data: {styles: {marginBottom: '50px'}},
-            hide: {enabled: true}
-        }
-    },
-});
-
 import blueimp from 'blueimp-gallery';
 
 document.getElementById('product-gallery').onclick = function (event) {
diff --git a/resources/js/tippy-config.js b/resources/js/tippy-config.js
new file mode 100644 (file)
index 0000000..76f5aa5
--- /dev/null
@@ -0,0 +1,20 @@
+import tippy from 'tippy.js'
+
+tippy('[data-tooltip]', {
+    arrow: true,
+    arrowType: 'sharp',
+    animation: 'shift-away',
+    content: function (el) {
+        return el.getAttribute('data-tooltip');
+    },
+    flipBehavior: ["top", "bottom"],
+    theme: 'custom',
+    placement: 'top',
+
+    popperOptions: {
+        modifiers: {
+            data: {styles: {marginBottom: '50px'}},
+            hide: {enabled: true}
+        }
+    },
+});
index 16e3cc1e84302e8a12907465162d5ed8d8e32324..c42bce5bc4adf62e7aca4686483cdc0361dd372d 100644 (file)
@@ -14,7 +14,7 @@
     @elseif(isset($template) && $template === "miniature" && $options)
     <a href="{{ $link }}" class="btn text-center">
     @else
-    <button data-ref="{{ $reference }}" data-product-id="{{ $id }}" class="btn cart-add">
+    <button data-ref="{{ $reference }}" data-price="{{ $price }}" data-product-id="{{ $id }}" class="btn cart-add">
     @endif
         <span class="btn-text relative">
             <span class="add">
index 5b5a03a31b2681aa3074169d990ce1e88e704254..a2910aa2fe1f772a7f75c6fd74473bbae8fc1d3a 100644 (file)
@@ -52,7 +52,7 @@
                         </div>
                         <div class="product-price">
                             @if(floatval($product['price']))
-                                <p class="no-m">{{ $product['price'] * $product['quantity'] }}€ HT</p>
+                                <p class="no-m">{{ number_format($product['price'] * $product['quantity'], 2) }}€ HT</p>
                             @else
                                 <p class="text-navy">
                                     N/A
index c511e6fc88e7aa3c75e125d7cd716e302dfd83d9..769f9913709b801b67824ce1ac1524096e6dca78 100644 (file)
@@ -1,5 +1,9 @@
 @extends('layouts/app')
 
+@push('scripts')
+    <script src="{{ mix('/js/tippy-config.js') }}"></script>
+@endpush
+
 @section('content')
     <full-width padding="pb-3v">
         <content>
index b0ba9d2337da26b76edbbff89161287100173409..1a4d2b06e3d426ef6391688bc87f56810607cc6c 100644 (file)
@@ -15,6 +15,7 @@
 
 @push('scripts')
     <script src="{{ mix('/js/product-details.js') }}"></script>
+    <script src="{{ mix('/js/tippy-config.js') }}"></script>
 @endpush
 
 @section('content')
                 @endauth
 
                 @if(config('features.quote'))
-                    <cart-add :id="$product->id" :reference="$product->reference" :price="$product->basic_selling_price" template="product-detail"></cart-add>
+                    <cart-add :id="$product->id" reference="" price="" template="product-detail"></cart-add>
                     <span
                         data-tooltip="{{__('Ajoutez un ou plusieurs produits à votre sélection, ajustez les quantités et obtenez un devis.')}}"
                         class="font-display text-lg inline-block align-middle rounded-full border-grey-dark border-2 h-8 w-8 text-center ml-6">?</span>
index 308f6571a5bdecd1d45840209c12b9cbab9bd52f..f8c3c15c3579b8b0feafefdb4977e3e78eabeef7 100644 (file)
@@ -6,7 +6,9 @@
     $categoryProduct = $product->category;
     $discount = \App\Models\Client::discountArray($categoryProduct);
 
-    $price = number_format($product->basic_selling_price - (($product->basic_selling_price * $discount) / 100), 2);
+    $price = floatval(number_format($product->basic_selling_price - (($product->basic_selling_price * $discount) / 100), 2));
+    if($price < 1)
+        $price = ""
 @endphp
 
 <div data-product-id="{{ $id }}" class="product-grid-item bg-grey-200">
@@ -38,7 +40,7 @@
             @endif
         </div>
         @if(config('features.quote'))
-            <cart-add :id="$product->id" :reference="$product->reference" :link="$product->getEntity()->URL" :price="$product->basic_selling_price" :options="$options" template="miniature"></cart-add>
+            <cart-add :id="$product->id" :reference="$product->reference" :link="$product->getEntity()->URL" :price="$price" :options="$options" template="miniature"></cart-add>
         @endif
         <div class="links mt-4">
             <div class="link">
index a7688f3dd3cab5e3e998c9b94828d53ca26d3b4c..b3c675ecd4a20d19e6b2eaea6a9fc84bd3b8356e 100644 (file)
@@ -37,6 +37,7 @@ mix.js('resources/js/app.js', 'public/js')
     .js('resources/js/carrousel.js', 'public/js')
     .js('resources/js/logowall.js', 'public/js')
     .js('resources/js/product-details.js', 'public/js')
+    .js('resources/js/tippy-config.js', 'public/js')
     .js('resources/js/mailform.js', 'public/js');
 
 // mix.polyfill({