// OrderInvoice PDF compliant
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10830 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+15
-10
@@ -116,15 +116,12 @@ function generateDeliverySlipPDF()
|
|||||||
|
|
||||||
function generateInvoicesPDF()
|
function generateInvoicesPDF()
|
||||||
{
|
{
|
||||||
$id_orders_list = Order::getOrdersIdInvoiceByDate($_GET['date_from'], $_GET['date_to'], NULL, 'invoice');
|
$id_orders_list = OrderInvoice::getByDateInterval($_GET['date_from'], $_GET['date_to'], NULL, 'invoice');
|
||||||
|
|
||||||
if (!is_array($id_orders_list))
|
if (!is_array($id_orders_list))
|
||||||
die (Tools::displayError('No invoices found'));
|
die (Tools::displayError('No invoices found'));
|
||||||
|
|
||||||
$orders = array();
|
generateOrderInvoicesPDF($id_orders_list);
|
||||||
foreach ($id_orders_list as $id_order)
|
|
||||||
$orders[] = new Order((int)$id_order);
|
|
||||||
|
|
||||||
generatePDF($orders, PDF::TEMPLATE_INVOICE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateInvoicesPDF2()
|
function generateInvoicesPDF2()
|
||||||
@@ -134,11 +131,19 @@ function generateInvoicesPDF2()
|
|||||||
if (is_array($id_orders = Order::getOrderIdsByStatus((int)$id_order_state)))
|
if (is_array($id_orders = Order::getOrderIdsByStatus((int)$id_order_state)))
|
||||||
$id_orders_list = array_merge($id_orders_list, $id_orders);
|
$id_orders_list = array_merge($id_orders_list, $id_orders);
|
||||||
|
|
||||||
$orders = array();
|
generateOrderInvoicesPDF($id_orders_list);
|
||||||
foreach ($id_orders_list as $id_order)
|
}
|
||||||
$orders[] = new Order((int)$id_order);
|
|
||||||
|
|
||||||
generatePDF($orders, PDF::TEMPLATE_INVOICE);
|
function generateOrderInvoicesPDF($id_orders_list)
|
||||||
|
{
|
||||||
|
$orders_invoices = array();
|
||||||
|
foreach ($id_orders_list as $id_order)
|
||||||
|
{
|
||||||
|
$order = new Order((int)$id_order);
|
||||||
|
$orders_invoices = array_merge($orders_invoices, $order->getInvoicesCollection());
|
||||||
|
}
|
||||||
|
|
||||||
|
generatePDF($orders_invoices, PDF::TEMPLATE_INVOICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateOrderSlipsPDF()
|
function generateOrderSlipsPDF()
|
||||||
|
|||||||
@@ -826,8 +826,20 @@ class OrderCore extends ObjectModel
|
|||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since 1.5.0.2
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @param $date_from
|
||||||
|
* @param $date_to
|
||||||
|
* @param $id_customer
|
||||||
|
* @param $type
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public static function getOrdersIdInvoiceByDate($date_from, $date_to, $id_customer = NULL, $type = NULL)
|
public static function getOrdersIdInvoiceByDate($date_from, $date_to, $id_customer = NULL, $type = NULL)
|
||||||
{
|
{
|
||||||
|
Tools::displayAsDeprecated();
|
||||||
$sql = 'SELECT `id_order`
|
$sql = 'SELECT `id_order`
|
||||||
FROM `'._DB_PREFIX_.'orders`
|
FROM `'._DB_PREFIX_.'orders`
|
||||||
WHERE DATE_ADD(invoice_date, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\' AND invoice_date >= \''.pSQL($date_from).'\'
|
WHERE DATE_ADD(invoice_date, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\' AND invoice_date >= \''.pSQL($date_from).'\'
|
||||||
|
|||||||
@@ -384,4 +384,26 @@ class OrderInvoiceCore extends ObjectModel
|
|||||||
AND `id_order_invoice` = '.(int)$this->id
|
AND `id_order_invoice` = '.(int)$this->id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all the order invoice that match the date interval
|
||||||
|
*
|
||||||
|
* @since 1.5.0.2
|
||||||
|
* @static
|
||||||
|
* @param $date_from
|
||||||
|
* @param $date_to
|
||||||
|
* @return array collection of OrderInvoice
|
||||||
|
*/
|
||||||
|
public static function getByDateInterval($date_from, $date_to)
|
||||||
|
{
|
||||||
|
$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).'\'
|
||||||
|
'.Context::getContext()->shop->addSqlRestriction().
|
||||||
|
' ORDER BY oi.date_add ASC');
|
||||||
|
|
||||||
|
return ObjectModel::hydrateCollection('OrderInvoice', $order_invoice_list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -147,11 +147,12 @@ class AdminInvoicesControllerCore extends AdminController
|
|||||||
SELECT COUNT(*) as nbOrders, (
|
SELECT COUNT(*) as nbOrders, (
|
||||||
SELECT oh.id_order_state
|
SELECT oh.id_order_state
|
||||||
FROM '._DB_PREFIX_.'order_history oh
|
FROM '._DB_PREFIX_.'order_history oh
|
||||||
WHERE oh.id_order = o.id_order
|
WHERE oh.id_order = oi.id_order
|
||||||
ORDER BY oh.date_add DESC, oh.id_order_history DESC
|
ORDER BY oh.date_add DESC, oh.id_order_history DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
) id_order_state
|
) id_order_state
|
||||||
FROM '._DB_PREFIX_.'orders o
|
FROM '._DB_PREFIX_.'order_invoice oi
|
||||||
|
LEFT JOIN '._DB_PREFIX_.'orders o ON (oi.id_order = o.id_order)
|
||||||
WHERE o.id_shop IN('.implode(', ', $this->context->shop->getListOfID()).')
|
WHERE o.id_shop IN('.implode(', ', $this->context->shop->getListOfID()).')
|
||||||
GROUP BY id_order_state
|
GROUP BY id_order_state
|
||||||
');
|
');
|
||||||
@@ -204,13 +205,17 @@ class AdminInvoicesControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
if (!Validate::isDate(Tools::getValue('date_from')))
|
if (!Validate::isDate(Tools::getValue('date_from')))
|
||||||
$this->_errors[] = $this->l('Invalid from date');
|
$this->_errors[] = $this->l('Invalid from date');
|
||||||
|
|
||||||
if (!Validate::isDate(Tools::getValue('date_to')))
|
if (!Validate::isDate(Tools::getValue('date_to')))
|
||||||
$this->_errors[] = $this->l('Invalid end date');
|
$this->_errors[] = $this->l('Invalid end date');
|
||||||
|
|
||||||
if (!count($this->_errors))
|
if (!count($this->_errors))
|
||||||
{
|
{
|
||||||
$orders = Order::getOrdersIdInvoiceByDate(Tools::getValue('date_from'), Tools::getValue('date_to'), null, 'invoice');
|
$order_invoice_list = OrderInvoice::getByDateInterval(Tools::getValue('date_from'), Tools::getValue('date_to'));
|
||||||
if (count($orders))
|
|
||||||
|
if (count($order_invoice_list))
|
||||||
Tools::redirectAdmin('pdf.php?invoices&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
|
Tools::redirectAdmin('pdf.php?invoices&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
|
||||||
|
|
||||||
$this->_errors[] = $this->l('No invoice found for this period');
|
$this->_errors[] = $this->l('No invoice found for this period');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,6 +228,7 @@ class AdminInvoicesControllerCore extends AdminController
|
|||||||
foreach ($status_array as $id_order_state)
|
foreach ($status_array as $id_order_state)
|
||||||
if (count($orders = Order::getOrderIdsByStatus((int)$id_order_state)))
|
if (count($orders = Order::getOrderIdsByStatus((int)$id_order_state)))
|
||||||
Tools::redirectAdmin('pdf.php?invoices2&id_order_state='.implode('-', $status_array).'&token='.$this->token);
|
Tools::redirectAdmin('pdf.php?invoices2&id_order_state='.implode('-', $status_array).'&token='.$this->token);
|
||||||
|
|
||||||
$this->_errors[] = $this->l('No invoice found for this status');
|
$this->_errors[] = $this->l('No invoice found for this status');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user