From 3593e0f875b1d6369841845bd3921431117e7029 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 29 May 2018 19:45:27 +0100 Subject: [PATCH] Add reserved/enabled to option groups list and buttons to top of page. --- CRM/Admin/Form/OptionGroup.php | 12 +++++---- templates/CRM/Admin/Page/OptionGroup.tpl | 31 ++++++++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/CRM/Admin/Form/OptionGroup.php b/CRM/Admin/Form/OptionGroup.php index 059a5bf878..c1216fcd83 100644 --- a/CRM/Admin/Form/OptionGroup.php +++ b/CRM/Admin/Form/OptionGroup.php @@ -110,22 +110,24 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { public function postProcess() { CRM_Utils_System::flushCache(); - $params = $this->exportValues(); if ($this->_action & CRM_Core_Action::DELETE) { CRM_Core_BAO_OptionGroup::del($this->_id); CRM_Core_Session::setStatus(ts('Selected option group has been deleted.'), ts('Record Deleted'), 'success'); } else { - - $params = $ids = array(); // store the submitted values in an array $params = $this->exportValues(); + // If we are adding option group via UI it should not be marked reserved. + if (!isset($params['is_reserved'])) { + $params['is_reserved'] = 0; + } + if ($this->_action & CRM_Core_Action::UPDATE) { - $ids['optionGroup'] = $this->_id; + $params['id'] = $this->_id; } - $optionGroup = CRM_Core_BAO_OptionGroup::add($params, $ids); + $optionGroup = CRM_Core_BAO_OptionGroup::add($params); CRM_Core_Session::setStatus(ts('The Option Group \'%1\' has been saved.', array(1 => $optionGroup->name)), ts('Saved'), 'success'); } } diff --git a/templates/CRM/Admin/Page/OptionGroup.tpl b/templates/CRM/Admin/Page/OptionGroup.tpl index f33ba6ed42..e8c60e31d8 100644 --- a/templates/CRM/Admin/Page/OptionGroup.tpl +++ b/templates/CRM/Admin/Page/OptionGroup.tpl @@ -36,20 +36,31 @@ {if $rows}
- {strip} + {if $action ne 1 and $action ne 2} + + {/if} + + {strip} {* handle enable/disable actions*} {include file="CRM/common/enableDisableApi.tpl"} - - - + + + + + {foreach from=$rows item=row} - - - - + + + + + + {/foreach}
{ts}Title{/ts}{ts}Name{/ts}{ts}Title{/ts}{ts}Name{/ts}{ts}Reserved{/ts}{ts}Enabled?{/ts}
{if $row.title}{$row.title}{else}( {ts}none{/ts} ){/if}{$row.name}{ts}Options{/ts}
{if $row.title}{$row.title}{else}( {ts}none{/ts} ){/if}{$row.name}{if $row.is_reserved eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}{ts}Options{/ts}
@@ -59,10 +70,10 @@ +
{/if} -{elseif $action NEQ 1 && $action NEQ 2} +{elseif $action ne 1 and $action ne 2}
{ts}status{/ts} {capture assign=crmURL}{crmURL p='civicrm/admin/optionGroup' q="action=add&reset=1"}{/capture} -- 2.25.1