1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: abstract class Mage_Adminhtml_Controller_Report_Abstract extends Mage_Adminhtml_Controller_Action
36: {
37: 38: 39: 40: 41:
42: protected $_adminSession = null;
43:
44: 45: 46: 47: 48:
49: protected function _getSession()
50: {
51: if (is_null($this->_adminSession)) {
52: $this->_adminSession = Mage::getSingleton('admin/session');
53: }
54: return $this->_adminSession;
55: }
56:
57: 58: 59: 60: 61:
62: public function _initAction()
63: {
64: $this->loadLayout()
65: ->_addBreadcrumb(Mage::helper('reports')->__('Reports'), Mage::helper('reports')->__('Reports'));
66: return $this;
67: }
68:
69: 70: 71: 72: 73: 74:
75: public function _initReportAction($blocks)
76: {
77: if (!is_array($blocks)) {
78: $blocks = array($blocks);
79: }
80:
81: $requestData = Mage::helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('filter'));
82: $requestData = $this->_filterDates($requestData, array('from', 'to'));
83: $requestData['store_ids'] = $this->getRequest()->getParam('store_ids');
84: $params = new Varien_Object();
85:
86: foreach ($requestData as $key => $value) {
87: if (!empty($value)) {
88: $params->setData($key, $value);
89: }
90: }
91:
92: foreach ($blocks as $block) {
93: if ($block) {
94: $block->setPeriodType($params->getData('period_type'));
95: $block->setFilterData($params);
96: }
97: }
98:
99: return $this;
100: }
101:
102: 103: 104: 105: 106: 107: 108:
109: protected function _showLastExecutionTime($flagCode, $refreshCode)
110: {
111: $flag = Mage::getModel('reports/flag')->setReportFlagCode($flagCode)->loadSelf();
112: $updatedAt = ($flag->hasData())
113: ? Mage::app()->getLocale()->storeDate(
114: 0, new Zend_Date($flag->getLastUpdate(), Varien_Date::DATETIME_INTERNAL_FORMAT), true
115: )
116: : 'undefined';
117:
118: $refreshStatsLink = $this->getUrl('*/report_statistics');
119: $directRefreshLink = $this->getUrl('*/report_statistics/refreshRecent', array('code' => $refreshCode));
120:
121: Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('adminhtml')->__('Last updated: %s. To refresh last day\'s <a href="%s">statistics</a>, click <a href="%s">here</a>.', $updatedAt, $refreshStatsLink, $directRefreshLink));
122: return $this;
123: }
124: }
125: