Jump to content

How to add the column with invoice number to the product list in BO?


ShopMann

Recommended Posts

Hi,

who had any idea how to add the column with invoice number to the product list in BO of Prestashop 1.7?

I use the Prestashop 1.7.2.4 but the solution would fit all versions 1.7 and even 1.6.

I was trying this with an overrides in /override/controllers/admin/AdminOrdersController.php.

But this add the column with invoice IDs instead of invoice numbers:

index.thumb.png.a844c19877ec98284f925c7d40d00c67.png

Here the overrides code that I added:

<?php
class AdminOrdersController extends AdminOrdersControllerCore
{
    public function __construct()  
    {
        parent::__construct();
      
        $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')
            ),
            'invoice_number' => array(
                'title' => $this->trans('Invoice', array(), 'Admin.Global'),
                'align' => 'text-center',
                'class' => 'fixed-width-xs'
            ),
            '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,
            ),	
        );

        $this->fields_list = array_merge($this->fields_list, array(
            'total_paid_tax_incl' => array(
                'title' => $this->trans('Total', array(), 'Admin.Global'),
                'align' => 'text-right',
                'type' => 'price',
                'currency' => true,
                'callback' => 'setOrderCurrency',
                'badge_success' => true
            ),
            'payment' => array(
                'title' => $this->trans('Payment', array(), 'Admin.Global')
            ),
            'osname' => array(
                'title' => $this->trans('Status', array(), 'Admin.Global'),
                'type' => 'select',
                'color' => 'color',
                'list' => $this->statuses_array,
                'filter_key' => 'os!id_order_state',
                'filter_type' => 'int',
                'order_key' => 'osname'
            ),
            'date_add' => array(
                'title' => $this->trans('Order Date', array(), 'Admin.Global'),
                'align' => 'text-right',
                'type' => 'datetime',
                'filter_key' => 'a!date_add'
            ),
            'invoice_date' => array(
                'title' => $this->trans('Invoice Date', array(), 'Admin.Global'),
                'align' => 'text-right',
                'type' => 'datetime',
                'filter_key' => 'a!invoice_date'
            ),			
            'id_pdf' => array(
                'title' => $this->trans('PDF', array(), 'Admin.Global'),
                'align' => 'text-center',
                'callback' => 'printPDFIcons',
                'orderby' => false,
                'search' => false,
                'remove_onclick' => true
            )
        ));

        if (Country::isCurrentlyUsed('country', true)) {
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
			SELECT DISTINCT c.id_country, cl.`name`
			FROM `'._DB_PREFIX_.'orders` o
			'.Shop::addSqlAssociation('orders', 'o').'
			INNER JOIN `'._DB_PREFIX_.'address` a ON a.id_address = o.id_address_delivery
			INNER JOIN `'._DB_PREFIX_.'country` c ON a.id_country = c.id_country
			INNER JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.')
			ORDER BY cl.name ASC');

            $country_array = array();
            foreach ($result as $row) {
                $country_array[$row['id_country']] = $row['name'];
            }

            $part1 = array_slice($this->fields_list, 0, 3);
            $part2 = array_slice($this->fields_list, 3);
            $part1['cname'] = array(
                'title' => $this->trans('Delivery', array(), 'Admin.Global'),
                'type' => 'select',
                'list' => $country_array,
                'filter_key' => 'country!id_country',
                'filter_type' => 'int',
                'order_key' => 'cname'
            );
            $this->fields_list = array_merge($part1, $part2);
        }

        $this->shopLinkType = 'shop';
        $this->shopShareDatas = Shop::SHARE_ORDER;

        if (Tools::isSubmit('id_order')) {
            // Save context (in order to apply cart rule)
            $order = new Order((int)Tools::getValue('id_order'));
            $this->context->cart = new Cart($order->id_cart);
            $this->context->customer = new Customer($order->id_customer);
        }

        $this->bulk_actions = array(
            'updateOrderStatus' => array('text' => $this->trans('Change Order Status', array(), 'Admin.Orderscustomers.Feature'), 'icon' => 'icon-refresh')
        );
		
    }
}

Explicit for the invoice I intended this lines:

            'invoice_number' => array(
                'title' => $this->trans('Invoice', array(), 'Admin.Global'),
                'align' => 'text-center',
                'class' => 'fixed-width-xs'
            ),

Unfortunately, this script displays the invoice ID instead of invoice numbers such as i.e. INV-2018-00012.

I don't not if this is important but I must say that i use in my shop this module:

https://addons.prestashop.com/en/ac...e-number-order-number-multistore-editing.html
I see that it created the ps_customnumber_document table, in which the account numbers are recorded since the last reset of the counter, that is, since January 1, 2019:

upload_2019-1-20_3-12-52.png

upload_2019-1-20_3-0-30.png

The previous numbers (by type R-2018-00001 and so on) in the list of orders (documents) are reflected, but again there is no trace of them in the database.
It is completely incomprehensible how to extract all this and insert it into the order page instead of the order ID.

But I don’t think that this module affects the search for a solution to the problem.

After all, this module is installed or not - it is still the above described override add the numbers with the invoice IDs instead of the invoice.

Who can tell me how I can add the column with invoice numbers?

index.thumb.png.a844c19877ec98284f925c7d40d00c67.png

Thank you in advance for any help.

Edited by Viaceslav (see edit history)
  • Like 1
Link to comment
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
×
×
  • Create New...