scripts in de database
This commit is contained in:
@@ -0,0 +1,262 @@
|
||||
// last execution: Thu Oct 30 2025 11:02:46 GMT+0100 (Midden-Europese standaardtijd)
|
||||
|
||||
$par_Aantal_jaren_totdat_er_een_nieuwe_visitatie_nodig_is=5;
|
||||
$par_Inventariseren_voor_het_jaar=2026;
|
||||
$par_Alleen_de_leden_die_gevisiteerd_moeten_worden=true;
|
||||
$par_Aantal_regels_per_pagina=11;
|
||||
$par_Maak_visitatie_record_aan_voor_te_visiteren_leden=true;
|
||||
$par_Open_lid_in_nieuwe_tab_bij_klik=false;
|
||||
|
||||
// Omzetten parameters
|
||||
$p_new_tab = $par_Open_lid_in_nieuwe_tab_bij_klik;
|
||||
$p_years=$par_Aantal_jaren_totdat_er_een_nieuwe_visitatie_nodig_is;
|
||||
$c_year = $par_Inventariseren_voor_het_jaar;
|
||||
$alleen_visiteerbaar = $par_Alleen_de_leden_die_gevisiteerd_moeten_worden;
|
||||
$p_make_record = $par_Maak_visitatie_record_aan_voor_te_visiteren_leden;
|
||||
|
||||
// Script runnen
|
||||
|
||||
$limit_year = $c_year - $p_years;
|
||||
|
||||
html = '';
|
||||
logAdd(log);
|
||||
|
||||
$p_page_len = $par_Aantal_regels_per_pagina;
|
||||
|
||||
$entities = record\fetchManyHash('Contact',
|
||||
'id, agbcode, name, emailAddress, regiocode, lidnummer, phoneNumber',
|
||||
'lastName', 'asc'
|
||||
);
|
||||
|
||||
$n = array\length($entities);
|
||||
logAdd(log, 'Aantal te beoordelen (ex)leden: ', $n);
|
||||
logAdd(log, 'info', 'Visitatierecords aanmaken: ', $p_make_record);
|
||||
|
||||
$aantal_te_visiteren = 0;
|
||||
$aantal_ongevisiteerd = 0;
|
||||
$aantal_gevisiteerd = 0;
|
||||
$aantal_visitatie_records = 0;
|
||||
|
||||
$h = '';
|
||||
|
||||
$table = table\new('Naam', 30, 'left',
|
||||
'eMail', 20, 'ellipsis',
|
||||
'telefoon', 10, 'center',
|
||||
'Lidnummer', 5, 'center',
|
||||
'Regiocode', 3, 'center',
|
||||
'Laatste visitatie', 7, 'center',
|
||||
'Visiteren', 7, 'center',
|
||||
'Praktijknaam', 10, 'center',
|
||||
'Adres', 10, 'center',
|
||||
'Postcode', 10, 'center',
|
||||
'Plaats', 10, 'center'
|
||||
);
|
||||
table\rowsPerPage($table, $p_page_len);
|
||||
|
||||
$i = 0;
|
||||
while($i < $n,
|
||||
$e = array\at($entities, $i);
|
||||
|
||||
$regiocode = hash\get($e, 'regiocode');
|
||||
$achternaam = hash\get($e, 'lastName');
|
||||
$lidnummer = hash\get($e, 'lidnummer');
|
||||
$id = hash\get($e, 'id');
|
||||
$contact_id = $id;
|
||||
$regiocode_nr = string\substring($regiocode, 0, 2) + 0;
|
||||
$meenemen = $regiocode_nr < 30;
|
||||
|
||||
ifThen($meenemen,
|
||||
$visitatie_id = record\findRelatedOne('Contact', $id, 'visitatiesRec', 'visitatiedatum', 'desc');
|
||||
|
||||
ifThenElse($visitatie_id,
|
||||
$v_datum = record\attribute('Visitatie', $visitatie_id, 'visitatiedatum');
|
||||
log('warning', $achternaam, ' - lidnummer = ', $lidnummer, ' - v_datum = "', $v_datum, '" - visitatie_id = ', $visitatie_id);
|
||||
ifThen($v_datum == '', $v_datum = null);
|
||||
,
|
||||
$v_datum = null;
|
||||
);
|
||||
|
||||
log('warning', $achternaam, ' - lidnummer = ', $lidnummer, ' - v_datum = "', $v_datum, '"');
|
||||
ifThenElse($v_datum == null, log('warning', 'null!'));
|
||||
|
||||
ifThenElse($v_datum == null,
|
||||
$visiteren = 'ja';
|
||||
$aantal_ongevisiteerd = $aantal_ongevisiteerd + 1;
|
||||
,
|
||||
$y = datetime\year($v_datum);
|
||||
ifThenElse($y <= $limit_year,
|
||||
$visiteren = 'ja';
|
||||
$aantal_te_visiteren = $aantal_te_visiteren + 1;
|
||||
,
|
||||
$visiteren = 'nee';
|
||||
$aantal_gevisiteerd = $aantal_gevisiteerd + 1;
|
||||
);
|
||||
);
|
||||
|
||||
ifThen($visiteren == 'ja',
|
||||
ifThen($p_make_record,
|
||||
$visitatie_te_visiteren = record\findRelatedOne('Contact', $id, 'visitatiesRec',
|
||||
'visitatiedatum', 'desc',
|
||||
'resultaat', '-'
|
||||
);
|
||||
ifThenElse($visitatie_te_visiteren,
|
||||
$maken = false;
|
||||
,
|
||||
$maken = true;
|
||||
);
|
||||
|
||||
log('warning', 'maken=', $maken);
|
||||
|
||||
ifThen($maken,
|
||||
log('warning', 'contact: ', $id, ', lidnummer:', $lidnummer);
|
||||
$rec_id = record\create('Visitatie', 'contact', $id, 'resultaat', '-', 'lidnummer', $lidnummer);
|
||||
log('warning', 'contact: ', $id, 'rec_id: ', $rec_id);
|
||||
record\relate('Contact', $id, 'visitatiesRec', $rec_id);
|
||||
$aantal_visitatie_records = $aantal_visitatie_records + 1;
|
||||
record\recalculate('Visitatie', 'id=', $rec_id);
|
||||
);
|
||||
|
||||
log('warning', 'maken=', $maken, ' - 1');
|
||||
|
||||
);
|
||||
);
|
||||
|
||||
$report = true;
|
||||
|
||||
ifThen($visiteren == 'nee', $report = !$alleen_visiteerbaar;);
|
||||
|
||||
log('warning', $achternaam, ' - 1');
|
||||
|
||||
ifThen($report,
|
||||
$naam = hash\get($e, 'name');
|
||||
$email = hash\get($e, 'emailAddress');
|
||||
$tel = hash\get($e, 'phoneNumber');
|
||||
$lidnummer = hash\get($e, 'lidnummer');
|
||||
|
||||
log('warning', $achternaam, ' - 2');
|
||||
|
||||
$contact = entity\get('Contact', $contact_id);
|
||||
$p1s = entity\getRelated($contact, 'accounts', 1, 'name', 'asc', 'type=', 'P1');
|
||||
ifThenElse(array\length($p1s) == 1, $p1 = array\at($p1s, 0), $p1 = null);
|
||||
$p2s = entity\getRelated($contact, 'accounts', 1, 'name', 'asc', 'type=', 'P2');
|
||||
ifThenElse(array\length($p2s) == 1, $p2 = array\at($p2s, 0), $p2 = null);
|
||||
$p3s = entity\getRelated($contact, 'accounts', 1, 'name', 'asc', 'type=', 'P3');
|
||||
ifThenElse(array\length($p3s) == 1, $p3 = array\at($p3s, 0), $p3 = null);
|
||||
|
||||
log('warning', $achternaam, ' - 3');
|
||||
|
||||
ifThenElse($p1,
|
||||
$p1_name = attr($p1, 'naam');
|
||||
$p1_straat = attr($p1, 'shippingAddressStreet');
|
||||
$p1_postcode = attr($p1, 'shippingAddressPostalCode');
|
||||
$p1_plaats = attr($p1, 'shippingAddressCity');
|
||||
$p1_land = attr($p1, 'shippngAddressCountry');
|
||||
$p1_email = attr($p1, 'emailAddress');
|
||||
$p1_phone = attr($p1, 'phoneNumber');
|
||||
$p1_website = attr($p1, 'website');
|
||||
$p1_op_internet = attr($p1, 'opInternet');
|
||||
$p1_agbcode = attr($p1, 'agbcode');
|
||||
,
|
||||
$p1_name = '';
|
||||
$p1_straat = '';
|
||||
$p1_postcode = '';
|
||||
$p1_plaats = '';
|
||||
$p1_land = '';
|
||||
$p1_email = '';
|
||||
$p1_phone = '';
|
||||
$p1_website = '';
|
||||
$p1_op_internet = '';
|
||||
$p1_agbcode = '';
|
||||
);
|
||||
|
||||
ifThenElse($p2,
|
||||
$p2_name = attr($p2, 'naam');
|
||||
$p2_straat = attr($p2, 'shippingAddressStreet');
|
||||
$p2_postcode = attr($p2, 'shippingAddressPostalCode');
|
||||
$p2_plaats = attr($p2, 'shippingAddressCity');
|
||||
$p2_land = attr($p2, 'shippngAddressCountry');
|
||||
$p2_email = attr($p2, 'emailAddress');
|
||||
$p2_phone = attr($p2, 'phoneNumber');
|
||||
$p2_website = attr($p2, 'website');
|
||||
$p2_op_internet = attr($p2, 'opInternet');
|
||||
$p2_agbcode = attr($p2, 'agbcode');
|
||||
,
|
||||
$p2_name = '';
|
||||
$p2_straat = '';
|
||||
$p2_postcode = '';
|
||||
$p2_plaats = '';
|
||||
$p2_land = '';
|
||||
$p2_email = '';
|
||||
$p2_phone = '';
|
||||
$p2_website = '';
|
||||
$p2_op_internet = '';
|
||||
$p2_agbcode = '';
|
||||
);
|
||||
|
||||
ifThenElse($p3,
|
||||
$p3_name = attr($p3, 'naam');
|
||||
$p3_straat = attr($p3, 'shippingAddressStreet');
|
||||
$p3_postcode = attr($p3, 'shippingAddressPostalCode');
|
||||
$p3_plaats = attr($p3, 'shippingAddressCity');
|
||||
$p3_land = attr($p3, 'shippngAddressCountry');
|
||||
$p3_email = attr($p3, 'emailAddress');
|
||||
$p3_phone = attr($p3, 'phoneNumber');
|
||||
$p3_website = attr($p3, 'website');
|
||||
$p3_op_internet = attr($p3, 'opInternet');
|
||||
$p3_agbcode = attr($p3, 'agbcode');
|
||||
,
|
||||
$p3_name = '';
|
||||
$p3_straat = '';
|
||||
$p3_postcode = '';
|
||||
$p3_plaats = '';
|
||||
$p3_land = '';
|
||||
$p3_email = '';
|
||||
$p3_phone = '';
|
||||
$p3_website = '';
|
||||
$p3_op_internet = '';
|
||||
$p3_agbcode = '';
|
||||
);
|
||||
|
||||
log('warning', $achternaam, ' - 4');
|
||||
|
||||
|
||||
ifThenElse($p_new_tab,
|
||||
$target = '_blank';
|
||||
,
|
||||
$target = "";
|
||||
);
|
||||
|
||||
table\add($table,
|
||||
table\link(string\concatenate('/#Contact/view/', $id), $naam, $target),
|
||||
$email,
|
||||
$tel,
|
||||
$lidnummer,
|
||||
$regiocode,
|
||||
$v_datum,
|
||||
$visiteren,
|
||||
$p1_name, $p1_straat, $p1_postcode, $p1_plaats
|
||||
);
|
||||
ifThen($p2_name != '',
|
||||
table\add($table, '', '', '', '', '', '', '', $p2_name, $p2_straat, $p2_postcode, $p2_plaats);
|
||||
);
|
||||
ifThen($p3_name != '',
|
||||
table\add($table, '', '', '', '', '', '', '', $p3_name, $p3_straat, $p3_postcode, $p3_plaats);
|
||||
);
|
||||
);
|
||||
);
|
||||
|
||||
$i = $i + 1;
|
||||
);
|
||||
|
||||
|
||||
strAdd($h, table\toHtml($table));
|
||||
strAdd($h, '</div>');
|
||||
|
||||
html=$h;
|
||||
|
||||
logAdd(log, 'info', 'Aantal leden zonder visitatiedatum: ', $aantal_ongevisiteerd);
|
||||
logAdd(log, 'info', 'Aantal leden met visitatiedatum langer dan ', $p_years, ' jaar geleden: ', $aantal_te_visiteren);
|
||||
logAdd(log, 'info', 'Aantal recent gevisiteerde leden: ', $aantal_gevisiteerd);
|
||||
ifThen($p_make_record,
|
||||
logAdd(log, 'info', 'Aantal aangemaakte visitatierecords: ', $aantal_visitatie_records);
|
||||
);
|
||||
Reference in New Issue
Block a user