Exemplo n.º 1
0
 public function getStatIntervalValues($stats_interval)
 {
     $this->setStatesCSV();
     $interval = new stdClass();
     switch ($stats_interval) {
         case "annually":
             $firstsale_date = CitruscartHelperOrder::getDateMarginalOrder($this->getStatesCSV(), 'ASC');
             $interval->date_from = date('Y-01-01 00:00:00', strtotime($firstsale_date));
             $interval->date_to = 'NOW';
             $interval->next_date = '+1 year';
             $interval->step = '1';
             $interval->pointinterval = 365 * 24 * 3600 * 1000;
             // one year
             $interval->index_format = 'Y-01-01';
             $interval->current_date_format = 'Y-01-01';
             $interval->end_date_format = 'Y-12-31';
             $interval->hour_format = '0';
             break;
         case "today":
             $interval->date_from = date('Y-m-d 00:00:00', strtotime('NOW'));
             $interval->date_to = date('Y-m-d 23:59:59', strtotime('NOW'));
             $interval->next_date = '+1 hour';
             $interval->step = 1;
             $interval->pointinterval = 3600 * 1000;
             // one hour
             $interval->index_format = 'Y-m-d H:00:00';
             $interval->current_date_format = 'Y-m-d H:00:00';
             $interval->end_date_format = 'Y-m-d 23:59:59';
             $interval->hour_format = 'H';
             break;
         case "yesterday":
             $interval->date_from = date('Y-m-d 00:00:00', strtotime('yesterday'));
             $interval->date_to = date('Y-m-d 23:59:59', strtotime('yesterday'));
             $interval->next_date = '+1 hour';
             $interval->step = 1;
             $interval->pointinterval = 3600 * 1000;
             // one hour
             $interval->index_format = 'Y-m-d H:00:00';
             $interval->current_date_format = 'Y-m-d H:00:00';
             $interval->end_date_format = 'Y-m-d 23:59:59';
             $interval->hour_format = 'H';
             break;
         case "ytd":
             $interval->date_from = date('Y', strtotime('NOW')) . '-01-01';
             $interval->date_to = 'NOW';
             $interval->next_date = '+1 month';
             $interval->step = 1;
             $interval->pointinterval = 30.25 * 24 * 3600 * 1000;
             // one month
             $interval->index_format = 'Y-m-01';
             $interval->current_date_format = 'Y-m-d';
             $interval->end_date_format = 'Y-m-d';
             $interval->hour_format = '0';
             break;
         case "last_seven":
             $interval->date_from = 'NOW -7 days';
             $interval->date_to = 'NOW';
             $interval->next_date = '+1 day';
             $interval->step = '1';
             $interval->pointinterval = 24 * 3600 * 1000;
             // one day
             $interval->index_format = 'Y-m-d';
             $interval->current_date_format = 'Y-m-d';
             $interval->end_date_format = 'Y-m-d';
             $interval->hour_format = '0';
             break;
         case "last_thirty":
         default:
             $interval->date_from = 'NOW -30 days';
             $interval->date_to = 'NOW';
             $interval->next_date = '+1 day';
             $interval->step = '7';
             $interval->pointinterval = 24 * 3600 * 1000;
             // one day
             $interval->index_format = 'Y-m-d';
             $interval->current_date_format = 'Y-m-d';
             $interval->end_date_format = 'Y-m-d';
             $interval->hour_format = '0';
             break;
     }
     return $interval;
 }
Exemplo n.º 2
0
 /**
  * _lifetime function.
  *
  * @access private
  * @return void
  */
 function _lifetime()
 {
     $database = JFactory::getDBO();
     $today = CitruscartHelperBase::getToday();
     Citruscart::load('CitruscartHelperOrder', 'helpers.order');
     $firstsale_date = CitruscartHelperOrder::getDateMarginalOrder($this->getStatesCSV(), 'ASC');
     $lastsale_date = CitruscartHelperOrder::getDateMarginalOrder($this->getStatesCSV(), 'DESC');
     $return = $this->_getDateDb($firstsale_date, $lastsale_date);
     $days = $return->days_in_business > 0 ? $return->days_in_business : 1;
     $return->average_daily = $return->num / $days;
     return $return;
 }