Skip to content

Commit

Permalink
PCHR-3546: Made all currencies available for new installations
Browse files Browse the repository at this point in the history
  • Loading branch information
backstageel committed Jun 21, 2018
1 parent 45176dd commit 0c8ded2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function install() {
$this->createRequiredLocationTypes();
$this->deleteUnneededCustomGroups();
$this->createDefaultRelationshipTypes();
$this->makeAllCurrenciesAvailable();
$this->runAllUpgraders();
}

Expand Down Expand Up @@ -223,6 +224,29 @@ private function createDefaultRelationshipTypes() {
}
}

/**
* Making All Currencies Available for new installations
*/
private function makeAllCurrenciesAvailable() {
$result = civicrm_api3('OptionValue', 'get', [
'return' => ['name'],
'option_group_id' => 'currencies_enabled',
]);
$enabledCurrencies = array_column($result['values'], 'name');

$dao = CRM_Core_DAO::executeQuery('SELECT * from civicrm_currency');
while ($dao->fetch()) {
if (!in_array($dao->name, $enabledCurrencies)) {
civicrm_api3('OptionValue', 'create', [
'option_group_id' => 'currencies_enabled',
'label' => $dao->name . ' (' . $dao->symbol . ')',
'value' => $dao->name,
'name' => $dao->name . ' (' . $dao->symbol . ')',
]);
}
}
}

/**
* Removes default relationship types
*/
Expand Down

0 comments on commit 0c8ded2

Please sign in to comment.