lidnummer veld toevoegen in service
This commit is contained in:
parent
72d66ee8a3
commit
1681acea4c
|
@ -205,6 +205,34 @@ class CRM_Bij1algemeen_Bij1AlgemeenService {
|
|||
return $this->_airtableDataTableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int
|
||||
*/
|
||||
public function setLidDataCustomGroupId(int $id) {
|
||||
$this->_lidDataCustomGroupId = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getLidDataCustomGroupId() {
|
||||
return $this->_lidDataCustomGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
public function setLidDataTableName(string $name) {
|
||||
$this->_lidDataTableName = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getLidDataTableName() {
|
||||
return $this->_lidDataTableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
use CRM_Bij1migratie_ExtensionUtil as E;
|
||||
use CRM_Bij1algemeen_ExtensionUtil as E;
|
||||
|
||||
/**
|
||||
* Groepen aanmaken als ze nog niet bestaan
|
||||
* Groepsverwerking Bij1
|
||||
*
|
||||
* @author Erik Hommel(CiviCooP) <erik.hommel@civicoop.org>
|
||||
* @license AGPL-3.0
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
use CRM_Bij1algemeen_ExtensionUtil as E;
|
||||
|
||||
/**
|
||||
* Lid verwerking Bij1
|
||||
*
|
||||
* @author Erik Hommel(CiviCooP) <erik.hommel@civicoop.org>
|
||||
* @license AGPL-3.0
|
||||
*/
|
||||
class CRM_Bij1algemeen_Lid {
|
||||
|
||||
/**
|
||||
* Method om te kijken of contact al een lidnummer heeft
|
||||
*
|
||||
* @param int $contactId
|
||||
* @return bool
|
||||
*/
|
||||
public function heeftLidNummer(int $contactId) {
|
||||
if (!empty($contactId)) {
|
||||
$table = Civi::service('bij1Algemeen')->getLidDataTableName();
|
||||
$column = Civi::service('bij1Algemeen')->getLidnummerColumnName();
|
||||
if ($table && $column) {
|
||||
$query = "SELECT " . $column . " FROM " . $table . " WHERE entity_id = %1";
|
||||
$lidNummer = CRM_Core_DAO::singleValueQuery($query, [1 => [$contactId, "Integer"]]);
|
||||
if ($lidNummer) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method om laatst uitgegeven lidnummer op te halen
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function haalLaatsteLidNummer() {
|
||||
return (int) Civi::settings()->get('bij1_laatste_lidnummer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method om het laatst uitgegeven lidnummer te bewaren
|
||||
*
|
||||
* @param int $lidNummer
|
||||
*/
|
||||
public function bewaarLaatsteLidnummer(int $lidNummer) {
|
||||
Civi::settings()->set('bij1_laatste_lidnummer', $lidNummer);
|
||||
}
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@ function bij1algemeen_civicrm_container(ContainerBuilder $container) {
|
|||
/**
|
||||
* Implements hook_civicrm_navigationMenu().
|
||||
*
|
||||
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_navigationMenu
|
||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu()/
|
||||
*/
|
||||
function bij1algemeen_civicrm_navigationMenu(&$menu) {
|
||||
_bij1algemeen_civix_insert_navigation_menu($menu, 'Administer', array(
|
||||
|
|
Loading…
Reference in New Issue