function a4Lieferschein_pdf_DB($ls_id=false){
require_once("config/connect.php");
require_once("global_functions.php");
require_once('include/extended_fpdf.php');
global $qrImg_temp_dir, $errorCorrectionLevel, $matrixPointSize, $qrMargin;
$A4TmplVersion="01"; # kp 2018 11 02 sITpos Standard A4 Lieferschein Templ
$fontConfig=SCHRIFT_AUSDRUCK_PDF_A4;
if ( strpos(strtolower($fontConfig), 'arial') !== false || strpos(strtolower($fontConfig), 'helvetica') !== false ||
strpos(strtolower($fontConfig), 'sans serif') !== false ){ $pdfFont="Arial"; }
else if ( strpos(strtolower($fontConfig), 'times') !== false || strpos(strtolower($fontConfig), 'roman') !== false ||
(strpos(strtolower($fontConfig), 'serif') !== false && strpos(strtolower($fontConfig), 'sans') == false)) { $pdfFont="Times"; }
else if (strpos(strtolower($fontConfig), 'courier') !== false ) { $pdfFont="Courier"; }
else {$pdfFont="Arial"; }
preg_match('/\d+px | \d+pt/', $fontConfig, $m);
preg_match('/\d+/', $m[0], $match);
$pdfFontSize=$match[0];
$lineHeight=$pdfFontSize/2.5;
$bonWidth=preg_replace('/[^\d]/', '', AUSDRUCK_GESAMTE_BREITE);
$printer=mysql_fetch_array(mysql_query("SELECT win_drucker_name, drucker_margin_pdf, zoom_factor FROM drucker
WHERE LOWER(ist_a4) = 'ja' AND LOWER(ist_lieferscheindrucker) = 'ja' "));
$drucker=$printer[0];
$margin=$printer[1];
$margins=explode(",", $margin);
if(isset($margins[2]))$marginLR=preg_replace('/\D/', '', $margins[2]); else $marginLR=0;
if(isset($margins[1]))$marginBottom=preg_replace('/\D/', '', $margins[1]); else $marginBottom=0;
if(isset($margins[0]))$marginTop=preg_replace('/\D/', '', $margins[0]); else $marginTop=0;
if($marginLR < 10) $marginLR = 10;
if(is_int($printer[2]) || is_float($printer[2])) $zoomF=$printer[2];
else $zoomF=1;
$pageWidth=210-($marginLR*2);
$pdfPrinterData=$printer;
/* kommt von A4 Rechnung
$bonData = mysql_fetch_array(mysql_query("SELECT kunden_id, verkaufer_id, gesamt_summe, retourgeld, bon_erstellt_datum,
storno_datum, gastro_tisch_id, qr_string, auftragsschein_nr, zusatztext
FROM abgeschlossener_bon
LEFT JOIN dep ON abgeschlossener_bon.bon_id = dep.beleg_nr
WHERE bon_id=".$bon_id ." "));
*/
$bonData = mysql_fetch_array(mysql_query("SELECT kunden_id, lieferschein_erstellt_datum, lieferschein_id, auftrags_nr, id FROM lieferschein_referenz
WHERE id='".$ls_id."' "));
if(!$bonData) $xx=mysql_error();
writeLog(basename( __FILE__)." ". __LINE__ , " ".$bonData['id']." - ".$bonData['lieferschein_id']." - ".$bonData['lieferschein_erstellt_datum']." ls id -> ".$ls_id);
class PDF extends PDF_MemImage{
function Header() {
$marginTop=$this->marginTop;
$marginLR=$this->marginLR;
$pdfFontSize=$this->pdfFontSize;
$pdfFont=$this->pdfFont;
$lineHeight=$this->lineHeight;
$bonId=$this->bonId;
$bonData=$this->bonData;
$this->SetFont($pdfFont, '', $pdfFontSize);
$calcH=0;
if(defined('AUSDRUCK_A4_LOGO_POSITION') && AUSDRUCK_A4_LOGO_POSITION != "")$logoPos=AUSDRUCK_A4_LOGO_POSITION;
else $logoPos='R, 50';
$logoPos=explode(',', $logoPos);
if(isset($logoPos[0]) && $logoPos[0] != '')$logoPos[0]=$logoPos[0];
else $logoPos[0] = 'R';
if(isset($logoPos[1]) && $logoPos[1] > 20)$imgWidth=$logoPos[1];
else $imgWidth = 50;
if(strtolower($logoPos[0]) == 'r') $leftPos=210-($imgWidth+$marginLR);
else if(strtolower($logoPos[0]) == 'l') $leftPos=$marginLR;
else if(strtolower($logoPos[0]) == 'c') $leftPos=(210-$imgWidth)/2;
if(defined('AUSDRUCK_A4_ADRESS_POSITION') && AUSDRUCK_A4_ADRESS_POSITION != "")$adressPos=AUSDRUCK_A4_ADRESS_POSITION;
else $adressPos='L, 30, R';
$adressPos=explode(',', $adressPos);
if(isset($adressPos[0]) && $adressPos[0] != '')$adressPos[0]=$adressPos[0];
else $adressPos[0]= 'L';
if(isset($adressPos[1]) && $adressPos[1] > 20)$adressCellWidth=$adressPos[1];
else $adressCellWidth=100;
if(isset($adressPos[2]) && $adressPos[2] != '')$adressPos[2]=$adressPos[2];
else $adressPos[2]= 'L';
if ($this->PageNo() == 1){
$getImg=mysql_fetch_assoc(mysql_query("SELECT image, name, imgx, imgy FROM images WHERE name='a4logo'"));
if(defined('AUSDRUCK_LOGO_RECHNUNGSBON_PDF') && strtolower(AUSDRUCK_LOGO_RECHNUNGSBON_PDF) == 'ja' && $getImg != false){
$zuzX=$this->GetY();
if($getImg == true){
$fac=$getImg['imgx']/$imgWidth;
$calcH=$getImg['imgy']/$fac;
$this->MemImage($getImg['image'], $leftPos, $marginTop, $imgWidth, 0); // breite ist definiert höhe auf null heißt wird calkuliert
}
if( strtolower($logoPos[0]) == 'r' && strtolower($adressPos[0]) == 'r'){
$this->SetXY($leftPos, $marginTop+$calcH);
$curYpos=$this->GetY()+$lineHeight;
}
else $curYpos=$marginTop;
}
else {
$curYpos=$marginTop;
}
$ibanTx="";
$kopfQl=mysql_query("SELECT name, wert FROM konfiguration WHERE name LIKE 'AUSRUCK_KOPFZEILE_%' AND wert <> '' ORDER BY name");
while($kopfR=mysql_fetch_array($kopfQl)){
$wert=$kopfR["wert"];
if(strpos(strtolower($kopfR["wert"]), 'uid') !== false || $kopfR["name"] == 'AUSRUCK_KOPFZEILE_IBAN') continue;
if(strtolower(trim($adressPos[0])) == 'r' && strtolower(trim($adressPos[2])) == 'r'){
$this->SetXY(210-($adressPos[1]+$marginLR), $curYpos);
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'R');
}
else if(strtolower(trim($adressPos[0])) == 'c' && strtolower($logoPos[0]) == 'c'){
# wenn logo und adresse in der mitte stehen wird logo oben normal positioniert und die adresse
# nach unten geschoben, der align wert wird trotzdem aus der konfig genommen, macvcht aber eh nur center sinn
$this->SetXY((210-$adressPos[1])/2, $curYpos+$calcH);
$adrAlign=strtoupper(trim($adressPos[2]));
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, $adrAlign);
}
else if(strtolower(trim($adressPos[0])) == 'r' && strtolower(trim($adressPos[2])) == 'c'){
$this->SetXY(210-($adressPos[1]+$marginLR), $curYpos);
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'C');
}
else if(strtolower(trim($adressPos[0])) == 'r' && strtolower(trim($adressPos[2])) == 'l'){
$this->SetXY(210-($adressPos[1]+$marginLR), $curYpos);
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'L');
}
else if(strtolower(trim($adressPos[0])) == 'c' && strtolower(trim($adressPos[2])) == 'r'){
$this->SetXY((210-$adressPos[1])/2, $curYpos);
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'R');
}
else if(strtolower(trim($adressPos[0])) == 'c' && strtolower(trim($adressPos[2])) == 'c'){
$this->SetXY((210-$adressPos[1])/2, $curYpos);
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'C');
}
else if(strtolower(trim($adressPos[0])) == 'c' && strtolower(trim($adressPos[2])) == 'l'){
$this->SetXY((210-$adressPos[1])/2, $curYpos);
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'L');
}
else if(strtolower(trim($adressPos[0])) == 'l' && strtolower(trim($adressPos[2])) == 'r'){
$this->SetXY($marginLR, $curYpos);
$this->Cell($adressCellWidth, $lineHeight, strip_tags($kopfR['wert']), 0, 1, 'R');
}
else if(strtolower(trim($adressPos[0])) == 'l' && strtolower(trim($adressPos[2])) == 'c'){
$this->SetXY($marginLR, $curYpos);
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'C');
}
else if(strtolower(trim($adressPos[0])) == 'l' && strtolower(trim($adressPos[2])) == 'l'){
$this->SetXY($marginLR, $curYpos);
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'L');
}
else{
$this->SetXY($marginLR, $curYpos);
$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'L');
}
$curYpos+=$lineHeight; # die Zellen sind absolut positioniert, deswegen muss hier die Y position immer um eine lineHeight erhöht werden
}
$kundenId=$bonData["kunden_id"];
$this->SetY(55);
if($kundenId > 0 ){
$custData="";
$kundenDetails=mysql_fetch_assoc(mysql_query("SELECT * FROM kunden WHERE id=".$kundenId." "));
if(strlen($kundenDetails['anrede']) > 0) $anrede=$kundenDetails['anrede']." ";
else $anrede="";
if(strlen($kundenDetails['titel']) > 0) $titel=$kundenDetails['titel']." ";
else $titel="";
if(strlen($kundenDetails['vorname']) > 0 && strlen($kundenDetails['nachname']) > 0) $kdName=$kundenDetails['vorname']." ".$kundenDetails['nachname'];
else if(strlen($kundenDetails['nachname']) > 0 &&
(strlen($kundenDetails['vorname']) == 0 || $kundenDetails['vorname'] == false ))$kdName=$kundenDetails['nachname'];
else if(strlen($kundenDetails['vorname']) > 0 &&
(strlen($kundenDetails['nachname']) == 0 || $kundenDetails['nachname'] == false ))$kdName=$kundenDetails['vorname'];
else $kdName="";
$kdName=$anrede.$titel.$kdName;
if(strlen($kundenDetails['Firma']) > 0)$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['Firma'])), 0, 1, 'L');
if(strlen($kdName) > 0 )$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kdName)), 0, 1, 'L');
if(strlen($kundenDetails['strasse1']) > 0)$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['strasse1'])), 0, 1, 'L');
if(strlen($kundenDetails['strasse2']) > 0)$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['strasse2'])), 0, 1, 'L');
if($kundenDetails['plz'] != '' || $kundenDetails['Ort'] != '')
$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['plz']))." ".iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['Ort'])), 0, 1, 'L');
if(strlen($kundenDetails['kundennummer']) > 1){
$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', "Versicherungs Nr: ".$kundenDetails['kundennummer']), 0, 1, 'L');
$this->Cell(0, 25, "", 0, 1, 'C');
}
else $this->Cell(0, $lineHeight+25, "", 0, 1, 'C');
$this->Cell(0, $lineHeight, "", 'B', 1, 'C'); # trennlinie unterhalb von Kunden Druck, falls Kunde ausgegeben wird
}
else {
/*
kommzt vom A4 Rechnungs Template
$zahlung=mysql_query("SELECT Name FROM abgeschlossener_bon_zahlung WHERE bon_id=".$bonId." ");
while($zahlR=mysql_fetch_array($zahlung)){
$zahlForm=$zahlR['Name'];
}
if(mysql_num_rows ($zahlung) > 1 ) $zahlForm="Gemischte Zahlungsform";
*/
$this->Cell(0, $lineHeight, "Lieferschein undefinierter Kunde", 0, 1, 'L');
$this->Cell(0, $lineHeight, "", 0, 1, 'L');
$this->Cell(0, $lineHeight, "", 0, 1, 'L');
$this->Cell(0, $lineHeight, "", 0, 1, 'L');
$this->Cell(0, $lineHeight, "", 'B', 1, 'C');
}
}
else { # bei mehrseitigen ausdruck wird ab der zweiten seite ein reduzierter header gedruckt
if(defined('AUSDRUCK_LOGO_RECHNUNGSBON_PDF') && strtolower(AUSDRUCK_LOGO_RECHNUNGSBON_PDF) == 'ja'){
$getImg=mysql_fetch_assoc(mysql_query("SELECT image, name, imgx, imgy FROM images WHERE name='a4logo'"));
if($getImg == true){
$fac=$getImg['imgx']/$imgWidth;
$calcH=$getImg['imgy']/$fac;
$this->MemImage($getImg['image'], $leftPos, $marginTop, $imgWidth, 0); // breite ist definiert höe auf null heißt wird calkuliert
}
}
$this->Ln($calcH+$marginTop+10);
if($this->checkPageBreak == true && $this->produktWhileEnd == false){
$pageWidth=210-($this->marginLR*2);
$colA_width=($pageWidth*.12)*$this->zoomF;
$colB_width=($pageWidth*.38)*$this->zoomF;
$colC_width=($pageWidth*.25)*$this->zoomF;
$colD_width=($pageWidth*.25)*$this->zoomF;
$this->SetFillColor(90);
$this->SetTextColor(255);
$this->Cell($colA_width, $lineHeight*1.3, "Stk.", 0, 0, 'R', true);
$this->Cell($colB_width, $lineHeight*1.3, "Bezeichnung", 0, 0, 'L', true);
$this->Cell($colC_width, $lineHeight*1.3, "Einzel", 0, 0, 'R', true);
$this->Cell($colD_width, $lineHeight*1.3, "Ges. Brutto", 0, 1, 'R', true);
$this->Cell(0, $lineHeight/3, "", 0, 1, 'C');
$this->SetFillColor(255);
$this->SetTextColor(0);
}
}
}
function docData(){
$marginLR=$this->marginLR;
$pdfFontSize=$this->pdfFontSize;
$pdfFont=$this->pdfFont;
$lineHeight=$this->lineHeight;
$bonId=$this->bonId;
$bonData=$this->bonData;
#$invoiceSumRaw=$bonData["gesamt_summe"];
#$gesamtsumme_brutto=number_format($bonData["gesamt_summe"],2,",",".");
$datetime=$bonData["lieferschein_erstellt_datum"];
#$stornoDatetime=$bonData["storno_datum"];
#$retourgeld=$bonData["retourgeld"];
#$verkauferId=$bonData["verkaufer_id"];
#$gastroTischId=$bonData["gastro_tisch_id"];
$lieferscheinNr=$bonData["lieferschein_id"];
$auftragsscheinNr=$bonData["auftrags_nr"];
$refId=$bonData['id'];
$this->SetFont($pdfFont, '', $pdfFontSize);
$pageWidth=210-($marginLR*2);
$dDate = strtotime( $datetime );
$datetime = "Datum: ".date( 'j.n.Y H:i', $dDate );
$this->Cell($pageWidth/3, $lineHeight*1.2, LIEFERSCHEIN_BENENNUNG." ".$lieferscheinNr, 0, 0, 'L');
#$this->Cell($pageWidth/3, $lineHeight*1.2, "Kassen Id: ".KASSA_ID, 0, 0, 'L');
$this->Cell($pageWidth/3, $lineHeight*1.2, "", 0, 0, 'L');
$this->Cell($pageWidth/3, $lineHeight*1.2, $datetime, 0, 1, 'R');
if($auftragsscheinNr > 0){
#$this->Cell($pageWidth/3, $lineHeight*1.2, AUFTRAGSSCHEIN_BENENNUNG.$auftragsscheinNr, 0, 1, 'L');
}
/*
if(defined("VERKAEUFER_AUF_BON_DRUCKEN") && strtolower(VERKAEUFER_AUF_BON_DRUCKEN)=='ja'){
$userQl=mysql_fetch_array(mysql_query("SELECT name FROM benutzer WHERE id = ".$verkauferId." "));
if($userQl==true) $this->Cell($pageWidth/3, $lineHeight*1.2, AUSDRUCK_VERKAUFER_AUF_BON_TEXT." ".iconv('UTF-8', 'windows-1252', $userQl[0]), 0, 0, 'L');
}
else $this->Cell($pageWidth/3, $lineHeight*1.2, "", 0, 0, 'L');
if( (defined('GASTRO_VERSION') && strtolower(GASTRO_VERSION) == 'ja')
&& (defined('GASTRO_TISCHNAME_AUF_BON_DRUCKEN') && strtolower(GASTRO_TISCHNAME_AUF_BON_DRUCKEN) == 'ja')){
$tName=mysql_fetch_array(mysql_query("SELECT raum.name AS raumN, tischName FROM tische
LEFT JOIN raum ON tische.raum = raum.id
WHERE tische.id = '".$gastroTischId."' LIMIT 1 "));
$raumName=$tName['raumN'];
if (preg_match("/(zimmer|apartment|ferienwohnung|suite|studio)/i", $raumName)) {
if (preg_match("/(zimmer|apartment|ferienwohnung|suite|studio)/i", $tName['tischName'])){
$this->Cell($pageWidth/3, $lineHeight*1.2, $tName['tischName'], 0, 0, 'L');
}
else $this->Cell($pageWidth/3, $lineHeight*1.2, "Zimmer: ".$tName['tischName'], 0, 0, 'L');
}
else $this->Cell($pageWidth/3, $lineHeight*1.2, "Tisch: ".$tName['tischName'], 0, 0, 'L');
}
else $this->Cell($pageWidth/3, $lineHeight*1.2, "", 0, 0, 'L');
$this->Cell($pageWidth/3, $lineHeight*1.2, iconv('UTF-8', 'windows-1252', "Beträge in EUR"), 0, 1, 'R');
if(strlen($bonData["zusatztext"]) > 0){
$this->Cell(0, $lineHeight*.5, "", "T", 1, 'C');
$this->MultiCell( $pageWidth, $lineHeight, iconv('UTF-8', 'windows-1252', $bonData['zusatztext']), 0, 'L', 0);
$this->Cell(0, $lineHeight*.2, "", "T", 1, 'C');
}
else $this->Cell(0, $lineHeight*.5, "", "T", 1, 'C');
*/
$colA_width=($pageWidth*.12)*$this->zoomF;
$colB_width=($pageWidth*.38)*$this->zoomF;
$colC_width=($pageWidth*.25)*$this->zoomF;
$colD_width=($pageWidth*.25)*$this->zoomF;
$this->SetFillColor(90);
$this->SetTextColor(255);
$this->Cell($colA_width, $lineHeight*1.3, "Stk.", 0, 0, 'R', true);
$this->Cell($colB_width, $lineHeight*1.3, "Bezeichnung", 0, 0, 'L', true);
$this->Cell($colC_width, $lineHeight*1.3, "Einzel", 0, 0, 'R', true);
$this->Cell($colD_width, $lineHeight*1.3, "Ges. Brutto", 0, 1, 'R', true);
$this->Cell(0, $lineHeight/3, "", 0, 1, 'C');
$this->SetFillColor(255);
$this->SetTextColor(0);
/*
$sql_produkte = mysql_query("SELECT abgeschlossener_bon_produkte.ID, produkt_id, tax_rate, REFERENCE, CODE, NAME, PRICEBUY, PRICESELL,
CATEGORY, TAXCAT, tax_rate, DISPLAY, VARPRICE, PRINTNAME, NEGATIVEPRICE, PRODUKTORDER, SICHTBAR, stueck,
has_childs, parent_id, isparent_id, childPrint, lsSource, lieferschein_id, lieferschein_erstellt_datum
FROM abgeschlossener_bon_produkte
LEFT JOIN lieferschein_referenz ON lsSource = lieferschein_referenz.id
WHERE bon_id='".$bonId."' ORDER BY lieferschein_referenz.id ASC, abgeschlossener_bon_produkte.ID ASC ");
*/
$sql_produkte = mysql_query("SELECT produkt_id, NAME, printname, PRICESELL, tax_rate, stueck
FROM lieferschein
WHERE ref_id ='".$refId."' ");
if (!$sql_produkte) {
echo "";
exit(1);
}
$countRows=mysql_num_rows($sql_produkte)*1;
$checkRows=0;
$this->checkPageBreak=0;
$lsGroup=false; # für den gruppenwechsel, sammelrechnung aus lieferscheine
$gesamtBetrag=0;
while ($row_produkt=mysql_fetch_assoc($sql_produkte)) {
$einzel_preis=$row_produkt["PRICESELL"];
$einzel_preis=$einzel_preis*(1+$row_produkt["tax_rate"]);
$summe=$einzel_preis*$row_produkt["stueck"];
$einzel_preis=number_format($einzel_preis,2,",",".");
$gesamtBetrag+=$summe;
/*
# COMBI ARTIKEL !!!
if($row_produkt['has_childs'] == 1 && $row_produkt['isparent_id'] > 0){
$findChilds=mysql_fetch_array(mysql_query("SELECT SUM(PRICESELL* (1 + tax_rate)) AS combiEinzelPr FROM abgeschlossener_bon_produkte
WHERE parent_id = ".$row_produkt['ID']." "));
$einzel_preis=number_format($findChilds['combiEinzelPr'],2,",",".");
$summe=$findChilds['combiEinzelPr']*$row_produkt["stueck"];
}
else if($row_produkt['parent_id'] > 0 && $row_produkt['childPrint'] == 0) continue;
*/
$stueck=$row_produkt["stueck"];
// Checke ob Stueck nachkomma hat oder nicht wenn ja, dann 2 Nachkommastellen ansonsten keine
if ( (int) $stueck == $stueck) {
$stueck_anzeige=number_format($stueck,0,"",".");
}
else $stueck_anzeige=number_format($stueck,2,",",".");
$summe=number_format($summe,2,",",".");
$printname=$row_produkt["printname"];
/*
if($row_produkt['parent_id'] > 0 && $row_produkt['childPrint'] == 1){
$ortstaxe=number_format($stueck*$row_produkt["PRICESELL"],2, ",", ".");
$einzel_preis='';
$stueck_anzeige='';
$summe='';
$printname=preg_replace('/€\s*0[,\.]00/', '€ '.$ortstaxe, $printname);
}
#
if(isset($row_produkt['lsSource']) && $row_produkt['lsSource'] > 0 && ($lsGroup != $row_produkt['lieferschein_id'])){
$headerTxt="Liefersch: ";
if(defined('LIEFERSCH_SAMMELRECHNUNG_GRUPPENHEADER')) $headerTxt=LIEFERSCH_SAMMELRECHNUNG_GRUPPENHEADER;
$dDate = strtotime($row_produkt['lieferschein_erstellt_datum']);
$dateTime = date( 'j.n.Y H:i', $dDate );
$lsHeader=iconv('UTF-8', 'windows-1252', LIEFERSCH_SAMMELRECHNUNG_GRUPPENHEADER.$row_produkt['lieferschein_id'].", ".$dateTime);
$headW=$this->getstringwidth($lsHeader);
if($lsGroup > 0)$this->Cell(0, $lineHeight/2, '', 0, 1, 'C');
$this->Cell(0, $lineHeight, $lsHeader, 0, 1, 'L');
$this->Cell($headW, 1, '', 'T', 1, 'L');
}
*/
$this->Cell($colA_width, $lineHeight, $stueck_anzeige, 0, 0, 'R');
# Einzelrabatt Zeile bilden, % -> gerade Zahl od Kommazahl
$rabattLine=false;
if(preg_match('/\d{1,},\d{1,}\%\sRabatt/', $printname, $matchRes)){
# Einzelrabatt Komma Zahl, steht mit "," im Produkt Table
$rabattLine=true;
$tmpPrintN=preg_split("/\d{1,},\d{1,}\%\sRabatt/", $printname);
if(isset($tmpPrintN[1]) && strlen($tmpPrintN[1]) > 0)$tmpPrintNameEnd="\n".trim($tmpPrintN[1]);
else $tmpPrintNameEnd="";
$printname=$tmpPrintN[0]."\n".trim($matchRes[0]." inkludiert").$tmpPrintNameEnd;
}
else if(preg_match('/\d{1,}%\sRabatt/', $printname, $matchRes)){
# Einzelrabatt gerade Zahl
$rabattLine=true;
$tmpPrintN=preg_split("/\d{1,}%\sRabatt/", $printname);
if(isset($tmpPrintN[1]) && strlen($tmpPrintN[1]) > 0)$tmpPrintNameEnd="\n".trim($tmpPrintN[1]);
else $tmpPrintNameEnd="";
$printname=$tmpPrintN[0]."\n".trim($matchRes[0]." inkludiert").$tmpPrintNameEnd;
}
if($this->getstringwidth(iconv('UTF-8', 'windows-1252', $printname)) > $colB_width || $rabattLine == true || strpos($printname, "\n")){
$posY=$this->GetY();
$posX=($colA_width + $colB_width + $marginLR );
$this->MultiCell( $colB_width, $lineHeight, iconv('UTF-8', 'windows-1252', $printname) , 0, 'L', 0); # border-0; align L, fill-0,
$posY_2=$this->GetY();
$this->SetXY($posX, $posY);
$this->Cell($colC_width, $lineHeight, $einzel_preis, 0, 0, 'R');
$this->Cell($colD_width, $lineHeight, $summe, 0, 1, 'R');
$this->SetY($posY_2);
}
else{
$this->Cell($colB_width, $lineHeight, iconv('UTF-8', 'windows-1252', $printname), 0, 0, 'L');
$this->Cell($colC_width, $lineHeight, $einzel_preis, 0, 0, 'R');
$this->Cell($colD_width, $lineHeight, $summe, 0, 1, 'R');
}
$checkRows++;
if($checkRows < $countRows) $this->checkPageBreak = true;
else $this->checkPageBreak = false;
#$lsGroup=$row_produkt['lieferschein_id'];
}
$this->produktWhileEnd=true;
$this->Cell(0, $lineHeight/2, "", 0, 1, 'C', 0);
$this->SetLineWidth(.5);
$this->SetDrawColor(90);
$this->SetFont($pdfFont,'B', $pdfFontSize);
$this->Cell($colA_width + $colB_width, $lineHeight*1.2, "Lieferschein Summe: ", "T", 0, 'L',0);
$this->Cell($colC_width + $colD_width, $lineHeight*1.2, number_format($gesamtBetrag,2,",","."), "T", 1, 'R',0);
$this->SetLineWidth(.2);
$this->SetDrawColor(250, 250, 250);
$this->SetFont($pdfFont,'', $pdfFontSize);
$this->Cell(0, $lineHeight*1.5, "", 0, 1, 'C');
$StColBlind_width=($pageWidth*.15)*$this->zoomF;
$StColA_width=($pageWidth*.20)*$this->zoomF;
$StColB_width=($pageWidth*.20)*$this->zoomF;
$StColC_width=($pageWidth*.20)*$this->zoomF;
$StColD_width=($pageWidth*.25)*$this->zoomF;
/*
$sql_tax = mysql_query("SELECT tax_rate, gesamt_betrag from abgeschlossener_bon_steuern WHERE bon_id='".$bonId."'");
if (! $sql_produkte){
echo "";
exit(1);
}
$qtyTaxRates=mysql_num_rows($sql_tax);
$taxBlockHeight=($lineHeight*$qtyTaxRates)+$lineHeight;
$currY=$this->GetY();
$restOnPage=$currY+$taxBlockHeight+AUSDRUCK_A4_FOOTER_HOEHE;
if($restOnPage > 275 ) $this->AddPage('','',false);
$this->Cell($StColBlind_width, $lineHeight, "", 0, 0, 'R');
$this->Cell($StColA_width, $lineHeight, "Steuersatz", 0, 0, 'R');
$this->Cell($StColB_width, $lineHeight, "Netto", 0, 0, 'R');
$this->Cell($StColC_width, $lineHeight, "Steuer", 0, 0, 'R');
$this->Cell($StColD_width, $lineHeight, "Brutto", 0, 1, 'R');
while ($rowTax=mysql_fetch_assoc($sql_tax)) {
$steuersatz=$rowTax["tax_rate"]*100;
$netto=$rowTax["gesamt_betrag"];
$steuer=$netto*$rowTax["tax_rate"];
$brutto=$netto+$steuer;
$brutto=number_format($brutto,2,",",".");
$netto=number_format($netto,2,",",".");
$steuer=number_format($steuer,2,",",".");
$this->Cell($StColBlind_width, $lineHeight, "", 0, 0, 'R');
$this->Cell( $StColA_width, $lineHeight, $steuersatz, 0, 0, 'R');
$this->Cell( $StColB_width, $lineHeight, $netto , 0, 0, 'R');
$this->Cell( $StColC_width, $lineHeight, $steuer, 0, 0, 'R');
$this->Cell( $StColD_width, $lineHeight, $brutto, 0, 1, 'R');
}
# das wird zahlungsform Print !!!!
$this->Cell( $StColD_width, $lineHeight, "", 0, 1, 'R');
$zahlungQl = mysql_query("SELECT Name, zahlbetrag_tatsaechlich FROM abgeschlossener_bon_zahlung WHERE bon_id='".$bonId."'");
$summe_zahlbetrag=0;
while ($zahlRow=mysql_fetch_assoc($zahlungQl)){
$zahlbetrag=$zahlRow["zahlbetrag_tatsaechlich"];
$summe_zahlbetrag+=$zahlbetrag;
$name=$zahlRow["Name"];
$zahlbetrag=number_format($zahlbetrag,2,",",".");
$this->Cell( $StColBlind_width+$StColA_width+$StColB_width, $lineHeight, iconv('UTF-8', 'windows-1252', $name), 0, 0, 'R');
$this->Cell( +$StColC_width+$StColD_width, $lineHeight, $zahlbetrag, 0, 1, 'R');
}
*/
} # ende function docdata
function Footer(){
$this->SetY(-AUSDRUCK_A4_FOOTER_HOEHE);
$this->SetFont($this->pdfFont, '', $this->pdfFontSize*.75);
$footerTxt=AUSDRUCK_A4_FOOTER_TXT;
$this->SetDrawColor(0);
$this->Cell(0, 2, "", "T", 1, 'C');
if (strpos($footerTxt, ';') !== false) {
$footerLines=explode(";", $footerTxt);
for($i=0; $i < sizeof($footerLines); $i++){
$this->Cell(0, $this->lineHeight, iconv('UTF-8', 'windows-1252', $footerLines[$i]), 0, 1, 'C');
}
}
else {
$this->Cell(0, $this->lineHeight, iconv('UTF-8', 'windows-1252', $footerTxt), 0, 1, 'C');
}
$this->Cell(0, $this->lineHeight, 'Seite '.$this->PageNo(). '/{nb}', 0, 1, 'R');
}
}
$pdf=new PDF('P','mm', 'A4');
$pdf->SetMargins($marginLR, $marginTop);
$pdf->header = 0;
$pdf->footer = 0;
# $pdf->addPage('','',false);
$pdf->pdfPrinterData=$pdfPrinterData;
$pdf->marginTop=$marginTop;
$pdf->marginLR=$marginLR;
$pdf->pdfFont=$pdfFont;
$pdf->pdfFontSize=$pdfFontSize;
$pdf->lineHeight=$lineHeight;
$pdf->bonId=$ls_id ;
$pdf->bonData=$bonData;
$pdf->zoomF=$zoomF;
$pdf->errorCorrectionLevel=$errorCorrectionLevel;
$pdf->matrixPointSize=$matrixPointSize;
$pdf->qrMargin=$qrMargin;
$pdf->qrImg_temp_dir=$qrImg_temp_dir;
$pdf->produktWhileEnd=false;
// $pdf->lieferscheinNr=$lieferscheinNr;
$pdf->checkPageBreak=false;
$pdf->SetAutoPageBreak(true, AUSDRUCK_A4_FOOTER_HOEHE+15);
$pdf->AddPage('','',false);
$pdf->docData();
$pdf->AliasNbPages('{nb}');
$lsNr=$bonData["lieferschein_id"];
if(defined('AUSDRUCK_A4_DOWNLOAD') && strtolower(AUSDRUCK_A4_DOWNLOAD) == 'ja'){
$outputTarget="docs/A4_ls_V".$A4TmplVersion."_".$lsNr."_".date('d_m_H_i').".pdf";
$writeFile=$pdf->Output($outputTarget, "F");
if($writeFile == ""){
return array("success", "browserPrint", $outputTarget, $lsNr, $outputTarget );
}
else{
return array("error", "browserPrint", $outputTarget, $lsNr, $outputTarget );
}
}
else{
$outputTarget=__DIR__ ."\docs\A4_ls_V".$A4TmplVersion."_".$lsNr."_".date('d_m_H_i').".pdf";
$command="C:\sitpos\pdfxchange\App\PDFV_Portable\PDFXCview.exe /print:printer=\"$drucker\" \"$outputTarget\" ";
$writeFile=$pdf->Output($outputTarget, "F");
exec($command, $output, $error_code);
if($writeFile == "" && $error_code == 0){
return array("success", "printerPrint", $outputTarget, $lsNr );
}
else{
return array("$error_code", "printerPrint", $outputTarget, $lsNr );
}
}
}