45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
// last execution: 2026-08-28 08:00:01
|
|
$jobs = entity\getMany('Script', 100, 'name', 'asc', 'type=', 'job');
|
|
|
|
logAdd(log);
|
|
html = '';
|
|
|
|
logAdd(log, 'info', 'Mailen laatste taken logs');
|
|
|
|
$html = "";
|
|
|
|
$i = 0;
|
|
$n = array\length($jobs);
|
|
while($i < $n,
|
|
$job = array\at($jobs, $i);
|
|
$log = attr($job, 'log');
|
|
|
|
$name = attr($job, 'name');
|
|
$last_exec = datetime\format(attr($job, 'lastexec'), 'Europe/Amsterdam', 'DD/MM/YYYY HH:mm:ss');
|
|
|
|
strAdd($html, '<h3>', $name, '</h3>');
|
|
strAdd($html, '<p>', 'Laatste uitvoering: ', $last_exec, '</p>');
|
|
|
|
$html = string\concatenate($html, '<table><tbody>', $log, '</tbody></table>');
|
|
|
|
$i = $i + 1;
|
|
);
|
|
|
|
$body = emailTemplate;
|
|
$body = string\replace($body, '{{log}}', $html);
|
|
$dt = datetime\format(datetime\now(), 'Europe/Amsterdam', 'DD/MM/YYYY');
|
|
$subject = string\concatenate('NVKH Crm - Job Verslag - ', $dt);
|
|
$userId = env\userAttribute('id');
|
|
$mailadr = configGet('job-report-mail-address');
|
|
|
|
$emailId = record\create('Email', 'subject', $subject,
|
|
'body', $body,
|
|
'to', $mailadr,
|
|
'assignedUser', $userId,
|
|
'isUser', true,
|
|
'parentType', 'Script',
|
|
'parentId', id
|
|
);
|
|
ext\email\send($emailId);
|
|
|
|
logAdd(log, 'info', 'Mail gestuurd naar ', $mailadr); |