Browse Source

Currencies in PDF are displayed

master
Tobias Herre 2 years ago
parent
commit
67d602af8d
2 changed files with 23 additions and 10 deletions
  1. +1
    -1
      form.php
  2. +22
    -9
      submit.php

+ 1
- 1
form.php View File

@ -135,7 +135,7 @@
<?=_("Währung:")?>
</div>
<div class="is-col">
<select onchange="renumberTableRows()" id="currency" >
<select onchange="renumberTableRows()" name='currency' id="currency" >
<option value="EUR">EUR</option>
<option value="USD">USD</option>
<option value="CHF">CHF</option>

+ 22
- 9
submit.php View File

@ -17,6 +17,9 @@
<?php
session_start();
error_log("SUBMIT\n");
require "config.php";
require "PHPMailer/PHPMailer.php";
require "PHPMailer/SMTP.php";
@ -185,7 +188,7 @@ function mkFrontPDF(){
// Set some content to print
$html =
<<<EOD
<h1>Kostenerstattungsantrag &uuml;ber $sum EUR</h1>
<h1>Kostenerstattungsantrag &uuml;ber $sum $_POST[currency]</h1>
<p><b>Projekt: $_POST[project]</b></p>
<hr>
<p>
@ -260,7 +263,7 @@ function mkSnippedPdf($key){
<h1>Position $pos</h1>
<p>$desc</p><br>
<p>$am EUR</p><br>
<p>$am $_POST[currency]</p><br>
EOD;
// Print text using writeHTMLCell()
@ -329,7 +332,7 @@ function mkTable(){
$html .= "<td>".$_POST['desc'][$key]."</td>";
$am = floatval(str_replace(",",".",$val));
$am = str_replace(".",",",sprintf("%.2f",$am));
$html .= '<td align="right">'.$am." ".$_POST['currency'][$key]. "</td>";
$html .= '<td align="right">'.$am." ".$_POST['currency']. "</td>";
$html .="</tr>";
@ -347,7 +350,7 @@ function mkTable(){
$html .= "Bereits erhaltener Vorschuss:";
$html .= '</td>';
$html .= '<td align="right">';
$html .= sprintf("-%0.2f",$adv)." EUR";
$html .= sprintf("-%0.2f",$adv)." ".$_POST['currency'];
$html .= '</td>';
$html .= "</tr>";
@ -358,7 +361,7 @@ function mkTable(){
$html .= "<b>Summe:</b>";
$html .= '</td>';
$html .= '<td align="right">';
$html .= "<b>".calcSum()." EUR</b>";
$html .= "<b>".calcSum()." ".$_POST['currency']."</b>";
$html .= '</td>';
$html .= '</tr>';
@ -375,6 +378,7 @@ function mkTable(){
$pdfs = array();
error_log("Making Front PDF");
//
// Applicatoin starts here
@ -404,18 +408,20 @@ foreach ($_POST['desc'] as $key => $val) {
$resultnam = tempnam("/tmp","karesult");
$cmd = "$PDFTK_CMD";
foreach ($pdfs as $filename){
$cmd .= " $filename";
}
$cmd .= " cat output $resultnam.pdf";
error_log("EXEC CMD $cmd");
exec ($cmd);
#var_dump($_POST);
$file = "$resultnam.pdf";
if ($_POST['sendmail']=='yes'){
$subj = "Kostenerstattungsantrag ueber".calcSum()." EUR";
$subj = "Kostenerstattungsantrag ueber".calcSum()." ".$_POST['currency'];
$mail = new PHPMailer\PHPMailer\PHPMailer();
@ -453,17 +459,24 @@ if ($_POST['sendmail']=='yes'){
echo "Dein Antrag wurde versendet.<BR>";
?>
<div class="is-col">
<!-- <div class="is-col">
<button type="button" onclick="downloadDocument(false);"
class="button is-orange"><?=_("Kopie des Antrags herunterladen")?></button>
</div>
</div> -->
<?php
echo '<a href="./">
Weiteren Antrag auf Kostenerstattung stellen</a><BR>';
die;
}
$file = "$resultnam.pdf";
header('Content-Disposition: attachment; filename="'. basename($file) . '"');
header('Content-Length: ' . filesize($file));
readfile($file);
?>
<script src="js/kube.min.js"></script>
<script src="addons/upload/kube.upload.min.js"></script>

Loading…
Cancel
Save