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: class Mage_Adminhtml_Block_Checkout_Agreement_Grid extends Mage_Adminhtml_Block_Widget_Grid
27: {
28:
29: public function __construct()
30: {
31: parent::__construct();
32: $this->setDefaultSort('agreement_id');
33: $this->setId('agreementGrid');
34: $this->setDefaultDir('asc');
35: $this->setSaveParametersInSession(true);
36: }
37:
38: protected function _prepareCollection()
39: {
40: $collection = Mage::getModel('checkout/agreement')
41: ->getCollection();
42: $this->setCollection($collection);
43: return parent::_prepareCollection();
44: }
45:
46: protected function _prepareColumns()
47: {
48: $this->addColumn('agreement_id',
49: array(
50: 'header'=>Mage::helper('checkout')->__('ID'),
51: 'align' =>'right',
52: 'width' => '50px',
53: 'index' => 'agreement_id'
54: )
55: );
56:
57: $this->addColumn('name',
58: array(
59: 'header'=>Mage::helper('checkout')->__('Condition Name'),
60: 'index' => 'name'
61: )
62: );
63:
64: if (!Mage::app()->isSingleStoreMode()) {
65: $this->addColumn('store_id', array(
66: 'header' => Mage::helper('adminhtml')->__('Store View'),
67: 'index' => 'store_id',
68: 'type' => 'store',
69: 'store_all' => true,
70: 'store_view' => true,
71: 'sortable' => false,
72: 'filter_condition_callback'
73: => array($this, '_filterStoreCondition'),
74: ));
75: }
76:
77: $this->addColumn('is_active', array(
78: 'header' => Mage::helper('adminhtml')->__('Status'),
79: 'index' => 'is_active',
80: 'type' => 'options',
81: 'options' => array(
82: 0 => Mage::helper('adminhtml')->__('Disabled'),
83: 1 => Mage::helper('adminhtml')->__('Enabled')
84: ),
85: ));
86:
87: return parent::_prepareColumns();
88: }
89:
90: protected function _afterLoadCollection()
91: {
92: $this->getCollection()->walk('afterLoad');
93: parent::_afterLoadCollection();
94: }
95:
96: protected function _filterStoreCondition($collection, $column)
97: {
98: if (!$value = $column->getFilter()->getValue()) {
99: return;
100: }
101:
102: $this->getCollection()->addStoreFilter($value);
103: }
104:
105: public function getRowUrl($row)
106: {
107: return $this->getUrl('*/*/edit', array('id' => $row->getId()));
108: }
109:
110: }
111: