/*
*
*
- * CONNEXION, REGISTER, MY ACCOUNT, SELECTION, COMMAND
+ * CONNEXION, REGISTER, MY ACCOUNT, SELECTION, ORDER
*
*
*/
}
return false;
}
+
+ public function order(Request $request) {
+ $request->validate([
+ 'id' => 'required|numeric'
+ ]);
+ }
}
'type' => 'Text'
]
];
+
+ protected function getAllByUserId() {
+ $userID = Client::getClientConnected()->id;
+ return self::all()->where('user_id', $userID)->toArray();
+ }
}
return $refs;
}
-
- public static function getAllCart() {
- return Panier::all()->toArray();
- }
}
BladeX::component('components.address-form'); // <address-form> ... </address-form>
BladeX::component('components.modal-confirm'); // <modal-confirm> ... </modal-confirm>
BladeX::component('components.btn-delete'); // <btn-delete> ... </btn-delete>
+ BladeX::component('components.item-cart'); // <item-cart> ... </item-cart>
} catch (\Exception $e) {
}
--- /dev/null
+<?php
+
+
+namespace App\Templates;
+
+use App\Models\Command;
+use App\Models\Panier;
+use Cubist\Backpack\app\Magic\Menu\PageItem;
+
+class MyOrder extends Base
+{
+ public function getName()
+ {
+ return 'Mes commandes';
+ }
+
+ public function setData(&$data)
+ {
+ $data["items"] = Command::getAllByUserId();
+ }
+
+ public function init()
+ {
+ parent::init();
+ }
+}
namespace App\Templates;
+use App\Models\Panier;
+
class PaniersEnregistres extends Base
{
public function getName()
return 'Paniers enregistrés';
}
+ public function setData(&$data)
+ {
+ $data["items"] = Panier::getAllByUserId();
+ }
+
public function init()
{
parent::init();
})
.catch(function (error) {
})
+ },
+ order(event) {
+ const root = this,
+ id = event.target.dataset.id
+
+ axios.post('/ajax/order', {id: id})
+ .then(function (response) {
+ root.validateAction = true
+ root.confirmMessageCart = response.data;
+ })
+ .catch(function (error) {
+ })
}
},
/**
--- /dev/null
+@foreach($items as $item)
+ <div id="cart-saved-{{ $item['id'] }}" class="cartsave bg-grey-200 pr-2v pl-2v">
+ <div class="cartsave-name">
+ @if($page === "savedcart")
+ <div>
+ <input id="cart-name-{{ $item['id'] }}" class="readonly" value="{{ $item['name'] }}" readonly />
+ </div>
+ <a href="#" data-input="{{ $item['id'] }}" class="inline-block animated-underline" data-defaulttext="{{ __('Editer le nom du panier') }}" data-edittext="{{ __('Sauvegarder le nom du panier') }}" @click.prevent.self="toggleName">
+ {{ __('Editer le nom du panier') }}
+ </a>
+ @else
+ <div class="flex justify-between">
+ <div>
+ <p class="no-m">{{ __('Date de commande') }}</p>
+ <p class="no-m text-navy">{{ \Carbon\Carbon::parse($item['created_at'])->isoFormat("D/MM/Y") }}</p>
+ </div>
+ <div>
+ <p class="no-m">{{ __('Numéro de commande') }}</p>
+ <p class="no-m text-navy">{{ $item['id'] }}</p>
+ </div>
+ </div>
+ @endif
+ </div>
+ <div class="cartsave-products">
+ @foreach(json_decode($item['products'], true) as $key => $product)
+ <grid gap="md" class="sm:grid-cols-1 cartsave-grid">
+ <div class="product-thumbnail bg-center bg-contain bg-no-repeat" style='background-image : url("{{ $product['image'] }}")'>
+ </div>
+ <div class="product-infos flex justify-between items-center">
+ <div>
+ <p class="no-m">{{ $product['ref'] }}</p>
+ <p class="no-m text-navy">{{ $product['name'] }}</p>
+ @isset($product['basic_selling_price'])
+ @if(floatval($product['basic_selling_price']))
+ <p class="no-m">{{ __('Prix unitaire') }} <span class="text-navy">{{
+ $product['basic_selling_price'] }} € HT</span>
+ </p>
+ @endif
+ @endisset
+ <p class="no-m">{{ __('Quantité') }} : <span class="text-navy">{{$product['quantity']}}</span></p>
+ </div>
+ <div class="product-price">
+ @if(floatval($product['price']))
+ <p class="no-m">{{ $product['price'] * $product['quantity'] }}€ HT</p>
+ @else
+ <p class="text-navy">
+ N/A
+ <span
+ data-tooltip="{{__('Prix sur devis.')}}"
+ class="font-display text-lg inline-block align-middle rounded-full border-grey-dark border-2 h-8 w-8 text-center ml-3">?</span>
+ </p>
+ @endif
+ </div>
+ </div>
+ </grid>
+ @endforeach
+ </div>
+ <div class="cartsave-footer <?php echo $item['total'] ? 'pt-6' : 'pt-12' ?>">
+ <div class=<?php echo $page !== "order" ?: "flex justify-between" ?>>
+ @if($page === "order")
+ <div>
+ <p class="no-m">{{ __('Statut') }}</p>
+ <p class="no-m text-navy">{{ $item['status'] }}</p>
+ </div>
+ @endif
+ @if($item['total'])
+ <div class="text-right pb-6">
+ <p class="no-m">{{ __('Montant Total') }}</p>
+ <p class="no-m">{{ $item['total'] }}€ HT</p>
+ </div>
+ @endif
+ </div>
+ <div class="flex justify-between items-center">
+ @if($page === "savedcart")
+ <button class="flex items-center" data-id="{{ $item['id'] }}" @click.stop="removeSavedCart">
+ @svg('icon-trash')
+ <span class="ml-3">{{ __('Supprimer ce panier') }}</span>
+ </button>
+
+ <div class="flex items-center">
+ <a href="#" data-id="{{ $item['id'] }}" class="animated-underline mr-10 xs:mr-0" @click.self.prevent="savedCartToCurrent">
+ {{ __('Modifier ce panier') }}
+ </a>
+ @isset($item['total'])
+ <a href="" class="btn">{{ __('Passer commande') }}</a>
+ @else
+ <a href="" class="btn">{{ __('Demander un devis') }}</a>
+ @endisset
+ </div>
+ @endif
+ </div>
+ </div>
+ </div>
+@endforeach
<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" v-cloak v-if="cartItemCount === cartItemHasPriceCount">
+ <button class="cart-valid-command btn btn-custom xs:w-full" data-id="" v-cloak v-if="cartItemCount === cartItemHasPriceCount" @click="order">
{{ __('Valider la commande') }}
</button>
<div class="cart-links">
<a href="#" v-cloak v-if="cartItemCount === cartItemHasPriceCount">{{ __('Obtenir un devis officiel') }}</a><br>
- <a href="#" @click.prevent="storeCart()">{{ __('Enregistrer ce panier') }}</a>
+ <a href="#" @click.prevent="storeCart">{{ __('Enregistrer ce panier') }}</a>
</div>
<div class="text-sm" v-cloak v-if="cartItemCount === cartItemHasPriceCount">
--- /dev/null
+@extends('layouts/app')
+
+@section('content')
+ <full-width padding="pb-3v">
+ <content>
+ <text-block :title="$page->title" title-tag="h1" />
+ <item-cart :items="$items" page="order"></item-cart>
+ </content>
+ </full-width>
+@endsection
<full-width padding="pb-3v">
<content>
<text-block :title="$page->title" title-tag="h1" />
-
- @foreach(\App\Models\Panier::getAllCart() as $cart)
- <div id="cart-saved-{{ $cart['id'] }}" class="cartsave bg-grey-200 pr-2v pl-2v">
- <div class="cartsave-name">
- <div>
- <input id="cart-name-{{ $cart['id'] }}" class="readonly" value="{{ $cart['name'] }}" readonly />
- </div>
- <a href="#" data-input="{{ $cart['id'] }}" class="inline-block animated-underline" data-defaulttext="{{ __('Editer le nom du panier') }}" data-edittext="{{ __('Sauvegarder le nom du panier') }}" @click.prevent.self="toggleName">
- {{ __('Editer le nom du panier') }}
- </a>
- </div>
- <div class="cartsave-products">
- @foreach(json_decode($cart['products'], true) as $key => $product)
- <grid gap="md" class="sm:grid-cols-1 cartsave-grid">
- <div class="product-thumbnail bg-center bg-contain bg-no-repeat" style='background-image : url("{{ $product['image'] }}")'>
- </div>
- <div class="product-infos flex justify-between items-center">
- <div>
- <p class="no-m">{{ $product['ref'] }}</p>
- <p class="no-m text-navy">{{ $product['name'] }}</p>
- @isset($product['basic_selling_price'])
- @if(floatval($product['basic_selling_price']))
- <p class="no-m">{{ __('Prix unitaire') }} <span class="text-navy">{{
- $product['basic_selling_price'] }} € HT</span>
- </p>
- @endif
- @endisset
- <p class="no-m">{{ __('Quantité') }} : <span class="text-navy">{{$product['quantity']}}</span></p>
- </div>
- <div class="product-price">
- @if(floatval($product['price']))
- <p class="no-m">{{ $product['price'] }}€ HT</p>
- @else
- <p class="text-navy">
- N/A
- <span
- data-tooltip="{{__('Prix sur devis.')}}"
- class="font-display text-lg inline-block align-middle rounded-full border-grey-dark border-2 h-8 w-8 text-center ml-3">?</span>
- </p>
- @endif
- </div>
- </div>
- </grid>
- @endforeach
- </div>
- <div class="cartsave-footer <?php echo $cart['total'] ? 'pt-6' : 'pt-12' ?>">
- @isset($cart['total'])
- <div class="text-right pb-6">
- <p class="no-m">{{ __('Montant Total') }}</p>
- <p class="no-m">{{ $cart['total'] }}€ HT</p>
- </div>
- @endisset
- <div class="flex justify-between items-center">
- <button class="flex items-center" data-id="{{ $cart['id'] }}" @click.stop="removeSavedCart">
- @svg('icon-trash')
- <span class="ml-3">{{ __('Supprimer ce panier') }}</span>
- </button>
-
- <div class="flex items-center">
- <a href="#" data-id="{{ $cart['id'] }}" class="animated-underline mr-10 xs:mr-0" @click.self.prevent="savedCartToCurrent">
- {{ __('Modifier ce panier') }}
- </a>
- @isset($cart['total'])
- <a href="" class="btn">{{ __('Passer commande') }}</a>
- @else
- <a href="" class="btn">{{ __('Demander un devis') }}</a>
- @endisset
- </div>
- </div>
- </div>
- </div>
- @endforeach
+ <item-cart :items="$items" page="savedcart"></item-cart>
</content>
</full-width>
@endsection
</ul>-->
</li>
<li class="{{ Request::is('mes-commandes') ? "active" : '' }}">
- <a href="">
+ <a href="/mes-commandes">
<span>{{ __('Mes commandes') }}</span>
</a>
</li>