jb-data.de/scripts/__re_test.php
2025-08-11 22:23:30 +02:00

221 lines
No EOL
9.5 KiB
PHP

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1); // Wenn fertig auf 0!
require('lib/config.php');
require('lib/mysql.class.php');
$GLOBALS['mysql'] = new mysql(CONFIG_MYSQL_HOST,CONFIG_MYSQL_USER,CONFIG_MYSQL_PW,CONFIG_MYSQL_DB);
$_GET['rID']=1;
$firmendaten = $GLOBALS['mysql']->query_single("SELECT * FROM firmendaten WHERE id = 1");
//echo "<pre>";
//print_r($firmendaten);
//echo "</pre>";
$check_rechnung = $GLOBALS['mysql']->query_single("SELECT * FROM rechnung WHERE rID = '".$_GET['rID']."'");
if($check_rechnung['num_rows'] != 0) {
$check_rechnung['posArray'] = unserialize(base64_decode($check_rechnung['posArray']));
echo "<pre>";
print_r($check_rechnung);
echo "</pre>";
}
require('lib/fpdf.php');
//--------------------------------
//-------------------- Variablen -
//--------------------------------
$renr="SR-10001";
$lagernr="PLX-0815";
$re_tag=2;
$re_monat=2;
$re_jahr=2015;
// 1. Demo-Datensatz
$adata['1']['pos']="1";
$adata['1']['Beschreibung1']="bunt,rund und hässlich";
$adata['1']['Beschreibung2']="stinkend verpackt in Papier";
$adata['1']['Beschreibung3']="bla bla";
$adata['1']['Beschreibung4']="";
$adata['1']['mwst']="19";
$adata['1']['menge']="4";
$adata['1']['epreis']="1.99";
// $adata['1']['gpreis']="1";
//--------------------------------
//-------------------- pdf starten
//--------------------------------
class PDF extends FPDF {
function Footer() { //Fusszeile(n)
$this->SetY(-20);
$this->SetFont('Helvetica','',8);
$this->Cell(7,2," ",'0','0','L','0');
$this->Cell(190,2," ",'T','1','0','0');
$this->Cell(7,3," ",'0','0','L','0');
$this->Cell(45,3,"OnlineDeals Hainichen",'0','0','0','0');
$this->Cell(45,3,"Tel.: 037207/579181",'0','0','0','0');
$this->Cell(50,3,"Volksbank Mittweida",'0','0','0','0');
$this->Cell(40,3,"USt-IdNr. ",'0','1','0','0');
$this->Cell(7,3," ",'0','0','L','0');
$this->Cell(45,3,"Inh. Sven Nestler",'0','0','0','0');
$this->Cell(45,3,"E-Mail: onlinedeals@online.de",'0','0','0','0');
$this->Cell(50,3,"BIC:GENODEF1MIW",'0','0','0','0');
$this->Cell(40,3,"222/466/00140G28/1",'0','1','0','0');
$this->Cell(7,3," ",'0','0','L','0');
$this->Cell(45,3,utf8_decode("Käthe- Kollwitz- Str. 34a"),'0','0','0','0');
$this->Cell(45,3," ",'0','0','0','0');
$this->Cell(50,3,"IBAN: DE04870961240197061596",'0','0','0','0');
$this->Cell(40,3,"Finanzamt Mittweida",'0','1','0','0');
$this->Cell(7,3," ",'0','0','L','0');
$this->Cell(45,3,"09661 Hainichen",'0','0','0','0');
$this->Cell(45,3," ",'0','0','0','0');
$this->Cell(50,3,"KTO Inh.: Sven Nestler",'0','0','0','0');
$this->Cell(40,3," ",'0','1','0','0');
}
}
$pdf = new PDF('P','mm','A4');
$pdf->AddPage();
$pdf->Image('public/images/od_logo.png', 100,15,120,20);
$pdf->Write(14,"\n\n");
$pdf->SetFont('Helvetica','U',7); $pdf->SetTextColor(0,0,0); $pdf->SetFillColor(255,255,255);
$pdf->Cell(7,5," ",'0','0','L','0'); $pdf->Cell(110,3,utf8_decode("OnlineDeals Hainichen Käthe-Kollwitz-Str.34a 09661Hainichen"),'0','1','L','1');
$pdf->SetFont(''); $pdf->Cell(110,3," ",'0','1','L','1');
$pdf->SetFont('Helvetica','B',10); $pdf->SetTextColor(0,0,0); $pdf->SetFillColor(255,255,255);
$pdf->Cell(7,5," ",'0','0','L','0'); $pdf->Cell(110,5,utf8_decode($check_rechnung['empfz1']),'0','0','L','0'); $pdf->Cell(70,5,utf8_decode("OnlineDeals Hainichen"),'0','1','R','1');
$pdf->Cell(7,5," ",'0','0','L','0'); $pdf->Cell(110,5,utf8_decode($check_rechnung['empfz2']),'0','0','L','0'); $pdf->Cell(70,5,utf8_decode("Käthe-Kollwitz-Str. 34a"),'0','1','R','1');
$pdf->Cell(7,5," ",'0','0','L','0'); $pdf->Cell(110,5,utf8_decode($check_rechnung['empfz3']),'0','0','L','0'); $pdf->Cell(70,5,utf8_decode("09661 Hainichen"),'0','1','R','1');
$pdf->Cell(7,5," ",'0','0','L','0'); $pdf->Cell(110,5,utf8_decode($check_rechnung['empfz4']),'0','0','L','1'); $pdf->Cell(70,5,utf8_decode(" "),'0','1','R','1');
$pdf->Cell(7,5," ",'0','0','L','0'); $pdf->Cell(110,5," ",'0','0','L','1'); $pdf->Cell(70,5,utf8_decode("Tel.: 037207/579181"),'0','1','R','1');
$pdf->Cell(7,5," ",'0','0','L','0'); $pdf->Cell(110,5," ",'0','0','L','1'); $pdf->Cell(70,5,utf8_decode("E-Mail: onlinedeals@online.de"),'0','1','R','1');
$pdf->Write(8,"\n"); $pdf->SetFont('Helvetica','BI',20);
$pdf->Cell(7,5," ",'0','0','L','0');$pdf->Cell(110,8,"Storno-Rechnung",'0','1','L','1');
$pdf->Write(4,"\n");
$pdf->SetFont('Helvetica','B',10);
$pdf->Cell(7,5," ",'0','0','L','0'); $pdf->Cell(60,5,"Rechnung Nr.: ".($check_rechnung['rNr']),'0','0','L','1');
$pdf->Cell(50,5,"Lager Nr.: ".($check_rechnung['lagerNr']),'0','0','L','1');
$pdf->Cell(70,5,"Datum: ".(sprintf("%02d",$re_tag)).".".(sprintf("%02d",$re_monat)).".".($re_jahr),'0','1','R','1');
$pdf->Cell(8,5," ",'0','0','L','0');$pdf->Cell(178,5," ",'B','1','L','1');
$pdf->Cell(8,5," ",'0','0','L','0');$pdf->Cell(178,5," ",'0','1','L','1');
//- Tabellenkopf -
$pdf->SetFillColor(90,90,90); $pdf->SetTextColor(255,255,255); $pdf->SetFont('Helvetica','B',10);
$pdf->Cell(8,5," ",'0','0','L','0');
$pdf->Cell(10,5,"Pos",'1','0','L','1');
$pdf->Cell(70,5,"Artikelbeschreibung",'1','0','L','1');
$pdf->Cell(20,5,"MwSt.",'1','0','R','1');
$pdf->Cell(18,5,"Anzahl",'1','0','R','1');
$pdf->Cell(30,5,"Einzelpreis",'1','0','R','1');
$pdf->Cell(30,5,"Gesamtpreis",'1','1','R','1');
$tmpgpreis=0; $endpreis=0;
//- Tabelle -
$pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0,0,0); $pdf->SetFont('Helvetica','',10);
//------------------------------------------------------------------------------------------------- Schleife Anfang
if($adata['1']['Beschreibung2']!="") {
$pdf->Cell(8,5," ",'0','0','L','0');
$pdf->Cell(10,5,$adata['1']['pos'],'LR','0','L','0');
$pdf->Cell(70,5,utf8_decode($adata['1']['Beschreibung1']),'LR','0','L','0');
$pdf->Cell(20,5,$adata['1']['mwst']." %",'LR','0','R','0');
$pdf->Cell(18,5,$adata['1']['menge'],'LR','0','R','0');
$pdf->Cell(30,5,$adata['1']['epreis']." EUR",'LR','0','R','0');
/*** Preisberechnung ***/ $tmpgpreis=$adata['1']['menge']*$adata['1']['epreis']; $endpreis=$endpreis+$tmpgpreis;
$pdf->Cell(30,5,$tmpgpreis." EUR",'LR','1','R','0');
} else {
$pdf->Cell(8,5," ",'0','0','L','0');
$pdf->Cell(10,5,$adata['1']['pos'],'BRL','0','L','0');
$pdf->Cell(70,5,utf8_decode($adata['1']['Beschreibung1']),'BRL','0','L','0');
$pdf->Cell(20,5,$adata['1']['mwst']." %",'BRL','0','R','0');
$pdf->Cell(18,5,$adata['1']['menge'],'BRL','0','R','0');
$pdf->Cell(30,5,$adata['1']['epreis']." EUR",'BRL','0','R','0');
/*** Preisberechnung ***/ $tmpgpreis=$adata['1']['menge']*$adata['1']['epreis']; $endpreis=$endpreis+$tmpgpreis;
$pdf->Cell(30,5,$tmpgpreis." EUR",'BRL','1','R','0');
}
if($adata['1']['Beschreibung2']!="") {
if($adata['1']['Beschreibung3']!="") {
$pdf->Cell(8,5," ",'0','0','L','0');
$pdf->Cell(10,5," ",'LR','0','L','0');
$pdf->Cell(70,5,utf8_decode($adata['1']['Beschreibung2']),'LR','0','L','0');
$pdf->Cell(20,5," ",'LR','0','R','0');
$pdf->Cell(18,5," ",'LR','0','R','0');
$pdf->Cell(30,5," ",'LR','0','R','0');
$pdf->Cell(30,5," ",'LR','1','R','0');
} else {
$pdf->Cell(8,5," ",'0','0','L','0');
$pdf->Cell(10,5," ",'BRL','0','L','0');
$pdf->Cell(70,5,utf8_decode($adata['1']['Beschreibung2']),'BRL','0','L','0');
$pdf->Cell(20,5," ",'BRL','0','R','0');
$pdf->Cell(18,5," ",'BRL','0','R','0');
$pdf->Cell(30,5," ",'BRL','0','R','0');
$pdf->Cell(30,5," ",'BRL','1','R','0');
}
}
if($adata['1']['Beschreibung3']!="") {
if($adata['1']['Beschreibung4']!="") {
$pdf->Cell(8,5," ",'0','0','L','0');
$pdf->Cell(10,5," ",'RL','0','L','0');
$pdf->Cell(70,5,utf8_decode($adata['1']['Beschreibung3']),'RL','0','L','0');
$pdf->Cell(20,5," ",'RL','0','R','0');
$pdf->Cell(18,5," ",'RL','0','R','0');
$pdf->Cell(30,5," ",'RL','0','R','0');
$pdf->Cell(30,5," ",'RL','1','R','0');
} else {
$pdf->Cell(8,5," ",'0','0','L','0');
$pdf->Cell(10,5," ",'BRL','0','L','0');
$pdf->Cell(70,5,utf8_decode($adata['1']['Beschreibung3']),'BRL','0','L','0');
$pdf->Cell(20,5," ",'BRL','0','R','0');
$pdf->Cell(18,5," ",'BRL','0','R','0');
$pdf->Cell(30,5," ",'BRL','0','R','0');
$pdf->Cell(30,5," ",'BRL','1','R','0');
}
}
if($adata['1']['Beschreibung4']!="") {
$pdf->Cell(8,5," ",'0','0','L','0');
$pdf->Cell(10,5," ",'BRL','0','L','0');
$pdf->Cell(70,5,utf8_decode($adata['1']['Beschreibung4']),'BRL','0','L','0');
$pdf->Cell(20,5," ",'BRL','0','R','0');
$pdf->Cell(18,5," ",'BRL','0','R','0');
$pdf->Cell(30,5," ",'BRL','0','R','0');
$pdf->Cell(30,5," ",'BRL','1','R','0');
}
//gesamtsumme
// $pdf->Cell(25,8," ",'0','1','R','1');
$pdf->Cell(8,5," ",'0','0','L','0'); $pdf->Cell(178,4," ",'T','1','R','0');
$pdf->Cell(8,5," ",'0','0','L','0'); $pdf->Cell(178,4," ",'B','1','R','0');
$pdf->Cell(141,4," ",'0','1','L','0');
$pdf->Cell(151,4,"Zwischensumme:",'0','0','R','1'); $pdf->Cell(37,4,(sprintf("%01.2f",$check_rechnung['ges_netto']))." EUR",'0','1','R','1');
$pdf->Cell(151,4,"zzgl. 19% MwSt.",'0','0','R','1'); $pdf->Cell(37,4,(sprintf("%01.2f",$check_rechnung['ges_mwst']))." EUR",'0','1','R','1');
$pdf->Cell(151,4,"Gesamtbetrag:",'0','0','R','1'); $pdf->Cell(37,4,(sprintf("%01.2f",$check_rechnung['ges_brutto']))." EUR",'0','1','R','1');
if($check_rechnung['ges_brutto']>9999) {
$pdf->Cell(188,4,"===========",'0','1','R','1');
} else {
$pdf->Cell(188,4,"============",'0','1','R','1');
}
//---------
$pdf->Output('rechnung_'.($check_rechnung['rNr']).'.pdf','I');
exit();
?>