[-] BO : fixed bug on Delivery slip generation in AdminDeliverySlip
This commit is contained in:
+7
-4
@@ -146,7 +146,7 @@ function generateDeliverySlipPDFByIdOrderInvoice($id_order_invoice)
|
||||
|
||||
function generateInvoicesPDF()
|
||||
{
|
||||
$order_invoice_collection = OrderInvoice::getByDateInterval($_GET['date_from'], $_GET['date_to'], NULL, 'invoice');
|
||||
$order_invoice_collection = OrderInvoice::getByDateInterval($_GET['date_from'], $_GET['date_to']);
|
||||
|
||||
if (!sizeof($order_invoice_collection))
|
||||
die(Tools::displayError('No invoices found'));
|
||||
@@ -182,9 +182,12 @@ function generateOrderSlipsPDF()
|
||||
|
||||
function generateDeliverySlipsPDF()
|
||||
{
|
||||
$slips = unserialize(urldecode($_GET['deliveryslips']));
|
||||
if (is_array($slips))
|
||||
generatePDF($slips, PDF::TEMPLATE_DELIVERY_SLIP);
|
||||
$order_invoice_collection = OrderInvoice::getByDeliveryDateInterval(Tools::getValue('date_from'), Tools::getValue('date_to'));
|
||||
|
||||
if (!sizeof($order_invoice_collection))
|
||||
die(Tools::displayError('No invoices found'));
|
||||
|
||||
generatePDF($order_invoice_collection, PDF::TEMPLATE_DELIVERY_SLIP);
|
||||
}
|
||||
|
||||
function generatePDF($object, $template)
|
||||
|
||||
+11
-11
@@ -851,17 +851,17 @@ class OrderCore extends ObjectModel
|
||||
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
|
||||
*/
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
|
||||
@@ -422,8 +422,8 @@ class OrderInvoiceCore extends ObjectModel
|
||||
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
|
||||
'.Context::getContext()->shop->addSqlRestriction().'
|
||||
ORDER BY oi.date_add ASC
|
||||
');
|
||||
|
||||
return ObjectModel::hydrateCollection('OrderInvoice', $order_invoice_list);
|
||||
@@ -455,6 +455,28 @@ class OrderInvoiceCore extends ObjectModel
|
||||
return ObjectModel::hydrateCollection('OrderInvoice', $order_invoice_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.5.0.3
|
||||
* @static
|
||||
* @param $date_from
|
||||
* @param $date_to
|
||||
* @return array collection of invoice
|
||||
*/
|
||||
public static function getByDeliveryDateInterval($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.delivery_date, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
|
||||
AND oi.date_add >= \''.pSQL($date_from).'\'
|
||||
'.Context::getContext()->shop->addSqlRestriction().'
|
||||
ORDER BY oi.delivery_date ASC
|
||||
');
|
||||
|
||||
return ObjectModel::hydrateCollection('OrderInvoice', $order_invoice_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.5
|
||||
* @static
|
||||
|
||||
@@ -108,9 +108,8 @@ class AdminDeliverySlipControllerCore extends AdminController
|
||||
$this->_errors[] = Tools::displayError('Invalid end date');
|
||||
if (!count($this->_errors))
|
||||
{
|
||||
$orders = Order::getOrdersIdByDate(Tools::getValue('date_from'), Tools::getValue('date_to'), null, 'delivery');
|
||||
if (count($orders))
|
||||
Tools::redirectAdmin('pdf.php?deliveryslips='.urlencode(serialize($orders)).'&token='.$this->token);
|
||||
if (count(OrderInvoice::getByDeliveryDateInterval(Tools::getValue('date_from'), Tools::getValue('date_to'))))
|
||||
Tools::redirectAdmin('pdf.php?deliveryslips&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('No delivery slip found for this period');
|
||||
}
|
||||
|
||||
@@ -217,9 +217,7 @@ class AdminInvoicesControllerCore extends AdminController
|
||||
|
||||
if (!count($this->_errors))
|
||||
{
|
||||
$order_invoice_list = OrderInvoice::getByDateInterval(Tools::getValue('date_from'), Tools::getValue('date_to'));
|
||||
|
||||
if (count($order_invoice_list))
|
||||
if (count(OrderInvoice::getByDateInterval(Tools::getValue('date_from'), Tools::getValue('date_to'))))
|
||||
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');
|
||||
@@ -232,7 +230,7 @@ class AdminInvoicesControllerCore extends AdminController
|
||||
else
|
||||
{
|
||||
foreach ($status_array as $id_order_state)
|
||||
if (count($orders = Order::getOrderIdsByStatus((int)$id_order_state)))
|
||||
if (count(OrderInvoice::getByStatus((int)$id_order_state)))
|
||||
Tools::redirectAdmin('pdf.php?invoices2&id_order_state='.implode('-', $status_array).'&token='.$this->token);
|
||||
|
||||
$this->_errors[] = $this->l('No invoice found for this status');
|
||||
|
||||
Reference in New Issue
Block a user