2021-09-07 18:00:22 +02:00
|
|
|
@extends('portal.ninja2020.layout.app')
|
|
|
|
|
|
|
|
@section('meta_title', ctrans('texts.statement'))
|
|
|
|
|
2021-09-20 17:33:33 +02:00
|
|
|
@push('head')
|
|
|
|
<meta name="pdf-url" content="{{ route('client.statement.raw') }}">
|
|
|
|
@endpush
|
|
|
|
|
2021-09-07 18:00:22 +02:00
|
|
|
@section('body')
|
2021-09-20 17:33:33 +02:00
|
|
|
<div class="flex flex-col md:flex-row md:justify-between">
|
|
|
|
<div class="flex flex-col md:flex-row md:items-center">
|
|
|
|
<div class="flex">
|
|
|
|
<label for="from" class="block w-full flex items-center mr-4">
|
|
|
|
<span class="mr-2">{{ ctrans('texts.from') }}:</span>
|
2021-09-21 14:05:47 +02:00
|
|
|
<input id="date-from" type="date" class="input w-full" data-field="startDate" value="{{ now()->startOfYear()->format('Y-m-d') }}">
|
2021-09-20 17:33:33 +02:00
|
|
|
</label>
|
|
|
|
|
|
|
|
<label for="to" class="block w-full flex items-center mr-4">
|
|
|
|
<span class="mr-2">{{ ctrans('texts.to') }}:</span>
|
2021-09-21 14:05:47 +02:00
|
|
|
<input id="date-to" type="date" class="input w-full" data-field="endDate" value="{{ now()->format('Y-m-d') }}">
|
2021-09-20 17:33:33 +02:00
|
|
|
</label>
|
|
|
|
</div> <!-- End date range -->
|
|
|
|
|
|
|
|
<label for="show_payments" class="block flex items-center mr-4 mt-4 md:mt-0">
|
2021-09-21 14:05:47 +02:00
|
|
|
<input id="show-payments-table" type="checkbox" data-field="showPaymentsTable" class="form-checkbox" autocomplete="off">
|
2021-09-20 17:33:33 +02:00
|
|
|
<span class="ml-2">{{ ctrans('texts.show_payments') }}</span>
|
|
|
|
</label> <!-- End show payments checkbox -->
|
|
|
|
|
|
|
|
<label for="show_aging" class="block flex items-center">
|
2021-09-21 14:05:47 +02:00
|
|
|
<input id="show-aging-table" type="checkbox" data-field="showAgingTable" class="form-checkbox" autocomplete="off">
|
2021-09-20 17:33:33 +02:00
|
|
|
<span class="ml-2">{{ ctrans('texts.show_aging') }}</span>
|
|
|
|
</label> <!-- End show aging checkbox -->
|
|
|
|
</div>
|
|
|
|
<button class="button button-primary bg-primary mt-4 md:mt-0">{{ ctrans('texts.download') }}</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
@include('portal.ninja2020.components.pdf-viewer', ['url' => route('client.statement.raw')])
|
2021-09-07 18:00:22 +02:00
|
|
|
@endsection
|
2021-09-20 17:33:33 +02:00
|
|
|
|
|
|
|
@push('footer')
|
|
|
|
<script>
|
2021-09-21 14:05:47 +02:00
|
|
|
class Statement {
|
|
|
|
constructor() {
|
|
|
|
this.url = new URL(document.querySelector('meta[name=pdf-url]').content);
|
|
|
|
this.startDate = '';
|
|
|
|
this.endDate = '';
|
|
|
|
this.showPaymentsTable = false;
|
|
|
|
this.showAgingTable = false;
|
|
|
|
}
|
2021-09-20 17:33:33 +02:00
|
|
|
|
2021-09-21 14:05:47 +02:00
|
|
|
bindEventListeners() {
|
|
|
|
['#date-from', '#date-to', '#show-payments-table', '#show-aging-table'].forEach(selector => {
|
|
|
|
document
|
|
|
|
.querySelector(selector)
|
|
|
|
.addEventListener('change', (event) => this.handleValueChange(event));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
handleValueChange(event) {
|
|
|
|
if (event.target.type === 'checkbox') {
|
|
|
|
console.log(1);
|
|
|
|
this[event.target.dataset.field] = event.target.checked;
|
|
|
|
} else {
|
|
|
|
this[event.target.dataset.field] = event.target.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updatePdf();
|
|
|
|
}
|
|
|
|
|
|
|
|
get composedUrl() {
|
|
|
|
this.url.search = '';
|
|
|
|
|
|
|
|
if (this.startDate.length > 0) {
|
|
|
|
this.url.searchParams.append('start_date', this.startDate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.endDate.length > 0) {
|
|
|
|
this.url.searchParams.append('end_date', this.endDate);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.url.searchParams.append('show_payments_table', +this.showPaymentsTable);
|
|
|
|
this.url.searchParams.append('show_aging_table', +this.showAgingTable);
|
|
|
|
|
|
|
|
return this.url.href;
|
|
|
|
}
|
|
|
|
|
|
|
|
updatePdf() {
|
|
|
|
document
|
|
|
|
.querySelector('meta[name=pdf-url]')
|
|
|
|
.content = this.composedUrl;
|
|
|
|
|
|
|
|
let iframe = document.querySelector('#pdf-iframe');
|
|
|
|
|
|
|
|
if (iframe) {
|
|
|
|
iframe.src = this.composedUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.querySelector('meta[name=pdf-url]').dispatchEvent(new Event('change'));
|
|
|
|
}
|
|
|
|
|
|
|
|
handle() {
|
|
|
|
this.bindEventListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new Statement().handle();
|
2021-09-20 17:33:33 +02:00
|
|
|
</script>
|
|
|
|
@endpush
|