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_Customer_Edit_Tab_Orders extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('customer_orders_grid');
00041 $this->setDefaultSort('created_at', 'desc');
00042 $this->setUseAjax(true);
00043 }
00044
00045 protected function _prepareCollection()
00046 {
00047
00048 $collection = Mage::getResourceModel('sales/order_collection')
00049 ->addAttributeToSelect('increment_id')
00050 ->addAttributeToSelect('created_at')
00051 ->addAttributeToSelect('grand_total')
00052 ->addAttributeToSelect('order_currency_code')
00053 ->addAttributeToSelect('store_id')
00054 ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
00055 ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
00056 ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
00057 ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
00058 ->addExpressionAttributeToSelect('billing_name',
00059 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
00060 array('billing_firstname', 'billing_lastname'))
00061 ->addExpressionAttributeToSelect('shipping_name',
00062 'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})',
00063 array('shipping_firstname', 'shipping_lastname'))
00064
00065 ->addAttributeToFilter('customer_id', Mage::registry('current_customer')->getEntityId())
00066 ;
00067 $this->setCollection($collection);
00068 return parent::_prepareCollection();
00069 }
00070
00071 protected function _prepareColumns()
00072 {
00073 $this->addColumn('increment_id', array(
00074 'header' => Mage::helper('customer')->__('Order #'),
00075 'width' => '100',
00076 'index' => 'increment_id',
00077 ));
00078
00079 $this->addColumn('created_at', array(
00080 'header' => Mage::helper('customer')->__('Purchase On'),
00081 'index' => 'created_at',
00082 'type' => 'datetime',
00083 ));
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 $this->addColumn('billing_name', array(
00095 'header' => Mage::helper('customer')->__('Bill to Name'),
00096 'index' => 'billing_name',
00097 ));
00098
00099 $this->addColumn('shipping_name', array(
00100 'header' => Mage::helper('customer')->__('Shipped to Name'),
00101 'index' => 'shipping_name',
00102 ));
00103
00104 $this->addColumn('grand_total', array(
00105 'header' => Mage::helper('customer')->__('Order Total'),
00106 'index' => 'grand_total',
00107 'type' => 'currency',
00108 'currency' => 'order_currency_code',
00109 ));
00110
00111 if (!Mage::app()->isSingleStoreMode()) {
00112 $this->addColumn('store_id', array(
00113 'header' => Mage::helper('customer')->__('Bought From'),
00114 'index' => 'store_id',
00115 'type' => 'store',
00116 'store_view' => true
00117 ));
00118 }
00119
00120 $this->addColumn('action', array(
00121 'header' => ' ',
00122 'filter' => false,
00123 'sortable' => false,
00124 'width' => '100px',
00125 'renderer' => 'adminhtml/sales_reorder_renderer_action'
00126 ));
00127
00128 return parent::_prepareColumns();
00129 }
00130
00131 public function getRowUrl($row)
00132 {
00133 return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
00134 }
00135
00136 public function getGridUrl()
00137 {
00138 return $this->getUrl('*/*/orders', array('_current' => true));
00139 }
00140
00141 }