Jump to content

Add employee fields to bo orders or to order status


ru5hm3
 Share

Recommended Posts

Hello, i am using prestashop 1.6.1.23 and i am a newbie and i need some help.

I want to add a new field in bo at orders where it should be show who of the employees modifies the status of the order.
image.thumb.png.55c9a010625f450b748f514ba4156239.png

or if it possible to asign at status messages the employee who modifies the status of the order.   "delivery"  by "employee name"

image.png.df3faada628fccdf8d305ecf2eb9e4ff.png

is someone who have try this? and solve it?

Share this post


Link to post
Share on other sites

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,
        ];
    }
}

 

Edited by Janett (see edit history)
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

10 hours ago, Janett said:

Hello,

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

Inside your modules folder, create a folder named "displayo

thank you for help, i ll make a backup of the site and install it on a machine then i'll add the module, not going live directly, i ve tryed to modify AdminOrdersController.php"  inside override/controllers/admin and my website go down. from this post 

 

Share this post


Link to post
Share on other sites

7 minutes ago, KamikStudio said:

On 1.7.6.4 it doesn't work; /

Do you have more info ? What's doesn't work ?

I tested on 1.7.6.4 and it works well : a new column Employee is displayed on Order list

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More