Kami Solutions Posted June 21, 2020 Share Posted June 21, 2020 (edited) Hi, I've been looking for a way to show the employee that modified an order in the orders page and filter it but without success, anyone can help? UPDATE: I've managed to join the employee but now i have duplicated orders with different status since the employee is obtained from ps_order_history, how can I get the latest update from date_add? I've been thinking of just doing a MAX(date_add) but I'm not pretty sure where to put it... Here is my code modification (PrestaShopFolder/controllers/admin/AdminOrdersController.php) $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(c.`firstname`, \' \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, CONCAT(e.`firstname`, \' \', e.`lastname`) AS `employee`, IF((SELECT so.id_order FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = a.id_customer AND so.id_order < a.id_order LIMIT 1) > 0, 0, 1) as new, country_lang.name as cname, IF(a.valid, 1, 0) badge_success'; $this->_join = ' LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON (c.`id_customer` = a.`id_customer`) INNER JOIN `' . _DB_PREFIX_ . 'address` address ON address.id_address = a.id_address_delivery INNER JOIN `' . _DB_PREFIX_ . 'country` country ON address.id_country = country.id_country INNER JOIN `' . _DB_PREFIX_ . 'country_lang` country_lang ON (country.`id_country` = country_lang.`id_country` AND country_lang.`id_lang` = ' . (int) $this->context->language->id . ') LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `' . _DB_PREFIX_ . 'order_history` oh ON (oh.`id_order` = a.`id_order`) LEFT JOIN `' . _DB_PREFIX_ . 'employee` e ON (e.`id_employee` = oh.`id_employee`) LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = ' . (int) $this->context->language->id . ')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; $this->_use_found_rows = true; $statuses = OrderState::getOrderStates((int) $this->context->language->id); foreach ($statuses as $status) { $this->statuses_array[$status['id_order_state']] = $status['name']; } $this->fields_list = array( 'id_order' => array( 'title' => $this->trans('ID', array(), 'Admin.Global'), 'align' => 'text-center', 'class' => 'fixed-width-xs', ), 'reference' => array( 'title' => $this->trans('Reference', array(), 'Admin.Global'), ), 'new' => array( 'title' => $this->trans('New client', array(), 'Admin.Orderscustomers.Feature'), 'align' => 'text-center', 'type' => 'bool', 'tmpTableFilter' => true, 'orderby' => false, ), 'customer' => array( 'title' => $this->trans('Customer', array(), 'Admin.Global'), 'havingFilter' => true, ), 'employee' => array( 'title' => $this->trans('Employee', array(), 'Admin.Global'), 'havingFilter' => true, ), ); As you can see, first I select the name and surname of the employee. CONCAT(e.`firstname`, \' \', e.`lastname`) AS `employee`, Then I join the tables ps_order_history, ps_employee and ps_orders LEFT JOIN `' . _DB_PREFIX_ . 'order_history` oh ON (oh.`id_order` = a.`id_order`) LEFT JOIN `' . _DB_PREFIX_ . 'employee` e ON (e.`id_employee` = oh.`id_employee`) Finally I show it like a customer to be able to filter the orders created by an employee 'employee' => array( 'title' => $this->trans('Employee', array(), 'Admin.Global'), 'havingFilter' => true, ), But how can I get the latest order updates??? Regards Edited June 21, 2020 by centrobolsos (see edit history) Link to comment Share on other sites More sharing options...
Kami Solutions Posted June 23, 2020 Author Share Posted June 23, 2020 47 minutes ago, ndiaga said: Hi, You have these informations in BO> Advanced Parameters > Logs . Hi, I don't think that checking logs in order to know what employee made an order, that's not the way to work, don't you think? The think is that I need to use the MAX or MIN function here and I don't know where to put the condition. Regards Link to comment Share on other sites More sharing options...
Kami Solutions Posted June 23, 2020 Author Share Posted June 23, 2020 10 minutes ago, ndiaga said: Are you not looking for employee activities in your shop? Not really, what I'm looking with this is to check the orders, see what employees prepared an order or created an order by hand, and filter out the sales from an employee, for instance Link to comment Share on other sites More sharing options...
Kami Solutions Posted June 23, 2020 Author Share Posted June 23, 2020 1 minute ago, ndiaga said: Ok, I see what you are trying to do. You can easily build a module for that. Also if you need rewards system for your employees this module can be usefull : Thanks for the approach of the module but it's not really my final goal, I just want to trace orders and see what employees are doing the mistakes and etc. Link to comment Share on other sites More sharing options...
Kami Solutions Posted June 23, 2020 Author Share Posted June 23, 2020 3 minutes ago, ndiaga said: Yes you can do that with a module. Modify the Admin Order is not the best approach. I was trying to create the fix first and then use an override to do it. I think using modules for modifications to the core is the way to go, but I don't think it's necessary to create a module just to do little modifications like this one. How can I do it with a module? Link to comment Share on other sites More sharing options...
HAKO Posted January 10, 2021 Share Posted January 10, 2021 On 6/23/2020 at 6:43 PM, ChineseNorris said: I was trying to create the fix first and then use an override to do it. I think using modules for modifications to the core is the way to go, but I don't think it's necessary to create a module just to do little modifications like this one. How can I do it with a module? Have you find a solution for your issue ? I also need the same information about my employees. BR Patrick Link to comment Share on other sites More sharing options...
ru5hm3 Posted May 5, 2021 Share Posted May 5, 2021 On 6/23/2020 at 7:19 PM, ChineseNorris said: Not really, what I'm looking with this is to check the orders, see what employees prepared an order or created an order by hand, and filter out the sales from an employee, for instance did you implement this finally??? Link to comment Share on other sites More sharing options...
Kami Solutions Posted May 6, 2021 Author Share Posted May 6, 2021 23 hours ago, ru5hm3 said: did you implement this finally??? No, I just stopped the development because I don't have time but it's on my TO-DO list Link to comment Share on other sites More sharing options...
ru5hm3 Posted May 7, 2021 Share Posted May 7, 2021 21 hours ago, ChineseNorris said: No, I just stopped the development because I don't have time but it's on my TO-DO list you can find here a solution - Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now