add datatables on orders

This commit is contained in:
Ludovic CANDELLIER
2023-02-28 08:42:53 +01:00
parent bb77a199eb
commit 3943fc033f
10 changed files with 62 additions and 4 deletions

View File

@@ -573,8 +573,8 @@ module.exports = function(grunt) {
watch: { watch: {
dist: { dist: {
files: ['build/js/*', 'build/css/*'], files: ['build/js/*', 'build/css/*'],
tasks: ['concat', 'copy'] // tasks: ['concat', 'copy']
// tasks: ['concat'] tasks: ['concat']
} }
}, },
}); });

View File

@@ -12,9 +12,20 @@ use App\Repositories\Shop\Orders;
use App\Repositories\Shop\Paybox; use App\Repositories\Shop\Paybox;
use App\Repositories\Shop\Baskets; use App\Repositories\Shop\Baskets;
use App\Repositories\Shop\SaleChannels; use App\Repositories\Shop\SaleChannels;
use App\Datatables\Shop\OrdersDataTable;
class OrderController extends Controller class OrderController extends Controller
{ {
public function index(OrdersDataTable $dataTable)
{
return $dataTable->render('Shop.Orders.partials.list', $data ?? []);
}
public function view($uuid)
{
$data = Orders::getByUUID($uuid);
}
public function order() public function order()
{ {
$customer = Customers::getWithAddresses(); $customer = Customers::getWithAddresses();

View File

@@ -2,6 +2,7 @@
namespace App\Repositories\Shop; namespace App\Repositories\Shop;
use App\Datatables\Shop\OrdersDataTable;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@@ -20,9 +21,11 @@ class Customers
public static function editProfile($id = false) public static function editProfile($id = false)
{ {
$id = $id ? $id : self::getId(); $id = $id ? $id : self::getId();
$orders_datatable = new OrdersDataTable;
$data = [ $data = [
'customer' => self::get($id, ['addresses', 'deliveries', 'orders'])->toArray(), 'customer' => self::get($id, ['addresses', 'deliveries', 'orders'])->toArray(),
'deliveries' => Deliveries::getAll('sale_channel')->toArray(), 'deliveries' => Deliveries::getAll('sale_channel')->toArray(),
'orders' => $orders_datatable->html(),
]; ];
return $data; return $data;
} }

View File

@@ -8,6 +8,11 @@ use App\Models\Shop\Invoice;
class Invoices class Invoices
{ {
public static function getByUUID($uuid)
{
return Order::byUUID($uuid)->first();
}
public static function saveInvoice($order_id, $data) public static function saveInvoice($order_id, $data)
{ {
$data['order_id'] = $order_id; $data['order_id'] = $order_id;

View File

@@ -10,9 +10,13 @@ use Illuminate\Support\Str;
class Orders class Orders
{ {
use DateStats; use DateStats;
public static function getByUUID($uuid)
{
return Order::byUUID($uuid)->first();
}
public static function saveOrder($data) public static function saveOrder($data)
{ {
$data += $data['basket']; $data += $data['basket'];

View File

@@ -1,3 +1,5 @@
@include('Shop.Orders.partials.list', ['dataTable' => $orders])
@if ($customer['orders'] ?? false) @if ($customer['orders'] ?? false)
<table class="table table-striped gradient-green1 green-fluo"> <table class="table table-striped gradient-green1 green-fluo">
@foreach ($customer['orders'] as $order) @foreach ($customer['orders'] as $order)

View File

@@ -2,7 +2,7 @@
@if ($customer['company']) @if ($customer['company'])
<i class="fa fa-building pr-2"></i> <i class="fa fa-building pr-2"></i>
{{ $customer['company'] }} {{ $customer['company'] }}<br>
@endif @endif
<i class="fa fa-fw fa-user pr-2"></i> <i class="fa fa-fw fa-user pr-2"></i>

View File

@@ -0,0 +1,2 @@
<form id="{{ $model }}-filters">
</form>

View File

@@ -0,0 +1,29 @@
@include('components.datatable', [
'route' => route('Shop.Orders.index'),
'model' => 'orders',
'with_add' => false,
'with_filters' => true,
'with_exports' => false,
'with_print' => false,
'show_callback' => 'OrderView(id);',
])
@component('components.layout.modal-filters', ['title' => 'Filters', 'id' => 'modal-aml_risks-filters'])
@include('Shop.Orders.partials.filters', ['model' => 'aml_risks'])
@endcomponent
@push('js')
<script>
function OrderView(id) {
var url_open = "{{ route('Shop.Orders.view') }}/" + id;
openModal("Voir une commande", '#model-form', url_open, false, false, 'xl', {{ !($with_add ?? false) }});
}
function OrderRefresh()
{
reloadDatatable("orders");
}
</script>
@endpush

View File

@@ -4,5 +4,7 @@ Route::prefix('Orders')->name('Orders.')->group(function () {
Route::get('order', 'OrderController@order')->name('order'); Route::get('order', 'OrderController@order')->name('order');
Route::get('confirmed', 'OrderController@confirmed')->name('confirmed'); Route::get('confirmed', 'OrderController@confirmed')->name('confirmed');
Route::post('order', 'OrderController@store')->name('store'); Route::post('order', 'OrderController@store')->name('store');
Route::any('', 'OrderController@index')->name('index');
Route::get('view/{uuid?}', 'OrderController@view')->name('view');
}); });