mirror of
https://github.com/grocy/grocy.git
synced 2025-10-14 09:11:11 +00:00
Highlight chores/tasks/batteries due today in a separate color + status filter (closes #1740)
This commit is contained in:
@@ -80,9 +80,30 @@ class BatteriesController extends BaseController
|
||||
$usersService = $this->getUsersService();
|
||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['batteries_due_soon_days'];
|
||||
|
||||
$batteries = $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
|
||||
$currentBatteries = $this->getBatteriesService()->GetCurrent();
|
||||
foreach ($currentBatteries as $currentBattery)
|
||||
{
|
||||
if (FindObjectInArrayByPropertyValue($batteries, 'id', $currentBattery->battery_id)->charge_interval_days > 0)
|
||||
{
|
||||
if ($currentBattery->next_estimated_charge_time < date('Y-m-d H:i:s'))
|
||||
{
|
||||
$currentBattery->due_type = 'overdue';
|
||||
}
|
||||
elseif ($currentBattery->next_estimated_charge_time <= date('Y-m-d 23:59:59'))
|
||||
{
|
||||
$currentBattery->due_type = 'duetoday';
|
||||
}
|
||||
elseif ($currentBattery->next_estimated_charge_time <= date('Y-m-d H:i:s', strtotime('+' . $nextXDays . ' days')))
|
||||
{
|
||||
$currentBattery->due_type = 'duesoon';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->renderPage($response, 'batteriesoverview', [
|
||||
'batteries' => $this->getDatabase()->batteries()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
|
||||
'current' => $this->getBatteriesService()->GetCurrent(),
|
||||
'batteries' => $batteries,
|
||||
'current' => $currentBatteries,
|
||||
'nextXDays' => $nextXDays,
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('batteries'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('batteries')
|
||||
|
@@ -94,9 +94,30 @@ class ChoresController extends BaseController
|
||||
$usersService = $this->getUsersService();
|
||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['chores_due_soon_days'];
|
||||
|
||||
$chores = $this->getDatabase()->chores()->orderBy('name', 'COLLATE NOCASE');
|
||||
$currentChores = $this->getChoresService()->GetCurrent();
|
||||
foreach ($currentChores as $currentChore)
|
||||
{
|
||||
if (FindObjectInArrayByPropertyValue($chores, 'id', $currentChore->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_PERIOD_TYPE_MANUALLY)
|
||||
{
|
||||
if ($currentChore->next_estimated_execution_time < date('Y-m-d H:i:s'))
|
||||
{
|
||||
$currentChore->due_type = 'overdue';
|
||||
}
|
||||
elseif ($currentChore->next_estimated_execution_time <= date('Y-m-d 23:59:59'))
|
||||
{
|
||||
$currentChore->due_type = 'duetoday';
|
||||
}
|
||||
elseif ($currentChore->next_estimated_execution_time <= date('Y-m-d H:i:s', strtotime('+' . $nextXDays . ' days')))
|
||||
{
|
||||
$currentChore->due_type = 'duesoon';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->renderPage($response, 'choresoverview', [
|
||||
'chores' => $this->getDatabase()->chores()->orderBy('name', 'COLLATE NOCASE'),
|
||||
'currentChores' => $this->getChoresService()->GetCurrent(),
|
||||
'chores' => $chores,
|
||||
'currentChores' => $currentChores,
|
||||
'nextXDays' => $nextXDays,
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('chores'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('chores'),
|
||||
|
@@ -6,6 +6,9 @@ class TasksController extends BaseController
|
||||
{
|
||||
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$usersService = $this->getUsersService();
|
||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['tasks_due_soon_days'];
|
||||
|
||||
if (isset($request->getQueryParams()['include_done']))
|
||||
{
|
||||
$tasks = $this->getDatabase()->tasks()->orderBy('name', 'COLLATE NOCASE');
|
||||
@@ -15,8 +18,21 @@ class TasksController extends BaseController
|
||||
$tasks = $this->getTasksService()->GetCurrent();
|
||||
}
|
||||
|
||||
$usersService = $this->getUsersService();
|
||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['tasks_due_soon_days'];
|
||||
foreach ($tasks as $task)
|
||||
{
|
||||
if ($task->due_date < date('Y-m-d 23:59:59', strtotime('-1 days')))
|
||||
{
|
||||
$task->due_type = 'overdue';
|
||||
}
|
||||
elseif ($task->due_date <= date('Y-m-d 23:59:59'))
|
||||
{
|
||||
$task->due_type = 'duetoday';
|
||||
}
|
||||
elseif ($task->due_date <= date('Y-m-d 23:59:59', strtotime('+' . $nextXDays . ' days')))
|
||||
{
|
||||
$task->due_type = 'duesoon';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->renderPage($response, 'tasks', [
|
||||
'tasks' => $tasks,
|
||||
|
Reference in New Issue
Block a user