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:
+28
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns true with a given percentage.
|
||||
*
|
||||
* @param int $prob Probability for true in percent.
|
||||
@@ -20,7 +20,7 @@ function rand_bool($prob = 50) {
|
||||
return $rand <= $prob;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Return the formatted string representation of a floatng point number.
|
||||
*
|
||||
* 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) {
|
||||
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');
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<tr style='color: red; font-weight: bold'>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{{ $year . '-' . sprintf('%02d', $month) . '-01'}}</td>
|
||||
<td>{{ startOfMonth($year, $month) }}</td>
|
||||
<td>Saldo</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
@@ -71,7 +71,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
@if (!$booking->isSimple())
|
||||
@foreach ($booking->subBookings() as $subBooking)
|
||||
@foreach ($booking->subBookings as $subBooking)
|
||||
<tr>
|
||||
<td>+</td>
|
||||
<td></td>
|
||||
@@ -80,12 +80,12 @@
|
||||
<td></td>
|
||||
<td align='right'>
|
||||
@if ($subBooking->signedAmount() < 0)
|
||||
{{ formatAmount($subBooking->signedAmount) }}
|
||||
{{ formatAmount($subBooking->signedAmount()) }}
|
||||
@endif
|
||||
</td>
|
||||
<td align='right'>
|
||||
@if ($subBooking->signedAmount() >= 0)
|
||||
{{ formatAmount($subBooking->signedAmount) }}
|
||||
{{ formatAmount($subBooking->signedAmount()) }}
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@@ -103,8 +103,7 @@
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
{{ $year . '-' . sprintf('%02d', $month) . '-' .
|
||||
cal_days_in_month(CAL_GREGORIAN, $month, $year) }}
|
||||
{{ endOfMonth($year, $month) }}
|
||||
</td>
|
||||
<td>Monatsabschluss</td>
|
||||
<td></td>
|
||||
@@ -117,8 +116,7 @@
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
{{ $year . '-' . sprintf('%02d', $month) . '-' .
|
||||
cal_days_in_month(CAL_GREGORIAN, $month, $year) }}
|
||||
{{ endOfMonth($year, $month) }}
|
||||
</td>
|
||||
<td>Saldo</td>
|
||||
<td></td>
|
||||
|
||||
Reference in New Issue
Block a user