1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Orders extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('customer_view_orders_grid');
41: $this->setDefaultSort('created_at', 'desc');
42: $this->setSortable(false);
43: $this->setPagerVisibility(false);
44: $this->setFilterVisibility(false);
45: }
46:
47: protected function _preparePage()
48: {
49: $this->getCollection()
50: ->setPageSize(5)
51: ->setCurPage(1);
52: }
53:
54: protected function _prepareCollection()
55: {
56: $collection = Mage::getResourceModel('sales/order_grid_collection')
57: ->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
58: ->setIsCustomerMode(true);
59: $this->setCollection($collection);
60: return parent::_prepareCollection();
61: }
62:
63: protected function _prepareColumns()
64: {
65:
66: $this->addColumn('increment_id', array(
67: 'header' => Mage::helper('customer')->__('Order #'),
68: 'align' => 'center',
69: 'index' => 'increment_id',
70: 'width' => '100px',
71: ));
72:
73: $this->addColumn('created_at', array(
74: 'header' => Mage::helper('customer')->__('Purchased At'),
75: 'index' => 'created_at',
76: 'type' => 'datetime',
77: ));
78:
79: $this->addColumn('billing_name', array(
80: 'header' => Mage::helper('customer')->__('Bill to Name'),
81: 'index' => 'billing_name',
82: ));
83:
84: $this->addColumn('shipping_name', array(
85: 'header' => Mage::helper('customer')->__('Shipped to Name'),
86: 'index' => 'shipping_name',
87: ));
88:
89: $this->addColumn('grand_total', array(
90: 'header' => Mage::helper('customer')->__('Grand Total'),
91: 'index' => 'grand_total',
92: 'type' => 'currency',
93: 'currency' => 'order_currency_code',
94: ));
95:
96: if (!Mage::app()->isSingleStoreMode()) {
97: $this->addColumn('store_id', array(
98: 'header' => Mage::helper('customer')->__('Bought From'),
99: 'index' => 'store_id',
100: 'type' => 'store',
101: 'store_view' => true,
102: ));
103: }
104:
105: $this->addColumn('action', array(
106: 'header' => ' ',
107: 'filter' => false,
108: 'sortable' => false,
109: 'width' => '100px',
110: 'renderer' => 'adminhtml/sales_reorder_renderer_action'
111: ));
112:
113: return parent::_prepareColumns();
114: }
115:
116: public function getRowUrl($row)
117: {
118: return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
119: }
120:
121: public function ()
122: {
123: return ($this->getCollection()->getSize() > 0);
124: }
125:
126: }
127: