[-] BO : fixed bug on Invoice generation in AdminInvoices

This commit is contained in:
aFolletete
2012-01-02 17:30:11 +00:00
parent fca37421ac
commit 8923947406
6 changed files with 73 additions and 49 deletions
+8
View File
@@ -880,8 +880,16 @@ class OrderCore extends ObjectModel
return $orders;
}
/**
* @deprecated 1.5.0.3
*
* @static
* @param $id_order_state
* @return array
*/
public static function getOrderIdsByStatus($id_order_state)
{
Tools::displayAsDeprecated();
$sql = 'SELECT id_order
FROM '._DB_PREFIX_.'orders o
WHERE '.(int)$id_order_state.' = (
+26
View File
@@ -429,6 +429,32 @@ class OrderInvoiceCore extends ObjectModel
return ObjectModel::hydrateCollection('OrderInvoice', $order_invoice_list);
}
/**
* @since 1.5.0.3
* @static
* @param $id_order_state
* @return array collection of OrderInvoice
*/
public static function getByStatus($id_order_state)
{
$order_invoice_list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT oi.*
FROM `'._DB_PREFIX_.'order_invoice` oi
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
WHERE '.(int)$id_order_state.' = (
SELECT id_order_state
FROM '._DB_PREFIX_.'order_history oh
WHERE oh.id_order = o.id_order
ORDER BY date_add DESC, id_order_history DESC
LIMIT 1
)
'.Context::getContext()->shop->addSqlRestriction(false, 'o').'
ORDER BY oi.`date_add` ASC
');
return ObjectModel::hydrateCollection('OrderInvoice', $order_invoice_list);
}
/**
* @since 1.5
* @static
+18 -18
View File
@@ -32,14 +32,14 @@ class PDFCore
{
public $filename;
public $pdf_renderer;
public $objects;
public $template;
public $objects;
public $template;
const TEMPLATE_INVOICE = 'Invoice';
const TEMPLATE_ORDER_RETURN = 'OrderReturn';
const TEMPLATE_ORDER_SLIP = 'OrderSlip';
const TEMPLATE_DELIVERY_SLIP = 'DeliverySlip';
const TEMPLATE_SUPPLY_ORDER_FORM = 'SupplyOrderForm';
const TEMPLATE_INVOICE = 'Invoice';
const TEMPLATE_ORDER_RETURN = 'OrderReturn';
const TEMPLATE_ORDER_SLIP = 'OrderSlip';
const TEMPLATE_DELIVERY_SLIP = 'DeliverySlip';
const TEMPLATE_SUPPLY_ORDER_FORM = 'SupplyOrderForm';
public function __construct($objects, $template, $smarty)
{
@@ -48,26 +48,26 @@ class PDFCore
$this->smarty = $smarty;
$this->objects = $objects;
if (!($objects instanceof Iterator))
if (!($objects instanceof Iterator) && !is_array($objects))
$this->objects = array($objects);
}
public function render($display = true)
{
$render = false;
$render = false;
$this->pdf_renderer->setFontForLang('fr');
foreach ($this->objects as $object)
{
$template = $this->getTemplateObject($object);
if (!$template)
continue;
$template = $this->getTemplateObject($object);
if (!$template)
continue;
if (empty($this->filename))
{
$this->filename = $template->getFilename();
if (count($this->objects) > 1)
$this->filename = $template->getBulkFilename();
}
if (empty($this->filename))
{
$this->filename = $template->getFilename();
if (count($this->objects) > 1)
$this->filename = $template->getBulkFilename();
}
$template->assignHookData($object);