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

175 lines
7.3 KiB
PHP

<?php
ini_set('display_errors',0);
$tour=$_GET['tour'];
$timestamp_sonntag = strtotime("{$_GET['jahr']}-W{$_GET['kw']}-7");
$tag=date("d", $timestamp_sonntag);
$monat=date("m", $timestamp_sonntag);
$datum=$tag.".".$monat.".".$_GET['jahr'];
require('lib/fpdf.php');
class PDF extends FPDF {
function Footer() {
$this->SetY(-15);
$this->SetFont('Helvetica','',8);
$this->Cell(90,4,'JB-Transport.de - Bautzner Str. 67 - 04347 Leipzig','1','0','L','1');
$this->Cell(50,4,'***** Interne Liste - NON Public *****','1','0','L','1');
$this->Cell(30,4,'F. Teichert 2011-2020','1','0','L','1');
$this->SetFont('Helvetica','B',10);
$this->Cell(20,4,'Seite '.$this->PageNo().'/{nb}',1,1,'L',1);
}
function Header() {
$this->SetFont('Helvetica','B',20);
// $pdf->SetTextColor(0,160,230);
$this->SetFillColor(255,255,255); $this->SetTextColor(80,80,80);
$this->Cell(22,12,' ','0','1','L','1'); $this->SetFont('Helvetica','',16);
$timestamp_sonntag = strtotime("{$_GET['jahr']}-W{$_GET['kw']}-7"); $tag=date("d", $timestamp_sonntag); $monat=date("m", $timestamp_sonntag);
$this->Cell(160,8," ",'0','0','L','1'); $this->Cell(33,8,$tag.".".$monat.".".$_GET['jahr'],'0','1','L','1');
$this->SetFont('Helvetica','BI',20);
$this->Image('template/images/faz_logo_sonntag_neu.png', 8, 7);
$row_tour = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE tour3='".$_GET['tour']."'");
$this->Image('template/images/jb_logo2.png', 125, 7); //----------------jb logo
$tm = $GLOBALS['mysql']->query_single("SELECT * FROM fazs WHERE kw='".$_GET['kw']."' and jahr='".$_GET['jahr']."' and plz='".$_GET['tour']."' and abo!=0");
$this->Write(2,"\n");
$this->SetFillColor(255,255,255); $this->SetFont('Helvetica','',14);
$this->Cell(140,6,utf8_decode($row_tour['tour']." ".$row_tour['infotitel']),'LTB','0','L','1');
$this->SetTextColor(0,0,0);
$this->Cell( 50,6,utf8_decode($tm['num_rows']." Exemplare"),'RTB','1','R','1');
$this->Cell(170,2,' ','0','1','L','0');
$this->SetFillColor(100,100,100); $this->SetTextColor(255,255,255); $this->SetFont('Helvetica','BI',10);
$this->Cell(90,4,"Abonnent / Adresse",'1','0','L','1');
$this->Cell(80,4,"Zusatzinfos/Telefonnr.",'1','0','L','1');
$this->Cell(20,4,"zugestellt",'1','1','L','1');
$this->SetFillColor(255,255,255); $this->SetTextColor(0,0,0);
}
}
//$pdf=new PDF_AutoPrint(); $pdf->Open();
$pdf = new PDF('P','mm','A4');
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetAutoPageBreak(false);
// blau (0,160,230)
// Orange (240,150, 0)
// grau (200,200,200)
$key=0;
$pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0,0,0);
// $row_tour = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE id='".$_SESSION['fazplz']."'");
$a_tour = $GLOBALS['mysql']->query("SELECT * FROM fazs WHERE kw='".$_GET['kw']."' and jahr='".$_GET['jahr']."' and plz='".$_GET['tour']."' and abo!=0 order by strasse");
while($row = $a_tour->fetch_assoc()) {
if($key==20) {
$key=0;
$pdf->AddPage();
}
$pdf->SetFont('Helvetica','B',11);
$pdf->Cell(170,1.5,' ','0','1','L','0');
//--- 1. Zeile - Name und Anschrift
$zeile1a=$row['titel'].$row['name2'].", ".$row['name']." ".$row['name4'];
$pdf->Cell(90,5,utf8_decode($zeile1a),'LT','0','L','0');
$pdf->Cell(80,5,utf8_decode($row['name3']),'RT','0','L','0');
//--- 1. Zeile hinten - Menge und Zustellbestätigung
if($row['abo'] >1) {
$pdf->SetFillColor(100,100,100); $pdf->SetTextColor(255,255,255);
$pdf->Cell(20,5,$row['abo']." FAZ",'LRT','1','R','1');
$pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0,0,0);
} else {
$pdf->Cell(20,5,$row['abo']." FAZ",'LRT','1','R','0');
}
//--- 2. Zeile A
$zeile2b=$row['strasse']." ".$row['hnr']." ".$row['hnrz'].", ".$row['plz']." ".$row['ort'];
$pdf->Cell(90,5,utf8_decode($zeile2b),'LB','0','L','0');
//--- 2. Zeile B
if(strlen($row['bemerkung'])==0) {
$pdf->Cell(80,5," ",'RB','0','R','0');
} else {
$pdf->SetFillColor(100,100,100); $pdf->SetTextColor(255,255,255); $pdf->SetFont('Helvetica','B',10);
$pdf->Cell(80,5,utf8_decode($row['bemerkung']),'RB','0','R','1');
$pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0,0,0); $pdf->SetFont('Helvetica','B',11);
}
$pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0,0,0);
//--- 2. Zeile hinten - Menge und Zustellbestätigung
$pdf->Cell(20,5,' ','LRB','1','L','0');
$key++;
}
//--------------------
$abfrage_tour = $GLOBALS['mysql']->query_single("SELECT * FROM fazs WHERE kw='".$_GET['kw']."' and jahr='".$_GET['jahr']."' and plz='".$_GET['tour']."' and abo=0");
if($abfrage_tour['num_rows'] != 0) {
$u_tour = $GLOBALS['mysql']->query("SELECT * FROM fazs WHERE kw='".$_GET['kw']."' and jahr='".$_GET['jahr']."' and plz='".$_GET['tour']."' and abo=0");
unset ($row);
while($row = $u_tour->fetch_assoc()) {
if($key==20) {
$key=0;
$pdf->AddPage();
}
// echo "<pre>"; print_r($row); echo "</pre>";
$pdf->SetFont('Helvetica','B',11);
$pdf->Cell(170,1.5,' ','0','1','L','0');
//--- 1. Zeile - Name und Anschrift
$pdf->SetTextColor(150,150,150);
$zeile1a=$row['titel'].$row['name2'].", ".$row['name']." ".$row['name4'];
$pdf->Cell(90,5,utf8_decode($zeile1a),'LT','0','L','0');
$pdf->Cell(80,5,utf8_decode($row['name3']),'RT','0','L','0');
//--- 1. Zeile hinten - Menge und Zustellbestätigung
$pdf->Cell(20,5,"xxxxxxx",'LRT','1','R','0');
//--- 2. Zeile A
$zeile2b=$row['strasse']." ".$row['hnr']." ".$row['hnrz'].", ".$row['plz']." ".$row['ort'];
$pdf->Cell(90,5,utf8_decode($zeile2b),'LB','0','L','0');
//--- 2. Zeile B
$pdf->SetTextColor(0,0,0);
$pauseinfo="Pause von: ".$row['pausevon']." bis ".$row['pausebis'];
$pdf->Cell(80,5,utf8_decode($pauseinfo),'RB','0','R','1');
//--- 2. Zeile hinten - Menge und Zustellbestätigung
$pdf->SetTextColor(150,150,150);
$pdf->Cell(20,5,"xxxxxxx",'LRB','1','R','0');
$pdf->SetTextColor(0,0,0);
$key++;
}
}
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('FAZ_'.($tour).'_'.($datum).'.pdf','I');
//---------------------------------------
if ($_GET['icon'] ==0) { $pdf->Output('FAZ_'.($tour).'_'.($datum).'.pdf','I'); }
if ($_GET['icon'] ==1) { $pdf->Output('FAZ_'.($tour).'_'.($datum).'.pdf','D'); }
if ($_GET['icon'] ==2) {
if (!class_exists("phpmailer")) {
require_once('lib/phpmailer/class.phpmailer.php');
}
$empfaenger = "dispo@jb-transport.de";
$betreff='FAZ_'.($tour).'_'.($datum).'.pdf';
$Dateiname = 'FAZ_'.($tour).'_'.($datum).'.pdf';
$DateinameMail = 'FAZ_'.($tour).'_'.($datum).'.pdf';
require_once('lib/phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->SetLanguage('de', $mail->PluginDir . '/language/');
$mail->Body = 'FAZ_'.($tour).'_'.($datum).'.pdf';
$mail->From = "dispo@jb-transport.de";
$mail->FromName = "dispo@jb-transport.de";
$mail->AddAddress("dispo@jb-transport.de");
$mail->AddAddress("womo16@freenet.de");
$mail->AddAddress("sieber1602@gmail.com");
$mail->Subject = $betreff;
$doc = $pdf->Output('','S');
$mail->AddStringAttachment($doc,'FAZ_'.($tour).'_'.($datum).'.pdf', 'base64', 'application/pdf'); //$Dateiname
$mail->Send();
echo $Dateiname.' wurde versendet an: '.$empfaenger;
?><meta http-equiv="refresh" content="2; URL=https://edv.jb-transport.de/index.php?s=linfo&mailok=1"><?php
}
?>