Skip to content

Commit

Permalink
Merge pull request #2691 from compucorp/PCHR-3545-Change-Order-For-In…
Browse files Browse the repository at this point in the history
…dividual-Prefix

PCHR-3545: Changed Order For Individual Prefix
  • Loading branch information
backstageel authored Jun 19, 2018
2 parents 40b4cf2 + be1ed18 commit b054784
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1018.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

trait CRM_HRCore_Upgrader_Steps_1018 {

/**
* Changes the Order Of Individual Prefix
*/
public function upgrade_1018() {
$this->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,
]);
}
}

}

0 comments on commit b054784

Please sign in to comment.