patched CRM-12437
authorKurund Jalmi <kurund@civicrm.org>
Tue, 7 May 2013 04:54:02 +0000 (21:54 -0700)
committerKurund Jalmi <kurund@civicrm.org>
Tue, 7 May 2013 04:54:02 +0000 (21:54 -0700)
CRM/Contribute/BAO/Contribution/Utils.php
CRM/Contribute/Form/ContributionCharts.php

index 37db9cd46119614aa4b7e4d5c5940c24ef74be32..624a1009078d881c1109ea916bd74ea4b5345799 100644 (file)
@@ -378,11 +378,14 @@ INNER JOIN   civicrm_contact AS contact ON ( contact.id = contrib.contact_id )
     $config = CRM_Core_Config::singleton();
     $yearClause = "year(contrib.receive_date) as contribYear";
     if (!empty($config->fiscalYearStart) && ($config->fiscalYearStart['M'] != 1 || $config->fiscalYearStart['d'] != 1)) {
-      $yearClause = "CASE WHEN DAYOFYEAR(contrib.receive_date)>= " .
-        date('z',mktime(0, 0, 0, $config->fiscalYearStart['M'], $config->fiscalYearStart['d']+1, 2000)) .
-        " THEN
-          concat(YEAR(contrib.receive_date), '-',YEAR(contrib.receive_date)+1)
-   ELSE concat(YEAR(contrib.receive_date)-1,'-', YEAR(contrib.receive_date)) END AS contribYear";
+      $yearClause = "CASE
+        WHEN (MONTH(contrib.receive_date)>= " . $config->fiscalYearStart['M'] . "
+               && DAYOFMONTH(contrib.receive_date)>= " . $config->fiscalYearStart['d'] . " )
+          THEN
+            concat(YEAR(contrib.receive_date), '-',YEAR(contrib.receive_date)+1)
+          ELSE
+            concat(YEAR(contrib.receive_date)-1,'-', YEAR(contrib.receive_date))
+        END AS contribYear";
     }
 
     $query = "
index 2ad052ad554c45625f8d3c97368f72e0d1272e30..ce2fdc288aa19f9a3e55223a058ccc6d347e9f0f 100644 (file)
@@ -200,8 +200,14 @@ class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form {
           $urlParams     = "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0";
         }
         elseif ($chartKey == 'by_year') {
-          $startDate = CRM_Utils_Date::format(array('Y' => substr($index,0,4)));
-          $endDate   = date('Ymd', mktime(0, 0, 0, 13, 0, substr($index,0,4)));
+          if (!empty($config->fiscalYearStart) && ($config->fiscalYearStart['M'] != 1 || $config->fiscalYearStart['d'] != 1)) {
+            $startDate = date('Ymd', mktime(0, 0, 0, $config->fiscalYearStart['M'], $config->fiscalYearStart['d'], substr($index,0,4)));
+            $endDate   = date('Ymd', mktime(0, 0, 0, $config->fiscalYearStart['M'], $config->fiscalYearStart['d'], substr($index,0,4)+1));
+          }
+          else {
+            $startDate = CRM_Utils_Date::format(array('Y' => substr($index,0,4)));
+            $endDate   = date('Ymd', mktime(0, 0, 0, 13, 0, substr($index,0,4)));
+          }
           $urlParams = "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0";
         }
         if ($urlParams) {