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 class Mage_Adminhtml_Report_SalesController extends Mage_Adminhtml_Controller_Action
00035 {
00036 public function _initAction()
00037 {
00038 $act = $this->getRequest()->getActionName();
00039 if(!$act)
00040 $act = 'default';
00041 $this->loadLayout()
00042 ->_addBreadcrumb(Mage::helper('reports')->__('Reports'), Mage::helper('reports')->__('Reports'))
00043 ->_addBreadcrumb(Mage::helper('reports')->__('Sales'), Mage::helper('reports')->__('Sales'));
00044 return $this;
00045 }
00046
00047 public function salesAction()
00048 {
00049 $this->_initAction()
00050 ->_setActiveMenu('report/sales/sales')
00051 ->_addBreadcrumb(Mage::helper('adminhtml')->__('Sales Report'), Mage::helper('adminhtml')->__('Sales Report'))
00052 ->_addContent($this->getLayout()->createBlock('adminhtml/report_sales_sales'))
00053 ->renderLayout();
00054 }
00055
00056
00057
00058
00059 public function exportSalesCsvAction()
00060 {
00061 $fileName = 'sales.csv';
00062 $content = $this->getLayout()->createBlock('adminhtml/report_sales_sales_grid')
00063 ->getCsv();
00064
00065 $this->_prepareDownloadResponse($fileName, $content);
00066 }
00067
00068
00069
00070
00071 public function exportSalesExcelAction()
00072 {
00073 $fileName = 'sales.xml';
00074 $content = $this->getLayout()->createBlock('adminhtml/report_sales_sales_grid')
00075 ->getExcel($fileName);
00076
00077 $this->_prepareDownloadResponse($fileName, $content);
00078 }
00079
00080 public function taxAction()
00081 {
00082 $this->_initAction()
00083 ->_setActiveMenu('report/sales/tax')
00084 ->_addBreadcrumb(Mage::helper('adminhtml')->__('Tax'), Mage::helper('adminhtml')->__('Tax'))
00085 ->_addContent($this->getLayout()->createBlock('adminhtml/report_sales_tax'))
00086 ->renderLayout();
00087 }
00088
00089
00090
00091
00092 public function exportTaxCsvAction()
00093 {
00094 $fileName = 'tax.csv';
00095 $content = $this->getLayout()->createBlock('adminhtml/report_sales_tax_grid')
00096 ->getCsv();
00097
00098 $this->_prepareDownloadResponse($fileName, $content);
00099 }
00100
00101
00102
00103
00104 public function exportTaxExcelAction()
00105 {
00106 $fileName = 'tax.xml';
00107 $content = $this->getLayout()->createBlock('adminhtml/report_sales_tax_grid')
00108 ->getExcel($fileName);
00109
00110 $this->_prepareDownloadResponse($fileName, $content);
00111 }
00112
00113 public function invoicedAction()
00114 {
00115 $this->_initAction()
00116 ->_setActiveMenu('report/sales/invoiced')
00117 ->_addBreadcrumb(Mage::helper('adminhtml')->__('Total Invoiced'), Mage::helper('adminhtml')->__('Total Invoiced'))
00118 ->_addContent($this->getLayout()->createBlock('adminhtml/report_sales_invoiced'))
00119 ->renderLayout();
00120 }
00121
00122
00123
00124
00125 public function exportInvoicedCsvAction()
00126 {
00127 $fileName = 'invoiced.csv';
00128 $content = $this->getLayout()->createBlock('adminhtml/report_sales_invoiced_grid')
00129 ->getCsv();
00130
00131 $this->_prepareDownloadResponse($fileName, $content);
00132 }
00133
00134
00135
00136
00137 public function exportInvoicedExcelAction()
00138 {
00139 $fileName = 'invoiced.xml';
00140 $content = $this->getLayout()->createBlock('adminhtml/report_sales_invoiced_grid')
00141 ->getExcel($fileName);
00142
00143 $this->_prepareDownloadResponse($fileName, $content);
00144 }
00145
00146 public function refundedAction()
00147 {
00148 $this->_initAction()
00149 ->_setActiveMenu('report/sales/refunded')
00150 ->_addBreadcrumb(Mage::helper('adminhtml')->__('Total Refunded'), Mage::helper('adminhtml')->__('Total Refunded'))
00151 ->_addContent($this->getLayout()->createBlock('adminhtml/report_sales_refunded'))
00152 ->renderLayout();
00153 }
00154
00155
00156
00157
00158 public function exportRefundedCsvAction()
00159 {
00160 $fileName = 'refunded.csv';
00161 $content = $this->getLayout()->createBlock('adminhtml/report_sales_refunded_grid')
00162 ->getCsv();
00163
00164 $this->_prepareDownloadResponse($fileName, $content);
00165 }
00166
00167
00168
00169
00170 public function exportRefundedExcelAction()
00171 {
00172 $fileName = 'refunded.xml';
00173 $content = $this->getLayout()->createBlock('adminhtml/report_sales_refunded_grid')
00174 ->getExcel($fileName);
00175
00176 $this->_prepareDownloadResponse($fileName, $content);
00177 }
00178
00179 public function couponsAction()
00180 {
00181 $this->_initAction()
00182 ->_setActiveMenu('report/sales/coupons')
00183 ->_addBreadcrumb(Mage::helper('adminhtml')->__('Coupons'), Mage::helper('adminhtml')->__('Coupons'))
00184 ->_addContent($this->getLayout()->createBlock('adminhtml/report_sales_coupons'))
00185 ->renderLayout();
00186 }
00187
00188
00189
00190
00191 public function exportCouponsCsvAction()
00192 {
00193 $fileName = 'coupons.csv';
00194 $content = $this->getLayout()->createBlock('adminhtml/report_sales_coupons_grid')
00195 ->getCsv();
00196
00197 $this->_prepareDownloadResponse($fileName, $content);
00198 }
00199
00200
00201
00202
00203 public function exportCouponsExcelAction()
00204 {
00205 $fileName = 'coupons.xml';
00206 $content = $this->getLayout()->createBlock('adminhtml/report_sales_coupons_grid')
00207 ->getExcel($fileName);
00208
00209 $this->_prepareDownloadResponse($fileName, $content);
00210 }
00211
00212 public function shippingAction()
00213 {
00214 $this->_initAction()
00215 ->_setActiveMenu('report/sales/shipping')
00216 ->_addBreadcrumb(Mage::helper('adminhtml')->__('Shipping'), Mage::helper('adminhtml')->__('Shipping'))
00217 ->_addContent($this->getLayout()->createBlock('adminhtml/report_sales_shipping'))
00218 ->renderLayout();
00219 }
00220
00221
00222
00223
00224 public function exportShippingCsvAction()
00225 {
00226 $fileName = 'shipping.csv';
00227 $content = $this->getLayout()->createBlock('adminhtml/report_sales_shipping_grid')
00228 ->getCsv();
00229
00230 $this->_prepareDownloadResponse($fileName, $content);
00231 }
00232
00233
00234
00235
00236 public function exportShippingExcelAction()
00237 {
00238 $fileName = 'shipping.xml';
00239 $content = $this->getLayout()->createBlock('adminhtml/report_sales_shipping_grid')
00240 ->getExcel($fileName);
00241
00242 $this->_prepareDownloadResponse($fileName, $content);
00243 }
00244
00245 protected function _isAllowed()
00246 {
00247 switch ($this->getRequest()->getActionName()) {
00248 case 'sales':
00249 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/sales');
00250 break;
00251 case 'tax':
00252 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/tax');
00253 break;
00254 case 'shipping':
00255 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/shipping');
00256 break;
00257 case 'invoiced':
00258 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/invoiced');
00259 break;
00260 case 'refunded':
00261 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/refunded');
00262 break;
00263 case 'coupons':
00264 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/coupons');
00265 break;
00266 case 'shipping':
00267 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/shipping');
00268 break;
00269 default:
00270 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot');
00271 break;
00272 }
00273 }
00274 }