mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Also show due/overdue on bateries- and habitoverview
This commit is contained in:
parent
ab8094e1c0
commit
3e394a3840
@ -22,10 +22,16 @@ class BatteriesController extends BaseController
|
|||||||
$nextChargeTimes[$battery->id] = $this->BatteriesService->GetNextChargeTime($battery->id);
|
$nextChargeTimes[$battery->id] = $this->BatteriesService->GetNextChargeTime($battery->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$nextXDays = 5;
|
||||||
|
$countDueNextXDays = count(FindAllItemsInArrayByValue($nextChargeTimes, date('Y-m-d', strtotime("+$nextXDays days")), '<'));
|
||||||
|
$countOverdue = count(FindAllItemsInArrayByValue($nextChargeTimes, date('Y-m-d', strtotime('-1 days')), '<'));
|
||||||
return $this->AppContainer->view->render($response, 'batteriesoverview', [
|
return $this->AppContainer->view->render($response, 'batteriesoverview', [
|
||||||
'batteries' => $this->Database->batteries(),
|
'batteries' => $this->Database->batteries(),
|
||||||
'current' => $this->BatteriesService->GetCurrent(),
|
'current' => $this->BatteriesService->GetCurrent(),
|
||||||
'nextChargeTimes' => $nextChargeTimes
|
'nextChargeTimes' => $nextChargeTimes,
|
||||||
|
'nextXDays' => $nextXDays,
|
||||||
|
'countDueNextXDays' => $countDueNextXDays - $countOverdue,
|
||||||
|
'countOverdue' => $countOverdue
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,10 +22,16 @@ class HabitsController extends BaseController
|
|||||||
$nextHabitTimes[$habit->id] = $this->HabitsService->GetNextHabitTime($habit->id);
|
$nextHabitTimes[$habit->id] = $this->HabitsService->GetNextHabitTime($habit->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$nextXDays = 5;
|
||||||
|
$countDueNextXDays = count(FindAllItemsInArrayByValue($nextHabitTimes, date('Y-m-d', strtotime("+$nextXDays days")), '<'));
|
||||||
|
$countOverdue = count(FindAllItemsInArrayByValue($nextHabitTimes, date('Y-m-d', strtotime('-1 days')), '<'));
|
||||||
return $this->AppContainer->view->render($response, 'habitsoverview', [
|
return $this->AppContainer->view->render($response, 'habitsoverview', [
|
||||||
'habits' => $this->Database->habits(),
|
'habits' => $this->Database->habits(),
|
||||||
'currentHabits' => $this->HabitsService->GetCurrentHabits(),
|
'currentHabits' => $this->HabitsService->GetCurrentHabits(),
|
||||||
'nextHabitTimes' => $nextHabitTimes
|
'nextHabitTimes' => $nextHabitTimes,
|
||||||
|
'nextXDays' => $nextXDays,
|
||||||
|
'countDueNextXDays' => $countDueNextXDays - $countOverdue,
|
||||||
|
'countOverdue' => $countOverdue
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,18 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
|
$currentStock = $this->StockService->GetCurrentStock();
|
||||||
|
$nextXDays = 5;
|
||||||
|
$countExpiringNextXDays = count(FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d', strtotime('+5 days')), '<'));
|
||||||
|
$countAlreadyExpired = count(FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d', strtotime('-1 days')), '<'));
|
||||||
return $this->AppContainer->view->render($response, 'stockoverview', [
|
return $this->AppContainer->view->render($response, 'stockoverview', [
|
||||||
'products' => $this->Database->products(),
|
'products' => $this->Database->products(),
|
||||||
'quantityunits' => $this->Database->quantity_units(),
|
'quantityunits' => $this->Database->quantity_units(),
|
||||||
'currentStock' => $this->StockService->GetCurrentStock(),
|
'currentStock' => $currentStock,
|
||||||
'missingProducts' => $this->StockService->GetMissingProducts()
|
'missingProducts' => $this->StockService->GetMissingProducts(),
|
||||||
|
'nextXDays' => $nextXDays,
|
||||||
|
'countExpiringNextXDays' => $countExpiringNextXDays,
|
||||||
|
'countAlreadyExpired' => $countAlreadyExpired
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,38 @@ function FindAllObjectsInArrayByPropertyValue($array, $propertyName, $propertyVa
|
|||||||
return $returnArray;
|
return $returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function FindAllItemsInArrayByValue($array, $value, $operator = '==')
|
||||||
|
{
|
||||||
|
$returnArray = array();
|
||||||
|
|
||||||
|
foreach($array as $item)
|
||||||
|
{
|
||||||
|
switch($operator)
|
||||||
|
{
|
||||||
|
case '==':
|
||||||
|
if($item == $value)
|
||||||
|
{
|
||||||
|
$returnArray[] = $item;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '>':
|
||||||
|
if($item > $value)
|
||||||
|
{
|
||||||
|
$returnArray[] = $item;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '<':
|
||||||
|
if($item < $value)
|
||||||
|
{
|
||||||
|
$returnArray[] = $item;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnArray;
|
||||||
|
}
|
||||||
|
|
||||||
function SumArrayValue($array, $propertyName)
|
function SumArrayValue($array, $propertyName)
|
||||||
{
|
{
|
||||||
$sum = 0;
|
$sum = 0;
|
||||||
|
@ -157,5 +157,9 @@ return array(
|
|||||||
'Alarm clock' => 'Wecker',
|
'Alarm clock' => 'Wecker',
|
||||||
'Heat remote control' => 'Fernbedienung Heizung',
|
'Heat remote control' => 'Fernbedienung Heizung',
|
||||||
'About grocy' => 'Über grocy',
|
'About grocy' => 'Über grocy',
|
||||||
'Close' => 'Schließen'
|
'Close' => 'Schließen',
|
||||||
|
'#1 batteries are due to be charged within the next #2 days' => '#1 Batterien müssen in den nächsten #2 Tagen geladen werden',
|
||||||
|
'#1 batteries are overdue to be charged' => '#1 Batterien sind überfällig',
|
||||||
|
'#1 habits are due to be done within the next #2 days' => '#1 Gewohnheiten stehen in den nächsten #2 Tagen an',
|
||||||
|
'#1 habits are overdue to be done' => '#1 Gewohnheiten sind überfällig'
|
||||||
);
|
);
|
||||||
|
@ -26,7 +26,7 @@ class BatteriesService extends BaseService
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return date('Y-m-d H:i:s');
|
return date('2999-12-31 23:59:59');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -26,7 +26,7 @@ class HabitsService extends BaseService
|
|||||||
switch($habit->period_type)
|
switch($habit->period_type)
|
||||||
{
|
{
|
||||||
case self::HABIT_TYPE_MANUALLY:
|
case self::HABIT_TYPE_MANUALLY:
|
||||||
return date('Y-m-d H:i:s');
|
return date('2999-12-31 23:59:59');
|
||||||
case self::HABIT_TYPE_DYNAMIC_REGULAR:
|
case self::HABIT_TYPE_DYNAMIC_REGULAR:
|
||||||
return date('Y-m-d H:i:s', strtotime('+' . $habit->period_days . ' day', strtotime($habitLastLogRow->last_tracked_time)));
|
return date('Y-m-d H:i:s', strtotime('+' . $habit->period_days . ' day', strtotime($habitLastLogRow->last_tracked_time)));
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,15 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<h1 class="page-header">@yield('title')</h1>
|
<h1 class="page-header">@yield('title')</h1>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<p class="btn btn-lg btn-warning no-real-button">{{ $L('#1 batteries are due to be charged within the next #2 days', $countDueNextXDays, $nextXDays) }}</p>
|
||||||
|
<p class="btn btn-lg btn-danger no-real-button">{{ $L('#1 batteries are overdue to be charged', $countOverdue) }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="discrete-content-separator-2x"></div>
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="batteries-overview-table" class="table table-striped">
|
<table id="batteries-overview-table" class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -7,6 +7,15 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<h1 class="page-header">@yield('title')</h1>
|
<h1 class="page-header">@yield('title')</h1>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<p class="btn btn-lg btn-warning no-real-button">{{ $L('#1 habits are due to be done within the next #2 days', $countDueNextXDays, $nextXDays) }}</p>
|
||||||
|
<p class="btn btn-lg btn-danger no-real-button">{{ $L('#1 habits are overdue to be done', $countOverdue) }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="discrete-content-separator-2x"></div>
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="habits-overview-table" class="table table-striped">
|
<table id="habits-overview-table" class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p class="btn btn-lg btn-warning no-real-button">{{ $L('#1 products expiring within the next #2 days', count(FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d', strtotime('+5 days')), '<')), 5) }}</p>
|
<p class="btn btn-lg btn-warning no-real-button">{{ $L('#1 products expiring within the next #2 days', $countExpiringNextXDays, $nextXDays) }}</p>
|
||||||
<p class="btn btn-lg btn-danger no-real-button">{{ $L('#1 products are already expired', count(FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d', strtotime('-1 days')), '<'))) }}</p>
|
<p class="btn btn-lg btn-danger no-real-button">{{ $L('#1 products are already expired', $countAlreadyExpired) }}</p>
|
||||||
<p class="btn btn-lg btn-info no-real-button">{{ $L('#1 products are below defined min. stock amount', count($missingProducts)) }}</p>
|
<p class="btn btn-lg btn-info no-real-button">{{ $L('#1 products are below defined min. stock amount', count($missingProducts)) }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user