function __construct($module = null, $caller_params = array())
 {
     $this->caller_params = $caller_params;
     $c = owa_coreAPI::configSingleton();
     $this->config = $c->fetch('base');
     $this->e = owa_coreAPI::errorSingleton();
     // set template dirs
     if (!empty($caller_params['module'])) {
         $this->_setTemplateDir($module);
     } else {
         $this->_setTemplateDir('base');
     }
     $this->time_now = owa_lib::time_now();
 }
 function _setDates($map = array())
 {
     $time_now = owa_lib::time_now();
     $nowDate = owa_coreAPI::supportClassFactory('base', 'date');
     $nowDate->set(time(), 'timestamp');
     $start = '';
     $end = '';
     switch ($this->period) {
         case "today":
             $start = mktime(0, 0, 0, $time_now['month'], $time_now['day'], $time_now['year']);
             $end = $start + 3600 * 24 - 1;
             break;
         case "last_24_hours":
             $end = $time_now['timestamp'];
             $start = $end - 3600 * 24;
             break;
         case "last_hour":
             $end = $time_now['timestamp'];
             $start = $end - 3600;
             break;
         case "last_half_hour":
             $end = $time_now['timestamp'];
             $start = $end - 1800;
             break;
         case "last_seven_days":
             //$end = mktime(0, 0, 0, $time_now['month'], $time_now['day']+1, $time_now['year']);
             $end = mktime(23, 59, 59, $time_now['month'], $time_now['day'], $time_now['year']);
             $start = $end - 3600 * 24 * 7;
             break;
         case "this_week":
             $end = mktime(23, 59, 59, $time_now['month'], $time_now['day'], $time_now['year']) + (6 - $nowDate->get('day_of_week')) * 3600 * 24;
             $start = mktime(0, 0, 0, $time_now['month'], $time_now['day'], $time_now['year']) - $nowDate->get('day_of_week') * 3600 * 24;
             break;
         case "this_month":
             $start = mktime(0, 0, 0, $time_now['month'], 1, $time_now['year']);
             $end = mktime(23, 59, 59, $time_now['month'], $nowDate->get('num_days_in_month'), $time_now['year']);
             break;
         case "this_year":
             $start = mktime(0, 0, 0, 1, 1, $time_now['year']);
             $end = mktime(23, 59, 59, 12, 31, $time_now['year']);
             break;
         case "yesterday":
             $end = mktime(0, 0, 0, $time_now['month'], $time_now['day'], $time_now['year']);
             $start = $end - 3600 * 24;
             $end = $end - 1;
             break;
         case "last_week":
             $day = $time_now['day'] - $time_now['dayofweek'] - 7;
             $start = mktime(0, 0, 0, $time_now['month'], $day, $time_now['year']);
             $end = $start + 3600 * 24 * 7;
             break;
         case "last_month":
             $month = $time_now['month'] - 1;
             $start = mktime(0, 0, 0, $month, 1, $time_now['year']);
             $last = owa_coreAPI::supportClassFactory('base', 'date');
             $last->set($start, 'timestamp');
             $end = mktime(23, 59, 59, $last->get('month'), $last->get('num_days_in_month'), $last->get('year'));
             break;
         case "last_year":
             $year = $time_now['year'] - 1;
             $start = mktime(0, 0, 0, 1, 1, $year);
             $end = mktime(23, 59, 59, 12, 31, $year);
             break;
         case "same_day_last_week":
             $start = mktime(0, 0, 0, $time_now['month'], $time_now['day'], $time_now['year']) - 3600 * 24 * 7;
             $end = $start + 3600 * 24 - 1;
             break;
             ///
         ///
         case "same_month_last_year":
             $year = $time_now['year'] - 1;
             $month = $time_now['month'];
             $start = mktime(0, 0, 0, $month, 1, $year);
             $last = owa_coreAPI::supportClassFactory('base', 'date');
             $last->set($start, 'timestamp');
             $end = mktime(23, 59, 59, $month, $last->get('num_days_in_month'), $year);
             break;
         case "all_time":
             $end = time();
             $start = mktime(0, 0, 0, 1, 1, 1969);
             break;
         case "last_thirty_days":
             $end = mktime(23, 59, 59, $time_now['month'], $time_now['day'], $time_now['year']);
             $start = $end + 1 - 30 * 3600 * 24;
             break;
         case "date_range":
             list($year, $month, $day) = sscanf($map['startDate'], "%4d%2d%2d");
             $start = mktime(0, 0, 0, $month, $day, $year);
             list($year, $month, $day) = sscanf($map['endDate'], "%4d%2d%2d");
             $end = mktime(23, 59, 59, $month, $day, $year);
             break;
         case "time_range":
             $start = $map['startTime'];
             $end = $map['endTime'];
             break;
         case "day":
             list($year, $month, $day) = sscanf($map['startDate'], "%4d%2d%2d");
             $start = mktime(0, 0, 0, $month, $day, $year);
             $end = mktime(23, 59, 59, $month, $day, $year);
             break;
     }
     $this->startDate->set($start, 'timestamp');
     $this->endDate->set($end, 'timestamp');
 }