Showing posts with label Extensions. Show all posts
Showing posts with label Extensions. Show all posts

Friday 9 February 2018

How to add / create grid Tab in custom module in magento admin panel

Step1 :
open : /app/code/local/Namespace/Modulename/Block/Adminhtml/Employee/Edit/Tabs.php
Add following lines

protected function _beforeToHtml()
{
.........
.........
.........
$this->addTab(
    'form_advancepayment',
    array(
'label'   => Mage::helper('namespace_modulename')->__('Advance Payment'),
'title'   => Mage::helper('namespace_modulename')->__('Advance Payment'),
'content' => $this->getLayout()->createBlock(
    'namespace_modulename/adminhtml_employee_edit_tab_advancepayment'
)
->toHtml(),
    )
);
return parent::_beforeToHtml();
}
Step2 :
Create new file (Advancepayment.php) : /app/code/local/Namespace/Modulename/Block/Adminhtml/Employee/Edit/Tab/Advancepayment.php
<?php
class Namespace_Modulename_Block_Adminhtml_Employee_Edit_Tab_Advancepayment extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('advancepymt_grid');
        $this->setDefaultSort('entity_id');
        $this->setDefaultDir('DESC');
        $this->setSaveParametersInSession(true);
        $this->setUseAjax(true);
        //$this->setFilterVisibility(false);
    }
   
    protected function _prepareCollection()
    {
        $id = $this->getRequest()->getParam('id');
        $collection = Mage::getModel('namespace_modulename/advancepymt')
            ->getCollection()
            ->addFieldToFilter('employee_id', $id);
       
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }
   
    protected function _prepareColumns()
    {
        $this->addColumn(
            'entity_id',
            array(
                'header' => Mage::helper('namespace_modulename')->__('Id'),
                'index'  => 'entity_id',
                'filter' => false,
                'type'   => 'number'
            )
        );
        $this->addColumn(
            'payment',
            array(
                'header'    => Mage::helper('namespace_modulename')->__('Payment'),
                'align'     => 'left',
                'type'   => 'number',
                'index'     => 'payment',
            )
        );
       
        $this->addColumn(
            'created_at',
            array(
                'header' => Mage::helper('namespace_modulename')->__('Created at'),
                'index'  => 'created_at',
                'width'  => '120px',
                'type'   => 'datetime',
            )
        );
        return parent::_prepareColumns();
    }
   
    public function getGridUrl()
    {
        return $this->getUrl('*/*/advancepymt', array('_current'=>true));
    }
   
    public function getRowUrl($row)
    {
        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }
Step3 :
Create function in current controller : /app/code/local/Namespace/Modulename/controllers/Adminhtml/Payroll/EmployeeController.php
class Namespace_Modulename_Adminhtml_Payroll_EmployeeController extends Namespace_Modulename_Controller_Adminhtml_Payroll
{
.............
.............
.............
public function advancepymtAction() {
        $this->loadLayout();
        $this->getLayout()->getBlock('edit.tab.advancepayment');
        $this->renderLayout(); 
    }
Step4 :
Add view in admin layout xml file : /app/design/adminhtml/default/default/layout/namespace_modulename.xml
Add following code into file

...........
...........
<adminhtml_modulename_employee_advancepymt>
<block type="core/text_list" name="root" output="toHtml">
    <block type="namespace_modulename/adminhtml_employee_edit_tab_advancepayment" name="edit.tab.advancepayment"/>
</block>
</adminhtml_modulename_employee_advancepymt>
...........
........... 

Tuesday 2 January 2018

How to install extensions in php 7 cent os


Install extensions in php 7 cent os follow these steps

1. curl 'https://setup.ius.io/' -o setup-ius.sh
2. sudo bash setup-ius.sh
3. sudo yum install -y mod_php70w php70w-cli php70w-mysqlnd php70w-json php70w-gd php70w-dom php70w-simplexml php70w-mcrypt php70w-intl httpd mysql-server git