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
113
114
115
116
| $sql_tarieven = "SELECT * FROM tijden";
$resulttar = mysql_query($sql_tarieven) or die (mysql_error());
$weergave_tar = mysql_fetch_object ($resulttar);
$ZtarA = $weergave_tar->ZtarA ;
$ZtarB = $weergave_tar->ZtarB ;
$ZtarC = $weergave_tar->ZtarC ;
$ZtarD = $weergave_tar->ZtarD ;
$ZtarE = $weergave_tar->ZtarE ;
$Avan = substr($ZtarA,0,2).substr($ZtarA,2,2);
$Atot = substr($ZtarA,4,2).substr($ZtarA,6,2);
$Avanpunt = substr($ZtarA,0,2).":".substr($ZtarA,2,2);
$Atotpunt = substr($ZtarA,4,2).":".substr($ZtarA,6,2);
$Apro = substr($ZtarA,8,3);
$Bvan = substr($ZtarB,0,2).substr($ZtarB,2,2);
$Btot = substr($ZtarB,4,2).substr($ZtarB,6,2);
$Bvanpunt = substr($ZtarB,0,2).":".substr($ZtarB,2,2);
$Btotpunt = substr($ZtarB,4,2).":".substr($ZtarB,6,2);
$Bpro = substr($ZtarB,8,3);
$Cvan = substr($ZtarC,0,2).substr($ZtarC,2,2);
$Ctot = substr($ZtarC,4,2).substr($ZtarC,6,2);
$Cvanpunt = substr($ZtarC,0,2).":".substr($ZtarC,2,2);
$Ctotpunt = substr($ZtarC,4,2).":".substr($ZtarC,6,2);
$Cpro = substr($ZtarC,8,3);
$Dvan = "zaterdag";
$Dtot = "zaterdag";
$Dpro = $ZtarD;
$Evan = "zondag";
$Etot = "zondag";
$Epro = $ZtarE;
//D en E zit alleen een procent
//in A B C zit bv 01001200160 als van 0100 uur tot 1200 uur 160 % geldt
$sql_query = "SELECT * FROM medewerkers ORDER BY achternaam";
$resultgo = mysql_query($sql_query) or die (mysql_error());
while ($weergave = mysql_fetch_object ($resultgo)) //while 1
{
$gewerkt = "0";
$A = 0;
$B = 0;
$C = 0;
$D = 0;
$E = 0;
$F = 0;
$medewerker = $weergave->id;
$medewerker naam = $weergave->achternaam;
$sql_query2 = "SELECT * FROM afspraken WHERE mid = $medewerker AND startdatum LIKE '%$maand%$jaar%'";
$result2 = mysql_query($sql_query2) or die (mysql_error());
while ($get = mysql_fetch_object ($result2)) //while 2
{
$starttijdunix = strtotime("$get->startdatum $get->tijd");
$einddtijdunix = strtotime("$get->einddatum $get->eindtijd");
$dag = date("D",strtotime($get->startdatum));
if ($dag == "Sat")
{
$D += $einddtijdunix-$starttijdunix;
}
elseif ($dag == "Sun")
{
$E += $einddtijdunix-$starttijdunix;
}
elseif (date("Hi",$starttijdunix)>=$Avan && date("Hi",$einddtijdunix)<=$Atot)
{
$A += $einddtijdunix-$starttijdunix;
}
elseif (date("Hi",$starttijdunix)>=$Bvan && date("Hi",$einddtijdunix)<=$Btot)
{
$B += $einddtijdunix-$starttijdunix;
}
elseif (date("Hi",$starttijdunix)>=$Cvan && date("Hi",$einddtijdunix)<=$Ctot)
{
$C += $einddtijdunix-$starttijdunix;
}
else
{
$tempvan = strtotime("$get->startdatum 00:00");
$tempAvan = strtotime("$get->startdatum $Avanpunt");
$tempAtot = strtotime("$get->startdatum $Atotpunt");
$tempBvan = strtotime("$get->startdatum $Bvanpunt");
$tempBtot = strtotime("$get->startdatum $Btotpunt");
$tempCvan = strtotime("$get->startdatum $Cvanpunt");
$tempCtot = strtotime("$get->startdatum $Ctotpunt");
$temptot = strtotime("$get->startdatum 00:00")+86400;
////// afspraken die over een hele tariefperiode heen vallen
if ($starttijdunix<=$tempAvan && $einddtijdunix >= $tempAtot) {
$A += $tempAtot-$tempAvan; }
if ($starttijdunix<=$tempBvan && $einddtijdunix >= $tempBtot) {
$B += $tempBtot-$tempBvan; }
if ($starttijdunix<=$tempCvan && $einddtijdunix >= $tempCtot) {
$C += $tempCtot-$tempCvan; }
////// afspraken die over het eerste deel van een tariefperiode heen vallen
if ($starttijdunix<=$tempAvan && ($einddtijdunix >= $tempAvan && $einddtijdunix <= $tempAtot))
{
$A += $einddtijdunix-$tempAvan; }
if ($starttijdunix<=$tempBvan && ($einddtijdunix >= $tempBvan && $einddtijdunix <= $tempBtot))
{
$B += $einddtijdunix-$tempBvan; }
if ($starttijdunix<=$tempCvan && ($einddtijdunix >= $tempCvan && $einddtijdunix <= $tempCtot))
{
$C += $einddtijdunix-$tempCvan; }
////// afspraken die over het laatste deel van een tariefperiode heen vallen
if ($einddtijdunix>=$tempAtot && ($starttijdunix >= $tempAvan && $starttijdunix <= $tempAtot))
{
$A += $tempAtot-$starttijdunix; }
if ($einddtijdunix>=$tempBtot && ($starttijdunix >= $tempBvan && $starttijdunix <= $tempBtot))
{
$B += $tempBtot-$starttijdunix; }
if ($einddtijdunix>=$tempCtot && ($starttijdunix >= $tempCvan && $starttijdunix <= $tempCtot))
{
$C += $tempCtot-$starttijdunix; }
} //else
$duur = tijdnaargetal($get->aantal_uur);
$duur = $duur*3600; //duur in seconden
$gewerkt += $duur;
} //while 2
$F = $gewerkt-($A+$B+$C+$D+$E); //totaal - tijden uit tijdsblokken = rest |