]> _ Git - pmi.git/commitdiff
wip #5850 @7:00
authorsoufiane <soufiane@cubedesigners.com>
Tue, 11 Apr 2023 16:23:19 +0000 (18:23 +0200)
committersoufiane <soufiane@cubedesigners.com>
Tue, 11 Apr 2023 16:23:19 +0000 (18:23 +0200)
app/Models/Product.php
resources/js/app.js
resources/js/components/CartItem.vue
resources/styles/common/spacing.styl
resources/styles/components/cart.styl
resources/views/components/cart-add.blade.php
resources/views/pages/cart.blade.php
resources/views/pages/product-detail.blade.php
resources/views/partials/account.blade.php

index b00d25c8cdb2dc7d6737fa9142f116790afa957a..c5f05f230dc531a84dd33537240795c83a8873df 100644 (file)
@@ -163,6 +163,12 @@ class Product extends CubistMagicPageModel
             'tab' => 'Produits associés',
         ]);
 
+        $this->addField(['name' => 'time_limit',
+            'label' => 'Délai',
+            'type' => 'Text',
+            'tab' => 'Informations fournisseur'
+        ]);
+
         foreach ($this->_hidden_options as $name => $label) {
             $this->addField(['name' => $name,
                 'label' => $label,
@@ -476,21 +482,6 @@ class Product extends CubistMagicPageModel
 
             if (count($cart_items) > 0) {
                 self::$_cart_data = $cart_items;
-                //$products = self::with('media')->whereIn('id', array_keys($cart_items))->get();
-
-                /*foreach ($cart_items as $product) {
-                    self::$_cart_data[] = [
-                        'id' => $product['id'],
-                        'name' => $product['name'],
-                        'reference' => $product['reference'],
-                        'category' => $product['category'],
-                        'quantity' => $product['quantity'],
-                        'image' => $product['image'],
-                        'URL' => $product['URL'],
-                        'price' => $product['price'],
-                        'ref' => $product['ref']
-                    ];
-                }*/
             }
         }
 
index 6720383a74751ce160ac46180626661a9b47d1e4..5480aaafe7c82da6490d385a83d6dc72f71d9760 100644 (file)
@@ -112,7 +112,7 @@ const app = new Vue({
         });
 
         this.ref = this.$refs.refProduct?.dataset.ref
-        this.price = this.$refs.optprice ?.dataset.default
+        this.price = parseFloat(this.$refs.optprice ?.dataset.default).toFixed(2)
         this.statusText = this.$refs.statusConfig ?.dataset.incomplete
     },
 
@@ -133,12 +133,26 @@ const app = new Vue({
         },
 
         cartItemHasPriceCount() {
-            return this.items.length ? this.items.filter(n => n.price !== "").length : 0
+            return this.items.length ? this.items.filter(n => n.price !== "" && !isNaN(n.price)).length : 0
         },
 
         total() {
-            let prices = this.items.map(item => item.price * item.quantity)
-            return this.items.length ? prices.reduce((init, current) => init + current) : false
+            let prices = this.items.length ? this.items.map(item => item.price * item.quantity) : false
+
+            prices = prices ? Number.parseFloat(prices.reduce((init, current) => init + current)) : 0
+            prices += (prices > 1000) ? 20 : 0
+
+            return prices.toFixed(2)
+        },
+
+        tva() {
+            let tva = this.total ? this.total * 0.2 : 0
+            return tva.toFixed(2)
+        },
+
+        totalTTC() {
+            let total = this.total ? parseFloat(this.total) + parseFloat(this.tva) : 0
+            return total.toFixed(2)
         }
     },
 
@@ -256,6 +270,7 @@ const app = new Vue({
             axios.post('/ajax/check_email_exist', data)
                 .then(function (response) {
                     root.validateEmail = true
+                    root.removeErrorsForm()
                     if (response.data.length > 0) {
                         root.emailExist = true
                     }
@@ -453,6 +468,7 @@ const app = new Vue({
 
             this.ref = this.$refs.refProduct.dataset.ref+'/'+placeholder
             this.price = total + parseFloat(this.$refs.optprice.dataset.default)
+            this.price = parseFloat(this.price).toFixed(2)
         }
     },
     /**
index dd56867511f99fa3d2c90cb078afd8fab4339597..81a2226da30d0b65504581f5a33bd21efd17df72 100644 (file)
@@ -16,8 +16,8 @@
                 <span class="mr-2">Quantité</span>
                 <number-input v-model="item.quantity" :min="1" inline center controls></number-input>
             </div>
-            <div v-if="item.price">
-                <span>{{ price }}€ HT</span>
+            <div v-if="!isNaN(item.price)">
+                <span class="text-navy">{{ Number.parseFloat(price).toFixed(2) }}€ HT</span>
             </div>
             <a href="#" class="cart-delete-item text-red" @click.prevent="deleteItem">
                 Supprimer
index 4ef8a8d49a83a5aec8dc721d0e6bb486b4182e1b..adbeaf85a0732efc4ae7ac332ddf79b87480ff0f 100644 (file)
@@ -8,7 +8,7 @@ $vw-spacing = {
   '2': 5vw,
   '3': 7.5vw,
   '4': 10vw,
-  '5': 12.5vw,
+  '5': 12.5vw
 }
 
 $sides = {
index f8cb1f6b07643c571cb316c0b6f04f27d19224ca..71ed0b5c99716ab417cab5c3a4eadc8872c8a837 100644 (file)
   .cart-quantity
     @apply bg-white
     max-width: 220px
+  .cart-addresses
+    form
+      label
+        padding-left: 20px !important
+
+      [type="radio"]
+        width: 16px !important
+        height: 24px
+        margin: 0
+        border: 0
+        display: grid
+        place-content: center
+        padding: 0
+        position: relative
+        appearance: none
+
+        &:before
+          content: ""
+          width: 16px
+          height: 16px
+          background-image: url(/images/icon-radio.svg)
+          background-repeat: no-repeat
+          background-position: center
+        &:checked:before
+          content: ""
+          background-image: url(/images/icon-radio-checked.svg)
+          background-repeat: no-repeat
+          background-position: center
+          border-radius: 50px
+
+.cart-shipping-fees
+  padding: 10px 0
+  margin-bottom: 36px
+  border: 1px solid #D5D7DF
+  border-left: 0
+  border-right: 0
+
+.cart-total
+  p
+    margin-bottom: 0 !important
+
+.cart-valid-command
+  margin: 32px 0 28px
+
+.cart-links
+  margin-bottom: 32px
+  a
+    display: inline-block
+    &:not(:last-child)
+      margin-bottom: 10px
 
 // Cart item
 .cart-item
index ade4c691c08a8458ad75ea19dc8d1dc783f9ab13..386441d88af93a65188d565dcee8eff6b2b2e540 100644 (file)
@@ -1,4 +1,4 @@
-<button data-product-id="{{ $id }}" class="btn cart-add" :class="{ 'pointer-events-none bg-grey-disabled' : price && !statusConfig }">
+<button data-product-id="{{ $id }}" class="btn cart-add" :class="{ 'pointer-events-none bg-grey-disabled' : !isNaN(price) && !statusConfig }">
         <span class="btn-text relative">
             <span class="add">
                 @if(isset($price))
index 03a650aef0f6f6ccd6fec31a9517953a7445ef4e..e153f373e5f44416b76399e6b01005bf69b2c749 100644 (file)
@@ -2,8 +2,8 @@
 
 @section('content')
 
-    <content class="pb-3v">
-        <text-block :title="$page->page_heading" title-tag="h1" />
+    <content class="pb-3v cart-page">
+        <text-block :title="__('Mon panier')" title-tag="h1" />
 
         <div v-if="cartItemCount > 0">
 
 
                 {{-- Nested divs to allow grey backgrounds of columns to match the height of their content instead of total height --}}
                 <div>
-                    <cart :items='items' :sendevents="false" class="cart-page bg-grey-100 p-1v pb-0 overflow-hidden"></cart>
+                    <cart :items='items' :sendevents="false" class="bg-grey-100 p-1v pb-0 overflow-hidden"></cart>
+                    <div class="bg-grey-100 p-1v pt-0">
+                        <div class="cart-shipping-fees text-navy">
+                            {{ __('Frais de ports') }} : <span v-cloak>@{{ total > 1000 ? '20€' : '0€' }}</span>
+                        </div>
+                        <div class="cart-total">
+                            <p class="text-2xl text-navy">{{ __('Total HT') }} : <span v-cloak>@{{ total }}</span></p>
+                            <p class="text-2xl text-navy">{{ __('Montant TVA') }} : <span v-cloak>@{{ tva }}</span></p>
+                            <p class="text-2xl text-navy">{{ __('Total TTC') }} : <span v-cloak>@{{ totalTTC }}</span></p>
+                        </div>
+                    </div>
+                    <button class="cart-valid-command btn btn-custom xs:w-full">
+                        {{ __('Valider la commande') }}
+                    </button>
+
+                    <div class="cart-links">
+                        <a href="">{{ __('Obtenir un devis officiel') }}</a><br>
+                        <a href="">{{ __('Enregistrer ce panier') }}</a>
+                    </div>
+
+                    <div class="text-sm">
+                        En nous transmettant votre demande, vous acceptez que PM Instrumentation traite vos données
+                        personnelles dans le but de vous offrir un service de qualité. Pour plus d’information sur la
+                        protection de vos données à caractère personnel, vous pouvez consulter la page
+                        <a href="/vie-privee">Vie privée</a>.
+                    </div>
                 </div>
 
                 <div>
-                    <div class="bg-grey-100 p-1v">
+                    <div class="bg-grey-100 p-1v" v-cloak v-if="cartItemCount !== cartItemHasPriceCount">
                         @form([
                         'action' => '/ajax/request_quote',
                         'ga'=>false,
                         'extra_fields' => '<input type="hidden" name="cart_data" :value="cartData">' // Populated by VueJS
                         ])
                     </div>
+
+                    <div class="bg-grey-100 p-1v cart-addresses" v-cloak v-else>
+                        <h2 class="font-normal">{{ __('Choisir une adresse de facturation') }} :</h2>
+                        <form class="mb-12">
+                            <div class="grid grid-cols-2 grid-gap-lg grid-rows-0 mb-3">
+                                <div class="bg-white p-3" v-for="address in addresses" :key="address.id">
+                                    <div class="form-group flex items-start" :data="address.address_billing">
+                                        <input name="billing_address" type="radio" :checked="address.billing_address === '1' ? true : false"/>
+                                        <label for="billing_address">
+                                            @verbatim
+                                                <span class="text-navy">{{ address.name }}</span>
+                                                <div class="text-sm leading-5">
+                                                    {{ address.company }}<br>
+                                                    {{ address.firstname }}&nbsp;{{ address.lastname }}<br>
+                                                    {{ address.address }}<br>
+                                                    {{ address.zipcode }}<br>
+                                                    {{ address.city }}
+                                                </div>
+                                            @endverbatim
+                                        </label>
+                                    </div>
+                                </div>
+                            </div>
+                            <a href="/mon-compte#address">{{ __('Ajouter une adresse') }}</a>
+                        </form>
+                        <h2 class="font-normal">{{ __('Choisir une adresse de livraison') }} :</h2>
+                        <form>
+                            <div class="grid grid-cols-2 grid-gap-lg grid-rows-0 mb-3">
+                                <div class="bg-white p-3" v-for="address in addresses" :key="address.id">
+                                    <div class="form-group flex items-start" :data="address.address_billing">
+                                        <input :id="'input-'+key" name="delivery_address" type="radio" :checked="address.delivery_address === '1' ? true : false"/>
+                                        <label :for="'input-'+key">
+                                            @verbatim
+                                                <span class="text-navy">{{ address.name }}</span>
+                                                <div class="text-sm leading-5">
+                                                    {{ address.company }}<br>
+                                                    {{ address.firstname }}&nbsp;{{ address.lastname }}<br>
+                                                    {{ address.address }}<br>
+                                                    {{ address.zipcode }}<br>
+                                                    {{ address.city }}
+                                                </div>
+                                            @endverbatim
+                                        </label>
+                                    </div>
+                                </div>
+                            </div>
+                            <a href="/mon-compte#address">{{ __('Ajouter une adresse') }}</a>
+                        </form>
+                    </div>
                 </div>
 
             </grid>
 
         </div>
 
-        <div v-if="cartItemCount == 0" class="p-1v text-center bg-grey-100 text-lg">
+        <div v-cloak v-if="cartItemCount == 0" class="p-1v text-center bg-grey-100 text-lg">
             {{ __("Vous n'avez encore rien sélectionné") }}
         </div>
 
index fe523e5c5782b8c42c4d36dcd76087449d6829d4..68e53fb0f5aceae50e0da7321260028a29b43fdb 100644 (file)
@@ -73,8 +73,8 @@
                             </div>
                         </div>
                         <div class="opt-infos mb-8">
-                            <div class="opt-ref" v-cloak>{{ __('Référence') }} : <span ref="refProduct" data-ref="{{ $product->reference }}">@{{ ref }}</span></div>
-                            <div class="opt-price">
+                            <div class="opt-ref text-navy" v-cloak>{{ __('Référence') }} : <span ref="refProduct" data-ref="{{ $product->reference }}">@{{ ref }}</span></div>
+                            <div class="opt-price text-navy">
                                 {{ __('Prix unitaire') }} :
                                 <span ref="optprice" v-cloak data-default="{{ $product->basic_selling_price }}">@{{ price }}</span>{{ "€ ".__('HT') }}
                             </div>
                         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>
                 @endif
 
+                @isset($product->time_limit)
+                    <div class="mt-3 text-navy text-lg">
+                        {{ $product->time_limit }}
+                    </div>
+                @endisset
             </text-block>
 
         </div>
index 02ef123f071e0bca4defcfa355e8aa705b785872..510b8571d752ff3007aecc203600bb5f2e4b093a 100644 (file)
@@ -1,9 +1,10 @@
 <span class="account-header-title">
     @auth('web-clients')
         <span v-if="!user.firstname">{{ Auth::guard('web-clients')->user()->firstname }}</span>
-        <span v-cloak>@{{ user.firstname }}</span>&nbsp
+        <span v-cloak>@{{ user.firstname }}</span>
+        <span class="mr-1"></span>
         <span v-if="!user.lastname">{{ Auth::guard('web-clients')->user()->lastname }}</span>
-        <span v-cloak>@{{ user.lastname }}</span>&nbsp
+        <span v-cloak>@{{ user.lastname }}</span>
     @else
         {{ __('Se connecter') }}
     @endauth