Example #1
0
 /**
  * @var $_block Mage_Adminhtml_Block_Widget_Grid
  * @return $this
  * */
 public function appendCustomColumns($_observer)
 {
     $_block = $_observer->getBlock();
     if (!isset($_block)) {
         return $this;
     }
     if ($_block->getType() == 'adminhtml/catalog_product_grid') {
         if (!Mage::helper('payperrentals/config')->hideBookedInventoryInGrid(Mage_Core_Model_App::ADMIN_STORE_ID)) {
             /** @var $_block ITwebexperts_Payperrentals_Block_Adminhtml_Catalog_Product_Grid */
             $_block->addColumnAfter('booked_qty', array('header' => Mage::helper('payperrentals')->__('Booked'), 'index' => 'entity_id', 'width' => '60px', 'align' => 'right', 'type' => 'number', 'renderer' => 'payperrentals/adminhtml_catalog_product_renderer_booked', 'sortable' => false, 'filter' => false), 'qty');
             $after = 'booked_qty';
             if (ITwebexperts_Payperrentals_Helper_Data::isMaintenanceInstalled()) {
                 $_block->addColumnAfter('maintenance_qty', array('header' => Mage::helper('payperrentals')->__('Maintenance'), 'index' => 'entity_id', 'align' => 'right', 'width' => '70px', 'type' => 'number', 'renderer' => 'ITwebexperts_Maintenance_Block_Adminhtml_Catalog_Product_Renderer_Maintenance', 'sortable' => false, 'filter' => false), 'booked_qty');
                 $after = 'maintenance_qty';
             }
             $_block->addColumnAfter('available_inventory', array('header' => Mage::helper('payperrentals')->__('Available'), 'index' => 'entity_id', 'width' => '60px', 'type' => 'number', 'align' => 'right', 'sortable' => false, 'filter' => false, 'renderer' => 'payperrentals/adminhtml_catalog_product_renderer_available'), $after);
             if (Mage::helper('payperrentals/config')->showSerialsColumn()) {
                 $_block->addColumnAfter('serials', array('header' => Mage::helper('payperrentals')->__('Serials'), 'index' => 'entity_id', 'width' => '60px', 'type' => 'text', 'align' => 'left', 'filter_condition_callback' => array($this, 'filterCallbackSerials'), 'renderer' => 'payperrentals/adminhtml_catalog_product_renderer_serials'), 'available_inventory');
             }
         }
         Mage::register('is_product_grid', true);
     }
     /** Changed to preg_match so vendor module also matches the pattern */
     $blocktype = $_block->getType();
     if (preg_match('/.*sales_order_grid$/', $blocktype) || preg_match('/.*sales_invoice_grid$/', $blocktype) || preg_match('/.*sales_shipment_grid$/', $blocktype) || preg_match('/.*sales_creditmemo_grid$/', $blocktype)) {
         if (!Mage::helper('payperrentals/config')->isNonSequentialSelect(Mage::app()->getStore()->getId())) {
             if (preg_match('/.*sales_order_grid$/', $blocktype)) {
                 /** @var $_block Mage_Adminhtml_Block_Sales_Order_Grid */
                 $_block->addColumnAfter('sfo_start_datetime', array('header' => Mage::helper('payperrentals')->__('Start Date'), 'index' => 'start_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'main_table.start_datetime'), 'shipping_name');
                 $_block->addColumnAfter('sfo_end_datetime', array('header' => Mage::helper('payperrentals')->__('End Date'), 'index' => 'end_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'main_table.end_datetime'), 'sfo_start_datetime');
             } else {
                 /** @var $_block Mage_Adminhtml_Block_Sales_Order_Grid */
                 if (preg_match('/.*adminhtml\\/sales_invoice_grid$/', $blocktype)) {
                     $_block->addColumnAfter('sfo_incr_id', array('header' => Mage::helper('payperrentals')->__('Invoice #'), 'width' => '160px', 'type' => 'text', 'index' => 'incr_id', 'filter_condition_callback' => array($this, 'filterCallbackIncrement')), 'massaction');
                 }
                 if (preg_match('/.*adminhtml\\/sales_shipment_grid$/', $blocktype)) {
                     $_block->addColumnAfter('start_datetime', array('header' => Mage::helper('payperrentals')->__('Start Date'), 'index' => 'sstart_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'sfow.start_datetime'), 'billing_name');
                     $_block->addColumnAfter('sfo_end_datetime', array('header' => Mage::helper('payperrentals')->__('End Date'), 'index' => 'send_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'sfow.end_datetime'), 'sfo_start_datetime');
                 } else {
                     $_block->addColumnAfter('start_datetime', array('header' => Mage::helper('payperrentals')->__('Start Date'), 'index' => 'start_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'sfo.start_datetime'), 'billing_name');
                     $_block->addColumnAfter('sfo_end_datetime', array('header' => Mage::helper('payperrentals')->__('End Date'), 'index' => 'end_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'sfo.end_datetime'), 'sfo_start_datetime');
                 }
                 $_block->sortColumnsByOrder();
             }
             if (!preg_match('/.*sales_invoice_grid$/', $blocktype) && !preg_match('/.*sales_shipment_grid$/', $blocktype)) {
                 $_block->addColumnAfter('shipping_state', array('header' => Mage::helper('payperrentals')->__('Shipping'), 'index' => 'total_qty_shipped', 'renderer' => $this->getShippingRenderer(), 'width' => '120px', 'type' => 'options', 'options' => Mage::getSingleton('payperrentals/sendreturn')->_getShippingStates(), 'sortable' => false, 'filter' => false), 'status');
                 $_block->addColumnAfter('return_state', array('header' => Mage::helper('payperrentals')->__('Return'), 'index' => 'total_qty_returned', 'renderer' => $this->getReturnRenderer(), 'width' => '120px', 'type' => 'options', 'options' => Mage::getSingleton('payperrentals/sendreturn')->_getReturnStates(), 'sortable' => false, 'filter' => false), 'shipping_state');
             }
         } else {
             if (!Mage::helper('payperrentals/config')->isNonSequentialSelect(Mage::app()->getStore()->getId())) {
                 if (preg_match('/.*sales_order_grid$/', $blocktype)) {
                     $_block->addColumnAfter('sfo_start_datetime', array('header' => Mage::helper('payperrentals')->__('Start Date'), 'index' => 'start_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'main_table.start_datetime'), 'shipping_name');
                     $_block->addColumnAfter('sfo_end_datetime', array('header' => Mage::helper('payperrentals')->__('End Date'), 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'index' => 'end_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'main_table.end_datetime'), 'sfo_start_datetime');
                     $_block->addColumnAfter('shipping_state', array('header' => Mage::helper('payperrentals')->__('Shipping'), 'index' => 'total_qty_shipped', 'renderer' => 'payperrentals/adminhtml_grid_column_renderer_shippingState', 'width' => '120px', 'type' => 'options', 'options' => Mage::getSingleton('payperrentals/sendreturn')->_getShippingStates(), 'sortable' => false, 'filter' => false), 'status');
                     $_block->addColumnAfter('return_state', array('header' => Mage::helper('payperrentals')->__('Return'), 'index' => 'total_qty_returned', 'renderer' => 'payperrentals/adminhtml_grid_column_renderer_returnState', 'width' => '120px', 'type' => 'options', 'options' => Mage::getSingleton('payperrentals/sendreturn')->_getReturnStates(), 'sortable' => false, 'filter' => false), 'shipping_state');
                 } else {
                     $_block->addColumnAfter('sfo_start_datetime', array('header' => Mage::helper('payperrentals')->__('Start Date'), 'index' => 'start_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'sfo.start_datetime'), 'shipping_name');
                     $_block->addColumnAfter('sfo_end_datetime', array('header' => Mage::helper('payperrentals')->__('End Date'), 'index' => 'end_datetime', 'renderer' => 'payperrentals/adminhtml_html_renderer_datetime', 'filter' => 'payperrentals/adminhtml_widget_grid_column_filter_datetimeppr', 'width' => '120px', 'type' => 'datetime', 'filter_index' => 'sfo.end_datetime'), 'sfo_start_datetime');
                 }
             } else {
                 $_block->addColumnAfter('sfo_dates', array('header' => Mage::helper('payperrentals')->__('Dates'), 'index' => 'entity_id', 'renderer' => 'payperrentals/adminhtml_html_renderer_dates', 'width' => '120px', 'type' => 'datetime', 'filter_condition_callback' => array($this, 'filterCallbackDates')), 'shipping_name');
             }
         }
     }
     return $this;
 }