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_Orders extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('customer_orders_grid');
41: $this->setDefaultSort('created_at', 'desc');
42: $this->setUseAjax(true);
43: }
44:
45: protected function _prepareCollection()
46: {
47: $collection = Mage::getResourceModel('sales/order_grid_collection')
48: ->addFieldToSelect('entity_id')
49: ->addFieldToSelect('increment_id')
50: ->addFieldToSelect('customer_id')
51: ->addFieldToSelect('created_at')
52: ->addFieldToSelect('grand_total')
53: ->addFieldToSelect('order_currency_code')
54: ->addFieldToSelect('store_id')
55: ->addFieldToSelect('billing_name')
56: ->addFieldToSelect('shipping_name')
57: ->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
58: ->setIsCustomerMode(true);
59:
60: $this->setCollection($collection);
61: return parent::_prepareCollection();
62: }
63:
64: protected function _prepareColumns()
65: {
66: $this->addColumn('increment_id', array(
67: 'header' => Mage::helper('customer')->__('Order #'),
68: 'width' => '100',
69: 'index' => 'increment_id',
70: ));
71:
72: $this->addColumn('created_at', array(
73: 'header' => Mage::helper('customer')->__('Purchase On'),
74: 'index' => 'created_at',
75: 'type' => 'datetime',
76: ));
77:
78: 79: 80: 81: 82: 83: 84: 85: 86:
87: $this->addColumn('billing_name', array(
88: 'header' => Mage::helper('customer')->__('Bill to Name'),
89: 'index' => 'billing_name',
90: ));
91:
92: $this->addColumn('shipping_name', array(
93: 'header' => Mage::helper('customer')->__('Shipped to Name'),
94: 'index' => 'shipping_name',
95: ));
96:
97: $this->addColumn('grand_total', array(
98: 'header' => Mage::helper('customer')->__('Order Total'),
99: 'index' => 'grand_total',
100: 'type' => 'currency',
101: 'currency' => 'order_currency_code',
102: ));
103:
104: if (!Mage::app()->isSingleStoreMode()) {
105: $this->addColumn('store_id', array(
106: 'header' => Mage::helper('customer')->__('Bought From'),
107: 'index' => 'store_id',
108: 'type' => 'store',
109: 'store_view' => true
110: ));
111: }
112:
113: if (Mage::helper('sales/reorder')->isAllow()) {
114: $this->addColumn('action', array(
115: 'header' => ' ',
116: 'filter' => false,
117: 'sortable' => false,
118: 'width' => '100px',
119: 'renderer' => 'adminhtml/sales_reorder_renderer_action'
120: ));
121: }
122:
123: return parent::_prepareColumns();
124: }
125:
126: public function getRowUrl($row)
127: {
128: return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
129: }
130:
131: public function getGridUrl()
132: {
133: return $this->getUrl('*/*/orders', array('_current' => true));
134: }
135:
136: }
137: