<?php

// +----------------------------------------------------------------------+
// | OpenConf                                                             |
// +----------------------------------------------------------------------+
// | Copyright (c) 2002-2011 Zakon Group LLC.  All Rights Reserved.       |
// +----------------------------------------------------------------------+
// | This source file is subject to the OpenConf License, available on    |
// | the OpenConf web site: www.OpenConf.com                              |
// +----------------------------------------------------------------------+

require_once "../include.php";

beginChairSession();

if (isset($_REQUEST['cmt']) && ($_REQUEST['cmt'] == "rev")) {
	$cmtAdd = " WHERE onprogramcommittee='F'";
	$hdr = "Review Committee Members";
} elseif (isset($_REQUEST['cmt']) && ($_REQUEST['cmt'] == "pc")) {
	$cmtAdd = " WHERE onprogramcommittee='T'";
	$hdr = "Program Committee Members";
} elseif ($OC_configAR['OC_paperAdvocates']) {
	$cmtAdd = '';
	$hdr = "Review &amp; Program Committee Members";
} else {
	$cmtAdd = '';
	$hdr = "Review Committee Members";
}

printHeader($hdr." Country Count",1);

if (!isset($_GET['s']) || ($_GET['s'] == "country")) {
    $sortby = "country";
	$csort = 'Country<br />' . $OC_sortImg;
	$nsort = '<a href="' . $_SERVER['PHP_SELF'] . '?s=num&cmt=' . (isset($_GET['cmt']) ? urlencode($_GET['cmt']) : '') . '">Count</a>';
} else {
	$sortby = "num";
	$nsort = 'Count<br />' . $OC_sortImg;
	$csort = '<a href="' . $_SERVER['PHP_SELF'] . '?s=country&cmt=' . (isset($_GET['cmt']) ? urlencode($_GET['cmt']) : '') . '">Country</a>';
}

$q = "SELECT country, COUNT(reviewerid) AS num FROM " . OCC_TABLE_REVIEWER . " $cmtAdd GROUP BY country ORDER BY $sortby";
$r = ocsql_query($q) or err("Unable to get information");
if (mysql_num_rows($r) == 0) {
        print '<span class="warn">No committee members have signed up yet</span><p>';
} else {
	print '<table border="0" cellpadding="5" cellspacing="1" style="margin: 0 auto"><tr class="rowheader"><th valign="top">' . $csort . '</th><th valign="top">' . $nsort . "</th></tr>\n";
	$row = 1;
	while ($l = mysql_fetch_array($r)) {
	  	print '<tr class="row' . $row . '"><td>' . $l['country'] . '</td><td align="right">'.$l['num']."</td></tr>\n";
		if ($row==1) { $row=2; } else { $row=1; }
	}
	print "</table>";
}

printFooter();

?>