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_Block_Sales_Order_View_Tab_Creditmemos
00035 extends Mage_Adminhtml_Block_Widget_Grid
00036 implements Mage_Adminhtml_Block_Widget_Tab_Interface
00037 {
00038 public function __construct()
00039 {
00040 parent::__construct();
00041 $this->setId('order_creditmemos_grid');
00042 $this->setUseAjax(true);
00043 }
00044
00045 protected function _prepareCollection()
00046 {
00047
00048 $collection = Mage::getResourceModel('sales/order_Creditmemo_collection')
00049 ->addAttributeToSelect('increment_id')
00050 ->addAttributeToSelect('created_at')
00051 ->addAttributeToSelect('order_currency_code')
00052 ->addAttributeToSelect('store_currency_code')
00053 ->addAttributeToSelect('base_currency_code')
00054 ->addAttributeToSelect('state')
00055 ->addAttributeToSelect('grand_total')
00056 ->addAttributeToSelect('base_grand_total')
00057 ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
00058 ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
00059 ->addExpressionAttributeToSelect('billing_name',
00060 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
00061 array('billing_firstname', 'billing_lastname'))
00062 ->setOrderFilter($this->getOrder())
00063 ;
00064 $this->setCollection($collection);
00065 return parent::_prepareCollection();
00066 }
00067
00068 protected function _prepareColumns()
00069 {
00070 $this->addColumn('increment_id', array(
00071 'header' => Mage::helper('sales')->__('Credit Memo #'),
00072 'width' => '120px',
00073 'index' => 'increment_id',
00074 ));
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 $this->addColumn('billing_name', array(
00086 'header' => Mage::helper('sales')->__('Bill to Name'),
00087 'index' => 'billing_name',
00088 ));
00089
00090 $this->addColumn('created_at', array(
00091 'header' => Mage::helper('sales')->__('Created At'),
00092 'index' => 'created_at',
00093 'type' => 'datetime',
00094 ));
00095
00096 $this->addColumn('state', array(
00097 'header' => Mage::helper('sales')->__('Status'),
00098 'index' => 'state',
00099 'type' => 'options',
00100 'options' => Mage::getModel('sales/order_creditmemo')->getStates(),
00101 ));
00102
00103 $this->addColumn('base_grand_total', array(
00104 'header' => Mage::helper('customer')->__('Refunded'),
00105 'index' => 'base_grand_total',
00106 'type' => 'currency',
00107 'currency' => 'base_currency_code',
00108 ));
00109
00110 return parent::_prepareColumns();
00111 }
00112
00113
00114
00115
00116
00117
00118 public function getOrder()
00119 {
00120 return Mage::registry('current_order');
00121 }
00122
00123 public function getRowUrl($row)
00124 {
00125 return $this->getUrl(
00126 '*/sales_order_creditmemo/view',
00127 array(
00128 'creditmemo_id'=> $row->getId(),
00129 'order_id' => $row->getOrderId()
00130 ));
00131 }
00132
00133 public function getGridUrl()
00134 {
00135 return $this->getUrl('*/*/creditmemos', array('_current' => true));
00136 }
00137
00138
00139
00140
00141 public function getTabLabel()
00142 {
00143 return Mage::helper('sales')->__('Credit Memos');
00144 }
00145
00146 public function getTabTitle()
00147 {
00148 return Mage::helper('sales')->__('Order Credit Memos');
00149 }
00150
00151 public function canShowTab()
00152 {
00153 return true;
00154 }
00155
00156 public function isHidden()
00157 {
00158 return false;
00159 }
00160 }