00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Report_CustomerController extends Mage_Adminhtml_Controller_Action
00036 {
00037 public function _initAction()
00038 {
00039 $act = $this->getRequest()->getActionName();
00040 if(!$act)
00041 $act = 'default';
00042
00043 $this->loadLayout()
00044 ->_addBreadcrumb(Mage::helper('reports')->__('Reports'), Mage::helper('reports')->__('Reports'))
00045 ->_addBreadcrumb(Mage::helper('reports')->__('Customers'), Mage::helper('reports')->__('Customers'));
00046 return $this;
00047 }
00048
00049 public function accountsAction()
00050 {
00051 $this->_initAction()
00052 ->_setActiveMenu('report/customer/accounts')
00053 ->_addBreadcrumb(Mage::helper('adminhtml')->__('New Accounts'), Mage::helper('adminhtml')->__('New Accounts'))
00054 ->_addContent($this->getLayout()->createBlock('adminhtml/report_customer_accounts'))
00055 ->renderLayout();
00056 }
00057
00058
00059
00060
00061 public function exportAccountsCsvAction()
00062 {
00063 $fileName = 'new_accounts.csv';
00064 $content = $this->getLayout()->createBlock('adminhtml/report_customer_accounts_grid')
00065 ->getCsv();
00066
00067 $this->_prepareDownloadResponse($fileName, $content);
00068 }
00069
00070
00071
00072
00073 public function exportAccountsExcelAction()
00074 {
00075 $fileName = 'accounts.xml';
00076 $content = $this->getLayout()->createBlock('adminhtml/report_customer_accounts_grid')
00077 ->getExcel($fileName);
00078
00079 $this->_prepareDownloadResponse($fileName, $content);
00080 }
00081
00082 public function ordersAction()
00083 {
00084 $this->_initAction()
00085 ->_setActiveMenu('report/customer/orders')
00086 ->_addBreadcrumb(Mage::helper('reports')->__('Customers by number of orders'),
00087 Mage::helper('reports')->__('Customers by number of orders'))
00088 ->_addContent($this->getLayout()->createBlock('adminhtml/report_customer_orders'))
00089 ->renderLayout();
00090 }
00091
00092
00093
00094
00095 public function exportOrdersCsvAction()
00096 {
00097 $fileName = 'customers_orders.csv';
00098 $content = $this->getLayout()->createBlock('adminhtml/report_customer_orders_grid')
00099 ->getCsv();
00100
00101 $this->_prepareDownloadResponse($fileName, $content);
00102 }
00103
00104
00105
00106
00107 public function exportOrdersExcelAction()
00108 {
00109 $fileName = 'customers_orders.xml';
00110 $content = $this->getLayout()->createBlock('adminhtml/report_customer_orders_grid')
00111 ->getExcel($fileName);
00112
00113 $this->_prepareDownloadResponse($fileName, $content);
00114 }
00115
00116 public function totalsAction()
00117 {
00118 $this->_initAction()
00119 ->_setActiveMenu('report/customer/totals')
00120 ->_addBreadcrumb(Mage::helper('reports')->__('Customers by orders total'),
00121 Mage::helper('reports')->__('Customers by orders total'))
00122 ->_addContent($this->getLayout()->createBlock('adminhtml/report_customer_totals'))
00123 ->renderLayout();
00124 }
00125
00126
00127
00128
00129 public function exportTotalsCsvAction()
00130 {
00131 $fileName = 'cuatomer_totals.csv';
00132 $content = $this->getLayout()->createBlock('adminhtml/report_customer_totals_grid')
00133 ->getCsv();
00134
00135 $this->_prepareDownloadResponse($fileName, $content);
00136 }
00137
00138
00139
00140
00141 public function exportTotalsExcelAction()
00142 {
00143 $fileName = 'customer_totals.xml';
00144 $content = $this->getLayout()->createBlock('adminhtml/report_customer_totals_grid')
00145 ->getExcel($fileName);
00146
00147 $this->_prepareDownloadResponse($fileName, $content);
00148 }
00149
00150 protected function _isAllowed()
00151 {
00152 switch ($this->getRequest()->getActionName()) {
00153 case 'accounts':
00154 return Mage::getSingleton('admin/session')->isAllowed('report/customers/accounts');
00155 break;
00156 case 'orders':
00157 return Mage::getSingleton('admin/session')->isAllowed('report/customers/orders');
00158 break;
00159 case 'totals':
00160 return Mage::getSingleton('admin/session')->isAllowed('report/customers/totals');
00161 break;
00162 default:
00163 return Mage::getSingleton('admin/session')->isAllowed('report/customers');
00164 break;
00165 }
00166 }
00167 }