highlight actual time in users shifts list

This commit is contained in:
Xu 2023-12-11 19:54:21 +01:00 committed by Igor Scheller
parent 15a6ba1c52
commit a35a3580e0
3 changed files with 40 additions and 1 deletions

View File

@ -327,7 +327,7 @@ function render_table($columns, $rows, $data = true)
$html .= '</tr></thead>'; $html .= '</tr></thead>';
$html .= '<tbody>'; $html .= '<tbody>';
foreach ($rows as $row) { foreach ($rows as $row) {
$html .= '<tr>'; $html .= '<tr' . (isset($row['row-class']) ? ' class="' . $row['row-class'] . '"' : '') . '>';
foreach ($columns as $key => $column) { foreach ($columns as $key => $column) {
$value = '&nbsp;'; $value = '&nbsp;';
if (isset($row[$key])) { if (isset($row[$key])) {

View File

@ -316,6 +316,8 @@ function User_view_myshift(Shift $shift, $user_source, $its_me)
'location' => location_name_render($shift->location), 'location' => location_name_render($shift->location),
'shift_info' => $shift_info, 'shift_info' => $shift_info,
'comment' => '', 'comment' => '',
'start' => $shift->start,
'end' => $shift->end,
]; ];
if ($its_me) { if ($its_me) {
@ -402,6 +404,20 @@ function User_view_myshifts(
if (count($myshifts_table) > 0) { if (count($myshifts_table) > 0) {
ksort($myshifts_table); ksort($myshifts_table);
$myshifts_table = array_values($myshifts_table);
foreach ($myshifts_table as $i => &$shift) {
$before = $myshifts_table[$i - 1] ?? null;
$after = $myshifts_table[$i + 1] ?? null;
if (Carbon::now() > $shift['start'] && Carbon::now() < $shift['end']) {
$shift['row-class'] = 'border border-info border-2';
} elseif ($after && Carbon::now() > $shift['end'] && Carbon::now() < $after['start']) {
$shift['row-class'] = 'border-bottom border-info';
} elseif (!$before && Carbon::now() < $shift['start']) {
$shift['row-class'] = 'border-top-info';
} elseif (!$after && Carbon::now() > $shift['end']) {
$shift['row-class'] = 'border-bottom border-info';
}
}
$myshifts_table[] = [ $myshifts_table[] = [
'date' => '<b>' . __('Sum:') . '</b>', 'date' => '<b>' . __('Sum:') . '</b>',
'duration' => '<b>' . sprintf('%.2f', round($timeSum / 3600, 2)) . '&nbsp;h</b>', 'duration' => '<b>' . sprintf('%.2f', round($timeSum / 3600, 2)) . '&nbsp;h</b>',
@ -461,6 +477,8 @@ function User_view_worklog(Worklog $worklog, $admin_user_worklog_privilege)
$worklog->created_at->format(__('general.datetime')) $worklog->created_at->format(__('general.datetime'))
), ),
'actions' => $actions, 'actions' => $actions,
'start' => $worklog->worked_at,
'end' => $worklog->worked_at,
]; ];
} }

View File

@ -121,6 +121,27 @@ table a > .icon-icon_angel {
margin-bottom: 0; margin-bottom: 0;
} }
/* making top border visible in tables */
table .border-top {
border-top-width: calc(var(--bs-border-width) * 2) !important;
}
/* to only highlight the top row in info color */
table .border-top-info {
border-top-width: calc(var(--bs-border-width) * 2) !important;
border-top-color: rgba(var(--bs-info-rgb)) !important;
}
// equal top and bottom border if highlighted
table .border-bottom {
border-bottom-width: calc(var(--bs-border-width) * 2) !important;
}
/* to be able to highlight table rows */
.table-responsive {
padding: 0 2px;
}
.stats { .stats {
font-size: 20px; font-size: 20px;
height: 150px; height: 150px;