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_Report_SalesController extends Mage_Adminhtml_Controller_Report_Abstract
35: {
36: 37: 38: 39: 40:
41: public function _initAction()
42: {
43: parent::_initAction();
44: $this->_addBreadcrumb(Mage::helper('reports')->__('Sales'), Mage::helper('reports')->__('Sales'));
45: return $this;
46: }
47:
48: public function salesAction()
49: {
50: $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Sales'));
51:
52: $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_ORDER_FLAG_CODE, 'sales');
53:
54: $this->_initAction()
55: ->_setActiveMenu('report/sales/sales')
56: ->_addBreadcrumb(Mage::helper('adminhtml')->__('Sales Report'), Mage::helper('adminhtml')->__('Sales Report'));
57:
58: $gridBlock = $this->getLayout()->getBlock('report_sales_sales.grid');
59: $filterFormBlock = $this->getLayout()->getBlock('grid.filter.form');
60:
61: $this->_initReportAction(array(
62: $gridBlock,
63: $filterFormBlock
64: ));
65:
66: $this->renderLayout();
67: }
68:
69: public function bestsellersAction()
70: {
71: $this->_title($this->__('Reports'))->_title($this->__('Products'))->_title($this->__('Bestsellers'));
72:
73: $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_BESTSELLERS_FLAG_CODE, 'bestsellers');
74:
75: $this->_initAction()
76: ->_setActiveMenu('report/products/bestsellers')
77: ->_addBreadcrumb(Mage::helper('adminhtml')->__('Products Bestsellers Report'), Mage::helper('adminhtml')->__('Products Bestsellers Report'));
78:
79: $gridBlock = $this->getLayout()->getBlock('report_sales_bestsellers.grid');
80: $filterFormBlock = $this->getLayout()->getBlock('grid.filter.form');
81:
82: $this->_initReportAction(array(
83: $gridBlock,
84: $filterFormBlock
85: ));
86:
87: $this->renderLayout();
88: }
89:
90: 91: 92:
93: public function exportBestsellersCsvAction()
94: {
95: $fileName = 'bestsellers.csv';
96: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_bestsellers_grid');
97: $this->_initReportAction($grid);
98: $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
99: }
100:
101: 102: 103:
104: public function exportBestsellersExcelAction()
105: {
106: $fileName = 'bestsellers.xml';
107: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_bestsellers_grid');
108: $this->_initReportAction($grid);
109: $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
110: }
111:
112: 113: 114: 115: 116: 117:
118: protected function _getCollectionNames()
119: {
120: return array();
121: }
122:
123: 124: 125: 126: 127: 128:
129: public function refreshRecentAction()
130: {
131: return $this->_forward('refreshRecent', 'report_statistics');
132: }
133:
134: 135: 136: 137: 138: 139:
140: public function refreshLifetimeAction()
141: {
142: return $this->_forward('refreshLifetime', 'report_statistics');
143: }
144:
145: 146: 147:
148: public function exportSalesCsvAction()
149: {
150: $fileName = 'sales.csv';
151: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_sales_grid');
152: $this->_initReportAction($grid);
153: $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
154: }
155:
156: 157: 158:
159: public function exportSalesExcelAction()
160: {
161: $fileName = 'sales.xml';
162: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_sales_grid');
163: $this->_initReportAction($grid);
164: $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
165: }
166:
167: public function taxAction()
168: {
169: $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Tax'));
170:
171: $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_TAX_FLAG_CODE, 'tax');
172:
173: $this->_initAction()
174: ->_setActiveMenu('report/sales/tax')
175: ->_addBreadcrumb(Mage::helper('adminhtml')->__('Tax'), Mage::helper('adminhtml')->__('Tax'));
176:
177: $gridBlock = $this->getLayout()->getBlock('report_sales_tax.grid');
178: $filterFormBlock = $this->getLayout()->getBlock('grid.filter.form');
179:
180: $this->_initReportAction(array(
181: $gridBlock,
182: $filterFormBlock
183: ));
184:
185: $this->renderLayout();
186: }
187:
188: 189: 190:
191: public function exportTaxCsvAction()
192: {
193: $fileName = 'tax.csv';
194: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_tax_grid');
195: $this->_initReportAction($grid);
196: $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
197: }
198:
199: 200: 201:
202: public function exportTaxExcelAction()
203: {
204: $fileName = 'tax.xml';
205: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_tax_grid');
206: $this->_initReportAction($grid);
207: $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
208: }
209:
210: public function shippingAction()
211: {
212: $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Shipping'));
213:
214: $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_SHIPPING_FLAG_CODE, 'shipping');
215:
216: $this->_initAction()
217: ->_setActiveMenu('report/sales/shipping')
218: ->_addBreadcrumb(Mage::helper('adminhtml')->__('Shipping'), Mage::helper('adminhtml')->__('Shipping'));
219:
220: $gridBlock = $this->getLayout()->getBlock('report_sales_shipping.grid');
221: $filterFormBlock = $this->getLayout()->getBlock('grid.filter.form');
222:
223: $this->_initReportAction(array(
224: $gridBlock,
225: $filterFormBlock
226: ));
227:
228: $this->renderLayout();
229: }
230:
231: 232: 233:
234: public function exportShippingCsvAction()
235: {
236: $fileName = 'shipping.csv';
237: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_shipping_grid');
238: $this->_initReportAction($grid);
239: $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
240: }
241:
242: 243: 244:
245: public function exportShippingExcelAction()
246: {
247: $fileName = 'shipping.xml';
248: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_shipping_grid');
249: $this->_initReportAction($grid);
250: $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
251: }
252:
253: public function invoicedAction()
254: {
255: $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Total Invoiced'));
256:
257: $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_INVOICE_FLAG_CODE, 'invoiced');
258:
259: $this->_initAction()
260: ->_setActiveMenu('report/sales/invoiced')
261: ->_addBreadcrumb(Mage::helper('adminhtml')->__('Total Invoiced'), Mage::helper('adminhtml')->__('Total Invoiced'));
262:
263: $gridBlock = $this->getLayout()->getBlock('report_sales_invoiced.grid');
264: $filterFormBlock = $this->getLayout()->getBlock('grid.filter.form');
265:
266: $this->_initReportAction(array(
267: $gridBlock,
268: $filterFormBlock
269: ));
270:
271: $this->renderLayout();
272: }
273:
274: 275: 276:
277: public function exportInvoicedCsvAction()
278: {
279: $fileName = 'invoiced.csv';
280: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_invoiced_grid');
281: $this->_initReportAction($grid);
282: $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
283: }
284:
285: 286: 287:
288: public function exportInvoicedExcelAction()
289: {
290: $fileName = 'invoiced.xml';
291: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_invoiced_grid');
292: $this->_initReportAction($grid);
293: $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
294: }
295:
296: public function refundedAction()
297: {
298: $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Total Refunded'));
299:
300: $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_REFUNDED_FLAG_CODE, 'refunded');
301:
302: $this->_initAction()
303: ->_setActiveMenu('report/sales/refunded')
304: ->_addBreadcrumb(Mage::helper('adminhtml')->__('Total Refunded'), Mage::helper('adminhtml')->__('Total Refunded'));
305:
306: $gridBlock = $this->getLayout()->getBlock('report_sales_refunded.grid');
307: $filterFormBlock = $this->getLayout()->getBlock('grid.filter.form');
308:
309: $this->_initReportAction(array(
310: $gridBlock,
311: $filterFormBlock
312: ));
313:
314: $this->renderLayout();
315: }
316:
317: 318: 319:
320: public function exportRefundedCsvAction()
321: {
322: $fileName = 'refunded.csv';
323: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_refunded_grid');
324: $this->_initReportAction($grid);
325: $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
326: }
327:
328: 329: 330:
331: public function exportRefundedExcelAction()
332: {
333: $fileName = 'refunded.xml';
334: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_refunded_grid');
335: $this->_initReportAction($grid);
336: $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
337: }
338:
339: public function couponsAction()
340: {
341: $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Coupons'));
342:
343: $this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_COUPONS_FLAG_CODE, 'coupons');
344:
345: $this->_initAction()
346: ->_setActiveMenu('report/sales/coupons')
347: ->_addBreadcrumb(Mage::helper('adminhtml')->__('Coupons'), Mage::helper('adminhtml')->__('Coupons'));
348:
349: $gridBlock = $this->getLayout()->getBlock('report_sales_coupons.grid');
350: $filterFormBlock = $this->getLayout()->getBlock('grid.filter.form');
351:
352: $this->_initReportAction(array(
353: $gridBlock,
354: $filterFormBlock
355: ));
356:
357: $this->renderLayout();
358: }
359:
360: 361: 362:
363: public function exportCouponsCsvAction()
364: {
365: $fileName = 'coupons.csv';
366: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_coupons_grid');
367: $this->_initReportAction($grid);
368: $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
369: }
370:
371: 372: 373:
374: public function exportCouponsExcelAction()
375: {
376: $fileName = 'coupons.xml';
377: $grid = $this->getLayout()->createBlock('adminhtml/report_sales_coupons_grid');
378: $this->_initReportAction($grid);
379: $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
380: }
381:
382: 383: 384:
385: public function refreshStatisticsAction()
386: {
387: return $this->_forward('index', 'report_statistics');
388: }
389:
390: protected function _isAllowed()
391: {
392: switch ($this->getRequest()->getActionName()) {
393: case 'sales':
394: return $this->_getSession()->isAllowed('report/salesroot/sales');
395: break;
396: case 'tax':
397: return $this->_getSession()->isAllowed('report/salesroot/tax');
398: break;
399: case 'shipping':
400: return $this->_getSession()->isAllowed('report/salesroot/shipping');
401: break;
402: case 'invoiced':
403: return $this->_getSession()->isAllowed('report/salesroot/invoiced');
404: break;
405: case 'refunded':
406: return $this->_getSession()->isAllowed('report/salesroot/refunded');
407: break;
408: case 'coupons':
409: return $this->_getSession()->isAllowed('report/salesroot/coupons');
410: break;
411: case 'shipping':
412: return $this->_getSession()->isAllowed('report/salesroot/shipping');
413: break;
414: case 'bestsellers':
415: return $this->_getSession()->isAllowed('report/products/bestsellers');
416: break;
417: default:
418: return $this->_getSession()->isAllowed('report/salesroot');
419: break;
420: }
421: }
422: }
423: