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 class Mage_Adminhtml_Controller_Sales_Creditmemo extends Mage_Adminhtml_Controller_Action
00033 {
00034
00035
00036
00037
00038 protected function _construct()
00039 {
00040 $this->setUsedModuleName('Mage_Sales');
00041 }
00042
00043
00044
00045
00046
00047
00048 protected function _initAction()
00049 {
00050 $this->loadLayout()
00051 ->_setActiveMenu('sales/order')
00052 ->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
00053 ->_addBreadcrumb($this->__('Credit Memos'),$this->__('Credit Memos'));
00054 return $this;
00055 }
00056
00057
00058
00059
00060 public function indexAction()
00061 {
00062 $this->_initAction()
00063 ->_addContent($this->getLayout()->createBlock('adminhtml/sales_creditmemo'))
00064 ->renderLayout();
00065 }
00066
00067
00068
00069
00070 public function viewAction()
00071 {
00072 if ($creditmemoId = $this->getRequest()->getParam('creditmemo_id')) {
00073 $this->_forward('view', 'sales_order_creditmemo', null, array('come_from' => 'sales_creditmemo'));
00074 } else {
00075 $this->_forward('noRoute');
00076 }
00077 }
00078
00079 public function pdfcreditmemosAction(){
00080 $creditmemosIds = $this->getRequest()->getPost('creditmemo_ids');
00081 if (!empty($creditmemosIds)) {
00082 $invoices = Mage::getResourceModel('sales/order_creditmemo_collection')
00083 ->addAttributeToSelect('*')
00084 ->addAttributeToFilter('entity_id', array('in' => $creditmemosIds))
00085 ->load();
00086 if (!isset($pdf)){
00087 $pdf = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($invoices);
00088 } else {
00089 $pages = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($invoices);
00090 $pdf->pages = array_merge ($pdf->pages, $pages->pages);
00091 }
00092
00093 return $this->_prepareDownloadResponse('creditmemo'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf');
00094 }
00095 $this->_redirect('*/*/');
00096 }
00097
00098 public function printAction()
00099 {
00100
00101 if ($creditmemoId = $this->getRequest()->getParam('invoice_id')) {
00102 if ($creditmemo = Mage::getModel('sales/order_creditmemo')->load($creditmemoId)) {
00103 if ($creditmemo->getStoreId()) {
00104 Mage::app()->setCurrentStore($creditmemo->getStoreId());
00105 }
00106 $pdf = Mage::getModel('sales/order_pdf_creditmemo')->getPdf(array($creditmemo));
00107 $this->_prepareDownloadResponse('creditmemo'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf');
00108 }
00109 }
00110 else {
00111 $this->_forward('noRoute');
00112 }
00113 }
00114
00115 protected function _isAllowed()
00116 {
00117 return Mage::getSingleton('admin/session')->isAllowed('sales/creditmemo');
00118 }
00119 }