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: class Mage_Adminhtml_Report_CustomerController extends Mage_Adminhtml_Controller_Action
36: {
37: public function _initAction()
38: {
39: $act = $this->getRequest()->getActionName();
40: if(!$act)
41: $act = 'default';
42:
43: $this->loadLayout()
44: ->_addBreadcrumb(Mage::helper('reports')->__('Reports'), Mage::helper('reports')->__('Reports'))
45: ->_addBreadcrumb(Mage::helper('reports')->__('Customers'), Mage::helper('reports')->__('Customers'));
46: return $this;
47: }
48:
49: public function accountsAction()
50: {
51: $this->_title($this->__('Reports'))
52: ->_title($this->__('Customers'))
53: ->_title($this->__('New Accounts'));
54:
55: $this->_initAction()
56: ->_setActiveMenu('report/customer/accounts')
57: ->_addBreadcrumb(Mage::helper('adminhtml')->__('New Accounts'), Mage::helper('adminhtml')->__('New Accounts'))
58: ->_addContent($this->getLayout()->createBlock('adminhtml/report_customer_accounts'))
59: ->renderLayout();
60: }
61:
62: 63: 64:
65: public function exportAccountsCsvAction()
66: {
67: $fileName = 'new_accounts.csv';
68: $content = $this->getLayout()->createBlock('adminhtml/report_customer_accounts_grid')
69: ->getCsv();
70:
71: $this->_prepareDownloadResponse($fileName, $content);
72: }
73:
74: 75: 76:
77: public function exportAccountsExcelAction()
78: {
79: $fileName = 'accounts.xml';
80: $content = $this->getLayout()->createBlock('adminhtml/report_customer_accounts_grid')
81: ->getExcel($fileName);
82:
83: $this->_prepareDownloadResponse($fileName, $content);
84: }
85:
86: public function ordersAction()
87: {
88: $this->_title($this->__('Reports'))
89: ->_title($this->__('Customers'))
90: ->_title($this->__('Customers by Number of Orders'));
91:
92: $this->_initAction()
93: ->_setActiveMenu('report/customer/orders')
94: ->_addBreadcrumb(Mage::helper('reports')->__('Customers by Number of Orders'),
95: Mage::helper('reports')->__('Customers by Number of Orders'))
96: ->_addContent($this->getLayout()->createBlock('adminhtml/report_customer_orders'))
97: ->renderLayout();
98: }
99:
100: 101: 102:
103: public function exportOrdersCsvAction()
104: {
105: $fileName = 'customers_orders.csv';
106: $content = $this->getLayout()->createBlock('adminhtml/report_customer_orders_grid')
107: ->getCsv();
108:
109: $this->_prepareDownloadResponse($fileName, $content);
110: }
111:
112: 113: 114:
115: public function exportOrdersExcelAction()
116: {
117: $fileName = 'customers_orders.xml';
118: $content = $this->getLayout()->createBlock('adminhtml/report_customer_orders_grid')
119: ->getExcel($fileName);
120:
121: $this->_prepareDownloadResponse($fileName, $content);
122: }
123:
124: public function totalsAction()
125: {
126: $this->_title($this->__('Reports'))
127: ->_title($this->__('Customers'))
128: ->_title($this->__('Customers by Orders Total'));
129:
130: $this->_initAction()
131: ->_setActiveMenu('report/customer/totals')
132: ->_addBreadcrumb(Mage::helper('reports')->__('Customers by Orders Total'),
133: Mage::helper('reports')->__('Customers by Orders Total'))
134: ->_addContent($this->getLayout()->createBlock('adminhtml/report_customer_totals'))
135: ->renderLayout();
136: }
137:
138: 139: 140:
141: public function exportTotalsCsvAction()
142: {
143: $fileName = 'cuatomer_totals.csv';
144: $content = $this->getLayout()->createBlock('adminhtml/report_customer_totals_grid')
145: ->getCsv();
146:
147: $this->_prepareDownloadResponse($fileName, $content);
148: }
149:
150: 151: 152:
153: public function exportTotalsExcelAction()
154: {
155: $fileName = 'customer_totals.xml';
156: $content = $this->getLayout()->createBlock('adminhtml/report_customer_totals_grid')
157: ->getExcel($fileName);
158:
159: $this->_prepareDownloadResponse($fileName, $content);
160: }
161:
162: protected function _isAllowed()
163: {
164: switch ($this->getRequest()->getActionName()) {
165: case 'accounts':
166: return Mage::getSingleton('admin/session')->isAllowed('report/customers/accounts');
167: break;
168: case 'orders':
169: return Mage::getSingleton('admin/session')->isAllowed('report/customers/orders');
170: break;
171: case 'totals':
172: return Mage::getSingleton('admin/session')->isAllowed('report/customers/totals');
173: break;
174: default:
175: return Mage::getSingleton('admin/session')->isAllowed('report/customers');
176: break;
177: }
178: }
179: }
180: