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_Block_Sales_Creditmemo_Grid extends Mage_Adminhtml_Block_Widget_Grid
00033 {
00034
00035 public function __construct()
00036 {
00037 parent::__construct();
00038 $this->setId('sales_creditmemo_grid');
00039 $this->setDefaultSort('created_at');
00040 $this->setDefaultDir('DESC');
00041 }
00042
00043 protected function _prepareCollection()
00044 {
00045
00046 $collection = Mage::getResourceModel('sales/order_Creditmemo_collection')
00047 ->addAttributeToSelect('increment_id')
00048 ->addAttributeToSelect('created_at')
00049 ->addAttributeToSelect('order_currency_code')
00050 ->addAttributeToSelect('state')
00051 ->addAttributeToSelect('grand_total')
00052 ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
00053 ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
00054 ->joinAttribute('order_increment_id', 'order/increment_id', 'order_id', null, 'left')
00055 ->joinAttribute('order_created_at', 'order/created_at', 'order_id', null, 'left')
00056 ;
00057 $this->setCollection($collection);
00058 return parent::_prepareCollection();
00059 }
00060
00061 protected function _prepareColumns()
00062 {
00063 $this->addColumn('increment_id', array(
00064 'header' => Mage::helper('sales')->__('Credit Memo #'),
00065 'index' => 'increment_id',
00066 'type' => 'number',
00067 ));
00068
00069 $this->addColumn('created_at', array(
00070 'header' => Mage::helper('sales')->__('Created At'),
00071 'index' => 'created_at',
00072 'type' => 'datetime',
00073 ));
00074
00075 $this->addColumn('order_increment_id', array(
00076 'header' => Mage::helper('sales')->__('Order #'),
00077 'index' => 'order_increment_id',
00078 'type' => 'number',
00079 ));
00080
00081 $this->addColumn('order_created_at', array(
00082 'header' => Mage::helper('sales')->__('Order Date'),
00083 'index' => 'order_created_at',
00084 'type' => 'datetime',
00085 ));
00086
00087 $this->addColumn('billing_firstname', array(
00088 'header' => Mage::helper('sales')->__('Bill to First name'),
00089 'index' => 'billing_firstname',
00090 ));
00091
00092 $this->addColumn('billing_lastname', array(
00093 'header' => Mage::helper('sales')->__('Bill to Last name'),
00094 'index' => 'billing_lastname',
00095 ));
00096
00097 $this->addColumn('state', array(
00098 'header' => Mage::helper('sales')->__('Status'),
00099 'index' => 'state',
00100 'type' => 'options',
00101 'options' => Mage::getModel('sales/order_creditmemo')->getStates(),
00102 ));
00103
00104 $this->addColumn('grand_total', array(
00105 'header' => Mage::helper('customer')->__('Refunded'),
00106 'index' => 'grand_total',
00107 'type' => 'currency',
00108 'align' => 'right',
00109 'currency' => 'order_currency_code',
00110 ));
00111
00112 $this->addColumn('action',
00113 array(
00114 'header' => Mage::helper('sales')->__('Action'),
00115 'width' => '50px',
00116 'type' => 'action',
00117 'getter' => 'getId',
00118 'actions' => array(
00119 array(
00120 'caption' => Mage::helper('sales')->__('View'),
00121 'url' => array('base'=>'*/*/view'),
00122 'field' => 'creditmemo_id'
00123 )
00124 ),
00125 'filter' => false,
00126 'sortable' => false,
00127 'is_system' => true
00128 ));
00129
00130 return parent::_prepareColumns();
00131 }
00132
00133 protected function _prepareMassaction()
00134 {
00135 $this->setMassactionIdField('entity_id');
00136 $this->getMassactionBlock()->setFormFieldName('creditmemo_ids');
00137
00138 $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
00139 'label'=> Mage::helper('sales')->__('PDF Credit Memos'),
00140 'url' => $this->getUrl('*/*/pdfcreditmemos'),
00141 ));
00142
00143 return $this;
00144 }
00145
00146 public function getRowUrl($row)
00147 {
00148 return $this->getUrl('*/*/view',
00149 array(
00150 'creditmemo_id'=> $row->getId(),
00151 )
00152 );
00153 }
00154
00155 public function getGridUrl()
00156 {
00157 return $this->getUrl('*/*/*', array('_current' => true));
00158 }
00159
00160
00161
00162 }