Added helper methods for first and last day of month.

Sub-bookings are now showed in the bookings index view.
This commit is contained in:
Lukas Halbritter
2018-10-01 09:56:55 +02:00
parent 491a6f6153
commit 8f865e9bff
2 changed files with 34 additions and 10 deletions
+28 -2
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /**
* Returns true with a given percentage. * Returns true with a given percentage.
* *
* @param int $prob Probability for true in percent. * @param int $prob Probability for true in percent.
@@ -20,7 +20,7 @@ function rand_bool($prob = 50) {
return $rand <= $prob; return $rand <= $prob;
} }
/* /**
* Return the formatted string representation of a floatng point number. * Return the formatted string representation of a floatng point number.
* *
* The decimal point is a ',', the thousands seperator ist set to '.'. * The decimal point is a ',', the thousands seperator ist set to '.'.
@@ -34,3 +34,29 @@ function rand_bool($prob = 50) {
function formatAmount(float $amount, $decimals = 2) { function formatAmount(float $amount, $decimals = 2) {
return number_format($amount, $decimals, ',', '.'); return number_format($amount, $decimals, ',', '.');
} }
/**
* Return the string that is the first day of the month, given by the year and
* the month.
*
* @param string $year
* @param string $month
* @return string
*/
function startOfMonth($year, $month) {
return Carbon\Carbon::createFromDate($year, $month)
->startOfMonth()->format('Y-m-d');
}
/**
* Return the string that is the last day of the month, given by the year and
* the month.
*
* @param string $year
* @param string $month
* @return string
*/
function endOfMonth($year, $month) {
return Carbon\Carbon::createFromDate($year, $month)
->endOfMonth()->format('Y-m-d');
}
+6 -8
View File
@@ -29,7 +29,7 @@
<tr style='color: red; font-weight: bold'> <tr style='color: red; font-weight: bold'>
<td></td> <td></td>
<td></td> <td></td>
<td>{{ $year . '-' . sprintf('%02d', $month) . '-01'}}</td> <td>{{ startOfMonth($year, $month) }}</td>
<td>Saldo</td> <td>Saldo</td>
<td></td> <td></td>
<td></td> <td></td>
@@ -71,7 +71,7 @@
</td> </td>
</tr> </tr>
@if (!$booking->isSimple()) @if (!$booking->isSimple())
@foreach ($booking->subBookings() as $subBooking) @foreach ($booking->subBookings as $subBooking)
<tr> <tr>
<td>+</td> <td>+</td>
<td></td> <td></td>
@@ -80,12 +80,12 @@
<td></td> <td></td>
<td align='right'> <td align='right'>
@if ($subBooking->signedAmount() < 0) @if ($subBooking->signedAmount() < 0)
{{ formatAmount($subBooking->signedAmount) }} {{ formatAmount($subBooking->signedAmount()) }}
@endif @endif
</td> </td>
<td align='right'> <td align='right'>
@if ($subBooking->signedAmount() >= 0) @if ($subBooking->signedAmount() >= 0)
{{ formatAmount($subBooking->signedAmount) }} {{ formatAmount($subBooking->signedAmount()) }}
@endif @endif
</td> </td>
<td> <td>
@@ -103,8 +103,7 @@
<td></td> <td></td>
<td></td> <td></td>
<td> <td>
{{ $year . '-' . sprintf('%02d', $month) . '-' . {{ endOfMonth($year, $month) }}
cal_days_in_month(CAL_GREGORIAN, $month, $year) }}
</td> </td>
<td>Monatsabschluss</td> <td>Monatsabschluss</td>
<td></td> <td></td>
@@ -117,8 +116,7 @@
<td></td> <td></td>
<td></td> <td></td>
<td> <td>
{{ $year . '-' . sprintf('%02d', $month) . '-' . {{ endOfMonth($year, $month) }}
cal_days_in_month(CAL_GREGORIAN, $month, $year) }}
</td> </td>
<td>Saldo</td> <td>Saldo</td>
<td></td> <td></td>