From d2108f71c9be5454a5ea533ef6b1f875d1034ee5 Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Wed, 21 May 2014 09:16:28 +0100 Subject: [PATCH] CRM-14696 Improve sold out display for price set options --- CRM/Price/BAO/PriceField.php | 25 ++++++++++++++++++++----- css/civicrm.css | 8 ++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index a029dd1494..0c6a037f57 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -320,9 +320,11 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $qf->add( 'text', 'txt-'.$elementName, $label, array( 'size' => '4')); } - // CRM-6902 + // CRM-6902 - Add "max" option for a price set field if (in_array($optionKey, $feezeOptions)) { $element->freeze(); + // CRM-14696 - Improve display for sold out price set options + $element->setLabel($label . ' ' . ts('Sold out') . ''); } //CRM-10117 @@ -374,9 +376,11 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $qf->add( 'text', 'txt-'.$elementName, $label, array( 'size' => '4')); } - // CRM-6902 + // CRM-6902 - Add "max" option for a price set field if (in_array($opId, $feezeOptions)) { $choice[$opId]->freeze(); + // CRM-14696 - Improve display for sold out price set options + $choice[$opId]->setText(' ' . ts('Sold out') . ' ' . $choice[$opId]->getText()); } } if (!empty($qf->_membershipBlock) && $field->name == 'contribution_amount') { @@ -429,15 +433,24 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $opt['label'] .= ' - '; $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]); } - $selectOption[$opt['id']] = $opt['label']; + + if (!in_array($opt['id'], $feezeOptions)) { $allowedOptions[] = $opt['id']; } + // CRM-14696 - Improve display for sold out price set options + else { + $opt['label'] = 'Sold out - ' . $opt['label']; + } + + $selectOption[$opt['id']] = $opt['label']; + if ($is_pay_later) { $qf->add( 'text', 'txt-'.$elementName, $label, array( 'size' => '4')); } } + $element = &$qf->add('select', $elementName, $label, array( '' => ts('- select -')) + $selectOption, @@ -445,7 +458,7 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { array('price' => json_encode($priceVal)) ); - // CRM-6902 + // CRM-6902 - Add "max" option for a price set field $button = substr($qf->controller->getButtonName(), -4); if (!empty($feezeOptions) && $button != 'skip') { $qf->addRule($elementName, ts('Sorry, this option is currently sold out.'), 'regex', "/" . implode('|', $allowedOptions) . "/"); @@ -474,9 +487,11 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $txtcheck[$opId] =& $qf->createElement( 'text', $opId, $opt['label'], array( 'size' => '4' ) ); $qf->addGroup($txtcheck, 'txt-'.$elementName, $label); } - // CRM-6902 + // CRM-6902 - Add "max" option for a price set field if (in_array($opId, $feezeOptions)) { $check[$opId]->freeze(); + // CRM-14696 - Improve display for sold out price set options + $check[$opId]->setText(' ' . ts('Sold out') . ' ' . $check[$opId]->getText()); } } $element = &$qf->addGroup($check, $elementName, $label); diff --git a/css/civicrm.css b/css/civicrm.css index ecb79db720..e4d57dbb33 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -4606,6 +4606,14 @@ span.crm-status-icon { color: #222222; } +#crm-container.crm-public .price-set-option-content > tt { + display: none; +} + +#crm-container.crm-public .price_set-section .sold-out-option { + font-weight: bold; + font-style: italic; +} #crm-container .crm-extensions-upgrade { background: #ffb; border: 1px solid #000; -- 2.25.1