add datatbles for invoices, add pdf icon, refactor icons components, add autocomplete on search, adapt searching to meilisearch
This commit is contained in:
@@ -50,19 +50,31 @@ class ParentDataTable extends DataTable
|
||||
return self::getButtonEdit().self::getButtonDel();
|
||||
}
|
||||
|
||||
public function getButtonEdit()
|
||||
public function getButtonEdit($field = 'id', $title = 'Modifier')
|
||||
{
|
||||
return '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-primary btn-edit mr-2"><i class="fa fa-fw fa-pencil-alt"></i></button>';
|
||||
return view('components.form.buttons.edit', [
|
||||
'dataId' => '{{$'.$field.'}}',
|
||||
'class' => 'btn-sm mr-2',
|
||||
'title' => $title,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getButtonShow()
|
||||
public function getButtonShow($field = 'id', $title = 'Voir')
|
||||
{
|
||||
return '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-secondary btn-show mr-2"><i class="fa fa-fw fa-eye"></i></button>';
|
||||
return view('components.form.buttons.show', [
|
||||
'dataId' => '{{$'.$field.'}}',
|
||||
'class' => 'btn-sm mr-2',
|
||||
'title' => $title,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getButtonDel()
|
||||
public function getButtonDel($field ='id', $title = 'Effacer')
|
||||
{
|
||||
return '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-danger btn-del"><i class="fa fa-fw fa-trash"></i></button>';
|
||||
return view('components.form.buttons.delete', [
|
||||
'dataId' => '{{$'.$field.'}}',
|
||||
'class' => 'btn-sm mr-2',
|
||||
'title' => $title,
|
||||
]);
|
||||
}
|
||||
|
||||
public function makeColumnButtons()
|
||||
|
||||
80
app/Datatables/Shop/CustomerInvoicesDataTable.php
Normal file
80
app/Datatables/Shop/CustomerInvoicesDataTable.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Invoice;
|
||||
use App\Repositories\Shop\InvoicePayments;
|
||||
use App\Repositories\Shop\Invoices;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class CustomerInvoicesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'invoices';
|
||||
|
||||
public $sortedColumn = 1;
|
||||
|
||||
public $sortedOrder = 'desc';
|
||||
|
||||
public $stateSave = true;
|
||||
|
||||
public $url = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = route('Shop.Invoices.index');
|
||||
}
|
||||
|
||||
public function query(Invoice $model)
|
||||
{
|
||||
$customerId = Auth::id();
|
||||
$model = $model->byCustomer($customerId)->with(['address']);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function getHtmlButtons()
|
||||
{
|
||||
$buttons = view('components.form.button', [
|
||||
'dataId' => '{{$uuid}}',
|
||||
'class' => 'btn-sm btn-secondary btn-invoice mr-2',
|
||||
'icon' => 'fa-file-pdf',
|
||||
'title' => 'Télécharger la facture',
|
||||
'url' => route('Shop.Invoices.pdf') . '/{{$uuid}}',
|
||||
]);
|
||||
|
||||
$buttons .= self::getButtonShow('uuid', 'Voir la facture');
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('status', function (Invoice $invoice) {
|
||||
return Invoices::getStatus($invoice->status);
|
||||
})
|
||||
->editColumn('created_at', function (Invoice $invoice) {
|
||||
return $invoice->created_at->isoFormat('DD/MM/YY HH:mm');
|
||||
})
|
||||
->editColumn('payment_type', function (Invoice $invoice) {
|
||||
return InvoicePayments::getPaymentType($invoice->payment_type);
|
||||
})
|
||||
->rawColumns(['action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('created_at')->title('Date'),
|
||||
Column::make('ref')->title('Ref'),
|
||||
Column::make('payment_type')->title('Règlement'),
|
||||
Column::make('total_shipped')->title('Montant')->class('text-right'),
|
||||
Column::make('status')->title('Statut'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ namespace App\Datatables\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Order;
|
||||
use App\Repositories\Shop\InvoicePayments;
|
||||
use App\Repositories\Shop\Orders;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class CustomerOrdersDataTable extends DataTable
|
||||
@@ -18,6 +18,8 @@ class CustomerOrdersDataTable extends DataTable
|
||||
|
||||
public $stateSave = true;
|
||||
|
||||
public $url = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = route('Shop.Orders.index');
|
||||
@@ -26,11 +28,16 @@ class CustomerOrdersDataTable extends DataTable
|
||||
public function query(Order $model)
|
||||
{
|
||||
$customerId = Auth::id();
|
||||
$model = $model->byCustomer($customerId)->with(['delivery']);
|
||||
$model = $model->byCustomer($customerId);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function getHtmlButtons()
|
||||
{
|
||||
return self::getButtonShow('uuid', 'Voir la commande');
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
@@ -38,10 +45,7 @@ class CustomerOrdersDataTable extends DataTable
|
||||
return Orders::getStatus($order->status);
|
||||
})
|
||||
->editColumn('created_at', function (Order $order) {
|
||||
return $order->created_at->toDateTimeString();
|
||||
})
|
||||
->editColumn('payment_type', function (Order $order) {
|
||||
return InvoicePayments::getPaymentType($order->payment_type);
|
||||
return $order->created_at->isoFormat('DD/MM/YY HH:mm');
|
||||
})
|
||||
->rawColumns(['action']);
|
||||
|
||||
@@ -53,7 +57,6 @@ class CustomerOrdersDataTable extends DataTable
|
||||
return [
|
||||
Column::make('created_at')->title('Date'),
|
||||
Column::make('ref')->title('Ref'),
|
||||
Column::make('payment_type')->title('Règlement'),
|
||||
Column::make('total_shipped')->title('Montant')->class('text-right'),
|
||||
Column::make('status')->title('Statut'),
|
||||
$this->makeColumnButtons(),
|
||||
|
||||
Reference in New Issue
Block a user