Merge branch 'ticket-8251' into develop

This commit is contained in:
Marion Muszynski 2016-06-10 11:42:32 +02:00
commit 9b9e586d0f
3 changed files with 73 additions and 7 deletions

View File

@ -44,6 +44,7 @@ $functionArray = array(
'deliveryslips' => 'generateDeliverySlipsPDF',
'privatesales' => 'generateInvoicesPDFPrivateSales',
'privatesales48h' => 'generateInvoicesPDFPrivateSales48h',
'privatesales48hbis' => 'generateInvoicesPDFPrivateSales48hBis',
'privatesales2' => 'generateInvoicesPDFPrivateSales2',
'privatesalesM2' => 'generateInvoicesPDFPrivateMulti',
'privatesalesM2Bis' => 'generateInvoicesPDFPrivateM2Bis',
@ -112,6 +113,21 @@ function generateInvoicesPDFPrivateSales()
}
function generateInvoicesPDFPrivateSales48h()
{
if(Module::isInstalled('privatesales')) {
include(dirname(__FILE__).'/../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSale($statuts, FALSE, TRUE);
if(count($orders) == 0) {
die (Tools::displayError('No invoices found'));
}
PDF::multipleInvoices($orders, false, true, true);
}
}
}
function generateInvoicesPDFPrivateSales48hBis()
{
if(Module::isInstalled('privatesales')) {
include(dirname(__FILE__).'/../modules/privatesales/Sale.php');
@ -122,7 +138,7 @@ function generateInvoicesPDFPrivateSales48h()
die (Tools::displayError('No invoices found'));
}
$orders2 = $sale->getOrdersFromSale($statuts, FALSE, TRUE);
$orders2 = $sale->getOrdersFromSale($statuts, FALSE, FALSE);
if (!empty($orders2)) {
foreach ($orders2 as $key => $order) {
if (in_array($order, $orders)) {
@ -131,10 +147,7 @@ function generateInvoicesPDFPrivateSales48h()
}
}
PDF::multipleInvoices($orders, false, true, true);
if (!empty($orders2)) {
PDF::multipleInvoices($orders2, true, true, true);
}
PDF::multipleInvoices2($orders, $orders2, true, true);
}
}
}

View File

@ -101,8 +101,11 @@ class AdminInvoices extends AdminTab
<th align="center" width="50">'.$this->l('Id Sale').'</th>
<th>'.$this->l('Name sale').' (%ean)</th>
<th align="center">'.$this->l('Date start').'</th>
<th align="center">48h</th>
<th align="center">M1</th>
<th align="center">48h</th>';
if ($cookie->id_employee == 1) {
echo '<th align="center">48H bis</th>';
}
echo '<th align="center">M1</th>
<th align="center">M2</th>
<th align="center">M3+</th>
<th align="center">All</th>
@ -129,6 +132,17 @@ class AdminInvoices extends AdminTab
} else {
echo '-';
}
if ($cookie->id_employee == 1) {
echo '</td><td align="center">';
if ($sale['delivery_delay'] == 2
|| $sale['delivery_delay'] == 6) {
echo '<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&print48hbis=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
<img src="../img/admin/pdf.gif" alt="">
</a>';
} else {
echo '-';
}
}
echo '</td>
<td align="center">
<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
@ -373,6 +387,23 @@ class AdminInvoices extends AdminTab
}
$this->_errors[] = $this->l('No invoice found for this sale');
}
// print 48h bis (distinct multi)
elseif (Tools::getValue('print48hbis') == 1)
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) {
if(!in_array($sale->delivery_delay, array(2 ,6) )) {
$this->_errors[] = $this->l('This sale is not delivery 48h');
} else {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSale($statuts, FALSE, TRUE);
if(sizeof($orders)) {
Tools::redirectAdmin('pdf.php?privatesales48hbis&id_sale='.(int) $sale->id.'&token='.$this->token);
}
}
}
$this->_errors[] = $this->l('No invoice found for this sale');
}
// print printAll
elseif (Tools::getValue('printAll') == 1)
{

View File

@ -341,6 +341,28 @@ class PDFCore extends PDF_PageGroupCore
return $pdf->Output('invoices.pdf', 'D');
}
public static function multipleInvoices2($invoices_single, $invoices_multi, $tri = false, $expe48 = false)
{
$pdf = new PDF('P', 'mm', 'A4');
// invoice for single sale orders
foreach ($invoices_single AS $id_order)
{
$orderObj = new Order((int)$id_order);
if (Validate::isLoadedObject($orderObj))
PDF::invoice($orderObj, 'D', true, $pdf, false, false, false, $tri, $expe48);
}
// invoice for multi sale orders
foreach ($invoices_multi AS $id_order)
{
$orderObj = new Order((int)$id_order);
if (Validate::isLoadedObject($orderObj))
PDF::invoice($orderObj, 'D', true, $pdf, false, false, true, $tri, $expe48);
}
return $pdf->Output('invoices.pdf', 'D');
}
public static function multipleOrderSlips($orderSlips)
{
$pdf = new PDF('P', 'mm', 'A4');