#include <infodrom.style>

<page func="Infodrom Oldenburg" title="Events">
<calendar_init -6>

<?
  $row = false;

  if ($_GET[id] > 0) {
    $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
		 or die("Unable to connect to SQL server");

    pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");

    $columns = 'name,city,country,start,start+delta AS stop,delta,conference,exhibition,url,deburl,localurl,cancelled';
    $query = sprintf ("SELECT %s FROM events WHERE oid = %d", $columns, $_GET[id]);
    $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");

    if (pg_NumRows ($sth) > 0) {
      $row = pg_fetch_array ($sth, 0);

      $start = explode (" ", $row['start']);
      $start = explode ("-", $start[0]);
      $start = sprintf ("%d.%d.%d", $start[2], $start[1], $start[0]);

      $end = explode (" ", $row['stop']);
      $end = explode ("-", $end[0]);
      $end = sprintf ("%d.%d.%d", $end[2], $end[1], $end[0]);

      $days = explode (" ", $row['delta']);
      $days = $days[0] + 1;
    }
  }
  if ($row === false) {
    echo('<h3>Keine Veranstaltung angegeben</h3>');
  } else {
    printf('<h3>%s</h3>', $row['name']);
    printf('<p style="margin-top: -10px; font-size: 10px; font-weight: bold;">%s, %s</p>', $row['city'], $row['country']);
    echo('<p>');
    if ($days > 1) {
      printf("Datum: %s &ndash; %s<br>", $start, $end);
      printf("Dauer: %d Tage<br>", $days);
    } else
      printf("Datum: %s<br>", $start);
    if ($row['conference']==1 && $row['exhibition']==1)
      echo("Art: Konferenz und Ausstellung<br>");
    elseif ($row['conference']==1)
      echo("Art: Konferenz<br>");
    elseif ($row['exhibition']==1)
      echo("Art: Ausstellung<br>");
    printf('URL: <a href="%s">%s</a><br>', $row['url'], $row['url']);
    if ($row['deburl'])
      printf('Debian URL: <a href="%s">%s</a><br>', $row['deburl'], $row['deburl']);
    if ($row['localurl'])
      printf('Local URL: <a href="%s">%s</a><br>', $row['localurl'], $row['localurl']);
    if ($row['cancelled']==1)
      echo('abgesagt<br>');
    if ($row['comment'])
      echo $row['comment'];
    echo('</p>');
?>
<p><form method=post action="update.php">
<input type=hidden name=id value="<? echo $_GET[id]; ?>">
<b>New date:</b> <input name=date id=date size=10 maxlength=10 value="" tabindex=1> <calendar "date"> &nbsp;
<input class=button type=submit name=clone value="Clone">
</form></p>
<?
  }
?>
</page>

# Local variables:
# mode: indented-text
# mode: auto-fill
# end:
