INFRA-132 - phpcbf Drupal.WhiteSpace.ScopeIndent.IncorrectExact
[civicrm-core.git] / CRM / Report / Form / Event / ParticipantListing.php
index d87d370ca6879a71abb476d66c0504df69dfc5d3..418ee97507738ff008cf8786ffe4befb912e046d 100644 (file)
@@ -1,8 +1,7 @@
 <?php
-
 /*
   +--------------------------------------------------------------------+
-  | CiviCRM version 4.5                                                |
+  | CiviCRM version 4.6                                                |
   +--------------------------------------------------------------------+
   | Copyright CiviCRM LLC (c) 2004-2014                                |
   +--------------------------------------------------------------------+
@@ -24,7 +23,7 @@
   | GNU Affero General Public License or the licensing of CiviCRM,     |
   | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
   +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -47,18 +46,16 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
     'Participant',
     'Contact',
     'Individual',
-    'Event'
+    'Event',
   );
 
   public $_drilldownReport = array('event/income' => 'Link to Detail Report');
 
   /**
-   *
    */
   /**
-   *
    */
-  function __construct() {
+  public function __construct() {
     $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
 
     // Check if CiviCampaign is a) enabled and b) has active campaigns
@@ -142,7 +139,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
           'birth_date' => array(
             'title' => 'Birth Date',
             'operatorType' => CRM_Report_Form::OP_DATE,
-            'type' => CRM_Utils_Type::T_DATE
+            'type' => CRM_Utils_Type::T_DATE,
           ),
         ),
       ),
@@ -215,7 +212,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
             'type' => CRM_Utils_Type::T_INT,
             'attributes' => array(
               'entity' => 'event',
-              'select' => array('minimumInputLength' => 0)
+              'select' => array('minimumInputLength' => 0),
             ),
           ),
           'sid' => array(
@@ -252,7 +249,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
           'event_id' => array(
             'title' => ts('Event'),
             'default_weight' => '1',
-            'default_order' => 'ASC'
+            'default_order' => 'ASC',
           ),
         ),
       ),
@@ -290,7 +287,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
           'event_type_id' => array(
             'title' => ts('Event Type'),
             'default_weight' => '2',
-            'default_order' => 'ASC'
+            'default_order' => 'ASC',
           ),
         ),
       ),
@@ -314,11 +311,11 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
           ),
           'currency' => array(
             'required' => TRUE,
-            'no_display' => TRUE
+            'no_display' => TRUE,
           ),
           'trxn_id' => NULL,
           'fee_amount' => array('title' => ts('Transaction Fee')),
-          'net_amount' => NULL
+          'net_amount' => NULL,
         ),
         'grouping' => 'contrib-fields',
         'filters' => array(
@@ -347,7 +344,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
             'title' => ts('Contribution Status'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Contribute_PseudoConstant::contributionStatus(),
-            'default' => NULL
+            'default' => NULL,
           ),
         ),
       ),
@@ -365,7 +362,6 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
       ),
     );
 
-
     $this->_options = array(
       'blank_column_begin' => array(
         'title' => ts('Blank column at the Begining'),
@@ -385,20 +381,18 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
 
     // If we have active campaigns add those elements to both the fields and filters
     if ($campaignEnabled && !empty($this->activeCampaigns)) {
-      $this->_columns['civicrm_participant']['fields']['campaign_id'] =
-        array(
-          'title' => ts('Campaign'),
-          'default' => 'false',
-        );
-      $this->_columns['civicrm_participant']['filters']['campaign_id'] =
-        array(
-          'title' => ts('Campaign'),
-          'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-          'options' => $this->activeCampaigns,
-        );
-      $this->_columns['civicrm_participant']['order_bys']['campaign_id'] =
-        array('title' => ts('Campaign'));
-
+      $this->_columns['civicrm_participant']['fields']['campaign_id'] = array(
+        'title' => ts('Campaign'),
+        'default' => 'false',
+      );
+      $this->_columns['civicrm_participant']['filters']['campaign_id'] = array(
+        'title' => ts('Campaign'),
+        'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+        'options' => $this->activeCampaigns,
+      );
+      $this->_columns['civicrm_participant']['order_bys']['campaign_id'] = array(
+        'title' => ts('Campaign'),
+      );
     }
 
     $this->_currencyColumn = 'civicrm_participant_fee_currency';
@@ -406,16 +400,22 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
   }
 
   /**
+   * Searches database for priceset values.
+   *
    * @return array
    */
-  function getPriceLevels() {
+  public function getPriceLevels() {
     $query = "
-SELECT     DISTINCT cv.label, cv.id
-FROM      civicrm_price_field_value cv
-LEFT JOIN civicrm_price_field cf ON cv.price_field_id = cf.id
-LEFT JOIN civicrm_price_set_entity ce ON ce.price_set_id = cf.price_set_id
-WHERE     ce.entity_table = 'civicrm_event'
-GROUP BY  cv.label
+SELECT CONCAT(cv.label, ' (', ps.title, ')') label, cv.id
+FROM civicrm_price_field_value cv
+LEFT JOIN civicrm_price_field cf
+  ON cv.price_field_id = cf.id
+LEFT JOIN civicrm_price_set_entity ce
+  ON ce.price_set_id = cf.price_set_id
+LEFT JOIN civicrm_price_set ps
+  ON ce.price_set_id = ps.id
+WHERE ce.entity_table = 'civicrm_event'
+ORDER BY  cv.label
 ";
     $dao = CRM_Core_DAO::executeQuery($query);
     $elements = array();
@@ -424,14 +424,13 @@ GROUP BY  cv.label
     }
 
     return $elements;
-  } //searches database for priceset values
-
+  }
 
-  function preProcess() {
+  public function preProcess() {
     parent::preProcess();
   }
 
-  function select() {
+  public function select() {
     $select = array();
     $this->_columnHeaders = array();
 
@@ -484,12 +483,12 @@ GROUP BY  cv.label
    *
    * @return array
    */
-  static function formRule($fields, $files, $self) {
+  public static function formRule($fields, $files, $self) {
     $errors = $grouping = array();
     return $errors;
   }
 
-  function from() {
+  public function from() {
     $this->_from = "
         FROM civicrm_participant {$this->_aliases['civicrm_participant']}
              LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']}
@@ -525,7 +524,7 @@ GROUP BY  cv.label
     }
   }
 
-  function where() {
+  public function where() {
     $clauses = array();
     foreach ($this->_columns as $tableName => $table) {
       if (array_key_exists('filters', $table)) {
@@ -573,8 +572,7 @@ GROUP BY  cv.label
       $this->_where = "WHERE {$this->_aliases['civicrm_participant']}.is_test = 0 ";
     }
     else {
-      $this->_where =
-        "WHERE {$this->_aliases['civicrm_participant']}.is_test = 0 AND " .
+      $this->_where = "WHERE {$this->_aliases['civicrm_participant']}.is_test = 0 AND " .
         implode(' AND ', $clauses);
     }
     if ($this->_aclWhere) {
@@ -582,11 +580,11 @@ GROUP BY  cv.label
     }
   }
 
-  function groupBy() {
+  public function groupBy() {
     $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_participant']}.id";
   }
 
-  function postProcess() {
+  public function postProcess() {
 
     // get ready with post process params
     $this->beginPostProcess();
@@ -596,7 +594,6 @@ GROUP BY  cv.label
     // build query
     $sql = $this->buildQuery(TRUE);
 
-
     // build array of result based on column headers. This method also allows
     // modifying column headers before using it to build result set i.e $rows.
     $rows = array();
@@ -635,7 +632,7 @@ GROUP BY  cv.label
   /**
    * @param $rows
    */
-  function alterDisplay(&$rows) {
+  public function alterDisplay(&$rows) {
     // custom code to alter rows
 
     $entryFound = FALSE;
@@ -789,4 +786,5 @@ GROUP BY  cv.label
       }
     }
   }
+
 }