test per diems calculator

svn path=/trunk/; revision=33483
This commit is contained in:
2016-06-12 15:35:27 +00:00
parent fb11e47590
commit a186793bdc
2 changed files with 338 additions and 0 deletions
+108
View File
@@ -0,0 +1,108 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>VKP calculator</title>
</head>
<body>
<?php
$epd = $_POST['country']; // Euro per day
$epd = explode('/', $epd);
$epd_trav = $epd[0];
$epd_full = $epd[1];
echo "<p>Travel day(s): " . $epd_trav . " EUR per day <br />";
echo "Full day(s): " . $epd_full . " EUR per day</p>";
?>
<table class="table table-striped">
<tr>
<th>Date</th>
<th>Breakfast paid</th>
<th>Lunch paid</th>
<th>Dinner paid</th>
<th>Your Reimbursement</th>
</tr>
<?php
$days = array('out', 1, 2, 3, 4, 5, 6, 7, 'return');
// set variables
$r_total = 0; // total reimbursement
foreach ($days as &$day) { // calculate for each day
$use = $_POST['use'][$day];
$date = $_POST['date'][$day];
$break = $_POST['break'][$day];
$lunch = $_POST['lunch'][$day];
$dinner = $_POST['dinner'][$day];
// set variables
$r_day = 0;
if ($use === 'yes') { // only calculate if checkbox has been activated (day in use)
if ($day === 'out' || $day === 'return') { // set amount of € for travel or full day
$eur = $epd_trav;
$desc = " (travel)";
} else {
$eur = $epd_full;
$desc = " (full)";
}
// open row
echo "<tr>";
// date
echo "<td>" . $date . $desc . "</td>";
// breakfast ($r_b)
if ($break === "yes") {
$r_b = $eur * 0.2;
$r_day = $r_day + $r_b;
echo "<td>yes (" . $r_b . " €)</td>";
} else {
echo "<td>no</td>";
}
// lunch ($r_l)
if ($lunch === "yes") {
$r_l = $eur * 0.4;
$r_day = $r_day + $r_l;
echo "<td>yes (" . $r_l . " €)</td>";
} else {
echo "<td>no</td>";
}
// breakfast ($r_d)
if ($dinner === "yes") {
$r_d = $eur * 0.4;
$r_day = $r_day + $r_d;
echo "<td>yes (" . $r_d . " €)</td>";
} else {
echo "<td>no</td>";
}
// reimbursement for the single day
echo "<td>" . $r_day . " €</td>";
$r_total = $r_total + $r_day;
// close row (day)
echo "</tr>";
} // if day is used
}
echo "<tr><td></td><td></td><td></td><td></td>";
echo "<td><strong>Total VKP: " . $r_total . " €</strong></td></tr>";
?>
</table>
</body>
</html>
+230
View File
@@ -0,0 +1,230 @@
<?xml version="1.0" encoding="utf-8" ?>
<html>
<head>
<title>FSFE - Internal Tools - per diems calculator</title>
<style type="text/css">
tr#descr {
font-style: italic;
font-size: small;
}
#content input[type="radio"] {
margin: 0 5px 0 15px;
}
label {
font-weight: normal;
}
</style>
</head>
<body>
<h1>Calculate per diems (VKP)</h1>
<form action="/cgi-bin/perdiem.php" method="post">
<h2>1. Select country</h2>
<!-- you can add new countries. For the individual amounts, set value=$travel/$full -->
<input type="radio" id="de" name="country" value="12/24" checked="checked" /><label for="de"> Germany</label>
<input type="radio" id="be" name="country" value="28/41" /><label for="be"> Belgium</label><br />
<input type="radio" id="be" name="country" value="" />Other (per diems travel/full (e.g. "12/24" for Germany)): <input type="text" name="country" placeholder="12/24" />
<h2>2. Which meal did you pay yourself?</h2>
<table class="table table-striped">
<tr>
<th>Use</th>
<th>Date</th>
<th>Breakfast</th>
<th>Lunch</th>
<th>Dinner</th>
</tr>
<tr id="descr">
<td>Calculate this day</td>
<td>Name the day (e.g. by date)</td>
<td>Did you pay this meal yourself?</td>
<td>Did you pay this meal yourself?</td>
<td>Did you pay this meal yourself?</td>
</tr>
<tr>
<td colspan="5"><strong>Outward travel day (or if you travelled only one day)</strong></td>
</tr>
<tr>
<td>
<input type="checkbox" name="use[out]" value="yes" checked="checked" />
</td>
<td>
<input type="date" name="date[out]" />
</td>
<td>
<input type="checkbox" name="break[out]" value="yes" />
</td>
<td>
<input type="checkbox" name="lunch[out]" value="yes" />
</td>
<td>
<input type="checkbox" name="dinner[out]" value="yes" />
</td>
</tr>
<tr>
<td colspan="5"><strong>Full days (only check those you travelled)</strong></td>
</tr>
<tr>
<td>
<input type="checkbox" name="use[1]" value="yes" />
</td>
<td>
<input type="date" name="date[1]" />
</td>
<td>
<input type="checkbox" name="break[1]" value="yes" />
</td>
<td>
<input type="checkbox" name="lunch[1]" value="yes" />
</td>
<td>
<input type="checkbox" name="dinner[1]" value="yes" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="use[2]" value="yes" />
</td>
<td>
<input type="date" name="date[2]" />
</td>
<td>
<input type="checkbox" name="break[2]" value="yes" />
</td>
<td>
<input type="checkbox" name="lunch[2]" value="yes" />
</td>
<td>
<input type="checkbox" name="dinner[2]" value="yes" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="use[3]" value="yes" />
</td>
<td>
<input type="date" name="date[3]" />
</td>
<td>
<input type="checkbox" name="break[3]" value="yes" />
</td>
<td>
<input type="checkbox" name="lunch[3]" value="yes" />
</td>
<td>
<input type="checkbox" name="dinner[3]" value="yes" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="use[4]" value="yes" />
</td>
<td>
<input type="date" name="date[4]" />
</td>
<td>
<input type="checkbox" name="break[4]" value="yes" />
</td>
<td>
<input type="checkbox" name="lunch[4]" value="yes" />
</td>
<td>
<input type="checkbox" name="dinner[4]" value="yes" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="use[5]" value="yes" />
</td>
<td>
<input type="date" name="date[5]" />
</td>
<td>
<input type="checkbox" name="break[5]" value="yes" />
</td>
<td>
<input type="checkbox" name="lunch[5]" value="yes" />
</td>
<td>
<input type="checkbox" name="dinner[5]" value="yes" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="use[6]" value="yes" />
</td>
<td>
<input type="date" name="date[6]" />
</td>
<td>
<input type="checkbox" name="break[6]" value="yes" />
</td>
<td>
<input type="checkbox" name="lunch[6]" value="yes" />
</td>
<td>
<input type="checkbox" name="dinner[6]" value="yes" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="use[7]" value="yes" />
</td>
<td>
<input type="date" name="date[7]" />
</td>
<td>
<input type="checkbox" name="break[7]" value="yes" />
</td>
<td>
<input type="checkbox" name="lunch[7]" value="yes" />
</td>
<td>
<input type="checkbox" name="dinner[7]" value="yes" />
</td>
</tr>
<tr>
<td colspan="5"><strong>Return travel day</strong></td>
</tr>
<tr>
<td>
<input type="checkbox" name="use[return]" value="yes" />
</td>
<td>
<input type="date" name="date[return]" />
</td>
<td>
<input type="checkbox" name="break[return]" value="yes" />
</td>
<td>
<input type="checkbox" name="lunch[return]" value="yes" />
</td>
<td>
<input type="checkbox" name="dinner[return]" value="yes" />
</td>
</tr>
</table>
<button type="submit" name="action" value="calc">Calculate per diems</button>
</form>
</body>
<timestamp>$Date$ $Author$</timestamp>
</html>
<!--
Local Variables: ***
mode: xml ***
End: ***
-->