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_ProductController extends Mage_Adminhtml_Controller_Action
00036 {
00037
00038
00039
00040
00041
00042 public function _initAction()
00043 {
00044 $act = $this->getRequest()->getActionName();
00045 if(!$act)
00046 $act = 'default';
00047 $this->loadLayout()
00048 ->_addBreadcrumb(Mage::helper('reports')->__('Reports'), Mage::helper('reports')->__('Reports'))
00049 ->_addBreadcrumb(Mage::helper('reports')->__('Products'), Mage::helper('reports')->__('Products'));
00050 return $this;
00051 }
00052
00053
00054
00055
00056
00057 public function orderedAction()
00058 {
00059 $this->_initAction()
00060 ->_setActiveMenu('report/product/ordered')
00061 ->_addBreadcrumb(Mage::helper('reports')->__('Bestsellers'), Mage::helper('reports')->__('Bestsellers'))
00062 ->_addContent($this->getLayout()->createBlock('adminhtml/report_product_ordered'))
00063 ->renderLayout();
00064 }
00065
00066
00067
00068
00069
00070 public function exportOrderedCsvAction()
00071 {
00072 $fileName = 'products_bestsellers.csv';
00073 $content = $this->getLayout()->createBlock('adminhtml/report_product_ordered_grid')
00074 ->getCsv();
00075
00076 $this->_prepareDownloadResponse($fileName, $content);
00077 }
00078
00079
00080
00081
00082
00083 public function exportOrderedExcelAction()
00084 {
00085 $fileName = 'products_bestsellers.xml';
00086 $content = $this->getLayout()->createBlock('adminhtml/report_product_ordered_grid')
00087 ->getExcel($fileName);
00088
00089 $this->_prepareDownloadResponse($fileName, $content);
00090 }
00091
00092
00093
00094
00095
00096 public function soldAction()
00097 {
00098 $this->_initAction()
00099 ->_setActiveMenu('report/product/sold')
00100 ->_addBreadcrumb(Mage::helper('reports')->__('Products Ordered'), Mage::helper('reports')->__('Products Ordered'))
00101 ->_addContent($this->getLayout()->createBlock('adminhtml/report_product_sold'))
00102 ->renderLayout();
00103 }
00104
00105
00106
00107
00108
00109 public function exportSoldCsvAction()
00110 {
00111 $fileName = 'products_ordered.csv';
00112 $content = $this->getLayout()
00113 ->createBlock('adminhtml/report_product_sold_grid')
00114 ->getCsv();
00115
00116 $this->_prepareDownloadResponse($fileName, $content);
00117 }
00118
00119
00120
00121
00122
00123 public function exportSoldExcelAction()
00124 {
00125 $fileName = 'products_ordered.xml';
00126 $content = $this->getLayout()
00127 ->createBlock('adminhtml/report_product_sold_grid')
00128 ->getExcel($fileName);
00129
00130 $this->_prepareDownloadResponse($fileName, $content);
00131 }
00132
00133
00134
00135
00136
00137 public function viewedAction()
00138 {
00139 $this->_initAction()
00140 ->_setActiveMenu('report/product/viewed')
00141 ->_addBreadcrumb(Mage::helper('reports')->__('Most viewed'), Mage::helper('reports')->__('Most viewed'))
00142 ->_addContent($this->getLayout()->createBlock('adminhtml/report_product_viewed'))
00143 ->renderLayout();
00144 }
00145
00146
00147
00148
00149
00150 public function exportViewedCsvAction()
00151 {
00152 $fileName = 'products_mostviewed.csv';
00153 $content = $this->getLayout()->createBlock('adminhtml/report_product_viewed_grid')
00154 ->getCsv();
00155
00156 $this->_prepareDownloadResponse($fileName, $content);
00157 }
00158
00159
00160
00161
00162
00163 public function exportViewedExcelAction()
00164 {
00165 $fileName = 'products_mostviewed.xml';
00166 $content = $this->getLayout()->createBlock('adminhtml/report_product_viewed_grid')
00167 ->getExcel($fileName);
00168
00169 $this->_prepareDownloadResponse($fileName, $content);
00170 }
00171
00172
00173
00174
00175
00176 public function lowstockAction()
00177 {
00178 $this->_initAction()
00179 ->_setActiveMenu('report/product/lowstock')
00180 ->_addBreadcrumb(Mage::helper('reports')->__('Low stock'), Mage::helper('reports')->__('Low stock'))
00181 ->_addContent($this->getLayout()->createBlock('adminhtml/report_product_lowstock'))
00182 ->renderLayout();
00183 }
00184
00185
00186
00187
00188
00189 public function exportLowstockCsvAction()
00190 {
00191 $fileName = 'products_lowstock.csv';
00192 $content = $this->getLayout()->createBlock('adminhtml/report_product_lowstock_grid')
00193 ->setSaveParametersInSession(true)
00194 ->getCsv();
00195
00196 $this->_prepareDownloadResponse($fileName, $content);
00197 }
00198
00199
00200
00201
00202
00203 public function exportLowstockExcelAction()
00204 {
00205 $fileName = 'products_lowstock.xml';
00206 $content = $this->getLayout()->createBlock('adminhtml/report_product_lowstock_grid')
00207 ->setSaveParametersInSession(true)
00208 ->getExcel($fileName);
00209
00210 $this->_prepareDownloadResponse($fileName, $content);
00211 }
00212
00213
00214
00215
00216
00217 public function downloadsAction()
00218 {
00219 $this->_initAction()
00220 ->_setActiveMenu('report/product/downloads')
00221 ->_addBreadcrumb(Mage::helper('reports')->__('Downloads'), Mage::helper('reports')->__('Downloads'))
00222 ->_addContent($this->getLayout()->createBlock('adminhtml/report_product_downloads'))
00223 ->renderLayout();
00224 }
00225
00226
00227
00228
00229
00230 public function exportDownloadsCsvAction()
00231 {
00232 $fileName = 'products_downloads.csv';
00233 $content = $this->getLayout()->createBlock('adminhtml/report_product_downloads_grid')
00234 ->setSaveParametersInSession(true)
00235 ->getCsv();
00236
00237 $this->_prepareDownloadResponse($fileName, $content);
00238 }
00239
00240
00241
00242
00243
00244 public function exportDownloadsExcelAction()
00245 {
00246 $fileName = 'products_downloads.xml';
00247 $content = $this->getLayout()->createBlock('adminhtml/report_product_downloads_grid')
00248 ->setSaveParametersInSession(true)
00249 ->getExcel($fileName);
00250
00251 $this->_prepareDownloadResponse($fileName, $content);
00252 }
00253
00254
00255
00256
00257
00258
00259 protected function _isAllowed()
00260 {
00261 switch ($this->getRequest()->getActionName()) {
00262 case 'ordered':
00263 return Mage::getSingleton('admin/session')->isAllowed('report/products/ordered');
00264 break;
00265 case 'viewed':
00266 return Mage::getSingleton('admin/session')->isAllowed('report/products/viewed');
00267 break;
00268 case 'sold':
00269 return Mage::getSingleton('admin/session')->isAllowed('report/products/sold');
00270 break;
00271 case 'lowstock':
00272 return Mage::getSingleton('admin/session')->isAllowed('report/products/lowstock');
00273 break;
00274 default:
00275 return Mage::getSingleton('admin/session')->isAllowed('report/products');
00276 break;
00277 }
00278 }
00279 }