View All Submissions';
if (!isset($_GET['pid']) || !ctype_digit($_GET['pid'])) {
	err("Submission id is invalid");
}
// Get sub info
$spq = "SELECT * FROM `" . OCC_TABLE_PAPER . "` WHERE `paperid`='" . safeSQLstr($_GET['pid']) . "'";
$spr = ocsql_query($spq) or err("Unable to get submissions ");
if (ocsql_num_rows($spr)!=1) {
	err("There does not appear to be a submission with that id (or there is more than one)");
}
$spl = ocsql_fetch_array($spr);
// Get authors
$oc_authorNum = 0;
$qa = "SELECT * FROM `" . OCC_TABLE_AUTHOR . "` WHERE `paperid`='" . safeSQLstr($_GET['pid']) . "'";
$ra = ocsql_query($qa) or err("Unable to get " . oc_strtolower(OCC_WORD_AUTHOR) . "s ");
while ($a = ocsql_fetch_array($ra)) {
	$apos = $a['position'];
	foreach ($a as $akey => $aval) {
		if (preg_match("/^(?:paperid|position)$/", $akey)) { continue; }
		$spl[$akey . $apos] = $aval;
	}
}
$oc_authorNum = $apos;
// Get topics
$qt = "SELECT `topicid` FROM `" . OCC_TABLE_PAPERTOPIC . "` WHERE `paperid`='" . safeSQLstr($_GET['pid']) . "'";
$rt = ocsql_query($qt) or err("Unable to get topics ");
$spl['topics'] = array();
while ($t = ocsql_fetch_array($rt)) {
  $spl['topics'][] = $t['topicid'];
}
require_once OCC_FORM_INC_FILE;
require_once OCC_SUBMISSION_INC_FILE;
$files = '| File | ';
if ($spl['format'] && oc_isFile($pfile = $OC_configAR['OC_paperDir'] . preg_replace("/\D/", "", $_GET['pid']) . "." . $spl['format'])) {
	$files .= "" . safeHTMLstr($_GET['pid']) . ".".$spl['format']." (" . oc_formatNumber(oc_fileSize($pfile)) . ')';
} else {
	$files .= "not uploaded";
}
$files .= ' | 
';
$advocate = '';
if ($OC_configAR['OC_paperAdvocates']) {
	$qadv = "SELECT `" . OCC_TABLE_PAPERADVOCATE . "`.`advocateid`, CONCAT_WS(' ',`" . OCC_TABLE_REVIEWER . "`.`name_first`,`" . OCC_TABLE_REVIEWER . "`.`name_last`) AS `name`, `" . OCC_TABLE_REVIEWER . "`.`organization` FROM `" . OCC_TABLE_PAPERADVOCATE . "`, `" . OCC_TABLE_REVIEWER . "` WHERE `" . OCC_TABLE_PAPERADVOCATE . "`.`paperid`='" . safeSQLstr($_GET['pid']) . "' AND `" . OCC_TABLE_PAPERADVOCATE . "`.`advocateid`=`" . OCC_TABLE_REVIEWER . "`.`reviewerid`";
	$radv = ocsql_query($qadv) or err("Unable to get advocate info ");
	if (ocsql_num_rows($radv) == 1) {
		$spladv = ocsql_fetch_array($radv);
		$advocate .= '| Advocate: | ' . safeHTMLstr($spladv['name']) . ', ' . $spladv['organization'] . ' | 
';
	}
}
$reviewers = '';
$qrev = "SELECT `" . OCC_TABLE_PAPERREVIEWER . "`.`reviewerid`, CONCAT_WS(' ',`" . OCC_TABLE_REVIEWER . "`.`name_first`,`" . OCC_TABLE_REVIEWER . "`.`name_last`) AS `name`, `" . OCC_TABLE_REVIEWER . "`.`organization` FROM `" . OCC_TABLE_PAPERREVIEWER . "`, `" . OCC_TABLE_REVIEWER . "` WHERE `" . OCC_TABLE_PAPERREVIEWER . "`.`paperid`='" . safeSQLstr($_GET['pid']) . "' AND `" . OCC_TABLE_PAPERREVIEWER . "`.`reviewerid`=`" . OCC_TABLE_REVIEWER . "`.`reviewerid`";
$rrev = ocsql_query($qrev) or err("Unable to get reviewers info ");
if (($rows = ocsql_num_rows($rrev)) > 0) {
	$reviewers .= '| Reviewer(s): | ';
	while ($splrev = ocsql_fetch_array($rrev)) {
		$reviewers .= (($rows > 1) ? '• ' : '') . '' . safeHTMLstr($splrev['name']) . ', ' . $splrev['organization'] . ' ';
	}
	$reviewers .= ' | 
';
}
print '
       
| ID: | ' . safeHTMLstr($_GET['pid']) . ' | 
| Submitted: | ' . safeHTMLstr($spl['submissiondate']) . ' | 
| Last Updated: | ' . safeHTMLstr($spl['lastupdate']) . ' | 
';
oc_showFieldSet($OC_submissionFieldSetAR, $OC_submissionFieldAR, $spl);
$extra = '';
if (oc_hookSet('chair-show_paper')) {
	foreach ($GLOBALS['OC_hooksAR']['chair-show_paper'] as $hook) {
		require_once $hook;
	}
}
print $files . $extra . $advocate . $reviewers;
print '
';
printFooter();
?>