auto-reload and sum bug fix

This commit is contained in:
Dennis Eichhorn 2019-12-21 12:26:24 +01:00
parent c3d8d0ca7f
commit 2628ca6f9f
4 changed files with 12 additions and 7 deletions

View File

@ -56,7 +56,7 @@
"icon": null,
"order": 1,
"from": "HumanResourceTimeRecording",
"permission": { "permission": 2, "type": null, "element": null },
"permission": { "permission": 2, "type": 2, "element": null },
"parent": 1003401001,
"children": []
}

View File

@ -80,6 +80,7 @@ final class BackendController extends Controller
$lastOpenSession = SessionMapper::getMostPlausibleOpenSessionForEmployee($employee);
$start = new SmartDateTime('now');
$start = $start->getEndOfDay();
$limit = $start->getEndOfMonth();
$limit->smartModify(0, -2, 0);

View File

@ -181,7 +181,7 @@ final class SessionMapper extends DataMapperAbstract
$query = new Builder(self::$db);
$query = self::getQuery($query)
->where(self::$table . '.hr_timerecording_session_employee', '=', $employee)
->andWhere(self::$table . '.' . self::$createdAt, '<=', $start->format('Y-m-d'))
->andWhere(self::$table . '.' . self::$createdAt, '<=', $start->format('Y-m-d H:i:s'))
->orderBy(self::$table . '.' . self::$createdAt, 'DESC')
->offset($offset)
->limit($limit);

View File

@ -80,7 +80,13 @@ show additional section with vacation days
</select>
<tr><td>
<input type="hidden" name="session" value="<?= $lastOpenSession !== null ? $lastOpenSession->getId() : ''; ?>">
<input type="submit" id="iclockingButton" name="clockingButton" value="<?= $this->getHtml('Submit', '0', '0'); ?>">
<input type="submit" id="iclockingButton" name="clockingButton" value="<?= $this->getHtml('Submit', '0', '0'); ?>" data-action='[
{
"key": 1, "listener": "click", "action": [
{"key": 1, "type": "dom.reload", "delay": 3000}
]
}
]'>
</table>
</form>
</div>
@ -148,7 +154,7 @@ show additional section with vacation days
<td><a href="<?= $url; ?>"><?= (int) ($session->getBreak() / 3600); ?>h <?= ((int) ($session->getBreak() / 60) % 60); ?>m</a>
<td><a href="<?= $url; ?>"><?= $session->getEnd() !== null ? $session->getEnd()->format('H:i') : ''; ?></a>
<td><a href="<?= $url; ?>"><?= (int) ($session->getBusy() / 3600); ?>h <?= ((int) ($session->getBusy() / 60) % 60); ?>m</a>
<?php if ($session->getStart()->getTimestamp() < $startWeek->getTimestamp() || $count === $sessionCount) : ?>
<?php $busy['week'] += $session->getBusy(); if ($session->getStart()->getTimestamp() < $startWeek->getTimestamp() || $count === $sessionCount) : ?>
<tr>
<th colspan="6"> <?= $startWeek->format('Y/m/d'); ?> - <?= $endWeek->format('Y/m/d'); ?>
<th><?= (int) ($busy['week'] / 3600); ?>h <?= ((int) ($busy['week'] / 60) % 60); ?>m
@ -157,9 +163,8 @@ show additional section with vacation days
$startWeek = $startWeek->createModify(0, 0, -7);
$busy['week'] = 0;
endif;
$busy['week'] += $session->getBusy();
?>
<?php if ($session->getStart()->getTimestamp() < $startMonth->getTimestamp() || $count === $sessionCount) : ?>
<?php $busy['month'] += $session->getBusy(); if ($session->getStart()->getTimestamp() < $startMonth->getTimestamp() || $count === $sessionCount) : ?>
<tr>
<th colspan="6"> <?= $startMonth->format('Y/m/d'); ?> - <?= $endMonth->format('Y/m/d'); ?>
<th><?= (int) ($busy['month'] / 3600); ?>h <?= ((int) ($busy['month'] / 60) % 60); ?>m
@ -168,7 +173,6 @@ show additional section with vacation days
$startMonth = $startMonth->createModify(0, -1, 0);
$busy['month'] = 0;
endif;
$busy['month'] += $session->getBusy();
?>
<?php endforeach; ?>
</table>