<?
include('../Code/confHeader.inc');
$Conf -> connect();

if ( IsSet($loginEmail) ) {
  $Me -> lookupByEmail($loginEmail, $Conf);
  if ( IsSet($password)
       && $Conf -> validTimeFor('reviewerSubmitReviewDeadline', 0)
       && $Me -> valid()
       && $Me -> password == $password) {
    //
    // Let them fall through -- they'll hit other security
    // checks in just a second, but they've been
    // logged in
    //
  } else {
    $Me -> invalidate();
    header("Location: ../index.php");
  }
}

$Me -> goIfInvalid("../index.php");
if ($Me->isPC) {
  //  $Conf -> goIfInvalidActivity("PCSubmitReviewDeadline", "../index.php");
} else {
  $Conf -> goIfInvalidActivity("reviewerSubmitReviewDeadline", "../index.php");
}

?>

<html>

<? $Conf->header("Select A Paper To Review As Requested by Program Committee") ?>

<body>


<h2> Requested Reviews </h2>

<p>You have been asked to review the following paper(s) by a member of the progam committee.
Click on the link to start or modify a review or to see your finalized review.
<b> You can continue to modify your review(s)
<? echo $Conf->printTimeRange('reviewerSubmitReview') ?>
or until you finalize them. </b>
</p>

<p> You can download the papers by clicking on the appropriate paper title; you will
find the link to download the paper at the top of the review form </p>

<?
 //
 // Now, look for reviews directed to this person
 //

$result=$Conf->qe("SELECT Paper.paperId, Paper.title, Paper.withdrawn FROM Paper, ReviewRequest "
		    . "WHERE ReviewRequest.asked='$Me->contactId' AND Paper.paperId=ReviewRequest.paperId "
		    . "ORDER BY Paper.paperId");
if (!DB::isError($result)) {
  $i = 0;
  while ($row=$result->fetchRow(DB_FETCHMODE_ASSOC)) {
    if ( !$row['withdrawn']) {
      $ids[$i] = $row['paperId'];
      $titles[$i] = $row['title'];
      $i++;
    }
  }
} else {
  $Conf->errorMsg("Error in sql " . $result->getMessage());
}

$Me->printReviewables($ids, $titles, "ReviewerSubmitReview.php", $Conf);
?>

<?
//
// Some PC members also like seeing their primary reviews here..
//
if ($Me -> isPC) {
?>

<h2> Primary Reviews </h2>

<p>You have been asked to review the following paper(s)
by the program chair.
Click on the link to start or modify a review or to see your finalized review.
<b> You can continue to modify your review(s)
<? echo $Conf->printTimeRange('PCSubmitReview') ?>
or until you finalize them. </b>
</p>

<p> You can download the papers by clicking on the appropriate paper title; you will
find the link to download the paper at the top of the review form </p>
<?
$result=$Conf->qe("SELECT Paper.paperId, Paper.title, Paper.withdrawn "
		  . " FROM Paper, PrimaryReviewer "
		  . "WHERE PrimaryReviewer.reviewer='$Me->contactId' "
		  . " AND Paper.paperId=PrimaryReviewer.paperId "
		  . "ORDER BY Paper.paperId");

if (DB::isError($result)) {
  $Conf->errorMsg("Error in sql " . $result->getMessage());
} else {
  $ids=array();
  $titles=array();
  $i = 0;
  while ($row=$result->fetchRow(DB_FETCHMODE_ASSOC)) {
    if ( !$row['withdrawn']) {
      $ids[$i] = $row['paperId'];
      $titles[$i] = $row['title'];
      $i++;
    }
  }
  $Me -> printReviewables($ids, $titles, "../PC/PCSubmitReview.php", $Conf);
}
}
?>


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