diff --git a/.env.example b/.env.example index 750bb5ee..c5c08d48 100644 --- a/.env.example +++ b/.env.example @@ -43,6 +43,8 @@ SENTRY_LARAVEL_DSN= # Matomo MATOMO_SITE_ID= -## ADMIN SECURE -LDC_WEB_API_KEY= -LDC_WEB_CIDR_MANUAL_ALLOWED_LIST= \ No newline at end of file +# UWIL ADMIN SECURE +# - LIST SEPARATED WITH ',' (Required) +UWIL_ADMIN_SECURE_CIDR_LIST="" +# - LIST SEPARATED WITH ',' (Optional) +UWIL_ADMIN_SECURE_CIDR_PROJECT_ALLOWED_LIST="" diff --git a/app/Http/Controllers/Bo/ProductsController.php b/app/Http/Controllers/Bo/ProductsController.php index 9574fa0d..bbd8a5d7 100644 --- a/app/Http/Controllers/Bo/ProductsController.php +++ b/app/Http/Controllers/Bo/ProductsController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bo; use App\Http\Controllers\Controller; use App\Http\Requests\Bo\ProductRequest; +use App\Http\Requests\Bo\UpdateProductOrderRequest; use App\Models\OldSlug; use App\Models\FoodProduct; use App\Models\ToolProduct; @@ -18,6 +19,7 @@ use App\Traits\Controllers\ChangesModelOrder; use App\Traits\Controllers\UpdateModelStatus; use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use Illuminate\Support\Facades\File; @@ -867,4 +869,35 @@ class ProductsController extends Controller $products = Product::where('star', 1)->paginate(10); return view('bo.products.starred', compact('products')); } + + /** + * Update product order. + * + * @param UpdateProductOrderRequest $request + * @param Product $product + * @return void + */ + public function changeSelectedOrder(UpdateProductOrderRequest $request, Product $product) + { + // Laravel 8 style ... validated() never returns a string. + $validated = $request->validated(); + $newOrder = $validated['order']; + + return DB::transaction(function () use ($product, $newOrder) { + // Update all products who will be moved with this order update. + // Includes soft deleted to avoid problems if we restore them. + $request = Product::withTrashed() + ->where('id', '!=', $product->id) + ->whereBetween('order', [min($product->order, $newOrder), max($product->order, $newOrder)]); + $product->order < $newOrder ? $request->decrement('order', 1) : $request->increment('order', 1); + + // Update the product. + $product->order = $newOrder; + if (!$product->saveOrFail()) { + return back()->with('error', trans('crud.messages.order_not_changed')); + }; + + return redirect()->back()->with('success', trans('crud.messages.order_changed')); + }); + } } diff --git a/app/Http/Controllers/Bo/PromotionsController.php b/app/Http/Controllers/Bo/PromotionsController.php index 98e35417..309eccc9 100644 --- a/app/Http/Controllers/Bo/PromotionsController.php +++ b/app/Http/Controllers/Bo/PromotionsController.php @@ -49,17 +49,19 @@ class PromotionsController extends Controller 'product_id' => 'required', ]); - $productIds = explode(",", $request->product_id); - $discType = $request->discount_type_id; - $value = $request->discount_value; - $date_start = $request->date_start_date . " " . $request->date_start_time; - $date_end = $request->date_end_date . " " . $request->date_end_time; + $productIds = explode(",", $request->product_id); + $discType = $request->discount_type_id; + $value = $request->discount_value; + $isOldPriceDisplayed = $request->boolean('is_old_price_displayed'); + $date_start = $request->date_start_date . " " . $request->date_start_time; + $date_end = $request->date_end_date . " " . $request->date_end_time; - $promotion = new Promotion(); - $promotion->discount_type_id = $discType; - $promotion->discount_value = $value; - $promotion->date_start = $date_start; - $promotion->date_end = $date_end; + $promotion = new Promotion(); + $promotion->discount_type_id = $discType; + $promotion->discount_value = $value; + $promotion->is_old_price_displayed = $isOldPriceDisplayed; + $promotion->date_start = $date_start; + $promotion->date_end = $date_end; $promotion->save(); // Prise en charge de la liaison avec les produits. @@ -101,16 +103,18 @@ class PromotionsController extends Controller 'product_id' => 'required', ]); - $productIds = explode(",", $request->product_id); - $discType = $request->discount_type_id; - $value = $request->discount_value; - $date_start = $request->date_start_date . " " . $request->date_start_time; - $date_end = $request->date_end_date . " " . $request->date_end_time; + $productIds = explode(",", $request->product_id); + $discType = $request->discount_type_id; + $value = $request->discount_value; + $isOldPriceDisplayed = $request->boolean('is_old_price_displayed'); + $date_start = $request->date_start_date . " " . $request->date_start_time; + $date_end = $request->date_end_date . " " . $request->date_end_time; - $promotion->discount_type_id = $discType; - $promotion->discount_value = $value; - $promotion->date_start = $date_start; - $promotion->date_end = $date_end; + $promotion->discount_type_id = $discType; + $promotion->discount_value = $value; + $promotion->is_old_price_displayed = $isOldPriceDisplayed; + $promotion->date_start = $date_start; + $promotion->date_end = $date_end; $promotion->save(); // Prise en charge de la liaison avec les produits. diff --git a/app/Http/Controllers/ProductsController.php b/app/Http/Controllers/ProductsController.php index f330dcde..1da938bd 100644 --- a/app/Http/Controllers/ProductsController.php +++ b/app/Http/Controllers/ProductsController.php @@ -88,12 +88,18 @@ class ProductsController extends Controller /** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Product> */ $products = $productsQuery->orderBy('order', 'ASC')->paginate(6); + $brands = \collect(\App\Enums\ProductBrand::toArray())->filter( + function (\App\Enums\ProductBrand $case) { + return Product::query()->pluck('brand')->contains($case->value); + } + )->values(); + if ($request->ajax()) { return \response()->json([ProductResource::collection($products), $products->total()]); } else { $ranges = Range::all(); $tags = Tag::where('status', true)->get(); - return view('ranges', compact('products', 'ranges', 'tags', 'sessionFilter', 'filtersMenuIsOpen')); + return view('ranges', compact('products', 'ranges', 'tags', 'sessionFilter', 'filtersMenuIsOpen', 'brands')); } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 4b8847f9..e780bc63 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -63,5 +63,6 @@ class Kernel extends HttpKernel 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'is-admin' => \App\Http\Middleware\IsAdmin::class, 'is-super-admin' => \App\Http\Middleware\IsSuperAdmin::class, + 'admin-secure' => \App\Http\Middleware\AdminSecureMiddleware::class, ]; } diff --git a/app/Http/Middleware/AdminSecureMiddleware.php b/app/Http/Middleware/AdminSecureMiddleware.php new file mode 100644 index 00000000..a2ac87f5 --- /dev/null +++ b/app/Http/Middleware/AdminSecureMiddleware.php @@ -0,0 +1,50 @@ +getCidrList()) + ->reduce(function ($initial, $ip_range) use ($client_ip) { + return $initial || IP::contains( + $ip_range, + $client_ip + )->unwrap(); + }); + + $ip_is_allowed_by_config = \collect(AdminSecure::getOptions()->getCidrAllowedList()) + ->reduce(function ($initial, $ip_range) use ($client_ip) { + return $initial || IP::contains( + $ip_range, + $client_ip + )->unwrap(); + }); + + if ($ip_is_allowed or $ip_is_allowed_by_config or AdminSecure::ipIsPrivate($client_ip)) { + return $next($request); + } + + abort(403, \trans('Denied IP')); + } +} + diff --git a/app/Http/Requests/Bo/UpdateProductOrderRequest.php b/app/Http/Requests/Bo/UpdateProductOrderRequest.php new file mode 100644 index 00000000..cc01750b --- /dev/null +++ b/app/Http/Requests/Bo/UpdateProductOrderRequest.php @@ -0,0 +1,57 @@ +check(); + } + + /** + * Prepare the data for validation. + * + * @return void + */ + protected function prepareForValidation(): void + { + $this->product = $this->route('product'); + $max = Product::query()->max('order'); + + $this->merge([ + 'order' => min($this->input('order'), $max) + ]); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'order' => [ + 'required', + 'integer', + 'min:1', + function ($attribute, $value, $fail) { + if ($this->product && intval($value) === $this->product->order) { + $fail("La valeur de {$attribute} doit être différente de la valeur actuelle."); + } + }, + ], + ]; + } +} diff --git a/app/Lib/AdminSecure.php b/app/Lib/AdminSecure.php new file mode 100644 index 00000000..cc05a579 --- /dev/null +++ b/app/Lib/AdminSecure.php @@ -0,0 +1,131 @@ +server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp(); + $ip = IPAddress::Make($ip); + + if ($ip->isErr()) { + throw new \Exception(\trans('Client IP not valid ') . $ip->getErr()); + } + return $ip->unwrap(); + } + + /** + * Check if ipV4 is private + * + * @param \Dxw\CIDR\IPv4Address $ipv4_address + * @return boolean + */ + private static function ipV4IsPrivate(IPv4Address $ipv4_address): bool + { + return \collect(self::$private_ip_v4_cidr_list) + ->concat([self::$private_ip_v4_loopback_cidr]) + ->map(function (string $ipv4_cidr) { + return IPv4Range::Make($ipv4_cidr)->unwrap(); + }) + ->reduce(function ($initial, IPv4Range $ipv4_range) use ($ipv4_address) { + return $initial || $ipv4_range->containsAddress($ipv4_address); + }); + } + + /** + * Check if ipV6 is private + * + * @param \Dxw\CIDR\IPv6Address $ipv6_address + * @return boolean + */ + private static function ipV6IsPrivate(IPv6Address $ipv6_address): bool + { + return \collect(self::$private_ip_v6_cidr_list) + ->concat([self::$private_ip_v6_loopback_cidr]) + ->map(function (string $ipv6_cidr) { + return IPv6Range::Make($ipv6_cidr)->unwrap(); + }) + ->reduce(function ($initial, IPv6Range $ipv6_range) { + return $initial || $ipv6_range->containsAddress($ipv6_address); + }); + } + + /** + * Get Admin secure options + * + * @return \App\Lib\Options + */ + public static function getOptions(): Options + { + if (!self::$options) { + self::$options = new Options(\config('admin-secure')); + } + return self::$options; + } +} diff --git a/app/Lib/Options.php b/app/Lib/Options.php new file mode 100644 index 00000000..b627087a --- /dev/null +++ b/app/Lib/Options.php @@ -0,0 +1,159 @@ + The configuration options + */ + private $options; + + /** + * @var \Symfony\Component\OptionsResolver\OptionsResolver The options resolver + */ + private $resolver; + + /** + * The cache key where to store config cidr list. + * + * @var string + */ + private static $cache_config_key = 'uwil_ip_cidr_config_list'; + + /** + * Class constructor. + * + * @param array $options The configuration options. + */ + public function __construct(array $options = []) + { + $this->resolver = new OptionsResolver(); + + $this->configureOptions($this->resolver); + + $this->options = $this->resolver->resolve($options); + } + + /** + * Get cidr list + * + * @return array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range> + */ + public function getCidrList(): array + { + return $this->options['cidrList']; + } + + /** + * Get cidr project allowed list + * + * @return array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range> + */ + public function getCidrAllowedList(): array + { + return $this->options['cidrProjectAllowedList']; + } + + /** + * Configures the options of the client. + * + * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver The resolver for the options. + * @return void + */ + private function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'cidrList' => [], + 'cidrProjectAllowedList' => [] + ]); + + $resolver->setNormalizer('cidrList', \Closure::fromCallable([$this, 'normalizeCidrList'])); + $resolver->setNormalizer('cidrProjectAllowedList', \Closure::fromCallable([$this, 'normalizeCidrProjectList'])); + } + + /** + * Normalise Cidr list for cidrList option + * + * @param \Symfony\Component\OptionsResolver\Options $options + * @param string|null $value + * @return array + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed + */ + private function normalizeCidrList( + \Symfony\Component\OptionsResolver\Options $options, + ?string $value + ): array { + // phpcs:enable + return $this->doNormalizeCidrList($value, 'cidrList'); + } + + /** + * Normalise Cidr list for cidrProjectAllowedList option + * + * @param \Symfony\Component\OptionsResolver\Options $options + * @param string|null $value + * @return array + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed + */ + private function normalizeCidrProjectList( + \Symfony\Component\OptionsResolver\Options $options, + ?string $value + ): array { + // phpcs:enable + return $this->doNormalizeCidrList($value, 'cidrProjectAllowedList'); + } + + /** + * Normalize CIDR list with specific cache key. + * + * @param string|null $value + * @param string $optionName + * @return array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range> + */ + private function doNormalizeCidrList(?string $value, string $optionName): array + { + $cacheConfigKey = self::$cache_config_key . '_' . $optionName; + $allowed_cidr_config_list = collect(explode(',', strval($value)))->filter(); + $allowed_cidr_config_list_hash = \md5($allowed_cidr_config_list->implode(',')); + $allowed_cidr_list = []; + + // Flush cache if config hash changed + if ($allowed_cidr_config_list_hash !== \collect(Cache::get($cacheConfigKey))->get('hash')) { + Cache::forget($cacheConfigKey); + + /** @var array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range> $allowed_cidr_list */ + $allowed_cidr_list = $allowed_cidr_config_list + ->map(function (string $cidr) { + $ip_range = !IPv4Range::Make($cidr)->isErr() ? IPv4Range::Make($cidr) : IPv6Range::Make($cidr); + if ($ip_range->isErr()) { + throw new \Exception(\trans( + 'CIDR LIST not valid (ipv4 or ipv6 cidr) :cidr', + [ + 'cidr' => $cidr + ] + )); + } + return $ip_range->unwrap(); + })->all(); + } + + /** @var array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range> $allowed_cidr_list */ + return \collect(Cache::rememberForever($cacheConfigKey, function() use ($allowed_cidr_list, $allowed_cidr_config_list_hash) { + return [ + 'list' => $allowed_cidr_list, + 'hash' => $allowed_cidr_config_list_hash + ]; + }))->get('list'); + } +} diff --git a/app/Models/Promotion.php b/app/Models/Promotion.php index 648ee3f0..914e8309 100644 --- a/app/Models/Promotion.php +++ b/app/Models/Promotion.php @@ -15,8 +15,9 @@ class Promotion extends Model * @var array */ protected $casts = [ - 'date_start' => 'datetime', - 'date_end' => 'datetime', + 'is_old_price_displayed' => 'boolean', + 'date_start' => 'datetime', + 'date_end' => 'datetime', ]; /** diff --git a/composer.json b/composer.json index 8cd0311f..d09a148b 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "php": "^7.3", "bumbummen99/shoppingcart": "^4.0", "diglactic/laravel-breadcrumbs": "^6.1", + "dxw/cidr": "^3.1", "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", @@ -18,7 +19,6 @@ "laravel/framework": "^8.12", "laravel/tinker": "^2.5", "ldc/ldccrmv2client": "^3.0", - "ldc/web-admin-secure-laravel": "^1.0", "maatwebsite/excel": "^3.1", "mews/purifier": "^3.3", "sentry/sentry-laravel": "^3.7", diff --git a/composer.lock b/composer.lock index 05f4f78e..bc77d0c9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f125859babe93c1c3b34a7e9b30cd499", + "content-hash": "d53d0cc95f99b7d1705ef16b912f287d", "packages": [ { "name": "asm89/stack-cors", @@ -715,6 +715,107 @@ ], "time": "2024-10-09T13:47:03+00:00" }, + { + "name": "dxw/cidr", + "version": "v3.1.2", + "source": { + "type": "git", + "url": "https://github.com/dxw/cidr.git", + "reference": "9cb82cb70f0d4a4a32b1b2e3e1ae005fba84d581" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dxw/cidr/zipball/9cb82cb70f0d4a4a32b1b2e3e1ae005fba84d581", + "reference": "9cb82cb70f0d4a4a32b1b2e3e1ae005fba84d581", + "shasum": "" + }, + "require": { + "dxw/result": "^1.0", + "php": "^7.2", + "phpseclib/phpseclib": "^2.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.16", + "mockery/mockery": "^1.3", + "peridot-php/leo": "^1.6", + "peridot-php/peridot": "^1.19", + "peridot-php/peridot-dot-reporter": "^1.0", + "vimeo/psalm": "^4.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Dxw\\CIDR\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "dxw", + "email": "team@govpress.com", + "homepage": "https://www.dxw.com" + } + ], + "description": "IP address matching with CIDR ranges", + "homepage": "https://github.com/dxw/cidr", + "support": { + "issues": "https://github.com/dxw/cidr/issues", + "source": "https://github.com/dxw/cidr/tree/v3.1.2" + }, + "time": "2021-04-13T15:13:30+00:00" + }, + { + "name": "dxw/result", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/dxw/result.git", + "reference": "5b9d3988c215dc95e17cd082a33bc2c02b6007ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dxw/result/zipball/5b9d3988c215dc95e17cd082a33bc2c02b6007ca", + "reference": "5b9d3988c215dc95e17cd082a33bc2c02b6007ca", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.16", + "peridot-php/leo": "^1.6", + "peridot-php/peridot": "^1.19", + "peridot-php/peridot-dot-reporter": "^1.0", + "vimeo/psalm": "^3.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Dxw\\Result\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mallory Adams", + "email": "mallory@dxw.com", + "homepage": "https://www.dxw.com/" + } + ], + "description": "Result values", + "homepage": "https://github.com/dxw/result", + "support": { + "issues": "https://github.com/dxw/result/issues", + "source": "https://github.com/dxw/result/tree/master" + }, + "time": "2020-06-12T16:01:47+00:00" + }, { "name": "egulias/email-validator", "version": "2.1.25", @@ -1672,66 +1773,6 @@ }, "time": "2022-07-28T15:18:54+00:00" }, - { - "name": "kwaadpepper/refresh-sitemap", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/Kwaadpepper/refresh-sitemap.git", - "reference": "4fdae6d0e9423f5af9216c74814929744807b6bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Kwaadpepper/refresh-sitemap/zipball/4fdae6d0e9423f5af9216c74814929744807b6bb", - "reference": "4fdae6d0e9423f5af9216c74814929744807b6bb", - "shasum": "" - }, - "require": { - "illuminate/support": "~8", - "kwaadpepper/enum": "~2", - "laravel/framework": "~8", - "spatie/laravel-sitemap": "^5.8" - }, - "require-dev": { - "slevomat/coding-standard": "^7.2" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Kwaadpepper\\RefreshSitemap\\RefreshSitemapServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Kwaadpepper\\RefreshSitemap\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jérémy Munsch", - "email": "github@jeremydev.ovh", - "homepage": "https://jeremydev.ovh" - } - ], - "description": "Create sitemap.xml for all routes", - "homepage": "https://github.com/kwaadpepper/refresh-sitemap", - "keywords": [ - "Sitemap", - "laravel" - ], - "support": { - "issues": "https://github.com/Kwaadpepper/refresh-sitemap/issues", - "source": "https://github.com/Kwaadpepper/refresh-sitemap/tree/1.1.0" - }, - "abandoned": "sitemap-refresh", - "time": "2023-03-06T08:27:09+00:00" - }, { "name": "laravel/framework", "version": "v8.83.29", @@ -2089,70 +2130,6 @@ "Laravel" ] }, - { - "name": "ldc/web-admin-secure-laravel", - "version": "1.0.1", - "source": { - "type": "git", - "url": "git@lab.s-web.fr:ldc-web/projets/ldc-web-admin-secure-laravel.git", - "reference": "c538f5d349b119ac64cb62b33e6368bef6be90bc" - }, - "dist": { - "type": "zip", - "url": "https://lab.s-web.fr/api/v4/projects/20/packages/composer/archives/ldc/web-admin-secure-laravel.zip?sha=c538f5d349b119ac64cb62b33e6368bef6be90bc", - "reference": "c538f5d349b119ac64cb62b33e6368bef6be90bc", - "shasum": "" - }, - "require": { - "illuminate/support": "~8|~9", - "laravel/framework": "~8|~9", - "php": "~7.3|7.4|~8" - }, - "require-dev": { - "orchestra/testbench": "^6.24", - "phpunit/php-code-coverage": "^9.2", - "phpunit/phpunit": "~9.0", - "slevomat/coding-standard": "^7.0", - "squizlabs/php_codesniffer": "^3.5" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "LDC\\WebAdminSecureLaravel\\AdminSecureServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "LDC\\WebAdminSecureLaravel\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "LDC\\WebAdminSecureLaravel\\Tests\\": "tests" - } - }, - "scripts": { - "test": [ - "vendor/bin/phpunit" - ], - "post-autoload-dump": [ - "@php ./vendor/bin/testbench package:discover --ansi" - ] - }, - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Vincent BRIDIER", - "email": "vincent.bridier@ldc.fr", - "homepage": "https://www.ldc.fr" - } - ], - "description": "Restrict access to LDC Network" - }, { "name": "league/commonmark", "version": "1.6.7", @@ -3885,6 +3862,116 @@ ], "time": "2024-07-20T21:41:07+00:00" }, + { + "name": "phpseclib/phpseclib", + "version": "2.0.51", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/phpseclib.git", + "reference": "ed661e7cdaeb8c419e609e2f3203551a13c2ed48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/ed661e7cdaeb8c419e609e2f3203551a13c2ed48", + "reference": "ed661e7cdaeb8c419e609e2f3203551a13c2ed48", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phing/phing": "~2.7", + "phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4", + "squizlabs/php_codesniffer": "~2.0" + }, + "suggest": { + "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", + "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", + "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", + "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations.", + "ext-xml": "Install the XML extension to load XML formatted public keys." + }, + "type": "library", + "autoload": { + "files": [ + "phpseclib/bootstrap.php" + ], + "psr-4": { + "phpseclib\\": "phpseclib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Wigginton", + "email": "terrafrost@php.net", + "role": "Lead Developer" + }, + { + "name": "Patrick Monnerat", + "email": "pm@datasphere.ch", + "role": "Developer" + }, + { + "name": "Andreas Fischer", + "email": "bantu@phpbb.com", + "role": "Developer" + }, + { + "name": "Hans-Jürgen Petrich", + "email": "petrich@tronic-media.com", + "role": "Developer" + }, + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "role": "Developer" + } + ], + "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", + "homepage": "http://phpseclib.sourceforge.net", + "keywords": [ + "BigInteger", + "aes", + "asn.1", + "asn1", + "blowfish", + "crypto", + "cryptography", + "encryption", + "rsa", + "security", + "sftp", + "signature", + "signing", + "ssh", + "twofish", + "x.509", + "x509" + ], + "support": { + "issues": "https://github.com/phpseclib/phpseclib/issues", + "source": "https://github.com/phpseclib/phpseclib/tree/2.0.51" + }, + "funding": [ + { + "url": "https://github.com/terrafrost", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpseclib", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", + "type": "tidelift" + } + ], + "time": "2026-01-27T09:11:52+00:00" + }, { "name": "psr/clock", "version": "1.0.0", diff --git a/config/admin-secure.php b/config/admin-secure.php new file mode 100644 index 00000000..e94639af --- /dev/null +++ b/config/admin-secure.php @@ -0,0 +1,6 @@ + env('UWIL_ADMIN_SECURE_CIDR_LIST'), + 'cidrProjectAllowedList' => env('UWIL_ADMIN_SECURE_CIDR_PROJECT_ALLOWED_LIST') +]; diff --git a/database/migrations/2026_02_25_102520_reorder_all_products.php b/database/migrations/2026_02_25_102520_reorder_all_products.php new file mode 100644 index 00000000..61653517 --- /dev/null +++ b/database/migrations/2026_02_25_102520_reorder_all_products.php @@ -0,0 +1,29 @@ +orderBy('order')->get(); + $order = 1; + foreach ($products as $product) { + $product->order = $order; + $product->saveOrFail(); + $order++; + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // Nothing to revert. + } +}; diff --git a/database/migrations/2026_02_25_111055_add_boolean_display_old_value_for_promotions_table.php b/database/migrations/2026_02_25_111055_add_boolean_display_old_value_for_promotions_table.php new file mode 100644 index 00000000..80205bde --- /dev/null +++ b/database/migrations/2026_02_25_111055_add_boolean_display_old_value_for_promotions_table.php @@ -0,0 +1,32 @@ +boolean('is_old_price_displayed')->comment('Should the old price be displayed ?')->after('discount_value'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('promotions', function (Blueprint $table) { + $table->dropColumn('is_old_price_displayed'); + }); + } +} diff --git a/manifest.yaml b/manifest.yaml index 85c94f35..447df561 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -27,8 +27,7 @@ data: CRM_PASSWORD: "${APP_CRM_PASSWORD}" SENTRY_LARAVEL_DSN: "${APP_SENTRY_LARAVEL_DSN}" MATOMO_SITE_ID: "${APP_MATOMO_SITE_ID}" - LDC_WEB_API_KEY: "${APP_LDC_WEB_API_KEY}" - LDC_WEB_CIDR_MANUAL_ALLOWED_LIST: "${APP_LDC_WEB_CIDR_MANUAL_ALLOWED_LIST}" + UWIL_ADMIN_SECURE_CIDR_LIST: "${APP_GLOBAL_UWIL_ADMIN_SECURE_CIDR_LIST}" --- apiVersion: v1 kind: PersistentVolumeClaim diff --git a/resources/views/bo/modules/change-model-order-select.blade.php b/resources/views/bo/modules/change-model-order-select.blade.php new file mode 100644 index 00000000..acfd6a0d --- /dev/null +++ b/resources/views/bo/modules/change-model-order-select.blade.php @@ -0,0 +1,23 @@ + +
+ {{ $value ?? '' }} + + +
+ + diff --git a/resources/views/bo/products/index.blade.php b/resources/views/bo/products/index.blade.php index 04f40ee5..2ac8205a 100644 --- a/resources/views/bo/products/index.blade.php +++ b/resources/views/bo/products/index.blade.php @@ -71,7 +71,7 @@ - @foreach ($products as $product) + @foreach ($products as $key => $product) @if(count(Config::get('theme.enum_product_types'))>1) @@ -110,11 +110,9 @@ - @php $routeName = request()->route()->getName(); @endphp - @include('bo.modules.change-model-order', [ - 'routeName' => 'products', - 'models' => $products, - 'model' => $product + @include('bo.modules.change-model-order-select', [ + 'model' => $product, + 'value' => $key + 1 + ($products->currentPage() - 1) * $products->perPage(), ]) Éditer diff --git a/resources/views/bo/promotions/create.blade.php b/resources/views/bo/promotions/create.blade.php index 35f13951..73560c13 100644 --- a/resources/views/bo/promotions/create.blade.php +++ b/resources/views/bo/promotions/create.blade.php @@ -40,7 +40,17 @@
- montant ou pourcentage de remise selon le type choisi + Montant ou pourcentage de remise selon le type choisi +
+
+ + + Cocher pour afficher l'ancien prix
diff --git a/resources/views/bo/promotions/edit.blade.php b/resources/views/bo/promotions/edit.blade.php index 82ea775e..dddd5501 100644 --- a/resources/views/bo/promotions/edit.blade.php +++ b/resources/views/bo/promotions/edit.blade.php @@ -44,7 +44,18 @@
- montant ou pourcentage de remise selon le type choisi + Montant ou pourcentage de remise selon le type choisi +
+
+
+ is_old_price_displayed)) checked @endif> +
+ Cocher pour afficher l'ancien prix
diff --git a/resources/views/bo/promotions/index.blade.php b/resources/views/bo/promotions/index.blade.php index 201973c5..00d82012 100644 --- a/resources/views/bo/promotions/index.blade.php +++ b/resources/views/bo/promotions/index.blade.php @@ -15,6 +15,7 @@ Type Valeur + Ancien prix affiché ? Début Fin Produits Concernés @@ -25,6 +26,7 @@ {{$promotion->discountType->label}} {{$promotion->discount_value}} + {{ $promotion->is_old_price_displayed ? 'Oui' : 'Non' }} {{$promotion->date_start}} {{$promotion->date_end}} diff --git a/resources/views/front/sable/home.blade.php b/resources/views/front/sable/home.blade.php index d975c3f9..97630cd4 100644 --- a/resources/views/front/sable/home.blade.php +++ b/resources/views/front/sable/home.blade.php @@ -31,7 +31,7 @@

@if ($product->weight_variable) Environ* @endif @fmt_currency($product->discountedPriceTtc) - @if ($product->promotions->count()) + @if ($product->promotions->count() && $product->promotions()->first()->is_old_price_displayed) @fmt_currency_without_ttc($product->priceTtc) @endif /{{ $product->sell_unit }} @@ -44,9 +44,12 @@ @endif

foodProduct->nutriscore . ".png") }}"> - @can('addToCart', $product) + @if( + Auth::guard('customer')->user() && + Auth::guard('customer')->user()->can('addToCart', $product) + ) - @endcan + @endif
diff --git a/resources/views/front/sable/js/components/FilterComponent.vue b/resources/views/front/sable/js/components/FilterComponent.vue index 46efd55f..d720b3c9 100644 --- a/resources/views/front/sable/js/components/FilterComponent.vue +++ b/resources/views/front/sable/js/components/FilterComponent.vue @@ -138,7 +138,11 @@
Environ* {{ currencyFormatter(product.discountedPriceTtc) }} - {{ currencyFormatter(product.priceTtc) }} + + {{ currencyFormatter(product.priceTtc) }} + /{{ product.sell_unit }}

*Produit vendu au kilo : {{ currencyFormatter(product.priceKgTtc) }} /kg

@@ -206,7 +210,8 @@ btnFilterCross: undefined, btnSearch: undefined, filters: [], - filtersMenuIsOpen: 0 + filtersMenuIsOpen: 0, + shouldDisplayPrices: false, } }, mounted() { @@ -221,6 +226,7 @@ this.productsResults = jsonData.productsResults ?? 0; this.filters = jsonData.filters ?? []; this.filtersMenuIsOpen = jsonData.filtersMenuIsOpen ?? []; + this.shouldDisplayPrices = jsonData.shouldDisplayPrices ?? false; this.selectFilters(); this.responsiveFilters(); this.countResults(); @@ -400,6 +406,9 @@ if (isNaN(num)) { return num; } + if (!this.shouldDisplayPrices) { + return '-.--'; + } return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(num); } } diff --git a/resources/views/front/sable/layouts/navbar.blade.php b/resources/views/front/sable/layouts/navbar.blade.php index 4187a0da..eda24d3b 100644 --- a/resources/views/front/sable/layouts/navbar.blade.php +++ b/resources/views/front/sable/layouts/navbar.blade.php @@ -20,7 +20,7 @@ {{ __('Offres') }} + href="{{ route('products') }}"> {{ __('Rayons') }} @foreach ($slides as $slide) -

{{ $slide->title }}

- @if(!empty($slide->picture)) - - @endif +
+
!empty($slide->picture), + "col-lg-10 col-lg-offset-1" => empty($slide->picture), + ])> +

{{ $slide->title }}

+
+ @if(!empty($slide->picture)) +
+ +
+ @endif +
@endforeach diff --git a/resources/views/front/sable/product.blade.php b/resources/views/front/sable/product.blade.php index 89b87c37..797be0e5 100644 --- a/resources/views/front/sable/product.blade.php +++ b/resources/views/front/sable/product.blade.php @@ -47,15 +47,18 @@

@if ($product->weight_variable) Environ* @endif @fmt_currency($product->discountedPriceTtc) - @if ($product->promotions->count()) + @if ($product->promotions->count() && $product->promotions()->first()->is_old_price_displayed) @fmt_currency($product->priceTtc) @endif /{{ $product->sell_unit }}

- @can('addToCart', $product) + @if( + Auth::guard('customer')->user() && + Auth::guard('customer')->user()->can('addToCart', $product) + ) - @endcan + @endif @if ($product->weight_variable)

*Produit vendu au kilo : @fmt_currency($product->priceKgTtc)/kg

diff --git a/resources/views/front/sable/ranges.blade.php b/resources/views/front/sable/ranges.blade.php index 81f31860..2a188ce3 100644 --- a/resources/views/front/sable/ranges.blade.php +++ b/resources/views/front/sable/ranges.blade.php @@ -11,14 +11,15 @@ $dataComponent = [ 'hasPromotion' => request()->promotion ? true : false, 'ranges' => $ranges, - 'brands' => \App\Enums\ProductBrand::toArray(), + 'brands' => $brands, 'tags' => $tags, 'products' => \App\Http\Resources\ProductResource::collection($products), 'productsResults' => $products->perPage(), 'productsCount' => $products->total(), 'search' => $sessionFilter->search ?? '', 'filters' => $sessionFilter, - 'filtersMenuIsOpen' => $filtersMenuIsOpen + 'filtersMenuIsOpen' => $filtersMenuIsOpen, + 'shouldDisplayPrices' => \App\Helpers\BladeDirectivesHelper::shouldShowPrices(), ]; @endphp diff --git a/resources/views/front/sable/sass/fo/pages/_home.scss b/resources/views/front/sable/sass/fo/pages/_home.scss index 7031f029..06b96289 100644 --- a/resources/views/front/sable/sass/fo/pages/_home.scss +++ b/resources/views/front/sable/sass/fo/pages/_home.scss @@ -5,17 +5,6 @@ &-container { overflow: hidden; } - - &-slide { - h2 { - width: 60%; - } - - img { - width: 40%; - max-width: 40rem; - } - } } } @@ -84,25 +73,6 @@ } } -// SSSSSSSSSSSSSSS MMMMMMMM MMMMMMMM -// SS:::::::::::::::SM:::::::M M:::::::M -// S:::::SSSSSS::::::SM::::::::M M::::::::M -// S:::::S SSSSSSSM:::::::::M M:::::::::M -// S:::::S M::::::::::M M::::::::::M -// S:::::S M:::::::::::M M:::::::::::M -// S::::SSSS M:::::::M::::M M::::M:::::::M -// SS::::::SSSSS M::::::M M::::M M::::M M::::::M -// SSS::::::::SS M::::::M M::::M::::M M::::::M -// SSSSSS::::S M::::::M M:::::::M M::::::M -// S:::::SM::::::M M:::::M M::::::M -// S:::::SM::::::M MMMMM M::::::M -// SSSSSSS S:::::SM::::::M M::::::M -// S::::::SSSSSS:::::SM::::::M M::::::M -// S:::::::::::::::SS M::::::M M::::::M -// SSSSSSSSSSSSSSS MMMMMMMM MMMMMMMM -@include media-breakpoint-up(sm) { //576px - // -} // MMMMMMMM MMMMMMMMDDDDDDDDDDDDD // M:::::::M M:::::::MD::::::::::::DDD // M::::::::M M::::::::MD:::::::::::::::DD @@ -227,41 +197,3 @@ } } } -// XXXXXXX XXXXXXXLLLLLLLLLLL -// X:::::X X:::::XL:::::::::L -// X:::::X X:::::XL:::::::::L -// X::::::X X::::::XLL:::::::LL -// XXX:::::X X:::::XXX L:::::L -// X:::::X X:::::X L:::::L -// X:::::X:::::X L:::::L -// X:::::::::X L:::::L -// X:::::::::X L:::::L -// X:::::X:::::X L:::::L -// X:::::X X:::::X L:::::L -// XXX:::::X X:::::XXX L:::::L LLLLLL -// X::::::X X::::::XLL:::::::LLLLLLLLL:::::L -// X:::::X X:::::XL::::::::::::::::::::::L -// X:::::X X:::::XL::::::::::::::::::::::L -// XXXXXXX XXXXXXXLLLLLLLLLLLLLLLLLLLLLLLL -@include media-breakpoint-up(xl) { //1200px - // -} -// XXXXXXX XXXXXXXXXXXXXX XXXXXXXLLLLLLLLLLL -// X:::::X X:::::XX:::::X X:::::XL:::::::::L -// X:::::X X:::::XX:::::X X:::::XL:::::::::L -// X::::::X X::::::XX::::::X X::::::XLL:::::::LL -// XXX:::::X X:::::XXXXXX:::::X X:::::XXX L:::::L -// X:::::X X:::::X X:::::X X:::::X L:::::L -// X:::::X:::::X X:::::X:::::X L:::::L -// X:::::::::X X:::::::::X L:::::L -// X:::::::::X X:::::::::X L:::::L -// X:::::X:::::X X:::::X:::::X L:::::L -// X:::::X X:::::X X:::::X X:::::X L:::::L -// XXX:::::X X:::::XXXXXX:::::X X:::::XXX L:::::L LLLLLL -// X::::::X X::::::XX::::::X X::::::XLL:::::::LLLLLLLLL:::::L -// X:::::X X:::::XX:::::X X:::::XL::::::::::::::::::::::L -// X:::::X X:::::XX:::::X X:::::XL::::::::::::::::::::::L -// XXXXXXX XXXXXXXXXXXXXX XXXXXXXLLLLLLLLLLLLLLLLLLLLLLLL -@include media-breakpoint-up(xxl) { //1400px - // -} diff --git a/resources/views/front/sable/theme.config.php b/resources/views/front/sable/theme.config.php index cc7a3610..026f0d15 100644 --- a/resources/views/front/sable/theme.config.php +++ b/resources/views/front/sable/theme.config.php @@ -14,8 +14,8 @@ return [ 'range_image_large_maxheight' => '500', 'content_banner_maxwidth' => '100', 'content_banner_maxheight' => '100', - 'slide_image_maxwidth' => '500', - 'slide_image_maxheight' => '500', + 'slide_image_maxwidth' => '830', + 'slide_image_maxheight' => '320', 'register_mode' => ['public', 'salaries'], /** * attention ce paramètre est un paramètre de fonctionnement diff --git a/routes/web-bo.php b/routes/web-bo.php index b077f5ec..0ace7905 100644 --- a/routes/web-bo.php +++ b/routes/web-bo.php @@ -32,7 +32,11 @@ Route::name('auth.') Route::prefix('bo') ->name('bo.') - ->middleware(['auth', 'is-admin', 'admin-secure']) + ->middleware([ + 'auth', + 'is-admin', + 'admin-secure' + ]) ->group(function () { Route::get('/', [DashboardController::class, 'index'])->name('dashboard'); Route::match(['get', 'put'], '/content/{key}', [ContentController::class, 'manage']) @@ -71,6 +75,10 @@ Route::prefix('bo') ->name('products.change-published'); Route::get('/products/change-order/{product}/{direction}', [ProductsController::class, 'changeOrder']) ->where('direction', 'up|down')->name('products.change-order'); + Route::patch('/products/{product}/change-selected-order', [ + ProductsController::class, + 'changeSelectedOrder' + ])->name('product.change-selected-order'); // Slides. Route::resource('slides', SlidesController::class)->except(['show']); Route::resource('sliders', SlidersController::class)->except(['show']);