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_ShopcartController extends Mage_Adminhtml_Controller_Action
35: {
36: public function _initAction()
37: {
38: $act = $this->getRequest()->getActionName();
39: $this->loadLayout()
40: ->_addBreadcrumb(Mage::helper('reports')->__('Reports'), Mage::helper('reports')->__('Reports'))
41: ->_addBreadcrumb(Mage::helper('reports')->__('Shopping Cart'), Mage::helper('reports')->__('Shopping Cart'));
42: return $this;
43: }
44:
45: public function customerAction()
46: {
47: $this->_title($this->__('Reports'))
48: ->_title($this->__('Shopping Cart'))
49: ->_title($this->__('Customer Shopping Carts'));
50:
51: $this->_initAction()
52: ->_setActiveMenu('report/shopcart/customer')
53: ->_addBreadcrumb(Mage::helper('reports')->__('Customers Report'), Mage::helper('reports')->__('Customers Report'))
54: ->_addContent($this->getLayout()->createBlock('adminhtml/report_shopcart_customer'))
55: ->renderLayout();
56: }
57:
58: 59: 60:
61: public function exportCustomerCsvAction()
62: {
63: $fileName = 'shopcart_customer.csv';
64: $content = $this->getLayout()->createBlock('adminhtml/report_shopcart_customer_grid')
65: ->getCsvFile();
66:
67: $this->_prepareDownloadResponse($fileName, $content);
68: }
69:
70: 71: 72:
73: public function exportCustomerExcelAction()
74: {
75: $fileName = 'shopcart_customer.xml';
76: $content = $this->getLayout()->createBlock('adminhtml/report_shopcart_customer_grid')
77: ->getExcelFile($fileName);
78:
79: $this->_prepareDownloadResponse($fileName, $content);
80: }
81:
82: public function productAction()
83: {
84: $this->_title($this->__('Reports'))
85: ->_title($this->__('Shopping Cart'))
86: ->_title($this->__('Products in Carts'));
87:
88: $this->_initAction()
89: ->_setActiveMenu('report/shopcart/product')
90: ->_addBreadcrumb(Mage::helper('reports')->__('Products Report'), Mage::helper('reports')->__('Products Report'))
91: ->_addContent($this->getLayout()->createBlock('adminhtml/report_shopcart_product'))
92: ->renderLayout();
93: }
94:
95: 96: 97:
98: public function exportProductCsvAction()
99: {
100: $fileName = 'shopcart_product.csv';
101: $content = $this->getLayout()->createBlock('adminhtml/report_shopcart_product_grid')
102: ->getCsvFile();
103:
104: $this->_prepareDownloadResponse($fileName, $content);
105: }
106:
107: 108: 109:
110: public function exportProductExcelAction()
111: {
112: $fileName = 'shopcart_product.xml';
113: $content = $this->getLayout()->createBlock('adminhtml/report_shopcart_product_grid')
114: ->getExcelFile($fileName);
115:
116: $this->_prepareDownloadResponse($fileName, $content);
117: }
118:
119: public function abandonedAction()
120: {
121: $this->_title($this->__('Reports'))
122: ->_title($this->__('Shopping Cart'))
123: ->_title($this->__('Abandoned Carts'));
124:
125: $this->_initAction()
126: ->_setActiveMenu('report/shopcart/abandoned')
127: ->_addBreadcrumb(Mage::helper('reports')->__('Abandoned Carts'), Mage::helper('reports')->__('Abandoned Carts'))
128: ->_addContent($this->getLayout()->createBlock('adminhtml/report_shopcart_abandoned'))
129: ->renderLayout();
130: }
131:
132: 133: 134:
135: public function exportAbandonedCsvAction()
136: {
137: $fileName = 'shopcart_abandoned.csv';
138: $content = $this->getLayout()->createBlock('adminhtml/report_shopcart_abandoned_grid')
139: ->getCsvFile();
140:
141: $this->_prepareDownloadResponse($fileName, $content);
142: }
143:
144: 145: 146:
147: public function exportAbandonedExcelAction()
148: {
149: $fileName = 'shopcart_abandoned.xml';
150: $content = $this->getLayout()->createBlock('adminhtml/report_shopcart_abandoned_grid')
151: ->getExcelFile($fileName);
152:
153: $this->_prepareDownloadResponse($fileName, $content);
154: }
155:
156: protected function _isAllowed()
157: {
158: switch ($this->getRequest()->getActionName()) {
159: case 'customer':
160: return Mage::getSingleton('admin/session')->isAllowed('report/shopcart/customer');
161: break;
162: case 'product':
163: return Mage::getSingleton('admin/session')->isAllowed('report/shopcart/product');
164: break;
165: case 'abandoned':
166: return Mage::getSingleton('admin/session')->isAllowed('report/shopcart/abandoned');
167: break;
168: default:
169: return Mage::getSingleton('admin/session')->isAllowed('report/shopcart');
170: break;
171: }
172: }
173: }
174: