$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 = "
$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) {