only use one pre-defined home country, for which defaults can be added in XHTML

This commit is contained in:
2021-10-19 16:07:23 +02:00
parent af3d68ee0c
commit ccf2b7c6c1
2 changed files with 28 additions and 61 deletions
+12 -29
View File
@@ -32,8 +32,7 @@ $er = isset($_POST["er"]) ? $_POST["er"] : false;
$catch = isset($_POST["catch"]) ? $_POST["catch"] : false;
$extra = isset($_POST["extra"]) ? $_POST["extra"] : false;
$mailopt = isset($_POST["mailopt"]) ? $_POST["mailopt"] : false;
$home = isset($_POST["home"]) ? $_POST["home"] : false;
$home_other = isset($_POST["home_other"]) ? $_POST["home_other"] : false;
$defaults = isset($_POST["defaults"]) ? $_POST["defaults"] : false;
$dest = isset($_POST["dest"]) ? $_POST["dest"] : false;
$dest_other = isset($_POST["dest_other"]) ? $_POST["dest_other"] : false;
$use = isset($_POST["use"]) ? $_POST["use"] : false;
@@ -100,40 +99,24 @@ function beautify_filename($filename) {
$filename = trim($filename, '.-');
return $filename;
}
/* Snippet End */
/* Snippet End */
// detect home country and set accodingly: currency, rates
if ($home === 'de') {
$cur = " "; // currency
$c_b = 0.2; // breakfast rate
$c_l = 0.4; // lunch rate
$c_d = 0.4; // dinner rate
$c_flat = 0; // flat rate (money which employee gets even if all meals are paid)
} elseif ($home === 'se' ) {
$cur = " SEK";
$c_b = 0.15;
$c_l = 0.35;
$c_d = 0.35;
$c_flat = 0.15;
} elseif ($home === 'other') {
$home_other = explode("/", $home_other);
$cur = " " . $home_other[0];
$c_b = $home_other[1];
$c_l = $home_other[2];
$c_d = $home_other[3];
$c_flat = $home_other[4];
}
// Take currency and meal rates for the default country. Other home countries are not supported.
$defaults = explode("/", $defaults);
$cur = " " . $defaults[0]; // currency
$c_b = intval($defaults[1]); // breakfast rate
$c_l = intval($defaults[2]); // lunch rate
$c_d = intval($defaults[3]); // dinner rate
$c_flat = intval($defaults[4]); // flat rate (money which employee gets even if all meals are paid)
// eligible amount per day
if ($dest === 'other') {
$dest = $dest_other; // if other destination, just take this value
} else {
$pattern = "/" . $home . "=([0-9.]+)?\/([0-9.]+)?/"; // define pattern something like "/de=12/24/"
$pattern = "/([0-9.]+)?\/([0-9.]+)?/"; // define pattern something like "/12/24/"
$dest = preg_match($pattern, $dest, $match, PREG_OFFSET_CAPTURE); // actually search for it
$dest = $match[0][0]; // matches are on 2nd level inn an array
$dest = explode('=', $dest); // now separate at the "="
$dest = $dest[1]; // take the second half of it "12/24"
$dest = $match[0][0]; // matches are on 2nd level in an array
}
// dest -> epd (half/full amount)
@@ -298,7 +281,7 @@ if ($extra) {
$html .= "<p>Extra remarks: <br />$extra</p>";
$email_body .= "
The sender added the following comment:
$extra";
+16 -32
View File
@@ -40,15 +40,17 @@
you will have to uncheck those meals which FSFE paid for, e.g. by
paying the hotel room incl. breakfast.
</p>
<p>
The outward and return travel day are calculated with a reduced
per diem amount, according to the legislation of your residence
(currently Germany is pre-defined). Please make sure that you
know whether a certain day counts as half/travel or full day.
</p>
<form action="/cgi-bin/perdiem.php" method="post">
<!-- Define default settings and rates. Currently Germany -->
<input type="hidden" name="defaults" value="€/0.2/0.4/0.4/0" />
<h2>1. Set general options</h2>
@@ -59,6 +61,7 @@
<option value="Alexander Sander|alex.sander">Alexander Sander</option>
<option value="Bonnie Mehring|bonnie">Bonnie Mehring</option>
<option value="Erik Albers|eal">Erik Albers</option>
<option value="Fani Partsafyllidou|fani">Fani Partsafyllidou</option>
<option value="Francesca Indorato|fi">Francesca Indorato</option>
<option value="Gabriel Ku Wei Bin|gabriel.ku">Gabriel Ku Wei Bin</option>
<option value="Lucas Lasota|lucas.lasota">Lucas Lasota</option>
@@ -85,29 +88,15 @@
</div>
</div>
<h2>2. Select your own country</h2>
<!-- if you add new countries, the respective settings have to be set in PHP file -->
<div class="form-group">
<label class="radio-inline">
<input type="radio" name="home" value="de" checked="checked" /> Germany
</label>
<label class="radio-inline">
<input type="radio" name="home" value="other" /> Other
</label>
<input type="text" name="home_other" placeholder="€/0.2/0.4/0.4/0" />
<p>(Other: currency and percentage rates: currency/breakfast/lunch/dinner/flat (e.g. "€/0.2/0.4/0.4/0" for Germany). If <em>Other</em> is selected, you'll have to set the values for the destination country in the next step manually)</p>
</div>
<h2>3. Select the destination country</h2>
<h2>2. Select the destination country</h2>
<!-- you can add new countries. For the individual amounts, set value="CC=$travel/$full,[...]" -->
<div class="form-group">
<label class="radio-inline">
<input type="radio" name="dest" value="de=14/28,se=314.5/629" checked="checked" /> Germany
<input type="radio" name="dest" value="14/28" checked="checked" /> Germany
</label>
<label class="radio-inline">
<input type="radio" name="dest" value="de=28/42,se=344/688" /> Belgium
<input type="radio" name="dest" value="28/42" /> Belgium
</label>
<label class="radio-inline">
<input type="radio" name="dest" value="other" /> Other
@@ -115,8 +104,8 @@
<input type="text" name="dest_other" placeholder="14/28" />
<p>(Other: per diem travel/full (e.g. "14/28" for Germany -> Germany). <a href="https://www.reisekostenabrechnung.com/verpflegungsmehraufwand-2020/">(See the different rates per country.)</a></p>
</div>
<h2>4. Which meal did you pay yourself?</h2>
<h2>3. Which meal did you pay yourself?</h2>
<table class="table table-striped">
<tr>
<th>Use</th>
@@ -132,14 +121,14 @@
<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 class="descr">
<td colspan="5">Please be aware of when a day counts as travel or full day!</td>
</tr>
<tr>
<td><input type="checkbox" name="use[out]" value="yes" checked="checked" /></td>
<td><input type="date" name="date[out]" /></td>
@@ -204,7 +193,7 @@
<td><input type="checkbox" name="lunch[7]" value="yes" checked="checked" /></td>
<td><input type="checkbox" name="dinner[7]" value="yes" checked="checked" /></td>
</tr>
<tr>
<td colspan="5"><strong>Return travel day</strong></td>
</tr>
@@ -221,7 +210,7 @@
</tr>
</table>
<h2>5. Extra remarks / notes</h2>
<h2>4. Extra remarks / notes</h2>
<p>If necessary, you can add additional remarks and notes to the statement you send.</p>
@@ -229,7 +218,7 @@
<textarea name="extra" class="form-control" rows="3"></textarea>
</div>
<h2>6. Submit per diem report</h2>
<h2>5. Submit per diem report</h2>
<p>If you would like to preview the results, either via email or
only in the web interface, choose differing options below. To not
@@ -251,13 +240,8 @@
<button type="submit" class="btn btn-primary">Submit per diem report</button>
</form>
</body>
</html>
<!--
Local Variables: ***
mode: xml ***
End: ***
-->