indelen leden
This commit is contained in:
parent
5b6c7c6323
commit
bf37091748
|
@ -8,7 +8,7 @@ use CRM_Bij1migratie_ExtensionUtil as E;
|
|||
* @param array $spec description of fields supported by this API call
|
||||
*/
|
||||
function _civicrm_api3_lid_Indelen_spec(&$spec) {
|
||||
$spec['max_id']['api_required'] = 1;
|
||||
$spec['min']['api_required'] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,33 +30,36 @@ function _civicrm_api3_lid_Indelen_spec(&$spec) {
|
|||
* @throws API_Exception
|
||||
*/
|
||||
function civicrm_api3_lid_Indelen($params) {
|
||||
$maxId = (int) $params['max_id'];
|
||||
$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();
|
||||
$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",
|
||||
]);
|
||||
$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", [1 => [$maxId, "Integer"]]);
|
||||
$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()) {
|
||||
if ($contact->heeftRecentBetaald((int) $lid->contact_id)) {
|
||||
$groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1Algemeen')->getNieuweLedenGroepId(), $contact->haalInschrijvingsDatum((int) $lid->contact_id));
|
||||
$returnValues[] = "Contact met ID " . $lid->contact_id . " in nieuwe leden geplaatst.";
|
||||
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);
|
||||
$returnValues[] = "Contact met ID " . $lid->contact_id . " in standaard leden geplaatst.";
|
||||
}
|
||||
else {
|
||||
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());
|
||||
$returnValues[] = "Contact met ID " . $lid->contact_id . " in standaard leden geplaatst.";
|
||||
if ($contact->heeftRecentBetaald((int) $lid->contact_id)) {
|
||||
$groep->plaatsInGroep((int) $lid->contact_id, Civi::service('bij1Algemeen')->getNieuweLedenGroepId(), $contact->haalInschrijvingsDatum((int) $lid->contact_id));
|
||||
$returnValues[] = "Contact met ID " . $lid->contact_id . " in nieuwe leden geplaatst.";
|
||||
}
|
||||
else {
|
||||
$groep->plaatsInGroep((int) $lid->contact_id, $nogInTeDelenGroepId);
|
||||
$groep->verwijderUitGroep((int) $lid->contact_id, Civi::service('bij1Algemeen')->getNieuweLedenGroepId());
|
||||
$groep->verwijderUitGroep((int) $lid->contact_id, Civi::service('bij1Algemeen')->getNieuweLedenGroepId(), TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use CRM_Bij1migratie_ExtensionUtil as E;
|
|||
* @param array $spec description of fields supported by this API call
|
||||
*/
|
||||
function _civicrm_api3_lid_datum_Fix_spec(&$spec) {
|
||||
$spec['max_id']['api_required'] = 1;
|
||||
$spec['min']['api_required'] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,8 @@ function civicrm_api3_lid_datum_Fix($params) {
|
|||
$returnValues = [];
|
||||
$contact = new CRM_Bij1migratie_Contact();
|
||||
$activiteit = new CRM_Bij1migratie_Activiteit();
|
||||
$maxId = (int) $params['max_id'];
|
||||
$lid = CRM_Core_DAO::executeQuery("SELECT DISTINCT(contact_id) FROM civicrm_contribution WHERE contact_id <= %1 ORDER BY contact_id", [1 => [$maxId, "Integer"]]);
|
||||
$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) {
|
||||
|
|
Loading…
Reference in New Issue