notification = $notification; } public static function getPlaceholders() { $placeholders = [ 'NOTIFIKACE' => [ 'text' => 'Záznam v activity logu', ], 'NAZEV_NOTIFIKACE' => [ 'text' => 'Název notifikace', ], 'INSTRUKCE' => [ 'text' => 'Instrukce', ], ]; return [self::$type => $placeholders] + (parent::getPlaceholders() ?? []); } public function replacePlaceholdersItem($placeholder) { if ($placeholder == 'NOTIFIKACE') { $smarty = createSmarty(true, true); $smarty->assign('report_notification', $this->notification); return $smarty->fetch('email/email_activity_log_notifications.tpl'); } if ($placeholder == 'NAZEV_NOTIFIKACE') { return $this->notification['notification']['name']; } if ($placeholder == 'INSTRUKCE') { return nl2br($this->notification['notification']['note']); } return parent::replacePlaceholdersItem($placeholder); } public function renderEmail($message, $data = [], $base_template = 'admin.tpl'): array { return parent::renderEmail($message, $data, $base_template); } public function testEmail(): array { if ($notification = sqlQueryBuilder()->select('*')->from('report_activities_notifications') ->orderBy('RAND()')->setMaxResults(1)->execute()->fetchAllAssociative()) { $notification = reset($notification); if ($reportActivities = sqlQueryBuilder()->select('*')->from('report_activities')->setMaxResults(5)->orderBy('date', 'DESC')->execute()->fetchAllAssociative() ?? false) { $reportActivitiesTmp = []; foreach ($reportActivities as $reportActivity) { $reportActivity['url'] = getAdminUrl('reportActivities', [ 'acn' => 'edit', 'ID' => $reportActivity['id'], ], true); $reportActivity['severity_index'] = $reportActivity['severity']; $reportActivity['severity'] = (!empty($reportActivity['severity'])) ? translate('severity_'.$reportActivity['severity'], 'reportActivities', isAdministration: true) : ''; $reportActivity['type'] = (!empty($reportActivity['type'])) ? translate('type_'.$reportActivity['type'], 'reportActivities', isAdministration: true) : ''; $reportActivitiesTmp[] = $reportActivity; } $notification['last_sync'] = now()->format('Y-m-d H:i:s'); $this->setNotification(['report_activities' => $reportActivitiesTmp, 'notification' => $notification]); } } return parent::testEmail(); } }