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_View_Orders extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('customer_view_orders_grid');
00041 $this->setDefaultSort('created_at', 'desc');
00042 $this->setSortable(false);
00043 $this->setPagerVisibility(false);
00044 $this->setFilterVisibility(false);
00045 }
00046
00047 protected function _preparePage()
00048 {
00049 $this->getCollection()
00050 ->setPageSize(5)
00051 ->setCurPage(1);
00052 }
00053
00054 protected function _prepareCollection()
00055 {
00056
00057 $collection = Mage::getResourceModel('sales/order_collection')
00058 ->addAttributeToSelect('increment_id')
00059 ->addAttributeToSelect('created_at')
00060 ->addAttributeToSelect('grand_total')
00061 ->addAttributeToSelect('order_currency_code')
00062 ->addAttributeToSelect('store_id')
00063 ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
00064 ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
00065 ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
00066 ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
00067 ->addExpressionAttributeToSelect('billing_name',
00068 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
00069 array('billing_firstname', 'billing_lastname'))
00070 ->addExpressionAttributeToSelect('shipping_name',
00071 'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})',
00072 array('shipping_firstname', 'shipping_lastname'))
00073 ->addAttributeToFilter('customer_id', Mage::registry('current_customer')->getId());
00074 $this->setCollection($collection);
00075 return parent::_prepareCollection();
00076 }
00077
00078 protected function _prepareColumns()
00079 {
00080
00081 $this->addColumn('increment_id', array(
00082 'header' => Mage::helper('customer')->__('Order #'),
00083 'align' => 'center',
00084 'index' => 'increment_id',
00085 'width' => '100px',
00086 ));
00087
00088 $this->addColumn('created_at', array(
00089 'header' => Mage::helper('customer')->__('Purchased at'),
00090 'index' => 'created_at',
00091 'type' => 'datetime',
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')->__('Grand 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 getHeadersVisibility()
00137 {
00138 return ($this->getCollection()->getSize() > 0);
00139 }
00140
00141 }