function do_page_summary()
{
    global $project;
    $projectid = $project->projectid;
    if (!$project->pages_table_exists) {
        return;
    }
    echo "<center>";
    echo "<h3>" . _("Page Summary") . "</h3>\n";
    // page counts by state.
    $total_num_pages = Project_getNumPages($projectid);
    echo "<table border=0>\n";
    global $PAGE_STATES_IN_ORDER;
    foreach ($PAGE_STATES_IN_ORDER as $page_state) {
        $num_pages = Project_getNumPagesInState($projectid, $page_state);
        if ($num_pages != 0) {
            // TRANSLATORS: %s is a page state, this is a label in a table for the number of pages in this state
            echo "<tr><td align='right'>{$num_pages}</td><td>" . sprintf(_("in %s"), $page_state) . "</td></tr>\n";
        }
    }
    echo "<tr><td colspan='2'><hr></td></tr>\n";
    echo "<tr><td align='right'>{$total_num_pages}</td><td align='center'>" . _("Pages Total") . "</td></tr>\n";
    echo "</table>\n";
    echo "</center>";
}
echo "    <td align='center' colspan='4'>" . _("In this phase we go through each page and annotate which pages contain footnotes, chapter headings, etc.") . "</td><tr></tr>\n";
echo "    <td align='center' colspan='1'><b>" . _("Title") . "</b></td>\n";
echo "    <td align='center' colspan='1'><b>" . _("Author") . "</b></td>\n";
echo "    <td align='center' colspan='1'><b>" . _("Total Pages") . "</b></td>\n";
echo "    <td align='center' colspan='1'><b>" . _("Remaining Pages") . "</b></td>\n";
echo "</tr>\n";
$result = mysql_query("SELECT projectid, nameofwork, authorsname, language, username, state FROM projects\n                WHERE state = 'project_md_second'");
$numrows = mysql_num_rows($result);
$rownum = 0;
while ($rownum < $numrows) {
    $projectid = mysql_result($result, $rownum, "projectid");
    $state = mysql_result($result, $rownum, "state");
    $name = mysql_result($result, $rownum, "nameofwork");
    $author = mysql_result($result, $rownum, "authorsname");
    $language = mysql_result($result, $rownum, "language");
    $numpages = Project_getNumPages($projectid);
    $availpages = Project_getNumPagesInState($projectid, 'avail_md_second');
    if ($rownum % 2) {
        $row_color = $theme['color_mainbody_bg'];
    } else {
        $row_color = $theme['color_navbar_bg'];
    }
    echo "<tr bgcolor='{$row_color}'>";
    echo "<td align='right'><a href = \"md_phase2.php?projectid={$projectid}\">{$name}</a></td>\n";
    echo "<td align='right'>{$author}</td>\n";
    echo "<td align='right'>{$numpages}</td>\n";
    echo "<td align='right'>{$availpages}</td>\n";
    $rownum++;
    echo "</tr>";
}
echo "</table>";
 if (!$res) {
     echo mysql_error(), "\n";
     echo "Skipping further processing of this project.\n";
     continue;
 }
 $n_reclaimable_pages = mysql_num_rows($res);
 if ($verbose) {
     echo "        reclaiming {$n_reclaimable_pages} pages\n";
 }
 while (list($image) = mysql_fetch_row($res)) {
     Page_reclaim($projectid, $image, $round, '[automodify.php]');
 }
 // Decide whether the project is finished its current round.
 if ($state == $round->project_available_state) {
     $num_done_pages = Project_getNumPagesInState($projectid, $round->page_save_state);
     $num_total_pages = Project_getNumPages($projectid);
     if ($num_done_pages != $num_total_pages) {
         if ($verbose) {
             echo "    Only {$num_done_pages} of {$num_total_pages} pages are in '{$round->page_save_state}'.\n";
         }
         continue;
     }
     if ($verbose) {
         echo "    All {$num_total_pages} pages are in '{$round->page_save_state}'.\n";
     }
     if (project_has_a_hold_in_state($projectid, $state)) {
         if ($verbose) {
             echo "    Normally, this project would now advance to {$round->project_complete_state},\n";
             echo "    but it has a hold in {$state}, so it stays where it is.\n";
         }
         continue;