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