isAllowed('gls/csv'); } public function downloadAction() { $params = $this->getRequest()->getParams(); if(isset($params['file'])){ $file = $params['file']; } else{ exit(); } $fileName = 'GLS-' . $file; $this->_prepareDownloadResponse($fileName, null, 'application/octet-stream', filesize(Mage::getBaseDir("var") . DS . "GLS" . DS . $file)); $this->getResponse()->sendHeaders(); $this->output($file); exit(); } public function output($filename) { $ioAdapter = new Varien_Io_File(); $ioAdapter->open(array('path' => Mage::getBaseDir("var") . DS . "GLS")); $ioAdapter->streamOpen($filename, 'r'); while ($buffer = $ioAdapter->streamRead()) { echo $buffer; } $ioAdapter->streamClose(); } public function createcsvfilesAction() { $returnlabel = $this->getRequest()->getParam('returnlabel',false); if($returnlabel) { $returnlabel = $this->getRequest()->getParam('returnlabelemail',true); } $params = $this->getRequest()->getParams(); if(isset($params['order_ids'])) { $order_ids = $params['order_ids']; $export_filename = false; /* if(count($order_ids) > 1) { $export_filename = "gls_orders_exported_".Mage::getModel('core/date')->date('Y-m-d_H-i_s').".csv"; } */ foreach($order_ids as $order_id) { $order = Mage::getModel('sales/order')->load($order_id); Mage::getModel('gls/observer')->exportToGLSFormat($order,$export_filename,$returnlabel); } Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/index/',$params)); } elseif(isset($params['order_id'])) { $order_id = $params['order_id']; $order = Mage::getModel('sales/order')->load($order_id); Mage::getModel('gls/observer')->exportToGLSFormat($order,false,$returnlabel); Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/view/',$params)); } else { Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/index/',$params)); } } } ?>