comment unused methods

This commit is contained in:
Kiara Grouwstra 2022-10-15 18:58:26 +02:00
parent 32749a9aec
commit 891431f19e
5 changed files with 189 additions and 219 deletions

View File

@ -1,26 +1,26 @@
<?php
use CRM_Bij1migratie_ExtensionUtil as E;
class CRM_Bij1migratie_BAO_MigratieLog extends CRM_Bij1migratie_DAO_MigratieLog {
// class CRM_Bij1migratie_BAO_MigratieLog extends CRM_Bij1migratie_DAO_MigratieLog {
/**
* Create a new MigratieLog based on array-data
*
* @param array $params key-value pairs
* @return CRM_Bij1migratie_DAO_MigratieLog|NULL
*
public static function create($params) {
$className = 'CRM_Bij1migratie_DAO_MigratieLog';
$entityName = 'MigratieLog';
$hook = empty($params['id']) ? 'create' : 'edit';
// /**
// * Create a new MigratieLog based on array-data
// *
// * @param array $params key-value pairs
// * @return CRM_Bij1migratie_DAO_MigratieLog|NULL
// */
// public static function create($params) {
// $className = 'CRM_Bij1migratie_DAO_MigratieLog';
// $entityName = 'MigratieLog';
// $hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
// CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
// $instance = new $className();
// $instance->copyValues($params);
// $instance->save();
// CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
return $instance;
} */
// return $instance;
// }
}
// }

View File

@ -312,72 +312,42 @@ class CRM_Bij1migratie_Migratie {
return FALSE;
}
/**
* Method om te bepalen of de persoon al bestaat
*
* @param int $ssaskiaNummer
* @return bool
*/
public static function bestaatPersoon(int $ssaskiaNummer) {
$query = "SELECT COUNT(*) FROM civicrm_value_pax_contact_data WHERE ssaskia_nummer = %1";
$count = CRM_Core_DAO::singleValueQuery($query, [1 => [$ssaskiaNummer, "Integer"]]);
if ($count > 0) {
return TRUE;
}
return FALSE;
}
// /**
// * Method om te bepalen of de persoon al bestaat
// *
// * @param int $ssaskiaNummer
// * @return bool
// */
// public static function bestaatPersoon(int $ssaskiaNummer) {
// $query = "SELECT COUNT(*) FROM civicrm_value_pax_contact_data WHERE ssaskia_nummer = %1";
// $count = CRM_Core_DAO::singleValueQuery($query, [1 => [$ssaskiaNummer, "Integer"]]);
// if ($count > 0) {
// return TRUE;
// }
// return FALSE;
// }
/**
* Method om migratie groep aan te maken
*/
public function maakMigratieGroepen() {
$query = "SELECT COUNT(*) FROM civicrm_group WHERE name = %1";
$count = CRM_Core_DAO::singleValueQuery($query, [1 => ["pax_migratie_groep", "String"]]);
if ($count == 0) {
try {
\Civi\Api4\Group::create()
->addValue('name', 'pax_migratie_groep')
->addValue('title', 'CiviCRM Migratie')
->addValue('description', 'Groep met personen en organisaties die tijdens de migratie aangemaakt werden')
->addValue('is_active', TRUE)
->addValue('is_reserved', TRUE)
->execute();
}
catch (API_Exception $ex) {
Civi::log()->error(E::ts("Kon geen groep voor migratie aanmaken, fout van API4 Group create: ") . $ex->getMessage());
}
}
$count = CRM_Core_DAO::singleValueQuery($query, [1 => ["pax_dm_mag", "String"]]);
if ($count == 0) {
try {
\Civi\Api4\Group::create()
->addValue('name', 'pax_dm_mag')
->addValue('title', 'DM Mag')
->addValue('description', 'Groep van personen die in sSaskia de vlag DM mag aan hadden staan')
->addValue('is_active', TRUE)
->addValue('is_reserved', TRUE)
->execute();
}
catch (API_Exception $ex) {
Civi::log()->error(E::ts("Kon geen groep voor dm mag aanmaken, fout van API4 Group create: ") . $ex->getMessage());
}
}
$count = CRM_Core_DAO::singleValueQuery($query, [1 => ["pax_post_mag", "String"]]);
if ($count == 0) {
try {
\Civi\Api4\Group::create()
->addValue('name', 'pax_post_mag')
->addValue('title', 'Post Mag')
->addValue('description', 'Groep van personen die in sSaskia de vlag post mag aan hadden staan')
->addValue('is_active', TRUE)
->addValue('is_reserved', TRUE)
->execute();
}
catch (API_Exception $ex) {
Civi::log()->error(E::ts("Kon geen groep voor post mag aanmaken, fout van API4 Group create: ") . $ex->getMessage());
}
}
}
// /**
// * Method om migratie groep aan te maken
// */
// public function maakMigratieGroepen() {
// $query = "SELECT COUNT(*) FROM civicrm_group WHERE name = %1";
// $count = CRM_Core_DAO::singleValueQuery($query, [1 => ["pax_migratie_groep", "String"]]);
// if ($count == 0) {
// try {
// \Civi\Api4\Group::create()
// ->addValue('name', 'pax_migratie_groep')
// ->addValue('title', 'CiviCRM Migratie')
// ->addValue('description', 'Groep met personen en organisaties die tijdens de migratie aangemaakt werden')
// ->addValue('is_active', TRUE)
// ->addValue('is_reserved', TRUE)
// ->execute();
// }
// catch (API_Exception $ex) {
// Civi::log()->error(E::ts("Kon geen groep voor migratie aanmaken, fout van API4 Group create: ") . $ex->getMessage());
// }
// }
// }
/**
* Method om bankrekening toe te voegen

View File

@ -1,73 +1,73 @@
<?php
use CRM_Bij1migratie_ExtensionUtil as E;
/**
* Lid.Indelen API specification (optional)
* This is used for documentation and validation.
*
* @param array $spec description of fields supported by this API call
*/
function _civicrm_api3_lid_Indelen_spec(&$spec) {
$spec['min']['api_required'] = 1;
}
// /**
// * Lid.Indelen API specification (optional)
// * This is used for documentation and validation.
// *
// * @param array $spec description of fields supported by this API call
// */
// function _civicrm_api3_lid_Indelen_spec(&$spec) {
// $spec['min']['api_required'] = 1;
// }
/**
* Lid.Indelen API
* Haal alle contacten die een bijdrage hebben en:
* - bekijk of ze het basisbedrag betaald hebben in 2021, zo ja zet in standaard leden en haal uit nieuwe leden
* - zo nee:
* - zet in ex-leden als ze helemaal geen betalingen in 2021 hebben
* - zet in groep nog in te delen leden als ze wel in 2021 betaald hebben
* - haal ze uit nieuwe leden
*
* @param array $params
*
* @return array
* API result descriptor
*
* @see civicrm_api3_create_success
*
* @throws API_Exception
*/
function civicrm_api3_lid_Indelen($params) {
$min = (int) $params['min'];
$vanDatum = new DateTime('2021-01-01');
$totDatum = new DateTime('2021-12-31');
$contact = new CRM_Bij1migratie_Contact();
$groep = new CRM_Bij1algemeen_Groep();
$groepCount = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM civicrm_group WHERE name = %1", [1 => ["bij1_nog_in_te_delen", "String"]]);
if ($groepCount == 0) {
$groep->maakGroep([
'name' => "bij1_nog_in_te_delen",
'title' => "Nog in te delen na migratie",
'description' => "Deze groep bevat alle contacten die betaald hebben waarvan nog geen groepsindeling duidelijk is",
]);
}
$nogInTeDelenGroepId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_group WHERE name = %1", [1 => ["bij1_nog_in_te_delen", "String"]]);
$returnValues = [];
$lid = CRM_Core_DAO::executeQuery("SELECT DISTINCT(contact_id) FROM civicrm_contribution WHERE contact_id >= %1 ORDER BY contact_id LIMIT 1000", [1 => [$min, "Integer"]]);
while ($lid->fetch()) {
$maxContactId = $lid->contact_id;
$inschrijvingsDatum = $contact->haalInschrijvingsDatum((int) $lid->contact_id);
if ($contact->heeftBasisBetaald((int) $lid->contact_id, $vanDatum, $totDatum)) {
$groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getStandaardLedenGroepId(), $vanDatum);
$groep->verwijderUitGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getNieuweLedenGroepId(), TRUE);
}
elseif ($contact->heeftRecentBetaald((int) $lid->contact_id)) {
$groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getNieuweLedenGroepId(), $inschrijvingsDatum);
$returnValues[] = $lid->contact_id . " in nieuwe.";
}
elseif ($contact->heeftMislukt((int) $lid->contact_id, $vanDatum, $totDatum)) {
$groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getStandaardLedenGroepId(), $vanDatum);
$groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getBetalingGemistLedenGroepId(), $inschrijvingsDatum);
$groep->verwijderUitGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getNieuweLedenGroepId(), TRUE);
$returnValues[] = $lid->contact_id . " in betaling gemist en standaard.";
}
else {
$groep->plaatsInGroep((int) $lid->contact_id, $nogInTeDelenGroepId);
$groep->verwijderUitGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getNieuweLedenGroepId(), TRUE);
}
}
$returnValues[] = ", de rest in standaard of nog in te delen. Laatste verwerkte contact is " . $maxContactId;
return civicrm_api3_create_success($returnValues, $params, 'Lid', 'Indelen');
}
// /**
// * Lid.Indelen API
// * Haal alle contacten die een bijdrage hebben en:
// * - bekijk of ze het basisbedrag betaald hebben in 2021, zo ja zet in standaard leden en haal uit nieuwe leden
// * - zo nee:
// * - zet in ex-leden als ze helemaal geen betalingen in 2021 hebben
// * - zet in groep nog in te delen leden als ze wel in 2021 betaald hebben
// * - haal ze uit nieuwe leden
// *
// * @param array $params
// *
// * @return array
// * API result descriptor
// *
// * @see civicrm_api3_create_success
// *
// * @throws API_Exception
// */
// function civicrm_api3_lid_Indelen($params) {
// $min = (int) $params['min'];
// $vanDatum = new DateTime('2021-01-01');
// $totDatum = new DateTime('2021-12-31');
// $contact = new CRM_Bij1migratie_Contact();
// $groep = new CRM_Bij1algemeen_Groep();
// $groepCount = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM civicrm_group WHERE name = %1", [1 => ["bij1_nog_in_te_delen", "String"]]);
// if ($groepCount == 0) {
// $groep->maakGroep([
// 'name' => "bij1_nog_in_te_delen",
// 'title' => "Nog in te delen na migratie",
// 'description' => "Deze groep bevat alle contacten die betaald hebben waarvan nog geen groepsindeling duidelijk is",
// ]);
// }
// $nogInTeDelenGroepId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_group WHERE name = %1", [1 => ["bij1_nog_in_te_delen", "String"]]);
// $returnValues = [];
// $lid = CRM_Core_DAO::executeQuery("SELECT DISTINCT(contact_id) FROM civicrm_contribution WHERE contact_id >= %1 ORDER BY contact_id LIMIT 1000", [1 => [$min, "Integer"]]);
// while ($lid->fetch()) {
// $maxContactId = $lid->contact_id;
// $inschrijvingsDatum = $contact->haalInschrijvingsDatum((int) $lid->contact_id);
// if ($contact->heeftBasisBetaald((int) $lid->contact_id, $vanDatum, $totDatum)) {
// $groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getStandaardLedenGroepId(), $vanDatum);
// $groep->verwijderUitGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getNieuweLedenGroepId(), TRUE);
// }
// elseif ($contact->heeftRecentBetaald((int) $lid->contact_id)) {
// $groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getNieuweLedenGroepId(), $inschrijvingsDatum);
// $returnValues[] = $lid->contact_id . " in nieuwe.";
// }
// elseif ($contact->heeftMislukt((int) $lid->contact_id, $vanDatum, $totDatum)) {
// $groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getStandaardLedenGroepId(), $vanDatum);
// $groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getBetalingGemistLedenGroepId(), $inschrijvingsDatum);
// $groep->verwijderUitGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getNieuweLedenGroepId(), TRUE);
// $returnValues[] = $lid->contact_id . " in betaling gemist en standaard.";
// }
// else {
// $groep->plaatsInGroep((int) $lid->contact_id, $nogInTeDelenGroepId);
// $groep->verwijderUitGroep((int) $lid->contact_id, Civi::service('bij1algemeen')->getNieuweLedenGroepId(), TRUE);
// }
// }
// $returnValues[] = ", de rest in standaard of nog in te delen. Laatste verwerkte contact is " . $maxContactId;
// return civicrm_api3_create_success($returnValues, $params, 'Lid', 'Indelen');
// }

View File

@ -1,53 +1,53 @@
<?php
use CRM_Bij1migratie_ExtensionUtil as E;
/**
* LidDatum.Fix API specification (optional)
* This is used for documentation and validation.
*
* @param array $spec description of fields supported by this API call
*/
function _civicrm_api3_lid_datum_Fix_spec(&$spec) {
$spec['min']['api_required'] = 1;
}
// /**
// * LidDatum.Fix API specification (optional)
// * This is used for documentation and validation.
// *
// * @param array $spec description of fields supported by this API call
// */
// function _civicrm_api3_lid_datum_Fix_spec(&$spec) {
// $spec['min']['api_required'] = 1;
// }
/**
* LidDatum.Fix API
* haal contacten met betalingen en check:
* - is inschrijvingsdatum gevuld? zo ja gebruik die
* - als geen inschrijvingsdatum gebruik datum eerste betaling
* - maak inschrijvingsactiviteit aan op die datum en probeer frequentie te bepalen
* - zet ingangsdatum groepslidmaatschap nieuwe leden op de gevonden datum
*
*
* @param array $params
*
* @return array
* API result descriptor
*
* @see civicrm_api3_create_success
* @throws
*/
function civicrm_api3_lid_datum_Fix($params) {
$returnValues = [];
$contact = new CRM_Bij1migratie_Contact();
$activiteit = new CRM_Bij1migratie_Activiteit();
$min = (int) $params['min'];
$lid = CRM_Core_DAO::executeQuery("SELECT DISTINCT(contact_id) FROM civicrm_contribution WHERE contact_id >= %1 ORDER BY contact_id LIMIT 500", [1 => [$min, "Integer"]]);
while ($lid->fetch()) {
$inschrijvingsDatum = $contact->haalInschrijvingsDatum((int) $lid->contact_id);
if ($inschrijvingsDatum) {
$activiteit->maakLidmaatschapsaanvraag((int) $lid->contact_id, $inschrijvingsDatum, $contact->haalFrequentie((int) $lid->contact_id));
$query = "UPDATE civicrm_subscription_history SET date = %1 WHERE contact_id = %2 AND group_id = %3 AND status = %4 AND method = %5";
CRM_Core_DAO::executeQuery($query, [
1 => [$inschrijvingsDatum->format("Y-m-d"), "String"],
2 => [(int) $lid->contact_id, "Integer"],
3 => [Civi::service('bij1algemeen')->getNieuweLedenGroepId(), "Integer"],
4 => ["Added", "String"],
5 => ["API", "String"],
]);
$returnValues[] = "Inschrijvingsdatum bijgewerkt voor contact ID " . $lid->contact_id . " naar " . $inschrijvingsDatum->format("d-m-Y");
}
}
return civicrm_api3_create_success($returnValues, $params, 'LidDatum', 'Fix');
}
// /**
// * LidDatum.Fix API
// * haal contacten met betalingen en check:
// * - is inschrijvingsdatum gevuld? zo ja gebruik die
// * - als geen inschrijvingsdatum gebruik datum eerste betaling
// * - maak inschrijvingsactiviteit aan op die datum en probeer frequentie te bepalen
// * - zet ingangsdatum groepslidmaatschap nieuwe leden op de gevonden datum
// *
// *
// * @param array $params
// *
// * @return array
// * API result descriptor
// *
// * @see civicrm_api3_create_success
// * @throws
// */
// function civicrm_api3_lid_datum_Fix($params) {
// $returnValues = [];
// $contact = new CRM_Bij1migratie_Contact();
// $activiteit = new CRM_Bij1migratie_Activiteit();
// $min = (int) $params['min'];
// $lid = CRM_Core_DAO::executeQuery("SELECT DISTINCT(contact_id) FROM civicrm_contribution WHERE contact_id >= %1 ORDER BY contact_id LIMIT 500", [1 => [$min, "Integer"]]);
// while ($lid->fetch()) {
// $inschrijvingsDatum = $contact->haalInschrijvingsDatum((int) $lid->contact_id);
// if ($inschrijvingsDatum) {
// $activiteit->maakLidmaatschapsaanvraag((int) $lid->contact_id, $inschrijvingsDatum, $contact->haalFrequentie((int) $lid->contact_id));
// $query = "UPDATE civicrm_subscription_history SET date = %1 WHERE contact_id = %2 AND group_id = %3 AND status = %4 AND method = %5";
// CRM_Core_DAO::executeQuery($query, [
// 1 => [$inschrijvingsDatum->format("Y-m-d"), "String"],
// 2 => [(int) $lid->contact_id, "Integer"],
// 3 => [Civi::service('bij1algemeen')->getNieuweLedenGroepId(), "Integer"],
// 4 => ["Added", "String"],
// 5 => ["API", "String"],
// ]);
// $returnValues[] = "Inschrijvingsdatum bijgewerkt voor contact ID " . $lid->contact_id . " naar " . $inschrijvingsDatum->format("d-m-Y");
// }
// }
// return civicrm_api3_create_success($returnValues, $params, 'LidDatum', 'Fix');
// }

View File

@ -1,20 +1,20 @@
<?php
use CRM_Bij1migratie_ExtensionUtil as E;
/**
* LidNummer.Genereer API (eenmalig API na migratie om lidnummer te genereren op basis van inschrijfdatum)
*
* @param array $params
*
* @return array
* API result descriptor
*
* @see civicrm_api3_create_success
*
* @throws API_Exception
*/
function civicrm_api3_lid_nummer_Genereer($params) {
$lidnummer = new CRM_Bij1migratie_Lidnummer();
$lidnummer->genereer();
return civicrm_api3_create_success([], $params, 'LidNummer', 'Genereer');
}
// /**
// * LidNummer.Genereer API (eenmalig API na migratie om lidnummer te genereren op basis van inschrijfdatum)
// *
// * @param array $params
// *
// * @return array
// * API result descriptor
// *
// * @see civicrm_api3_create_success
// *
// * @throws API_Exception
// */
// function civicrm_api3_lid_nummer_Genereer($params) {
// $lidnummer = new CRM_Bij1migratie_Lidnummer();
// $lidnummer->genereer();
// return civicrm_api3_create_success([], $params, 'LidNummer', 'Genereer');
// }