Merge pull request #4925 from KarinG/patch-1
[civicrm-core.git] / CRM / Report / Form / Contribute / Repeat.php
index ea3a43f51876033a4719823bbd7e5b7d124e418b..7d07560621757db94cc3e8b70a436d6eab47160a 100644 (file)
@@ -1,8 +1,7 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -39,12 +38,10 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form {
   public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report');
 
   /**
-   *
    */
   /**
-   *
    */
-  function __construct() {
+  public function __construct() {
     $this->_columns = array(
       'civicrm_contact' => array(
         'dao' => 'CRM_Contact_DAO_Contact',
@@ -152,9 +149,7 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form {
             'type' => CRM_Utils_Type::T_MONEY,
             'default' => TRUE,
             'required' => TRUE,
-            'clause' => '
-contribution_civireport1.total_amount_count as contribution1_total_amount_count,
-contribution_civireport1.total_amount_sum as contribution1_total_amount_sum',
+            'clause' => 'contribution_civireport1.total_amount_count as contribution1_total_amount_count, contribution_civireport1.total_amount_sum as contribution1_total_amount_sum',
           ),
           'total_amount2' => array(
             'name' => 'total_amount',
@@ -163,9 +158,7 @@ contribution_civireport1.total_amount_sum as contribution1_total_amount_sum',
             'type' => CRM_Utils_Type::T_MONEY,
             'default' => TRUE,
             'required' => TRUE,
-            'clause' => '
-contribution_civireport2.total_amount_count as contribution2_total_amount_count,
-contribution_civireport2.total_amount_sum as contribution2_total_amount_sum',
+            'clause' => 'contribution_civireport2.total_amount_count as contribution2_total_amount_count, contribution_civireport2.total_amount_sum as contribution2_total_amount_sum',
           ),
         ),
         'grouping' => 'contri-fields',
@@ -218,7 +211,7 @@ contribution_civireport2.total_amount_sum as contribution2_total_amount_sum',
     parent::__construct();
   }
 
-  function preProcess() {
+  public function preProcess() {
     parent::preProcess();
   }
 
@@ -227,11 +220,11 @@ contribution_civireport2.total_amount_sum as contribution2_total_amount_sum',
    *
    * @return array
    */
-  function setDefaultValues($freeze = TRUE) {
+  public function setDefaultValues($freeze = TRUE) {
     return parent::setDefaultValues($freeze);
   }
 
-  function select() {
+  public function select() {
     $select = array();
     $append = NULL;
     // since contact fields not related to financial type
@@ -276,7 +269,7 @@ contribution_civireport2.total_amount_sum as contribution2_total_amount_sum',
   /**
    * @param bool $tableCol
    */
-  function groupBy($tableCol = FALSE) {
+  public function groupBy($tableCol = FALSE) {
     $this->_groupBy = "";
     if (!empty($this->_params['group_bys']) &&
       is_array($this->_params['group_bys'])
@@ -300,7 +293,7 @@ contribution_civireport2.total_amount_sum as contribution2_total_amount_sum',
     }
   }
 
-  function from() {
+  public function from() {
     list($fromTable, $fromAlias, $fromCol) = $this->groupBy(TRUE);
     $from = "$fromTable $fromAlias";
 
@@ -314,7 +307,7 @@ LEFT JOIN civicrm_phone   {$this->_aliases['civicrm_phone']}
        ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND {$this->_aliases['civicrm_phone']}.is_primary = 1";
 
     }
-    else if ($fromTable == 'civicrm_financial_type') {
+    elseif ($fromTable == 'civicrm_financial_type') {
       $contriCol = "financial_type_id";
     }
     elseif ($fromTable == 'civicrm_contribution') {
@@ -341,7 +334,7 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution
    *
    * @return mixed|string
    */
-  function whereContribution($replaceAliasWith = 'contribution1') {
+  public function whereContribution($replaceAliasWith = 'contribution1') {
     $clauses = array("is_test" => "{$this->_aliases['civicrm_contribution']}.is_test = 0");
 
     foreach ($this->_columns['civicrm_contribution']['filters'] as $fieldName => $field) {
@@ -389,8 +382,7 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution
       unset($clauses['receive_date1'], $clauses['total_amount1']);
     }
 
-    $whereClause = !empty($clauses) ?
-      "WHERE " . implode(' AND ', $clauses) : '';
+    $whereClause = !empty($clauses) ? "WHERE " . implode(' AND ', $clauses) : '';
 
     if ($replaceAliasWith) {
       $whereClause = str_replace($this->_aliases['civicrm_contribution'], $replaceAliasWith, $whereClause);
@@ -399,10 +391,10 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution
     return $whereClause;
   }
 
-  function where() {
+  public function where() {
     if (!$this->_amountClauseWithAND) {
-      $this->_amountClauseWithAND =
-        "!({$this->_aliases['civicrm_contribution']}1.total_amount_count IS NULL AND {$this->_aliases['civicrm_contribution']}2.total_amount_count IS NULL)";
+      $this->_amountClauseWithAND
+        "!({$this->_aliases['civicrm_contribution']}1.total_amount_count IS NULL AND {$this->_aliases['civicrm_contribution']}2.total_amount_count IS NULL)";
     }
     $clauses = array("atleast_one_amount" => $this->_amountClauseWithAND);
 
@@ -428,8 +420,7 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution
       }
     }
 
-    $this->_where = !empty($clauses) ?
-      "WHERE " . implode(' AND ', $clauses) : '';
+    $this->_where = !empty($clauses) ? "WHERE " . implode(' AND ', $clauses) : '';
   }
 
   /**
@@ -439,7 +430,7 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution
    *
    * @return array
    */
-  static function formRule($fields, $files, $self) {
+  public static function formRule($fields, $files, $self) {
 
     $errors = $checkDate = $errorCount = array();
 
@@ -504,14 +495,14 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution
           if (!$found) {
             $erorrGrps = implode(',', $invlidGroups);
             $tempErrors[] = ts("Do not select field %1 with Group by %2.", array(
-                1 => $idMapping[$fld_id],
-                2 => $erorrGrps
-              ));
+              1 => $idMapping[$fld_id],
+              2 => $erorrGrps,
+            ));
           }
         }
       }
       if (!empty($tempErrors)) {
-        $errors['fields'] = implode("<br>", $tempErrors);
+        $errors['fields'] = implode("<br/>", $tempErrors);
       }
     }
 
@@ -599,7 +590,7 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution
    *
    * @return array
    */
-  function statistics(&$rows) {
+  public function statistics(&$rows) {
     $statistics = parent::statistics($rows);
 
     //fetch contributions for both date ranges from pre-existing temp tables
@@ -622,10 +613,10 @@ LEFT JOIN civicrm_temp_civireport_repeat2
     //store contributions in array 'contact_sums' for comparison
     $contact_sums = array();
     while ($dao->fetch()) {
-      $contact_sums[$dao->contact_id] =
-        array(
+      $contact_sums[$dao->contact_id]
+        array(
           'contribution1_total_amount_sum' => $dao->contribution1_total_amount_sum,
-          'contribution2_total_amount_sum' => $dao->contribution2_total_amount_sum
+          'contribution2_total_amount_sum' => $dao->contribution2_total_amount_sum,
         );
     }
 
@@ -706,16 +697,16 @@ GROUP BY    currency
     $count = $count2 = 0;
     while ($dao->fetch()) {
       if ($dao->amount) {
-        $amount[] =
-          CRM_Utils_Money::format($dao->amount, $dao->currency) . "(" .
+        $amount[]
+          CRM_Utils_Money::format($dao->amount, $dao->currency) . "(" .
           $dao->count . ")";
         $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency);
       }
 
       $count += $dao->count;
       if ($dao->amount2) {
-        $amount2[] =
-          CRM_Utils_Money::format($dao->amount2, $dao->currency) . "(" .
+        $amount2[]
+          CRM_Utils_Money::format($dao->amount2, $dao->currency) . "(" .
           $dao->count . ")";
         $average2[] = CRM_Utils_Money::format($dao->avg2, $dao->currency);
       }
@@ -758,7 +749,7 @@ GROUP BY    currency
     return $statistics;
   }
 
-  function postProcess() {
+  public function postProcess() {
     $this->beginPostProcess();
     $create = $subSelect1 = $subSelect2 = NULL;
     list($fromTable, $fromAlias, $fromCol) = $this->groupBy(TRUE);
@@ -858,13 +849,13 @@ currency varchar(3)
         $rows[$uid]['change'] = ts('New Donor');
       }
       if ($row['contribution1_total_amount_count']) {
-        $rows[$uid]['contribution1_total_amount_sum'] =
-          $row['contribution1_total_amount_sum'] .
+        $rows[$uid]['contribution1_total_amount_sum']
+          $row['contribution1_total_amount_sum'] .
           " ({$row['contribution1_total_amount_count']})";
       }
       if ($row['contribution2_total_amount_count']) {
-        $rows[$uid]['contribution2_total_amount_sum'] =
-          $row['contribution2_total_amount_sum'] .
+        $rows[$uid]['contribution2_total_amount_sum']
+          $row['contribution2_total_amount_sum'] .
           " ({$row['contribution2_total_amount_count']})";
       }
     }
@@ -905,7 +896,7 @@ currency varchar(3)
   /**
    * @param $rows
    */
-  function alterDisplay(&$rows) {
+  public function alterDisplay(&$rows) {
     // custom code to alter rows
     list($from1, $to1) = $this->getFromTo(CRM_Utils_Array::value("receive_date1_relative", $this->_params),
       CRM_Utils_Array::value("receive_date1_from", $this->_params),
@@ -981,4 +972,3 @@ currency varchar(3)
     // foreach ends
   }
 }
-