Added Voiceplan PDF export

This commit is contained in:
Frank Schubert
2024-08-30 13:17:22 +02:00
parent 46c97221eb
commit ebace237da
3 changed files with 99 additions and 0 deletions

View File

@@ -85,6 +85,7 @@
<td><?=str_replace(".",",",(float)$plan->price_multiplicator)?>x</td>
<td><?=date("d.m.Y H:i", $plan->create)?> (<?=$plan->creator->name?>)</td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Voiceplan", "downloadPdf", ["id" => $plan->id])?>"><i class="far fa-file-pdf" title="Anzeigen"></i></a>
<a href="<?=self::getUrl("Voiceplan", "view", ["id" => $plan->id])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
<a href="<?=self::getUrl("Voiceplan", "edit", ["id" => $plan->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("Voiceplan", "delete", ["id" => $plan->id])?>" onclick="if(!confirm('Sprachtarifpaket wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>

View File

@@ -0,0 +1,77 @@
<?php
/**
* @var $voiceplan Voiceplan
* @var $ressourcePathPrefix string
*/
$this->setReturnValue([
'filename' => "xinon-sprachtarif-uebersicht-".preg_replace("/[^a-z0-9-_]+/i","-", $voiceplan->name).".pdf"
]);
?>
<!DOCTYPE html>
<html>
<head>
<title>Xinon Sprachtarifsübersicht <?=$voiceplan->name?></title>
<meta charset="utf-8" />
<link href="<?=$ressourcePathPrefix?>fontawesome/css/all.min.css" rel="stylesheet" type="text/css" />
<link href="<?=$ressourcePathPrefix?>assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="<?=$ressourcePathPrefix?>assets/css/thetool.css" rel="stylesheet" type="text/css" />
<link href="<?=$ressourcePathPrefix?>assets/css/print.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
margin-left: 36pt;
margin-right: 36pt;
font-size: 9pt;
font-family: "Open Sans", OpenSans, sans-serif;
background-color: #fff !important;
}
</style>
</head>
<body>
<div style="border-top: 1pt solid #000">
&nbsp;
</div>
<div>
<img src="<?=$ressourcePathPrefix?>assets/images/xinon-full.png" style="height: 80pt;" />
</div>
<div style="height:32pt;"></div>
<div>
<h3 class="text-center mb-3">Gesprächsgebührenübersicht für den Sprachtarif<br /> <?=$voiceplan->name?></h3>
<?php if($voiceplan->increment_first == 1 && $voiceplan->increment == 1): ?>
<p class="text-center">Abrechnungstakt: Sekundengenaue Abrechnung</p>
<?php else: ?>
<p class="text-center">Abrechnungstakt: <?=$voiceplan->increment_first?>/<?=$voiceplan->increment?>*</p>
<?php endif; ?>
<table class="table table-sm table-bordered table-striped">
<tr>
<th class="font-weight-bold">Ziel</th>
<th class="text-right font-weight-bold">Preis pro Minute excl. Ust.</th>
<th class="text-right font-weight-bold">Preis pro Minute incl. Ust.</th>
</tr>
<?php $i=0; foreach($voiceplan->zones as $zone): ?>
<tr style="page-break-inside: avoid">
<td style="padding:6pt; padding-top: 2pt; padding-bottom: 2pt;"><?=$zone->name?></td>
<td style="padding:6pt; padding-top: 2pt; padding-bottom: 2pt;" class="text-right text-monospace">€ <?=number_format($zone->price, 4, ",",".")?></td>
<td style="padding:6pt; padding-top: 2pt; padding-bottom: 2pt;" class="text-right text-monospace">€ <?=number_format($zone->price*1.2, 4, ",",".")?></td>
</tr>
<?php $i++; endforeach; ?>
</table>
<?php if($voiceplan->increment_first != 1 || $voiceplan->increment != 1): ?>
<p style="font-size: 6pt;">* Taktung: Jedes Gespräch wird für volle <?=$voiceplan->increment_first?> Gesprächssekunden abgerechnet, darüber hinausgehende Gesprächsdauer in Schritten von <?=$voiceplan->increment?> Sekunden.</p>
<?php endif; ?>
</div>
</body>
</html>

View File

@@ -297,4 +297,25 @@ class VoiceplanController extends mfBaseController {
$this->redirect("Voiceplan", "Index");
}
protected function downloadPdf() {
$this->layout()->setTemplate("Voiceplan/export.pdf");
$voiceplan = new Voiceplan($this->request->id);
if(!$voiceplan->id) {
$this->layout()->setFlash("Sprachtarif nicht gefunden", "error");
$this->redirect("Voiceplan", "Index");
}
$pdf_vars = [
"voiceplan" => $voiceplan,
];
$pdf = new PdfForm("Voiceplan/export.pdf", $pdf_vars);
$title = "Xinon Sprachtarif ".$voiceplan->name;
$pdf->render("--footer-center '$title Seite [page] / [topage]' --footer-font-name OpenSans --footer-font-size 9");
$tvalue = $pdf->getReturnedValues();
$pdfname = $tvalue['filename'];
$pdf->download($pdfname);
}
}