source: trunk/otevreno.php@ 203

Last change on this file since 203 was 203, checked in by george, 16 years ago
  • Opraveno: Validace HTML stránky otvírací doby subjektů.
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1<?php
2include_once('global.php');
3
4class SubjectOpenTimePage extends Page
5{
6 var $FullTitle = 'Otvírací doby místních subjektů';
7 var $ShortTitle = 'Otvírací doby';
8 var $DaysOfWeek = array('Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle');
9 var $DayShift = 3;
10
11 function Show()
12 {
13 $Output = '<div class="Centred">';
14 $DbResult = $this->Database->query('SELECT SubjectOpenTime.*, DATE_FORMAT(SubjectOpenTime.UpdateTime, "%e.%c.%Y") as UpdateTime, Subject.Name as Name FROM SubjectOpenTime JOIN Subject ON Subject.Id = SubjectOpenTime.Subject ORDER BY Name');
15 while($Subject = $DbResult->fetch_assoc())
16 {
17 $Output .= '<strong>'.$Subject['Name'].':</strong><br />';
18
19 $DbResult2 = $this->Database->query('SELECT Subject, OpenTime, CloseTime, TIMEDIFF(DATE_FORMAT(CloseTime, "0000-01-%w %T"), DATE_FORMAT(NOW(), "0000-01-%w %T")) as RemainTime FROM `SubjectOpenTimeInterval` WHERE DATE_FORMAT(NOW(), "0000-01-%w %T") > OpenTime AND DATE_FORMAT(NOW(), "0000-01-%w %T") < CloseTime AND Subject='.$Subject['Subject']);
20 if($DbResult2->num_rows > 0)
21 {
22 $DbRow = $DbResult2->fetch_assoc();
23 $Output .= 'Zavírá za '.$DbRow['RemainTime'];
24 } else
25 {
26 $DbResult2 = $this->Database->query('SELECT Subject, OpenTime, CloseTime, TIMEDIFF(OpenTime, DATE_FORMAT(NOW(), "0000-01-%w %T")) as RemainTime FROM `SubjectOpenTimeInterval` WHERE DATE_FORMAT(NOW(), "0000-01-%w %T") < OpenTime AND Subject='.$Subject['Subject'].' ORDER BY OpenTime LIMIT 1');
27 $DbRow = $DbResult2->fetch_assoc();
28 $Output .= 'Otevírá za '.$DbRow['RemainTime'];
29 }
30
31 $Output .= '<table class="WideTable">
32<tr><th>Den</th><th>Čas</th></tr>';
33 foreach($this->DaysOfWeek as $DayIndex => $DayOfWeek)
34 {
35 $DbResult2 = $this->Database->query('SELECT *, DATE_FORMAT(OpenTime, "%k:%i") as OpenTime2, DATE_FORMAT(CloseTime, "%k:%i") as CloseTime2, DAYOFWEEK(OpenTime) as Week FROM SubjectOpenTimeInterval WHERE SubjectOpenTimeInterval.Subject = '.$Subject['Subject'].' AND ((DAYOFWEEK(OpenTime) + 7) MOD 7)='.$DayIndex);
36 $Output .= '<tr><td>'.$DayOfWeek.'</td><td align="center">';
37 if($DbResult2->num_rows)
38 {
39 while($TimeInterval = $DbResult2->fetch_assoc())
40 {
41 $Output .= $TimeInterval['OpenTime2'].' - '.$TimeInterval['CloseTime2'].' &nbsp;&nbsp; ';
42 }
43 } else
44 $Output .= '&nbsp;';
45 $Output .= '</td></tr>';
46 }
47 $Output .= '</table>Aktualizováno: '.$Subject['UpdateTime'].'<br />';
48 if($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />';
49 $Output .= '<br />';
50 }
51 $Output .= '</div>';
52 return($Output);
53 }
54}
55
56$System->AddModule(new SubjectOpenTimePage());
57$System->Modules['SubjectOpenTimePage']->GetOutput();
58
59?>
Note: See TracBrowser for help on using the repository browser.