-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkm.php
More file actions
executable file
·112 lines (79 loc) · 2.48 KB
/
km.php
File metadata and controls
executable file
·112 lines (79 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
iconv_set_encoding("internal_encoding", "UTF-8");
iconv_set_encoding("output_encoding", "UTF-8");
iconv_set_encoding("input_encoding", "UTF-8");
ob_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once('login.class.php');
include_once('helper.class.php');
include_once 'database.class.php';
$log = new CLogin();
$helper = new Helper();
header ('Content-Type:text/html; charset=UTF-8');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Arbeitsplan - Kilometerabrechnung</title>
<link href="default.css" rel="stylesheet" type="text/css">
<body>
<div id="kmbox">
<?php
$userid = $log->getIdUser();
$startweek = $_POST["datefrom"];
$endweek = $_POST["dateto"];
global $dbserver;
global $dbuser;
global $dbpass;
global $dbname;
$dbx = new DatabaseConnection($dbserver, $dbuser, $dbpass, $dbname);
$ssql = "SELECT year(startdate) FROM " . CConfig::$db_tbl_prefix . "users WHERE id=$userid";
$res;
$year = "0000";
if ($res = $dbx->ExecuteSql($ssql) ) {
if ( $ff = $res->fetch_row() ) {
$year = $ff[0];
}
}
else {
echo "There was a problem: $ssql";
die;
}
// KM Money
$ssql = "SELECT kmsatz FROM " . CConfig::$db_tbl_prefix . "users WHERE id=$userid";
$res = $dbx->ExecuteSql($ssql);
$kmsatz = 0.0;
$totalmoney = 0.0;
$kms = 0;
if ( $ff = $res->fetch_row() ) {
$kmsatz = $ff[0];
}
$sd = $helper->CalendarWeekStartDate($startweek, $year);
$ed = $helper->CalendarWeekStartDate($endweek, $year);
$ssql = "SELECT km FROM " . CConfig::$db_tbl_prefix . "kilometers WHERE user_id=$userid AND day >= '$sd' AND day < '$ed' ORDER BY day, id";
if ( $res = $dbx->ExecuteSql($ssql) ) {
while ( $ff = $res->fetch_row() ) {
$daymoney = $ff[0];
$kms += $ff[0];
$daymoney *= $kmsatz;
$totalmoney += $daymoney;
}
}
$dname = $log->getDisplayName();
echo "<h1> Gefahrene Kilometer während der Arbeit für das Jugendbüro </h1>";
echo "<p>Mitarbeiter(in): $dname </p>";
echo "<p>Von Woche $startweek bis Woche $endweek </p>";
echo "<p>Anzahl Kilometer: $kms </p>";
$kmsatz = number_format($kmsatz, 4, ",", ".");
echo "<p>Kilometersatz: € $kmsatz </p>";
$totalmoney = number_format($totalmoney, 2, ",", ".");
echo "<p>Berechtigte Entschädigung: € $totalmoney</p>";
?>
<form method="post" action="">
<?php //echo $helper->generateKmInvoiceTable($log->getIdUser()); ?>
<!-- Offener Betrag: <input type="text" name="money"> <input type="submit" value="!"> -->
</form>
</div>
</body>
</html>