<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Bugs</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" title="Default" href="main.css" type="text/css" />
</head>
<?
    my $action = $request->get("action", "NONE");
    if($action eq "resolved") {
        my $id = $request->get("id", "0");
        $EQW->ResolveBug($id);
    }

    $offset = $request->get("offset", "0");
    $count = $EQW->CountBugs();
    @bugs = $EQW->ListBugs($offset);
#  @bugs = (
#   { who => "Kim", where => "arena (0.0, 4.0, 5.0)", target => "an_arena_fighter000", description => "Wont accept a simple summons item" }
#  );

?>

<body>
<h2 align="center">Bug List</h2>
<hr/>
<div align="center">
<?
    my $sep = ($count / 30);
    for(my $i = 0; $i < $sep; ++$i) {
        my $cur = 30 * $i;
        my $name = $i + 1;
        print "<a href='bugs.html?offset=$cur'>$name</a> ";
    }
?>
</div>
<?
print "There are $count bugs in the database.";
?>
<hr/>
<table width="100%"  border="1" cellspacing="2" cellpadding="3" class="zonelist">
  <tr>
    <th scope="col">Actions</th>
    <th scope="col">Reporter</th>
    <th scope="col">Where</th>
    <th scope="col">Target</th>
    <th scope="col">Descripton</th>
  </tr>
<?
  for my $bugkey (@bugs) {
		my $bug = $EQW->GetBugDetails($bugkey);
		if(!$bug) {
			next;
		}

		print "<tr>\n";
        print "<td><a href='bugs.html?action=resolved&id=$bug->{id}&offset=$offset'>Resolved</a></td>";
		print "<td>$bug->{name}</td>";
        print "<td>$bug->{zone}: ($bug->{x}, $bug->{y}, $bug->{z})</td>";
        print "<td>$bug->{target}</td>";
        print "<td>$bug->{bug}</td>";
		print "</tr>\n";
  }
?>
</table>
<div align="center">
<?
    my $sep = ($count / 30);
    for(my $i = 0; $i < $sep; ++$i) {
        my $cur = 30 * $i;
        my $name = $i + 1;
        print "<a href='bugs.html?offset=$cur'>$name</a> ";
    }
?>
</div>



</body>
</html>
