From be1ed18691d69d7eb4cd313eabb7df664748d8ff Mon Sep 17 00:00:00 2001 From: Elisio Leonardo Date: Tue, 19 Jun 2018 12:26:20 +0200 Subject: [PATCH] PCHR-3545: Changed Order For Individual Prefix --- .../CRM/HRCore/Upgrader.php | 1 + .../CRM/HRCore/Upgrader/Steps/1018.php | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1018.php diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php index 230c30760e0..2dd44cd6f67 100755 --- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php +++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php @@ -25,6 +25,7 @@ class CRM_HRCore_Upgrader extends CRM_HRCore_Upgrader_Base { use CRM_HRCore_Upgrader_Steps_1015; use CRM_HRCore_Upgrader_Steps_1016; use CRM_HRCore_Upgrader_Steps_1017; + use CRM_HRCore_Upgrader_Steps_1018; /** * @var array diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1018.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1018.php new file mode 100644 index 00000000000..4afc20b2a6e --- /dev/null +++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1018.php @@ -0,0 +1,52 @@ +up1018_changeOrderOfIndividualPrefix(); + + return TRUE; + } + + /** + * Changes The Order of Individual Prefixes + */ + private function up1018_changeOrderOfIndividualPrefix() { + $optionValues = civicrm_api3('OptionValue', 'get', [ + 'option_group_id' => 'individual_prefix', + ]); + + $optionValues = $optionValues['values']; + foreach ($optionValues as $optionValueId => $optionValue) { + switch ($optionValue['name']) { + case 'Mr.': + $newWeight = 1; + break; + + case 'Mrs.': + $newWeight = 2; + break; + + case 'Ms.': + $newWeight = 3; + break; + + case 'Miss': + $newWeight = 4; + break; + + case 'Dr.': + $newWeight = 5; + break; + } + civicrm_api3('OptionValue', 'create', [ + 'id' => $optionValueId, + 'weight' => $newWeight, + ]); + } + } + +}