Changeset 148 for www/otevreno.php
- Timestamp:
- Feb 15, 2009, 7:59:35 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/otevreno.php
r146 r148 1 1 <?php 2 include ('style.php');2 include_once('global.php'); 3 3 4 ShowHeader('Otvírací doby místních subjektů', 'Otvírací doby'); 5 $DaysOfWeek = array('Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle'); 4 class 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'); 6 9 7 10 function Show() 8 11 { 9 global $Database, $DaysOfWeek;10 11 12 $Output = '<div align="center">'; 12 $DbResult = $ 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');13 $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'); 13 14 while($Subject = $DbResult->fetch_array()) 14 15 { 15 16 $Output .= '<strong>'.$Subject['Name'].':</strong><br />'; 16 $DbResult2 = $ Database->query('SELECT Subject, OpenTime, CloseTime, TIMEDIFF(CloseTime, 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']);17 $DbResult2 = $this->Database->query('SELECT Subject, OpenTime, CloseTime, TIMEDIFF(CloseTime, 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']); 17 18 if($DbResult2->num_rows > 0) 18 19 { … … 21 22 } else 22 23 { 23 $DbResult2 = $ 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');24 $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'); 24 25 $DbRow = $DbResult2->fetch_array(); 25 26 $Output .= 'Otevírá za '.$DbRow['RemainTime']; … … 27 28 $Output .= '<table class="WideTable"> 28 29 <tr><th>Den</th><th>Čas</th></tr>'; 29 foreach($ DaysOfWeek as $DayIndex => $DayOfWeek)30 foreach($this->DaysOfWeek as $DayIndex => $DayOfWeek) 30 31 { 31 $DbResult2 = $ Database->query('SELECT *, DATE_FORMAT(OpenTime, "%k:%i") as OpenTime, DATE_FORMAT(CloseTime, "%k:%i") as CloseTime FROM SubjectOpenTimeInterval WHERE SubjectOpenTimeInterval.Subject = '.$Subject['Subject'].' AND ((DAYOFWEEK(OpenTime) + 0) MOD 7)='.$DayIndex);32 $DbResult2 = $this->Database->query('SELECT *, DATE_FORMAT(OpenTime, "%k:%i") as OpenTime, DATE_FORMAT(CloseTime, "%k:%i") as CloseTime FROM SubjectOpenTimeInterval WHERE SubjectOpenTimeInterval.Subject = '.$Subject['Subject'].' AND ((DAYOFWEEK(OpenTime) + 0) MOD 7)='.$DayIndex); 32 33 $Output .= '<tr><td>'.$DayOfWeek.'</td><td align="center">'; 33 34 if($DbResult2->num_rows) … … 47 48 return($Output); 48 49 } 50 } 49 51 50 echo(Show()); 51 52 ShowFooter(); 52 $System->AddModule(new SubjectOpenTimePage()); 53 $System->Modules['SubjectOpenTimePage']->GetOutput(); 53 54 54 55 ?>
Note:
See TracChangeset
for help on using the changeset viewer.