Start history grid weeks at monday
Add configuration option for week-start and set the default to Monday.
This commit is contained in:
parent
e42b7b3026
commit
6c3c466f92
|
@ -23,6 +23,7 @@ class HistoryColorGrid extends AbstractWidget {
|
|||
|
||||
public $weekFlow = self::CAL_GROW_INTO_PAST;
|
||||
public $orientation = self::ORIENTATION_VERTICAL;
|
||||
public $weekStartMonday = true;
|
||||
|
||||
private $maxValue = 1;
|
||||
|
||||
|
@ -161,7 +162,7 @@ class HistoryColorGrid extends AbstractWidget {
|
|||
$html = '<table class="historycolorgrid">';
|
||||
$html .= '<tr>';
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$html .= '<th>' . $this->weekdayName($i) . "</th>";
|
||||
$html .= '<th>' . $this->weekdayName($this->weekStartMonday ? $i + 1 : $i) . "</th>";
|
||||
}
|
||||
$html .= '</tr>';
|
||||
$old = -1;
|
||||
|
@ -195,7 +196,9 @@ class HistoryColorGrid extends AbstractWidget {
|
|||
*/
|
||||
private function renderWeekdayHorizontal($weekday, &$weeks)
|
||||
{
|
||||
$html = '<tr><td class="weekday">' . $this->weekdayName($weekday) . '</td>';
|
||||
$html = '<tr><td class="weekday">'
|
||||
. $this->weekdayName($this->weekStartMonday ? $weekday + 1 : $weekday)
|
||||
. '</td>';
|
||||
foreach ($weeks as $week) {
|
||||
if (array_key_exists($weekday, $week)) {
|
||||
$html .= '<td>' . $this->renderDay($week[$weekday]) . '</td>';
|
||||
|
@ -222,6 +225,10 @@ class HistoryColorGrid extends AbstractWidget {
|
|||
$month = intval(date('n', $start));
|
||||
$day = intval(date('j', $start));
|
||||
$weekday = intval(date('w', $start));
|
||||
if ($this->weekStartMonday) {
|
||||
// 0 => monday, 6 => sunday
|
||||
$weekday = $weekday === 0 ? 6 : $weekday - 1;
|
||||
}
|
||||
|
||||
$date = $this->toDateStr($day, $month, $year);
|
||||
$weeks[0][$weekday] = $date;
|
||||
|
|
Loading…
Reference in New Issue