bijwerken toevoegen geplande taak

This commit is contained in:
ErikHommel 2022-01-28 12:14:02 +01:00
parent 132e9f135e
commit 1e68031968
2 changed files with 4 additions and 22 deletions

View File

@ -16,10 +16,11 @@ class CRM_Bij1migratie_Lidnummer {
* @return array
*/
public function genereer() {
$lid = new CRM_Bij1algemeen_Lid();
$sylvanaId = $this->vindSylvana();
// selecteer iedereen met een inschrijfdatum (behalve Sylvana)
if ($sylvanaId) {
$this->bewaar($sylvanaId, 1);
$lid->bewaar($sylvanaId, 1);
$query = "SELECT entity_id AS contact_id
FROM civicrm_value_airtable_data
WHERE entity_id != %1 AND inschrijvingsdatum IS NOT NULL
@ -35,7 +36,7 @@ class CRM_Bij1migratie_Lidnummer {
$maxLid = (int) Civi::settings()->get('bij1_laatste_lidnummer');
while ($contact->fetch()) {
$maxLid++;
$this->bewaar((int) $contact->contact_id, $maxLid);
$lid->bewaar((int) $contact->contact_id, $maxLid);
}
Civi::settings()->set("bij1_laatste_lidnummer", $maxLid);
}
@ -66,23 +67,4 @@ class CRM_Bij1migratie_Lidnummer {
return FALSE;
}
/**
* Method om lidnummer te bewaren bij contact
*/
public function bewaar(int $contactId, int $lidNummer) {
$countQuery = "SELECT COUNT(*) FROM civicrm_value_lid_data WHERE entity_id = %1";
$count = CRM_Core_DAO::singleValueQuery($countQuery, [1 => [$contactId, "Integer"]]);
if ($count == 0) {
$bijwerken = "INSERT INTO civicrm_value_lid_data (entity_id, lidnummer) VALUES(%1, %2)";
}
else {
$bijwerken = "UPDATE civicrm_value_lid_data SET lidnummer = %2 WHERE entity_id = %1";
}
$bijwerkenParams = [
1 => [$contactId, "Integer"],
2 => [$lidNummer, "Integer"],
];
CRM_Core_DAO::executeQuery($bijwerken, $bijwerkenParams);
}
}

View File

@ -53,7 +53,7 @@ class CRM_Bij1migratie_Upgrader extends CRM_Bij1migratie_Upgrader_Base {
2 => ["Yearly", "String"],
3 => ["BIJ1 Genereer lidnummers gelijk na migratie", "String"],
4 => ["Deze taak genereert nieuwe lidnummers op basis van inschrijvingsdatum", "String"],
5 => ["Lidnummer", "String"],
5 => ["LidNummer", "String"],
6 => ["genereer", "String"],
7 => [0, "Integer"],
]);