Build the stuff for payments.
This commit is contained in:
101
resources/views/payment/index.blade.php
Normal file
101
resources/views/payment/index.blade.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
|
||||
{{ __('invoice.Payments') }}
|
||||
</h2>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
|
||||
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
||||
<div class="max-w-xl">
|
||||
<section>
|
||||
<header>
|
||||
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
|
||||
{{ __('invoice.Add new payment') }}
|
||||
</h2>
|
||||
|
||||
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
|
||||
{{ __("invoice.Add new payment by clicking add") }}
|
||||
</p>
|
||||
</header>
|
||||
<a class="mt-6 inline-block" href="{{ route('payment.create') }}"><x-primary-button>{{ __('form.Add') }}</x-primary-button></a>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
||||
<div class="max-w" x-data="paymentForm">
|
||||
<section>
|
||||
<header>
|
||||
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
|
||||
{{ __('invoice.Existing payments') }}
|
||||
</h2>
|
||||
<div class="flex flex-row space-x-4 items-center">
|
||||
<x-input-label for="from" :value="__('invoice.From')"/>
|
||||
<x-text-input type="date" id="from" name="from" x-model="from" x-on:change="fetchPayments()"/>
|
||||
<x-input-label for="end" :value="__('invoice.End')"/>
|
||||
<x-text-input type="date" id="end" name="end" x-model="end" x-on:change="fetchPayments()"/>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<summary class="flex flex-row w-full mt-4">
|
||||
<div class="w-1/4 font-bold border-b-2">{{ __('invoice.Invoice Number') }}</div>
|
||||
<div class="w-1/4 font-bold border-b-2">{{ __('invoice.State') }}</div>
|
||||
<div class="w-1/4 text-right font-bold border-b-2 text-right">{{ __('invoice.Sum') }}</div>
|
||||
<div class="w-1/4 text-right font-bold border-b-2 text-right">{{ __('invoice.Paid at') }}</div>
|
||||
</summary>
|
||||
|
||||
<template x-for="payment in payments">
|
||||
<details class="even:bg-gray-100 odd:bg-white">
|
||||
<summary class="cursor-pointer flex flex-row w-full" @click="window.location.href='/payment/' + payment.id + '/edit';">
|
||||
<div class="w-1/4" x-text="payment.invoice.number"></div>
|
||||
<div class="w-1/4" x-text="payment.localized_state"></div>
|
||||
<div class="w-1/4 text-right" x-text="payment.paid_amount + ' €'"></div>
|
||||
<div class="w-1/4 text-right" x-text="payment.date"></div>
|
||||
</summary>
|
||||
</details>
|
||||
</template>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
|
||||
<script>
|
||||
function paymentForm() {
|
||||
return {
|
||||
from: "{{ \Illuminate\Support\Facades\Date::now()->firstOfMonth()->format('Y-m-d') }}",
|
||||
end: "{{ \Illuminate\Support\Facades\Date::now()->format('Y-m-d') }}",
|
||||
payments: [],
|
||||
sum: 0,
|
||||
|
||||
init() {
|
||||
this.fetchPayments();
|
||||
},
|
||||
|
||||
fetchPayments() {
|
||||
let vm = this;
|
||||
axios.get('/payment-filter/' + this.from + '/' + this.end)
|
||||
.then(function (response) {
|
||||
vm.payments = response.data;
|
||||
vm.calculateSum();
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
})
|
||||
},
|
||||
|
||||
calculateSum() {
|
||||
this.sum = 0;
|
||||
for (const [key, payment] of Object.entries(this.payments)) {
|
||||
this.sum += parseFloat(payment.sum);
|
||||
}
|
||||
this.sum = this.sum.toFixed(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user