From 58f5af7d8bf4af18fe7e2d34050bbf5a1e0d64c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADsio=20Leonardo?= Date: Wed, 20 Jun 2018 21:51:41 +0200 Subject: [PATCH] PCHR-3546: Made all currencies available for new installations --- .../CRM/HRCore/Upgrader.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php index 2dd44cd6f67..5a4a37dc4e4 100755 --- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php +++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php @@ -64,6 +64,7 @@ public function install() { $this->deleteLocationTypes(); $this->deleteUnneededCustomGroups(); $this->createDefaultRelationshipTypes(); + $this->makeAllCurrenciesAvailable(); $this->runAllUpgraders(); } @@ -188,6 +189,28 @@ private function createDefaultRelationshipTypes() { } } + private function makeAllCurrenciesAvailable() { + + $dao = CRM_Core_DAO::executeQuery('SELECT * from civicrm_currency'); + while ($dao->fetch()) { + $currencyExists = civicrm_api3('OptionValue', 'get', [ + 'value' => $dao->name, + ]); + if (empty($currencyExists['values'])) { + civicrm_api3('OptionValue', 'create', [ + 'option_group_id' => 'currencies_enabled', + 'label' => $dao->name . ' (' . $dao->symbol . ')', + 'value' => $dao->name, + 'name' => $dao->name, + 'is_active' => 1, + 'is_reserved' => 0, + 'is_optgroup' => 0, + 'is_default' => 0, + ]); + } + } + } + /** * Removes default relationship types */