Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Reports_Block_Product_Abstract
  • Mage_Reports_Block_Product_Compared
  • Mage_Reports_Block_Product_Viewed
  • Mage_Reports_Block_Product_Widget_Compared
  • Mage_Reports_Block_Product_Widget_Viewed
  • Mage_Reports_Exception
  • Mage_Reports_Helper_Data
  • Mage_Reports_Model_Config
  • Mage_Reports_Model_Event
  • Mage_Reports_Model_Event_Observer
  • Mage_Reports_Model_Event_Type
  • Mage_Reports_Model_Flag
  • Mage_Reports_Model_Grouped_Collection
  • Mage_Reports_Model_Mysql4_Accounts_Collection
  • Mage_Reports_Model_Mysql4_Coupons_Collection
  • Mage_Reports_Model_Mysql4_Customer_Collection
  • Mage_Reports_Model_Mysql4_Customer_Orders_Collection
  • Mage_Reports_Model_Mysql4_Customer_Totals_Collection
  • Mage_Reports_Model_Mysql4_Entity_Summary_Collection_Abstract
  • Mage_Reports_Model_Mysql4_Event
  • Mage_Reports_Model_Mysql4_Event_Collection
  • Mage_Reports_Model_Mysql4_Event_Type
  • Mage_Reports_Model_Mysql4_Event_Type_Collection
  • Mage_Reports_Model_Mysql4_Invoiced_Collection
  • Mage_Reports_Model_Mysql4_Order_Collection
  • Mage_Reports_Model_Mysql4_Product_Collection
  • Mage_Reports_Model_Mysql4_Product_Downloads_Collection
  • Mage_Reports_Model_Mysql4_Product_Index_Abstract
  • Mage_Reports_Model_Mysql4_Product_Index_Collection_Abstract
  • Mage_Reports_Model_Mysql4_Product_Index_Compared
  • Mage_Reports_Model_Mysql4_Product_Index_Compared_Collection
  • Mage_Reports_Model_Mysql4_Product_Index_Viewed
  • Mage_Reports_Model_Mysql4_Product_Index_Viewed_Collection
  • Mage_Reports_Model_Mysql4_Product_Lowstock_Collection
  • Mage_Reports_Model_Mysql4_Product_Ordered_Collection
  • Mage_Reports_Model_Mysql4_Product_Sold_Collection
  • Mage_Reports_Model_Mysql4_Product_Viewed_Collection
  • Mage_Reports_Model_Mysql4_Quote_Collection
  • Mage_Reports_Model_Mysql4_Refunded_Collection
  • Mage_Reports_Model_Mysql4_Report_Abstract
  • Mage_Reports_Model_Mysql4_Report_Collection
  • Mage_Reports_Model_Mysql4_Review_Collection
  • Mage_Reports_Model_Mysql4_Review_Customer_Collection
  • Mage_Reports_Model_Mysql4_Review_Product_Collection
  • Mage_Reports_Model_Mysql4_Shipping_Collection
  • Mage_Reports_Model_Mysql4_Tag_Collection
  • Mage_Reports_Model_Mysql4_Tag_Customer_Collection
  • Mage_Reports_Model_Mysql4_Tag_Product_Collection
  • Mage_Reports_Model_Mysql4_Tax_Collection
  • Mage_Reports_Model_Mysql4_Wishlist_Collection
  • Mage_Reports_Model_Mysql4_Wishlist_Product_Collection
  • Mage_Reports_Model_Product_Index_Abstract
  • Mage_Reports_Model_Product_Index_Compared
  • Mage_Reports_Model_Product_Index_Viewed
  • Mage_Reports_Model_Report
  • Mage_Reports_Model_Resource_Accounts_Collection
  • Mage_Reports_Model_Resource_Coupons_Collection
  • Mage_Reports_Model_Resource_Customer_Collection
  • Mage_Reports_Model_Resource_Customer_Orders_Collection
  • Mage_Reports_Model_Resource_Customer_Totals_Collection
  • Mage_Reports_Model_Resource_Entity_Summary_Collection_Abstract
  • Mage_Reports_Model_Resource_Event
  • Mage_Reports_Model_Resource_Event_Collection
  • Mage_Reports_Model_Resource_Event_Type
  • Mage_Reports_Model_Resource_Event_Type_Collection
  • Mage_Reports_Model_Resource_Helper_Mysql4
  • Mage_Reports_Model_Resource_Invoiced_Collection
  • Mage_Reports_Model_Resource_Order_Collection
  • Mage_Reports_Model_Resource_Product_Collection
  • Mage_Reports_Model_Resource_Product_Downloads_Collection
  • Mage_Reports_Model_Resource_Product_Index_Abstract
  • Mage_Reports_Model_Resource_Product_Index_Collection_Abstract
  • Mage_Reports_Model_Resource_Product_Index_Compared
  • Mage_Reports_Model_Resource_Product_Index_Compared_Collection
  • Mage_Reports_Model_Resource_Product_Index_Viewed
  • Mage_Reports_Model_Resource_Product_Index_Viewed_Collection
  • Mage_Reports_Model_Resource_Product_Lowstock_Collection
  • Mage_Reports_Model_Resource_Product_Ordered_Collection
  • Mage_Reports_Model_Resource_Product_Sold_Collection
  • Mage_Reports_Model_Resource_Product_Viewed_Collection
  • Mage_Reports_Model_Resource_Quote_Collection
  • Mage_Reports_Model_Resource_Refunded_Collection
  • Mage_Reports_Model_Resource_Report_Abstract
  • Mage_Reports_Model_Resource_Report_Collection
  • Mage_Reports_Model_Resource_Report_Collection_Abstract
  • Mage_Reports_Model_Resource_Report_Product_Viewed
  • Mage_Reports_Model_Resource_Report_Product_Viewed_Collection
  • Mage_Reports_Model_Resource_Review_Collection
  • Mage_Reports_Model_Resource_Review_Customer_Collection
  • Mage_Reports_Model_Resource_Review_Product_Collection
  • Mage_Reports_Model_Resource_Shipping_Collection
  • Mage_Reports_Model_Resource_Shopcart_Product_Collection
  • Mage_Reports_Model_Resource_Tag_Collection
  • Mage_Reports_Model_Resource_Tag_Customer_Collection
  • Mage_Reports_Model_Resource_Tag_Product_Collection
  • Mage_Reports_Model_Resource_Tax_Collection
  • Mage_Reports_Model_Resource_Wishlist_Collection
  • Mage_Reports_Model_Resource_Wishlist_Product_Collection
  • Mage_Reports_Model_Session
  • Mage_Reports_Model_Test
  • Mage_Reports_Model_Totals

Interfaces

  • Mage_Reports_Model_Resource_Helper_Interface
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Reports
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Report Reviews collection
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Reports
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Reports_Model_Resource_Report_Collection
 36: {
 37:     /**
 38:      * From value
 39:      *
 40:      * @var string
 41:      */
 42:     protected $_from;
 43: 
 44:     /**
 45:      * To value
 46:      *
 47:      * @var string
 48:      */
 49:     protected $_to;
 50: 
 51:     /**
 52:      * Report period
 53:      *
 54:      * @var int
 55:      */
 56:     protected $_period;
 57: 
 58:     /**
 59:      * Model object
 60:      *
 61:      * @var string
 62:      */
 63:     protected $_model;
 64: 
 65:     /**
 66:      * Intervals
 67:      *
 68:      * @var int
 69:      */
 70:     protected $_intervals;
 71: 
 72:     /**
 73:      * Page size
 74:      *
 75:      * @var int
 76:      */
 77:     protected $_pageSize;
 78: 
 79:     /**
 80:      * Array of store ids
 81:      *
 82:      * @var array
 83:      */
 84:     protected $_storeIds;
 85: 
 86:     /**
 87:      * Resource initialization
 88:      *
 89:      */
 90:     protected function _construct()
 91:     {
 92: 
 93:     }
 94: 
 95:     /**
 96:      * Set period
 97:      *
 98:      * @param int $period
 99:      * @return Mage_Reports_Model_Resource_Report_Collection
100:      */
101:     public function setPeriod($period)
102:     {
103:         $this->_period = $period;
104:         return $this;
105:     }
106: 
107:     /**
108:      * Set interval
109:      *
110:      * @param int $from
111:      * @param int $to
112:      * @return Mage_Reports_Model_Resource_Report_Collection
113:      */
114:     public function setInterval($from, $to)
115:     {
116:         $this->_from = $from;
117:         $this->_to   = $to;
118: 
119:         return $this;
120:     }
121: 
122:     /**
123:      * Get intervals
124:      *
125:      * @return unknown
126:      */
127:     public function getIntervals()
128:     {
129:         if (!$this->_intervals) {
130:             $this->_intervals = array();
131:             if (!$this->_from && !$this->_to) {
132:                 return $this->_intervals;
133:             }
134:             $dateStart  = new Zend_Date($this->_from);
135:             $dateEnd    = new Zend_Date($this->_to);
136: 
137: 
138:             $t = array();
139:             $firstInterval = true;
140:             while ($dateStart->compare($dateEnd) <= 0) {
141: 
142:                 switch ($this->_period) {
143:                     case 'day':
144:                         $t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
145:                         $t['start'] = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
146:                         $t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
147:                         $dateStart->addDay(1);
148:                         break;
149:                     case 'month':
150:                         $t['title'] =  $dateStart->toString('MM/yyyy');
151:                         $t['start'] = ($firstInterval) ? $dateStart->toString('yyyy-MM-dd 00:00:00')
152:                             : $dateStart->toString('yyyy-MM-01 00:00:00');
153: 
154:                         $lastInterval = ($dateStart->compareMonth($dateEnd->getMonth()) == 0);
155: 
156:                         $t['end'] = ($lastInterval) ? $dateStart->setDay($dateEnd->getDay())
157:                             ->toString('yyyy-MM-dd 23:59:59')
158:                             : $dateStart->toString('yyyy-MM-'.date('t', $dateStart->getTimestamp()).' 23:59:59');
159: 
160:                         $dateStart->addMonth(1);
161: 
162:                         if ($dateStart->compareMonth($dateEnd->getMonth()) == 0) {
163:                             $dateStart->setDay(1);
164:                         }
165: 
166:                         $firstInterval = false;
167:                         break;
168:                     case 'year':
169:                         $t['title'] =  $dateStart->toString('yyyy');
170:                         $t['start'] = ($firstInterval) ? $dateStart->toString('yyyy-MM-dd 00:00:00')
171:                             : $dateStart->toString('yyyy-01-01 00:00:00');
172: 
173:                         $lastInterval = ($dateStart->compareYear($dateEnd->getYear()) == 0);
174: 
175:                         $t['end'] = ($lastInterval) ? $dateStart->setMonth($dateEnd->getMonth())
176:                             ->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59')
177:                             : $dateStart->toString('yyyy-12-31 23:59:59');
178:                         $dateStart->addYear(1);
179: 
180:                         if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
181:                             $dateStart->setMonth(1)->setDay(1);
182:                         }
183: 
184:                         $firstInterval = false;
185:                         break;
186:                 }
187:                 $this->_intervals[$t['title']] = $t;
188:             }
189:         }
190:         return  $this->_intervals;
191:     }
192: 
193:     /**
194:      * Return date periods
195:      *
196:      * @return array
197:      */
198:     public function getPeriods()
199:     {
200:         return array(
201:             'day'   => Mage::helper('reports')->__('Day'),
202:             'month' => Mage::helper('reports')->__('Month'),
203:             'year'  => Mage::helper('reports')->__('Year')
204:         );
205:     }
206: 
207:     /**
208:      * Set store ids
209:      *
210:      * @param array $storeIds
211:      * @return Mage_Reports_Model_Resource_Report_Collection
212:      */
213:     public function setStoreIds($storeIds)
214:     {
215:         $this->_storeIds = $storeIds;
216:         return $this;
217:     }
218: 
219:     /**
220:      * Get store ids
221:      *
222:      * @return arrays
223:      */
224:     public function getStoreIds()
225:     {
226:         return $this->_storeIds;
227:     }
228: 
229:     /**
230:      * Get size
231:      *
232:      * @return int
233:      */
234:     public function getSize()
235:     {
236:         return count($this->getIntervals());
237:     }
238: 
239:     /**
240:      * Set page size
241:      *
242:      * @param int $size
243:      * @return Mage_Reports_Model_Resource_Report_Collection
244:      */
245:     public function setPageSize($size)
246:     {
247:         $this->_pageSize = $size;
248:         return $this;
249:     }
250: 
251:     /**
252:      * Get page size
253:      *
254:      * @return int
255:      */
256:     public function getPageSize()
257:     {
258:         return $this->_pageSize;
259:     }
260: 
261:     /**
262:      * Init report
263:      *
264:      * @param string $modelClass
265:      * @return Mage_Reports_Model_Resource_Report_Collection
266:      */
267:     public function initReport($modelClass)
268:     {
269:         $this->_model = Mage::getModel('reports/report')
270:             ->setPageSize($this->getPageSize())
271:             ->setStoreIds($this->getStoreIds())
272:             ->initCollection($modelClass);
273: 
274:         return $this;
275:     }
276: 
277:     /**
278:      * get report full
279:      *
280:      * @param int $from
281:      * @param int $to
282:      * @return unknown
283:      */
284:     public function getReportFull($from, $to)
285:     {
286:         return $this->_model->getReportFull($this->timeShift($from), $this->timeShift($to));
287:     }
288: 
289:     /**
290:      * Get report
291:      *
292:      * @param int $from
293:      * @param int $to
294:      * @return Varien_Object
295:      */
296:     public function getReport($from, $to)
297:     {
298:         return $this->_model->getReport($this->timeShift($from), $this->timeShift($to));
299:     }
300: 
301:     /**
302:      * Retreive time shift
303:      *
304:      * @param string $datetime
305:      * @return string
306:      */
307:     public function timeShift($datetime)
308:     {
309:         return Mage::app()->getLocale()
310:             ->utcDate(null, $datetime, true, Varien_Date::DATETIME_INTERNAL_FORMAT)
311:             ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
312:     }
313: }
314: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0