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: class Mage_Adminhtml_Block_Report_Refresh_Statistics_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: public function __construct()
37: {
38: parent::__construct();
39: $this->setFilterVisibility(false);
40: $this->setPagerVisibility(false);
41: $this->setUseAjax(false);
42: }
43:
44: protected function _getUpdatedAt($reportCode)
45: {
46: $flag = Mage::getModel('reports/flag')->setReportFlagCode($reportCode)->loadSelf();
47: return ($flag->hasData())
48: ? Mage::app()->getLocale()->storeDate(
49: 0, new Zend_Date($flag->getLastUpdate(), Varien_Date::DATETIME_INTERNAL_FORMAT), true
50: )
51: : '';
52: }
53:
54: protected function _prepareCollection()
55: {
56: $collection = new Varien_Data_Collection();
57:
58: $data = array(
59: array(
60: 'id' => 'sales',
61: 'report' => Mage::helper('sales')->__('Orders'),
62: 'comment' => Mage::helper('sales')->__('Total Ordered Report'),
63: 'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_ORDER_FLAG_CODE)
64: ),
65: array(
66: 'id' => 'tax',
67: 'report' => Mage::helper('sales')->__('Tax'),
68: 'comment' => Mage::helper('sales')->__('Order Taxes Report Grouped by Tax Rates'),
69: 'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_TAX_FLAG_CODE)
70: ),
71: array(
72: 'id' => 'shipping',
73: 'report' => Mage::helper('sales')->__('Shipping'),
74: 'comment' => Mage::helper('sales')->__('Total Shipped Report'),
75: 'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_SHIPPING_FLAG_CODE)
76: ),
77: array(
78: 'id' => 'invoiced',
79: 'report' => Mage::helper('sales')->__('Total Invoiced'),
80: 'comment' => Mage::helper('sales')->__('Total Invoiced VS Paid Report'),
81: 'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_INVOICE_FLAG_CODE)
82: ),
83: array(
84: 'id' => 'refunded',
85: 'report' => Mage::helper('sales')->__('Total Refunded'),
86: 'comment' => Mage::helper('sales')->__('Total Refunded Report'),
87: 'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_REFUNDED_FLAG_CODE)
88: ),
89: array(
90: 'id' => 'coupons',
91: 'report' => Mage::helper('sales')->__('Coupons'),
92: 'comment' => Mage::helper('sales')->__('Promotion Coupons Usage Report'),
93: 'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_COUPONS_FLAG_CODE)
94: ),
95: array(
96: 'id' => 'bestsellers',
97: 'report' => Mage::helper('sales')->__('Bestsellers'),
98: 'comment' => Mage::helper('sales')->__('Products Bestsellers Report'),
99: 'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_BESTSELLERS_FLAG_CODE)
100: ),
101: array(
102: 'id' => 'viewed',
103: 'report' => Mage::helper('sales')->__('Most Viewed'),
104: 'comment' => Mage::helper('sales')->__('Most Viewed Products Report'),
105: 'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_PRODUCT_VIEWED_FLAG_CODE)
106: ),
107: );
108:
109: foreach ($data as $value) {
110: $item = new Varien_Object();
111: $item->setData($value);
112: $collection->addItem($item);
113: }
114:
115: $this->setCollection($collection);
116:
117: return parent::_prepareCollection();
118: }
119:
120: protected function _prepareColumns()
121: {
122: $this->addColumn('report', array(
123: 'header' => Mage::helper('reports')->__('Report'),
124: 'index' => 'report',
125: 'type' => 'string',
126: 'width' => 150,
127: 'sortable' => false
128: ));
129:
130: $this->addColumn('comment', array(
131: 'header' => Mage::helper('reports')->__('Description'),
132: 'index' => 'comment',
133: 'type' => 'string',
134: 'sortable' => false
135: ));
136:
137: $this->addColumn('updated_at', array(
138: 'header' => Mage::helper('reports')->__('Updated At'),
139: 'index' => 'updated_at',
140: 'type' => 'datetime',
141: 'width' => 200,
142: 'default' => Mage::helper('reports')->__('undefined'),
143: 'sortable' => false
144: ));
145:
146: return parent::_prepareColumns();
147: }
148:
149: protected function _prepareMassaction()
150: {
151: $this->setMassactionIdField('id');
152: $this->getMassactionBlock()->setFormFieldName('code');
153:
154: $this->getMassactionBlock()->addItem('refresh_lifetime', array(
155: 'label' => Mage::helper('reports')->__('Refresh Lifetime Statistics'),
156: 'url' => $this->getUrl('*/*/refreshLifetime'),
157: 'confirm' => Mage::helper('reports')->__('Are you sure you want to refresh lifetime statistics? There can be performance impact during this operation.')
158: ));
159:
160: $this->getMassactionBlock()->addItem('refresh_recent', array(
161: 'label' => Mage::helper('reports')->__('Refresh Statistics for the Last Day'),
162: 'url' => $this->getUrl('*/*/refreshRecent'),
163: 'confirm' => Mage::helper('reports')->__('Are you sure?'),
164: 'selected' => true
165: ));
166:
167: return $this;
168: }
169: }
170: