Skip to content

Commit

Permalink
Remove existing ticket entries from dropdown list in my timesheet view
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Sep 21, 2024
1 parent 2d2ef6b commit 45d69b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/Domain/Timesheets/Controllers/ShowMy.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public function run(): Response
}

$myTimesheets = $this->timesheetService->getWeeklyTimesheets(-1, $fromDate, session("userdata.id"));
$existingTicketIds = array_map(fn($item) => $item['ticketId'], $myTimesheets);

$this->tpl->assign('existingTicketIds', $existingTicketIds);
$this->tpl->assign('dateFrom', $fromDate);
$this->tpl->assign('actKind', $kind);
$this->tpl->assign('kind', $this->timesheetRepo->kind);
Expand Down Expand Up @@ -123,6 +125,11 @@ public function saveTimeSheet(array $postData): void
if ($ticketId === "new" || $ticketId === 0) {
$ticketId = (int)$postData["ticketId"];
$kind = $postData["kindId"];

if($ticketId == 0){
$this->tpl->setNotification("Task ID is required for new entries", "error", "save_timesheet");
return;
}
}

$values = array(
Expand Down
4 changes: 3 additions & 1 deletion app/Domain/Timesheets/Templates/showMy.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ class="hourCell"
<div class="form-group" id="ticketSelect">
<select data-placeholder="<?php echo $tpl->__('input.placeholders.choose_todo')?>" style="" class="ticket-select" name="ticketId">
<option value=""></option>
<?php foreach ($tpl->get('allTickets') as $ticketRow) { ?>
<?php foreach ($tpl->get('allTickets') as $ticketRow) {
if(in_array($ticketRow['id'],$tpl->get('existingTicketIds'))) continue;
?>
<?php echo sprintf(
$tpl->dispatchTplFilter(
'todo_format',
Expand Down

0 comments on commit 45d69b0

Please sign in to comment.