Add merchandise, fix articletosell with src for images

This commit is contained in:
Ludovic CANDELLIER
2022-04-14 23:20:09 +02:00
parent 2f77b5fc23
commit 165262abfa
14 changed files with 69 additions and 23 deletions

View File

@@ -59,6 +59,11 @@ class Shop
$menu->addTo('shop', 'Accueil', [
'route' => 'Admin.Shop.Homepages.index',
])->activeIfRoute(['Admin.Shop.Homepages.*'])->order(14);
])->activeIfRoute(['Admin.Shop.Homepages.*'])->order(15);
$menu->addTo('shop', 'Marchandises', [
'route' => 'Admin.Shop.Merchandises.index',
])->activeIfRoute(['Admin.Shop.Merchandises.*'])->order(16);
}
}

View File

@@ -83,8 +83,8 @@ class Articles
$parents = self::getInheritedByProduct($article->product_id, $article->product_type);
$data['description'] = self::getFullDescriptionByArticle($article);
$image = self::getFullImageByArticle($article);
$data['image'] = self::getPreview($image);
$data['image_big'] = self::getImage($image);
$data['image'] = self::getPreviewSrc($image);
$data['image_big'] = self::getImageSrc($image);
$data['inherited'] = self::getInherited($id);
$data['categories'] = self::getCategoriesNameByArticle($article);
$data['tags'] = self::getTagsSlugByArticle($article);
@@ -408,6 +408,10 @@ class Articles
$specie = $article->product;
$image = $specie->image;
break;
case 'App\Models\Shop\Merchandise':
$merchandise = $article->product;
$image = $merchandise->image;
break;
}
}
return $image;

View File

@@ -23,7 +23,7 @@ trait Imageable
public static function getThumbSrc($image)
{
return Medias::getThumbSrc($image);
return $image ? Medias::getThumbSrc($image) : '/img/visuel-non-disponible.jpg';
}
public static function getPreview($image)

View File

@@ -42,7 +42,7 @@
label: '{{ __('Commander') }}',
className: 'btn-success',
callback: function() {
submitModal(form_id);
// submitModal(form_id);
}
},
};
@@ -51,11 +51,12 @@
'Ajout dans le panier',
'basket-form',
"{{ route('Shop.Basket.modalBasket') }}/" + offer_id + '/' + quantity,
"{{ route('Shop.Basket.addBasket') }}",
refreshBasketTop(),
"{{ route('Shop.Orders.create') }}",
false,
false,
true,
buttons
buttons,
"refreshBasketTop()",
);
});

View File

@@ -10,7 +10,7 @@
</div>
<div class="row">
<div class="col-4">
{!! $article['image_big'] !!}
<img src="{{ $article['image_big'] }}" class="img-fluid border">
</div>
<div class="col-5">
{!! $article['description'] !!}

View File

@@ -4,7 +4,7 @@
@section('content')
@if ($basket)
<div class="row m-0">
<div class="row">
<div class="col-8">
<div class="row mb-3">
<div class="col-4">
@@ -17,7 +17,7 @@
</div>
</div>
@foreach ($basket as $nature => $items)
<div class="row mb-3 p-2 bg-green-light">
<div class="row mb-3 p-2 bg-green-light border">
<div class="col-12">
<h2 style="font-size: 1.6em;">{{ ucfirst($nature) }}</h2>
@foreach ($items as $item)
@@ -73,19 +73,28 @@
calculateTotal();
$('.basket-quantity').change(function() {
var offer_id = $(this).data('id');
quantity = $('.basket-quantity').value;
addBasket(offer_id, quantity, function() {
calculatePrice($(this).parents('.basket-row'));
calculateTotal();
});
});
$('.basket-delete').click(function() {
var offer_id = $(this).data('id');
var data = {offer_id: offer_id, quantity: 0};
$.post("{{ route('Shop.Basket.addBasket') }}", data, function() {
addBasket(offer_id, 0, function() {
$('#basket_offer-' + offer_id).remove();
calculateTotal();
});
});
}
function addBasket(offer_id, quantity, callback) {
var data = {offer_id: offer_id, quantity: 0};
$.post("{{ route('Shop.Basket.addBasket') }}", data, callback);
}
function calculatePrice($that) {
var quantity = $that.find('.basket-quantity').val();
var price = $that.find('.basket-price').text();
@@ -103,6 +112,7 @@
});
$('#basket-total').html(fixNumber(total));
calculateTotalShipped();
refreshBasketTop();
return total;
}

View File

@@ -14,13 +14,12 @@
'name' => 'quantity',
'value' => $item['quantity'],
'class' => 'basket-quantity',
'data_id' => $item['id'],
])
</div>
<div class="col-3 text-right" style="font-size: 2em;" id="basket_total-{{ $item['id'] }}">
<div class="col-4 text-right" style="font-size: 2em;" id="basket_total-{{ $item['id'] }}">
<span class="basket-total-row">{{ $item['quantity'] * $item['price'] }}</span>
</div>
<div class="col-1 text-center">
<i class="btn fa fa-fw fa-trash basket-delete" style="font-size: 1.6em;" data-id={{ $item['id'] }}></i>
<i class="btn btn-success fa fa-trash basket-delete ml-3 mb-2" data-id={{ $item['id'] }}></i>
</div>
</div>
</div>

View File

@@ -56,11 +56,10 @@
</script>
@endif
@stack('js')
<script>
function refreshBasketTop() {
$.get("{{ route('Shop.Basket.getSummary') }}", function(response) {
console.log("refreshBasketTop()");
console.log(response);
$('#count-basket').html(response.data.quantity);
$('#total-basket').html(response.data.total);
@@ -68,6 +67,8 @@
}
</script>
@stack('js')
</body>
</html>

View File

@@ -1,7 +1,7 @@
<div class="row">
<div class="col-12 text-right p-2">
<a href="{{ route('Shop.Basket.basket') }}" style="color: white;">
<button type="button" class="btn bg-green-dark basket light">
<button type="button" class="btn bg-green-dark light">
<i class="fa fa-2x fa-fw fa-shopping-basket mr-2"></i>
<span class="ml-2 badge bg-yellow green-dark">
<span id="count-basket">{{ \App\Repositories\Core\User\ShopCart::getTotalQuantity() }}</span>

View File

@@ -1,6 +1,6 @@
<div class="row bg-green">
<div class="col-3 form-inline pl-4">
<div class="col-3 form-inline">
<a href="/"><img src="/img/logo.jpg" class="img-responvive"></a>
<a id="filters" href="#" class="text-white pl-3"><i class="fa fa-2x fa-bars"></i></a>
</div>

View File

@@ -1,4 +1,7 @@
<input type="number" name="{{ $name }}" id="{{ $id_name ?? str_slug($name,'-') }}" class="form-control {{ $class ?? ''}}" value="{{ $value ?? ''}}"
@if (isset($data_id))
data-id="{{ $data_id }}"
@endif
@if (isset($required))
required="required"
@endif

View File

@@ -3,7 +3,7 @@
@push('js')
<script>
function openModal(title, form_id, url_open, url_save, callback, size, no_confirm, buttons) {
function openModal(title, form_id, url_open, url_save, callback, size, no_confirm, buttons, callback_after_loaded) {
var status = 0;
var dialog = bootbox.dialog({
title: title,
@@ -18,7 +18,11 @@
dialog.init(function() {
$.get(url_open, function(data) {
console.log("OpenModal init");
dialog.find('.bootbox-body').html(data);
if (callback_after_loaded) {
eval(callback_after_loaded);
}
// if ( typeOf(url_save) !== 'undefined') {
handlePostModal(form_id,url_save, callback);
// }

View File

@@ -0,0 +1,18 @@
<?php
Route::prefix('Merchandises')->name('Merchandises.')->group(function () {
Route::get('', 'MerchandiseController@index')->name('index');
Route::get('getDataTable', 'MerchandiseController@getDataTable')->name('getDataTable');
Route::get('create', 'MerchandiseController@create')->name('create');
Route::delete('destroy/{id?}', 'MerchandiseController@destroy')->name('destroy');
Route::post('update', 'MerchandiseController@update')->name('update');
Route::post('store', 'MerchandiseController@store')->name('store');
Route::get('edit/{id}', 'MerchandiseController@edit')->name('edit');
Route::post('getSelect', 'MerchandiseController@getOptionsWithSpecie')->name('getSelect');
Route::post('deleteImage', 'MerchandiseController@deleteImage')->name('deleteImage');
Route::any('getImages/{id?}/{can_edit?}', 'MerchandiseController@getImages')->name('getImages');
Route::any('exportExcel', 'MerchandiseController@exportExcel')->name('exportExcel');
});

View File

@@ -10,6 +10,7 @@ Route::middleware('auth')->prefix('Shop')->namespace('Shop')->name('Shop.')->gro
include __DIR__ . '/Homepages.php';
include __DIR__ . '/InvoiceItems.php';
include __DIR__ . '/Invoices.php';
include __DIR__ . '/Merchandises.php';
include __DIR__ . '/Offers.php';
include __DIR__ . '/OrderPayments.php';
include __DIR__ . '/Orders.php';