<?php require 'ean13.php'; $pdf = new PDF_EAN13(); $pdf->AddPage(); $pdf->EAN13(80, 40, '123456789012'); $pdf->Output();
function CreatePDFFile($servername, $username, $password, $dbname, $order, $orderlines, $singleorder, $pdf) { require_once 'EAN13.php'; if ($singleorder == true) { $pdf = new PDF_EAN13('P', 'mm', array(105, 148)); } $AnzRes = 0; $data_error = false; foreach ($orderlines as $line) { if ($line->sku != '101') { if (GetVPE($line->vpe) == "lfdm") { $AnzRes = $AnzRes + 1; } else { $AnzRes = $AnzRes + CalculateOrderPages($line->qty_ordered, GetEinheit($line->einheit, GetVPE($line->vpe)), GetVPE($line->vpe), GetPackStueck($line->packstueck)); } if ($line->data_error != "") { $data_error = true; } } } if (!$data_error) { $page = 0; foreach ($orderlines as $orderarticle) { $Anz = 1; if (GetVPE($orderarticle->vpe) != "lfdm") { $Anz = CalculateOrderPages($orderarticle->qty_ordered, GetEinheit($orderarticle->einheit, GetVPE($orderarticle->vpe)), GetVPE($orderarticle->vpe), GetPackStueck($orderarticle->packstueck)); } for ($i = 1; $i <= $Anz; $i++) { $page = $page + 1; $pdf->AddPage(); $pdf->SetFont('Helvetica', 'B', 18); $po = ""; if ($orderarticle->product_options != "") { $po = GetLaenge($orderarticle->product_options); } // jetzt gehts 3 zeilig, keine kürzung mehr notwendig $orderarticle->name = substr($orderarticle->name, 0, 45); $pdf->MultiCell(80, 6, $orderarticle->name, 0, 'L'); $pdf->SetFont('Helvetica', 'B', 12); $pm = GetPayMethodASCII($order->paymethod); $bem = ""; if ($orderarticle->qty_ordered <= GetVPE($orderarticle->vpe)) { $txt = round($orderarticle->qty_ordered); if ($orderarticle->qty_ordered < GetVPE($orderarticle->vpe)) { $bem = "ACHTUNG:\n" . round($orderarticle->qty_ordered) . " " . GetEinheitASCII($orderarticle->einheit, GetVPE($orderarticle->vpe)) . " !!!"; } } else { $txt = round(GetVPE($orderarticle->vpe)); $orderarticle->qty_ordered = $orderarticle->qty_ordered - GetVPE($orderarticle->vpe); } $txt = $txt . " " . GetEinheitASCII($orderarticle->einheit, GetVPE($orderarticle->vpe)); $txt = $txt . " (Art.Nr.: " . $orderarticle->sku . ") Packstueck(e): "; if (GetPackStueck($orderarticle->packstueck) > 1) { $txt = $txt . $i . "/" . GetPackStueck($orderarticle->packstueck); } else { $txt = $txt . GetPackStueck($orderarticle->packstueck); } $pdf->Text(10, 35, $txt, 0, 1, 'L'); $txt = ""; // if (GetLaenge($orderarticle->product_options) <> "") { // $txt = $txt . "Laenge: " . GetLaenge($orderarticle->product_options) . " "; // } if ($orderarticle->product_quotes != "") { $txt = $txt . $orderarticle->product_quotes . " "; } if ($orderarticle->product_ltxt != "") { $txt = $txt . "Zustand: " . $orderarticle->product_ltxt; } $pdf->SetFont('Helvetica', 'B', 10); $pdf->Text(10, 40, $txt, 0, 1, 'L'); // bemerkung aus Auftrag Artikel !!! if ($order->bemerkung != "") { $pdf->SetXY(55, 73); $pdf->SetFillColor(204, 204, 204); $pdf->MultiCell(45, 5, $order->bemerkung, 1, 'R', true); $pdf->SetFillColor(0, 0, 0); } if ($bem != "") { $pdf->SetXY(55, 40); $pdf->SetFillColor(204, 204, 204); $pdf->MultiCell(45, 5, $bem, 1, 'R', true); $pdf->SetFillColor(0, 0, 0); } if ($order->country_id != "DE") { $pdf->SetFont('Helvetica', 'B', 24); $pdf->SetFillColor(204, 204, 204); $pdf->SetXY(80, 85); $pdf->MultiCell(20, 15, "DPD", 1, 'R', true); $pdf->SetFillColor(0, 0, 0); $pdf->SetFont('Helvetica', 'B', 10); } $pdf->Text(10, 75, $order->ba_lastname . ", " . $order->ba_firstname, 0, 1, 'L'); $pdf->SetFont('Helvetica', '', 8); if ($orderarticle->product_base != "") { $pdf->Text(10, 40, "(" . $orderarticle->product_base . ")"); } $pdf->SetFont('Helvetica', '', 10); $txt = ""; if ($order->lastname != $order->ba_lastname or $order->firstname != $order->ba_firstname) { $txt = '(LiAdr: ' . $order->lastname . ", " . $order->firstname . ') '; } $txt = $txt . $pm; $pdf->Text(10, 80, $txt, 0, 1, 'L'); $pdf->SetFont('Helvetica', '', 6); $ts = strtotime($order->order_date); $pdf->Text(10, 85, $order->order_number . " vom " . date("d.m.Y G:i:s", $ts), 0, 1, 'L'); $pdf->Text(10, 88, $order->firstname . " " . $order->lastname, 0, 1, 'L'); $pdf->Text(10, 91, $order->street, 0, 1, 'L'); $city = ""; if ($order->country_id != "DE") { $city = $order->country_id . "-"; } $city = $city . $order->postcode . " " . $order->city; $pdf->Text(10, 94, $city, 0, 1, 'L'); $pdf->SetFont('Helvetica', 'I', 6); $space = 0; if (sizeof($orderlines) > 1) { $space = $space + 1; $pdf->Text(10, 98, 'weitere Artikel:', 0, 1, 'L'); $space = $space + 3; for ($j = 0; $j < sizeof($orderlines); $j++) { if ($orderlines[$j]->sku != $orderarticle->sku) { $qtt = round($orderlines[$j]->qty_ordered); $pdf->Text(10, 98 + $space, $qtt . " " . GetEinheitASCII($orderlines[$j]->einheit, GetVPE($orderlines[$j]->vpe)) . " " . $orderlines[$j]->name, 0, 1, 'L'); $space = $space + 3; } } } $pdf->SetFont('Helvetica', 'B', 10); $pdf->Text(80, 140, "Seite " . $page . " / " . $AnzRes, 0, 1, 'R'); $pdf->EAN13(10, 55, $orderarticle->ean, 8, 0.3); $pdf->Text(45, 60, "<= ARTIKELNUMMER"); $txt = str_pad($order->order_number, 12, '0', STR_PAD_LEFT); $pdf->EAN13(10, 130, $txt, 8, 0.3); $pdf->Text(45, 135, "<= Auftragsnummer"); } } if ($singleorder == true) { $nomFacture = getcwd() . "/upload/Reservierungen_" . $order->order_number . ".pdf"; $pdf->Output($nomFacture); echo "<span style=\"font-size: 12pt;color:#000000;\" >Reservierungszettel für Bestellung <a href=\"upload/Reservierungen_" . $order->order_number . ".pdf" . "\">" . $order->order_number . "</a> drucken.</spawn><br><br>"; } if (db_exists($servername, $username, $password, $dbname)) { // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "UPDATE `orders` SET status=\"printed\" WHERE increment_id like '" . $order->order_number . "'"; MakeOrderHistoryEntry($conn, $order->order_number, "RESPRINTED", "Reservierungszettel wurden gedruckt."); $result = $conn->query($sql); } } else { echo "<span style=\"font-size: 12pt;color:#ff0000;\" >Bestellung <a href=\"order.php" . "?MKZ=" . $MKZ . "&UPG=" . $UGP . "&order=" . $order->order_number . "&function=ShowTheOrder\">" . $order->order_number . "</a> hat Datenfehler. Bittes zuerst korrigieren</spawn><br><br>"; } }