Jump to content

Edit History

Janett

Janett

Hello,

It's easy to add a column with a little module.

Inside your modules folder, create a folder named "displayorderemployee" and a file named displayorderemployee.php and copy this inside.

After go to back office and install the module.

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}

class DisplayOrderEmployee extends Module
{
    public function __construct()
    {
        $this->name = 'displayorderemployee';
        $this->tab = 'administration';
        $this->version = '1.0.0';
        $this->author = 'Janett';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = [
            'min' => '1.6.1.0',
            'max' => '1.7.6.99',
        ];

        parent::__construct();

        $this->displayName = $this->l('Display employee on Orders list');
        $this->description = $this->l('Adds employee on Order list');
    }

    public function install()
    {
        return parent::install()
            && $this->registerHook('actionAdminOrdersListingFieldsModifier');
    }

    public function hookActionAdminOrdersListingFieldsModifier($params)
    {
        if (isset($params['select'])) {
            $params['select'] .= ', e.id_employee, CONCAT(LEFT(e.firstname, 1), \'. \', e.lastname) AS employee';
        }

        if (isset($params['join'])) {
            $params['join'] .= 'LEFT JOIN ' . _DB_PREFIX_ . 'order_history AS oh ON (a.id_order = oh.id_order AND a.current_state = oh.id_order_state)';
            $params['join'] .= 'LEFT JOIN ' . _DB_PREFIX_ . 'employee AS e ON (e.id_employee = oh.id_employee)';
        }

        $list = [];

        $employees = Employee::getEmployees();

        if (!empty($employees)) {
            foreach ($employees as $employee) {
                $list[(int) $employee['id_employee']] = substr($employee['firstname'], 0, 1) . ' ' . $employee['lastname'];
            }
        }

        $params['fields']['employee'] = [
            'title' => $this->l('Employee'),
            'filter_key' => 'e!id_employee',
            'order_key' => 'e!id_employee',
            'type' => 'select',
            'list' => $list,
        ];
    }
}

 

Janett

Janett

Hello,

It's easy to add a column with a little module.

Inside your modules folder, create a folder named "displayorderemployee" and a file named displayorderemployee.php and copy this inside.

After go to back office and install the module.

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}

class DisplayOrderEmployee extends Module
{
    public function __construct()
    {
        $this->name = 'displayorderemployee';
        $this->tab = 'administration';
        $this->version = '1.0.0';
        $this->author = 'Janett';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = [
            'min' => '1.6.1.0',
            'max' => '1.6.1.99',
        ];

        parent::__construct();

        $this->displayName = $this->l('Display employee on Orders list');
        $this->description = $this->l('Adds employee on Order list');
    }

    public function install()
    {
        return parent::install()
            && $this->registerHook('actionAdminOrdersListingFieldsModifier');
    }

    public function hookActionAdminOrdersListingFieldsModifier($params)
    {
        if (isset($params['select'])) {
            $params['select'] .= ', e.id_employee, CONCAT(LEFT(e.firstname, 1), \'. \', e.lastname) AS employee';
        }

        if (isset($params['join'])) {
            $params['join'] .= 'LEFT JOIN ' . _DB_PREFIX_ . 'order_history AS oh ON (a.id_order = oh.id_order AND a.current_state = oh.id_order_state)';
            $params['join'] .= 'LEFT JOIN ' . _DB_PREFIX_ . 'employee AS e ON (e.id_employee = oh.id_employee)';
        }

        $list = [];

        $employees = Employee::getEmployees();

        if (!empty($employees)) {
            foreach ($employees as $employee) {
                $list[(int) $employee['id_employee']] = substr($employee['firstname'], 0, 1) . ' ' . $employee['lastname'];
            }
        }

        $params['fields']['employee'] = [
            'title' => $this->l('Employee'),
            'filter_key' => 'e!id_employee',
            'order_key' => 'e!id_employee',
            'type' => 'select',
            'list' => $list,
        ];
    }
}

 

Janett

Janett

Hello,

It's easy to add a column with a little module.

Inside your modules folder, create a folder named "displayorderemployee" and a file named displayorderemployee.php and copy this inside

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}

class DisplayOrderEmployee extends Module
{
    public function __construct()
    {
        $this->name = 'displayorderemployee';
        $this->tab = 'administration';
        $this->version = '1.0.0';
        $this->author = 'Janett';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = [
            'min' => '1.6.1.0',
            'max' => '1.6.1.99',
        ];

        parent::__construct();

        $this->displayName = $this->l('Display employee on Orders list');
        $this->description = $this->l('Adds employee on Order list');
    }

    public function install()
    {
        return parent::install()
            && $this->registerHook('actionAdminOrdersListingFieldsModifier');
    }

    public function hookActionAdminOrdersListingFieldsModifier($params)
    {
        if (isset($params['select'])) {
            $params['select'] .= ', e.id_employee, CONCAT(LEFT(e.firstname, 1), \'. \', e.lastname) AS employee';
        }

        if (isset($params['join'])) {
            $params['join'] .= 'LEFT JOIN ' . _DB_PREFIX_ . 'order_history AS oh ON (a.id_order = oh.id_order AND a.current_state = oh.id_order_state)';
            $params['join'] .= 'LEFT JOIN ' . _DB_PREFIX_ . 'employee AS e ON (e.id_employee = oh.id_employee)';
        }

        $list = [];

        $employees = Employee::getEmployees();

        if (!empty($employees)) {
            foreach ($employees as $employee) {
                $list[(int) $employee['id_employee']] = substr($employee['firstname'], 0, 1) . ' ' . $employee['lastname'];
            }
        }

        $params['fields']['employee'] = [
            'title' => $this->l('Employee'),
            'filter_key' => 'e!id_employee',
            'order_key' => 'e!id_employee',
            'type' => 'select',
            'list' => $list,
        ];
    }
}

 

×
×
  • Create New...