From: Kurund Jalmi Date: Tue, 7 May 2013 04:54:02 +0000 (-0700) Subject: patched CRM-12437 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a48278eb5285052620892b6e6127139877b5658a;p=civicrm-core.git patched CRM-12437 --- diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index 37db9cd461..624a100907 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -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 = " diff --git a/CRM/Contribute/Form/ContributionCharts.php b/CRM/Contribute/Form/ContributionCharts.php index 2ad052ad55..ce2fdc288a 100644 --- a/CRM/Contribute/Form/ContributionCharts.php +++ b/CRM/Contribute/Form/ContributionCharts.php @@ -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) {