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_XmlConnect_Block_Adminhtml_Queue_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: 37: 38:
39: public function __construct()
40: {
41: parent::__construct();
42: $this->setId('app_queue_grid');
43: $this->setDefaultSort('exec_time');
44: $this->setDefaultDir('DESC');
45: $this->setSaveParametersInSession(true);
46: }
47:
48: 49: 50: 51: 52:
53: protected function _prepareCollection()
54: {
55: $collection = Mage::getModel('xmlconnect/queue')->getCollection();
56:
57: $collection->addFieldToFilter(
58: 'main_table.status',
59: array('neq' => Mage_XmlConnect_Model_Queue::STATUS_DELETED)
60: );
61: $this->setCollection($collection);
62: return parent::_prepareCollection();
63: }
64:
65: 66: 67: 68: 69:
70: protected function _prepareColumns()
71: {
72: $this->addColumn('queue_id', array(
73: 'header' => $this->__('ID'),
74: 'align' => 'center',
75: 'index' => 'main_table.queue_id',
76: 'width' => '40px',
77: 'renderer' => 'xmlconnect/adminhtml_queue_grid_renderer_id'
78: ));
79:
80: $this->addColumn('exec_time', array(
81: 'header' => $this->__('Queue Date'),
82: 'index' => 'exec_time',
83: 'type' => 'datetime',
84: 'gmtoffset' => false,
85: 'default' => ' ---- '
86: ));
87:
88: $this->addColumn('app_code', array(
89: 'header' => $this->__('Application Name'),
90: 'align' => 'left',
91: 'index' => 'app.code',
92: 'type' => 'options',
93: 'options' => Mage::helper('xmlconnect')->getApplications(),
94: 'renderer' => 'xmlconnect/adminhtml_queue_grid_renderer_application'
95: ));
96:
97: $this->addColumn('name', array(
98: 'header' => $this->__('Template Name'),
99: 'align' => 'left',
100: 'index' => 't.name',
101: 'type' => 'text',
102: 'default' => '--- Parent template has been deleted ---',
103: 'renderer' => 'xmlconnect/adminhtml_queue_grid_renderer_template'
104: ));
105:
106: $this->addColumn('push_title', array(
107: 'header' => $this->__('Push Title'),
108: 'align' => 'left',
109: 'index' => 'main_table.push_title',
110: 'type' => 'text',
111: 'renderer' => 'xmlconnect/adminhtml_queue_grid_renderer_pushtitle'
112: ));
113:
114: $this->addColumn('message_title', array(
115: 'header' => $this->__('Message Title'),
116: 'align' => 'left',
117: 'index' => 'main_table.message_title',
118: 'type' => 'text',
119: 'renderer' => 'xmlconnect/adminhtml_queue_grid_renderer_msgtitle'
120: ));
121:
122: $this->addColumn('status', array(
123: 'header' => $this->__('Status'),
124: 'align' => 'left',
125: 'index' => 'main_table.status',
126: 'type' => 'options',
127: 'width' => '50px',
128: 'options' => array(
129: Mage_XmlConnect_Model_Queue::STATUS_CANCELED => $this->__('Canceled'),
130: Mage_XmlConnect_Model_Queue::STATUS_IN_QUEUE => $this->__('In Queue'),
131: Mage_XmlConnect_Model_Queue::STATUS_COMPLETED => $this->__('Completed'),
132: ),
133: 'renderer' => 'xmlconnect/adminhtml_queue_grid_renderer_status',
134: ));
135:
136: $this->addColumn('action', array(
137: 'header' => $this->__('Action'),
138: 'type' => 'action',
139: 'getter' => 'getId',
140: 'renderer' => 'xmlconnect/adminhtml_queue_grid_renderer_action',
141:
142: 'filter' => false,
143: 'sortable' => false,
144: ));
145:
146: return parent::_prepareColumns();
147: }
148:
149: 150: 151: 152: 153:
154: protected function _prepareMassaction()
155: {
156: $this->setMassactionIdField('id');
157: $this->getMassactionBlock()->setFormFieldName('queue');
158:
159: $this->getMassactionBlock()->addItem('delete', array(
160: 'label' => $this->__('Delete'),
161: 'url' => $this->getUrl('*/*/massDeleteQueue'),
162: 'confirm' => $this->__('Are you sure you what to delete selected records?')
163: ));
164:
165: $this->getMassactionBlock()->addItem('cancel', array(
166: 'label' => $this->__('Cancel'),
167: 'url' => $this->getUrl('*/*/massCancelQueue'),
168: 'confirm' => $this->__('Are you sure you what to cancel selected records?')
169: ));
170: return $this;
171: }
172:
173: 174: 175: 176: 177: 178:
179: public function getRowUrl($row)
180: {
181: return $this->getUrl('*/*/editQueue', array('id' => $row->getId()));
182: }
183: }
184: