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