add datatables on orders

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

View File

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

View File

@@ -12,9 +12,20 @@ use App\Repositories\Shop\Orders;
use App\Repositories\Shop\Paybox;
use App\Repositories\Shop\Baskets;
use App\Repositories\Shop\SaleChannels;
use App\Datatables\Shop\OrdersDataTable;
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()
{
$customer = Customers::getWithAddresses();

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@
@if ($customer['company'])
<i class="fa fa-building pr-2"></i>
{{ $customer['company'] }}
{{ $customer['company'] }}<br>
@endif
<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('confirmed', 'OrderController@confirmed')->name('confirmed');
Route::post('order', 'OrderController@store')->name('store');
Route::any('', 'OrderController@index')->name('index');
Route::get('view/{uuid?}', 'OrderController@view')->name('view');
});