fix invoice payment
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\InvoicePayment;
|
||||
use App\Repositories\Shop\InvoicePayments;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class InvoicesDataTable extends DataTable
|
||||
class InvoicePaymentsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'InvoicePayments';
|
||||
public $model_name = 'invoice_payments';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = route('Admin.Shop.InvoicePayments.index');
|
||||
}
|
||||
|
||||
public function query(InvoicePayment $model)
|
||||
{
|
||||
@@ -34,7 +39,7 @@ class InvoicesDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('payment_type')->title('Type')->width(80),
|
||||
Column::make('status')->width(60),
|
||||
Column::make('date')->width(60),
|
||||
Column::make('amount')->title('Montant')->width(100),
|
||||
Column::make('reference')->title('Référence'),
|
||||
$this->makeColumnButtons(),
|
||||
@@ -38,12 +38,9 @@ class InvoiceController extends Controller
|
||||
{
|
||||
$data = Invoices::init();
|
||||
$data['invoice'] = Invoices::getFull($id)->toArray();
|
||||
$model = new invoicePaymentsDataTable();
|
||||
$model = new InvoicePaymentsDataTable();
|
||||
$data['invoice_payments'] = $model->html();
|
||||
|
||||
// dump($data);
|
||||
// exit;
|
||||
|
||||
return view('Admin.Shop.Invoices.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@ class InvoicePaymentController extends Controller
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Admin.Shop.InvoicePayments.create');
|
||||
$data = InvoicePayments::init();
|
||||
|
||||
return view('Admin.Shop.InvoicePayments.create' , $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
@@ -37,8 +39,6 @@ class InvoicePaymentController extends Controller
|
||||
{
|
||||
$data = InvoicePayments::init();
|
||||
$data['invoice_payment'] = InvoicePayments::getFull($id)->toArray();
|
||||
$model = new invoice_paymentPaymentsDataTable();
|
||||
$data['invoice_payment_payments'] = $model->html();
|
||||
|
||||
return view('Admin.Shop.InvoicePayments.edit', $data);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,12 @@ use App\Models\Shop\InvoicePayment;
|
||||
|
||||
class InvoicePayments
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -1,16 +1 @@
|
||||
@extends('layout.index', [
|
||||
'title' => __('invoices.title'),
|
||||
'subtitle' => __('invoices.create.title'),
|
||||
'breadcrumb' => [__('invoices.title'), __('invoices.create.title')]
|
||||
])
|
||||
|
||||
@include('boilerplate::load.fileinput')
|
||||
|
||||
@section('content')
|
||||
|
||||
{{ Form::open(['route' => 'Admin.Shop.Invoices.store', 'id' => 'invoice-form', 'autocomplete' => 'off']) }}
|
||||
@include('Admin.Shop.Invoices.form')
|
||||
@include('components.save')
|
||||
</form>
|
||||
|
||||
@endsection
|
||||
@include('Admin.Shop.InvoicePayments.form')
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
'label' => 'Règlement',
|
||||
'name' => 'payment_type',
|
||||
'list' => $payment_types ?? [],
|
||||
'value' => $invoice_payment['payment_type'],
|
||||
'value' => $invoice_payment['payment_type'] ?? null,
|
||||
'class' => 'select2',
|
||||
])
|
||||
</div>
|
||||
@@ -12,15 +12,7 @@
|
||||
@include('components.form.input', [
|
||||
'label' => 'Montant',
|
||||
'name' => 'amount',
|
||||
'value' => $invoice_payment['amount'],
|
||||
'value' => $invoice_payment['amount'] ?? null,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="float-right mt-3">
|
||||
@include('components.form.buttons.button-save')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,95 +4,8 @@
|
||||
'breadcrumb' => ['Articles'],
|
||||
])
|
||||
|
||||
@include('boilerplate::load.fileinput')
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
{{ Form::open(['route' => 'Admin.Shop.Invoices.update', 'id' => 'invoice-form', 'autocomplete' => 'off']) }}
|
||||
<input type="hidden" name="id" value="{{ $invoice['id'] }}">
|
||||
<x-card>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<h4> </h4>
|
||||
</div>
|
||||
<div class="col-6 text-right">
|
||||
@include('components.form.buttons.button-save')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-6">
|
||||
<h3>
|
||||
{{ $invoice['order']['customer']['last_name'] }}
|
||||
{{ $invoice['order']['customer']['first_name'] }}
|
||||
</h3>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h6>
|
||||
@if ($invoice['order']['delivery_address'])
|
||||
{{ $invoice['order']['delivery_address']['address'] }}<br />
|
||||
@isset($invoice['order']['delivery_address']['address2'])
|
||||
{{ $invoice['order']['delivery_address']['address2'] }}<br />
|
||||
@endisset
|
||||
{{ $invoice['order']['delivery_address']['zipcode'] }}
|
||||
{{ $invoice['order']['delivery_address']['city'] }}<br />
|
||||
@endif
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="row mb-3">
|
||||
<div class="col-6" style="font-size: 1.2em; font-weight: 500;">
|
||||
Facture N° {{ $invoice['ref'] }}<br />
|
||||
du {{ Carbon\Carbon::parse($invoice['created_at'])->isoFormat('LLLL') }}
|
||||
</div>
|
||||
<div class="col-6">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-6">
|
||||
@include('components.form.select', [
|
||||
'label' => 'Statut',
|
||||
'name' => 'status',
|
||||
'list' => $statuses ?? [],
|
||||
'value' => $invoice['status'],
|
||||
'class' => 'select2',
|
||||
])
|
||||
</div>
|
||||
<div class="col-6">
|
||||
@include('components.form.select', [
|
||||
'label' => 'Règlement',
|
||||
'name' => 'payment_type',
|
||||
'list' => $payment_types ?? [],
|
||||
'value' => $invoice['order']['payment_type'],
|
||||
'class' => 'select2',
|
||||
'disabled' => false,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
@include('Admin.Shop.Orders.partials.detail', [
|
||||
'detail_type' => 'facture',
|
||||
'order' => $invoice['order'],
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
@include('Admin.Shop.Invoices.form')
|
||||
</x-card>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<x-card>
|
||||
<h4>Règlements</h4>
|
||||
@include('Admin.Shop.InvoicePayments.list', [
|
||||
'dataTable' => $invoice_payments,
|
||||
])
|
||||
</x-card>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -1,29 +1,71 @@
|
||||
{{ Form::open(['route' => 'Admin.Shop.Invoices.update', 'id' => 'invoice-form', 'autocomplete' => 'off']) }}
|
||||
<input type="hidden" name="id" id="id" value="{{ $invoice['id'] ?? false }}">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
@include('components.form.input', [
|
||||
'name' => 'name',
|
||||
'value' => $family['name'] ?? null,
|
||||
'required' => true,
|
||||
'label' => 'Nom',
|
||||
])
|
||||
|
||||
@include('components.form.textarea', [
|
||||
'name' => 'description',
|
||||
'value' => isset($description) ? $description : null,
|
||||
'class' => 'editor',
|
||||
'required' => false,
|
||||
'label' => 'Description',
|
||||
])
|
||||
|
||||
<div class="col-6">
|
||||
<h5>
|
||||
Facture N° {{ $invoice['ref'] }}
|
||||
du {{ Carbon\Carbon::parse($invoice['created_at'])->isoFormat('LLLL') }}
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="float-right mt-3">
|
||||
<div class="col-6 text-right">
|
||||
@include('components.form.buttons.button-save')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('boilerplate::load.tinymce')
|
||||
<div class="row mb-3">
|
||||
<div class="col-6">
|
||||
<h3>
|
||||
{{ $invoice['order']['customer']['last_name'] }}
|
||||
{{ $invoice['order']['customer']['first_name'] }}
|
||||
</h3>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h6>
|
||||
@if ($invoice['order']['delivery_address'])
|
||||
{{ $invoice['order']['delivery_address']['address'] }}<br />
|
||||
@isset($invoice['order']['delivery_address']['address2'])
|
||||
{{ $invoice['order']['delivery_address']['address2'] }}<br />
|
||||
@endisset
|
||||
{{ $invoice['order']['delivery_address']['zipcode'] }}
|
||||
{{ $invoice['order']['delivery_address']['city'] }}<br />
|
||||
@endif
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="row mb-3">
|
||||
<div class="col-6">
|
||||
@include('components.form.select', [
|
||||
'label' => 'Statut',
|
||||
'name' => 'status',
|
||||
'list' => $statuses ?? [],
|
||||
'value' => $invoice['status'],
|
||||
'class' => 'select2',
|
||||
])
|
||||
</div>
|
||||
<div class="col-6">
|
||||
@include('components.form.select', [
|
||||
'label' => 'Règlement',
|
||||
'name' => 'payment_type',
|
||||
'list' => $payment_types ?? [],
|
||||
'value' => $invoice['order']['payment_type'],
|
||||
'class' => 'select2',
|
||||
'disabled' => false,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
@include('Admin.Shop.Invoices.partials.payments')
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
@include('Admin.Shop.Orders.partials.detail', [
|
||||
'detail_type' => 'facture',
|
||||
'order' => $invoice['order'] ?? null,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@include('load.layout.modal')
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<h4>
|
||||
<x-form.buttons.button-add id="add_payment" class="btn-xs" />
|
||||
Règlements
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
@if ($payments ?? false)
|
||||
@foreach ($payments as $payment)
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
$('#add_payment').click(function() {
|
||||
InvoicePaymentCreate();
|
||||
});
|
||||
|
||||
function InvoicePaymentCreate() {
|
||||
var url_open = "{{ route('Admin.Shop.InvoicePayments.create') }}";
|
||||
var url_save = "{{ route('Admin.Shop.InvoicePayments.store') }}";
|
||||
openModal("Ajouter un paiement", '#invoice_payment-form', url_open, url_save,
|
||||
"InvoicePaymentRefresh();");
|
||||
}
|
||||
|
||||
function InvoicePaymentEdit(id) {
|
||||
var url_open = "{{ route('Admin.Shop.InvoicePayments.edit') }}/" + id;
|
||||
var url_save = "{{ route('Admin.Shop.InvoicePayments.store') }}";
|
||||
openModal("Editer un paiement", '#invoice_payment-form', url_open, url_save,
|
||||
"InvoicePaymentRefresh();");
|
||||
}
|
||||
|
||||
function InvoicePaymentRefresh() {
|
||||
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@@ -6,6 +6,6 @@ Route::prefix('InvoicePayments')->name('InvoicePayments.')->group(function () {
|
||||
Route::delete('destroy', 'InvoicePaymentController@destroy')->name('destroy');
|
||||
Route::post('update', 'InvoicePaymentController@update')->name('update');
|
||||
Route::post('store', 'InvoicePaymentController@store')->name('store');
|
||||
Route::get('edit/{id}', 'InvoicePaymentController@edit')->name('edit');
|
||||
Route::get('edit/{id?}', 'InvoicePaymentController@edit')->name('edit');
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user