<?php

/*
 * @author     M2E Pro Developers Team
 * @copyright  M2E LTD
 * @license    Commercial use is forbidden
 */

class Ess_M2ePro_Block_Adminhtml_Ebay_Listing_Product_SourceProducts_Grid
    extends Ess_M2ePro_Block_Adminhtml_Ebay_Listing_Product_Grid
{
    //########################################

    protected function _prepareColumns()
    {
        $this->addColumnAfter(
            'visibility', array(
                'header'    => Mage::helper('M2ePro')->__('Visibility'),
                'align'     => 'left',
                'width'     => '90px',
                'type'      => 'options',
                'sortable'  => false,
                'index'     => 'visibility',
                'filter_index' => 'visibility',
                'options' => Mage::getModel('catalog/product_visibility')->getOptionArray()
            ), 'qty'
        );

        $this->addColumnAfter(
            'status', array(
                'header'    => Mage::helper('M2ePro')->__('Status'),
                'align'     => 'left',
                'width'     => '90px',
                'type'      => 'options',
                'sortable'  => false,
                'index'     => 'status',
                'filter_index' => 'status',
                'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
                'frame_callback' => array($this, 'callbackColumnStatus')
            ), 'visibility'
        );

        if (!Mage::app()->isSingleStoreMode()) {
            $this->addColumnAfter(
                'websites', array(
                    'header'    => Mage::helper('M2ePro')->__('Websites'),
                    'align'     => 'left',
                    'width'     => '90px',
                    'type'      => 'options',
                    'sortable'  => false,
                    'index'     => 'websites',
                    'filter_index' => 'websites',
                    'options'   => Mage::getModel('core/website')->getCollection()->toOptionHash()
                ), 'status'
            );
        }

        return parent::_prepareColumns();
    }

    //########################################

    protected function getSelectedProductsCallback()
    {
        return <<<JS
(function() {
    return function(callback) {
        return callback && callback({$this->getId()}_massactionJsObject.checkedString)
    }
})()
JS;

    }

    //########################################
}
