Merge branch 'ticket-11208-FactureCadeau' into develop
This commit is contained in:
commit
9a9d363b87
@ -149,9 +149,9 @@ class AdminInvoices extends AdminTab
|
|||||||
echo '</td>*/
|
echo '</td>*/
|
||||||
echo '</td>
|
echo '</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a title="Facture - Avec prix" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
|
<!--a title="Facture - Avec prix" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
|
||||||
<span class="text-green-light anticon anticon-file-pdf" style="cursor:pointer;"></span>
|
<span class="text-green-light anticon anticon-file-pdf" style="cursor:pointer;"></span>
|
||||||
</a>
|
</a-->
|
||||||
<a title="Facture cadeau - Sans prix" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&gift=1&token='.$this->token.'">
|
<a title="Facture cadeau - Sans prix" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&gift=1&token='.$this->token.'">
|
||||||
<span class="text-rose anticon anticon-file-pdf" style="cursor:pointer;"></span>
|
<span class="text-rose anticon anticon-file-pdf" style="cursor:pointer;"></span>
|
||||||
</a>
|
</a>
|
||||||
@ -165,9 +165,9 @@ class AdminInvoices extends AdminTab
|
|||||||
echo '<td align="center"><input id="multi_'. $sale['id_sale'].'" type="checkbox" name="multi2[]" value="'.$sale['id_sale'].'" '.(in_array((int)$sale['id_sale'], $id_sales)?'checked':'').'/></td>
|
echo '<td align="center"><input id="multi_'. $sale['id_sale'].'" type="checkbox" name="multi2[]" value="'.$sale['id_sale'].'" '.(in_array((int)$sale['id_sale'], $id_sales)?'checked':'').'/></td>
|
||||||
<td align="center"><input id="multi_plus_'. $sale['id_sale'].'" type="checkbox" name="multiPlus[]" value="'.$sale['id_sale'].'"/></td>
|
<td align="center"><input id="multi_plus_'. $sale['id_sale'].'" type="checkbox" name="multiPlus[]" value="'.$sale['id_sale'].'"/></td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
|
<!--a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
|
||||||
<span class="text-green-light anticon anticon-file-pdf" style="cursor:pointer;"></span>
|
<span class="text-green-light anticon anticon-file-pdf" style="cursor:pointer;"></span>
|
||||||
</a>
|
</a-->
|
||||||
<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&gift=1&token='.$this->token.'">
|
<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&gift=1&token='.$this->token.'">
|
||||||
<span class="text-rose anticon anticon-file-pdf" style="cursor:pointer;"></span>
|
<span class="text-rose anticon anticon-file-pdf" style="cursor:pointer;"></span>
|
||||||
</a>
|
</a>
|
||||||
@ -178,12 +178,13 @@ class AdminInvoices extends AdminTab
|
|||||||
}
|
}
|
||||||
// <td align="center"><input id="m2_'. $sale['id_sale'].'" type="checkbox" name="m2[]" value="'.$sale['id_sale'].'" /></td>
|
// <td align="center"><input id="m2_'. $sale['id_sale'].'" type="checkbox" name="m2[]" value="'.$sale['id_sale'].'" /></td>
|
||||||
echo '<tr>
|
echo '<tr>
|
||||||
<td colspan="4" style="padding:5px;">
|
<td colspan="4" style="padding:5px;"></td>';
|
||||||
<input type="hidden" name="date_to" value="'. Tools::getValue('date_to') .'" />
|
// <td colspan="4" style="padding:5px;">
|
||||||
<input type="hidden" name="date_from" value="'. Tools::getValue('date_from') .'" />
|
// <input type="hidden" name="date_to" value="'. Tools::getValue('date_to') .'" />
|
||||||
<label style="float:none;" class="text-green-light "><span class="anticon anticon-file-pdf"></span> '.$this->l('Avec prix').'</label>
|
// <input type="hidden" name="date_from" value="'. Tools::getValue('date_from') .'" />
|
||||||
<label style="float:none;" class="text-rose "><span class="anticon anticon-file-pdf"></span> '.$this->l('Sans prix').'</label>
|
// <label style="float:none;" class="text-green-light "><span class="anticon anticon-file-pdf"></span> '.$this->l('Avec prix').'</label>
|
||||||
</td>';
|
// <label style="float:none;" class="text-rose "><span class="anticon anticon-file-pdf"></span> '.$this->l('Sans prix').'</label>
|
||||||
|
// </td>';
|
||||||
/*<td align="center">
|
/*<td align="center">
|
||||||
<input type="submit" name="submitPrintM2Bis" class="button" value="'.$this->l('Print M2\'').'" />
|
<input type="submit" name="submitPrintM2Bis" class="button" value="'.$this->l('Print M2\'').'" />
|
||||||
</td>*/
|
</td>*/
|
||||||
|
137
classes/PDF.php
137
classes/PDF.php
@ -570,6 +570,7 @@ class PDFCore extends PDF_PageGroupCore
|
|||||||
|
|
||||||
if (!Validate::isLoadedObject($order) OR (!$cookie->id_employee AND (!OrderState::invoiceAvailable($order->getCurrentState()) AND !$order->invoice_number)))
|
if (!Validate::isLoadedObject($order) OR (!$cookie->id_employee AND (!OrderState::invoiceAvailable($order->getCurrentState()) AND !$order->invoice_number)))
|
||||||
die('Invalid order or invalid order state');
|
die('Invalid order or invalid order state');
|
||||||
|
/* @Override Antadis */
|
||||||
if($gift && $order->gift == 1) {
|
if($gift && $order->gift == 1) {
|
||||||
self::invoiceWithoutPrice($order, $mode = 'D', $multiple, $pdf, $slip, $delivery, $multi, $tri, $expe48);
|
self::invoiceWithoutPrice($order, $mode = 'D', $multiple, $pdf, $slip, $delivery, $multi, $tri, $expe48);
|
||||||
} else {
|
} else {
|
||||||
@ -795,6 +796,7 @@ class PDFCore extends PDF_PageGroupCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @Add Antadis
|
||||||
* invoiceWithoutPrice
|
* invoiceWithoutPrice
|
||||||
*
|
*
|
||||||
* @param object $order Order
|
* @param object $order Order
|
||||||
@ -912,6 +914,7 @@ class PDFCore extends PDF_PageGroupCore
|
|||||||
/* Exit if delivery */
|
/* Exit if delivery */
|
||||||
if (!self::$delivery)
|
if (!self::$delivery)
|
||||||
{
|
{
|
||||||
|
/* @Override Antadis */
|
||||||
if(!empty(self::$order->gift_message)) {
|
if(!empty(self::$order->gift_message)) {
|
||||||
$pdf->Ln(15);
|
$pdf->Ln(15);
|
||||||
$pdf->SetFont(self::fontname(), 'B', 10);
|
$pdf->SetFont(self::fontname(), 'B', 10);
|
||||||
@ -967,25 +970,73 @@ class PDFCore extends PDF_PageGroupCore
|
|||||||
$this->SetFont(self::fontname(), '', 8);
|
$this->SetFont(self::fontname(), '', 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* @Override Antadis */
|
||||||
|
private function ProdTabHeaderWithEcotax($delivery = false)
|
||||||
|
{
|
||||||
|
// label, alignment (L: left, R: right, C: center)
|
||||||
|
if (!$delivery) {
|
||||||
|
$header = array(
|
||||||
|
array(self::l('Description'), 'L'),
|
||||||
|
array(self::l('Reference'), 'L'),
|
||||||
|
array(self::l('U. price'), 'R'),
|
||||||
|
array(self::l('Ecotax incl.'), 'R'),
|
||||||
|
array(self::l('Qty'), 'C'),
|
||||||
|
array(self::l('Total'), 'R')
|
||||||
|
);
|
||||||
|
$w = array(85, 15, 30, 30, 15, 15);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$header = array(
|
||||||
|
array(self::l('Description'), 'L'),
|
||||||
|
array(self::l('Reference'), 'L'),
|
||||||
|
array(self::l('Qty'), 'C'),
|
||||||
|
);
|
||||||
|
$w = array(120, 30, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->SetFont(self::fontname(), 'B', 8);
|
||||||
|
$this->SetFillColor(240, 240, 240);
|
||||||
|
if ($delivery)
|
||||||
|
$this->SetX(25);
|
||||||
|
for ($i = 0; $i < sizeof($header); $i++) {
|
||||||
|
$this->Cell($w[$i], 5, $header[$i][0], 'T', 0, $header[$i][1], 1);
|
||||||
|
}
|
||||||
|
$this->Ln();
|
||||||
|
$this->SetFont(self::fontname(), '', 8);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Product table with price, quantities...
|
* Product table with price, quantities...
|
||||||
*/
|
*/
|
||||||
public function ProdTab($delivery = false, $tri=false, $gift=false)
|
public function ProdTab($delivery = false, $tri=false, $gift=false)
|
||||||
{
|
{
|
||||||
if (!$delivery)
|
|
||||||
$w = array(100, 15, 30, 15, 30);
|
|
||||||
else
|
|
||||||
$w = array(120, 30, 10);
|
|
||||||
self::ProdTabHeader($delivery);
|
|
||||||
if (!self::$orderSlip)
|
if (!self::$orderSlip)
|
||||||
{
|
{
|
||||||
if (isset(self::$order->products) AND sizeof(self::$order->products))
|
if (isset(self::$order->products) AND sizeof(self::$order->products))
|
||||||
$products = self::$order->products;
|
$products = self::$order->products;
|
||||||
else
|
else
|
||||||
$products = self::$order->getProducts(false,false,false,true);
|
$products = self::$order->getProducts(false, false, false, $tri);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$products = self::$orderSlip->getOrdersSlipProducts(self::$orderSlip->id, self::$order);
|
$products = self::$orderSlip->getOrdersSlipProducts(self::$orderSlip->id, self::$order);
|
||||||
|
|
||||||
|
/* @Override Antadis */
|
||||||
|
$hasEcotax = $this->hasProductWithEcotax($products);
|
||||||
|
if ($hasEcotax) {
|
||||||
|
$this->ProdTabHeaderWithEcotax($delivery);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self::ProdTabHeader($delivery);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$delivery) {
|
||||||
|
$w = $hasEcotax?array(85, 15, 30, 30, 15, 15):array(100, 15, 30, 15, 30);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$w = array(120, 30, 10);
|
||||||
|
}
|
||||||
|
|
||||||
$customizedDatas = Product::getAllCustomizedDatas((int)(self::$order->id_cart));
|
$customizedDatas = Product::getAllCustomizedDatas((int)(self::$order->id_cart));
|
||||||
Product::addCustomizationPrice($products, $customizedDatas);
|
Product::addCustomizationPrice($products, $customizedDatas);
|
||||||
|
|
||||||
@ -997,6 +1048,10 @@ class PDFCore extends PDF_PageGroupCore
|
|||||||
foreach($products AS $product)
|
foreach($products AS $product)
|
||||||
if ((!$delivery || ($delivery && $gift)) || ((int)($product['product_quantity']) - (int)($product['product_quantity_refunded']) > 0))
|
if ((!$delivery || ($delivery && $gift)) || ((int)($product['product_quantity']) - (int)($product['product_quantity_refunded']) > 0))
|
||||||
{
|
{
|
||||||
|
if ($product['sended'] == 1) {
|
||||||
|
$product['product_name'] = '* '.$product['product_name'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($counter >= $lines)
|
if ($counter >= $lines)
|
||||||
{
|
{
|
||||||
$this->AddPage();
|
$this->AddPage();
|
||||||
@ -1062,15 +1117,29 @@ class PDFCore extends PDF_PageGroupCore
|
|||||||
if ($delivery)
|
if ($delivery)
|
||||||
$this->SetX(25);
|
$this->SetX(25);
|
||||||
$before = $this->GetY();
|
$before = $this->GetY();
|
||||||
|
|
||||||
$this->MultiCell($w[++$i], 5, Tools::iconv('utf-8', self::encoding(), $product['product_name']).' - '.self::l('Customized')." \n".Tools::iconv('utf-8', self::encoding(), $custoLabel), 'B');
|
$this->MultiCell($w[++$i], 5, Tools::iconv('utf-8', self::encoding(), $product['product_name']).' - '.self::l('Customized')." \n".Tools::iconv('utf-8', self::encoding(), $custoLabel), 'B');
|
||||||
$lineSize = $this->GetY() - $before;
|
$lineSize = $this->GetY() - $before;
|
||||||
$this->SetXY($this->GetX() + $w[0] + ($delivery ? 15 : 0), $this->GetY() - $lineSize);
|
$this->SetXY($this->GetX() + $w[0] + ($delivery ? 15 : 0), $this->GetY() - $lineSize);
|
||||||
$this->Cell($w[++$i], $lineSize, $product['product_reference'], 'B');
|
$this->Cell($w[++$i], $lineSize, $product['product_reference'], 'B');
|
||||||
if (!$delivery)
|
if (!$delivery) {
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($unit_price, self::$currency, true)), 'B', 0, 'R');
|
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($unit_price, self::$currency, true)), 'B', 0, 'R');
|
||||||
|
/* @Override Antadis */
|
||||||
|
if ($hasEcotax) {
|
||||||
|
if (!empty($product['ecotax']) && $product['ecotax']>0) {
|
||||||
|
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($product['ecotax'], self::$currency, true)), 'BT', 0, 'R');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->Cell($w[++$i], $lineSize, '-', 'BT', 0, 'R');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->Cell($w[++$i], $lineSize, (int)($product['customizationQuantityTotal']), 'B', 0, 'C');
|
$this->Cell($w[++$i], $lineSize, (int)($product['customizationQuantityTotal']), 'B', 0, 'C');
|
||||||
if (!$delivery)
|
if (!$delivery) {
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($unit_price * (int)($product['customizationQuantityTotal']), self::$currency, true)), 'B', 0, 'R');
|
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($unit_price * (int)($product['customizationQuantityTotal']), self::$currency, true)), 'B', 0, 'R');
|
||||||
|
}
|
||||||
|
|
||||||
$this->Ln();
|
$this->Ln();
|
||||||
$i = -1;
|
$i = -1;
|
||||||
$total_with_tax = $unit_with_tax * $productQuantity;
|
$total_with_tax = $unit_with_tax * $productQuantity;
|
||||||
@ -1081,15 +1150,45 @@ class PDFCore extends PDF_PageGroupCore
|
|||||||
if ($productQuantity)
|
if ($productQuantity)
|
||||||
{
|
{
|
||||||
$before = $this->GetY();
|
$before = $this->GetY();
|
||||||
$this->MultiCell($w[++$i], 5, Tools::iconv('utf-8', self::encoding(), $product['product_name']), 'B');
|
$fill = false;
|
||||||
|
if($productQuantity > 1) {
|
||||||
|
$this->SetFont(self::fontname(), 'B', 7);
|
||||||
|
$this->SetFillColor(240, 240, 240);
|
||||||
|
$fill = true;
|
||||||
|
} else {
|
||||||
|
$this->SetFont(self::fontname(), '', 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->MultiCell($w[++$i], 5, Tools::iconv('utf-8', self::encoding(), $product['product_name']), 'BT', 'L');
|
||||||
$lineSize = $this->GetY() - $before;
|
$lineSize = $this->GetY() - $before;
|
||||||
$this->SetXY($this->GetX() + $w[0] + ($delivery ? 15 : 0), $this->GetY() - $lineSize);
|
$this->SetXY($this->GetX() + $w[0] + ($delivery ? 15 : 0), $this->GetY() - $lineSize);
|
||||||
$this->Cell($w[++$i], $lineSize, ($product['product_reference'] ? Tools::iconv('utf-8', self::encoding(), $product['product_reference']) : '--'), 'B');
|
$this->Cell($w[++$i], $lineSize, ($product['product_reference'] ? Tools::iconv('utf-8', self::encoding(), $product['product_reference']) : '--'), 'BT');
|
||||||
|
if (!$delivery) {
|
||||||
|
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($unit_price, self::$currency, true)), 'BT', 0, 'R');
|
||||||
|
/* @Override Antadis */
|
||||||
|
if ($hasEcotax) {
|
||||||
|
if (!empty($product['ecotax']) && $product['ecotax']>0) {
|
||||||
|
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($product['ecotax'], self::$currency, true)), 'BT', 0, 'R');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->Cell($w[++$i], $lineSize, '-', 'BT', 0, 'R');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* @Override Antadis */
|
||||||
|
if(!$delivery) {
|
||||||
|
global $cookie;
|
||||||
|
error_log("logt" . serialize($cookie));
|
||||||
|
if(method_exists($cookie, 'isLoggedBack') && $cookie->isLoggedBack()) {
|
||||||
|
$this->Cell($w[++$i], $lineSize, $productQuantity.(self::$orderSlip? '': ($product['product_quantity_return'] > 0? ' (-'.$product['product_quantity_return'].')': ($product['product_quantity_refunded'] > 0? ' (-'.$product['product_quantity_refunded'].')': '' ))), 'BT', 0, 'C', $fill);
|
||||||
|
} else {
|
||||||
|
$this->Cell($w[++$i], $lineSize, $productQuantity, 'BT', 0, 'C', $fill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->Cell($w[++$i], $lineSize, $productQuantity, 'BT', 0, 'C');
|
||||||
if (!$delivery)
|
if (!$delivery)
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($unit_price, self::$currency, true)), 'B', 0, 'R');
|
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($final_price, self::$currency, true)), 'BT', 0, 'R');
|
||||||
$this->Cell($w[++$i], $lineSize, $productQuantity, 'B', 0, 'C');
|
|
||||||
if (!$delivery)
|
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($final_price, self::$currency, true)), 'B', 0, 'R');
|
|
||||||
$this->Ln();
|
$this->Ln();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1394,5 +1493,15 @@ class PDFCore extends PDF_PageGroupCore
|
|||||||
return $font ? $font : 'Arial';
|
return $font ? $font : 'Arial';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function hasProductWithEcotax($products)
|
||||||
|
{
|
||||||
|
foreach($products as $product) {
|
||||||
|
if (!empty($product['ecotax']) && $product['ecotax']>0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,240 +0,0 @@
|
|||||||
<?php
|
|
||||||
class PDF extends PDFCore {
|
|
||||||
|
|
||||||
// PDF column width for the table of ordered products
|
|
||||||
private $cell_widths = [
|
|
||||||
'with_ecotax' => [85, 15, 30, 30, 15, 15],
|
|
||||||
'no_ecotax' => [100, 15, 30, 15, 30],
|
|
||||||
'delivery' => [120, 30, 10]
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
private function hasProductWithEcotax($products)
|
|
||||||
{
|
|
||||||
foreach($products as $product) {
|
|
||||||
if (!empty($product['ecotax']) && $product['ecotax']>0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function ProdTab($delivery = false, $tri = false)
|
|
||||||
{
|
|
||||||
if (!self::$orderSlip)
|
|
||||||
{
|
|
||||||
if (isset(self::$order->products) AND sizeof(self::$order->products))
|
|
||||||
$products = self::$order->products;
|
|
||||||
else
|
|
||||||
$products = self::$order->getProducts(false, false, false, $tri);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$products = self::$orderSlip->getOrdersSlipProducts(self::$orderSlip->id, self::$order);
|
|
||||||
|
|
||||||
$hasEcotax = $this->hasProductWithEcotax($products);
|
|
||||||
|
|
||||||
if ($hasEcotax) {
|
|
||||||
$this->ProdTabHeaderWithEcotax($delivery);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->ProdTabHeader($delivery);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$delivery) {
|
|
||||||
$w = &$this->cell_widths[$hasEcotax?'with_ecotax':'no_ecotax'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$w = &$this->cell_widths['delivery'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$customizedDatas = Product::getAllCustomizedDatas((int)(self::$order->id_cart));
|
|
||||||
Product::addCustomizationPrice($products, $customizedDatas);
|
|
||||||
|
|
||||||
$counter = 0;
|
|
||||||
$lines = 25;
|
|
||||||
$lineSize = 0;
|
|
||||||
$line = 0;
|
|
||||||
|
|
||||||
foreach($products AS $product)
|
|
||||||
if (!$delivery OR ((int)($product['product_quantity']) - (int)($product['product_quantity_refunded']) > 0))
|
|
||||||
{
|
|
||||||
if ($product['sended'] == 1) {
|
|
||||||
$product['product_name'] = '* '.$product['product_name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($counter >= $lines)
|
|
||||||
{
|
|
||||||
$this->AddPage();
|
|
||||||
$this->Ln();
|
|
||||||
self::ProdTabHeader($delivery);
|
|
||||||
$lineSize = 0;
|
|
||||||
$counter = 0;
|
|
||||||
$lines = 40;
|
|
||||||
$line++;
|
|
||||||
}
|
|
||||||
$counter = $counter + ($lineSize / 5) ;
|
|
||||||
|
|
||||||
$i = -1;
|
|
||||||
|
|
||||||
// Unit vars
|
|
||||||
$unit_without_tax = $product['product_price'] + $product['ecotax'];
|
|
||||||
$unit_with_tax = $product['product_price_wt'];
|
|
||||||
if (self::$_priceDisplayMethod == PS_TAX_EXC)
|
|
||||||
$unit_price = &$unit_without_tax;
|
|
||||||
else
|
|
||||||
$unit_price = &$unit_with_tax;
|
|
||||||
$productQuantity = $delivery ? ((int)($product['product_quantity']) - (int)($product['product_quantity_refunded'])) : (int)($product['product_quantity']);
|
|
||||||
|
|
||||||
if ($productQuantity <= 0)
|
|
||||||
continue ;
|
|
||||||
|
|
||||||
// Total prices
|
|
||||||
$total_with_tax = $unit_with_tax * $productQuantity;
|
|
||||||
$total_without_tax = $unit_without_tax * $productQuantity;
|
|
||||||
// Spec
|
|
||||||
if (self::$_priceDisplayMethod == PS_TAX_EXC)
|
|
||||||
$final_price = &$total_without_tax;
|
|
||||||
else
|
|
||||||
$final_price = &$total_with_tax;
|
|
||||||
// End Spec
|
|
||||||
|
|
||||||
if (isset($customizedDatas[$product['product_id']][$product['product_attribute_id']]))
|
|
||||||
{
|
|
||||||
$custoLabel = '';
|
|
||||||
|
|
||||||
foreach($customizedDatas[$product['product_id']][$product['product_attribute_id']] as $customizedData)
|
|
||||||
{
|
|
||||||
$customizationGroup = $customizedData['datas'];
|
|
||||||
$nb_images = 0;
|
|
||||||
|
|
||||||
if (array_key_exists(_CUSTOMIZE_FILE_, $customizationGroup))
|
|
||||||
$nb_images = sizeof($customizationGroup[_CUSTOMIZE_FILE_]);
|
|
||||||
|
|
||||||
if (array_key_exists(_CUSTOMIZE_TEXTFIELD_, $customizationGroup))
|
|
||||||
foreach($customizationGroup[_CUSTOMIZE_TEXTFIELD_] as $customization)
|
|
||||||
if (!empty($customization['name'])) $custoLabel .= '- '.$customization['name'].': '.$customization['value']."\n";
|
|
||||||
|
|
||||||
|
|
||||||
if ($nb_images > 0)
|
|
||||||
$custoLabel .= '- '.$nb_images. ' '. self::l('image(s)')."\n";
|
|
||||||
|
|
||||||
$custoLabel .= "---\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$custoLabel = rtrim($custoLabel, "---\n");
|
|
||||||
|
|
||||||
$productQuantity = (int)($product['product_quantity']) - (int)($product['customizationQuantityTotal']);
|
|
||||||
if ($delivery)
|
|
||||||
$this->SetX(25);
|
|
||||||
$before = $this->GetY();
|
|
||||||
|
|
||||||
$this->MultiCell($w[++$i], 5, Tools::iconv('utf-8', self::encoding(), $product['product_name']).' - '.self::l('Customized')." \n".Tools::iconv('utf-8', self::encoding(), $custoLabel), 'B');
|
|
||||||
$lineSize = $this->GetY() - $before;
|
|
||||||
$this->SetXY($this->GetX() + $w[0] + ($delivery ? 15 : 0), $this->GetY() - $lineSize);
|
|
||||||
$this->Cell($w[++$i], $lineSize, $product['product_reference'], 'B');
|
|
||||||
if (!$delivery) {
|
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($unit_price, self::$currency, true)), 'B', 0, 'R');
|
|
||||||
|
|
||||||
if ($hasEcotax) {
|
|
||||||
if (!empty($product['ecotax']) && $product['ecotax']>0) {
|
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($product['ecotax'], self::$currency, true)), 'BT', 0, 'R');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->Cell($w[++$i], $lineSize, '-', 'BT', 0, 'R');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->Cell($w[++$i], $lineSize, (int)($product['customizationQuantityTotal']), 'B', 0, 'C');
|
|
||||||
if (!$delivery) {
|
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($unit_price * (int)($product['customizationQuantityTotal']), self::$currency, true)), 'B', 0, 'R');
|
|
||||||
|
|
||||||
}
|
|
||||||
$this->Ln();
|
|
||||||
$i = -1;
|
|
||||||
$total_with_tax = $unit_with_tax * $productQuantity;
|
|
||||||
$total_without_tax = $unit_without_tax * $productQuantity;
|
|
||||||
}
|
|
||||||
if ($delivery)
|
|
||||||
$this->SetX(25);
|
|
||||||
if ($productQuantity)
|
|
||||||
{
|
|
||||||
$before = $this->GetY();
|
|
||||||
$fill = FALSE;
|
|
||||||
if($productQuantity > 1) {
|
|
||||||
$this->SetFont(self::fontname(), 'B', 7);
|
|
||||||
$this->SetFillColor(240, 240, 240);
|
|
||||||
$fill = TRUE;
|
|
||||||
} else {
|
|
||||||
$this->SetFont(self::fontname(), '', 7);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->MultiCell($w[++$i], 5, Tools::iconv('utf-8', self::encoding(), $product['product_name']), 'BT', 'L', $fill);
|
|
||||||
$lineSize = $this->GetY() - $before;
|
|
||||||
$this->SetXY($this->GetX() + $w[0] + ($delivery ? 15 : 0), $this->GetY() - $lineSize);
|
|
||||||
$this->Cell($w[++$i], $lineSize, ($product['product_reference'] ? Tools::iconv('utf-8', self::encoding(), $product['product_reference']) : '--'), 'BT');
|
|
||||||
if (!$delivery) {
|
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($unit_price, self::$currency, true)), 'BT', 0, 'R');
|
|
||||||
|
|
||||||
if ($hasEcotax) {
|
|
||||||
if (!empty($product['ecotax']) && $product['ecotax']>0) {
|
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($product['ecotax'], self::$currency, true)), 'BT', 0, 'R');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->Cell($w[++$i], $lineSize, '-', 'BT', 0, 'R');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
global $cookie;
|
|
||||||
error_log("logt" . serialize($cookie));
|
|
||||||
if(method_exists($cookie, 'isLoggedBack') && $cookie->isLoggedBack()) {
|
|
||||||
$this->Cell($w[++$i], $lineSize, $productQuantity.(self::$orderSlip? '': ($product['product_quantity_return'] > 0? ' (-'.$product['product_quantity_return'].')': ($product['product_quantity_refunded'] > 0? ' (-'.$product['product_quantity_refunded'].')': '' ))), 'BT', 0, 'C', $fill);
|
|
||||||
} else {
|
|
||||||
$this->Cell($w[++$i], $lineSize, $productQuantity, 'BT', 0, 'C', $fill);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$delivery)
|
|
||||||
$this->Cell($w[++$i], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($final_price, self::$currency, true)), 'BT', 0, 'R');
|
|
||||||
$this->Ln();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sizeof(self::$order->getDiscounts()) AND !$delivery)
|
|
||||||
$this->Cell(array_sum($w), 0, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function ProdTabHeaderWithEcotax($delivery = false)
|
|
||||||
{
|
|
||||||
// label, alignment (L: left, R: right, C: center)
|
|
||||||
if (!$delivery) {
|
|
||||||
$header = array(
|
|
||||||
array(self::l('Description'), 'L'),
|
|
||||||
array(self::l('Reference'), 'L'),
|
|
||||||
array(self::l('U. price'), 'R'),
|
|
||||||
array(self::l('Ecotax incl.'), 'R'),
|
|
||||||
array(self::l('Qty'), 'C'),
|
|
||||||
array(self::l('Total'), 'R')
|
|
||||||
);
|
|
||||||
$w = &$this->cell_widths['with_ecotax'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$header = array(
|
|
||||||
array(self::l('Description'), 'L'),
|
|
||||||
array(self::l('Reference'), 'L'),
|
|
||||||
array(self::l('Qty'), 'C'),
|
|
||||||
);
|
|
||||||
$w = &$this->cell_widths['delivery'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->SetFont(self::fontname(), 'B', 8);
|
|
||||||
$this->SetFillColor(240, 240, 240);
|
|
||||||
if ($delivery)
|
|
||||||
$this->SetX(25);
|
|
||||||
for ($i = 0; $i < sizeof($header); $i++)
|
|
||||||
$this->Cell($w[$i], 5, $header[$i][0], 'T', 0, $header[$i][1], 1);
|
|
||||||
$this->Ln();
|
|
||||||
$this->SetFont(self::fontname(), '', 8);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user