#include "party.style"

<auth>

#include <infodrom.style>
#include <debian.style>

<page title="Debian Birthday Party -- Edit Data">

<h1 align=center>Debian Birthday Party</h1>

<?
  # Only the admin is permitted to edit an id different to his own
  if ($DEBIAN_AUTH['admin'] != 1 || !isset ($id)) {
    $id = $DEBIAN_AUTH['id'];
  }

  $query = sprintf ("SELECT * FROM party_person WHERE id = %d", $id);
  $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");

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

?>
<fetch_days>

<form method=post action=update.php3>
<?
  # The admin may pass the id through
  if ($DEBIAN_AUTH['admin'] == 1 && $id != $DEBIAN_AUTH['id']) {
    printf ("<input name=\"id\" type=\"hidden\" value=\"%d\">", $id);
  }
?>

<br><input name=name value="<? echo $row['name']; ?>" type=text size=50 maxlen=100> <b>Name</b> 
<br><input name=email value="<? echo $row['email']; ?>" type=text size=50 maxlen=100> <b>E-Mail</b>
<br><input name=login value="<? echo $row['login']; ?>" type=text size=50 maxlen=100> <b>Login</b>
<br><input name=city value="<? echo $row['city']; ?>" type=text size=50 maxlen=100> <b>City</b>
<br><input name=country value="<? echo $row['country']; ?>" type=text size=50 maxlen=100> <b>Country</b>
<br><select name=food>
<option value="meat"<? echo $row['food']=="meat"?" selected":"";?>>anything
<option value="vegetarian"<? echo $row['food']=="vegetarian"?" selected":"";?>>vegetarian
<option value="vegan"<? echo $row['food']=="vegan"?" selected":"";?>>vegan
</select> <b>Food</b>
<br><select name=type>
<option value="Developer"<? echo $row['type']=="Developer"?" selected":"";?>>Debian Developer
<option value="User"<? echo $row['type']=="User"?" selected":"";?>>Debian User
<option value="Geek"<? echo $row['type']=="Geek"?" selected":"";?>>Regular Geek
<option value="Guest"<? echo $row['type']=="Guest"?" selected":"";?>>Guest
</select> <b>Type</b>
<br><?
  $query  = "SELECT day,weekday FROM party_dates ORDER BY day";
  $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");

  $days = fetch_days ($dbh, $id);

  for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
    $row = pg_fetch_array ($sth, $nr);

    printf ("<input name=\"%s\" value=\"1\" type=\"checkbox\"%s> %s&nbsp;&nbsp;",
	   $row['day'], $days[$row['day']]==1?" checked":"", $row['weekday']);
  }
?> <b>Days</b>
<?
  # The admin may create a new password
  if ($DEBIAN_AUTH['admin'] == 1 && $id != $DEBIAN_AUTH['id']) {
?>
<br><input type=checkbox value=1 name=newpass> <b>New password</b>
<? } ?>
<br><input type=checkbox value=1 name=delete> <b>Delete this</b>

<br><input type=submit value="Change">
</form>

</page>

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