<?
include('../Code/confHeader.inc');
$Me -> goIfInvalid("../index.php");
$Me -> goIfNotAssistant('../index.php');
$Conf -> connect();

function olink($key,$string)
{
  return "<a href=\"$PHP_SELF?orderBy=$key\"> $string </a>";
}

?>

<html>
<style type=text/css>
p.page {page-break-after: always}
</style>


<? $Conf->header("List All Submitted Papers") ?>

<body>
<?

$finalizedStr = "";
if ( $onlyFinalized ) {
  $finalizedStr =  " AND Paper.acknowledged!=0 ";
}

$ORDER="ORDER BY Paper.paperId";
if (IsSet($orderBy)) {
  $ORDER = "ORDER BY $orderBy";
}
?>
<h2> List of submitted papers  </h2>
<p>
This page shows you all the papers & abstracts that have been entered into the database.
Under Microsoft Internet Explorer, you should be able to "Print" or "Print Preview" and it
will print a single abstract per page (overly long abstracts may print on two pages).
I'm not certain if this works under Netscape or other browsers.
</p>

<P CLASS=page> You should see a page break following this when printing. </p>

<FORM method="POST" action="<?echo $PHP_SELF?>">
<INPUT type=checkbox name=onlyFinalized value=1
   <? if ($onlyFinalized) {echo "checked";}?> > Only show finalized </br>
<input type="submit" value="Update View" name="submit">
</p>


<?
  $query="SELECT Paper.paperId, Paper.title, "
  . " Paper.acknowledged, Paper.withdrawn, "
  . " Paper.abstract,  "
  . " LENGTH(PaperStorage.paper), PaperStorage.mimetype "
  . " FROM Paper, ContactInfo "
  . " LEFT JOIN PaperStorage ON (PaperStorage.paperId=Paper.paperId)"
  . " WHERE ContactInfo.contactId = Paper.ContactId "
  . $finalizedStr
  . $ORDER;

$result=$Conf->q($query);

  if (DB::isError($result) ) {
    $Conf->errorMsg("Error in retrieving paper list " . $result->getMessage());
  } else {
   while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC) ) {
     $paperId=$row['paperId'];
     $title=$row['title'];
     $abstract=$row['abstract'];
     $mimetype=$row['mimetype'];
     $length=$row['LENGTH(PaperStorage.paper)'];
  ?>


<div align=center>
<h2> Paper # <? echo $paperId ?> </h2>
</div>

<table align=center width="100%" border=1 bgcolor="<?echo $Conf->bgOne?>" >
<h3>
   <tr> <td> Title: </td> <td> <? echo $title ?> </td> </tr>
<tr> <td> Abstract: </td> <td> <? echo $abstract ?> </td> </tr>
</table>

<table align=center width="75%" border=0 >
</table>

  <?
}
}
?>

</body>
<? $Conf->footer() ?>
</html>

