fix: [appTable:table_statistics] Compute timeline only if the fields exist in the DB schema
parent
f3813dd5a7
commit
e6ec31ff23
|
@ -94,8 +94,12 @@ class AppTable extends Table
|
||||||
{
|
{
|
||||||
$statistics = [];
|
$statistics = [];
|
||||||
if ($table->hasBehavior('Timestamp')) {
|
if ($table->hasBehavior('Timestamp')) {
|
||||||
$statistics['created'] = $this->getActivityStatistic($table, $days, 'created');
|
if ($table->getSchema()->getColumnType('created') == 'datetime') {
|
||||||
$statistics['modified'] = $this->getActivityStatistic($table, $days, 'modified');
|
$statistics['created'] = $this->getActivityStatistic($table, $days, 'created');
|
||||||
|
}
|
||||||
|
if ($table->getSchema()->getColumnType('modified') == 'datetime') {
|
||||||
|
$statistics['modified'] = $this->getActivityStatistic($table, $days, 'modified');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $statistics;
|
return $statistics;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +136,7 @@ class AppTable extends Table
|
||||||
->where(["{$field} >" => new \DateTime("-{$days} days")])
|
->where(["{$field} >" => new \DateTime("-{$days} days")])
|
||||||
->group(['date'])
|
->group(['date'])
|
||||||
->order(['date']);
|
->order(['date']);
|
||||||
$data = $query->toArray();
|
$data = $query->all()->toArray();
|
||||||
$interval = new \DateInterval('P1D');
|
$interval = new \DateInterval('P1D');
|
||||||
$period = new \DatePeriod(new \DateTime("-{$days} days"), $interval, (new \DateTime())->modify( '+1 day' ));
|
$period = new \DatePeriod(new \DateTime("-{$days} days"), $interval, (new \DateTime())->modify( '+1 day' ));
|
||||||
foreach ($period as $date) {
|
foreach ($period as $date) {
|
||||||
|
|
|
@ -43,18 +43,19 @@ $panelControlHtml = sprintf(
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
$activityNumbers = sprintf(
|
$createdNumber = empty($timeline['created']) ? '' : sprintf(
|
||||||
'<div class="my-1 fs-5">
|
'<div class="lh-1 d-flex align-items-center" title="%s">%s<span class="ms-1"> %s</span></div>',
|
||||||
<div class="lh-1 d-flex align-items-center" title="%s">%s<span class="ms-1"> %s</span></div>
|
|
||||||
<div class="lh-1 d-flex align-items-center" title="%s">%s<span class="ms-1">%s</span></div>
|
|
||||||
</div>',
|
|
||||||
__('{0} Created', $timeline['created']['variation']),
|
__('{0} Created', $timeline['created']['variation']),
|
||||||
$this->Bootstrap->icon('plus', ['class' => ['fa-fw'], 'params' => ['style' => 'font-size: 60%;']]),
|
$this->Bootstrap->icon('plus', ['class' => ['fa-fw'], 'params' => ['style' => 'font-size: 60%;']]),
|
||||||
$timeline['created']['variation'],
|
$timeline['created']['variation']
|
||||||
|
);
|
||||||
|
$modifiedNumber = empty($timeline['modified']) ? '' : sprintf(
|
||||||
|
'<div class="lh-1 d-flex align-items-center" title="%s">%s<span class="ms-1"> %s</span></div>',
|
||||||
__('{0} Modified', $timeline['modified']['variation']),
|
__('{0} Modified', $timeline['modified']['variation']),
|
||||||
$this->Bootstrap->icon('edit', ['class' => ['fa-fw'], 'params' => ['style' => 'font-size: 60%;']]),
|
$this->Bootstrap->icon('edit', ['class' => ['fa-fw'], 'params' => ['style' => 'font-size: 60%;']]),
|
||||||
$timeline['modified']['variation']
|
$timeline['modified']['variation']
|
||||||
);
|
);
|
||||||
|
$activityNumbers = sprintf('<div class="my-1 fs-5">%s%s</div>', $createdNumber, $modifiedNumber);
|
||||||
|
|
||||||
$leftContent = sprintf(
|
$leftContent = sprintf(
|
||||||
'%s%s',
|
'%s%s',
|
||||||
|
|
Loading…
Reference in New Issue