CRM-15378 - Add max participants and count to price option browse page.
authorDave Greenberg <dave@civicrm.org>
Fri, 18 Sep 2015 00:27:34 +0000 (17:27 -0700)
committerDave Greenberg <dave@civicrm.org>
Fri, 18 Sep 2015 00:27:34 +0000 (17:27 -0700)
----------------------------------------
* CRM-15378: Include Max Participants and Participant Count columns when viewing price field options
  https://issues.civicrm.org/jira/browse/CRM-15378

CRM/Price/Page/Option.php
templates/CRM/Price/Page/Option.tpl

index 7d47ac79a2882d17c9a9f28d99652575ecd7100a..5113766055d84738f50cc88730f5e9d79a514997 100644 (file)
@@ -123,6 +123,16 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
   public function browse() {
     $customOption = array();
     CRM_Price_BAO_PriceFieldValue::getValues($this->_fid, $customOption);
+
+    // CRM-15378 - check if these price options are in an Event price set
+    $isEvent = FALSE;
+    $extendComponentId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'extends', 'id');
+    $allComponents = explode(CRM_Core_DAO::VALUE_SEPARATOR, $extendComponentId);
+    $eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
+    if (in_array($eventComponentId, $allComponents)) {
+      $isEvent = TRUE;
+    }
+
     $config = CRM_Core_Config::singleton();
     $financialType = CRM_Contribute_PseudoConstant::financialType();
     $taxRate = CRM_Core_PseudoConstant::getTaxRates();
@@ -188,6 +198,7 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
     $this->assign('getTaxDetails', $getTaxDetails);
     $this->assign('customOption', $customOption);
     $this->assign('sid', $this->_sid);
+    $this->assign('isEvent', $isEvent);
   }
 
   /**
index 4402ffb26ef5d809a69a70709be6050ede305c4c..cd257f921cde34cff1d9fbef449786e10d08890f 100644 (file)
           <tr>
             <th>{ts}Option Label{/ts}</th>
             <th>{ts}Option Amount{/ts}</th>
+            {if $isEvent}
+              <th>{ts}Participant Count{/ts}</th>
+              <th>{ts}Maximum{/ts}</th>
+            {/if}
             <th>{ts}Default{/ts}</th>
             <th>{ts}Financial Type{/ts}</th>
             <th>{ts}Order{/ts}</th>
             <tr id="price_field_value-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"} {$row.class}{if NOT $row.is_active} disabled{/if}">
               <td class="crm-price-option-label crm-editable" data-field="label">{$row.label}</td>
               <td class="crm-price-option-value">{$row.amount|crmMoney}</td>
+              {if $isEvent}
+                <td class="crm-price-option-count">{$row.count}</td>
+                <td class="crm-price-option-max">{$row.max_value}</td>
+              {/if}
               <td class="crm-price-option-is_default">{if $row.is_default}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" />{/if}</td>
               <td class="nowrap crm-price-option-financial-type-id">{$row.financial_type_id}</td>
               <td class="nowrap crm-price-option-order">{$row.weight}</td>