add payments by invoice

This commit is contained in:
ludo
2023-11-25 16:21:35 +01:00
parent 0ec0b8e85b
commit b812a78f9f
20 changed files with 579 additions and 215 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Datatables\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
{
public $model_name = 'InvoicePayments';
public function query(InvoicePayment $model)
{
return $this->buildQuery($model);
}
public function modifier($datatables)
{
$datatables
->editColumn('payment_type', function (InvoicePayment $payment) {
return InvoicePayments::getPaymentType($payment->payment_type);
})
->editColumn('date', function (InvoicePayment $payment) {
return $payment->date;
})
->rawColumns(['action']);
return parent::modifier($datatables);
}
protected function getColumns()
{
return [
Column::make('payment_type')->title('Type')->width(80),
Column::make('status')->width(60),
Column::make('amount')->title('Montant')->width(100),
Column::make('reference')->title('Référence'),
$this->makeColumnButtons(),
];
}
}

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin\Shop;
use App\Datatables\Admin\Shop\InvoicesDataTable;
use App\Datatables\Admin\Shop\InvoicePaymentsDataTable;
use App\Http\Controllers\Controller;
use App\Repositories\Shop\Invoices;
use Illuminate\Http\Request;
@@ -28,15 +29,20 @@ class InvoiceController extends Controller
public function show($id)
{
$data['invoice'] = Invoices::get($id)->toArray();
$data['invoice'] = Invoices::getFull($id)->toArray();
return view('Admin.Shop.Invoices.view', $data);
}
public function edit($id)
{
$data['invoice'] = Invoices::get($id, ['order.customer', 'order.address', 'order.detail'])->toArray();
$data['statuses'] = Invoices::statuses();
$data = Invoices::init();
$data['invoice'] = Invoices::getFull($id)->toArray();
$model = new invoicePaymentsDataTable();
$data['invoice_payments'] = $model->html();
// dump($data);
// exit;
return view('Admin.Shop.Invoices.edit', $data);
}

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\Admin\Shop;
use App\Datatables\Admin\Shop\InvoicePaymentsDataTable;
use App\Http\Controllers\Controller;
use App\Repositories\Shop\InvoicePayments;
use Illuminate\Http\Request;
class InvoicePaymentController extends Controller
{
public function index(InvoicePaymentsDataTable $dataTable)
{
return $dataTable->render('Admin.Shop.InvoicePayments.list');
}
public function create()
{
return view('Admin.Shop.InvoicePayments.create');
}
public function store(Request $request)
{
$ret = InvoicePayments::store($request->all());
return redirect()->route('Admin.Shop.InvoicePayments.index');
}
public function show($id)
{
$data['invoice_payment'] = InvoicePayments::getFull($id)->toArray();
return view('Admin.Shop.InvoicePayments.view', $data);
}
public function edit($id)
{
$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);
}
public function destroy($id)
{
return InvoicePayments::delete($id);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Admin\Shop;
use Illuminate\Foundation\Http\FormRequest;
class StoreMerchandisePost extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'name' => 'required',
'producer_id' => 'required',
];
}
}

View File

@@ -37,10 +37,10 @@ class InvoicePayments
public static function getPaymentType($id)
{
return self::PaymentTypes()[$id] ?? false;
return self::paymentTypes()[$id] ?? false;
}
public static function PaymentTypes()
public static function paymentTypes()
{
return [
'',

View File

@@ -13,7 +13,7 @@ class Invoices
public static function getInvoiceHtml($id)
{
$invoice = self::get($id, ['order.customer', 'order.delivery_address', 'order.detail']);
$invoice = self::getFull($id);
$order = $invoice->order;
$customer = $order->customer;
unset($invoice->order, $order->customer);
@@ -26,6 +26,19 @@ class Invoices
return view('Shop.Invoices.mail', $data)->render();
}
public static function init()
{
return [
'statuses' => Invoices::statuses(),
'payment_types' => InvoicePayments::paymentTypes(),
];
}
public static function getFull($id)
{
return self::get($id, ['address', 'order.customer', 'order.delivery_address', 'order.detail']);
}
public static function getByUUID($uuid)
{
return Invoice::byUUID($uuid)->first();

View File

@@ -0,0 +1,16 @@
@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

View File

@@ -0,0 +1,95 @@
@extends('layout.index', [
'title' => 'Factures',
'subtitle' => 'Edition d\'une facture',
'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 {{ $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>
</x-card>
</form>
</div>
<div class="col-4">
<x-card>
<h4>Règlements</h4>
</x-card>
</div>
</div>
@endsection

View File

@@ -0,0 +1,26 @@
<div class="row">
<div class="col-6">
@include('components.form.select', [
'label' => 'Règlement',
'name' => 'payment_type',
'list' => $payment_types ?? [],
'value' => $invoice_payment['payment_type'],
'class' => 'select2',
])
</div>
<div class="col-6">
@include('components.form.input', [
'label' => 'Montant',
'name' => 'amount',
'value' => $invoice_payment['amount'],
])
</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>

View File

@@ -0,0 +1,14 @@
@extends('layout.index', [
'title' => __('shop.invoice_payments.title'),
'subtitle' => __('shop.invoice_payments.list'),
'breadcrumb' => [__('shop.invoice_payments.title')],
])
@section('content')
<x-card>
@include('components.datatable', [
'route' => route('Admin.Shop.InvoicePayments.index'),
'model' => 'invoice_payments',
])
</x-card>
@endsection

View File

@@ -0,0 +1,4 @@
@include('components.datatable', [
'route' => route('Admin.Shop.InvoicePayments.index'),
'model' => 'invoice_payments',
])

View File

@@ -0,0 +1,36 @@
@extends('layout.index', [
'title' => __('products.title'),
'subtitle' => __('products.title'),
'breadcrumb' => [__('products.title')]
])
@section('content')
<form action="{{ route('Shop.Products') }}" method="GET">
<div class="row">
<div class="col-md-offset-2 col-md-8">
<div class="box box-info">
<div class="box-body">
<div class="col-md-6">
<h3>{{ name }}</h3>
<h4>
{{ $product.section.name }}<br>
</h4>
</div>
<div class="col-md-6 text-right">
<h2>{{ $prix_total }} </h2>
<h4>{{ $residence['type_produit']['name'] }}</h4>
</div>
<div class="col-md-12">
@include('Hestimmo.modules.Lot.partials.carousel')
</div>
</div>
</div>
</div>
</div>
</form>
@endsection

View File

@@ -1,13 +1,14 @@
@extends('layout.index', [
'title' => 'Factures',
'subtitle' => 'Edition d\'une facture',
'breadcrumb' => ['Articles']
'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>
@@ -22,16 +23,20 @@
<div class="row mb-3">
<div class="col-6">
<h3>{{ $invoice['order']['customer']['last_name'] }} {{ $invoice['order']['customer']['first_name'] }}</h3>
<h3>
{{ $invoice['order']['customer']['last_name'] }}
{{ $invoice['order']['customer']['first_name'] }}
</h3>
<div class="row">
<div class="col-12">
<h6>
@if ($invoice['order']['address'])
{{ $invoice['order']['address']['address'] }}<br/>
@isset ($invoice['order']['address']['address2'])
{{ $invoice['order']['address']['address2'] }}<br/>
@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']['address']['zipcode'] }} {{ $invoice['order']['address']['city'] }}<br/>
{{ $invoice['order']['delivery_address']['zipcode'] }}
{{ $invoice['order']['delivery_address']['city'] }}<br />
@endif
</h6>
</div>
@@ -40,7 +45,7 @@
<div class="col-6">
<div class="row mb-3">
<div class="col-6" style="font-size: 1.2em; font-weight: 500;">
Facture {{ $invoice['ref'] }}<br/>
Facture {{ $invoice['ref'] }}<br />
du {{ Carbon\Carbon::parse($invoice['created_at'])->isoFormat('LLLL') }}
</div>
<div class="col-6">
@@ -72,10 +77,22 @@
</div>
<div class="row mb-3">
<div class="col-12">
@include('Admin.Shop.Orders.partials.detail', ['detail_type' => 'facture', 'order' => $invoice['order']])
@include('Admin.Shop.Orders.partials.detail', [
'detail_type' => 'facture',
'order' => $invoice['order'],
])
</div>
</div>
</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

View File

@@ -1,13 +1,19 @@
@include('boilerplate::load.tinymce')
<div class="row">
<div class="col-md-8">
{{ Form::label('name', 'Nom') }}
@include('components.form.input', ['name' => 'name', 'value' => (isset($family['name'])) ? $family['name'] : null, 'required' => true])
@include('components.form.input', [
'name' => 'name',
'value' => $family['name'] ?? null,
'required' => true,
'label' => 'Nom',
])
{{ Form::label('description', 'Description') }}
@include('components.form.textarea', ['name' => 'description', 'value' => isset($description) ? $description : null, 'class' => 'editor', 'required' => false])
@include('components.form.textarea', [
'name' => 'description',
'value' => isset($description) ? $description : null,
'class' => 'editor',
'required' => false,
'label' => 'Description',
])
</div>
</div>
@@ -20,10 +26,4 @@
</div>
</div>
@push('js')
<script>
$(function() {
$('.editor').tinymce({});
});
</script>
@endpush
@include('boilerplate::load.tinymce')

View File

@@ -1,11 +1,14 @@
@extends('layout.index', [
'title' => __('shop.invoices.title'),
'subtitle' => __('shop.invoices.list'),
'breadcrumb' => [__('shop.invoices.title')]
'title' => __('shop.invoice_payments.title'),
'subtitle' => __('shop.invoice_payments.list'),
'breadcrumb' => [__('shop.invoice_payments.title')],
])
@section('content')
@component('components.card')
@include('components.datatable', ['route' => route('Admin.Shop.Invoices.index'), 'model' => 'invoices'])
@endcomponent
<x-card>
@include('components.datatable', [
'route' => route('Admin.Shop.InvoicePayments.index'),
'model' => 'invoice_payments',
])
</x-card>
@endsection

View File

@@ -1,19 +1,22 @@
@if(!defined('LOAD_TINYMCE'))
@if (!defined('LOAD_TINYMCE'))
@push('js')
<script src="/assets/plugins/tinymce/jquery.tinymce.min.js"></script>
<script src="/assets/plugins/tinymce/tinymce.min.js"></script>
@component('boilerplate::minify')
<script>
tinymce.defaultSettings = {
path_absolute : "/",
plugins: "autolink autoresize fullscreen codemirror link lists table media preview image paste customalign stickytoolbar",
path_absolute: "/",
plugins: "autolink autoresize fullscreen codemirror link lists table media preview image paste customalign",
toolbar: "insertfile undo redo | styleselect | bold italic underline | customalignleft aligncenter customalignright | link media image | bullist numlist | table | code fullscreen",
contextmenu: "link image imagetools table spellchecker bold italic underline",
sticky_toolbar_container: '.tox-editor-header',
toolbar_drawer: "sliding",
sticky_offset: $('nav.main-header').outerHeight(),
codemirror: { config: { theme: 'storm' } },
codemirror: {
config: {
theme: 'storm'
}
},
menubar: false,
removed_menuitems: 'newdocument',
remove_linebreaks: false,
@@ -27,15 +30,21 @@
encoding: 'UTF-8',
image_uploadtab: false,
paste_preprocess: function(plugin, args) {
args.content = args.content.replace(/<(\/)*(\\?xml:|meta|link|span|font|del|ins|st1:|[ovwxp]:)((.|\s)*?)>/gi, ''); // Unwanted tags
args.content = args.content.replace(/\s(class|style|type|start)=("(.*?)"|(\w*))/gi, ''); // Unwanted attributes
args.content = args.content.replace(/<(p|a|div|span|strike|strong|i|u)[^>]*?>(\s|&nbsp;|<br\/>|\r|\n)*?<\/(p|a|div|span|strike|strong|i|u)>/gi, ''); // Empty tags
args.content = args.content.replace(
/<(\/)*(\\?xml:|meta|link|span|font|del|ins|st1:|[ovwxp]:)((.|\s)*?)>/gi, ''); // Unwanted tags
args.content = args.content.replace(/\s(class|style|type|start)=("(.*?)"|(\w*))/gi,
''); // Unwanted attributes
args.content = args.content.replace(
/<(p|a|div|span|strike|strong|i|u)[^>]*?>(\s|&nbsp;|<br\/>|\r|\n)*?<\/(p|a|div|span|strike|strong|i|u)>/gi,
''); // Empty tags
},
skin : "boilerplate",
skin: "boilerplate",
language: '{{ App::getLocale() }}',
file_picker_callback : function(callback, value, meta) {
var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight;
file_picker_callback: function(callback, value, meta) {
var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName(
'body')[0].clientWidth;
var y = window.innerHeight || document.documentElement.clientHeight || document
.getElementsByTagName('body')[0].clientHeight;
var cmsURL = tinymce.defaultSettings.path_absolute + 'filemanager?editor=' + meta.fieldname;
if (meta.filetype == 'image') {
@@ -45,12 +54,12 @@
}
tinyMCE.activeEditor.windowManager.openUrl({
url : cmsURL,
title : 'Filemanager',
width : x * 0.8,
height : y * 0.8,
resizable : "yes",
close_previous : "no",
url: cmsURL,
title: 'Filemanager',
width: x * 0.8,
height: y * 0.8,
resizable: "yes",
close_previous: "no",
onMessage: (api, message) => {
callback(message.content);
}
@@ -60,7 +69,8 @@
// Prevent Bootstrap dialog from blocking focusin
$(document).on('focusin', function(e) {
if ($(e.target).closest(".tox-tinymce, .tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length) {
if ($(e.target).closest(".tox-tinymce, .tox-tinymce-aux, .moxman-window, .tam-assetmanager-root")
.length) {
e.stopImmediatePropagation();
}
});
@@ -70,19 +80,18 @@
var options = (typeof(options) == 'undefined') ? {} : options;
var setup = {
setup: function(ed) {
if ($('#'+ed.id).prop('readonly')) {
if ($('#' + ed.id).prop('readonly')) {
ed.settings.readonly = true;
}
}
};
options = Object.assign(options, setup);
for (var i = tinymce.editors.length - 1 ; i > -1 ; i--) {
for (var i = tinymce.editors.length - 1; i > -1; i--) {
tinyMCE.execCommand("mceRemoveEditor", true, tinymce.editors[i].id);
}
$(selector).tinymce(options);
}
</script>
@endcomponent
@endpush

View File

@@ -1,11 +1,10 @@
@if(!defined('LOAD_SELECT2'))
@if (!defined('LOAD_SELECT2'))
@push('scripts')
<script src="/assets/plugins/select2/js/select2.full.min.js"></script>
<script src="/assets/plugins/select2/js/i18n/{{ App::getLocale() }}.js"></script>
<script>
function initSelect2(sel, parent) {
console.log('initSelect2');
// $.fn.modal.Constructor.prototype.enforceFocus = function() {};
var selector = (typeof(sel) == 'undefined') ? '.select2' : sel;
@@ -28,7 +27,7 @@
}
});
}
/*
/*
$(selector).on('select2:open',(e) => {
let t = $(e.target);
console.log(t);
@@ -40,7 +39,7 @@
return item ? item.focus() : false;
}
});
*/
*/
}
</script>
@endpush

View File

@@ -1,12 +1,11 @@
@if(!defined('LOAD_FILEINPUT'))
@if (!defined('LOAD_FILEINPUT'))
@push('css')
<link rel="stylesheet" href="/assets/plugins/bootstrap-fileinput/css/fileinput.min.css">
@endpush
@push('scripts')
<script src="/assets/plugins/bootstrap-fileinput/js/fileinput.min.js"></script>
@if(App::getLocale() !== 'en')
@if (App::getLocale() !== 'en')
<script src="/assets/plugins/bootstrap-fileinput/js/locales/{{ App::getLocale() }}.js"></script>
<script src="/assets/plugins/bootstrap-fileinput/themes/fas/theme.min.js"></script>
<script>
$.fn.fileinput.defaults.language = '{{ App::getLocale() }}';
</script>
@@ -19,7 +18,7 @@
$(selector).fileinput(options)
.on("filebatchselected", function(event, files) {
$(selector).fileinput("upload");
}).on('fileuploaded', function (event, data, previewId, index, fileId) {
}).on('fileuploaded', function(event, data, previewId, index, fileId) {
// console.log('File uploaded', previewId, index, fileId);
var file = data.files[0];
// console.log(file);
@@ -47,11 +46,14 @@
function UploadOptions(options) {
return {
allowedFileExtensions: (typeof(options.allowedFileExtensions) == 'undefined') ? ['doc','docx','jpg','jpeg','png','xls','xlsx','pdf'] : options.allowedFileExtensions,
allowedFileExtensions: (typeof(options.allowedFileExtensions) == 'undefined') ? ['doc', 'docx', 'jpg',
'jpeg', 'png', 'xls', 'xlsx', 'pdf'
] : options.allowedFileExtensions,
browseOnZoneClick: (typeof(options.browseOnZoneClick) == 'undefined') ? true : options.browseOnZoneClick,
dropZoneEnabled: (typeof(options.dropZoneEnabled) == 'undefined') ? false : options.dropZoneEnabled,
initialPreview: (typeof(options.initialPreview) == 'undefined') ? false : options.initialPreview,
initialPreviewAsData: (typeof(options.initialPreviewAsData) == 'undefined') ? false : options.initialPreviewAsData,
initialPreviewAsData: (typeof(options.initialPreviewAsData) == 'undefined') ? false : options
.initialPreviewAsData,
maxFilesize: (typeof(options.maxFilesize) == 'undefined') ? false : options.maxFilesize,
overwriteInitial: (typeof(options.overwriteInitial) == 'undefined') ? false : options.overwriteInitial,
showCaption: (typeof(options.showCaption) == 'undefined') ? true : options.showCaption,
@@ -117,8 +119,7 @@
});
}
function initFileInputImage(images, sel)
{
function initFileInputImage(images, sel) {
UploadInit(sel, {
allowedFileExtensions: ['jpg', 'jpeg', 'png', 'gif'],
overwriteInitial: true,
@@ -131,8 +132,7 @@
});
}
function uploadShowImage(id, image)
{
function uploadShowImage(id, image) {
$('#' + id + '_preview').toggleClass('d-none');
$('#' + id + '_preview').find('img').attr('src', image);
$('#' + id + '_uploader').toggleClass('d-none');

View File

@@ -0,0 +1,11 @@
<?php
Route::prefix('InvoicePayments')->name('InvoicePayments.')->group(function () {
Route::get('', 'InvoicePaymentController@index')->name('index');
Route::get('create', 'InvoicePaymentController@create')->name('create');
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');
});

View File

@@ -13,6 +13,7 @@ Route::middleware('auth')->prefix('Shop')->namespace('Shop')->name('Shop.')->gro
include_once __DIR__.'/DeliveryTypeCalculations.php';
include_once __DIR__.'/Homepages.php';
include_once __DIR__.'/InvoiceItems.php';
include_once __DIR__.'/InvoicePayments.php';
include_once __DIR__.'/Invoices.php';
include_once __DIR__.'/Merchandises.php';
include_once __DIR__.'/Offers.php';