From 9949ae95cf62829069e0b24d33b0937f8be9c498 Mon Sep 17 00:00:00 2001 From: ludo Date: Sat, 25 Nov 2023 20:23:21 +0100 Subject: [PATCH] update --- .../Admin/Shop/InvoiceController.php | 3 ++ .../Admin/Shop/InvoicePaymentController.php | 6 ++-- app/Repositories/Shop/InvoicePayments.php | 36 +++++-------------- app/Repositories/Shop/Invoices.php | 2 +- build/css/main.css | 9 ++++- .../views/Admin/Shop/Invoices/form.blade.php | 14 +++----- .../Shop/Invoices/partials/payments.blade.php | 20 +++++++++-- 7 files changed, 46 insertions(+), 44 deletions(-) diff --git a/app/Http/Controllers/Admin/Shop/InvoiceController.php b/app/Http/Controllers/Admin/Shop/InvoiceController.php index bd007371..15985678 100644 --- a/app/Http/Controllers/Admin/Shop/InvoiceController.php +++ b/app/Http/Controllers/Admin/Shop/InvoiceController.php @@ -38,8 +38,11 @@ class InvoiceController extends Controller { $data = Invoices::init(); $data['invoice'] = Invoices::getFull($id)->toArray(); + /* $model = new InvoicePaymentsDataTable(); $data['invoice_payments'] = $model->html(); + */ + // dump($data); return view('Admin.Shop.Invoices.edit', $data); } diff --git a/app/Http/Controllers/Admin/Shop/InvoicePaymentController.php b/app/Http/Controllers/Admin/Shop/InvoicePaymentController.php index 098d6a19..ac682c7b 100644 --- a/app/Http/Controllers/Admin/Shop/InvoicePaymentController.php +++ b/app/Http/Controllers/Admin/Shop/InvoicePaymentController.php @@ -30,7 +30,7 @@ class InvoicePaymentController extends Controller public function show($id) { - $data['invoice_payment'] = InvoicePayments::getFull($id)->toArray(); + $data['invoice_payment'] = InvoicePayments::getArray($id); return view('Admin.Shop.InvoicePayments.view', $data); } @@ -38,13 +38,13 @@ class InvoicePaymentController extends Controller public function edit($id) { $data = InvoicePayments::init(); - $data['invoice_payment'] = InvoicePayments::getFull($id)->toArray(); + $data['invoice_payment'] = InvoicePayments::getArray($id); return view('Admin.Shop.InvoicePayments.edit', $data); } public function destroy($id) { - return InvoicePayments::delete($id); + return InvoicePayments::destroy($id); } } diff --git a/app/Repositories/Shop/InvoicePayments.php b/app/Repositories/Shop/InvoicePayments.php index 0acf23df..b9e7c703 100644 --- a/app/Repositories/Shop/InvoicePayments.php +++ b/app/Repositories/Shop/InvoicePayments.php @@ -3,43 +3,18 @@ namespace App\Repositories\Shop; use App\Models\Shop\InvoicePayment; +use App\Traits\Model\Basic; class InvoicePayments { + use Basic; + public static function init() { return [ 'payment_types' => self::paymentTypes(), ]; } - public static function get($id, $relations = false) - { - return $relations ? InvoicePayment::with($relations)->findOrFail($id) : InvoicePayment::findOrFail($id); - } - - public static function store($data) - { - return ($data['id'] ?? false) ? self::update($data) : self::create($data); - } - - public static function create($data) - { - return InvoicePayment::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $item = self::get($id); - $item->update($data); - - return $item; - } - - public static function delete($id) - { - return InvoicePayment::destroy($id); - } public static function getPaymentType($id) { @@ -55,4 +30,9 @@ class InvoicePayments 'VIREMENT', ]; } + + public static function getModel() + { + return InvoicePayment::query(); + } } diff --git a/app/Repositories/Shop/Invoices.php b/app/Repositories/Shop/Invoices.php index 10284997..bfeb2cd8 100644 --- a/app/Repositories/Shop/Invoices.php +++ b/app/Repositories/Shop/Invoices.php @@ -36,7 +36,7 @@ class Invoices public static function getFull($id) { - return self::get($id, ['address', 'order.customer', 'order.delivery_address', 'order.detail']); + return self::get($id, ['address', 'payments', 'order.customer', 'order.delivery_address', 'order.detail']); } public static function getByUUID($uuid) diff --git a/build/css/main.css b/build/css/main.css index 47f4ccae..2fd125ae 100644 --- a/build/css/main.css +++ b/build/css/main.css @@ -104,4 +104,11 @@ body { .dashtable .counter .value { color: #527C39!important; font-size: 1.4em; -} \ No newline at end of file +} +.bg-lighter { + background-color: rgba(255,255,255,0.05)!important; +} + +.bg-darker { + background-color: rgba(0,0,0,0.05)!important; +} diff --git a/resources/views/Admin/Shop/Invoices/form.blade.php b/resources/views/Admin/Shop/Invoices/form.blade.php index 36bbd483..78b320aa 100644 --- a/resources/views/Admin/Shop/Invoices/form.blade.php +++ b/resources/views/Admin/Shop/Invoices/form.blade.php @@ -45,17 +45,13 @@ ])
- @include('components.form.select', [ - 'label' => 'Règlement', - 'name' => 'payment_type', - 'list' => $payment_types ?? [], - 'value' => $invoice['order']['payment_type'], - 'class' => 'select2', - 'disabled' => false, - ])
- @include('Admin.Shop.Invoices.partials.payments') + + @include('Admin.Shop.Invoices.partials.payments', [ + 'payments' => $invoice['payments'] ?? false, + ]) +
diff --git a/resources/views/Admin/Shop/Invoices/partials/payments.blade.php b/resources/views/Admin/Shop/Invoices/partials/payments.blade.php index a0dcfc8b..d225f232 100644 --- a/resources/views/Admin/Shop/Invoices/partials/payments.blade.php +++ b/resources/views/Admin/Shop/Invoices/partials/payments.blade.php @@ -7,8 +7,24 @@
@if ($payments ?? false) - @foreach ($payments as $payment) - @endforeach + + + + + + + + + @foreach ($payments as $payment) + + + + + + + @endforeach + +
DateTypeMontantRef
{{ $payment['date'] }}{{ $payment_types[$payment['payment_type']] }}{{ sprintf('%01.2f', $payment['amount']) }} €{{ $payment['reference'] }}
@endif @push('js')