Shows correct costs in advance in generated PDF

This commit is contained in:
7u83 2020-03-09 13:33:04 +00:00
parent 42d3126398
commit d199e664c9
2 changed files with 44 additions and 4 deletions

2
ka.php
View File

@ -267,7 +267,7 @@ Grund für abweichende Kontoinhabende Person"></textarea>
H&ouml;he von: H&ouml;he von:
</div> </div>
<div class="is-col"> <div class="is-col">
<input type="text" placeholder="0,00 EUR"/> <input input name="advance" id="advance" type="text" placeholder="0,00 EUR"/>
</div> </div>
</div> </div>
<br> <br>

View File

@ -35,6 +35,18 @@ class kaformPDF extends TCPDF {
// //
}; };
function get_adv()
{
$aval = $_POST['advance'];
if (!$aval)
$aval = "0";
$advance = floatval(str_replace(",",".",$aval));
if ($advance < 0 )
$advance = -$advance;
return $advance;
}
function mkFrontPDF(){ function mkFrontPDF(){
$comments = str_replace("\n","<BR>",$_POST['comments']); $comments = str_replace("\n","<BR>",$_POST['comments']);
$bankaddress = str_replace("\n","<BR>",$_POST['n_bankaddress']); $bankaddress = str_replace("\n","<BR>",$_POST['n_bankaddress']);
@ -43,6 +55,9 @@ function mkFrontPDF(){
$account_owner = $_POST['owner']; $account_owner = $_POST['owner'];
if (!$account_owner) $account_owner = $_POST['realname']; if (!$account_owner) $account_owner = $_POST['realname'];
# $aval = $_POST['advance'];
# $advance = floatval(str_replace(",",".",$aval));
$aw = $_POST; $aw = $_POST;
switch ($_POST['banktype']){ switch ($_POST['banktype']){
@ -53,6 +68,7 @@ function mkFrontPDF(){
Kontoinhaber: $account_owner<br> Kontoinhaber: $account_owner<br>
IBAN: $_POST[iban]<br> IBAN: $_POST[iban]<br>
BIC: $_POST[bic]<br> BIC: $_POST[bic]<br>
Anmerkungen:<br> $comments<br>
"; ";
break; break;
case "bank-noneu": case "bank-noneu":
@ -267,7 +283,9 @@ function calcSum(){
foreach ($_POST['amount'] as $val){ foreach ($_POST['amount'] as $val){
// var_dump($val); // var_dump($val);
$sum += floatval(str_replace(",",".",$val)); $sum += floatval(str_replace(",",".",$val));
} }
$sum -= get_adv();
return str_replace(".",",",sprintf("%0.2f",$sum)); return str_replace(".",",",sprintf("%0.2f",$sum));
// return sprintf("%.2f",$sum); // return sprintf("%.2f",$sum);
} }
@ -293,7 +311,7 @@ function mkTable(){
$html .= "<td>".$_POST['description'][$key]."</td>"; $html .= "<td>".$_POST['description'][$key]."</td>";
$am = floatval(str_replace(",",".",$val)); $am = floatval(str_replace(",",".",$val));
$am = str_replace(".",",",sprintf("%.2f",$am)); $am = str_replace(".",",",sprintf("%.2f",$am));
$html .= "<td>".$am." ".$_POST['currency'][$key]. "</td>"; $html .= '<td align="right">'.$am." ".$_POST['currency'][$key]. "</td>";
$html .="</tr>"; $html .="</tr>";
@ -304,9 +322,31 @@ function mkTable(){
$pos ++; $pos ++;
} }
$adv = get_adv();
if ($adv) {
$html .= "<tr>";
$html .= '<td colspan="3">';
$html .= "Bereits erhaltener Vorschuss:";
$html .= '</td>';
$html .= '<td align="right">';
$html .= sprintf("-%0.2f",$adv)." EUR";
$html .= '</td>';
$html .= "</tr>";
}
$html .= '<tr>';
$html .= '<td colspan="3">';
$html .= "<b>Summe:</b>";
$html .= '</td>';
$html .= '<td align="right">';
$html .= "<b>".calcSum()." EUR</b>";
$html .= '</td>';
$html .= '</tr>';
$html .= "</table>"; $html .= "</table>";
$html .="<br>&nbsp;<br>"; # $html .="<br>&nbsp;<br>";
$html .="<b>Summe: ".calcSum()."</b>"; # $html .="<b>Summe: ".calcSum()."</b>";
return $html; return $html;
// return str_replace(".",",",sprintf("%0.2f",$sum)); // return str_replace(".",",",sprintf("%0.2f",$sum));