function print_me($template)
{
    $leht =& $template->leht;
    #$curr_rub_id = $leht->id;
    $args[tulemuste_arv] = 10;
    $curr_rub_id = $leht->site->alias("gallup_arhiiv");
    $template->debug->msg("Rubriik: {$curr_rub_id}");
    ?>

<table width="<?php 
    echo $template->site->dbstyle("sisu_tabeli_laius", "layout");
    ?>
" height="<?php 
    echo $template->site->dbstyle("sisu_tabeli_korgus", "layout");
    ?>
"  border="0" cellspacing="<?php 
    echo $template->site->dbstyle("sisu_tabeli_cellspacing", "layout");
    ?>
" cellpadding="0">
    <tr valign="top"> 

<?php 
    $leht->debug->msg($leht->site->dbstyle("menyy", "layout"));
    ?>
<td width="100%">
	<h1 class="pealkiri"><?php 
    echo $template->site->sys_sona(array("sona" => $template->all["nimi"], "tyyp" => "kujundus"));
    ?>
</h1><br><hr noshade size="1" style="color:#dddddd;">

<?php 
    # ---------------------------
    # Gallup on siin
    # ---------------------------
    $alamlist_count = new Alamlist(array(parent => $curr_rub_id, klass => "gallup", on_counter => 1));
    ########## 1. ONE GALLUP
    if ($leht->site->fdat["gallup_id"]) {
        $obj = new Objekt(array(objekt_id => $leht->site->fdat["gallup_id"]));
    }
    if (!$obj) {
        $alamlist = new Alamlist(array(parent => $curr_rub_id, klass => "gallup", start => 0, limit => 1));
        $obj = $alamlist->next();
    }
    if ($obj->on_404) {
        header('Location: ' . $site->CONF['wwwroot'] . '/?id=' . $obj->objekt_id);
        exit;
    } elseif ($obj) {
        printf("<font class=sub_pealkiri>%s</font><br>", $obj->get_edit_buttons(array(tyyp_idlist => "6", nupud => array("edit", "delete"))) . $obj->pealkiri);
        $sql = $leht->site->db->prepare("SELECT * FROM gallup_vastus WHERE objekt_id=?", $obj->objekt_id);
        $sth = new SQL($sql);
        # tulemused
        #### 1. for MSSQL
        if (strtoupper($leht->site->CONF["dbtype"]) == 'MSSQL') {
            $sql = $leht->site->db->prepare("SELECT SUM([count]) AS kokku, MAX([count]) AS maksi FROM gallup_vastus WHERE objekt_id=?", $obj->objekt_id);
        } else {
            $sql = $leht->site->db->prepare("SELECT SUM(count) AS kokku, MAX(count) AS maksi FROM gallup_vastus WHERE objekt_id=?", $obj->objekt_id);
        }
        $sth_c = new SQL($sql);
        $stat = $sth_c->fetch();
        $obj->debug->msg("kokku = {$stat['kokku']}, maks = {$stat['maksi']}");
        $obj->debug->msg($sth_c->debug->get_msgs());
        ?>
		<table border=0>
			 <tr>
				 <td valign="top"><img src="<?php 
        echo $obj->site->img_path;
        ?>
/px.gif" width="300" height="3"></td>
			 </tr>
<?php 
        while ($vastus = $sth->fetch()) {
            $percent = $stat[kokku] ? sprintf('%2.0f', 100 * $vastus[count] / $stat[kokku]) : 0;
            ?>
					
			 <tr>
				 <td valign="top" class="<?php 
            echo $obj->site->agent ? "txt" : "txt1";
            ?>
"><?php 
            echo $vastus[vastus];
            ?>
</td>
			 </tr>
			 <tr>
				 <td valign="top"><b><font class="<?php 
            echo $obj->site->agent ? "txt" : "txt1";
            ?>
">- <?php 
            echo $percent;
            ?>
%</font></b> <img src="<?php 
            echo $obj->site->img_path;
            ?>
/gallup_bar<?php 
            echo $stat[maksi] == $vastus[count] && $vastus[count] ? "2" : "1";
            ?>
.gif" width="<?php 
            echo 0.01 * 250 * $percent;
            ?>
" height=8 border="1"></td>
			 </tr>
<?php 
        }
        # while vastus
        ?>
			 <tr>
				 <td valign="top" class="<?php 
        echo $obj->site->agent ? "txt" : "txt1";
        ?>
"><?php 
        echo $leht->site->sys_sona(array(sona => "vastajaid", tyyp => "kujundus"));
        ?>
: <b><?php 
        echo $stat[kokku];
        ?>
</b></td>
			 </tr>
		 </table>
		 <br><br>
<?php 
    }
    ########## 2. GALLUP LIST
    $alamlistSQL = new AlamlistSQL(array("parent" => $curr_rub_id, "klass" => "gallup"));
    $alamlistSQL->add_select(" DATE_FORMAT(objekt.aeg, '%d.%m.%y') as faeg ");
    $alamlistSQL->debug->print_msg();
    $template->debug->msg("SQL: " . $alamlistSQL->make_sql());
    $alamlist = new Alamlist(array(alamlistSQL => $alamlistSQL));
    $alamlist->debug->print_msg();
    ?>

	<table>
<?php 
    while ($obj = $alamlist->next()) {
        ?>
	<tr>
	<td class=date><?php 
        echo $obj->all['faeg'];
        ?>
</td>
	<td><a href="?op=gallup_arhiiv&page=<?php 
        echo $site->fdat['page'];
        ?>
&gallup_id=<?php 
        echo $obj->objekt_id;
        ?>
"><?php 
        echo $obj->get_edit_buttons(array("tyyp_idlist" => 6, "nupud" => array("edit", "delete")));
        echo $obj->all['pealkiri'];
        ?>
</a></td>

	</tr>
<?php 
    }
    ?>
	</table>



</td>
</tr>
</table>
<?php 
}