Mage_Reports_Model_Mysql4_Report_Collection Class Reference

List of all members.

Public Member Functions

 setPeriod ($period)
 setInterval ($from, $to)
 getIntervals ()
 getPeriods ()
 setStoreIds ($storeIds)
 getStoreIds ()
 getSize ()
 setPageSize ($size)
 getPageSize ()
 initReport ($modelClass)
 getReportFull ($from, $to)
 getReport ($from, $to)
 timeShift ($datetime)

Protected Member Functions

 _construct ()

Protected Attributes

 $_from
 $_to
 $_period
 $_model
 $_intervals
 $_pageSize
 $_storeIds


Detailed Description

Definition at line 35 of file Collection.php.


Member Function Documentation

_construct (  )  [protected]

Definition at line 50 of file Collection.php.

00051     {
00052 
00053     }

getIntervals (  ) 

Definition at line 66 of file Collection.php.

00067     {
00068         if (!$this->_intervals) {
00069             $this->_intervals = array();
00070             if (!$this->_from && !$this->_to){
00071                 return $this->_intervals;
00072             }
00073             $dateStart = new Zend_Date($this->_from);
00074             $dateStart2 = new Zend_Date($this->_from);
00075 
00076             $dateEnd = new Zend_Date($this->_to);
00077 
00078 
00079             $t = array();
00080             while ($dateStart->compare($dateEnd)<=0) {
00081 
00082                 switch ($this->_period) {
00083                     case 'day' :
00084                         $t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
00085                         $t['start'] = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
00086                         $t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
00087                         $dateStart->addDay(1);
00088                         break;
00089                     case 'month':
00090                         $t['title'] =  $dateStart->toString('MM/yyyy');
00091                         $t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
00092                         $t['end'] = $dateStart->toString('yyyy-MM-'.date('t', $dateStart->getTimestamp()).' 23:59:59');
00093                         $dateStart->addMonth(1);
00094                         break;
00095                     case 'year':
00096                         $t['title'] =  $dateStart->toString('yyyy');
00097                         $t['start'] = $dateStart->toString('yyyy-01-01 00:00:00');
00098                         $t['end'] = $dateStart->toString('yyyy-12-31 23:59:59');
00099                         $dateStart->addYear(1);
00100                         break;
00101                 }
00102                 $this->_intervals[$t['title']] = $t;
00103             }
00104 
00105             if ($this->_period != 'day') {
00106                 $titles = array_keys($this->_intervals);
00107                 if (count($titles) > 0) {
00108                     $this->_intervals[$titles[0]]['start'] = $dateStart2->toString('yyyy-MM-dd 00:00:00');
00109                     $this->_intervals[$titles[count($titles)-1]]['end'] = $dateEnd->toString('yyyy-MM-dd 23:59:59');
00110                 }
00111             }
00112         }
00113         return  $this->_intervals;
00114     }

getPageSize (  ) 

Definition at line 152 of file Collection.php.

00153     {
00154         return $this->_pageSize;
00155     }

getPeriods (  ) 

Return date periods

Returns:
array

Definition at line 122 of file Collection.php.

00123     {
00124         return array(
00125             'day'=>Mage::helper('reports')->__('Day'),
00126             'month'=>Mage::helper('reports')->__('Month'),
00127             'year'=>Mage::helper('reports')->__('Year')
00128         );
00129     }

getReport ( from,
to 
)

Definition at line 176 of file Collection.php.

00177     {
00178         return $this->_model->getReport($this->timeShift($from), $this->timeShift($to));
00179     }

getReportFull ( from,
to 
)

Definition at line 171 of file Collection.php.

00172     {
00173         return $this->_model->getReportFull($this->timeShift($from), $this->timeShift($to));
00174     }

getSize (  ) 

Definition at line 141 of file Collection.php.

00142     {
00143         return count($this->getIntervals());
00144     }

getStoreIds (  ) 

Definition at line 136 of file Collection.php.

00137     {
00138         return $this->_storeIds;
00139     }

initReport ( modelClass  ) 

Definition at line 157 of file Collection.php.

00158     {
00159         //$this->_modelArray = array();
00160         //foreach ($this->getIntervals() as $key=>$interval) {
00161             $this->_model = Mage::getModel('reports/report')
00162                 ->setPageSize($this->getPageSize())
00163                 ->setStoreIds($this->getStoreIds())
00164                 ->initCollection($modelClass);
00165                 //->setPeriodTitle($interval['title']);
00166                 //->setStartDate($interval['start'])
00167                 //->setEndDate($interval['end']);
00168         //}
00169     }

setInterval ( from,
to 
)

Definition at line 60 of file Collection.php.

00061     {
00062         $this->_from = $from;
00063         $this->_to = $to;
00064     }

setPageSize ( size  ) 

Definition at line 146 of file Collection.php.

00147     {
00148         $this->_pageSize = $size;
00149         return $this;
00150     }

setPeriod ( period  ) 

Definition at line 55 of file Collection.php.

00056     {
00057         $this->_period = $period;
00058     }

setStoreIds ( storeIds  ) 

Definition at line 131 of file Collection.php.

00132     {
00133         $this->_storeIds = $storeIds;
00134     }

timeShift ( datetime  ) 

Definition at line 181 of file Collection.php.

00182     {
00183         return date('Y-m-d H:i:s', strtotime($datetime) - Mage::getModel('core/date')->getGmtOffset());
00184     }


Member Data Documentation

$_from [protected]

Definition at line 38 of file Collection.php.

$_intervals [protected]

Definition at line 44 of file Collection.php.

$_model [protected]

Definition at line 42 of file Collection.php.

$_pageSize [protected]

Definition at line 46 of file Collection.php.

$_period [protected]

Definition at line 40 of file Collection.php.

$_storeIds [protected]

Definition at line 48 of file Collection.php.

$_to [protected]

Definition at line 39 of file Collection.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:37 2009 for Magento by  doxygen 1.5.8