This commit is contained in:
2026-08-28 12:27:35 +02:00
parent bfeff94be7
commit 45e62fda5f
178 changed files with 10 additions and 7257 deletions
@@ -1,96 +0,0 @@
// last execution: 2021-06-10 04:17:02
$today = datetime\today();
$before_yesterday = datetime\addDays($today, -2);
$updates = record\fetchManyHash('Ledenupdates',
'id, name, type, contactId, createdAt, description',
'createdAt', 'desc',
'createdAt<', $today,
'createdAt>', $before_yesterday
);
logAdd(log);
html = '';
$n_updates = array\length($updates);
logAdd(log, 'info', 'Updates door leden voor de dag tussen = ', $before_yesterday, ' en ', $today);
logAdd(log, 'info', $n_updates, ' updates door leden gisteren.');
$h_leden = Hash\New();
$i = 0;
while($i < $n_updates,
$row = array\at($updates, $i);
$name = hash\get($row, 'name');
$contact_id = hash\get($row, 'contactId');
$created_at = datetime\format(hash\get($row, 'createdAt'), 'Europe/Amsterdam', 'DD-MM-YYYY HH:mm');
$opm = hash\get($row, 'description');
$opm = string\replace($opm, '```', '');
$opm = string\replace($opm, '\n', '<br>');
ifThenElse(Hash\IsSet($h_leden, $contact_id),
$tbl = hash\get($h_leden, $contact_id);
,
$contact = entity\get('Contact', $contact_id);
$c_name = attr($contact, 'name');
$tbl = string\concatenate('<tr><th style="text-align:left;background:#85e880;" colspan="3">', $c_name, '</th></tr>');
);
strAdd($tbl, '<tr>');
strAdd($tbl, '<td style="width:15%;border: 1px solid black;vertical-align: top;">', $name, '</td>',
'<td style="width:10%;border: 1px solid black;vertical-align: top;">', $created_at, '</td>',
'<td style="font-family: courier;width:75%; border: 1px solid black;vertical-align: top;">', $opm, '</td>');
strAdd($tbl, '</tr>');
$h_leden = Hash\Set($h_leden, $contact_id, $tbl);
$i = $i + 1;
);
$keys = hash\keys($h_leden);
$n = array\length($keys);
logAdd(log, 'info', 'aantal contacten:', $n);
$html = '<table style="font-size: 8pt;width:90%;border: 1px solid black;border-collapse:collapse;">';
$i = 0;
while($i < $n,
$key = array\at($keys, $i);
$tbl = hash\get($h_leden, $key);
strAdd($html, $tbl);
$i = $i + 1;
);
strAdd($html, '</table>');
ifThenElse($n_updates == 0,
logAdd(log, 'info', 'Geen updates gisteren, niets te versturen.');
,
$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');
$mailadrs = string\matchAll(configGet('job-secretariaat-mail-address'), '/[^, ]+/');
$m = array\length($mailadrs);
logAdd(log, 'Aantal mailadressen secretariaat: ', $m);
$i = 0;
while($i < $m,
$mailadr = array\at($mailadrs, $i);
logAdd(log, 'Mail sturen naar: ', $mailadr);
$i = $i + 1;
$emailId = record\create('Email', 'subject', $subject,
'body', $body,
'to', $mailadr,
'assignedUser', $userId,
'isUser', true,
'parentType', 'Script',
'parentId', id
);
ext\email\send($emailId);
);
);