scripts added
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// last execution: 2026-08-28 03:00:01
|
||||
logAdd(log);
|
||||
|
||||
$entities = Entity\GetMany('TargetList', 1, 'name', 'asc', 'name=', 'Homeopaten');
|
||||
$n = array\length($entities);
|
||||
|
||||
ifThenElse($n == 0,
|
||||
logAdd(log, 'warning', 'Geen "Homeopaten" doellijst, maak deze eerst aan!');
|
||||
,
|
||||
logAdd(log, 'info', 'Homeopaten doellijst aanwezig, leden worden vervangen...');
|
||||
|
||||
$doellijst = array\at($entities, 0);
|
||||
$id = attr($doellijst, 'id');
|
||||
|
||||
logAdd(log, 'info', 'Verwijderen leden met regiocode >=30');
|
||||
$rows = record\fetchRelatedManyHash('TargetList', $id,
|
||||
'contacts', 'id, lastName, regiocode',
|
||||
'lastName', 'asc'
|
||||
);
|
||||
$n = array\length($rows);
|
||||
logAdd(log, 'info', 'Aantal gerelateerde leden: ', $n);
|
||||
$i = 0;
|
||||
$rcnt = 0;
|
||||
while($i < $n,
|
||||
$row = array\at($rows, $i);
|
||||
$code = hash\get($row, 'regiocode') + 0;
|
||||
ifThen($code >= 30,
|
||||
$lastname = hash\get($row, 'lastName');
|
||||
$contact_id = hash\get($row, 'id');
|
||||
logAdd(log, 'info', 'Verwijderen: ', $lastname, '; regiocode=', $code);
|
||||
record\unrelate('TargetList', $id, 'contacts', $contact_id);
|
||||
$rcnt = $rcnt + 1;
|
||||
);
|
||||
$i = $i + 1;
|
||||
);
|
||||
|
||||
logAdd(log, 'info', 'Relateren leden met regiocode <30');
|
||||
$rows = record\fetchManyHash('Contact', 'id, lastName, regiocode', 'lastName', 'asc');
|
||||
$n = array\length($rows);
|
||||
logAdd(log, 'info', 'Aantal leden om te beoordelen: ', $n);
|
||||
$i = 0;
|
||||
$cnt = 0;
|
||||
$hom_cnt = 0;
|
||||
while($i < $n,
|
||||
$row = array\at($rows, $i);
|
||||
$code = hash\get($row, 'regiocode') + 0;
|
||||
ifThen($code < 30,
|
||||
$hom_cnt = $hom_cnt + 1;
|
||||
$contact_id = hash\get($row, 'id');
|
||||
$r_id = record\findRelatedMany('TargetList', $id,
|
||||
'contacts', 1, 'createdAt', 'desc',
|
||||
'id=', $contact_id
|
||||
);
|
||||
ifThen(!$r_id,
|
||||
$lastname = hash\get($row, 'lastName');
|
||||
logAdd(log, 'info', 'Toevoegen lid: ', $lastname);
|
||||
record\relate('TargetList', $id, 'contacts', $contact_id);
|
||||
$cnt = $cnt + 1;
|
||||
);
|
||||
);
|
||||
$i = $i + 1;
|
||||
);
|
||||
logAdd(log, 'info', $cnt, ' leden toegevoegd');
|
||||
logAdd(log, 'info', $rcnt, ' leden verwijderd');
|
||||
logAdd(log, 'info', $hom_cnt, ' leden in de lijst');
|
||||
);
|
||||
Reference in New Issue
Block a user