$result = $Conf->qe("select ContactInfo.contactId, count(reviewId)\n                from ContactInfo\n                left join PaperReview on (PaperReview.contactId=ContactInfo.contactId and PaperReview.reviewType>=" . REVIEW_SECONDARY . ")\n                where (roles&" . Contact::ROLE_PC . ")!=0\n                group by ContactInfo.contactId");
$rev_count = array();
while ($row = edb_row($result)) {
    $rev_count[$row[0]] = $row[1];
}
$rev_opt = array();
if ($reviewer <= 0) {
    $rev_opt[0] = "(Select a PC member)";
}
foreach ($pcm as $pc) {
    $rev_opt[$pc->contactId] = Text::name_html($pc) . " (" . plural(defval($rev_count, $pc->contactId, 0), "assignment") . ")";
}
echo "<table><tr><td><strong>PC member:</strong> &nbsp;</td>", "<td>", Ht::select("reviewer", $rev_opt, $reviewer, array("onchange" => "hiliter(this)")), "</td></tr>", "<tr><td colspan='2'><div class='g'></div></td></tr>\n";
// Paper selection
$q = $qreq->q == "" ? "(All)" : $qreq->q;
echo "<tr><td>Paper selection: &nbsp;</td><td>", Ht::entry_h("q", $q, array("id" => "manualassignq", "size" => 40, "placeholder" => "(All)", "title" => "Paper numbers or search terms")), " &nbsp;in &nbsp;";
if (count($tOpt) > 1) {
    echo Ht::select("t", $tOpt, $qreq->t, array("onchange" => "hiliter(this)"));
} else {
    echo join("", $tOpt);
}
echo "</td></tr>\n", "<tr><td colspan='2'><div class='g'></div>\n";
echo Ht::radio("kind", "a", $qreq->kind == "a", array("onchange" => "hiliter(this)")), "&nbsp;", Ht::label("Assign reviews and/or conflicts"), "<br />\n", Ht::radio("kind", "c", $qreq->kind == "c", array("onchange" => "hiliter(this)")), "&nbsp;", Ht::label("Assign conflicts only (and limit papers to potential conflicts)"), "</td></tr>\n";
echo "<tr><td colspan='2'><div class='aax' style='text-align:right'>", Ht::submit("Go", array("class" => "bb")), "</div></td></tr>\n", "</table>\n</div></form></div></td></tr></table>\n";
function make_match_preg($str)
{
    $a = $b = array();
    foreach (explode(" ", preg_quote($str)) as $word) {
        if ($word != "") {
            $a[] = Text::utf8_word_regex($word);
            if (!preg_match("/[€-ÿ]/", $word)) {
        $classes = ($classes ? $classes . " " : "") . "error";
    }
    if ($classes) {
        return '<div class="' . $classes . '">';
    } else {
        return '<div>';
    }
}
echo Ht::form(hoturl_post("autoassign", array("profile" => $Qreq->profile, "seed" => $Qreq->seed, "XDEBUG_PROFILE" => $Qreq->XDEBUG_PROFILE))), '<div class="aahc">', "<div class='helpside'><div class='helpinside'>\nAssignment methods:\n<ul><li><a href='", hoturl("autoassign"), "' class='q'><strong>Automatic</strong></a></li>\n <li><a href='", hoturl("manualassign"), "'>Manual by PC member</a></li>\n <li><a href='", hoturl("assign") . "'>Manual by paper</a></li>\n <li><a href='", hoturl("bulkassign"), "'>Bulk update</a></li>\n</ul>\n<hr class='hr' />\nTypes of PC review:\n<dl><dt>" . review_type_icon(REVIEW_PRIMARY) . " Primary</dt><dd>Mandatory, may not be delegated</dd>\n  <dt>" . review_type_icon(REVIEW_SECONDARY) . " Secondary</dt><dd>Mandatory, may be delegated to external reviewers</dd>\n  <dt>" . review_type_icon(REVIEW_PC) . " Optional</dt><dd>May be declined</dd></dl>\n</div></div>\n";
// paper selection
echo divClass("pap"), "<h3>Paper selection</h3>";
if (!isset($Qreq->q)) {
    // XXX redundant
    $Qreq->q = join(" ", $SSel->selection());
}
echo Ht::entry_h("q", $Qreq->q, array("id" => "autoassignq", "placeholder" => "(All)", "size" => 40, "title" => "Enter paper numbers or search terms", "class" => "hotcrp_searchbox", "onfocus" => 'autosub("requery",this)')), " &nbsp;in &nbsp;";
if (count($tOpt) > 1) {
    echo Ht::select("t", $tOpt, $Qreq->t, array("onchange" => "highlightUpdate(\"requery\")"));
} else {
    echo join("", $tOpt);
}
echo " &nbsp; ", Ht::submit("requery", "List", array("id" => "requery"));
if (isset($Qreq->requery) || isset($Qreq->haspap)) {
    echo "<br /><span class='hint'>Assignments will apply to the selected papers.</span>\n<div class='g'></div>";
    $search = new PaperSearch($Me, array("t" => $Qreq->t, "q" => $Qreq->q, "urlbase" => hoturl_site_relative_raw("autoassign")));
    $plist = new PaperList($search);
    $plist->display .= " reviewers ";
    $plist->papersel = $SSel->selection_map();
    echo $plist->table_html("reviewersSel", ["nofooter" => true]), Ht::hidden("prevt", $Qreq->t), Ht::hidden("prevq", $Qreq->q), Ht::hidden("haspap", 1);
}
echo "</div>\n";