function testStep5_iteration()
 {
     $db_config = new mock_db_configure(3);
     $db_q = array(0 => $this->queries['step5_iteration']);
     $dat = $this->_generate_records(array("proid"), 3);
     $rows = $this->_generate_records(array("milestone_number", "iteration"), 8);
     for ($idx = 0; $idx < 3; $idx++) {
         $db_config->add_query(sprintf($db_q[0], $dat[$idx]["proid"]), $idx);
         $db_config->add_num_row($idx * 2, $idx);
     }
     // first test: no rows
     $this->assertEquals(0, step5_iteration($dat[0]["proid"]), "test 1");
     // second test: 2 rows: milestone_number -1 and -2
     $rows[0]["milestone_number"] = -1;
     $rows[0]["iteration"] = 10;
     $rows[1]["milestone_number"] = -2;
     $rows[1]["iteration"] = 20;
     $db_config->add_record($rows[0], 1);
     $db_config->add_record($rows[1], 1);
     $this->assertEquals(0, step5_iteration($dat[1]["proid"]), "test 2");
     // third test: 4 rows: milestone_number 2, 1, 0, -1
     $rows[2]["milestone_number"] = 2;
     $rows[2]["iteration"] = 10;
     $rows[3]["milestone_number"] = 1;
     $rows[3]["iteration"] = 20;
     $rows[4]["milestone_number"] = 0;
     $rows[4]["iteration"] = 30;
     $rows[5]["milestone_number"] = -1;
     $rows[5]["iteration"] = 40;
     $db_config->add_record($rows[2], 2);
     $db_config->add_record($rows[3], 2);
     $db_config->add_record($rows[4], 2);
     $db_config->add_record($rows[5], 2);
     $this->assertEquals(20, step5_iteration($dat[2]["proid"]), "test 3");
     // check the database
     $this->_check_db($db_config);
 }
######################################################################
require "include/prepend.php3";
page_open(array('sess' => 'SourceAgency_Session'));
if (isset($auth) && !empty($auth->auth['perm'])) {
    page_close();
    page_open(array('sess' => 'SourceAgency_Session', 'auth' => 'SourceAgency_Auth', 'perm' => 'SourceAgency_Perm'));
}
require 'include/header.inc';
require 'include/followuplib.inc';
require 'include/decisionslib.inc';
$bx = new box('100%', $th_box_frame_color, $th_box_frame_width, $th_box_title_bgcolor, $th_box_title_font_color, $th_box_title_align, $th_box_body_bgcolor, $th_box_body_font_color, $th_box_body_align);
start_content();
$page = 'step5_sponsor';
if (check_permission($proid, $page)) {
    top_bar($proid, $page);
    if (step5_iteration($proid) != 3) {
        print $t->translate("This is the page where sponsors accept or reject milestones") . ".\n";
        $db->query("SELECT quorum FROM configure WHERE proid='{$proid}'");
        $db->next_record();
        $decision_value = $db->f('quorum');
        $milestone_number = followup_current_milestone($proid);
        $count = followup_current_count($proid, $milestone_number);
        $location = followup_location($proid, $milestone_number, $count);
        if (!isset($Yes) || empty($Yes)) {
            $voted_yet = 0;
            if (!strcmp($vote, 'vote')) {
                put_decision_step5_into_database($proid, $decision, $milestone_number, $count);
            }
            // If the sponsor has already voted, then we look for his vote
            if (!isset($decision) || empty($decision)) {
                $db->query("SELECT decision FROM decisions_step5 WHERE proid='{$proid}' AND decision_user='******' AND number='{$milestone_number}' AND count='{$count}'");