private function statspro::get_period in Statistics Pro 6
Same name and namespace in other branches
- 6.2 statspro.inc \StatsPro::get_period()
Generate SQL fragment for period query.
1 call to statspro::get_period()
- statspro::get_stats in ./
statspro.inc - Get statictics for output.
File
- ./
statspro.inc, line 359 - statspro class for statistics pro module.
Class
- statspro
- Manages the data saving and retrieval according to the user defined parameters.
Code
private function get_period() {
$now = time();
switch ($this->period) {
case 'today':
$today = date('Ymd', $now);
return sprintf('day = %u', $today);
break;
case 'yesterday':
$day = date('Ymd', strtotime('-1 day', $now));
return sprintf('day = %u', $day);
break;
case 'week_current':
$min = $this
->get_first_day_of_week_from_reference($now);
$max = date('Ymd', $now);
return $this
->get_min_max_period($min, $max);
break;
case 'week_last':
$reference = strtotime('-1 week', $now);
return $this
->get_week_from_reference($reference);
break;
case 'week_last2':
$reference = strtotime('-2 week', $now);
return $this
->get_week_from_reference($reference);
break;
case 'month_current':
$min = $this
->get_first_day_of_month_from_reference($now);
$max = date('Ymd', $now);
return $this
->get_min_max_period($min, $max);
break;
case 'month_last':
$reference = strtotime('-1 month', $now);
return $this
->get_month_from_reference($reference);
break;
case 'month_last3':
$reference = strtotime('-3 month', $now);
$min = $this
->get_first_day_of_month_from_reference($reference);
$max = date('Ymd', $now);
return $this
->get_min_max_period($min, $max);
break;
case 'month_last6':
$reference = strtotime('-6 month', $now);
$min = $this
->get_first_day_of_month_from_reference($reference);
$max = date('Ymd', $now);
return $this
->get_min_max_period($min, $max);
break;
case 'quarter_current':
$min = $this
->get_first_day_of_quarter_from_reference($now);
$max = date('Ymd', $now);
return $this
->get_min_max_period($min, $max);
break;
case 'quarter_last':
$reference = strtotime('-3 month', $now);
$min = $this
->get_first_day_of_quarter_from_reference($reference);
$max = $this
->get_last_day_of_quarter_from_reference($reference);
return $this
->get_min_max_period($min, $max);
break;
case 'year_current':
$min = $this
->get_first_day_of_year_from_reference($now);
$max = date('Ymd', $now);
return $this
->get_min_max_period($min, $max);
break;
case 'year_last':
$reference = strtotime('-1 year', $now);
$min = $this
->get_first_day_of_year_from_reference($reference);
$max = $this
->get_last_day_of_year_from_reference($reference);
return $this
->get_min_max_period($min, $max);
break;
default:
watchdog('statspro', "Unknown period '@period'.", array(
'@period' => $this->period,
), WATCHDOG_ERROR);
return FALSE;
break;
}
}