/** * Product table with price, quantities... */ public function ProdTab($delivery = false) { self::$orderQuantity = 0; 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(); } } else { $products = self::$orderSlip->getProducts(); } $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 ($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 = Tools::ps_round($unit_with_tax) * $productQuantity; $total_without_tax = Tools::ps_round($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']) . " \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'] ? $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(round($unit_price) * (int) $product['customizationQuantityTotal'], self::$currency, true)), 'B', 0, 'R'); } $this->Ln(); $i = -1; $total_with_tax = Tools::ps_round($unit_with_tax) * $productQuantity; $total_without_tax = Tools::ps_round($unit_without_tax) * $productQuantity; } self::$orderQuantity += $product['product_quantity']; if ($delivery) { $this->SetX(25); } if ($productQuantity) { $before = $this->GetY(); $this->MultiCell($w[++$i], 5, Tools::iconv('utf-8', self::encoding(), $product['product_name']), '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'] ? $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, $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(); } } } if (!sizeof(self::$order->getDiscounts()) and !$delivery) { $this->Cell(array_sum($w), 0, ''); } }