Changeset 93 for devel/www/otevreno.php


Ignore:
Timestamp:
Jul 26, 2008, 2:03:12 PM (16 years ago)
Author:
george
Message:

Upraveno: Přepracována stránka otvírací doby. Dynamické zobrazení času do oteveření a zavření.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/www/otevreno.php

    r87 r93  
    66  var $FullTitle = 'Otvírací doby místních subjektů';
    77  var $ShortTitle = 'Otvírací doby';
     8  var $DaysOfWeek = array('Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle');
     9  var $Subjects = array(
     10    'Jednota' => array(
     11      'Notice' => '',
     12      'LastUpdateTime' => '2008-07-04',
     13      'Intervals' => array(
     14        array('DayOfWeek' => 0, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
     15        array('DayOfWeek' => 0, 'Index' => 1,  'OpenTime' => '14:00:00', 'CloseTime' => '16:30:00'),
     16        array('DayOfWeek' => 1, 'Index' => 0,  'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
     17        array('DayOfWeek' => 2, 'Index' => 0,  'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
     18        array('DayOfWeek' => 2, 'Index' => 1,  'OpenTime' => '14:00:00', 'CloseTime' => '16:30:00'),
     19        array('DayOfWeek' => 3, 'Index' => 0,  'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
     20        array('DayOfWeek' => 3, 'Index' => 1,  'OpenTime' => '14:00:00', 'CloseTime' => '16:30:00'),
     21        array('DayOfWeek' => 4, 'Index' => 0,  'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
     22        array('DayOfWeek' => 4, 'Index' => 1,  'OpenTime' => '13:30:00', 'CloseTime' => '16:30:00'),
     23        array('DayOfWeek' => 5, 'Index' => 0,  'OpenTime' => '6:00:00', 'CloseTime' => '10:30:00'),
     24      ),
     25    ),
     26    'Pošta' => array(
     27      'Notice' => 'Schránka se vybírá v pracovní dny v 7:45 a 9:30',
     28      'LastUpdateTime' => '2007-07-20',
     29      'Intervals' => array(
     30        array('DayOfWeek' => 0, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     31        array('DayOfWeek' => 0, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
     32        array('DayOfWeek' => 1, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     33        array('DayOfWeek' => 1, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
     34        array('DayOfWeek' => 2, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     35        array('DayOfWeek' => 2, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
     36        array('DayOfWeek' => 3, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     37        array('DayOfWeek' => 3, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
     38        array('DayOfWeek' => 4, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     39        array('DayOfWeek' => 4, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
     40        array('DayOfWeek' => 5, 'Index' => 0,  'OpenTime' => '6:00:00', 'CloseTime' => '10:30:00'),
     41      ),
     42    ),
     43    'Obecní úřad' => array(
     44      'Notice' => 'Zdroj <a href="http://www.zdechov.cz/pages/main.php?pg=obecniurad&cat=1">www.zdechov.cz</a>',
     45      'LastUpdateTime' => '2008-07-07',
     46      'Intervals' => array(
     47        array('DayOfWeek' => 0, 'Index' => 0,  'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
     48        array('DayOfWeek' => 0, 'Index' => 1,  'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
     49        array('DayOfWeek' => 1, 'Index' => 0,  'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
     50        array('DayOfWeek' => 1, 'Index' => 1,  'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
     51        array('DayOfWeek' => 2, 'Index' => 0,  'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
     52        array('DayOfWeek' => 2, 'Index' => 1,  'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
     53        array('DayOfWeek' => 3, 'Index' => 0,  'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
     54        array('DayOfWeek' => 3, 'Index' => 1,  'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
     55        array('DayOfWeek' => 4, 'Index' => 0,  'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
     56        array('DayOfWeek' => 4, 'Index' => 1,  'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
     57      ),
     58    ),
     59    'Kavárna Centrum' => array(
     60      'Notice' => '',
     61      'LastUpdateTime' => '2006-09-13',
     62      'Intervals' => array(
     63        array('DayOfWeek' => 0, 'Index' => 0,  'OpenTime' => '15:00:00', 'CloseTime' => '21:00:00'),
     64        array('DayOfWeek' => 1, 'Index' => 0,  'OpenTime' => '15:00:00', 'CloseTime' => '21:00:00'),
     65        array('DayOfWeek' => 2, 'Index' => 0,  'OpenTime' => '15:00:00', 'CloseTime' => '21:00:00'),
     66        array('DayOfWeek' => 3, 'Index' => 0,  'OpenTime' => '15:00:00', 'CloseTime' => '21:00:00'),
     67        array('DayOfWeek' => 4, 'Index' => 0,  'OpenTime' => '15:00:00', 'CloseTime' => '21:00:00'),
     68        array('DayOfWeek' => 5, 'Index' => 0,  'OpenTime' => '15:00:00', 'CloseTime' => '22:00:00'),
     69      ),
     70    ),
     71    'Knihovna' => array(
     72      'Notice' => '',
     73      'LastUpdateTime' => '2004-08-20',
     74      'Intervals' => array(
     75        array('DayOfWeek' => 4, 'Index' => 0,  'OpenTime' => '14:30:00', 'CloseTime' => '17:00:00'),
     76      ),
     77    ),
     78    'Koliba' => array(
     79      'Notice' => '',
     80      'LastUpdateTime' => '2008-04-29',
     81      'Intervals' => array(
     82        array('DayOfWeek' => 2, 'Index' => 0,  'OpenTime' => '14:00:00', 'CloseTime' => '22:00:00'),
     83        array('DayOfWeek' => 3, 'Index' => 0,  'OpenTime' => '14:00:00', 'CloseTime' => '22:00:00'),
     84        array('DayOfWeek' => 4, 'Index' => 0,  'OpenTime' => '14:00:00', 'CloseTime' => '27:00:00'),
     85        array('DayOfWeek' => 5, 'Index' => 0,  'OpenTime' => '14:00:00', 'CloseTime' => '27:00:00'),
     86        array('DayOfWeek' => 6, 'Index' => 0,  'OpenTime' => '14:00:00', 'CloseTime' => '21:00:00'),
     87      ),
     88    ),
     89    'Hospoda Kasino' => array(
     90      'Notice' => '',
     91      'LastUpdateTime' => '2008-07-04',
     92      'Intervals' => array(
     93        array('DayOfWeek' => 0, 'Index' => 0,  'OpenTime' => '16:00:00', 'CloseTime' => '21:00:00'),
     94        array('DayOfWeek' => 1, 'Index' => 0,  'OpenTime' => '16:00:00', 'CloseTime' => '21:00:00'),
     95        array('DayOfWeek' => 2, 'Index' => 0,  'OpenTime' => '17:00:00', 'CloseTime' => '21:00:00'),
     96        array('DayOfWeek' => 3, 'Index' => 0,  'OpenTime' => '17:00:00', 'CloseTime' => '21:00:00'),
     97        array('DayOfWeek' => 4, 'Index' => 0,  'OpenTime' => '16:00:00', 'CloseTime' => '24:00:00'),
     98        array('DayOfWeek' => 5, 'Index' => 0,  'OpenTime' => '14:00:00', 'CloseTime' => '24:00:00'),
     99        array('DayOfWeek' => 6, 'Index' => 0,  'OpenTime' => '10:00:00', 'CloseTime' => '21:00:00'),
     100      ),
     101    ),
     102  );
    8103
    9104  function Show()
    10105  {
    11     $Output = '<div align="center">
     106    //$this->ImportToDatabase();
    12107
    13 <strong>Jednota:</strong>
    14 <table class="WideTable">
    15 <tr><th>Den</th><th>Dopoledne</th><th>Odpoledne</th></tr>
    16 <tr><td>Pondělí</td><td>7:00 - 12:00</td><td>14:00 - 16:30</td></tr>
    17 <tr><td>Úterý</td><td>7:00 - 12:00</td><td>&nbsp;</td></tr>
    18 <tr><td>Středa</td><td>7:00 - 12:00</td><td>14:00 - 16:30</td></tr>
    19 <tr><td>Čtvrtek</td><td>7:00 - 12:00</td><td>14:00 - 16:30</td></tr>
    20 <tr><td>Pátek</td><td>7:00 - 12:00</td><td>13:30 - 16:30</td></tr>
    21 <tr><td>Sobota</td><td>6:00 - 10:30</td><td>&nbsp;</td></tr>
    22 <tr><td>Neděle</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>
    23 Aktualizováno: 15.7.2004<br /><br />
     108    $Output = '<div align="center">';
     109    $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');
     110    while($Subject = $DbResult->fetch_array())
     111    {
     112      $Output .= '<strong>'.$Subject['Name'].':</strong><br />';
     113      $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']);
     114      if($DbResult2->num_rows > 0)
     115      {
     116        $DbRow = $DbResult2->fetch_array();
     117        $Output .= 'Zavírá za '.$DbRow['RemainTime'];
     118      } else
     119      {
     120        $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');
     121        $DbRow = $DbResult2->fetch_array();
     122        $Output .= 'Otevírá za '.$DbRow['RemainTime'];
     123      }
     124      $Output .= '<table class="WideTable">
     125<tr><th>Den</th><th>Čas</th></tr>';
     126      foreach($this->DaysOfWeek as $DayIndex => $DayOfWeek)
     127      {
     128        $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);
     129        $Output .= '<tr><td>'.$DayOfWeek.'</td><td align="center">';
     130        if($DbResult2->num_rows)
     131        {
     132          while($TimeInterval = $DbResult2->fetch_array())
     133          {
     134            $Output .= $TimeInterval['OpenTime'].' - '.$TimeInterval['CloseTime'].' &nbsp;&nbsp; ';
     135          }
     136        } else
     137          $Output .= '&nbsp;';
     138        $Output .= '</td></tr>';
     139      }
     140      $Output .= '</table>Aktualizováno: '.$Subject['UpdateTime'].'<br />';
     141      if($Subject['Notice'] != '') $Output .= '</table>Poznámka: '.$Subject['Notice'].'<br />';
     142      $Output .= '<br />';
     143    }
     144    return($Output);
     145  }
    24146
    25 <strong>Pošta:</strong>
    26 <table class="WideTable">
    27 <tr><th>Den</th><th>Dopoledne</th><th>Odpoledne</th></tr>
    28 <tr><td>Pondělí</td><td>8:00 - 10:00</td><td>14:30 - 15:30</td></tr>
    29 <tr><td>Úterý</td><td>8:00 - 10:00</td><td>14:30 - 15:30</td></tr>
    30 <tr><td>Středa</td><td>8:00 - 10:00</td><td>14:30 - 15:30</td></tr>
    31 <tr><td>Čtvrtek</td><td>8:00 - 10:00</td><td>14:30 - 15:30</td></tr>
    32 <tr><td>Pátek</td><td>8:00 - 10:00</td><td>14:30 - 15:30</td></tr>
    33 <tr><td>Sobota</td><td>&nbsp;</td><td>&nbsp;</td></tr>
    34 <tr><td>Neděle</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>
    35 Schránka se vybírá v pracovní dny v 7:45 a 9:30<br />
    36 Aktualizováno: 20.7.2007<br /><br />
    37 
    38 <strong>Kavárna Centrum:</strong>
    39 <table class="WideTable">
    40 <tr><th>Den</th><th>Čas</th></tr>
    41 <tr><td>Pondělí</td><td>&nbsp;</td></tr>
    42 <tr><td>Úterý</td><td>15:00 - 21:00</td></tr>
    43 <tr><td>Středa</td><td>15:00 - 21:00</td></tr>
    44 <tr><td>Čtvrtek</td><td>15:00 - 21:00</td></tr>
    45 <tr><td>Pátek</td><td>15:00 - 21:00</td></tr>
    46 <tr><td>Sobota</td><td>15:00 - 22:00</td></tr>
    47 <tr><td>Neděle</td><td>&nbsp;</td></tr></table>
    48 Aktualizováno: 13.9.2006<br /><br />
    49 
    50 <strong>Knihovna:</strong>
    51 <table class="WideTable">
    52 <tr><th>Den</th><th>Čas</th></tr>
    53 <tr><td>Pondělí</td><td>&nbsp;</td></tr>
    54 <tr><td>Úterý</td><td>&nbsp;</td></tr>
    55 <tr><td>Středa</td><td>&nbsp;</td></tr>
    56 <tr><td>Čtvrtek</td><td>&nbsp;</td></tr>
    57 <tr><td>Pátek</td><td>14:30 - 17:00</td></tr>
    58 <tr><td>Sobota</td><td>&nbsp;</td></tr>
    59 <tr><td>Neděle</td><td>&nbsp;</td></tr></table>
    60 Aktualizováno: 20.8.2004<br /><br />
    61 
    62 <strong>Koliba:</strong>
    63 <table class="WideTable">
    64 <tr><th>Den</th><th>Čas</th></tr>
    65 <tr><td>Pondělí</td><td>&nbsp;</td></tr>
    66 <tr><td>Úterý</td><td>&nbsp;</td></tr>
    67 <tr><td>Středa</td><td>14:00 - 22:00</td></tr>
    68 <tr><td>Čtvrtek</td><td>14:00 - 22:00</td></tr>
    69 <tr><td>Pátek</td><td>14:00 - 3:00</td></tr>
    70 <tr><td>Sobota</td><td>14:00 - 3:00</td></tr>
    71 <tr><td>Neděle</td><td>14:00 - 21:00</td></tr></table>
    72 Aktualizováno: 29.4.2008<br /><br />';
    73     return($Output);
     147  function ImportToDatabase()
     148  {
     149    $this->Database->query('DELETE FROM Subject WHERE Subject.Id = SubjectOpenTime.Subject');
     150    $this->Database->query('TRUNCATE TABLE SubjectOpenTime');
     151    $this->Database->query('TRUNCATE TABLE SubjectOpenTimeInterval');
     152    foreach($this->Subjects as $SubjectName => $Subject)
     153    {
     154      $this->Database->insert('Subject', array('Name' => $SubjectName));
     155      $Subject['Id'] = $this->Database->insert_id;
     156      $this->Database->insert('SubjectOpenTime', array('Notice' => $Subject['Notice'], 'UpdateTime' => $Subject['LastUpdateTime'], 'Subject' => $Subject['Id']));
     157      foreach($Subject['Intervals'] as $TimeInterval)
     158      {
     159        $TimeInterval['Subject'] = $Subject['Id'];
     160        $TimeInterval['OpenTime'] = '0000-01-0'.($TimeInterval['DayOfWeek'] + 1).' '.$TimeInterval['OpenTime'];
     161        $TimeInterval['CloseTime'] = '0000-01-0'.($TimeInterval['DayOfWeek'] + 1).' '.$TimeInterval['CloseTime'];
     162        unset($TimeInterval['DayOfWeek']);
     163        unset($TimeInterval['Index']);
     164        $this->Database->insert('SubjectOpenTimeInterval', $TimeInterval);
     165        //echo($this->Database->LastQuery.'<br>');
     166      }
     167    }
    74168  }
    75169}
Note: See TracChangeset for help on using the changeset viewer.