2016-06-12 15:35:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
2016-06-12 17:34:31 +00:00
|
|
|
$output = '';
|
|
|
|
|
|
2016-06-12 15:35:27 +00:00
|
|
|
$epd = $_POST['country']; // Euro per day
|
2016-06-12 17:34:31 +00:00
|
|
|
if ($epd === 'other') {
|
|
|
|
|
$epd = $_POST['country_other'];
|
|
|
|
|
}
|
2016-06-12 15:35:27 +00:00
|
|
|
$epd = explode('/', $epd);
|
|
|
|
|
$epd_trav = $epd[0];
|
|
|
|
|
$epd_full = $epd[1];
|
|
|
|
|
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<p>Travel day(s): " . $epd_trav . " EUR per day <br />";
|
|
|
|
|
$output .= "Full day(s): " . $epd_full . " EUR per day</p>";
|
2016-06-12 15:35:27 +00:00
|
|
|
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= '<table class="table table-striped">
|
2016-06-12 15:35:27 +00:00
|
|
|
<tr>
|
|
|
|
|
<th>Date</th>
|
2016-06-12 17:34:31 +00:00
|
|
|
<th>Breakfast</th>
|
|
|
|
|
<th>Lunch</th>
|
|
|
|
|
<th>Dinner</th>
|
2016-06-12 15:35:27 +00:00
|
|
|
<th>Your Reimbursement</th>
|
2016-06-12 17:34:31 +00:00
|
|
|
</tr>';
|
2016-06-12 15:35:27 +00:00
|
|
|
|
|
|
|
|
$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
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<tr>";
|
2016-06-12 15:35:27 +00:00
|
|
|
|
|
|
|
|
// date
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<td>" . $date . $desc . "</td>";
|
2016-06-12 15:35:27 +00:00
|
|
|
|
|
|
|
|
// breakfast ($r_b)
|
|
|
|
|
if ($break === "yes") {
|
|
|
|
|
$r_b = $eur * 0.2;
|
|
|
|
|
$r_day = $r_day + $r_b;
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<td>yes (" . $r_b . " €)</td>";
|
2016-06-12 15:35:27 +00:00
|
|
|
} else {
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<td>no</td>";
|
2016-06-12 15:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lunch ($r_l)
|
|
|
|
|
if ($lunch === "yes") {
|
|
|
|
|
$r_l = $eur * 0.4;
|
|
|
|
|
$r_day = $r_day + $r_l;
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<td>yes (" . $r_l . " €)</td>";
|
2016-06-12 15:35:27 +00:00
|
|
|
} else {
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<td>no</td>";
|
2016-06-12 15:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// breakfast ($r_d)
|
|
|
|
|
if ($dinner === "yes") {
|
|
|
|
|
$r_d = $eur * 0.4;
|
|
|
|
|
$r_day = $r_day + $r_d;
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<td>yes (" . $r_d . " €)</td>";
|
2016-06-12 15:35:27 +00:00
|
|
|
} else {
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<td>no</td>";
|
2016-06-12 15:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// reimbursement for the single day
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<td>" . $r_day . " €</td>";
|
2016-06-12 15:35:27 +00:00
|
|
|
$r_total = $r_total + $r_day;
|
|
|
|
|
|
|
|
|
|
// close row (day)
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "</tr>";
|
2016-06-12 15:35:27 +00:00
|
|
|
|
|
|
|
|
} // if day is used
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-12 17:34:31 +00:00
|
|
|
$output .= "<tr><td></td><td></td><td></td><td></td>";
|
|
|
|
|
$output .= "<td><strong>Total VKP: " . $r_total . " €</strong></td></tr></table>";
|
2016-06-12 15:35:27 +00:00
|
|
|
|
2016-06-12 17:34:31 +00:00
|
|
|
//------------------------------------
|
2016-06-12 15:35:27 +00:00
|
|
|
|
2016-06-12 17:34:31 +00:00
|
|
|
function replace_page($temp, $content){
|
|
|
|
|
$vars = array('%RESULT%'=>$content);
|
|
|
|
|
return str_replace(array_keys($vars), $vars, $temp);
|
|
|
|
|
}
|
2016-06-12 15:35:27 +00:00
|
|
|
|
2016-06-12 17:34:31 +00:00
|
|
|
$template = file_get_contents('/home/www/html/global/internal/pd-result.en.html', true);
|
2016-06-12 15:35:27 +00:00
|
|
|
|
2016-06-12 17:34:31 +00:00
|
|
|
echo replace_page($template, $output);
|
|
|
|
|
|
|
|
|
|
?>
|