Jump to content

Invoice per user group


lukasknol

Recommended Posts

Hi there,

 

I'm using Prestashop 1.6 witht the default theme. Presta has a nice option to select an invoice sorted on date (orders > invoices). The only thing is it shows all the products which are ordered. Is there a trick to select an invoice of products sorted on date and a user group? Does anyone knows a module for this?

 

post-788340-0-54256000-1401430409_thumb.jpg

Link to comment
Share on other sites

Hi,

 

when you are click "Generate PDF by date" OrderInvoice::getByDateInterval($date_from, $date_to) function executes with next SQL-query:

$order_invoice_list = Db::getInstance()->executeS('
	SELECT oi.*
	FROM `'._DB_PREFIX_.'order_invoice` oi
	LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
	WHERE DATE_ADD(oi.date_add, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
	AND oi.date_add >= \''.pSQL($date_from).'\'
	'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
	ORDER BY oi.date_add ASC
');

there is the new SQL-query with for example id_group=4:

$order_invoice_list = Db::getInstance()->executeS('
	SELECT oi.*
	FROM `'._DB_PREFIX_.'order_invoice` oi
	LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
    LEFT JOIN  `'._DB_PREFIX_.'customer_group` cg ON ( cg.`id_customer` = o.`id_customer` )
	WHERE DATE_ADD(oi.date_add, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
	AND oi.date_add >= \''.pSQL($date_from).'\'
	'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
    AND cg.`id_group` =4
	ORDER BY oi.date_add ASC
');

so you can temporary manual edit the file: classes/order/OrderInvoice.php for your purpose

 

Regards

Link to comment
Share on other sites

Thank you for the idea. It works but it isn't really what I am looking for. I need a more simple overview with the products orderd with the names of the clients (of a specific group). Is there a user friendly module which has the option to generate invoices by different user groups and time. The idea is to create an invoice for a company where employees order their product. At the end of the month the invoice goes to the company with an overview of orderd products by every employee.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

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...