Compare commits
394 Commits
7913576f1a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef1964d472 | ||
|
|
abb32e32b9 | ||
|
|
8c29459489 | ||
|
|
accb052f5c | ||
|
|
d5f095b5e5 | ||
|
|
fd628f3f95 | ||
|
|
a10f0b35d9 | ||
|
|
858421a9eb | ||
|
|
158bc4fd57 | ||
|
|
b7e3eefed6 | ||
|
|
67e4346c68 | ||
|
|
9ce62e82e5 | ||
|
|
7e93219774 | ||
|
|
29f46b7287 | ||
|
|
1f02c932a0 | ||
|
|
7d8bd8c372 | ||
|
|
f4bd4ddf24 | ||
|
|
1f7098d55b | ||
|
|
1867e75177 | ||
|
|
d502882052 | ||
|
|
a5b2196b32 | ||
|
|
cc8dfa29b4 | ||
|
|
62bce92d6d | ||
|
|
8d130b9741 | ||
|
|
2d7436a12b | ||
|
|
f25a62ed26 | ||
|
|
36764f2647 | ||
|
|
e37cad6699 | ||
|
|
ae7f8ed2c9 | ||
|
|
a3a86f4b2f | ||
|
|
9c081574c8 | ||
|
|
11edccad02 | ||
|
|
7c796802be | ||
|
|
5cc43bc889 | ||
|
|
f094411f10 | ||
|
|
ccc477f291 | ||
|
|
7217d945a3 | ||
|
|
9185269874 | ||
|
|
e42e3b4c0d | ||
|
|
a7ae946797 | ||
|
|
7a189abf0b | ||
|
|
34fc1c33bf | ||
|
|
61e34b4f4e | ||
|
|
7fe2770d45 | ||
|
|
0479ae25f8 | ||
|
|
0a45b0c71f | ||
|
|
1cc6cc879e | ||
|
|
adbba79bd2 | ||
|
|
592402a6c1 | ||
|
|
d1cc62c9b1 | ||
|
|
a76d81c437 | ||
|
|
2e71f17856 | ||
|
|
df78126b12 | ||
|
|
befaa40b48 | ||
|
|
b3fbfc38e7 | ||
|
|
ee60bac538 | ||
|
|
c63bb762ed | ||
|
|
44bfe7d09c | ||
|
|
5db7438c27 | ||
|
|
2227242704 | ||
|
|
7b7295aed1 | ||
|
|
26ca3eb3ca | ||
|
|
139aeb8074 | ||
|
|
cc411cba68 | ||
|
|
fb6da523fa | ||
|
|
64a218afc2 | ||
|
|
722ea43bc2 | ||
|
|
869b148e20 | ||
|
|
15a6621a56 | ||
|
|
601b758179 | ||
|
|
e559c785c2 | ||
|
|
329643ce3b | ||
|
|
7bb38071ef | ||
|
|
ee9979f547 | ||
|
|
c4fda18356 | ||
|
|
8c6e10fb3b | ||
|
|
5a400aaedd | ||
|
|
23fb8a79ac | ||
|
|
67e439f420 | ||
|
|
df377c4f3f | ||
|
|
69264dcf80 | ||
|
|
308b6cb349 | ||
|
|
4c6f9b3b61 | ||
|
|
067532b6fc | ||
|
|
8eb3104b2a | ||
|
|
1bc9bf9fe9 | ||
|
|
53ad10eefa | ||
|
|
9fcc81f4d9 | ||
|
|
75107285e7 | ||
|
|
502b71617a | ||
|
|
ca474ddadb | ||
|
|
fbe9633651 | ||
|
|
1677ec6b03 | ||
|
|
1533c18c54 | ||
|
|
fc5a3186bf | ||
|
|
0bb75125a7 | ||
|
|
af5fc8d0ee | ||
|
|
17e322cd88 | ||
|
|
8ceab7e9f5 | ||
|
|
116f289285 | ||
|
|
560ef61c9f | ||
|
|
4df8628a3e | ||
|
|
5144c1f7fd | ||
|
|
90b0af5b2d | ||
|
|
03027cde01 | ||
|
|
8a463e7b9e | ||
|
|
643c26d549 | ||
|
|
ee64ae0be7 | ||
|
|
e0d8106078 | ||
|
|
df65516b36 | ||
|
|
25b78f3380 | ||
|
|
2a429e4163 | ||
|
|
b5da5fc881 | ||
|
|
ec509df665 | ||
|
|
4bcfc7bc6d | ||
|
|
9949ae95cf | ||
|
|
82b864768e | ||
|
|
34f0b2796f | ||
|
|
731c31a58c | ||
|
|
9b18531c83 | ||
|
|
2ebdc5f16b | ||
|
|
04df068931 | ||
|
|
86b8156e38 | ||
|
|
b86b043604 | ||
|
|
23ac0cedad | ||
|
|
9f90f983ab | ||
|
|
4ce3d528dd | ||
|
|
e42ac75ff7 | ||
|
|
746cf661ce | ||
|
|
a9432bd3c1 | ||
|
|
f3b9db1a6f | ||
|
|
50d5d6944d | ||
|
|
bc7880b242 | ||
|
|
5f215cef81 | ||
|
|
da48f41ec0 | ||
|
|
eda2bbf1db | ||
|
|
5e161745bb | ||
|
|
a29faabbf2 | ||
|
|
470560efb6 | ||
|
|
b1d16a7871 | ||
|
|
496274b4f4 | ||
|
|
7addea00a2 | ||
|
|
f721422abc | ||
|
|
1cba52bb6d | ||
|
|
902604b9cd | ||
|
|
b8c31f6049 | ||
|
|
1675745e2a | ||
|
|
0879b0abf0 | ||
|
|
72a7b270f9 | ||
|
|
3d16580bc8 | ||
|
|
d6ab6c73e2 | ||
|
|
9f9b7173d7 | ||
|
|
c677dbd5fa | ||
|
|
313525a25b | ||
|
|
24e518fffe | ||
|
|
7d1a34a12e | ||
|
|
938d6a9cbd | ||
|
|
0a6b90b434 | ||
|
|
20b3521c72 | ||
|
|
06c68dd223 | ||
|
|
4f9f9b296d | ||
|
|
7454411d27 | ||
|
|
4e69399309 | ||
|
|
3745abc90b | ||
|
|
0828ac3377 | ||
|
|
b3d16a06b0 | ||
|
|
753be00a1e | ||
|
|
a63618a753 | ||
|
|
3287caac54 | ||
|
|
312f1f4e3d | ||
|
|
39e3407ea1 | ||
|
|
03a52d504b | ||
|
|
c1d7f3fe10 | ||
|
|
8e571de523 | ||
|
|
878ec7a8f2 | ||
|
|
06107cb8fc | ||
|
|
10cebd0955 | ||
|
|
0ecc7c73c7 | ||
|
|
f2f4788ce1 | ||
|
|
8313e25f2e | ||
|
|
cafd0a49e7 | ||
|
|
405effe43e | ||
|
|
4914e0c9c9 | ||
|
|
909336bb8b | ||
|
|
60682f2295 | ||
|
|
2fc88c6163 | ||
|
|
6c60d9a148 | ||
|
|
cb488383e0 | ||
|
|
32291dc44a | ||
|
|
0123885e03 | ||
|
|
72d989f692 | ||
|
|
66e0197b50 | ||
|
|
bfd30b668e | ||
|
|
28c200fd9f | ||
|
|
7819a8e11b | ||
|
|
b6821d52a7 | ||
|
|
b4d8bab385 | ||
|
|
d72dfa5b6b | ||
|
|
35fcc992ae | ||
|
|
0feebca7e0 | ||
|
|
5151f393be | ||
|
|
73ed46bc28 | ||
|
|
533b63f8fb | ||
|
|
966e687509 | ||
|
|
ee1511962b | ||
|
|
d62cad1725 | ||
|
|
0cf5569a4c | ||
|
|
73763bb146 | ||
|
|
caee665758 | ||
|
|
7df2421373 | ||
|
|
f89acd9399 | ||
|
|
c22b10dd10 | ||
|
|
5cd48c03f9 | ||
|
|
d423fce4f5 | ||
|
|
573e98a2ce | ||
|
|
06cfb92757 | ||
|
|
bcb3e15f33 | ||
|
|
b392b426d5 | ||
|
|
e435752484 | ||
|
|
c2fd71e3d1 | ||
|
|
e9ab7173f8 | ||
|
|
6b1cc0f045 | ||
|
|
123b951538 | ||
|
|
9710a7017a | ||
|
|
32044118f3 | ||
|
|
b37321daf8 | ||
|
|
e31978b1e3 | ||
|
|
5b74c93b2e | ||
|
|
352b109e87 | ||
|
|
a70e8c39cf | ||
|
|
439a339027 | ||
|
|
2ee339a022 | ||
|
|
84063d2f72 | ||
|
|
61a52ef330 | ||
|
|
c9bf18d87d | ||
|
|
328d791b87 | ||
|
|
e22a541342 | ||
|
|
d8bf91da54 | ||
|
|
5747b93952 | ||
|
|
570374bab7 | ||
|
|
416c724ad1 | ||
|
|
5d68e8787a | ||
|
|
e4672a42d7 | ||
|
|
94234218d6 | ||
|
|
a12dd0c653 | ||
|
|
fe1e14d2c0 | ||
|
|
1dc815bf39 | ||
|
|
2d111605f2 | ||
|
|
68a13b7a58 | ||
|
|
c2ef0c7b35 | ||
|
|
9c2b9cf02e | ||
|
|
6e133246cf | ||
|
|
eff2cb21c7 | ||
|
|
c50bd2aead | ||
|
|
dd0dddb1ff | ||
|
|
34d273e510 | ||
|
|
f1f1a8bc70 | ||
|
|
c1a0d449be | ||
|
|
957d033e2d | ||
|
|
dde59a0c90 | ||
|
|
1dced19068 | ||
|
|
1c5db3c654 | ||
|
|
c8cd3e4fa6 | ||
|
|
e312572bcc | ||
|
|
c4bb4fdd59 | ||
|
|
ff18a0f5bf | ||
|
|
573e4dc6cb | ||
|
|
2a98b24bc1 | ||
|
|
c357ea932a | ||
|
|
c65056531c | ||
|
|
ddc5f2664c | ||
|
|
0eaa11b2a9 | ||
|
|
aa50f908ba | ||
|
|
719f89cc50 | ||
|
|
14931bc5e6 | ||
|
|
30876ba67d | ||
|
|
5794cbb045 | ||
|
|
27893eaa7e | ||
|
|
53d1307837 | ||
|
|
f8c686caa3 | ||
|
|
3c3481b39d | ||
|
|
c75f580ad2 | ||
|
|
ea53cb4c8a | ||
|
|
4b2c431ee9 | ||
|
|
655f502279 | ||
|
|
6556127cc8 | ||
|
|
b3a2ad31b2 | ||
|
|
7d6c7ca36d | ||
|
|
5701985734 | ||
|
|
9e064bcd74 | ||
|
|
f0386269e6 | ||
|
|
90d683f7ed | ||
|
|
7723b475ac | ||
|
|
d8ce8f5259 | ||
|
|
48359525bf | ||
|
|
0399d90ca7 | ||
|
|
32362d74dc | ||
|
|
b90d3ba3f2 | ||
|
|
642fd52d36 | ||
|
|
a6a4b9e59a | ||
|
|
3c00452219 | ||
|
|
2e14e494a1 | ||
|
|
b4856266c8 | ||
|
|
5e5f12ddb2 | ||
|
|
5799eb36fc | ||
|
|
b4057c28d0 | ||
|
|
45c7385046 | ||
|
|
fb047aa036 | ||
|
|
ed1d87a7d1 | ||
|
|
9b6bac5545 | ||
|
|
1fb9319bac | ||
|
|
30666e2931 | ||
|
|
3e26bf368b | ||
|
|
52019357ba | ||
|
|
81b6c87d59 | ||
|
|
fe759565a8 | ||
|
|
94a162deb7 | ||
|
|
f4aecc9130 | ||
|
|
f35650b234 | ||
|
|
6f04a8e7b7 | ||
|
|
2912dc6794 | ||
|
|
6ff65eb927 | ||
|
|
7ae2c4b07c | ||
|
|
cefe956bc4 | ||
|
|
3641bd7d68 | ||
|
|
050fd76122 | ||
|
|
95ca3c6404 | ||
|
|
a3c6fc6ebe | ||
|
|
2be07ce72c | ||
|
|
2f3da7d700 | ||
|
|
b0b1164881 | ||
|
|
6439d2d4ad | ||
|
|
6f0506a71e | ||
|
|
5b84ff74e3 | ||
|
|
323330b1a1 | ||
|
|
63c6671c97 | ||
|
|
c7c8e18cbc | ||
|
|
46b751c361 | ||
|
|
4761656405 | ||
|
|
eb0c9444bc | ||
|
|
e8d503b65d | ||
|
|
900da34b57 | ||
|
|
ae20643879 | ||
|
|
8aaab4345f | ||
|
|
e356b3fcda | ||
|
|
fae7b7897f | ||
|
|
e040837ce6 | ||
|
|
86f6ee9a13 | ||
|
|
c150be2c3e | ||
|
|
a7f661ab10 | ||
|
|
9d21f28d9e | ||
|
|
95997a4a0a | ||
|
|
2195ca122c | ||
|
|
85465f67c6 | ||
|
|
c347b7fe82 | ||
|
|
e98266e556 | ||
|
|
ffb9f81353 | ||
|
|
1dcc3e34a9 | ||
|
|
9cf96b7d4e | ||
|
|
50d445bb3b | ||
|
|
b20c32d722 | ||
|
|
4614ea57cf | ||
|
|
73cfe5a42e | ||
|
|
144532acbf | ||
|
|
8d3ccbf148 | ||
|
|
e407934e2a | ||
|
|
5ddcebc303 | ||
|
|
04685cc7dc | ||
|
|
32c532d49b | ||
|
|
67f490b2fe | ||
|
|
82afe63c60 | ||
|
|
a84955412a | ||
|
|
f32ac13f1e | ||
|
|
8d51ced269 | ||
|
|
967af93f8c | ||
|
|
c3f66af009 | ||
|
|
46316ac974 | ||
|
|
7d1b2f1273 | ||
|
|
5d99f9a09a | ||
|
|
24fffce7a1 | ||
|
|
81fbec892c | ||
|
|
9a0601d473 | ||
|
|
daeece59c9 | ||
|
|
b879f11c99 | ||
|
|
f75632b054 | ||
|
|
b50f50ea62 | ||
|
|
4ce0fa942d | ||
|
|
fd2e87aa07 | ||
|
|
ebea9844dd | ||
|
|
096351ae4e | ||
|
|
f5ca57fdf2 | ||
|
|
f781158e36 | ||
|
|
7a9f20acb9 | ||
|
|
098a46f3a0 |
74
AGENTS.md
Normal file
74
AGENTS.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# Repository Guidelines
|
||||
|
||||
## Project Structure & Module Organization
|
||||
|
||||
OpenSem builds on Laravel 9.
|
||||
|
||||
Core application code lives in `app/`, while HTTP routes reside in
|
||||
`routes/` and Blade views in `resources/views/`. Reusable front-end
|
||||
assets (JS, SCSS, images) sit under `resources/` and are compiled into
|
||||
`public/` via Laravel Mix.
|
||||
|
||||
Database blueprints are versioned in `database/migrations/` with seeds
|
||||
in `database/seeders/`.
|
||||
|
||||
Tests are organised in `tests/Unit/` and `tests/Feature/`; keep large
|
||||
fixtures in `tests/Fixtures/` to avoid polluting source directories.
|
||||
|
||||
## Build, Test, and Development Commands
|
||||
|
||||
- `composer install` — install PHP dependencies defined in
|
||||
`composer.json`.
|
||||
|
||||
- `php artisan serve` — start a local HTTP server on port 8000.
|
||||
|
||||
- `npm install && npm run dev` — install Node tooling and build UI
|
||||
assets for development.
|
||||
|
||||
- `npm run prod` — generate minified production assets in `public/`.
|
||||
|
||||
- `php artisan migrate --seed` — apply database schema and load
|
||||
default data for demo instances.
|
||||
|
||||
- `./build.sh` — builds a `.tar.xz` that contains the production and
|
||||
deployement ready source to be deployed.
|
||||
|
||||
## Coding Style & Naming Conventions
|
||||
|
||||
Follow PSR-12 with four-space indentation and `snake_case` database
|
||||
columns. Controllers, models, and Livewire components use StudlyCase
|
||||
class names; private methods remain `camelCase`. Run `composer run
|
||||
inspect` before opening a PR to execute `phpcs` and `phpstan`. For
|
||||
front-end changes, keep Blade sections in lowercase kebab IDs (for
|
||||
example, `@section('order-summary')`).
|
||||
|
||||
## Testing Guidelines
|
||||
|
||||
Use PHPUnit via `php artisan test`; target deterministic tests with
|
||||
clear Arrange/Act/Assert blocks. Feature tests should mirror top-level
|
||||
route names (e.g., `OrdersTest.php`). Unit tests belong in
|
||||
`tests/Unit/` and should stub external services. When adding
|
||||
migrations or service integrations, include coverage that exercises
|
||||
failure paths. For granular checks, `./vendor/bin/phpunit --filter
|
||||
FooTest` is acceptable, but always run the full suite before pushing.
|
||||
|
||||
## Commit & Pull Request Guidelines
|
||||
|
||||
Commits in this repo mix Conventional Commit prefixes (`new:`, `fix:`,
|
||||
`chg:`); `fix: prevent null totals`. Keep messages in the imperative
|
||||
mood and reference ticket IDs when available.
|
||||
|
||||
Pull requests must describe scope, list schema or configuration
|
||||
changes, and note any manual follow-up (cron, storage links,
|
||||
queues).
|
||||
|
||||
Attach screenshots or terminal logs when touching UI or console
|
||||
output, and ensure CI scripts (when available) pass.
|
||||
|
||||
## Environment & Security Notes
|
||||
|
||||
Copy `.env.example` to `.env` and run `php artisan key:generate`
|
||||
before local work. Never commit `.env`, `storage/`, or database dumps
|
||||
containing sensitive data. Use the Docker resources in `docker/` only
|
||||
for reproducible environments; keep secrets in your host overrides,
|
||||
not in version control.
|
||||
@@ -43,6 +43,7 @@ COPY . /app
|
||||
WORKDIR /app
|
||||
|
||||
RUN mkdir -p /app/bootstrap/cache \
|
||||
/app/storage/media-library/temp \
|
||||
/app/storage/framework/cache \
|
||||
/app/storage/framework/views \
|
||||
/app/storage/framework/sessions \
|
||||
@@ -84,8 +85,6 @@ RUN apk add --no-cache xz
|
||||
# bring PHP app with vendor
|
||||
COPY --from=phpdeps /app /app
|
||||
|
||||
# ensure required runtime dirs exist (empty is fine)
|
||||
RUN mkdir -p storage/framework/{cache,views,sessions} bootstrap/cache
|
||||
# create artifact (use tar + xz so we don't depend on GNU tar -J)
|
||||
RUN mkdir -p /out \
|
||||
&& tar -C /app -cf /out/app.tar \
|
||||
|
||||
30
README.md
30
README.md
@@ -1,10 +1,19 @@
|
||||
## A propos de OpenSem
|
||||
|
||||
OpenSem est une solution de commerce électronique et un ERP développé pour les besoins exprimés.
|
||||
OpenSem est une solution de commerce électronique et un ERP développé
|
||||
pour les besoins exprimés.
|
||||
|
||||
Développée par Ludovic Candellier en étroite relation avec
|
||||
Jardin'Envie.
|
||||
|
||||
L'application est écrite en PHP et est basée sur Laravel.
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
Laravel is a web application framework with expressive, elegant
|
||||
syntax. We believe development must be an enjoyable and creative
|
||||
experience to be truly fulfilling. Laravel takes the pain out of
|
||||
development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
@@ -14,12 +23,21 @@ Laravel is a web application framework with expressive, elegant syntax. We belie
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
Laravel is accessible, powerful, and provides tools required for
|
||||
large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
Laravel has the most extensive and thorough
|
||||
[documentation](https://laravel.com/docs) and video tutorial library
|
||||
of all modern web application frameworks, making it a breeze to get
|
||||
started with the framework.
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can
|
||||
help. Laracasts contains over 1500 video tutorials on a range of
|
||||
topics including Laravel, modern PHP, unit testing, and
|
||||
JavaScript. Boost your skills by digging into our comprehensive video
|
||||
library.
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
The Laravel framework is open-sourced software licensed under the [MIT
|
||||
license](https://opensource.org/licenses/MIT).
|
||||
|
||||
@@ -11,7 +11,7 @@ use Yajra\DataTables\Html\Column;
|
||||
|
||||
class CustomerInvoicesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'invoices';
|
||||
public $model_name = 'customer_invoices';
|
||||
|
||||
public $sortedColumn = 1;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Controllers\Admin\Botanic;
|
||||
|
||||
use App\Datatables\Botanic\SpeciesDataTable;
|
||||
use App\Repositories\Botanic\Genres;
|
||||
use App\Repositories\Botanic\Species;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -21,7 +20,7 @@ class SpecieController extends Controller
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = Genres::init();
|
||||
$data = Species::init();
|
||||
|
||||
return view('Admin.Botanic.Species.create', $data);
|
||||
}
|
||||
@@ -36,7 +35,7 @@ class SpecieController extends Controller
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Genres::init();
|
||||
$data = Species::init();
|
||||
$data['specie'] = Species::getFull($id);
|
||||
|
||||
return view('Admin.Botanic.Species.edit', $data);
|
||||
|
||||
@@ -12,15 +12,6 @@ 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);
|
||||
|
||||
@@ -71,7 +71,10 @@ class PriceListValueController extends Controller
|
||||
|
||||
public function addPrice($index)
|
||||
{
|
||||
$data['index'] = $index;
|
||||
$data = [
|
||||
'index' => $index,
|
||||
'taxes' => Taxes::getOptions(),
|
||||
];
|
||||
|
||||
return view('Admin.Shop.PriceListValues.partials.row_price', $data);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
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\Schema;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class CustomerController extends Controller
|
||||
@@ -44,8 +48,69 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$customerId = $data['id'] ?? Customers::getId();
|
||||
$requestedDefaultSaleChannelId = $data['default_sale_channel_id'] ?? null;
|
||||
$hasDefaultSaleChannelColumn = Schema::hasColumn('shop_customers', 'default_sale_channel_id');
|
||||
|
||||
if (! $hasDefaultSaleChannelColumn) {
|
||||
unset($data['default_sale_channel_id']);
|
||||
}
|
||||
|
||||
$customer = Customers::store($data);
|
||||
|
||||
if (! $customer) {
|
||||
return response()->json([
|
||||
'error' => 1,
|
||||
'message' => __('Impossible de mettre à jour votre profil pour le moment.'),
|
||||
], 422);
|
||||
}
|
||||
|
||||
if ($hasDefaultSaleChannelColumn && $requestedDefaultSaleChannelId !== null) {
|
||||
Customers::setDefaultSaleChannel($customerId, $requestedDefaultSaleChannelId);
|
||||
}
|
||||
|
||||
$freshCustomer = Customers::get($customerId, ['sale_channels']);
|
||||
Customers::guard()->setUser($freshCustomer);
|
||||
|
||||
if ($requestedDefaultSaleChannelId !== null) {
|
||||
session(['shop.default_sale_channel_id' => $requestedDefaultSaleChannelId]);
|
||||
Baskets::refreshPrices((int) $requestedDefaultSaleChannelId);
|
||||
}
|
||||
|
||||
return response()->json(['error' => 0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,14 @@ class InvoiceController extends Controller
|
||||
|
||||
public function view($uuid)
|
||||
{
|
||||
$invoice = Invoices::view($uuid);
|
||||
|
||||
if (! $invoice) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'invoice' => Invoices::view($uuid),
|
||||
'invoice' => $invoice,
|
||||
];
|
||||
|
||||
return view('Shop.Invoices.view', $data);
|
||||
|
||||
@@ -49,12 +49,22 @@ class OrderController extends Controller
|
||||
{
|
||||
if (ShopCart::count()) {
|
||||
$customer = Customers::getWithAddresses();
|
||||
$deliveries = Deliveries::getByCustomer();
|
||||
$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;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'customer' => $customer ? $customer->toArray() : false,
|
||||
'customer' => $customerData,
|
||||
'basket' => Baskets::getBasketTotal(),
|
||||
'deliveries' => $deliveries ? $deliveries->toArray() : [],
|
||||
'deliveries' => $deliveries->toArray(),
|
||||
'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()),
|
||||
];
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\Admin\Shop;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreArticlePost extends FormRequest
|
||||
{
|
||||
@@ -13,8 +14,13 @@ class StoreArticlePost extends FormRequest
|
||||
|
||||
public function rules()
|
||||
{
|
||||
$articleId = $this->input('id');
|
||||
|
||||
return [
|
||||
'ref' => 'required|unique:shop_articles',
|
||||
'ref' => [
|
||||
'required',
|
||||
Rule::unique('shop_articles', 'ref')->ignore($articleId)->whereNull('deleted_at'),
|
||||
],
|
||||
'product_type' => 'required',
|
||||
'product_id' => 'required',
|
||||
'article_nature_id' => 'required',
|
||||
|
||||
@@ -11,9 +11,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
if (config('app.env') === 'production') {
|
||||
\URL::forceScheme('https');
|
||||
}
|
||||
Schema::defaultStringLength(191);
|
||||
View::composer('Shop.layout.layout', LayoutComposer::class);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,9 @@ class Varieties
|
||||
{
|
||||
$images = $data['images'] ?? false;
|
||||
$tags = $data['tags'] ?? false;
|
||||
if (! array_key_exists('plus', $data) || $data['plus'] === null) {
|
||||
$data['plus'] = '';
|
||||
}
|
||||
unset($data['images']);
|
||||
unset($data['tags']);
|
||||
$variety = self::store($data);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media as MediaModel;
|
||||
|
||||
class Medias
|
||||
{
|
||||
public static function getImage($model, $conversion = 'normal', $collection = 'images')
|
||||
@@ -79,13 +81,9 @@ class Medias
|
||||
|
||||
public static function getImageSrc($image)
|
||||
{
|
||||
if (! $image) {
|
||||
return null;
|
||||
}
|
||||
$id = $image['id'];
|
||||
$filename = self::getFilename($image);
|
||||
$media = self::resolveMedia($image);
|
||||
|
||||
return "/storage/{$id}/{$filename}";
|
||||
return $media ? $media->getUrl() : null;
|
||||
}
|
||||
|
||||
public static function getThumbSrc($image)
|
||||
@@ -110,6 +108,12 @@ class Medias
|
||||
|
||||
public static function getSrcByType($image, $type)
|
||||
{
|
||||
$media = self::resolveMedia($image);
|
||||
|
||||
if ($media) {
|
||||
return $type ? $media->getUrl($type) : $media->getUrl();
|
||||
}
|
||||
|
||||
return $image ? '/storage/'.$image['id'].'/conversions/'.self::getFilename($image, $type) : false;
|
||||
}
|
||||
|
||||
@@ -124,4 +128,48 @@ class Medias
|
||||
{
|
||||
return str_replace(['#', '/', '\\', ' '], '-', $name);
|
||||
}
|
||||
|
||||
protected static function resolveMedia($image): ?MediaModel
|
||||
{
|
||||
if ($image instanceof MediaModel) {
|
||||
return $image;
|
||||
}
|
||||
|
||||
if (is_null($image)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_array($image)) {
|
||||
return self::hydrateMedia($image);
|
||||
}
|
||||
|
||||
if (is_object($image)) {
|
||||
if ($image instanceof \ArrayAccess) {
|
||||
return self::hydrateMedia((array) $image);
|
||||
}
|
||||
|
||||
$array = method_exists($image, 'toArray') ? $image->toArray() : (array) $image;
|
||||
|
||||
return self::hydrateMedia($array);
|
||||
}
|
||||
|
||||
$id = data_get($image, 'id');
|
||||
|
||||
return $id ? MediaModel::query()->withoutGlobalScopes()->find($id) : null;
|
||||
}
|
||||
|
||||
protected static function hydrateMedia(array $attributes): ?MediaModel
|
||||
{
|
||||
$id = data_get($attributes, 'id');
|
||||
|
||||
if (! $id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$media = new MediaModel();
|
||||
$media->forceFill($attributes);
|
||||
$media->exists = true;
|
||||
|
||||
return $media;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,21 +27,34 @@ class ArticleTags
|
||||
|
||||
switch ($article->product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$data += $article->product->tags->toArray();
|
||||
if ($article->product->specie ?? false) {
|
||||
$data += $article->product->specie->tags->toArray();
|
||||
$variety = $article->product;
|
||||
if ($variety && $variety->tags) {
|
||||
$data = array_merge($data, $variety->tags->toArray());
|
||||
}
|
||||
if ($variety && $variety->specie && $variety->specie->tags) {
|
||||
$data = array_merge($data, $variety->specie->tags->toArray());
|
||||
}
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$data += $article->product->tags->toArray();
|
||||
$specie = $article->product;
|
||||
if ($specie && $specie->tags) {
|
||||
$data = array_merge($data, $specie->tags->toArray());
|
||||
}
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$data += $article->product->tags->toArray();
|
||||
$data += $article->product->producer->tags->toArray();
|
||||
$merchandise = $article->product;
|
||||
if ($merchandise && $merchandise->tags) {
|
||||
$data = array_merge($data, $merchandise->tags->toArray());
|
||||
}
|
||||
if ($merchandise && $merchandise->producer && $merchandise->producer->tags) {
|
||||
$data = array_merge($data, $merchandise->producer->tags->toArray());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
$data += $article->tags->toArray();
|
||||
if ($article->tags) {
|
||||
$data = array_merge($data, $article->tags->toArray());
|
||||
}
|
||||
|
||||
foreach ($data as $tag) {
|
||||
if (! isset($tags[$tag['group']][$tag['name']])) {
|
||||
|
||||
@@ -5,6 +5,9 @@ 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\Shop\Customers;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Repositories\Core\Comments;
|
||||
use App\Traits\Model\Basic;
|
||||
use App\Traits\Repository\Imageable;
|
||||
@@ -16,7 +19,7 @@ class Articles
|
||||
|
||||
public static function autocomplete($str)
|
||||
{
|
||||
$data = Article::byAutocomplete($str)->orderBy('name')->limit(20)->pluck('name', 'id');
|
||||
$data = Article::byAutocomplete($str)->visible()->orderBy('name')->limit(20)->pluck('name', 'id');
|
||||
$export = [];
|
||||
foreach ($data as $key => $name) {
|
||||
$export[] = ['value' => $key, 'text' => $name];
|
||||
@@ -70,9 +73,33 @@ class Articles
|
||||
|
||||
public static function getArticleToSell($id, $saleChannelId = false)
|
||||
{
|
||||
$saleChannelId = $saleChannelId ?: SaleChannels::getDefaultID();
|
||||
$sessionSaleChannelId = session('shop.default_sale_channel_id');
|
||||
$customer = Customers::getAuth();
|
||||
$hasDefaultSaleChannelColumn = Schema::hasColumn('shop_customers', 'default_sale_channel_id');
|
||||
$customerDefaultSaleChannelId = ($customer && $hasDefaultSaleChannelColumn)
|
||||
? $customer->default_sale_channel_id
|
||||
: null;
|
||||
$customerSaleChannelIds = [];
|
||||
|
||||
if ($customer) {
|
||||
$customer->loadMissing('sale_channels:id');
|
||||
$customerSaleChannelIds = $customer->sale_channels->pluck('id')->toArray();
|
||||
}
|
||||
$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);
|
||||
$data['debug_sale_channel'] = [
|
||||
'session_default_sale_channel_id' => $sessionSaleChannelId,
|
||||
'customer_default_sale_channel_id' => $customerDefaultSaleChannelId,
|
||||
'customer_linked_sale_channel_ids' => $customerSaleChannelIds,
|
||||
'resolved_sale_channel_id' => $saleChannelId,
|
||||
'has_default_sale_channel_column' => $hasDefaultSaleChannelColumn,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -108,8 +135,11 @@ class Articles
|
||||
$data['specie'] = $article->product ? $article->product->description : '';
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$data['merchandise'] = $article->product ? $article->product->description : '';
|
||||
$data['producer'] = $article->product->producer->description;
|
||||
$merchandise = $article->product;
|
||||
$data['merchandise'] = $merchandise ? ($merchandise->description ?? '') : '';
|
||||
if ($merchandise && $merchandise->producer) {
|
||||
$data['producer'] = $merchandise->producer->description ?? '';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -100,12 +100,19 @@ 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' => $item->price,
|
||||
'price' => $unitPrice,
|
||||
'variation' => $offer->variation->name,
|
||||
'image' => Articles::getPreviewSrc(ArticleImages::getFullImageByArticle($offer->article)),
|
||||
'latin' => $offer->article->product->specie->latin ?? false,
|
||||
@@ -115,6 +122,24 @@ 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,18 +31,33 @@ class Customers
|
||||
public static function getSaleChannels($customerId = false)
|
||||
{
|
||||
$customer = $customerId ? self::get($customerId) : self::getAuth();
|
||||
$saleChannels = $customer ? $customer->sale_channels : false;
|
||||
$saleChannels = collect();
|
||||
|
||||
return $saleChannels ? $saleChannels : SaleChannels::getDefault();
|
||||
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();
|
||||
}
|
||||
|
||||
public static function getSaleChannel($customerId = false)
|
||||
{
|
||||
$saleChannels = self::getSaleChannels($customerId);
|
||||
|
||||
if ($saleChannels instanceof \Illuminate\Support\Collection) {
|
||||
return $saleChannels->first();
|
||||
}
|
||||
|
||||
return $saleChannels;
|
||||
}
|
||||
|
||||
public static function getDeliveries()
|
||||
{
|
||||
$customer = self::getAuth();
|
||||
@@ -58,12 +73,22 @@ class Customers
|
||||
|
||||
public static function editProfile($id = false)
|
||||
{
|
||||
return $id ? [
|
||||
'customer' => self::get($id, ['addresses', 'deliveries'])->toArray(),
|
||||
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
||||
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()),
|
||||
'orders' => (new CustomerOrdersDataTable())->html(),
|
||||
'invoices' => (new CustomerInvoicesDataTable())->html(),
|
||||
] : abort('403');
|
||||
];
|
||||
}
|
||||
|
||||
public static function getAddresses($id = false)
|
||||
@@ -154,6 +179,24 @@ class Customers
|
||||
return $customer->sale_channels()->sync($saleChannels);
|
||||
}
|
||||
|
||||
public static function setDefaultSaleChannel($customerId, $saleChannelId)
|
||||
{
|
||||
if (! $customerId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$customer = self::get($customerId);
|
||||
|
||||
if (! $customer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$customer->default_sale_channel_id = $saleChannelId ?: null;
|
||||
$customer->save();
|
||||
|
||||
return $customer->fresh(['sale_channels']);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
$data['uuid'] = Str::uuid();
|
||||
|
||||
@@ -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) : false;
|
||||
return $saleChannels ? self::getBySaleChannels($saleChannels) : collect();
|
||||
}
|
||||
|
||||
public static function getBySaleChannels($saleChannels)
|
||||
{
|
||||
return Delivery::bySaleChannels($saleChannels)->with('sale_channel')->get();
|
||||
return Delivery::bySaleChannels($saleChannels)->active()->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()->public()->with('sale_channel')->get();
|
||||
return Delivery::orderBy('name', 'asc')->active()->with('sale_channel')->get();
|
||||
}
|
||||
|
||||
public static function toggleActive($id, $active)
|
||||
|
||||
@@ -15,9 +15,15 @@ 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' => self::getPrice($type->id, $weight),
|
||||
'price' => $price,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,13 @@ class Invoices
|
||||
|
||||
public static function view($uuid)
|
||||
{
|
||||
$data = self::getFullByUUID($uuid)->toArray();
|
||||
$invoice = self::getFullByUUID($uuid);
|
||||
|
||||
if (! $invoice) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = $invoice->toArray();
|
||||
$data['payment_type'] = InvoicePayments::getPaymentType($data['payment_type']);
|
||||
$data['status'] = self::getStatus($data['status']);
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Offer;
|
||||
use App\Models\Shop\PriceList;
|
||||
use App\Models\Shop\PriceListValue;
|
||||
use App\Models\Shop\SaleChannel;
|
||||
use App\Traits\Model\Basic;
|
||||
|
||||
class Offers
|
||||
@@ -166,4 +169,87 @@ 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',
|
||||
'tariff:id,status_id',
|
||||
'variation',
|
||||
])
|
||||
->get();
|
||||
|
||||
return $channels->map(function ($channel) use ($offers) {
|
||||
$priceValue = null;
|
||||
$candidateOffer = null;
|
||||
$allOffersForChannel = [];
|
||||
|
||||
foreach ($offers as $offer) {
|
||||
$priceCandidate = self::getPrice($offer->id, 1, $channel->id);
|
||||
|
||||
if ($priceCandidate && (float) $priceCandidate->price_taxed > 0) {
|
||||
// Get price list name
|
||||
$priceListName = null;
|
||||
if ($priceCandidate) {
|
||||
$priceListModel = PriceList::find($priceCandidate->price_list_id);
|
||||
$priceListName = $priceListModel ? $priceListModel->name : null;
|
||||
}
|
||||
|
||||
// Collect all offers with their details
|
||||
$allOffersForChannel[] = [
|
||||
'id' => $offer->id,
|
||||
'variation_name' => $offer->variation ? $offer->variation->name : null,
|
||||
'stock_current' => (int) $offer->stock_current,
|
||||
'status_id' => (int) $offer->status_id,
|
||||
'is_active' => (int) $offer->status_id === 1,
|
||||
'tariff_id' => $offer->tariff_id ? (int) $offer->tariff_id : null,
|
||||
'price_taxed' => (float) $priceCandidate->price_taxed,
|
||||
'quantity' => (int) $priceCandidate->quantity,
|
||||
'price_list_name' => $priceListName,
|
||||
];
|
||||
|
||||
// Keep first valid offer as the main candidate
|
||||
if (!$candidateOffer) {
|
||||
$priceValue = $priceCandidate;
|
||||
$candidateOffer = $offer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$offerId = $candidateOffer ? $candidateOffer->id : null;
|
||||
$offerStock = $candidateOffer ? (int) $candidateOffer->stock_current : null;
|
||||
$offerIsActive = $candidateOffer ? (int) $candidateOffer->status_id === 1 : false;
|
||||
$offerTariffStatus = $candidateOffer && $candidateOffer->tariff ? (int) $candidateOffer->tariff->status_id : null;
|
||||
$offerHasStock = $candidateOffer && $candidateOffer->stock_current !== null
|
||||
? (float) $candidateOffer->stock_current > 0
|
||||
: null;
|
||||
$offerTariffId = $candidateOffer && $candidateOffer->tariff_id ? (int) $candidateOffer->tariff_id : null;
|
||||
|
||||
return [
|
||||
'id' => $channel->id,
|
||||
'name' => $channel->name,
|
||||
'code' => $channel->code,
|
||||
'price_taxed' => $priceValue ? (float) $priceValue->price_taxed : null,
|
||||
'quantity' => $priceValue ? (int) $priceValue->quantity : null,
|
||||
'offer_id' => $offerId,
|
||||
'offer_is_active' => $offerIsActive,
|
||||
'offer_stock_current' => $offerStock,
|
||||
'offer_has_stock' => $offerHasStock,
|
||||
'tariff_status_id' => $offerTariffStatus,
|
||||
'tariff_id' => $offerTariffId,
|
||||
'all_offers' => $allOffersForChannel,
|
||||
];
|
||||
})->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,12 +46,34 @@ class PriceListValues
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
$value['price_list_id'] = $price_list_id;
|
||||
if ($value['price']) {
|
||||
if (self::hasPrice($value)) {
|
||||
self::store($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function purgeRemovedValues($price_list_id, array $ids)
|
||||
{
|
||||
if (! count($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PriceListValue::byPriceList($price_list_id)
|
||||
->whereIn('id', $ids)
|
||||
->delete();
|
||||
}
|
||||
|
||||
protected static function hasPrice($value): bool
|
||||
{
|
||||
if (! array_key_exists('price', $value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$price = $value['price'];
|
||||
|
||||
return $price !== null && $price !== '';
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return PriceListValue::query();
|
||||
|
||||
@@ -17,7 +17,7 @@ class PriceLists
|
||||
'taxes' => Taxes::getOptions(),
|
||||
'price_list' => [
|
||||
'tariff_id' => $tariffId,
|
||||
'price_list_values' => array_fill(0, 3, ''),
|
||||
'price_list_values' => [],
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -50,9 +50,8 @@ class PriceLists
|
||||
public static function edit($id)
|
||||
{
|
||||
$price_list = self::getFull($id)->toArray();
|
||||
$n = count($price_list['price_list_values']);
|
||||
if ($n <= 3) {
|
||||
$price_list['price_list_values'] += array_fill($n, 3 - $n, '');
|
||||
if (count($price_list['price_list_values']) === 0) {
|
||||
$price_list['price_list_values'][] = [];
|
||||
}
|
||||
|
||||
return $price_list;
|
||||
@@ -71,9 +70,14 @@ class PriceLists
|
||||
public static function store($data)
|
||||
{
|
||||
$id = $data['id'] ?? false;
|
||||
$price_list_values = $data['price_list_values'] ?? false;
|
||||
$price_list_values = $data['price_list_values'] ?? [];
|
||||
$deleted_values = array_map('intval', array_filter($data['deleted_price_list_value_ids'] ?? [], function ($value) {
|
||||
return $value !== null && $value !== '';
|
||||
}));
|
||||
unset($data['price_list_values']);
|
||||
unset($data['deleted_price_list_value_ids']);
|
||||
$price_list = $id ? self::update($data) : self::create($data);
|
||||
PriceListValues::purgeRemovedValues($price_list->id, $deleted_values);
|
||||
PriceListValues::storePrices($price_list->id, $price_list_values);
|
||||
|
||||
return $price_list;
|
||||
|
||||
@@ -3,22 +3,53 @@
|
||||
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()
|
||||
public static function getDefaultID($customerId = false)
|
||||
{
|
||||
$default = self::getDefault();
|
||||
$default = self::getDefault($customerId);
|
||||
|
||||
return $default ? self::getDefault()->id : false;
|
||||
return $default ? $default->id : false;
|
||||
}
|
||||
|
||||
public static function getDefault()
|
||||
public static function getDefault($customerId = false)
|
||||
{
|
||||
return self::getByCode('EXP');
|
||||
$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('POSTE');
|
||||
}
|
||||
|
||||
public static function getByCode($code)
|
||||
|
||||
@@ -8,8 +8,14 @@ class Searches
|
||||
{
|
||||
public static function search($options)
|
||||
{
|
||||
// Get article IDs from Scout search
|
||||
$searchResults = Article::search($options['search_name'])->get()->pluck('id');
|
||||
|
||||
// Filter to only include visible articles
|
||||
$visibleArticleIds = Article::whereIn('id', $searchResults)->visible()->pluck('id');
|
||||
|
||||
return collect(Articles::getArticlesToSell([
|
||||
'ids' => Article::search($options['search_name'])->get()->pluck('id'),
|
||||
'ids' => $visibleArticleIds,
|
||||
]))->sortBy('searchOrder')->toArray();
|
||||
}
|
||||
|
||||
|
||||
47
app/Repositories/Shop/Shop.php
Normal file
47
app/Repositories/Shop/Shop.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
// Default configuration group for Gravatar
|
||||
'default' => [
|
||||
// --- The default avatar size
|
||||
'size' => 80,
|
||||
|
||||
@@ -12,12 +14,22 @@ return [
|
||||
// (string) monsterid: a generated 'monster' with different colors, faces, etc.
|
||||
// (string) wavatar: generated faces with differing features and backgrounds.
|
||||
// (string) retro: awesome generated, 8-bit arcade-style pixelated faces.
|
||||
'default' => 'identicon',
|
||||
'fallback' => 'identicon',
|
||||
|
||||
// --- Whether to use HTTPS protocol
|
||||
'secure' => false,
|
||||
|
||||
// --- Set the type of avatars we allow to show
|
||||
// - g: suitable for display on all websites with any audience type.
|
||||
// - pg: may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.
|
||||
// - r: may contain such things as harsh profanity, intense violence, nudity, or hard drug use.
|
||||
// - x: may contain hardcore sexual imagery or extremely disturbing violence.
|
||||
'maxRating' => 'g',
|
||||
'maximumRating' => 'g',
|
||||
|
||||
// --- Force default image to always display
|
||||
'forceDefault' => false,
|
||||
|
||||
// --- Optional file extension appended to URL
|
||||
'forceExtension' => 'jpg',
|
||||
]
|
||||
];
|
||||
|
||||
@@ -126,7 +126,7 @@ return [
|
||||
* The path where to store temporary files while performing image conversions.
|
||||
* If set to null, storage_path('media-library/temp') will be used.
|
||||
*/
|
||||
'temporary_directory_path' => null,
|
||||
'temporary_directory_path' => env('MEDIA_LIBRARY_TEMP_PATH', storage_path('media-library/temp')),
|
||||
|
||||
/*
|
||||
* The engine that should perform the image conversions.
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('shop_articles', function (Blueprint $table) {
|
||||
$table->dropUnique('ref');
|
||||
$table->unique(['ref', 'deleted_at'], 'shop_articles_ref_deleted_at_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shop_articles', function (Blueprint $table) {
|
||||
$table->dropUnique('shop_articles_ref_deleted_at_unique');
|
||||
$table->unique('ref');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -223,6 +223,9 @@ 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,8 +4,28 @@
|
||||
'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,6 +15,7 @@
|
||||
<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,
|
||||
@@ -24,6 +25,7 @@
|
||||
</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,
|
||||
|
||||
@@ -15,4 +15,9 @@
|
||||
<td>
|
||||
@include('components.form.inputs.money', ['name' => 'price_list_values[' . $index . '][price_taxed]', 'value' => $price_list_value['price_taxed'] ?? null, 'required' => true, 'class' => 'price_taxed'])
|
||||
</td>
|
||||
<td class="text-center align-middle">
|
||||
<button type="button" class="btn btn-outline-danger btn-xs remove-price" title="{{ __('Supprimer') }}">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -30,12 +30,18 @@
|
||||
<th>Unit. HT</th>
|
||||
<th>TVA</th>
|
||||
<th>Unit. TTC</th>
|
||||
<th class="text-center" style="width: 60px;">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($price_list['price_list_values'] as $price_list_value)
|
||||
@include('Admin.Shop.PriceListValues.partials.row_price', ['index' => $loop->index])
|
||||
@php($priceListValues = $price_list['price_list_values'] ?? [])
|
||||
@php($nextIndex = count($priceListValues))
|
||||
|
||||
@foreach ($priceListValues as $index => $price_list_value)
|
||||
@include('Admin.Shop.PriceListValues.partials.row_price', ['index' => $index, 'price_list_value' => $price_list_value])
|
||||
@endforeach
|
||||
|
||||
@include('Admin.Shop.PriceListValues.partials.row_price', ['index' => $nextIndex, 'price_list_value' => []])
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
@@ -49,19 +55,28 @@
|
||||
</tfoot>
|
||||
</table>
|
||||
@endcomponent
|
||||
|
||||
<div id="deleted-price-list-values"></div>
|
||||
</form>
|
||||
|
||||
|
||||
<script>
|
||||
var priceRowIndex = 0;
|
||||
var lastRemovedIndex = null;
|
||||
|
||||
function handleAddPrice() {
|
||||
$('#add_price').click( function () {
|
||||
var index = $('#prices-table tbody tr').length;
|
||||
addEmptyPriceRow();
|
||||
})
|
||||
}
|
||||
|
||||
function addEmptyPriceRow() {
|
||||
var index = nextPriceRowIndex();
|
||||
$.get("{{ route('Admin.Shop.PriceListValues.addPrice') }}/" + index, function(data) {
|
||||
$("#prices-table").append(data);
|
||||
})
|
||||
$("#prices-table tbody").append(data);
|
||||
handlePrices();
|
||||
})
|
||||
handleRemovePrice();
|
||||
lastRemovedIndex = null;
|
||||
});
|
||||
}
|
||||
|
||||
function handle_prices() {
|
||||
@@ -101,9 +116,82 @@
|
||||
handle_prices_taxed();
|
||||
}
|
||||
|
||||
function handleRemovePrice() {
|
||||
$('#prices-table').off('click', '.remove-price').on('click', '.remove-price', function() {
|
||||
var $row = $(this).closest('tr');
|
||||
var idx = extractRowIndex($row);
|
||||
var id = $row.find('input[name$="[id]"]').val();
|
||||
if (id) {
|
||||
registerDeletedPrice(id);
|
||||
}
|
||||
$row.remove();
|
||||
lastRemovedIndex = idx;
|
||||
ensureAtLeastOneRow();
|
||||
});
|
||||
}
|
||||
|
||||
function registerDeletedPrice(id) {
|
||||
var $container = $('#deleted-price-list-values');
|
||||
if ($container.find('input[value="' + id + '"]').length === 0) {
|
||||
$container.append('<input type="hidden" name="deleted_price_list_value_ids[]" value="' + id + '">');
|
||||
}
|
||||
}
|
||||
|
||||
function ensureAtLeastOneRow() {
|
||||
if ($('#prices-table tbody tr').length === 0) {
|
||||
if (lastRemovedIndex !== null) {
|
||||
$.get("{{ route('Admin.Shop.PriceListValues.addPrice') }}/" + lastRemovedIndex, function(data) {
|
||||
$("#prices-table tbody").append(data);
|
||||
handlePrices();
|
||||
handleRemovePrice();
|
||||
});
|
||||
} else {
|
||||
addEmptyPriceRow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function computeStartingIndex() {
|
||||
var maxIndex = -1;
|
||||
$('#prices-table tbody tr').each(function() {
|
||||
var $idInput = $(this).find('input[name$="[id]"]');
|
||||
var name = $idInput.attr('name');
|
||||
if (name) {
|
||||
var matches = name.match(/price_list_values\[(\d+)\]\[id\]/);
|
||||
if (matches && matches[1]) {
|
||||
var idx = parseInt(matches[1], 10);
|
||||
if (!isNaN(idx) && idx > maxIndex) {
|
||||
maxIndex = idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return maxIndex + 1;
|
||||
}
|
||||
|
||||
function nextPriceRowIndex() {
|
||||
return priceRowIndex++;
|
||||
}
|
||||
|
||||
function extractRowIndex($row) {
|
||||
var $idInput = $row.find('input[name$="[id]"]');
|
||||
var name = $idInput.attr('name');
|
||||
if (!name) {
|
||||
return priceRowIndex;
|
||||
}
|
||||
|
||||
var matches = name.match(/price_list_values\[(\d+)\]\[id\]/);
|
||||
|
||||
return matches && matches[1] ? parseInt(matches[1], 10) : priceRowIndex;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
priceRowIndex = computeStartingIndex();
|
||||
handleAddPrice();
|
||||
handlePrices();
|
||||
handleRemovePrice();
|
||||
ensureAtLeastOneRow();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -1,37 +1,59 @@
|
||||
@if ($article['offers']['semences'] ?? false)
|
||||
@php
|
||||
// Check if article is not visible OR has no offers at all
|
||||
$hasNoOffers = empty($article['offers']['semences'] ?? false)
|
||||
&& empty($article['offers']['plants'] ?? false)
|
||||
&& empty($article['offers']['legumes'] ?? false)
|
||||
&& empty($article['offers']['marchandise'] ?? false);
|
||||
$shouldShowComingSoon = !($article['visible'] ?? true) || $hasNoOffers;
|
||||
@endphp
|
||||
|
||||
@if ($shouldShowComingSoon)
|
||||
{{-- Display "Coming Soon" box when article is not visible or has no offers --}}
|
||||
<div class="card border-info">
|
||||
<div class="card-body text-center p-4">
|
||||
<h4 class="text-info mb-3">
|
||||
<i class="fas fa-clock"></i>
|
||||
</h4>
|
||||
<h5 class="card-title mb-0">Bientôt disponible</h5>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
{{-- Display normal offers for visible articles with available offers --}}
|
||||
@if ($article['offers']['semences'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['semences'],
|
||||
'title' => 'Semences',
|
||||
'model' => 'semences',
|
||||
'bgClass' => 'bg-green-light',
|
||||
])
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@if ($article['offers']['plants'] ?? false)
|
||||
@if ($article['offers']['plants'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['plants'],
|
||||
'title' => 'Plants',
|
||||
'model' => 'plants',
|
||||
'bgClass' => 'bg-green-light',
|
||||
])
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@if ($article['offers']['legumes'] ?? false)
|
||||
@if ($article['offers']['legumes'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['legumes'],
|
||||
'title' => 'Légumes',
|
||||
'model' => 'legumes',
|
||||
'bgClass' => 'bg-green-light',
|
||||
])
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@if ($article['offers']['marchandise'] ?? false)
|
||||
@if ($article['offers']['marchandise'] ?? false)
|
||||
@include('Shop.Articles.partials.addBasket', [
|
||||
'data' => $article['offers']['marchandise'],
|
||||
'title' => 'Marchandises',
|
||||
'model' => 'marchandise',
|
||||
'bgClass' => 'bg-green-light',
|
||||
])
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@include('load.basket')
|
||||
|
||||
@@ -48,9 +48,167 @@
|
||||
|
||||
</div>
|
||||
<div class="col-lg-3 col-xs-12">
|
||||
@if (auth('web')->check() && !empty($article['available_sale_channels']))
|
||||
<div id="article-admin-offers" class="alert alert-info p-2 mb-3">
|
||||
<strong class="d-block">Offres :</strong>
|
||||
<ul class="list-unstyled mb-0 small">
|
||||
@php
|
||||
$currentSaleChannelId = $article['current_sale_channel']['id'] ?? null;
|
||||
@endphp
|
||||
@foreach ($article['available_sale_channels'] as $channel)
|
||||
@php
|
||||
$isCurrentChannel = $currentSaleChannelId === $channel['id'];
|
||||
$priceTaxed = $channel['price_taxed'] ?? null;
|
||||
$quantity = $channel['quantity'] ?? null;
|
||||
$offerStock = $channel['offer_stock_current'] ?? null;
|
||||
$offerIsActive = $channel['offer_is_active'] ?? false;
|
||||
$offerHasStock = $channel['offer_has_stock'] ?? null;
|
||||
$highlightStyle = $isCurrentChannel ? 'background-color: rgba(0, 0, 0, 0.06);' : '';
|
||||
$nameClass = ($offerIsActive && $offerHasStock !== false) ? '' : 'text-muted';
|
||||
$flags = [];
|
||||
if (! $offerIsActive) {
|
||||
$flags[] = 'inactive';
|
||||
}
|
||||
if ($offerHasStock === false) {
|
||||
$flags[] = 'no-stock';
|
||||
}
|
||||
@endphp
|
||||
<li style="{{ $highlightStyle }}">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<span class="{{ $nameClass }}">
|
||||
• {{ $channel['name'] }}
|
||||
<span class="d-block text-muted" style="font-size: 0.85em; padding-left: 0.9em;">
|
||||
Code {{ $channel['code'] }}{!! $flags ? ' · <strong class="text-dark">'.implode('</strong> · <strong class="text-dark">', $flags).'</strong>' : '' !!}
|
||||
</span>
|
||||
</span>
|
||||
@if ($priceTaxed !== null)
|
||||
@php
|
||||
$tariffId = $channel['tariff_id'] ?? null;
|
||||
@endphp
|
||||
@if ($tariffId)
|
||||
<a href="{{ route('Admin.Shop.Tariffs.edit', $tariffId) }}" target="_blank" rel="noopener" class="ml-2 text-nowrap text-right {{ $nameClass }} text-decoration-none text-reset d-inline-block admin-link-group admin-price-link">
|
||||
{{ number_format($priceTaxed, 2, ',', ' ') }} € TTC
|
||||
@if (! empty($quantity))
|
||||
<span class="d-block text-muted" style="font-size: 0.85em;">Qté min. {{ $quantity }}</span>
|
||||
@endif
|
||||
</a>
|
||||
@else
|
||||
<span class="ml-2 text-nowrap text-right {{ $nameClass }}">
|
||||
{{ number_format($priceTaxed, 2, ',', ' ') }} € TTC
|
||||
@if (! empty($quantity))
|
||||
<span class="d-block text-muted" style="font-size: 0.85em;">Qté min. {{ $quantity }}</span>
|
||||
@endif
|
||||
</span>
|
||||
@endif
|
||||
@else
|
||||
<span class="ml-2 text-muted">–</span>
|
||||
@endif
|
||||
</div>
|
||||
@if (!empty($channel['all_offers']))
|
||||
<ul class="list-unstyled mb-0 mt-1" style="padding-left: 0.75em;">
|
||||
@foreach ($channel['all_offers'] as $offer)
|
||||
@php
|
||||
$isSelectedOffer = $offer['id'] === $channel['offer_id'];
|
||||
$offerClass = $offer['is_active'] ? 'text-dark' : 'text-muted';
|
||||
$stockClass = $offer['stock_current'] > 0 ? 'text-success' : 'text-danger';
|
||||
@endphp
|
||||
<li class="small {{ $offerClass }}" style="font-size: 0.85em;">
|
||||
<a href="{{ route('Admin.Shop.Offers.edit', $offer['id']) }}" target="_blank" rel="noopener" class="text-decoration-none {{ $offerClass }} admin-link-group admin-offer-link">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<span style="opacity: 0.5;">{{ $isSelectedOffer ? '▸' : '○' }}</span>
|
||||
@if ($offer['variation_name'])
|
||||
{{ $offer['variation_name'] }}
|
||||
@endif
|
||||
- Stock: <strong class="{{ $stockClass }}">{{ $offer['stock_current'] }}</strong>
|
||||
@if (!$offer['is_active'])
|
||||
<span class="text-muted">(inactive)</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="text-right text-nowrap ml-2">
|
||||
{{ number_format($offer['price_taxed'], 2, ',', ' ') }} €
|
||||
@if ($offer['quantity'] > 1)
|
||||
<span class="text-muted">(min {{ $offer['quantity'] }})</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
@include('Shop.Articles.partials.ArticleAddBasket')
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('load.layout.modal')
|
||||
|
||||
@if (auth('web')->check() && !empty($article['available_sale_channels']))
|
||||
@push('styles')
|
||||
<style>
|
||||
#article-admin-offers .admin-link-group {
|
||||
transition: background-color 0.15s ease;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
#article-admin-offers .admin-price-link {
|
||||
display: inline-block;
|
||||
padding: 2px 4px;
|
||||
margin: -2px -4px;
|
||||
}
|
||||
|
||||
#article-admin-offers .admin-offer-link {
|
||||
display: block;
|
||||
padding: 2px 4px;
|
||||
margin: -2px -4px;
|
||||
}
|
||||
|
||||
#article-admin-offers .admin-link-group:hover,
|
||||
#article-admin-offers .admin-link-group:focus,
|
||||
#article-admin-offers .admin-link-group.linked-hover {
|
||||
background-color: rgba(0, 123, 255, 0.1);
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const container = document.getElementById('article-admin-offers');
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
||||
const links = Array.from(container.querySelectorAll('a.admin-link-group[href]'));
|
||||
const grouped = new Map();
|
||||
|
||||
links.forEach((link) => {
|
||||
const href = link.getAttribute('href');
|
||||
if (!grouped.has(href)) {
|
||||
grouped.set(href, []);
|
||||
}
|
||||
grouped.get(href).push(link);
|
||||
});
|
||||
|
||||
grouped.forEach((group) => {
|
||||
group.forEach((link) => {
|
||||
const addHighlight = () => group.forEach((item) => item.classList.add('linked-hover'));
|
||||
const removeHighlight = () => group.forEach((item) => item.classList.remove('linked-hover'));
|
||||
|
||||
link.addEventListener('mouseenter', addHighlight);
|
||||
link.addEventListener('mouseleave', removeHighlight);
|
||||
link.addEventListener('focus', addHighlight);
|
||||
link.addEventListener('blur', removeHighlight);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@endif
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
updateBasket(offer_id, quantity, function() {
|
||||
calculatePrice($row);
|
||||
calculateTotal();
|
||||
});
|
||||
}, $row);
|
||||
});
|
||||
|
||||
$('.basket-delete').click(function() {
|
||||
@@ -70,13 +70,20 @@
|
||||
});
|
||||
}
|
||||
|
||||
function updateBasket(offer_id, quantity, callback) {
|
||||
function updateBasket(offer_id, quantity, callback, $row) {
|
||||
var data = {
|
||||
offer_id: offer_id,
|
||||
quantity: quantity,
|
||||
update: true
|
||||
};
|
||||
$.post("{{ route('Shop.Basket.addBasket') }}", data, callback);
|
||||
$.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();
|
||||
});
|
||||
}
|
||||
|
||||
function calculatePrice($that) {
|
||||
|
||||
@@ -1,25 +1,174 @@
|
||||
@foreach ($deliveries as $delivery)
|
||||
<div class="row">
|
||||
<div class="col-1 text-right pt-1">
|
||||
@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">
|
||||
|
||||
@include('components.form.radios.icheck', [
|
||||
'name' => 'delivery_id',
|
||||
'id_name' => 'delivery_id_' . $delivery['id'],
|
||||
'value' => $delivery['id'],
|
||||
'checked' => $customer['sale_delivery_id'] ?? false,
|
||||
'class' => 'delivery',
|
||||
'name' => 'sale_channel_id',
|
||||
'id_name' => 'sale_channel_id_' . $saleChannel['id'],
|
||||
'val' => $saleChannel['id'],
|
||||
'value' => $selectedSaleChannelId,
|
||||
'class' => 'sale-channel',
|
||||
'disabled' => $isBlocked,
|
||||
])
|
||||
</div>
|
||||
<div class="col-11 pt-3">
|
||||
<strong>{{ $delivery['name'] }} - {{ $delivery['sale_channel']['name'] }}</strong><br />
|
||||
<p>{{ $delivery['description'] }}</p>
|
||||
<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>
|
||||
@endforeach
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
$('.delivery').off().change(function() {
|
||||
console.log($(this).val());
|
||||
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é.') }}";
|
||||
|
||||
console.error('Sale channel update failed', {
|
||||
status: xhr.status,
|
||||
response: xhr.responseJSON || xhr.responseText,
|
||||
selectedSaleChannel
|
||||
});
|
||||
|
||||
alert(message);
|
||||
|
||||
if (currentSaleChannelId) {
|
||||
$saleChannels.filter('[value="' + currentSaleChannelId + '"]').prop('checked', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<nav>
|
||||
@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
|
||||
@@ -10,9 +15,9 @@
|
||||
FACTURES
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</nav>
|
||||
|
||||
<div class="tab-content">
|
||||
<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')
|
||||
@@ -32,4 +37,33 @@
|
||||
])
|
||||
</x-card>
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
@endif
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
@include('load.layout.chevron')
|
||||
|
||||
@push('js')
|
||||
@prepend('js')
|
||||
<script>
|
||||
$('#customer').click(function() {
|
||||
$(".personal_data").addClass('d-none');
|
||||
@@ -65,7 +65,9 @@
|
||||
});
|
||||
|
||||
function refreshBasketTotal(deliveryId, deliveryTypeId) {
|
||||
options = deliveryId + '/' + deliveryTypeId;
|
||||
var safeDeliveryId = deliveryId !== undefined && deliveryId !== null ? deliveryId : '';
|
||||
var safeDeliveryTypeId = deliveryTypeId !== undefined && deliveryTypeId !== null ? deliveryTypeId : '';
|
||||
var options = safeDeliveryId + '/' + safeDeliveryTypeId;
|
||||
$.get("{{ Route('Shop.Basket.getBasketTotal') }}/" + options, function(data) {
|
||||
$('#basketTotal').html(data);
|
||||
});
|
||||
@@ -73,4 +75,4 @@
|
||||
|
||||
initChevron();
|
||||
</script>
|
||||
@endpush
|
||||
@endprepend
|
||||
|
||||
@@ -1,13 +1,51 @@
|
||||
@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' =>
|
||||
old($name) ?? $address['priority'] || count($addresses) === 1 ? $address['id'] : false,
|
||||
'value' => $preselectedAddressId,
|
||||
])
|
||||
</div>
|
||||
<div class="col-11">
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
@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' => (int) old('delivery_id') === $delivery['id'] ? $delivery['id'] : null,
|
||||
'value' => $preselectedDeliveryId,
|
||||
'id' => 'delivery_' . $delivery['id'],
|
||||
'class' => 'delivery_mode' . ($delivery['at_house'] ? ' at_house' : ''),
|
||||
])
|
||||
@@ -29,16 +39,29 @@ ci-contre
|
||||
@push('js')
|
||||
<script>
|
||||
function handleDeliveries() {
|
||||
$('#delivery_mode input.delivery_mode').change(function() {
|
||||
if ($(this).hasClass('at_house')) {
|
||||
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_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 = $(this).val();
|
||||
|
||||
var deliveryId = $currentDelivery.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,7 +7,18 @@
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach ($delivery_types as $delivery_type_id => $delivery_type)
|
||||
@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)
|
||||
<tr>
|
||||
<td>
|
||||
@include('components.form.radios.icheck', [
|
||||
@@ -15,6 +26,7 @@
|
||||
'val' => $delivery_type_id,
|
||||
'id' => 'delivery_type_' . $delivery_type_id,
|
||||
'class' => 'delivery_type',
|
||||
'value' => $preselectedDeliveryTypeId,
|
||||
])
|
||||
</td>
|
||||
<td>
|
||||
@@ -31,11 +43,19 @@
|
||||
@push('js')
|
||||
<script>
|
||||
function handleDeliveryTypes() {
|
||||
$('input.delivery_type').change(function() {
|
||||
var $deliveryTypeInputs = $('input.delivery_type');
|
||||
|
||||
$deliveryTypeInputs.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,6 +17,7 @@
|
||||
<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,7 +38,8 @@
|
||||
/<(p|a|div|span|strike|strong|i|u)[^>]*?>(\s| |<br\/>|\r|\n)*?<\/(p|a|div|span|strike|strong|i|u)>/gi,
|
||||
''); // Empty tags
|
||||
},
|
||||
skin: "boilerplate",
|
||||
skin: "oxide",
|
||||
content_css: 'oxide',
|
||||
language: '{{ App::getLocale() }}',
|
||||
file_picker_callback: function(callback, value, meta) {
|
||||
var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName(
|
||||
|
||||
@@ -9,14 +9,16 @@
|
||||
var selector = (typeof(sel) == 'undefined') ? '.save' : sel;
|
||||
$(selector).off().click(function(e) {
|
||||
if (typeof initValidator === 'function') {
|
||||
console.log('click');
|
||||
e.preventDefault();
|
||||
if ($(form).valid()) {
|
||||
$(this).prop("disabled", true);
|
||||
$(this).html($(this).data('loading-text'));
|
||||
$(form).submit();
|
||||
} else {
|
||||
console.log('erreur');
|
||||
const $firstInvalid = $(form).find(':invalid, .error').first();
|
||||
if ($firstInvalid.length) {
|
||||
$firstInvalid.focus();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$(form).submit();
|
||||
|
||||
@@ -75,12 +75,12 @@
|
||||
if (typeof(tinyMCE) != 'undefined') {
|
||||
tinyMCE.triggerSave();
|
||||
}
|
||||
$('form ' + form_id).submit();
|
||||
getModalForm(form_id).trigger('submit');
|
||||
status = 1;
|
||||
}
|
||||
|
||||
function handlePostModal(form_id, url_save, callback) {
|
||||
$('form ' + form_id).submit(function(e) {
|
||||
getModalForm(form_id).off('submit').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
var formData = new FormData(this);
|
||||
$.ajax({
|
||||
@@ -98,6 +98,15 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getModalForm(form_id) {
|
||||
var $form = $(form_id);
|
||||
if (! $form.length) {
|
||||
$form = $('form' + form_id);
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
||||
@@ -3,5 +3,4 @@
|
||||
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