INFRA-132 - CRM/Event - phpcbf
[civicrm-core.git] / CRM / Event / Form / ParticipantFeeSelection.php
index 577f6ec4450df05dc0d296b7ba0ac7ae66aa98f4..a80d8f7d32ab0ff462a28345c5c6e677f90f334d 100644 (file)
@@ -129,10 +129,17 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form {
     $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $this->_eventId);
 
     $priceSetValues = CRM_Event_Form_EventFees::setDefaultPriceSet($this->_participantId, $this->_eventId, FALSE);
+    $priceFieldId = (array_keys($this->_values['fee']));
     if (!empty($priceSetValues)) {
       $defaults[$this->_participantId] = array_merge($defaults[$this->_participantId], $priceSetValues);
     }
-
+    else {
+      foreach($priceFieldId as $key => $value) {
+        if (!empty($value) && ($this->_values['fee'][$value]['html_type'] == 'Radio' || $this->_values['fee'][$value]['html_type'] == 'Select') && !$this->_values['fee'][$value]['is_required']) {
+          $defaults[$this->_participantId]['price_'.array_keys($this->_values['fee'])[$key]] = 0;
+        }
+      }
+    }
     $this->assign('totalAmount', CRM_Utils_Array::value('fee_amount', $defaults[$this->_participantId]));
     if ($this->_action == CRM_Core_Action::UPDATE) {
       $fee_level = $defaults[$this->_participantId]['fee_level'];
@@ -147,12 +154,12 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form {
   public function buildQuickForm() {
 
     $statuses = CRM_Event_PseudoConstant::participantStatus();
-    $this->assign('partiallyPaid',  array_search('Partially paid', $statuses));
-    $this->assign('pendingRefund',  array_search('Pending refund', $statuses));
+    $this->assign('partiallyPaid', array_search('Partially paid', $statuses));
+    $this->assign('pendingRefund', array_search('Pending refund', $statuses));
     $this->assign('participantStatus', $this->_participantStatus);
 
     $config = CRM_Core_Config::singleton();
-    $this->assign('currencySymbol',  $config->defaultCurrencySymbol);
+    $this->assign('currencySymbol', $config->defaultCurrencySymbol);
 
     // line items block
     $lineItem = $event = array();
@@ -220,7 +227,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form {
    *
    * @return array
    */
-  static function formRule($fields, $files, $self) {
+  public static function formRule($fields, $files, $self) {
     $errors = array();
     return $errors;
   }
@@ -268,7 +275,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form {
    *
    * @return mixed
    */
-  function emailReceipt(&$params) {
+  public function emailReceipt(&$params) {
     $updatedLineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant', NULL, FALSE);
     $lineItem = array();
     if ($updatedLineItem) {