mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
CalendarService reflect config options for GetEvents (#552)
This commit is contained in:
parent
ba4dfa30a7
commit
13f99ad5f2
@ -29,65 +29,77 @@ class CalendarService extends BaseService
|
|||||||
|
|
||||||
public function GetEvents()
|
public function GetEvents()
|
||||||
{
|
{
|
||||||
$products = $this->Database->products();
|
|
||||||
$titlePrefix = $this->LocalizationService->__t('Product expires') . ': ';
|
|
||||||
$stockEvents = array();
|
$stockEvents = array();
|
||||||
foreach($this->StockService->GetCurrentStock() as $currentStockEntry)
|
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||||
{
|
{
|
||||||
if ($currentStockEntry->amount > 0)
|
$products = $this->Database->products();
|
||||||
|
$titlePrefix = $this->LocalizationService->__t('Product expires') . ': ';
|
||||||
|
foreach($this->StockService->GetCurrentStock() as $currentStockEntry)
|
||||||
{
|
{
|
||||||
$stockEvents[] = array(
|
if ($currentStockEntry->amount > 0)
|
||||||
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->name,
|
{
|
||||||
'start' => $currentStockEntry->best_before_date,
|
$stockEvents[] = array(
|
||||||
|
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->name,
|
||||||
|
'start' => $currentStockEntry->best_before_date,
|
||||||
|
'date_format' => 'date'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$taskEvents = array();
|
||||||
|
if (GROCY_FEATURE_FLAG_TASKS)
|
||||||
|
{
|
||||||
|
$titlePrefix = $this->LocalizationService->__t('Task due') . ': ';
|
||||||
|
foreach($this->TasksService->GetCurrent() as $currentTaskEntry)
|
||||||
|
{
|
||||||
|
$taskEvents[] = array(
|
||||||
|
'title' => $titlePrefix . $currentTaskEntry->name,
|
||||||
|
'start' => $currentTaskEntry->due_date,
|
||||||
'date_format' => 'date'
|
'date_format' => 'date'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$titlePrefix = $this->LocalizationService->__t('Task due') . ': ';
|
|
||||||
$taskEvents = array();
|
|
||||||
foreach($this->TasksService->GetCurrent() as $currentTaskEntry)
|
|
||||||
{
|
|
||||||
$taskEvents[] = array(
|
|
||||||
'title' => $titlePrefix . $currentTaskEntry->name,
|
|
||||||
'start' => $currentTaskEntry->due_date,
|
|
||||||
'date_format' => 'date'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$usersService = new UsersService();
|
|
||||||
$users = $usersService->GetUsersAsDto();
|
|
||||||
|
|
||||||
$chores = $this->Database->chores();
|
|
||||||
$titlePrefix = $this->LocalizationService->__t('Chore due') . ': ';
|
|
||||||
$choreEvents = array();
|
$choreEvents = array();
|
||||||
foreach($this->ChoresService->GetCurrent() as $currentChoreEntry)
|
if (GROCY_FEATURE_FLAG_CHORES)
|
||||||
{
|
{
|
||||||
$chore = FindObjectInArrayByPropertyValue($chores, 'id', $currentChoreEntry->chore_id);
|
$usersService = new UsersService();
|
||||||
|
$users = $usersService->GetUsersAsDto();
|
||||||
|
|
||||||
$assignedToText = '';
|
$chores = $this->Database->chores();
|
||||||
if (!empty($currentChoreEntry->next_execution_assigned_to_user_id))
|
$titlePrefix = $this->LocalizationService->__t('Chore due') . ': ';
|
||||||
|
foreach($this->ChoresService->GetCurrent() as $currentChoreEntry)
|
||||||
{
|
{
|
||||||
$assignedToText = ' (' . $this->LocalizationService->__t('assigned to %s', FindObjectInArrayByPropertyValue($users, 'id', $currentChoreEntry->next_execution_assigned_to_user_id)->display_name) . ')';
|
$chore = FindObjectInArrayByPropertyValue($chores, 'id', $currentChoreEntry->chore_id);
|
||||||
}
|
|
||||||
|
|
||||||
$choreEvents[] = array(
|
$assignedToText = '';
|
||||||
'title' => $titlePrefix . $chore->name . $assignedToText,
|
if (!empty($currentChoreEntry->next_execution_assigned_to_user_id))
|
||||||
'start' => $currentChoreEntry->next_estimated_execution_time,
|
{
|
||||||
'date_format' => 'datetime'
|
$assignedToText = ' (' . $this->LocalizationService->__t('assigned to %s', FindObjectInArrayByPropertyValue($users, 'id', $currentChoreEntry->next_execution_assigned_to_user_id)->display_name) . ')';
|
||||||
);
|
}
|
||||||
|
|
||||||
|
$choreEvents[] = array(
|
||||||
|
'title' => $titlePrefix . $chore->name . $assignedToText,
|
||||||
|
'start' => $currentChoreEntry->next_estimated_execution_time,
|
||||||
|
'date_format' => 'datetime'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$batteries = $this->Database->batteries();
|
|
||||||
$titlePrefix = $this->LocalizationService->__t('Battery charge cycle due') . ': ';
|
|
||||||
$batteryEvents = array();
|
$batteryEvents = array();
|
||||||
foreach($this->BatteriesService->GetCurrent() as $currentBatteryEntry)
|
if (GROCY_FEATURE_FLAG_BATTERIES)
|
||||||
{
|
{
|
||||||
$batteryEvents[] = array(
|
$batteries = $this->Database->batteries();
|
||||||
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($batteries, 'id', $currentBatteryEntry->battery_id)->name,
|
$titlePrefix = $this->LocalizationService->__t('Battery charge cycle due') . ': ';
|
||||||
'start' => $currentBatteryEntry->next_estimated_charge_time,
|
foreach($this->BatteriesService->GetCurrent() as $currentBatteryEntry)
|
||||||
'date_format' => 'datetime'
|
{
|
||||||
);
|
$batteryEvents[] = array(
|
||||||
|
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($batteries, 'id', $currentBatteryEntry->battery_id)->name,
|
||||||
|
'start' => $currentBatteryEntry->next_estimated_charge_time,
|
||||||
|
'date_format' => 'datetime'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$recipes = $this->Database->recipes();
|
$recipes = $this->Database->recipes();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user