mirror of
https://github.com/grocy/grocy.git
synced 2025-10-12 08:34:48 +00:00
Squashed commit
Updated dependencies Added the possibility to skip chore schedules (closes #1486) Show the meal plan section on the corresponding calendar events (closes #1582) Make it possible to define a time for meal plan sections and use that time for the corresponding calendar events (references #1582) Added a changelog template Make it possible to toggle the meal plan calendar view on bigger screens (closes #1678)
This commit is contained in:
@@ -110,8 +110,8 @@ class ChoresService extends BaseService
|
||||
$users = $this->getUsersService()->GetUsersAsDto();
|
||||
|
||||
$chore = $this->getDatabase()->chores($choreId);
|
||||
$choreTrackedCount = $this->getDatabase()->chores_log()->where('chore_id = :1 AND undone = 0', $choreId)->count();
|
||||
$choreLastTrackedTime = $this->getDatabase()->chores_log()->where('chore_id = :1 AND undone = 0', $choreId)->max('tracked_time');
|
||||
$choreTrackedCount = $this->getDatabase()->chores_log()->where('chore_id = :1 AND undone = 0 AND skipped = 0', $choreId)->count();
|
||||
$choreLastTrackedTime = $this->getDatabase()->chores_log()->where('chore_id = :1 AND undone = 0 AND skipped = 0', $choreId)->max('tracked_time');
|
||||
$nextExecutionTime = $this->getDatabase()->chores_current()->where('chore_id', $choreId)->min('next_estimated_execution_time');
|
||||
|
||||
$lastChoreLogRow = $this->getDatabase()->chores_log()->where('chore_id = :1 AND tracked_time = :2 AND undone = 0', $choreId, $choreLastTrackedTime)->fetch();
|
||||
@@ -157,7 +157,7 @@ class ChoresService extends BaseService
|
||||
return $chores;
|
||||
}
|
||||
|
||||
public function TrackChore(int $choreId, string $trackedTime, $doneBy = GROCY_USER_ID)
|
||||
public function TrackChore(int $choreId, string $trackedTime, $doneBy = GROCY_USER_ID, $skipped = false)
|
||||
{
|
||||
if (!$this->ChoreExists($choreId))
|
||||
{
|
||||
@@ -176,10 +176,21 @@ class ChoresService extends BaseService
|
||||
$trackedTime = substr($trackedTime, 0, 10) . ' 00:00:00';
|
||||
}
|
||||
|
||||
if ($skipped)
|
||||
{
|
||||
if ($chore->period_type == self::CHORE_PERIOD_TYPE_MANUALLY)
|
||||
{
|
||||
throw new \Exception('Chores without a schedule can\'t be skipped');
|
||||
}
|
||||
|
||||
$trackedTime = $this->getDatabase()->chores_current()->where('chore_id', $choreId)->min('next_estimated_execution_time');
|
||||
}
|
||||
|
||||
$logRow = $this->getDatabase()->chores_log()->createRow([
|
||||
'chore_id' => $choreId,
|
||||
'tracked_time' => $trackedTime,
|
||||
'done_by_user_id' => $doneBy
|
||||
'done_by_user_id' => $doneBy,
|
||||
'skipped' => BoolToInt($skipped)
|
||||
]);
|
||||
$logRow->save();
|
||||
$lastInsertId = $this->getDatabase()->lastInsertId();
|
||||
|
Reference in New Issue
Block a user