Compare commits
366 Commits
1.0.0-rc.5
...
7913576f1a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7913576f1a | ||
|
|
d88b8c8a70 | ||
|
|
f2a87f4d12 | ||
|
|
c338a8afc7 | ||
|
|
29c21367d7 | ||
|
|
09b6c3cf28 | ||
|
|
a34905f34e | ||
|
|
8d8528f6fb | ||
|
|
e69487f73e | ||
|
|
a2da0a8a12 | ||
|
|
b7634e07c0 | ||
|
|
ece0b433fd | ||
|
|
c94d815e5a | ||
|
|
0d0e7c4652 | ||
|
|
0e9d758e6b | ||
|
|
883d2d634d | ||
|
|
1503f21b3b | ||
|
|
17fa80b96b | ||
|
|
92c9975e81 | ||
|
|
b214d8dc74 | ||
|
|
08fc49cb61 | ||
|
|
0f32386406 | ||
|
|
4023fd9ee4 | ||
|
|
1e32fd7cf1 | ||
|
|
870fc6c806 | ||
|
|
045641e687 | ||
|
|
38e477ee5f | ||
|
|
561cd2248c | ||
|
|
0a538ee1a2 | ||
|
|
e490c27837 | ||
|
|
e92f38f6c3 | ||
|
|
296dc4fde2 | ||
|
|
e4e2126ada | ||
|
|
44391e817c | ||
|
|
5359375210 | ||
|
|
c15a6e380f | ||
|
|
3acb69abe4 | ||
|
|
00fc978217 | ||
|
|
7a33245c1e | ||
|
|
927be4ea77 | ||
|
|
b0b87db86d | ||
|
|
53448d7907 | ||
|
|
e920157c0b | ||
|
|
8f905ce1eb | ||
|
|
b95da54240 | ||
|
|
e6ad147790 | ||
|
|
5fc8d3dc57 | ||
|
|
4caf069011 | ||
|
|
d0e97ccd08 | ||
|
|
38ce69b525 | ||
|
|
b67e91d228 | ||
|
|
94f84a7a85 | ||
|
|
54ab6b0231 | ||
|
|
9e30118088 | ||
|
|
6c88e43b74 | ||
|
|
5c20e6d5d0 | ||
|
|
79af996c63 | ||
|
|
c0c4146c9c | ||
|
|
84bc5f2e67 | ||
|
|
72f5da4555 | ||
|
|
349204307f | ||
|
|
36459de793 | ||
|
|
d432827bab | ||
|
|
930695166d | ||
|
|
8c39035cdc | ||
|
|
6a1d8ba80a | ||
|
|
6f8340b90b | ||
|
|
c5f06a608c | ||
|
|
50111787aa | ||
|
|
b80c2a8d41 | ||
|
|
2eea4ec73d | ||
|
|
88a57a9c32 | ||
|
|
7e5b1fea89 | ||
|
|
c053221662 | ||
|
|
25b8fc40c5 | ||
|
|
d33dd6e755 | ||
|
|
04f92c9695 | ||
|
|
7c8546e450 | ||
|
|
585d42264f | ||
|
|
9f4ef99ce2 | ||
|
|
501f3a5ab9 | ||
|
|
0ff39c1401 | ||
|
|
71ecb13af0 | ||
|
|
7561a8e8ba | ||
|
|
bbf4bc4232 | ||
|
|
5d5ea92127 | ||
|
|
a84995e0ce | ||
|
|
fcc564b6d8 | ||
|
|
be468304c9 | ||
|
|
b812a78f9f | ||
|
|
0ec0b8e85b | ||
|
|
9d520abfcf | ||
|
|
174c4ca0e2 | ||
|
|
216c408596 | ||
|
|
3cdb30a0dc | ||
|
|
5bcf265cda | ||
|
|
7ec1d3e89b | ||
|
|
741f389620 | ||
|
|
37f1ebbb59 | ||
|
|
81974d38ab | ||
|
|
cc9672ddca | ||
|
|
12903b6029 | ||
|
|
e6b15e2438 | ||
|
|
002644cb97 | ||
|
|
dfe7625995 | ||
|
|
53feef282f | ||
|
|
69478e3c74 | ||
|
|
ab8ab8eba1 | ||
|
|
de5f3d665d | ||
|
|
afaf0cc629 | ||
|
|
419a4c2b9a | ||
|
|
d750cdced7 | ||
|
|
01f9c9ae7c | ||
|
|
043b7d7215 | ||
|
|
f85df32c67 | ||
|
|
6f2a985edc | ||
|
|
5f1ff26196 | ||
|
|
ddb4520621 | ||
|
|
c619f540f8 | ||
|
|
39c80ce6d1 | ||
|
|
297dcc62d2 | ||
|
|
b011f40b2f | ||
|
|
fdbf819bf5 | ||
|
|
f4738377c7 | ||
|
|
99bdf09be7 | ||
|
|
b283363543 | ||
|
|
6649c32501 | ||
|
|
bc1cf1190b | ||
|
|
3dc6c70c4d | ||
|
|
6e4f93dd65 | ||
|
|
ba8f87cff4 | ||
|
|
efb3fe9670 | ||
|
|
23e6ca35ca | ||
|
|
695d23a139 | ||
|
|
3943fc033f | ||
|
|
bb77a199eb | ||
|
|
808e60e41b | ||
|
|
260eccc1f1 | ||
|
|
abed17b3f0 | ||
|
|
3ad83b870a | ||
|
|
241b255b1c | ||
|
|
d2ec87c374 | ||
|
|
24b86652aa | ||
|
|
923f988aba | ||
|
|
0778fdc10a | ||
|
|
900aa413a2 | ||
|
|
820a200e88 | ||
|
|
186e3de863 | ||
|
|
7722b73be9 | ||
|
|
685160ddf5 | ||
|
|
7449229ff7 | ||
|
|
c5ae71544a | ||
|
|
926996166b | ||
|
|
fd8e89e33c | ||
|
|
503efc6f25 | ||
|
|
e8ae460bab | ||
|
|
bb1e1a6b18 | ||
|
|
02b2d3e410 | ||
|
|
72870680cf | ||
|
|
f3289334f3 | ||
|
|
12e5dbb721 | ||
|
|
b42ae14428 | ||
|
|
ea5350a0a6 | ||
|
|
90d78bc3e3 | ||
|
|
a85e5f2921 | ||
|
|
5e6af2e5f8 | ||
|
|
11aaaa024c | ||
|
|
fd1ab5cf04 | ||
|
|
a03befbf44 | ||
|
|
ce7755ffe3 | ||
|
|
17792fce40 | ||
|
|
9698ba54d0 | ||
|
|
ae39681cb0 | ||
|
|
9895266798 | ||
|
|
c1a9c21e52 | ||
|
|
3a18679a1c | ||
|
|
6ef31f286e | ||
|
|
52193994a3 | ||
|
|
71c0489862 | ||
|
|
d33b5eea52 | ||
|
|
782809829b | ||
|
|
ebe7ba5f6c | ||
|
|
dae8156164 | ||
|
|
1880b25407 | ||
|
|
5819f51f79 | ||
|
|
01f56204b7 | ||
|
|
eadea3958d | ||
|
|
719e4481d7 | ||
|
|
eae2cdf345 | ||
|
|
ab145dd60f | ||
|
|
8054bffb43 | ||
|
|
d50ecd674e | ||
|
|
1703082b3e | ||
|
|
35310b049e | ||
|
|
4801ff4338 | ||
|
|
b2987e5eed | ||
|
|
8b334bc8ed | ||
|
|
79c717ae6c | ||
|
|
8abf391a53 | ||
|
|
cc2798a78e | ||
|
|
ce9f613b66 | ||
|
|
3370b8061c | ||
|
|
8c898bf63b | ||
|
|
fedf463f15 | ||
|
|
73508f6b46 | ||
|
|
c79facd0ca | ||
|
|
3ba5a833b2 | ||
|
|
c77db883c2 | ||
|
|
904110d10f | ||
|
|
3c8fab27da | ||
|
|
ee0954931f | ||
|
|
d399b72120 | ||
|
|
6fc6451f6f | ||
|
|
f3e9ccaa46 | ||
|
|
1fc860715f | ||
|
|
6837954fc9 | ||
|
|
483aa59750 | ||
|
|
f460865a57 | ||
|
|
4d31b1682c | ||
|
|
ee148a27ed | ||
|
|
79e5a6388a | ||
|
|
165262abfa | ||
|
|
2f77b5fc23 | ||
|
|
8afb3467f8 | ||
|
|
e3c60e7cde | ||
|
|
7187a312eb | ||
|
|
e208dc910b | ||
|
|
d4bb94a487 | ||
|
|
e77ed62066 | ||
|
|
8dddd4d99b | ||
|
|
edf43ff270 | ||
|
|
36c6402f04 | ||
|
|
8ba8d9a276 | ||
|
|
cdce15a29f | ||
|
|
c12b45f8ad | ||
|
|
081df4d5d0 | ||
|
|
2d86f162a0 | ||
|
|
c2b7315abf | ||
|
|
7b265d3b47 | ||
|
|
c90dd98319 | ||
|
|
193f5cf4ad | ||
|
|
930eeaede8 | ||
|
|
36a63f3b14 | ||
|
|
d9dba1c515 | ||
|
|
411b47f78d | ||
|
|
a550278f39 | ||
|
|
d715d726db | ||
|
|
60acbc7939 | ||
|
|
6a634c10ca | ||
|
|
308f226ca0 | ||
|
|
c0aeda7554 | ||
|
|
3633581ebf | ||
|
|
15539f27a6 | ||
|
|
0a9d03e214 | ||
|
|
36f16921bb | ||
|
|
cbe397be6a | ||
|
|
8dc409bd78 | ||
|
|
56659c73bb | ||
|
|
accc94f56b | ||
|
|
64f5663da5 | ||
|
|
c6ba4aaa24 | ||
|
|
020954a7cc | ||
|
|
61be4a6769 | ||
|
|
cf9439852f | ||
|
|
5bf3b7ec7b | ||
|
|
715e228b41 | ||
|
|
91675dc83b | ||
|
|
e0addd61ce | ||
|
|
66cc7a6054 | ||
|
|
2d6b092b64 | ||
|
|
9ab19b0e4d | ||
|
|
6110b42ce2 | ||
|
|
82a345c4c7 | ||
|
|
c0a80aa62b | ||
|
|
b325a44ee2 | ||
|
|
88d87ceaab | ||
|
|
ba04007f86 | ||
|
|
81dcd273ce | ||
|
|
d899d3dcaa | ||
|
|
9f6d21ef04 | ||
|
|
bdefa235eb | ||
|
|
545c242bba | ||
|
|
e241486143 | ||
|
|
2f81f1d61d | ||
|
|
4d3ffa2ca3 | ||
|
|
f237882757 | ||
|
|
090dcd6f24 | ||
|
|
6db343c6b2 | ||
|
|
d46347a66f | ||
|
|
ab8f68e4bc | ||
|
|
8c9fc66b89 | ||
|
|
2be53d581e | ||
|
|
26f3fc3d2c | ||
|
|
efff4f0341 | ||
|
|
b3f2aa36be | ||
|
|
cdc88b43df | ||
|
|
ecbb7b62c9 | ||
|
|
b1a2e70d12 | ||
|
|
b2f5cc4a45 | ||
|
|
8a1573d425 | ||
|
|
cb0b2e4aa0 | ||
|
|
7092cf23fc | ||
|
|
e434220c16 | ||
|
|
0858804095 | ||
|
|
5f7e90d22d | ||
|
|
6dce60d227 | ||
|
|
f6668a6dd3 | ||
|
|
dd396a86aa | ||
|
|
f3b6504723 | ||
|
|
41cab61bda | ||
|
|
c76996db86 | ||
|
|
f5716c6530 | ||
|
|
459d35e8a1 | ||
|
|
e9ce44481a | ||
|
|
18f1f8a13a | ||
|
|
e97f54f126 | ||
|
|
0d0e4deb16 | ||
|
|
da51da2530 | ||
|
|
c024bdc31e | ||
|
|
4ec0558cd8 | ||
|
|
48d89d338c | ||
|
|
0f23d5cd56 | ||
|
|
9380d99688 | ||
|
|
06fb42e7c7 | ||
|
|
66a830eec0 | ||
|
|
0e73c8109b | ||
|
|
5e4c9963c6 | ||
|
|
f9070b2ec8 | ||
|
|
8107078ea7 | ||
|
|
be3b6bc0a8 | ||
|
|
290602057a | ||
|
|
a1a3ccb227 | ||
|
|
e9002fb494 | ||
|
|
cffec143e0 | ||
|
|
385873a0cf | ||
|
|
8842b7eea7 | ||
|
|
0cd0e1f126 | ||
|
|
7c01366281 | ||
|
|
fa193a8089 | ||
|
|
27c5663ba1 | ||
|
|
cfd8086586 | ||
|
|
c3a05640ab | ||
|
|
ca691c8fdd | ||
|
|
47ff07451f | ||
|
|
5bbf63b33f | ||
|
|
768c7e88f9 | ||
|
|
23b8914187 | ||
|
|
aee50813e4 | ||
|
|
331b7647de | ||
|
|
b1494477a2 | ||
|
|
31b671bcdd | ||
|
|
9e2226a776 | ||
|
|
9ca510086b | ||
|
|
7ec40145de | ||
|
|
734ec87b89 | ||
|
|
0d421226fa | ||
|
|
d174fe1c81 | ||
|
|
64abc46d99 | ||
|
|
f4ab8e71a8 | ||
|
|
763577bf87 | ||
|
|
226153f744 | ||
|
|
e298320119 | ||
|
|
b90d633e6e | ||
|
|
31e60dee45 | ||
|
|
0dd3df2984 | ||
|
|
d53e9f5a4f |
@@ -11,7 +11,7 @@ use Yajra\DataTables\Html\Column;
|
||||
|
||||
class CustomerInvoicesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'customer_invoices';
|
||||
public $model_name = 'invoices';
|
||||
|
||||
public $sortedColumn = 1;
|
||||
|
||||
|
||||
@@ -12,6 +12,15 @@ class CustomerInvoiceController extends Controller
|
||||
return $dataTable->render('Admin.Shop.CustomerInvoices.list');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = [
|
||||
'invoice' => Invoices::get($id),
|
||||
];
|
||||
|
||||
return view('Admin.Shop.CustomerInvoices.view', $data);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return Invoices::destroy($id);
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
use App\Repositories\Shop\Baskets;
|
||||
use App\Repositories\Shop\CustomerAddresses;
|
||||
use App\Repositories\Shop\Customers;
|
||||
use App\Repositories\Shop\Offers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
@@ -47,50 +44,8 @@ class CustomerController extends Controller
|
||||
public function storeProfileAjax(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
|
||||
if (array_key_exists('default_sale_channel_id', $data)) {
|
||||
$customer = Customers::get(Customers::getId());
|
||||
$newSaleChannelId = (int) $data['default_sale_channel_id'];
|
||||
$currentSaleChannelId = (int) ($customer->default_sale_channel_id ?? 0);
|
||||
|
||||
if ($newSaleChannelId && $newSaleChannelId !== $currentSaleChannelId && ShopCart::count() > 0) {
|
||||
$cartItems = ShopCart::getContent();
|
||||
$unavailable = [];
|
||||
|
||||
foreach ($cartItems as $item) {
|
||||
$offerId = (int) $item->id;
|
||||
|
||||
if (! Offers::getPrice($offerId, 1, $newSaleChannelId)) {
|
||||
$offer = Offers::get($offerId, ['article']);
|
||||
$unavailable[] = $offer->article->name ?? $item->name;
|
||||
|
||||
if (count($unavailable) >= 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($unavailable)) {
|
||||
$list = implode(', ', $unavailable);
|
||||
|
||||
return response()->json([
|
||||
'error' => 1,
|
||||
'message' => __('Certains articles de votre panier ne sont pas disponibles dans ce canal : :products. Merci de finaliser votre commande ou de retirer ces articles avant de changer de canal.', ['products' => $list]),
|
||||
], 422);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$customer = Customers::store($data);
|
||||
|
||||
if ($customer) {
|
||||
Customers::guard()->setUser($customer->fresh(['sale_channels']));
|
||||
if (array_key_exists('default_sale_channel_id', $data)) {
|
||||
session(['shop.default_sale_channel_id' => $data['default_sale_channel_id']]);
|
||||
Baskets::refreshPrices((int) $data['default_sale_channel_id']);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(['error' => 0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,14 +15,8 @@ class InvoiceController extends Controller
|
||||
|
||||
public function view($uuid)
|
||||
{
|
||||
$invoice = Invoices::view($uuid);
|
||||
|
||||
if (! $invoice) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'invoice' => $invoice,
|
||||
'invoice' => Invoices::view($uuid),
|
||||
];
|
||||
|
||||
return view('Shop.Invoices.view', $data);
|
||||
|
||||
@@ -49,22 +49,12 @@ class OrderController extends Controller
|
||||
{
|
||||
if (ShopCart::count()) {
|
||||
$customer = Customers::getWithAddresses();
|
||||
$customerId = $customer ? $customer->id : false;
|
||||
$defaultSaleChannelId = SaleChannels::getDefaultID($customerId);
|
||||
$deliveries = $defaultSaleChannelId
|
||||
? Deliveries::getBySaleChannels([$defaultSaleChannelId])
|
||||
: Deliveries::getByCustomer($customerId);
|
||||
$deliveries = $deliveries ? $deliveries->values() : collect();
|
||||
|
||||
$customerData = $customer ? $customer->toArray() : false;
|
||||
if ($customerData && $defaultSaleChannelId) {
|
||||
$customerData['default_sale_channel_id'] = $defaultSaleChannelId;
|
||||
}
|
||||
$deliveries = Deliveries::getByCustomer();
|
||||
|
||||
$data = [
|
||||
'customer' => $customerData,
|
||||
'customer' => $customer ? $customer->toArray() : false,
|
||||
'basket' => Baskets::getBasketTotal(),
|
||||
'deliveries' => $deliveries->toArray(),
|
||||
'deliveries' => $deliveries ? $deliveries->toArray() : [],
|
||||
'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()),
|
||||
];
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Repositories\Shop;
|
||||
use App\Models\Shop\Article;
|
||||
use App\Repositories\Botanic\Species;
|
||||
use App\Repositories\Botanic\Varieties;
|
||||
use App\Repositories\Shop\SaleChannels;
|
||||
use App\Repositories\Core\Comments;
|
||||
use App\Traits\Model\Basic;
|
||||
use App\Traits\Repository\Imageable;
|
||||
@@ -71,14 +70,9 @@ class Articles
|
||||
|
||||
public static function getArticleToSell($id, $saleChannelId = false)
|
||||
{
|
||||
$saleChannelId = $saleChannelId ?: SaleChannels::getDefaultID();
|
||||
$data = self::getArticle($id);
|
||||
$data['offers'] = self::getOffersGroupedByNature($id, $saleChannelId);
|
||||
|
||||
$currentSaleChannel = $saleChannelId ? SaleChannels::get($saleChannelId) : null;
|
||||
$data['current_sale_channel'] = $currentSaleChannel ? $currentSaleChannel->toArray() : null;
|
||||
$data['available_sale_channels'] = Offers::getSaleChannelsForArticle($id);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,19 +100,12 @@ class Baskets
|
||||
$offers = Offers::getWithPricesByIds(self::getIds(), $saleChannelId);
|
||||
foreach ($basket as $item) {
|
||||
$offer = $offers->where('id', $item->id)->first();
|
||||
if (! $offer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$priceValue = Offers::getPrice($item->id, $item->quantity, $saleChannelId);
|
||||
$unitPrice = $priceValue ? (float) $priceValue->price_taxed : (float) $item->price;
|
||||
|
||||
$article_nature = strtolower($offer->article->article_nature->name);
|
||||
$data[$article_nature][] = [
|
||||
'id' => (int) $item->id,
|
||||
'name' => $item->name,
|
||||
'quantity' => (int) $item->quantity,
|
||||
'price' => $unitPrice,
|
||||
'price' => $item->price,
|
||||
'variation' => $offer->variation->name,
|
||||
'image' => Articles::getPreviewSrc(ArticleImages::getFullImageByArticle($offer->article)),
|
||||
'latin' => $offer->article->product->specie->latin ?? false,
|
||||
@@ -122,24 +115,6 @@ class Baskets
|
||||
return $data ?? false;
|
||||
}
|
||||
|
||||
public static function refreshPrices($saleChannelId = false)
|
||||
{
|
||||
$saleChannelId = $saleChannelId ? $saleChannelId : SaleChannels::getDefaultID();
|
||||
$basket = ShopCart::getContent();
|
||||
|
||||
foreach ($basket as $item) {
|
||||
$priceValue = Offers::getPrice($item->id, $item->quantity, $saleChannelId);
|
||||
|
||||
if (! $priceValue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ShopCart::get()->update($item->id, [
|
||||
'price' => $priceValue->price_taxed,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getBasketData($id, $quantity = 1)
|
||||
{
|
||||
$offer = Offers::get($id, ['article', 'variation']);
|
||||
|
||||
@@ -31,31 +31,16 @@ class Customers
|
||||
public static function getSaleChannels($customerId = false)
|
||||
{
|
||||
$customer = $customerId ? self::get($customerId) : self::getAuth();
|
||||
$saleChannels = collect();
|
||||
$saleChannels = $customer ? $customer->sale_channels : false;
|
||||
|
||||
if ($customer) {
|
||||
$customer->loadMissing('sale_channels');
|
||||
$saleChannels = $customer->sale_channels ?? collect();
|
||||
|
||||
if ($saleChannels instanceof \Illuminate\Support\Collection && $saleChannels->isNotEmpty()) {
|
||||
return $saleChannels;
|
||||
}
|
||||
}
|
||||
|
||||
$default = SaleChannels::getDefault($customerId);
|
||||
|
||||
return $default ? collect([$default]) : collect();
|
||||
return $saleChannels ? $saleChannels : SaleChannels::getDefault();
|
||||
}
|
||||
|
||||
public static function getSaleChannel($customerId = false)
|
||||
{
|
||||
$saleChannels = self::getSaleChannels($customerId);
|
||||
|
||||
if ($saleChannels instanceof \Illuminate\Support\Collection) {
|
||||
return $saleChannels->first();
|
||||
}
|
||||
|
||||
return $saleChannels;
|
||||
return $saleChannels->first();
|
||||
}
|
||||
|
||||
public static function getDeliveries()
|
||||
@@ -73,22 +58,12 @@ class Customers
|
||||
|
||||
public static function editProfile($id = false)
|
||||
{
|
||||
if (! $id) {
|
||||
abort('403');
|
||||
}
|
||||
|
||||
$customer = self::get($id, ['addresses', 'deliveries', 'sale_channels']);
|
||||
|
||||
$saleChannels = self::getSaleChannels($id);
|
||||
|
||||
return [
|
||||
'customer' => $customer->toArray(),
|
||||
'sale_channels' => $saleChannels->toArray(),
|
||||
'deliveries' => Deliveries::getByCustomer($id)->toArray(),
|
||||
'sale_channel_checks' => Shop::getSaleChannelAvailabilitySummary($saleChannels->pluck('id')->toArray()),
|
||||
return $id ? [
|
||||
'customer' => self::get($id, ['addresses', 'deliveries'])->toArray(),
|
||||
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
||||
'orders' => (new CustomerOrdersDataTable())->html(),
|
||||
'invoices' => (new CustomerInvoicesDataTable())->html(),
|
||||
];
|
||||
] : abort('403');
|
||||
}
|
||||
|
||||
public static function getAddresses($id = false)
|
||||
|
||||
@@ -21,12 +21,12 @@ class Deliveries
|
||||
$customer = $customerId ? Customers::get($customerId) : Customers::getAuth();
|
||||
$saleChannels = $customer ? $customer->sale_channels->pluck('id')->toArray() : [SaleChannels::getDefaultID()];
|
||||
|
||||
return $saleChannels ? self::getBySaleChannels($saleChannels) : collect();
|
||||
return $saleChannels ? self::getBySaleChannels($saleChannels) : false;
|
||||
}
|
||||
|
||||
public static function getBySaleChannels($saleChannels)
|
||||
{
|
||||
return Delivery::bySaleChannels($saleChannels)->active()->with('sale_channel')->get();
|
||||
return Delivery::bySaleChannels($saleChannels)->with('sale_channel')->get();
|
||||
}
|
||||
|
||||
public static function getSaleChannelId($deliveryId)
|
||||
@@ -41,7 +41,7 @@ class Deliveries
|
||||
|
||||
public static function getAllWithSaleChannel()
|
||||
{
|
||||
return Delivery::orderBy('name', 'asc')->active()->with('sale_channel')->get();
|
||||
return Delivery::orderBy('name', 'asc')->active()->public()->with('sale_channel')->get();
|
||||
}
|
||||
|
||||
public static function toggleActive($id, $active)
|
||||
|
||||
@@ -15,15 +15,9 @@ class DeliveryTypes
|
||||
$types = self::getAll();
|
||||
|
||||
foreach ($types as $type) {
|
||||
$price = self::getPrice($type->id, $weight);
|
||||
|
||||
if ($price === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data[$type->id] = [
|
||||
'name' => $type->name,
|
||||
'price' => $price,
|
||||
'price' => self::getPrice($type->id, $weight),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -36,13 +36,7 @@ class Invoices
|
||||
|
||||
public static function view($uuid)
|
||||
{
|
||||
$invoice = self::getFullByUUID($uuid);
|
||||
|
||||
if (! $invoice) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = $invoice->toArray();
|
||||
$data = self::getFullByUUID($uuid)->toArray();
|
||||
$data['payment_type'] = InvoicePayments::getPaymentType($data['payment_type']);
|
||||
$data['status'] = self::getStatus($data['status']);
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Offer;
|
||||
use App\Models\Shop\PriceListValue;
|
||||
use App\Models\Shop\SaleChannel;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class Offers
|
||||
@@ -168,42 +166,4 @@ class Offers
|
||||
{
|
||||
return Offer::query();
|
||||
}
|
||||
|
||||
public static function getSaleChannelsForArticle($articleId)
|
||||
{
|
||||
$channels = SaleChannel::query()
|
||||
->whereHas('price_lists', function ($query) use ($articleId) {
|
||||
$query->whereHas('tariff.offers', function ($subQuery) use ($articleId) {
|
||||
$subQuery->byArticle($articleId);
|
||||
})->whereHas('price_list_values');
|
||||
})
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
$offers = Offer::query()
|
||||
->byArticle($articleId)
|
||||
->with('article')
|
||||
->get();
|
||||
|
||||
return $channels->map(function ($channel) use ($offers) {
|
||||
$priceValue = null;
|
||||
|
||||
foreach ($offers as $offer) {
|
||||
$priceCandidate = self::getPrice($offer->id, 1, $channel->id);
|
||||
|
||||
if ($priceCandidate && (float) $priceCandidate->price_taxed > 0) {
|
||||
$priceValue = $priceCandidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $channel->id,
|
||||
'name' => $channel->name,
|
||||
'code' => $channel->code,
|
||||
'price_taxed' => $priceValue ? (float) $priceValue->price_taxed : null,
|
||||
'quantity' => $priceValue ? (int) $priceValue->quantity : null,
|
||||
];
|
||||
})->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,52 +3,21 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\SaleChannel;
|
||||
use App\Repositories\Shop\Customers;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class SaleChannels
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function getDefaultID($customerId = false)
|
||||
public static function getDefaultID()
|
||||
{
|
||||
$default = self::getDefault($customerId);
|
||||
$default = self::getDefault();
|
||||
|
||||
return $default ? $default->id : false;
|
||||
return $default ? self::getDefault()->id : false;
|
||||
}
|
||||
|
||||
public static function getDefault($customerId = false)
|
||||
public static function getDefault()
|
||||
{
|
||||
$sessionChannelId = session('shop.default_sale_channel_id');
|
||||
if ($sessionChannelId) {
|
||||
$sessionChannel = SaleChannel::find($sessionChannelId);
|
||||
if ($sessionChannel) {
|
||||
return $sessionChannel;
|
||||
}
|
||||
}
|
||||
|
||||
$customer = $customerId ? Customers::get($customerId) : Customers::getAuth();
|
||||
|
||||
if ($customer) {
|
||||
$customer->loadMissing('sale_channels');
|
||||
|
||||
if ($customer->default_sale_channel_id) {
|
||||
$preferred = $customer->sale_channels->firstWhere('id', $customer->default_sale_channel_id);
|
||||
if (! $preferred) {
|
||||
$preferred = SaleChannel::find($customer->default_sale_channel_id);
|
||||
}
|
||||
if ($preferred) {
|
||||
session(['shop.default_sale_channel_id' => $preferred->id]);
|
||||
return $preferred;
|
||||
}
|
||||
}
|
||||
|
||||
if ($customer->sale_channels->isNotEmpty()) {
|
||||
session(['shop.default_sale_channel_id' => $customer->sale_channels->first()->id]);
|
||||
return $customer->sale_channels->first();
|
||||
}
|
||||
}
|
||||
|
||||
return self::getByCode('EXP');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
|
||||
class Shop
|
||||
{
|
||||
public static function getSaleChannelAvailabilitySummary(array $saleChannelIds): array
|
||||
{
|
||||
if (empty($saleChannelIds) || ShopCart::count() === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$cartItems = ShopCart::getContent();
|
||||
$summary = [];
|
||||
|
||||
foreach ($saleChannelIds as $saleChannelId) {
|
||||
$saleChannelId = (int) $saleChannelId;
|
||||
$issues = [];
|
||||
$issueCount = 0;
|
||||
|
||||
foreach ($cartItems as $item) {
|
||||
$offerId = (int) $item->id;
|
||||
|
||||
if (! Offers::getPrice($offerId, 1, $saleChannelId)) {
|
||||
$offer = Offers::get($offerId, ['article']);
|
||||
$issues[] = $offer->article->name ?? $item->name;
|
||||
$issueCount++;
|
||||
|
||||
if (count($issues) >= 3) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($issues)) {
|
||||
$summary[$saleChannelId] = [
|
||||
'full_count' => $issueCount,
|
||||
'names' => array_slice($issues, 0, 3),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $summary;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('shop_deliveries')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$columns = ['created_by', 'updated_by', 'deleted_by'];
|
||||
$columnsToDrop = [];
|
||||
|
||||
foreach ($columns as $column) {
|
||||
if (Schema::hasColumn('shop_deliveries', $column)) {
|
||||
$columnsToDrop[] = $column;
|
||||
}
|
||||
}
|
||||
|
||||
if ($columnsToDrop) {
|
||||
Schema::table('shop_deliveries', function (Blueprint $table) use ($columnsToDrop) {
|
||||
$table->dropColumn($columnsToDrop);
|
||||
});
|
||||
}
|
||||
|
||||
Schema::table('shop_deliveries', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('created_by')->nullable()->after('event_date_end');
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->after('created_by');
|
||||
$table->unsignedBigInteger('deleted_by')->nullable()->after('updated_by');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('shop_deliveries')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('shop_deliveries', function (Blueprint $table) {
|
||||
$table->dropColumn(['created_by', 'updated_by', 'deleted_by']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('shop_customers', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('shop_customers', 'default_sale_channel_id')) {
|
||||
$table->unsignedInteger('default_sale_channel_id')->nullable()->after('settings');
|
||||
$table->index('default_sale_channel_id', 'shop_customers_default_sale_channel_id_index');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('shop_customers', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('shop_customers', 'default_sale_channel_id')) {
|
||||
$table->dropIndex('shop_customers_default_sale_channel_id_index');
|
||||
$table->dropColumn('default_sale_channel_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -223,9 +223,6 @@ return [
|
||||
'successmod' => 'Le canal de vente a été correctement modifié',
|
||||
'successdel' => 'Le canal de vente a été correctement effacé',
|
||||
'confirmdelete' => 'Confirmez-vous la suppression du canal de vente ?',
|
||||
'missing_offers' => '{1} Ce canal de vente n\'a pas d\'offre pour :count produit.|[2,*] Ce canal de vente n\'a pas d\'offre pour :count produits.',
|
||||
'missing_offers_all' => 'Ce canal de vente n\'a aucune offre pour tous les produits de votre panier.',
|
||||
'cannot_select_with_cart' => 'Vous ne pouvez pas sélectionner ce mode d\'achat tant que votre panier contient des produits non disponibles dans ce mode.',
|
||||
],
|
||||
'shelves' => [
|
||||
'title' => 'Rayons',
|
||||
|
||||
@@ -4,28 +4,8 @@
|
||||
'model' => 'customer_invoices',
|
||||
'with_print' => false,
|
||||
'with_filters' => false,
|
||||
'show_callback' => 'AdminCustomerInvoiceView(id);',
|
||||
])
|
||||
<x-layout.modal title="Filtres" id="modal-customer_invoices-filters">
|
||||
@include('Admin.Shop.CustomerInvoices.partials.filters', ['model' => 'customer_invoices'])
|
||||
</x-layout.modal>
|
||||
</x-card>
|
||||
|
||||
@include('load.layout.modal')
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
(function() {
|
||||
const customerInvoiceShowTemplate = "{{ route('Shop.Invoices.view', ['uuid' => '__UUID__']) }}";
|
||||
|
||||
window.AdminCustomerInvoiceView = function(id) {
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = customerInvoiceShowTemplate.replace('__UUID__', id);
|
||||
openModal('Voir une facture', '#invoice-form', url, false, false, 'xl', true);
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
<div class="row">
|
||||
<div class="col-5">
|
||||
{{ Form::label('active', __('Actif')) }}<br/>
|
||||
<input type="hidden" name="active" value="0">
|
||||
@include("components.form.toggle", [
|
||||
'name' => 'active',
|
||||
'value' => $delivery['active'] ?? false,
|
||||
@@ -25,7 +24,6 @@
|
||||
</div>
|
||||
<div class="col-3">
|
||||
{{ Form::label('is_public', __('Type')) }}
|
||||
<input type="hidden" name="is_public" value="0">
|
||||
@include('components.form.toggle', [
|
||||
'name' => 'is_public',
|
||||
'value' => $delivery['is_public'] ?? false,
|
||||
|
||||
@@ -48,37 +48,6 @@
|
||||
|
||||
</div>
|
||||
<div class="col-lg-3 col-xs-12">
|
||||
@if (config('app.debug') && ($article['current_sale_channel'] ?? false))
|
||||
<div class="alert alert-info p-2 mb-3">
|
||||
<strong>Canal actif :</strong>
|
||||
{{ $article['current_sale_channel']['name'] ?? 'N/A' }}
|
||||
<span class="d-block small text-muted">
|
||||
ID {{ $article['current_sale_channel']['id'] ?? '–' }} · Code {{ $article['current_sale_channel']['code'] ?? '–' }}
|
||||
</span>
|
||||
@if (!empty($article['available_sale_channels']))
|
||||
<hr class="my-2">
|
||||
<strong class="d-block">Offres disponibles dans :</strong>
|
||||
<ul class="list-unstyled mb-0 small">
|
||||
@foreach ($article['available_sale_channels'] as $channel)
|
||||
<li class="d-flex justify-content-between align-items-start">
|
||||
<span>
|
||||
• {{ $channel['name'] }}
|
||||
<span class="d-block text-muted" style="font-size: 0.85em; padding-left: 0.9em;">code {{ $channel['code'] }}</span>
|
||||
</span>
|
||||
@if (isset($channel['price_taxed']))
|
||||
<span class="ml-2 text-nowrap text-right">
|
||||
{{ number_format($channel['price_taxed'], 2, ',', ' ') }} € TTC
|
||||
@if (! empty($channel['quantity']))
|
||||
<span class="d-block text-muted" style="font-size: 0.85em;">Qté min. {{ $channel['quantity'] }}</span>
|
||||
@endif
|
||||
</span>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
@include('Shop.Articles.partials.ArticleAddBasket')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
updateBasket(offer_id, quantity, function() {
|
||||
calculatePrice($row);
|
||||
calculateTotal();
|
||||
}, $row);
|
||||
});
|
||||
});
|
||||
|
||||
$('.basket-delete').click(function() {
|
||||
@@ -70,20 +70,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
function updateBasket(offer_id, quantity, callback, $row) {
|
||||
function updateBasket(offer_id, quantity, callback) {
|
||||
var data = {
|
||||
offer_id: offer_id,
|
||||
quantity: quantity,
|
||||
update: true
|
||||
};
|
||||
$.post("{{ route('Shop.Basket.addBasket') }}", data, function(response) {
|
||||
if ($row && response && response.added && typeof response.added.price !== 'undefined') {
|
||||
$row.find('.basket-price').text(fixNumber(response.added.price));
|
||||
$row.find('.basket-total-row').text(fixNumber(response.added.price * $row.find('.basket-quantity').val()));
|
||||
}
|
||||
callback(response);
|
||||
refreshBasketTop();
|
||||
});
|
||||
$.post("{{ route('Shop.Basket.addBasket') }}", data, callback);
|
||||
}
|
||||
|
||||
function calculatePrice($that) {
|
||||
|
||||
@@ -1,168 +1,25 @@
|
||||
@push('styles')
|
||||
<style>
|
||||
.sale-channel-wrapper {
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.sale-channel-wrapper:not(.blocked) .card-body {
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: .75rem;
|
||||
background-color: #ffffff;
|
||||
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.sale-channel-wrapper:not(.blocked) .card-body:hover {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0.35rem 0.8rem rgba(37, 99, 235, 0.12);
|
||||
}
|
||||
|
||||
.sale-channel-wrapper.blocked .card-body {
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: .75rem;
|
||||
background-color: #f3f4f6;
|
||||
}
|
||||
|
||||
.sale-channel-wrapper .card-body {
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.sale-channel-toggle {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding-top: 0.25rem;
|
||||
}
|
||||
|
||||
.sale-channel-content strong {
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.sale-channel-warning {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.sale-channel-wrapper .icheck-success > input:first-child + label::before,
|
||||
.sale-channel-wrapper .icheck-primary > input:first-child + label::before,
|
||||
.sale-channel-wrapper .icheck-danger > input:first-child + label::before {
|
||||
opacity: 1;
|
||||
border-width: 2px;
|
||||
border-color: #9ca3af;
|
||||
}
|
||||
|
||||
.sale-channel-wrapper.blocked .icheck-success > input:first-child + label::before,
|
||||
.sale-channel-wrapper.blocked .icheck-primary > input:first-child + label::before,
|
||||
.sale-channel-wrapper.blocked .icheck-danger > input:first-child + label::before {
|
||||
border-color: #cbd5f5;
|
||||
background-color: #f8fafc;
|
||||
}
|
||||
|
||||
.sale-channel-wrapper .icheck-success > input:first-child + label,
|
||||
.sale-channel-wrapper .icheck-primary > input:first-child + label,
|
||||
.sale-channel-wrapper .icheck-danger > input:first-child + label {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.sale-channel-wrapper [class*="icheck-"] > input:first-child:disabled + label {
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@php
|
||||
$saleChannelsCollection = collect($sale_channels);
|
||||
$firstSaleChannel = $saleChannelsCollection->first();
|
||||
$selectedSaleChannelId = $customer['default_sale_channel_id'] ?? ($firstSaleChannel['id'] ?? null);
|
||||
$cartCount = app('App\\Repositories\\Core\\User\\ShopCart')::count();
|
||||
@endphp
|
||||
|
||||
@if ($cartCount > 0)
|
||||
<div class="alert alert-warning">
|
||||
<strong>Note :</strong> en changeant votre mode d'achat, les articles de votre panier seront transférés sur la liste de prix correspondant au nouveau canal de vente sélectionné.
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@foreach ($saleChannelsCollection as $saleChannel)
|
||||
@php
|
||||
$check = $sale_channel_checks[$saleChannel['id']] ?? null;
|
||||
$isBlocked = $check && $saleChannel['id'] !== $selectedSaleChannelId;
|
||||
@endphp
|
||||
<div class="card sale-channel-wrapper mb-3 @if($isBlocked) blocked @endif">
|
||||
<div class="card-body py-3">
|
||||
<div class="row align-items-start">
|
||||
<div class="col-1 sale-channel-toggle">
|
||||
|
||||
@foreach ($deliveries as $delivery)
|
||||
<div class="row">
|
||||
<div class="col-1 text-right pt-1">
|
||||
@include('components.form.radios.icheck', [
|
||||
'name' => 'sale_channel_id',
|
||||
'id_name' => 'sale_channel_id_' . $saleChannel['id'],
|
||||
'val' => $saleChannel['id'],
|
||||
'value' => $selectedSaleChannelId,
|
||||
'class' => 'sale-channel',
|
||||
'disabled' => $isBlocked,
|
||||
'name' => 'delivery_id',
|
||||
'id_name' => 'delivery_id_' . $delivery['id'],
|
||||
'value' => $delivery['id'],
|
||||
'checked' => $customer['sale_delivery_id'] ?? false,
|
||||
'class' => 'delivery',
|
||||
])
|
||||
</div>
|
||||
<div class="col-11 sale-channel-content @if($isBlocked) text-muted @endif">
|
||||
<strong>{{ $saleChannel['name'] }}</strong><br />
|
||||
<p class="mb-2">{!! $saleChannel['description'] ?? '' !!}</p>
|
||||
@if ($check)
|
||||
<div class="text-danger small mb-0 sale-channel-warning">
|
||||
@php $missingCount = $check['full_count'] ?? count($check['names']); @endphp
|
||||
@if ($cartCount > 0 && $missingCount >= $cartCount)
|
||||
{{ __('shop.sale_channels.missing_offers_all') }}
|
||||
@else
|
||||
{{ trans_choice('shop.sale_channels.missing_offers', $missingCount, ['count' => $missingCount]) }}
|
||||
<br>
|
||||
@if ($missingCount > 3)
|
||||
<span class="d-block">{{ implode(', ', array_slice($check['names'], 0, 3)) }}, …</span>
|
||||
@else
|
||||
<span class="d-block">{{ implode(', ', $check['names']) }}</span>
|
||||
@endif
|
||||
@endif
|
||||
<div class="d-flex align-items-start mt-1">
|
||||
<span class="mr-1">⚠️</span>
|
||||
<span>{{ __('shop.sale_channels.cannot_select_with_cart') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-11 pt-3">
|
||||
<strong>{{ $delivery['name'] }} - {{ $delivery['sale_channel']['name'] }}</strong><br />
|
||||
<p>{{ $delivery['description'] }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
const $saleChannels = $('.sale-channel');
|
||||
const updateUrl = '{{ route('Shop.Customers.storeProfileAjax') }}';
|
||||
const token = '{{ csrf_token() }}';
|
||||
const customerId = {{ $customer['id'] ?? 'null' }};
|
||||
let currentSaleChannelId = '{{ $selectedSaleChannelId }}';
|
||||
|
||||
$saleChannels.off().change(function() {
|
||||
if (!customerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedSaleChannel = $(this).val();
|
||||
|
||||
$.post(updateUrl, {
|
||||
_token: token,
|
||||
id: customerId,
|
||||
default_sale_channel_id: selectedSaleChannel,
|
||||
}).done(function() {
|
||||
currentSaleChannelId = selectedSaleChannel;
|
||||
window.location.reload();
|
||||
}).fail(function(xhr) {
|
||||
const message = xhr.responseJSON && xhr.responseJSON.message
|
||||
? xhr.responseJSON.message
|
||||
: "{{ __('Une erreur est survenue lors de l\'enregistrement du canal de vente préféré.') }}";
|
||||
|
||||
alert(message);
|
||||
|
||||
if (currentSaleChannelId) {
|
||||
$saleChannels.filter('[value="' + currentSaleChannelId + '"]').prop('checked', true);
|
||||
}
|
||||
});
|
||||
$('.delivery').off().change(function() {
|
||||
console.log($(this).val());
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -1,69 +1,35 @@
|
||||
@php
|
||||
$saleChannels = $sale_channels ?? [];
|
||||
@endphp
|
||||
|
||||
@if (count($saleChannels) > 1)
|
||||
<nav>
|
||||
<div class="nav nav-tabs pl-2">
|
||||
<a href="#deliveriesTab" data-toggle="tab" class="nav-item nav-link active" role="tab" aria-selected="true">
|
||||
MON MODE D'ACHAT
|
||||
</a>
|
||||
<a href="#ordersTab" data-toggle="tab" class="nav-item nav-link" role="tab" aria-selected="false">
|
||||
SUIVI DE COMMANDES
|
||||
</a>
|
||||
<a href="#invoicesTab" data-toggle="tab" class="nav-item nav-link" role="tab" aria-selected="false">
|
||||
FACTURES
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active pt-0 pb-0" id="deliveriesTab">
|
||||
<x-card classBody="bg-light">
|
||||
@include('Shop.Customers.partials.deliveries')
|
||||
</x-card>
|
||||
</div>
|
||||
<div class="tab-pane fade show pt-0 pb-0" id="ordersTab">
|
||||
<x-card classBody="bg-light">
|
||||
@include('Shop.Orders.partials.list', [
|
||||
'dataTable' => $orders,
|
||||
])
|
||||
</x-card>
|
||||
</div>
|
||||
<div class="tab-pane fade show pt-0 pb-0" id="invoicesTab">
|
||||
<x-card classBody="bg-light">
|
||||
@include('Shop.Invoices.partials.list', [
|
||||
'dataTable' => $invoices,
|
||||
])
|
||||
</x-card>
|
||||
</div>
|
||||
<nav>
|
||||
<div class="nav nav-tabs pl-2">
|
||||
<a href="#deliveriesTab" data-toggle="tab" class="nav-item nav-link active" role="tab" aria-selected="true">
|
||||
MON MODE D'ACHAT
|
||||
</a>
|
||||
<a href="#ordersTab" data-toggle="tab" class="nav-item nav-link" role="tab" aria-selected="false">
|
||||
SUIVI DE COMMANDES
|
||||
</a>
|
||||
<a href="#invoicesTab" data-toggle="tab" class="nav-item nav-link" role="tab" aria-selected="false">
|
||||
FACTURES
|
||||
</a>
|
||||
</div>
|
||||
@else
|
||||
<nav>
|
||||
<div class="nav nav-tabs pl-2">
|
||||
<a href="#ordersTab" data-toggle="tab" class="nav-item nav-link active" role="tab" aria-selected="true">
|
||||
SUIVI DE COMMANDES
|
||||
</a>
|
||||
<a href="#invoicesTab" data-toggle="tab" class="nav-item nav-link" role="tab" aria-selected="false">
|
||||
FACTURES
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</nav>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active pt-0 pb-0" id="ordersTab">
|
||||
<x-card classBody="bg-light">
|
||||
@include('Shop.Orders.partials.list', [
|
||||
'dataTable' => $orders,
|
||||
])
|
||||
</x-card>
|
||||
</div>
|
||||
<div class="tab-pane fade show pt-0 pb-0" id="invoicesTab">
|
||||
<x-card classBody="bg-light">
|
||||
@include('Shop.Invoices.partials.list', [
|
||||
'dataTable' => $invoices,
|
||||
])
|
||||
</x-card>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active pt-0 pb-0" id="deliveriesTab">
|
||||
<x-card classBody="bg-light">
|
||||
@include('Shop.Customers.partials.deliveries')
|
||||
</x-card>
|
||||
</div>
|
||||
@endif
|
||||
<div class="tab-pane fade show pt-0 pb-0" id="ordersTab">
|
||||
<x-card classBody="bg-light">
|
||||
@include('Shop.Orders.partials.list', [
|
||||
'dataTable' => $orders,
|
||||
])
|
||||
</x-card>
|
||||
</div>
|
||||
<div class="tab-pane fade show pt-0 pb-0" id="invoicesTab">
|
||||
<x-card classBody="bg-light">
|
||||
@include('Shop.Invoices.partials.list', [
|
||||
'dataTable' => $invoices,
|
||||
])
|
||||
</x-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,51 +1,13 @@
|
||||
@php
|
||||
$addresses = collect($addresses ?? []);
|
||||
$preselectedAddressId = old($name);
|
||||
|
||||
if ($preselectedAddressId === null && is_string($name) && str_contains($name, '[')) {
|
||||
$dotName = preg_replace('/\[(.*?)\]/', '.$1', $name);
|
||||
$dotName = trim($dotName, '.');
|
||||
$preselectedAddressId = $dotName ? old($dotName) : null;
|
||||
}
|
||||
|
||||
if (($preselectedAddressId === null || $preselectedAddressId === '') && $addresses->isNotEmpty()) {
|
||||
$defaultAddress = $addresses->firstWhere('priority', 1);
|
||||
|
||||
if (! $defaultAddress) {
|
||||
$defaultAddress = $addresses
|
||||
->filter(function ($address) {
|
||||
return (int) ($address['priority'] ?? 0) > 0;
|
||||
})
|
||||
->sortByDesc(function ($address) {
|
||||
return (int) ($address['priority'] ?? 0);
|
||||
})
|
||||
->first();
|
||||
}
|
||||
|
||||
if (! $defaultAddress) {
|
||||
$defaultAddress = $addresses->firstWhere('is_default', true)
|
||||
?? $addresses->firstWhere('default', true);
|
||||
}
|
||||
|
||||
if (! $defaultAddress) {
|
||||
$defaultAddress = $addresses->first();
|
||||
}
|
||||
|
||||
$preselectedAddressId = $defaultAddress['id'] ?? null;
|
||||
}
|
||||
|
||||
$addresses = $addresses->all();
|
||||
@endphp
|
||||
|
||||
@if ($addresses)
|
||||
@foreach ($addresses as $address)
|
||||
@foreach ($addresses ?? [] as $address)
|
||||
<div class="row mb-3">
|
||||
<div class="col-1">
|
||||
@include('components.form.radios.icheck', [
|
||||
'name' => $name,
|
||||
'val' => $address['id'],
|
||||
'id' => $prefix . '_address_' . $address['id'],
|
||||
'value' => $preselectedAddressId,
|
||||
'value' =>
|
||||
old($name) ?? $address['priority'] || count($addresses) === 1 ? $address['id'] : false,
|
||||
])
|
||||
</div>
|
||||
<div class="col-11">
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
@php
|
||||
$defaultSaleChannelId = $customer['default_sale_channel_id'] ?? null;
|
||||
$preselectedDeliveryId = old('delivery_id');
|
||||
|
||||
if (! $preselectedDeliveryId && $defaultSaleChannelId) {
|
||||
$match = collect($deliveries)->firstWhere('sale_channel_id', $defaultSaleChannelId);
|
||||
$preselectedDeliveryId = $match['id'] ?? null;
|
||||
}
|
||||
@endphp
|
||||
|
||||
@foreach ($deliveries as $delivery)
|
||||
<div class="row">
|
||||
<div class="col-1">
|
||||
@include('components.form.radios.icheck', [
|
||||
'name' => 'delivery_id',
|
||||
'val' => $delivery['id'],
|
||||
'value' => $preselectedDeliveryId,
|
||||
'value' => (int) old('delivery_id') === $delivery['id'] ? $delivery['id'] : null,
|
||||
'id' => 'delivery_' . $delivery['id'],
|
||||
'class' => 'delivery_mode' . ($delivery['at_house'] ? ' at_house' : ''),
|
||||
])
|
||||
@@ -39,29 +29,16 @@ ci-contre
|
||||
@push('js')
|
||||
<script>
|
||||
function handleDeliveries() {
|
||||
var $deliveryInputs = $('#delivery_mode input.delivery_mode');
|
||||
|
||||
$deliveryInputs.change(function() {
|
||||
var $currentDelivery = $(this);
|
||||
var deliveryTypeId = $('input[name=delivery_type_id]:checked').val();
|
||||
|
||||
if ($currentDelivery.hasClass('at_house')) {
|
||||
$('#delivery_mode input.delivery_mode').change(function() {
|
||||
if ($(this).hasClass('at_house')) {
|
||||
$('#delivery_addresses').closest('.card').removeClass('d-none');
|
||||
var deliveryTypeId = $('input[name=delivery_type_id]:checked').val()
|
||||
} else {
|
||||
$('#delivery_addresses').closest('.card').addClass('d-none');
|
||||
}
|
||||
|
||||
var deliveryId = $currentDelivery.val();
|
||||
var deliveryId = $(this).val();
|
||||
refreshBasketTotal(deliveryId, deliveryTypeId);
|
||||
});
|
||||
|
||||
var $preselected = $deliveryInputs.filter(':checked').first();
|
||||
|
||||
if ($preselected.length) {
|
||||
$preselected.trigger('change');
|
||||
} else {
|
||||
$('#delivery_addresses').closest('.card').addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
handleDeliveries();
|
||||
|
||||
@@ -7,18 +7,7 @@
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@php
|
||||
$deliveryTypes = collect($delivery_types);
|
||||
$preselectedDeliveryTypeId = old('delivery_type_id');
|
||||
|
||||
if ($preselectedDeliveryTypeId === null || $preselectedDeliveryTypeId === '') {
|
||||
$preselectedDeliveryTypeId = $deliveryTypes->keys()->first();
|
||||
}
|
||||
|
||||
$deliveryTypes = $deliveryTypes->all();
|
||||
@endphp
|
||||
|
||||
@foreach ($deliveryTypes as $delivery_type_id => $delivery_type)
|
||||
@foreach ($delivery_types as $delivery_type_id => $delivery_type)
|
||||
<tr>
|
||||
<td>
|
||||
@include('components.form.radios.icheck', [
|
||||
@@ -26,7 +15,6 @@
|
||||
'val' => $delivery_type_id,
|
||||
'id' => 'delivery_type_' . $delivery_type_id,
|
||||
'class' => 'delivery_type',
|
||||
'value' => $preselectedDeliveryTypeId,
|
||||
])
|
||||
</td>
|
||||
<td>
|
||||
@@ -43,19 +31,11 @@
|
||||
@push('js')
|
||||
<script>
|
||||
function handleDeliveryTypes() {
|
||||
var $deliveryTypeInputs = $('input.delivery_type');
|
||||
|
||||
$deliveryTypeInputs.change(function() {
|
||||
$('input.delivery_type').change(function() {
|
||||
var deliveryTypeId = $(this).val();
|
||||
var deliveryId = $('input[name=delivery_id]:checked').val()
|
||||
refreshBasketTotal(deliveryId, deliveryTypeId);
|
||||
});
|
||||
|
||||
var $preselected = $deliveryTypeInputs.filter(':checked').first();
|
||||
|
||||
if ($preselected.length) {
|
||||
$preselected.trigger('change');
|
||||
}
|
||||
}
|
||||
handleDeliveryTypes();
|
||||
</script>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{{ asset('img/favicon.ico') }}">
|
||||
<link rel="stylesheet" href="/css/site.min.css?{{ date('Ymd') }}" type="text/css" media="all">
|
||||
|
||||
@stack('styles')
|
||||
@stack('css')
|
||||
|
||||
</head>
|
||||
|
||||
@@ -38,8 +38,7 @@
|
||||
/<(p|a|div|span|strike|strong|i|u)[^>]*?>(\s| |<br\/>|\r|\n)*?<\/(p|a|div|span|strike|strong|i|u)>/gi,
|
||||
''); // Empty tags
|
||||
},
|
||||
skin: "oxide",
|
||||
content_css: 'oxide',
|
||||
skin: "boilerplate",
|
||||
language: '{{ App::getLocale() }}',
|
||||
file_picker_callback: function(callback, value, meta) {
|
||||
var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName(
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
Route::prefix('CustomerInvoices')->name('CustomerInvoices.')->group(function () {
|
||||
Route::get('', 'CustomerInvoiceController@index')->name('index');
|
||||
Route::delete('destroy/{id?}', 'CustomerInvoiceController@destroy')->name('destroy');
|
||||
Route::get('view/{id?}', 'CustomerInvoiceController@view')->name('view');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user