From 5bfef8fae73545b3d65aa8b4656868058502756d Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Wed, 29 Jun 2016 14:37:14 +1000 Subject: [PATCH] CRM-12252 Add in help_pre and help_post fields for price field options --- CRM/Price/BAO/PriceField.php | 25 +++++++++++++------- CRM/Upgrade/Incremental/sql/4.7.9.mysql.tpl | 6 +++++ templates/CRM/Price/Form/Option.tpl | 8 +++++++ templates/CRM/Price/Page/Option.tpl | 4 ++++ xml/schema/Price/PriceFieldValue.xml | 26 +++++++++++++++++++++ 5 files changed, 60 insertions(+), 9 deletions(-) diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index 4ea169d4fa..a78f297857 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -376,21 +376,25 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); if ($field->is_display_amounts) { $opt['label'] = !empty($opt['label']) ? $opt['label'] . ' - ' : ''; + $pre_help = isset($opt['help_pre']) ? + '' . $opt['help_pre'] . ': ' : ''; + $post_help = isset($opt['help_post']) ? + ': ' . $opt['help_post'] . '' : ''; if (isset($taxAmount) && $invoicing) { if ($displayOpt == 'Do_not_show') { - $opt['label'] = '' . $opt['label'] . '' . '' . CRM_Utils_Money::format($opt[$valueFieldName] + $taxAmount) . ''; + $opt['label'] = $pre_help . '' . $opt['label'] . '' . '' . CRM_Utils_Money::format($opt[$valueFieldName] + $taxAmount) . '' . $post_help; } elseif ($displayOpt == 'Inclusive') { - $opt['label'] = '' . $opt['label'] . '' . '' . CRM_Utils_Money::format($opt[$valueFieldName] + $taxAmount) . ''; - $opt['label'] .= ' (includes ' . $taxTerm . ' of ' . CRM_Utils_Money::format($opt['tax_amount']) . ')'; + $opt['label'] = $pre_help . '' . $opt['label'] . '' . '' . CRM_Utils_Money::format($opt[$valueFieldName] + $taxAmount) . ''; + $opt['label'] .= ' (includes ' . $taxTerm . ' of ' . CRM_Utils_Money::format($opt['tax_amount']) . ')' . $post_help; } else { - $opt['label'] = '' . $opt['label'] . '' . '' . CRM_Utils_Money::format($opt[$valueFieldName]) . ''; - $opt['label'] .= ' + ' . CRM_Utils_Money::format($opt['tax_amount']) . ' ' . $taxTerm . ''; + $opt['label'] = $pre_help . '' . $opt['label'] . '' . '' . CRM_Utils_Money::format($opt[$valueFieldName]) . ''; + $opt['label'] .= ' + ' . CRM_Utils_Money::format($opt['tax_amount']) . ' ' . $taxTerm . '' . $post_help; } } else { - $opt['label'] = '' . $opt['label'] . '' . '' . CRM_Utils_Money::format($opt[$valueFieldName]) . ''; + $opt['label'] = $pre_help . '' . $opt['label'] . '' . '' . CRM_Utils_Money::format($opt[$valueFieldName]) . '' . $post_help; } } $count = CRM_Utils_Array::value('count', $opt, ''); @@ -414,7 +418,6 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } $choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra); - if ($is_pay_later) { $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4')); } @@ -527,12 +530,16 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $max_value = CRM_Utils_Array::value('max_value', $opt, ''); if ($field->is_display_amounts) { + $pre_help = isset($opt['help_pre']) ? + '' . $opt['help_pre'] . ': ' : ''; + $post_help = isset($opt['help_post']) ? + ': ' . $opt['help_post'] . '' : ''; $opt['label'] = '' . $opt['label'] . ' - '; if (isset($taxAmount) && $invoicing) { - $opt['label'] .= self::getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm); + $opt['label'] .= $pre_help . self::getTaxLabel($opt, $valueFieldName, $displayOpt, $taxTerm) . $post_help; } else { - $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]); + $opt['label'] .= $pre_help . CRM_Utils_Money::format($opt[$valueFieldName]) . $post_help; } } $priceVal = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value)); diff --git a/CRM/Upgrade/Incremental/sql/4.7.9.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.9.mysql.tpl index 6c411d128a..e553d8fcfc 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.9.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.9.mysql.tpl @@ -53,3 +53,9 @@ INSERT INTO `civicrm_entity_financial_account` VALUES ('civicrm_financial_type', @financial_type_id_ef, @option_value_rel_id_dr, @financial_account_id_dref), ('civicrm_financial_type', @financial_type_id_md, @option_value_rel_id_dr, @financial_account_id_drmd); + +--CRM-12252 Add in help_pre and help_post colmns to price field value table +ALTER TABLE `civicrm_price_field_value` +ADD `help_pre` text COLLATE utf8_unicode_ci COMMENT 'Price field option pre help text.'; +ALTER TABLE `civicrm_price_field_value` +ADD `help_post` text COLLATE utf8_unicode_ci COMMENT 'Price field option post field help.'; diff --git a/templates/CRM/Price/Form/Option.tpl b/templates/CRM/Price/Form/Option.tpl index 123be21b3e..5600203623 100644 --- a/templates/CRM/Price/Form/Option.tpl +++ b/templates/CRM/Price/Form/Option.tpl @@ -55,6 +55,14 @@ {$form.description.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_price_field_value' field='description' id=$optionId}{/if}{$form.description.html} + + {$form.help_pre.label} + {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_price_field_value' field='help_pre' id=$optionId}{/if}{$form.help_pre.html} + + + {$form.help_post.label} + {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_price_field_value' field='help_post' id=$optionId}{/if}{$form.help_post.html} + {$form.financial_type_id.label} diff --git a/templates/CRM/Price/Page/Option.tpl b/templates/CRM/Price/Page/Option.tpl index a96f73b758..d97a3dd8e8 100644 --- a/templates/CRM/Price/Page/Option.tpl +++ b/templates/CRM/Price/Page/Option.tpl @@ -54,6 +54,8 @@ {ts}Option Label{/ts} {ts}Option Amount{/ts} + {ts}Pre Help{/ts} + {ts}Post Help{/ts} {if $isEvent} {ts}Participant Count{/ts} {ts}Maximum{/ts} @@ -74,6 +76,8 @@ {$row.label} {$row.amount|crmMoney} + {$row.help_pre} + {$row.help_post} {if $isEvent} {$row.count} {$row.max_value} diff --git a/xml/schema/Price/PriceFieldValue.xml b/xml/schema/Price/PriceFieldValue.xml index 256a5284d7..5fc037bdc2 100644 --- a/xml/schema/Price/PriceFieldValue.xml +++ b/xml/schema/Price/PriceFieldValue.xml @@ -67,6 +67,32 @@ >Price field option description. 3.3 + + help_pre + text + + TextArea + 2 + 60 + + NULL + true + Price field option pre help text. + 4.7 + + + help_post + text + + TextArea + 2 + 60 + + NULL + true + Price field option post field help. + 4.7 + amount varchar -- 2.25.1