fixes
This commit is contained in:
@@ -36,7 +36,11 @@ class CustomerOrdersDataTable extends DataTable
|
||||
|
||||
public function getHtmlButtons()
|
||||
{
|
||||
return self::getButtonShow('uuid', 'Voir la commande');
|
||||
$buttons = '';
|
||||
|
||||
$buttons .= self::getButtonShow('uuid', 'Voir la facture');
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
|
||||
@@ -24,6 +24,26 @@ class CustomerAddresses
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getInvoiceAddress($customerId)
|
||||
{
|
||||
$addresses = CustomerAddress::byCustomer($customerId)->byInvoicing()->get();
|
||||
if (count($addresses)) {
|
||||
$address = $addresses->first();
|
||||
}
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
public static function getDeliveryAddress($customerId)
|
||||
{
|
||||
$addresses = CustomerAddress::byCustomer($customerId)->byDelivery()->get();
|
||||
if (count($addresses)) {
|
||||
$address = $addresses->first();
|
||||
}
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
public static function storeByCustomer($customer, $data)
|
||||
{
|
||||
$deliveries = $data['deliveries'] ?? false;
|
||||
|
||||
@@ -55,15 +55,12 @@ class Customers
|
||||
|
||||
public static function editProfile($id = false)
|
||||
{
|
||||
$datatableOrders = new CustomerOrdersDataTable();
|
||||
$datatableInvoices = new CustomerInvoicesDataTable();
|
||||
|
||||
return [
|
||||
return $id ? [
|
||||
'customer' => self::get($id, ['addresses', 'deliveries'])->toArray(),
|
||||
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
||||
'orders' => $datatableOrders->html(),
|
||||
'invoices' => $datatableInvoices->html(),
|
||||
];
|
||||
'orders' => (new CustomerOrdersDataTable())->html(),
|
||||
'invoices' => (new CustomerInvoicesDataTable())->html(),
|
||||
] : abort('403');
|
||||
}
|
||||
|
||||
public static function getAvatar($id = false)
|
||||
@@ -151,6 +148,9 @@ class Customers
|
||||
|
||||
public static function edit($id)
|
||||
{
|
||||
if (!$id) {
|
||||
abort('403');
|
||||
}
|
||||
$customer = self::get($id, ['delivery_addresses', 'invoice_addresses', 'sale_channels']);
|
||||
$data = $customer->toArray();
|
||||
$data['sale_channels'] = $customer->sale_channels->pluck('id')->toArray();
|
||||
|
||||
@@ -6,11 +6,20 @@
|
||||
'id_name' => 'delivery_id_' . $delivery['id'],
|
||||
'value' => $delivery['id'],
|
||||
'checked' => $customer['sale_delivery_id'] ?? false,
|
||||
'class' => 'delivery',
|
||||
])
|
||||
</div>
|
||||
<div class="col-11 pt-3">
|
||||
<strong>{{ $delivery['name'] }} - {{ $delivery['sale_channel']['name'] }}</strong><br/>
|
||||
<strong>{{ $delivery['name'] }} - {{ $delivery['sale_channel']['name'] }}</strong><br />
|
||||
<p>{{ $delivery['description'] }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
$('.delivery').off().change(function() {
|
||||
console.log($(this).val());
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -1,34 +1,33 @@
|
||||
@if(!defined('LOAD_TOGGLE'))
|
||||
@push('scripts')
|
||||
<script src="{{ asset('/assets/plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js') }}"></script>
|
||||
@if (!defined('LOAD_TOGGLE'))
|
||||
@push('scripts')
|
||||
<script src="{{ asset('/assets/plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
function initToggle(url, sel, data, callback) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.toggle' : sel;
|
||||
if (typeof(data) == 'undefined') {
|
||||
var data = {};
|
||||
}
|
||||
$(selector).bootstrapToggle();
|
||||
|
||||
$('input' + selector).change(function() {
|
||||
data['id'] = $(this).data('id');
|
||||
var name = (typeof($(this).data('name')) == 'undefined') ? 'active' : $(this).data('name');
|
||||
data[name] = $(this).is(':checked');
|
||||
if (data['id'] && (typeof(url) != 'undefined') && (url != '')) {
|
||||
var dataJson = Object.assign({}, data);
|
||||
$.post(url, dataJson);
|
||||
}
|
||||
if (typeof(callback) != 'undefined') {
|
||||
eval(callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function initToggle(url, sel, data, callback) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.toggle' : sel;
|
||||
if (typeof(data) == 'undefined') {
|
||||
var data = {};
|
||||
}
|
||||
$(selector).bootstrapToggle();
|
||||
|
||||
@endpush
|
||||
$('input' + selector).change(function() {
|
||||
data['id'] = $(this).data('id');
|
||||
var name = (typeof($(this).data('name')) == 'undefined') ? 'active' : $(this).data('name');
|
||||
data[name] = $(this).is(':checked');
|
||||
if (data['id'] && (typeof(url) != 'undefined') && (url != '')) {
|
||||
var dataJson = Object.assign({}, data);
|
||||
$.post(url, dataJson);
|
||||
}
|
||||
if (typeof(callback) != 'undefined') {
|
||||
eval(callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="{{ asset('/assets/plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css') }}">
|
||||
@endpush
|
||||
@php(define('LOAD_TOGGLE', true))
|
||||
@endif
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="{{ asset('/assets/plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css') }}">
|
||||
@endpush
|
||||
@php(define('LOAD_TOGGLE', true))
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user