Initialer Commit: Kundenverwaltung (PHP/Smarty)

Bestehende Codebasis als Ausgangsstand aufgenommen.

- .gitignore: Kundendaten (uploads_*), Smarty-Compile-Cache
  (templates_c), Laufzeit-Temp und Datenbank-Dumps ausgeschlossen;
  Verzeichnisstruktur ueber .gitkeep erhalten
- .gitattributes: Zeilenenden normalisiert (LF im Repo),
  Binaerformate markiert
- db-backup.php: MySQL-Zugangsdaten kommen jetzt wie im Rest der
  Anwendung aus der externen Konfiguration statt hartkodiert aus der
  Datei; Passwort wird ueber eine temporaere Optionsdatei statt per
  Kommandozeile uebergeben, Fehler von mysqldump/gzip werden gemeldet,
  Aufraeumen aelterer Backups berechnet Jahr und Monat konsistent

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-28 16:41:18 +02:00
co-authored by Claude Opus 5
commit e2124220e5
2225 changed files with 1070301 additions and 0 deletions
+504
View File
@@ -0,0 +1,504 @@
<?php
require('fpdf.php');
require_once('mysql.php');
$id=$_GET['id'];
class PDF extends FPDF
{
//Kopfzeile
function Header()
{
//Logo
$this->Image('./pics/logo1.png',0,0,210);
//Arial fett 15
$this->SetFont('Arial','B',15);
//nach rechts gehen
//Zeilenumbruch
$this->Ln(50);
}
//Fusszeile
function Footer()
{
//Logo
$this->Image('./pics/logo2.png',15,275,17);
//Position 1,5 cm von unten
$this->SetY(-17);
$this->setX(15);
$this->SetFont('Times','',8);
$this->SetTextColor(0,0,0);
if ($_GET['leer'] == 0) $this->Cell(180,5,'Seite '.$this->PageNo().' von {nb}',0,0,'R');
$this->SetY(-7);
$this->setX(15);
//Arial fett 6
$this->SetFont('Arial','B',6);
$this->SetTextColor(124,124,138);
//Seitenzahl
$this->Cell(0,7,utf8_decode('WAGNER MARKISEN GMBH · IM ENGELFELD 13 · TEL. 0 83 23 - 68 63 · FAX: 0 83 23 - 37 55 · GESCHÄFTSFÜHRER: K.H. WAGNER'),0,0,'L');
$this->Ln(2.3);
$this->setX(15);
$this->Cell(0,7,utf8_decode('BANKEN: VOBA IMMENSTADT BLZ 733 920 00 · NR. 0 414 204 · SPARKASSE ALLGÄU BLZ 733 500 00 · NR. 106 526 · RAIBA OBERALLGÄU-SÜD BLZ 733 699 20 · NR. 7 232 829'),0,0,'L');
}
}
$verbindung=mysql_connect($mysqlserver,$mysqluser,$mysqlpass) or die("konnte nicht verbinden...");;
mysql_select_db("angebot") or die("da is keine Db...");;
$timestamp=time();
$res=mysql_query("SELECT * FROM angebot WHERE id='$id' ;") or die("konnte nicht eingetragen werden: " . mysql_error());
$obj=Mysql_fetch_object($res);
//Instanciation of inherited class
$pdf=new PDF();
$pdf->SetTopMargin(50);
$pdf->SetAutoPageBreak(true,25);
$pdf->AliasNbPages();
$pdf->AddPage(P);
if ($_GET['leer']==0){
//ADRESSE!!!!
$pdf->SetFont('Arial','B',6);
$pdf->SetTextColor(124,124,138);
$pdf->setY(35);
$pdf->setX(25);
$pdf->Cell(0,3,utf8_decode('WAGNER MARKISEN GMBH · IM ENGELFELD 13 · 87509 IMMENSTADT'),0,0,'L');
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Times','',12);
$pdf->setY(40);
$pdf->setX(25);
$pdf->Cell(0,5,utf8_decode($obj->anr),0,0,'L');
$pdf->Ln(5);
$pdf->setX(25);
if (str_replace ( " " ,"" ,$obj->vname) == "") $name=$obj->nname;
else $name=$obj->vname." ".$obj->nname;
$pdf->Cell(0,5,utf8_decode($name),0,0,'L');
if ($obj->zus!=""){
$pdf->Ln(5);
$pdf->setX(25);
$pdf->Cell(0,5,utf8_decode($obj->zus),0,0,'L');
}
$pdf->Ln(5);
$pdf->setX(25);
$pdf->Cell(0,5,utf8_decode($obj->str.' '.$obj->nr),0,0,'L');
$pdf->Ln(5);
$pdf->Ln(5);
$pdf->setX(25);
$pdf->Cell(0,5,utf8_decode($obj->plz.' '.$obj->ort),0,0,'L');
//DATUM
$pdf->sety(60);
$pdf->setX(170);
setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
$datum=strftime("%d.%m.%Y",strtotime($obj->timestampnew));
$pdf->Cell(0,5,utf8_decode($datum),0,0,'L');
//Betreff
$pdf->sety(80);
$pdf->setX(20);
if ($obj->type == 0) $pdf->MultiCell(0,5,utf8_decode($obj->betr),0,'L',0);
else $pdf->MultiCell(0,5,"Auftragsbesttigung",0,'L',0);
$pdf->SetTextColor(150,150,150);
$pdf->line(0,87,5,87);
$pdf->SetTextColor(0,0,0);
//Begrüßung
$pdf->SetFont('Times','B',12);
$pdf->sety(90);
$pdf->setX(20);
$pdf->Cell(0,5,utf8_decode($obj->begr),0,0,'L');
$currY=100;
if ($obj->begr2 != "") {
$pdf->sety(95);
$pdf->setX(30);
$pdf->Cell(0,5,utf8_decode($obj->begr2),0,0,'L');
$currY=105;
}
//Vielen Dank
$pdf->SetFont('Times','',12);
$pdf->sety($currY);
$pdf->setX(20);
if ($obj->type == 0) $pdf->Cell(0,5,utf8_decode("Vielen Dank für Ihre Anfrage."),0,0,'L');
else $pdf->Cell(0,5,"Hiermit besttigen wir folgenden Auftrag:",0,0,'L');
//Gerne bieten wir Ihnen an:
$pdf->SetFont('Times','',12);
$pdf->sety($currY+10);
$pdf->setX(20);
if ($obj->type == 0) $pdf->Cell(0,5,utf8_decode("Gerne unterbreiten wir Ihnen folgendes Angebot:"),0,0,'L');
//txt1
if (rtrim($obj->txt1)!="" ){
$pdf->SetFont('Times','',12);
$pdf->sety($currY+15);
$pdf->setX(20);
$pdf->MultiCell(0,5,utf8_decode($obj->txt1),0,'L',0);
}
// calcheight
$newpdf=new PDF();
$newpdf->SetAutoPageBreak(true,40);
$newpdf->AddPage(P);
$calculatedHeight = 0;
$newpdf->setY(0);
$pdf->setX(20);
$abfrage = "select * from artikel where angebot_id = '$id' ";
$res = mysql_query($abfrage) or die("Anfrage fehlgeschlagen: " . mysql_error());
$newpdf->SetFont('Times','',12);
$newpdf->setY(7);
$objart=Mysql_fetch_object($res);
$newpdf->Cell(100,5,utf8_decode($objart->name),0,0,'L');
$newpdf->setY(12);
$newpdf->MultiCell(0, 5, utf8_decode(rtrim($objart->beschr)), 0, "L", 0);
$artheight = $newpdf->getY();
unset($newpdf);
if ($currY+$artheight > 245 and $artheight < 119){
$pdf->AddPage(P);
$currY=110;
}
//TABELLE
$currY=$pdf->GetY();
if ($currY > 210 or $obj->newpageitem == 0){
$pdf->AddPage(P);
$currY=70;
}
//Table-HEAD
$pdf->SetFont('Times','B',12);
$pdf->sety($currY+5);
$pdf->setX(20);
$pdf->Cell(100,5,utf8_decode('Bezeichnung'),0,0,'L');
$pdf->setX(120);
$pdf->Cell(15,5,utf8_decode('Menge'),0,0,'C');
$pdf->setX(135);
$pdf->Cell(30,5,utf8_decode('Einzelpreis'),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode('Gesamtpreis'),0,0,'R');
$pdf->Line(18 , $currY+10, 200, $currY+10);
$currY=$currY+2;
$abfrage = "select * from artikel where angebot_id = '$id' ";
$res = mysql_query($abfrage) or die("Anfrage fehlgeschlagen: " . mysql_error());
$numarts = mysql_num_rows($res);
$toreplace=array(".",",");
$replace=array("",".");
$pdf->SetFont('Times','',12);
$currY=$currY+7;
$pdf->setY($currY);
for($i=1;$i<=$numarts;$i++){
$objart=Mysql_fetch_object($res);
// calcheight
$newpdf=new PDF();
$newpdf->SetAutoPageBreak(true,40);
$newpdf->AddPage(P);
$calculatedHeight = 0;
$newpdf->setY(0);
$newpdf->setX(20);
if ($objart->typ==0){
$newcurrY=3;
$newpdf->setY($newcurrY);
$newpdf->SetFont('Times','',12);
$newpdf->setX(20);
$newpdf->Cell(100,5,utf8_decode($objart->name),0,0,'L');
$newpdf->setX(120);
$newpdf->Cell(15,5,utf8_decode(number_format($anzahl,2,",","")),0,0,'C');
$newpdf->setX(135);
$newpdf->Cell(30,5,utf8_decode(number_format($einzelpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$newpdf->setX(165);
$newpdf->Cell(30,5,utf8_decode(number_format($gesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$newpdf->setY($newcurrY+2);
$newpdf->SetFont('Times','',10);
$newpdf->MultiCell(100, 3, utf8_decode(rtrim($objart->beschr)), 0, "L", 0);
}
elseif ($objart->typ==1){
$newpdf->SetFont('Times','I',10);
$newpdf->setX(25);
$newpdf->Cell(95,5,utf8_decode('(optional: '.$objart->name.')'),0,0,'L');
$newpdf->setX(120);
$newpdf->Cell(15,5,utf8_decode(number_format($anzahl,2,",","")),0,0,'C');
$newpdf->setX(135);
$newpdf->Cell(30,5,utf8_decode(number_format($einzelpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$newpdf->setX(165);
$newpdf->Cell(30,5,utf8_decode(number_format($gesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$newpdf->setY($newcurrY+2);
$newpdf->SetFont('Times','',10);
$newpdf->MultiCell(80, 3, utf8_decode(rtrim($objart->beschr)), 0, "L", 0);
}
elseif ($objart->typ==2){
$newpdf->SetFont('Times','I',10);
$newpdf->setX(25);
$newpdf->Cell(95,5,utf8_decode('(alternativ: '.$objart->name.')'),0,0,'L');
$newpdf->setX(120);
$newpdf->Cell(15,5,utf8_decode(number_format($anzahl,2,",","")),0,0,'C');
$newpdf->setX(135);
$newpdf->Cell(30,5,utf8_decode(number_format($einzelpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$newpdf->setX(165);
$newpdf->Cell(30,5,utf8_decode(number_format($gesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$newpdf->setY($newcurrY+2);
$newpdf->SetFont('Times','',10);
$newpdf->MultiCell(80, 3, utf8_decode(rtrim($objart->beschr)), 0, "L", 0);
}
$artheight = $newpdf->getY();
unset($newpdf);
if ($currY+$artheight > 255 and $artheight < 219){
$pdf->SetFont('Times','B',12);
$pdf->Line(18 , $currY+5, 200, $currY+5);
$pdf->setY($currY+7);
$pdf->setX(130);
$pdf->Cell(30,5,utf8_decode('Übertrag:'),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode(number_format($gesgesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$pdf->AddPage(P);
$currY=70;
//Table-re-HEAD
$pdf->sety($currY);
$pdf->setX(20);
$pdf->Cell(95,5,utf8_decode('Bezeichnung'),0,0,'L');
$pdf->setX(115);
$pdf->Cell(10,5,utf8_decode('Menge'),0,0,'C');
$pdf->setX(135);
$pdf->Cell(30,5,utf8_decode('Einzelpreis'),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode('Gesamtpreis'),0,0,'R');
$pdf->Line(18 , $currY+5, 200, $currY+5);
$currY=$currY+7;
$pdf->setY($currY);
$pdf->SetFont('Times','',12);
}
if ($obj->mwstart==0) {
$divi='1.'.$obj->mwst;
$einzelpreis=round(str_replace ( $toreplace , $replace ,$objart->einzelpreis)/$divi,2);
$anzahl=str_replace ( $toreplace , $replace ,$objart->anzahl);
$gesamtpreis=round($einzelpreis*$anzahl,2);
if ($objart->typ==0){
$gesgesamtpreis=$gesgesamtpreis+$gesamtpreis;
}
}
else {
$einzelpreis=round(str_replace ( $toreplace , $replace ,$objart->einzelpreis),2);
$anzahl=str_replace ( $toreplace , $replace ,$objart->anzahl);
$gesamtpreis=round($einzelpreis*$anzahl,2);
if ($objart->typ==0){
$gesgesamtpreis=$gesgesamtpreis+$gesamtpreis;
}
}
if ($objart->typ==0){
$currY=$currY+3;
$pdf->setY($currY);
$pdf->SetFont('Times','B',12);
$pdf->setX(20);
$pdf->Cell(100,5,utf8_decode($objart->name),0,0,'L');
$pdf->setX(120);
$pdf->SetFont('Times','',12);
$pdf->Cell(15,5,utf8_decode(number_format($anzahl,2,",","")),0,0,'C');
$pdf->setX(135);
$pdf->Cell(30,5,utf8_decode(number_format($einzelpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode(number_format($gesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$currY=$currY+6;
$pdf->setY($currY);
$pdf->setX(20);
$pdf->SetFont('Times','',10);
if (rtrim($objart->beschr)) {
$pdf->MultiCell(100, 3, utf8_decode(rtrim($objart->beschr)), 0, "L", 0);
$currY=$pdf->getY();
$currY=$currY+2;
}
else $crrY=$currY-2;
$pdf->setY($currY);
}
elseif ($objart->typ==1){
$pdf->SetFont('Times','BI',10);
$pdf->setX(25);
$pdf->Cell(95,5,utf8_decode('Wahlweise: '.$objart->name),0,0,'L');
$pdf->setX(120);
$pdf->SetFont('Times','I',10);
$pdf->Cell(15,5,utf8_decode(number_format($anzahl,2,",","")),0,0,'C');
$pdf->setX(135);
$pdf->Cell(30,5,utf8_decode(number_format($einzelpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode(number_format($gesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$currY=$currY+5;
$pdf->setY($currY);
$pdf->setX(25);
$pdf->SetFont('Times','I',10);
if (rtrim($objart->beschr)) {
$pdf->MultiCell(80, 3, utf8_decode(rtrim($objart->beschr)), 0, "L", 0);
$currY=$pdf->getY();
$currY=$currY+2;
}
$pdf->setY($currY);
}
elseif ($objart->typ==2){
$pdf->SetFont('Times','BI',10);
$pdf->setX(25);
$pdf->Cell(95,5,utf8_decode('Alternativ: '.$objart->name),0,0,'L');
$pdf->setX(120);
$pdf->SetFont('Times','I',10);
$pdf->Cell(15,5,utf8_decode(number_format($anzahl,2,",","")),0,0,'C');
$pdf->setX(135);
$pdf->Cell(30,5,utf8_decode(number_format($einzelpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode(number_format($gesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$currY=$currY+5;
$pdf->setY($currY);
$pdf->setX(25);
$pdf->SetFont('Times','I',10);
if (rtrim($objart->beschr)) {
$pdf->MultiCell(80, 3, utf8_decode(rtrim($objart->beschr)), 0, "L", 0);
$currY=$pdf->getY();
$currY=$currY+2;
}
$pdf->setY($currY);
}
if ($currY > 240 or $i == $obj->newpageitem) {
$pdf->SetFont('Times','B',12);
$pdf->Line(18 , $currY+5, 200, $currY+5);
$pdf->setY($currY+7);
$pdf->setX(130);
$pdf->Cell(30,5,utf8_decode('Übertrag:'),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode(number_format($gesgesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$pdf->AddPage(P);
$currY=70;
//Table-re-HEAD
$pdf->sety($currY);
$pdf->setX(20);
$pdf->Cell(95,5,utf8_decode('Bezeichnung'),0,0,'L');
$pdf->setX(115);
$pdf->Cell(10,5,utf8_decode('Menge'),0,0,'C');
$pdf->setX(135);
$pdf->Cell(30,5,utf8_decode('Einzelpreis'),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode('Gesamtpreis'),0,0,'R');
$pdf->Line(18 , $currY+5, 200, $currY+5);
$currY=$currY+7;
$pdf->setY($currY);
$pdf->SetFont('Times','',12);
}
}
//Endbetrag
$pdf->SetFont('Times','B',12);
$pdf->Line(18 , $currY+2, 200, $currY+2);
$pdf->setY($currY+2);
$pdf->setX(130);
$pdf->Cell(30,5,utf8_decode('Gesamtbetrag Netto:'),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode(number_format($gesgesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
//RABATT
if ($obj->rab =="" or $obj->rab == "0") {
$currY=$currY+7;
}
else {
$currY=$currY+7;
$pdf->setY($currY);
$pdf->setX(130);
$pdf->Cell(30,5,utf8_decode($obj->rabtxt." (".$obj->rab."%):"),0,0,'R');
$pdf->setX(165);
$multi=$obj->rab/100;
$pdf->Cell(30,5,utf8_decode("-".number_format(round($gesgesamtpreis*$multi,2),2,",",".")." ".$obj->wahrung),0,0,'R');
$gesgesamtpreis=$gesgesamtpreis-round($gesgesamtpreis*$multi,2);
$currY=$currY+5;
}
//Mwst ausweisen
$pdf->setY($currY);
$pdf->setX(130);
$pdf->Cell(30,5,utf8_decode('Zuzüglich '.$obj->mwst.'% Mwst.:'),0,0,'R');
$pdf->setX(165);
$multi='0.'.$obj->mwst;
$pdf->Cell(30,5,utf8_decode(number_format(round($gesgesamtpreis*$multi,2),2,",",".")." ".$obj->wahrung),0,0,'R');
$gesgesamtpreis=$gesgesamtpreis+round($gesgesamtpreis*$multi,2);
//komplettpreis ausgeben
$pdf->setY($currY+5);
$pdf->setX(130);
$pdf->Cell(30,5,utf8_decode('Gesamtbetrag Brutto:'),0,0,'R');
$pdf->setX(165);
$pdf->Cell(30,5,utf8_decode(number_format($gesgesamtpreis,2,",",".")." ".$obj->wahrung),0,0,'R');
$currY=$currY+15;
$pdf->setY($currY);
$pdf->SetFont('Times','',12);
$pdf->setX(20);
$currY=$currY;
if ($currY > 270) {
$pdf->AddPage(P);
$currY=60;
}
if ($currY <= 270) {
//txt2 hhe berechnen!!
// calcheight
$newpdf=new PDF();
$newpdf->SetAutoPageBreak(true,40);
$newpdf->AddPage(P);
$calculatedHeight = 0;
$newpdf->setY(0);
$newpdf->setX(20);
$newpdf->SetFont('Times','',12);
$newpdf->MultiCell(0, 5, utf8_decode(rtrim($obj->txt2)), 0, "L", 0);
$newpdf->setX(20);
$newpdf->Cell(0,5,utf8_decode($obj->mfg),0,0,'L',0);
//unterschrift
$res=mysql_query("SELECT userpic, name FROM user WHERE id='$obj->userid' LIMIT 1 ;") or die("konnte nicht eingetragen werden: " . mysql_error());
$objuser=Mysql_fetch_object($res);
$newpdf->Image($objuser->userpic,25,$currY+10,0,10);
$newpdf->sety($pdf->getY()+15);
$newpdf->setX(20);
$newpdf->Cell(0,5,utf8_decode($obj->wm),0,0,'L',0);
$newpdf->sety($pdf->getY()+5);
$newpdf->setX(20);
$newpdf->Cell(0,5,utf8_decode($objuser->name),0,0,'L',0);
$txt2height = $newpdf->getY();
unset($newpdf);
if ($currY+$txt2height > 420 and $txt2height < 239){
$pdf->AddPage(P);
$currY=70;
}
}
$pdf->setY($currY);
if (rtrim($obj->txt2) != ""){
$pdf->SetFont('Times','',12);
$pdf->setX(20);
$pdf->MultiCell(0,5,utf8_decode(rtrim($obj->txt2)),0,'L',0);
//ENDE!!
$currY=$pdf->getY();
$pdf->setY($currY+5);
}
$pdf->setX(20);
$pdf->Cell(0,5,utf8_decode($obj->mfg),0,0,'L',0);
//unterschrift
$res=mysql_query("SELECT userpic, name FROM user WHERE id='$obj->userid' LIMIT 1 ;") or die("konnte nicht eingetragen werden: " . mysql_error());
$objuser=Mysql_fetch_object($res);
$pdf->Image($objuser->userpic,25,$currY+10,0,10);
$pdf->sety($pdf->getY()+23);
$pdf->setX(20);
$pdf->Cell(0,5,utf8_decode($obj->wm),0,0,'L',0);
$pdf->sety($pdf->getY()+5);
$pdf->setX(20);
$pdf->Cell(0,5,utf8_decode($objuser->name),0,0,'L',0);
}
$pdf->Output();
?>