Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCHR-3545: Changed Order For Individual Prefix #2691

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
]);
}
}

}