Merge pull request #4898 from monishdeb/CRM-15619-fix
[civicrm-core.git] / CRM / Event / Form / EventFees.php
index 42d7bb6cb150cbf9cdadb57b12a6a8c88781183f..e5628f00e75cbbdc7ac8455fa3ddc22274c19037 100644 (file)
@@ -45,9 +45,8 @@ class CRM_Event_Form_EventFees {
    * @param CRM_Core_Form $form
    *
    * @return void
-   * @access public
    */
-  static function preProcess(&$form) {
+  public static function preProcess(&$form) {
     //as when call come from register.php
     if (!$form->_eventId) {
       $form->_eventId = CRM_Utils_Request::retrieve('eventId', 'Positive', $form);
@@ -71,18 +70,17 @@ class CRM_Event_Form_EventFees {
    * This function sets the default values for the form in edit/view mode
    * the default values are retrieved from the database
    *
-   * @access public
    *
    * @param CRM_Core_Form $form
    *
    * @return void
    */
-  static function setDefaultValues(&$form) {
+  public static function setDefaultValues(&$form) {
     $defaults = array();
 
     if ($form->_eventId) {
       //get receipt text and financial type
-      $returnProperities = array( 'confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date' );
+      $returnProperities = array('confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date');
       $details = array();
       CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities);
       if (!empty($details[$form->_eventId]['financial_type_id'])) {
@@ -154,7 +152,6 @@ class CRM_Event_Form_EventFees {
       //             $defaults[$form->_pId]['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
     }
 
-
     // if user has selected discount use that to set default
     if (isset($form->_discountId)) {
       $defaults[$form->_pId]['discount_id'] = $form->_discountId;
@@ -181,19 +178,18 @@ class CRM_Event_Form_EventFees {
 
     if (($form->_action == CRM_Core_Action::ADD) && $form->_eventId && $discountId) {
       // this case is for add mode, where we show discount automatically
-        $defaults[$form->_pId]['discount_id'] = $discountId;
+      $defaults[$form->_pId]['discount_id'] = $discountId;
     }
 
-
     if ($priceSetId) {
       // get price set default values, CRM-4090
       if (in_array(get_class($form),
-          array(
-            'CRM_Event_Form_Participant',
-            'CRM_Event_Form_Registration_Register',
-            'CRM_Event_Form_Registration_AdditionalParticipant',
-          )
-        )) {
+        array(
+          'CRM_Event_Form_Participant',
+          'CRM_Event_Form_Registration_Register',
+          'CRM_Event_Form_Registration_AdditionalParticipant',
+        )
+      )) {
         $priceSetValues = self::setDefaultPriceSet($form->_pId, $form->_eventId);
         if (!empty($priceSetValues)) {
           $defaults[$form->_pId] = array_merge($defaults[$form->_pId], $priceSetValues);
@@ -237,8 +233,14 @@ class CRM_Event_Form_EventFees {
     if ($contriId = $form->get('onlinePendingContributionId')) {
       $contribution = new CRM_Contribute_DAO_Contribution();
       $contribution->id = $contriId;
-      $contribution->find( true );
-      foreach( array('financial_type_id', 'payment_instrument_id','contribution_status_id', 'receive_date', 'total_amount' ) as $f ) {
+      $contribution->find(TRUE);
+      foreach (array(
+                 'financial_type_id',
+                 'payment_instrument_id',
+                 'contribution_status_id',
+                 'receive_date',
+                 'total_amount'
+               ) as $f) {
         if ($f == 'receive_date') {
           list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults($contribution->$f);
         }
@@ -253,7 +255,6 @@ class CRM_Event_Form_EventFees {
   /**
    * This function sets the default values for price set.
    *
-   * @access public
    *
    * @param int $participantID
    * @param int $eventID
@@ -261,7 +262,7 @@ class CRM_Event_Form_EventFees {
    *
    * @return void
    */
-  static function setDefaultPriceSet($participantID, $eventID = NULL, $includeQtyZero = TRUE) {
+  public static function setDefaultPriceSet($participantID, $eventID = NULL, $includeQtyZero = TRUE) {
     $defaults = array();
     if (!$eventID && $participantID) {
       $eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'event_id');
@@ -344,9 +345,8 @@ SELECT  id, html_type
    * @param CRM_Core_Form $form
    *
    * @return void
-   * @access public
    */
-  static function buildQuickForm(&$form) {
+  public static function buildQuickForm(&$form) {
     if ($form->_eventId) {
       $form->_isPaidEvent = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'is_monetary');
       if ($form->_isPaidEvent) {
@@ -362,8 +362,9 @@ SELECT  id, html_type
 
     if ($form->_pId) {
       if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
-          $form->_pId, 'contribution_id', 'participant_id'
-        )) {
+        $form->_pId, 'contribution_id', 'participant_id'
+      )
+      ) {
         $form->_online = TRUE;
       }
     }
@@ -377,7 +378,7 @@ SELECT  id, html_type
       CRM_Event_Form_Registration::initEventFee($form, $event['id']);
       CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId);
       $lineItem = array();
-      $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings');
+      $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
       $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
       $totalTaxAmount = 0;
       if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) {
@@ -400,7 +401,8 @@ SELECT  id, html_type
         $element = $form->add('select', 'discount_id',
           ts('Discount Set'),
           array(
-            0 => ts('- select -')) + $discounts,
+            0 => ts('- select -')
+          ) + $discounts,
           FALSE,
           array('onchange' => "buildFeeBlock( {$form->_eventId}, this.value );")
         );
@@ -418,7 +420,7 @@ SELECT  id, html_type
         );
 
         $form->add('select', 'financial_type_id',
-          ts( 'Financial Type' ),
+          ts('Financial Type'),
           array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()
         );
 
@@ -490,7 +492,7 @@ SELECT  id, html_type
       if ($form->_contactId) {
         list($form->_contributorDisplayName,
           $form->_contributorEmail
-        ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($form->_contactId);
+          ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($form->_contactId);
         $form->assign('email', $form->_contributorEmail);
       }
       else {
@@ -506,4 +508,3 @@ SELECT  id, html_type
     $form->assign('hasPayment', $form->_paymentId);
   }
 }
-