1.1.0 - Fixed "end of year"-bug

Fixed the bug with the end of the year, where the $kw could be higher than 52 (or 53).
This commit is contained in:
Gehirnfussel 2013-12-20 10:26:22 +01:00
parent 12e17959c1
commit 4f30d3429d
1 changed files with 21 additions and 7 deletions

View File

@ -1,7 +1,7 @@
<?php
#¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
# version......: 1.0.2
# last.change..: 2013-11-15
# version......: 1.1.0
# last.change..: 2013-12-19
# created.by...: Jan Jastrow
# contact......: jan@schwerkraftlabor.de
# license......: MIT license
@ -9,10 +9,17 @@
#_________________
# Gibt die Kalenderwoche des 31.12. des aktuellen Jahres aus
$max_kw = date("W",mktime(0,0,0,12,31,date("Y")));
date_default_timezone_set('Europe/Berlin');
function maxKW($year) {
if (date("W",mktime(0,0,0,12,31,$year)) == 53)
return 53;
else
return 52;
}
$max_kw = maxKW(date("o"));
# Kalenderwoche ermitteln
$kw = date('W');
$akt_kw = date('W');
# GET-Parameter auslesen
if(isset($_GET['wann']))
@ -21,7 +28,7 @@ else
$wann = 0; # Standard: Aktuelle Woche (+0)
# Diese Woche + $wann
$kw = $kw + $wann;
$kw = $akt_kw + $wann;
# Standort auslesen
if(isset($_GET['wo']))
@ -29,6 +36,13 @@ if(isset($_GET['wo']))
else
$wo = "RD"; # Standard: RD
# Jahresende-Check
if($kw > $max_kw)
$kw = $kw - $max_kw;
if($kw < 10)
$kw = "0".$kw;
# Pfad und Dateiname zum PDF
$speiseplan = "file://Server/Path1-".$wo."/Path2/".$kw."-KW.pdf";
@ -49,9 +63,9 @@ echo '<!doctype html>
</style>
</head>
<body>
<!-- <script type="text/javascript">window.location = "'.$speiseplan.'"</script> -->
<script type="text/javascript">window.location = "'.$speiseplan.'"</script>
<p>Es erfolgt eine automatische Weiterleitung zum aktuellen Speiseplan…</p>
<p>Sollte diese nicht stattfinden, können Sie <a href="'.$speiseplan.'">hier klicken</a>, um zum aktuellen Speiseplan zu kommen.</p>
<p>Sollte diese nicht stattfinden, können Sie <a href="'.$speiseplan.'">hier klicken</a>, um zum aktuellen Speiseplan zu kommen oder <a href="file://Server/Path1-'.$wo.'/Path2/personalspeiseplan_'.strtolower($wo).'.htm">hier klicken</a>, um zur Wochenübersicht zu gelangen.</p>
<p>Falls ein Fehler auftritt, wenden Sie sich bitte an Ihren Administrator.</p>
</body>
</html>';