phpcs - Fix error, "Expected 1 newline at end of file; XXX found".
[civicrm-core.git] / CRM / Report / Form / Membership / Summary.php
index 6af59c05fde3bc4e40a5e5864175b7ea23e8eca4..2163a08fedfce904add84e0fbe2b6965baf42170 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -43,44 +43,42 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form {
     'pieChart' => 'Pie Chart',
   );
 
-  function __construct() {
+  /**
+   *
+   */
+  /**
+   *
+   */
+  public function __construct() {
     // UI for selecting columns to appear in the report list
     // array conatining the columns, group_bys and filters build and provided to Form
     $this->_columns = array(
-      'civicrm_contact' =>
-      array(
+      'civicrm_contact' => array(
         'dao' => 'CRM_Contact_DAO_Contact',
-        'fields' =>
-        array(
-          'sort_name' =>
-          array('title' => ts('Member Name'),
+        'fields' => array(
+          'sort_name' => array(
+            'title' => ts('Member Name'),
             'no_repeat' => TRUE,
             'required' => TRUE,
           ),
-          'id' =>
-          array(
+          'id' => array(
             'no_display' => TRUE,
             'required' => TRUE,
           ),
         ),
-        'group_bys' =>
-        array(
-          'id' =>
-          array('title' => ts('Contact ID')),
-          'display_name' =>
-          array('title' => ts('Contact Name'),
+        'group_bys' => array(
+          'id' => array('title' => ts('Contact ID')),
+          'display_name' => array(
+            'title' => ts('Contact Name'),
           ),
         ),
         'grouping' => 'contact-fields',
       ),
-      'civicrm_membership_type' =>
-      array(
+      'civicrm_membership_type' => array(
         'dao' => 'CRM_Member_DAO_MembershipType',
         'grouping' => 'member-fields',
-        'filters' =>
-        array(
-          'gid' =>
-          array(
+        'filters' => array(
+          'gid' => array(
             'name' => 'id',
             'title' => ts('Membership Types'),
             'type' => CRM_Utils_Type::T_INT + CRM_Utils_Type::T_ENUM,
@@ -88,66 +86,55 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form {
           ),
         ),
       ),
-      'civicrm_membership' =>
-      array(
+      'civicrm_membership' => array(
         'dao' => 'CRM_Member_DAO_Membership',
         'grouping' => 'member-fields',
-        'fields' =>
-        array(
-          'membership_type_id' =>
-          array(
+        'fields' => array(
+          'membership_type_id' => array(
             'title' => 'Membership Type',
             'required' => TRUE,
           ),
           'join_date' => NULL,
-          'start_date' => array('title' => ts('Current Cycle Start Date'),
+          'start_date' => array(
+            'title' => ts('Current Cycle Start Date'),
           ),
-          'end_date' => array('title' => ts('Current Cycle End Date'),
+          'end_date' => array(
+            'title' => ts('Current Cycle End Date'),
           ),
         ),
-        'group_bys' =>
-        array(
-          'membership_type_id' =>
-          array('title' => ts('Membership Type')),
+        'group_bys' => array(
+          'membership_type_id' => array('title' => ts('Membership Type')),
         ),
-        'filters' =>
-        array(
-          'join_date' =>
-          array('type' => CRM_Utils_Type::T_DATE),
+        'filters' => array(
+          'join_date' => array('type' => CRM_Utils_Type::T_DATE),
         ),
       ),
-      'civicrm_address' =>
-      array(
+      'civicrm_address' => array(
         'dao' => 'CRM_Core_DAO_Address',
-        'fields' =>
-        array(
+        'fields' => array(
           'street_address' => NULL,
           'city' => NULL,
           'postal_code' => NULL,
-          'state_province_id' =>
-          array('title' => ts('State/Province'),
+          'state_province_id' => array(
+            'title' => ts('State/Province'),
           ),
-          'country_id' =>
-          array('title' => ts('Country'),
+          'country_id' => array(
+            'title' => ts('Country'),
             'default' => TRUE,
           ),
         ),
         'grouping' => 'contact-fields',
       ),
-      'civicrm_email' =>
-      array(
+      'civicrm_email' => array(
         'dao' => 'CRM_Core_DAO_Email',
-        'fields' =>
-        array('email' => NULL),
+        'fields' => array('email' => NULL),
         'grouping' => 'contact-fields',
       ),
-      'civicrm_contribution' =>
-      array(
+      'civicrm_contribution' => array(
         'dao' => 'CRM_Contribute_DAO_Contribution',
-        'filters' =>
-        array(
-          'total_amount' =>
-          array('title' => ts('Contribution Amount'),
+        'filters' => array(
+          'total_amount' => array(
+            'title' => ts('Contribution Amount'),
           ),
         ),
       ),
@@ -155,22 +142,27 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form {
     parent::__construct();
   }
 
-  function preProcess() {
+  public function preProcess() {
     $this->assign('reportTitle', ts('Membership Summary Report'));
     parent::preProcess();
   }
 
-  function setDefaultValues() {
+  /**
+   * @return array
+   */
+  public function setDefaultValues() {
     return parent::setDefaultValues();
   }
 
-  function select() {
+  public function select() {
     $select = array();
     $this->_columnHeaders = array();
     foreach ($this->_columns as $tableName => $table) {
       if (array_key_exists('fields', $table)) {
         foreach ($table['fields'] as $fieldName => $field) {
-          if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) {
+          if (!empty($field['required']) ||
+            !empty($this->_params['fields'][$fieldName])
+          ) {
             // to include optional columns address and email, only if checked
             if ($tableName == 'civicrm_address') {
               $this->_addressField = TRUE;
@@ -189,7 +181,14 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form {
     $this->_select = "SELECT " . implode(', ', $select) . " ";
   }
 
-  static function formRule($fields, $files, $self) {
+  /**
+   * @param $fields
+   * @param $files
+   * @param $self
+   *
+   * @return array
+   */
+  public static function formRule($fields, $files, $self) {
     $errors = $grouping = array();
     //check for searching combination of dispaly columns and
     //grouping criteria
@@ -197,7 +196,7 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form {
     return $errors;
   }
 
-  function from() {
+  public function from() {
     $this->_from = NULL;
 
     $this->_from = "
@@ -220,7 +219,7 @@ LEFT  JOIN civicrm_contribution  {$this->_aliases['civicrm_contribution']}
     }
   }
 
-  function where() {
+  public function where() {
     $clauses = array();
     foreach ($this->_columns as $tableName => $table) {
       if (array_key_exists('filters', $table)) {
@@ -228,8 +227,8 @@ LEFT  JOIN civicrm_contribution  {$this->_aliases['civicrm_contribution']}
           $clause = NULL;
           if ($field['type'] & CRM_Utils_Type::T_DATE) {
             $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
-            $from     = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
-            $to       = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
+            $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
+            $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
 
             if ($relative || $from || $to) {
               $clause = $this->dateClause($field['name'], $relative, $from, $to);
@@ -262,15 +261,21 @@ LEFT  JOIN civicrm_contribution  {$this->_aliases['civicrm_contribution']}
     }
   }
 
-  function statistics(&$rows) {
+  /**
+   * @param $rows
+   *
+   * @return array
+   */
+  public function statistics(&$rows) {
     $statistics = array();
-    $statistics[] = array('title' => ts('Row(s) Listed'),
+    $statistics[] = array(
+      'title' => ts('Row(s) Listed'),
       'value' => count($rows),
     );
     return $statistics;
   }
 
-  function groupBy() {
+  public function groupBy() {
     $this->_groupBy = "";
     if (is_array($this->_params['group_bys']) &&
       !empty($this->_params['group_bys'])
@@ -290,14 +295,15 @@ LEFT  JOIN civicrm_contribution  {$this->_aliases['civicrm_contribution']}
       ) {
         $this->_rollup = " WITH ROLLUP";
       }
-      $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy) . " {$this->_rollup} ";
+      $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy) .
+        " {$this->_rollup} ";
     }
     else {
       $this->_groupBy = "GROUP BY contact.id";
     }
   }
 
-  function postProcess() {
+  public function postProcess() {
     $this->_params = $this->controller->exportValues($this->_name);
     if (empty($this->_params) &&
       $this->_force
@@ -318,8 +324,8 @@ LEFT  JOIN civicrm_contribution  {$this->_aliases['civicrm_contribution']}
 
     $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}";
 
-    $dao   = CRM_Core_DAO::executeQuery($sql);
-    $rows  = $graphRows = array();
+    $dao = CRM_Core_DAO::executeQuery($sql);
+    $rows = $graphRows = array();
     $count = 0;
     while ($dao->fetch()) {
       $row = array();
@@ -346,7 +352,10 @@ LEFT  JOIN civicrm_contribution  {$this->_aliases['civicrm_contribution']}
 
     if (!empty($this->_params['charts'])) {
       foreach (array(
-        'receive_date', $this->_interval, 'value') as $ignore) {
+                 'receive_date',
+                 $this->_interval,
+                 'value'
+               ) as $ignore) {
         unset($graphRows[$ignore][$count - 1]);
       }
 
@@ -356,7 +365,10 @@ LEFT  JOIN civicrm_contribution  {$this->_aliases['civicrm_contribution']}
     parent::endPostProcess();
   }
 
-  function alterDisplay(&$rows) {
+  /**
+   * @param $rows
+   */
+  public function alterDisplay(&$rows) {
     // custom code to alter rows
     $entryFound = FALSE;
     $checkList = array();
@@ -413,7 +425,8 @@ LEFT  JOIN civicrm_contribution  {$this->_aliases['civicrm_contribution']}
           'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'],
           $this->_absoluteUrl
         );
-        $rows[$rowNum]['civicrm_contact_sort_name'] = "<a href='$url'>" . $row["civicrm_contact_sort_name"] . '</a>';
+        $rows[$rowNum]['civicrm_contact_sort_name'] =
+          "<a href='$url'>" . $row["civicrm_contact_sort_name"] . '</a>';
         $entryFound = TRUE;
       }
 
@@ -425,4 +438,3 @@ LEFT  JOIN civicrm_contribution  {$this->_aliases['civicrm_contribution']}
     }
   }
 }
-