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: * Reports summary collection
30: *
31: * @category Mage
32: * @package Mage_Reports
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Reports_Model_Resource_Entity_Summary_Collection_Abstract extends Varien_Data_Collection
36: {
37: /**
38: * Entity collection for summaries
39: *
40: * @var Mage_Entity_Model_Entity_Collection_Abstract
41: */
42: protected $_entityCollection;
43:
44: /**
45: * Filters the summaries by some period
46: *
47: * @param string $periodType
48: * @param string|int|null $customStart
49: * @param string|int|null $customEnd
50: * @return Mage_Reports_Model_Resource_Entity_Summary_Collection_Abstract
51: */
52: public function setSelectPeriod($periodType, $customStart = null, $customEnd = null)
53: {
54: switch ($periodType) {
55: case "24h":
56: $customStart = Varien_Date::toTimestamp(true) - 86400;
57: $customEnd = Varien_Date::toTimestamp(true);
58: break;
59:
60: case "7d":
61: $customStart = Varien_Date::toTimestamp(true) - 604800;
62: $customEnd = Varien_Date::toTimestamp(true);
63: break;
64:
65: case "30d":
66: $customStart = Varien_Date::toTimestamp(true) - 2592000;
67: $customEnd = Varien_Date::toTimestamp(true);
68: break;
69:
70: case "1y":
71: $customStart = Varien_Date::toTimestamp(true) - 31536000;
72: $customEnd = Varien_Date::toTimestamp(true);
73: break;
74:
75: default:
76: if (is_string($customStart)) {
77: $customStart = strtotime($customStart);
78: }
79: if (is_string($customEnd)) {
80: $customEnd = strtotime($customEnd);
81: }
82: break;
83:
84: }
85:
86:
87: return $this;
88: }
89:
90: /**
91: * Set date period
92: *
93: * @param int $period
94: * @return Mage_Reports_Model_Resource_Entity_Summary_Collection_Abstract
95: */
96: public function setDatePeriod($period)
97: {
98: return $this;
99: }
100:
101: /**
102: * Set store filter
103: *
104: * @param int $storeId
105: * @return Mage_Reports_Model_Resource_Entity_Summary_Collection_Abstract
106: */
107: public function setStoreFilter($storeId)
108: {
109: return $this;
110: }
111:
112: /**
113: * Return collection for summaries
114: *
115: * @return Mage_Eav_Model_Entity_Collection_Abstract
116: */
117: public function getCollection()
118: {
119: if (empty($this->_entityCollection)) {
120: $this->_initCollection();
121: }
122: return $this->_entityCollection;
123: }
124:
125: /**
126: * Init collection
127: *
128: * @return Mage_Reports_Model_Resource_Entity_Summary_Collection_Abstract
129: */
130: protected function _initCollection()
131: {
132: return $this;
133: }
134: }
135: