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_Sales_Order_Status_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('sales_order_status_grid');
41:
42: $this->setPagerVisibility(false);
43: $this->setDefaultSort('state');
44: $this->setDefaultDir('DESC');
45: }
46:
47: protected function _prepareCollection()
48: {
49: $collection = Mage::getResourceModel('sales/order_status_collection');
50: $collection->joinStates();
51: $this->setCollection($collection);
52: parent::_prepareCollection();
53: return $this;
54: }
55:
56: protected function _prepareColumns()
57: {
58: $this->addColumn('label', array(
59: 'header' => Mage::helper('sales')->__('Status'),
60: 'index' => 'label',
61: ));
62:
63: $this->addColumn('status', array(
64: 'header' => Mage::helper('sales')->__('Status Code'),
65: 'type' => 'text',
66: 'index' => 'status',
67: 'filter_index' => 'main_table.status',
68: 'width' => '200px',
69: ));
70:
71: $this->addColumn('is_default', array(
72: 'header' => Mage::helper('sales')->__('Default Status'),
73: 'index' => 'is_default',
74: 'width' => '100px',
75: 'type' => 'options',
76: 'options' => array(0 => $this->__('No'), 1 => $this->__('Yes')),
77: 'sortable' => false,
78: ));
79:
80: $this->addColumn('state', array(
81: 'header'=> Mage::helper('sales')->__('State Code [State Title]'),
82: 'type' => 'text',
83: 'index' => 'state',
84: 'width' => '250px',
85: 'frame_callback' => array($this, 'decorateState')
86: ));
87:
88: $this->addColumn('unassign', array(
89: 'header' => Mage::helper('sales')->__('Action'),
90: 'index' => 'unassign',
91: 'width' => '100px',
92: 'type' => 'text',
93: 'frame_callback' => array($this, 'decorateAction'),
94: 'sortable' => false,
95: 'filter' => false,
96: ));
97:
98: return parent::_prepareColumns();
99: }
100:
101: 102: 103: 104: 105:
106: public function decorateState($value, $row, $column, $isExport)
107: {
108: if ($value) {
109: $cell = $value . ' [' . Mage::getSingleton('sales/order_config')->getStateLabel($value) . ']';
110: } else {
111: $cell = $value;
112: }
113: return $cell;
114: }
115:
116: public function decorateAction($value, $row, $column, $isExport)
117: {
118: $cell = '';
119: $state = $row->getState();
120: if (!empty($state)) {
121: $url = $this->getUrl(
122: '*/*/unassign',
123: array('status' => $row->getStatus(), 'state' => $row->getState())
124: );
125: $label = Mage::helper('sales')->__('Unassign');
126: $cell = '<a href="' . $url . '">' . $label . '</a>';
127: }
128: return $cell;
129: }
130:
131: 132: 133:
134: protected function _preparePage()
135: {
136: return $this;
137: }
138:
139:
140: public function getRowUrl($row)
141: {
142: return $this->getUrl('*/sales_order_status/edit', array('status' => $row->getStatus()));
143: }
144: }
145: