break;
case 'week':
+ $weekFirst = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'weekBegins', NULL, 0);;
+ $thisDay = $now['wday'];
+ if ($weekFirst > $thisDay){
+ $diffDay = $thisDay - $weekFirst + 7;
+ }
+ else {
+ $diffDay = $thisDay - $weekFirst;
+ }
switch ($relativeTerm) {
case 'this':
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']), $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay), $from);
$to = self::intervalAdd('day', 6, $from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) - 7, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) - 7, $from);
$to = self::intervalAdd('day', 6, $from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) - 14, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) - 14, $from);
$to = self::intervalAdd('day', 6, $from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) - 14, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) - 14, $from);
$to = self::intervalAdd('day', 13, $from);
break;
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
$to['Y'] = $now['year'];
- $to = self::intervalAdd('day', -1 * ($now['wday']) - 1, $to);
+ $to = self::intervalAdd('day', -1 * ($diffDay) - 1, $to);
unset($from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']), $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay), $from);
unset($to);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) - 1, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) - 1, $from);
unset($to);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']), $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay), $from);
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
$to['Y'] = $now['year'];
$to['M'] = $now['mon'];
$to['Y'] = $now['year'];
//CRM-14550 QA Fix
- $to = self::intervalAdd('day', -1 * ($now['wday']) + 6, $to);
+ $to = self::intervalAdd('day', -1 * ($diffDay) + 6, $to);
unset($from);
break;
$from['d'] = $now['mday'];
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
- $from = self::intervalAdd('day', -1 * ($now['wday']) + 7, $from);
+ $from = self::intervalAdd('day', -1 * ($diffDay) + 7, $from);
$to = self::intervalAdd('day', 6, $from);
break;