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