fix basket

This commit is contained in:
ludo
2023-10-31 17:05:41 +01:00
parent a9432bd3c1
commit 746cf661ce
14 changed files with 144 additions and 88 deletions

View File

@@ -39,7 +39,7 @@
<input type="hidden" name="user_id_client_assoc" id="user_id_client_assoc" value="{{ $id }}" class="form-control" />
<select multiple class="multi-select form-no-control" name="user_clients_list" id="user_clients_list">
@foreach ($clients as $client)
<option value="{{ $client->id }}" {{ !($client->active) ? 'disabled' : '' }} {{ in-array($client->id, $clients_selected) ?? 'selected' : ''>
<option value="{{ $client->id }}" {{ !($client->active) ? 'disabled' : '' }} {{ in_array($client->id, $clients_selected) ? 'selected' : '' }}>
{{ $client->name }}
</option>
@endforeach

View File

@@ -29,7 +29,7 @@
</div>
<div id="collapse_{{ $app }}" class="collapse content-box light p-2" role="tabpanel">
@foreach ($modules as $module = $actions)
@foreach ($modules as $module => $actions)
<h4 class="brand">{{ $module }}</h4>
<div class="inline-group">
@foreach ($actions as $permission)

View File

@@ -39,7 +39,7 @@
<input type="hidden" name="user_id_client_assoc" id="user_id_client_assoc" value="{{ $id }}" class="form-control" />
<select multiple class="multi-select form-no-control" name="user_clients_list" id="user_clients_list">
@foreach ($clients as $client)
<option value="{{ $client->id }}" {{ !($client->active) ? 'disabled' : '' }} {{ in-array($client->id, $clients_selected) ?? 'selected' : ''>
<option value="{{ $client->id }}" {{ !($client->active) ? 'disabled' : '' }} {{ in_array($client->id, $clients_selected ?? []) ? 'selected' : '' }}>
{{ $client->name }}
</option>
@endforeach

View File

@@ -39,7 +39,7 @@
<input type="hidden" name="user_id_client_assoc" id="user_id_client_assoc" value="{{ $id }}" class="form-control" />
<select multiple class="multi-select form-no-control" name="user_clients_list" id="user_clients_list">
@foreach ($clients as $client)
<option value="{{ $client->id }}" {{ !($client->active) ? 'disabled' : '' }} {{ in-array($client->id, $clients_selected) ?? 'selected' : ''>
<option value="{{ $client->id }}" {{ !($client->active) ? 'disabled' : '' }} {{ in_array($client->id, $clients_selected) ? 'selected' : '' }}>
{{ $client->name }}
</option>
@endforeach

View File

@@ -25,43 +25,11 @@
])
@endif
@include('load.basket')
@push('js')
<script>
$('.basket').click(function() {
var type = $(this).data('type');
var offer_id = $('#' + type + '-offer_id').find('option:selected').val();
var quantity = $('#' + type + '-quantity').val();
var data = {
'offer_id': offer_id,
'quantity': quantity,
};
var buttons = {
cancel: {
label: '{{ __('Continuer mes achats') }}',
className: 'btn-secondary'
},
confirm: {
label: '{{ __('Commander') }}',
className: 'btn-success',
callback: function() {
window.location = "{{ route('Shop.Basket.basket') }}";
}
},
};
openModal(
'Ajout dans le panier',
'basket-form',
"{{ route('Shop.Basket.modalBasket') }}/" + offer_id + '/' + quantity,
"{{ route('Shop.Orders.order') }}",
false,
false,
true,
buttons,
"refreshBasketTop()",
);
});
initBasket();
function setPrice(model) {
var offer_id = $('#' + model + '-offer_id').find('option:selected').val();

View File

@@ -1,7 +1,7 @@
@component('components.card', [
'id_card' => $model . '-basket',
'title' => $title,
'class' => 'mb-3 ' . ($bgClass ?? null),
'class' => 'mb-3 addBasket ' . ($bgClass ?? null),
'classTitle' => 'mb-0',
'outline' => false,
])
@@ -10,13 +10,14 @@
'name' => 'offer_id',
'id_name' => $model . '-offer_id',
'list' => collect($data)->pluck('name', 'id')->toArray(),
'class' => 'select2 mb-2',
'class' => 'select2 mb-2 offer_id',
])
<div class="row">
<div class="col-5">
@include('components.form.inputs.number', [
'name' => 'quantity',
'class' => 'quantity',
'id_name' => $model . '-quantity',
'value' => 1,
])

View File

@@ -1,29 +1,41 @@
@if ($article_nature == 'semences')
<div class="w-100 mt-3 p-1 bg-green-light green-dark rounded-lg border text-center">
<div class="w-100 mt-3 p-1 bg-green-light green-dark rounded-lg border text-center addBasket">
<span style="font-size: 1.4em; font-weight: bold;">{{ $article['semences']['price'] ?? null }}</span> <br>
{{ $article['semences']['variation'] }}
<div>
Quantité : 1
Quantité :
@include('components.form.inputs.number', [
'name' => uniqid(),
'class' => 'quantity',
'value' => 1,
'style' => 'max-width: 64px; display: inline-block',
])
</div>
<input type="hidden" class="offer_id" value="{{ $article['semences']['offer_id'] ?? null }}" />
@include('components.form.button', [
'class' => 'btn-green-dark basket semences mb-3 mt-2 shadow',
'txt' => 'Ajouter au panier',
'data_id' => $article['semences']['offer_id'] ?? null,
])
</div>
@endif
@if ($article_nature == 'plants')
<div class="w-100 mt-3 p-1 bg-green-light green-dark rounded-lg border text-center">
<div class="w-100 mt-3 p-1 bg-green-light green-dark rounded-lg border text-center addBasket">
<span style="font-size: 1.4em; font-weight: bold;">{{ $article['plants']['price'] ?? null }}</span> <br>
{{ $article['plants']['variation'] }}
<div>
Quantité : 1
Quantité :
@include('components.form.inputs.number', [
'name' => uniqid(),
'class' => 'quantity',
'value' => 1,
'style' => 'max-width: 64px; display: inline-block',
])
</div>
<input type="hidden" class="offer_id" value="{{ $article['plants']['offer_id'] ?? null }}" />
@include('components.form.button', [
'class' => 'btn-success basket plants mb-3 mt-2 shadow',
'txt' => 'Ajouter au panier',
'data_id' => $article['plants']['offer_id'] ?? null,
])
</div>
@endif

View File

@@ -47,3 +47,10 @@
@endsection
@include('load.layout.modal')
@include('load.basket')
@push('js')
<script>
initBasket();
</script>
@endpush

View File

@@ -6,7 +6,7 @@
@component('components.layout.box-collapse', [
'title' => $group['name'],
'id' => 'tag_group_' . $tag_group_id,
'collapsed' => App\Repositories\Shop\TagGroups::isTagGroupHaveSelected($tags_selected, $group['tags']),
'collapsed' => App\Repositories\Shop\TagGroups::isTagGroupHaveSelected($tags_selected ?? [], $group['tags']),
])
@foreach ($group['tags'] as $tag)
<div class="form-inline">

View File

@@ -1 +1,4 @@
@include('components.form.button', ['class' => 'btn-danger ' . ($class ?? ''), 'icon' => ($icon ?? 'fa-trash)'])
@include('components.form.button', [
'class' => 'btn-danger ' . ($class ?? ''),
'icon' => $icon ?? 'fa-trash',
])

View File

@@ -1,6 +1,7 @@
@include('components.form.label')
<input type="number" name="{{ $name }}" id="{{ $id_name ?? str_slug($name,'-') }}" class="form-control {{ $class ?? ''}}" value="{{ $value ?? ''}}"
@if ($style ?? false) style="{{ $style }}" @endif
@if ($required ?? false) required @endif
@if ($disabled ?? false) disabled @endif
@if ($readonly ?? false) readonly @endif

View File

@@ -0,0 +1,48 @@
@if(!defined('BASKET'))
@push('scripts')
<script>
function initBasket(sel) {
var selector = (typeof(sel) == 'undefined') ? '.basket' : sel;
$(selector).off().click(function() {
var $addBasket = $(this).closest('.addBasket');
var offerId = $addBasket.find('.offer_id').val();
var quantity = $addBasket.find('.quantity').val();
var data = {
'offer_id': offerId,
'quantity': quantity,
};
console.log(data);
var buttons = {
cancel: {
label: '{{ __('Continuer mes achats') }}',
className: 'btn-secondary'
},
confirm: {
label: '{{ __('Commander') }}',
className: 'btn-success',
callback: function() {
window.location = "{{ route('Shop.Basket.basket') }}";
}
},
};
openModal(
'Ajout dans le panier',
'basket-form',
"{{ route('Shop.Basket.modalBasket') }}/" + offerId + '/' + quantity,
"{{ route('Shop.Orders.order') }}",
false,
false,
true,
buttons,
"refreshBasketTop()",
);
});
}
</script>
@endpush
@php(define('BASKET', true))
@endif