153 lines
5.8 KiB
PHP
153 lines
5.8 KiB
PHP
<?php
|
|
class PDF extends PDFCore {
|
|
public function ProdTab($delivery = false, $tri = false)
|
|
{
|
|
if (!$delivery)
|
|
$w = array(100, 15, 30, 15, 30);
|
|
else
|
|
$w = array(120, 30, 10);
|
|
self::ProdTabHeader($delivery);
|
|
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);
|
|
$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');
|
|
$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');
|
|
|
|
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, '');
|
|
}
|
|
}
|