setId('ekomi_sent_status'); $this->setDefaultSort('ekomi_rating_email_id'); $this->setDefaultDir('desc'); $this->setUseAjax(true); $this->setSaveParametersInSession(true); } protected function _prepareCollection() { // @todo add multi store support $collection = Mage::getModel('ekomimeetsmage/rating_email')->getCollection(); $collection->getSelect() ->joinInner( array('order'=>Mage::getSingleton('core/resource')->getTableName('sales_flat_order')), 'main_table.order_id = order.entity_id' ); $this->setCollection($collection); return parent::_prepareCollection(); } protected function _prepareColumns() { $this->addColumn( 'ekomi_rating_email_id', array('header' => $this->getEkomiHelper()->__('ID'), 'align' => 'center', 'width' => '50px', 'filter' => false, 'sortable' => true, 'index' => 'ekomi_rating_email_id', ) ); $this->addColumn( 'sent_status', array('header' => $this->getEkomiHelper()->__('Send Status'), 'align' => 'left', 'width' => '160px', 'filter_index' => 'sent_status', 'index' => 'sent_status', 'type' => 'text', 'filter' => false, 'sortable' => true, 'frame_callback' => array($this, 'decorateStatus') ) ); $this->addColumn( 'send_out_date', array('header' => $this->getEkomiHelper()->__('Planed send time'), 'align' => 'left', 'width' => '160px', 'index' => 'send_out_date', 'sortable' => true, 'filter' => false, 'frame_callback' => array($this, 'decorateTime') ) ); $this->addColumn( 'sent_date', array('header' => $this->getEkomiHelper()->__('Sent time'), 'align' => 'left', 'width' => '160px', 'index' => 'sent_date', 'sortable' => true, 'filter' => false, 'frame_callback' => array($this, 'decorateTime') ) ); $this->addColumn( 'order_id', array('header' => $this->getEkomiHelper()->__('Order number'), 'align' => 'left', 'width' => '120px', 'index' => 'order_id', 'filter_index' => 'order_id', 'filter' => false, 'sortable' => true, 'frame_callback'=> array($this, 'decorateOrderId') ) ); $this->addColumn( 'firstname', array('header' => $this->getEkomiHelper()->__('Firstname'), 'align' => 'left', 'width' => '120px', 'index' => 'customer_firstname', 'filter_index' => 'customer_firstname', 'sortable' => false, ) ); $this->addColumn( 'lastname', array('header' => $this->getEkomiHelper()->__('Lastname'), 'align' => 'left', 'width' => '120px', 'index' => 'customer_lastname', 'filter_index' => 'customer_lastname', 'sortable' => false, ) ); $this->addColumn( 'email', array('header' => $this->getEkomiHelper()->__('E-Mail'), 'align' => 'left', 'index' => 'customer_email', 'filter_index' => 'customer_email', 'sortable' => false, ) ); $this->addColumn( 'settings', array('header' => $this->getEkomiHelper()->__('Settings'), 'align' => 'left', 'width' => '120px', 'index' => 'settings', 'sortable' => false, 'filter' => false, 'frame_callback'=> array($this, 'decorateOptions') ) ); return parent::_prepareColumns(); } public function decorateRating($value, $row, $column, $isExport) { func_get_args(); $html = ""; $html .= "
"; $html .= "
getRating())."px; background: "; $html .= "url({$this->getSkinUrl("ekomimeetsmage/images/ekomi_star_color.png")}) repeat-x;\">"; $html .= "
"; $html .= "
"; return $html; } public function decorateStatus($value, $row, $column, $isExport) { func_get_args(); $class = ''; $word = ''; if ($value == MeetsEcommerce_Ekomimeetsmage_Model_Rating_Email::STATUS_COMPLETE) { $class = 'grid-severity-notice'; $word = $this->__('complete'); } elseif ($value == MeetsEcommerce_Ekomimeetsmage_Model_Rating_Email::STATUS_WAITING) { $class = 'grid-severity-minor'; $word = $this->__('waiting'); } elseif ($value == MeetsEcommerce_Ekomimeetsmage_Model_Rating_Email::STATUS_PENDING) { $class = 'grid-severity-minor'; $word = $this->__('pending'); } elseif ($value == MeetsEcommerce_Ekomimeetsmage_Model_Rating_Email::STATUS_FAILED) { $class = 'grid-severity-critical'; $word = $this->__('failed'); } elseif ($value == MeetsEcommerce_Ekomimeetsmage_Model_Rating_Email::STATUS_CANCELED) { $class = 'grid-severity-critical'; $word = $this->__('canceled'); } return ''.$word.''; } public function decorateOptions($value, $row, $column, $isExport) { func_get_args(); return 'getUrl( "ekomimeetsmage_admin/watch/resendemail/", array("id" => $row->getId()) ).'">'.$this->__("Resend email").''; } public function decorateTime($value, $row, $column, $isExport) { func_get_args(); $result = in_array( $row->getSentStatus(), array( MeetsEcommerce_Ekomimeetsmage_Model_Rating_Email::STATUS_FAILED, MeetsEcommerce_Ekomimeetsmage_Model_Rating_Email::STATUS_PENDING, MeetsEcommerce_Ekomimeetsmage_Model_Rating_Email::STATUS_WAITING ) ); if ($value==0 && $result) { return $this->__('not send yet'); } return date("d.m.Y H:i:s", (int)$value); } public function decorateOrderId($value, $row, $column, $isExport) { func_get_args(); return '#'.Mage::getSingleton('sales/order')->load($value)->getIncrementId(); } public function getRowUrl($row) { func_get_args(); return '#'; } public function getGridUrl() { return Mage::helper("adminhtml")->getUrl( "ekomimeetsmage_admin/grid/watch_sent/", array("sku" => $this->_currentSku) ); } private function getEkomiHelper() { if ($this->_helper === NULL) { $this->_helper = Mage::helper('ekomimeetsmage'); } return $this->_helper; } }