<?php

// Prints all the stuff that a guy did that was in the 2004-2008 senate.
// We know that the person we are talking about is $person.
$sql = "SELECT sen.id, sen.idperson, sen.name, idm, timein, timeout, motif, " . "possible, percent, idparty " . "FROM senat_2004_senators AS sen " . "LEFT JOIN senat_2004_votes_agg AS votes " . "ON votes.idperson = sen.idperson " . "LEFT JOIN senat_2004_belong_agg AS belong " . "ON belong.idperson = sen.idperson " . "WHERE sen.id = {$person->id} ";
$sdep = mysql_query($sql);
$rdep = mysql_fetch_array($sdep);
$numVotes = getSenatorsNumberOfVotes();
// Vote percentages
$timein = $rdep['timein'] / 1000;
$timeout = $rdep['timeout'] / 1000;
// 1103259600 = 17 dec 2004
$t = new Smarty();
// Times in office, if need be
$t->assign('from', date("M Y", $timein));
$t->assign('to', $timeout == 0 ? 'Noiembrie 2008' : date("M Y", $timeout));
if ($rdep['timeout'] != 0) {
    $t->assign('reason', $rdep['motif'] != "" ? "(" . $rdep['motif'] . ")" : "");
}
// Print the party belonging during his senator years
$parties = getPartiesForSenator($rdep['idperson']);
$t->assign('party', getPartyName($parties[0]['name']));
$party_list = array();
if (sizeof($parties) > 1) {
    for ($i = 1; $i < sizeof($parties); $i++) {
        array_push($party_list, getPartyName($parties[$i]['name']) . " până în " . date("M Y", $parties[$i]['t'] / 1000));
    }
}
$t->assign('party_list', $party_list);
$candidateVotes = $rdep['possible'];
$percent = $rdep['percent'];
Example #2
0
/**
 * Displays a senator from the 2004-2008 timeframe.
 *
 * TODO(vivi) Should be replaced by the generic displaying of a person,
 * starting from the person ID and figuring out all that is related to that
 * person, not starting from the fact that he was a senator (which does not
 * scale).
 */
function showSenator($id)
{
    $sql = "SELECT sen.id, sen.name, idm, timein, timeout, motif, " . "possible, percent, idparty, cand.url as dep_url, " . "colleges.url as col_url, imgurl " . "FROM senat_2004_senators AS sen " . "LEFT JOIN senat_2004_votes_agg AS votes " . "ON votes.idperson = sen.idperson " . "LEFT JOIN senat_2004_belong_agg AS belong " . "ON belong.idperson = sen.idperson " . "LEFT JOIN alegeri_2008_candidates AS cand " . "ON cand.idperson = sen.idperson " . "LEFT JOIN alegeri_2008_colleges AS colleges " . "ON cand.college_id = colleges.id " . "WHERE sen.id = {$id} ";
    $sdep = mysql_query($sql);
    $numVotes = getSenatorsNumberOfVotes();
    $rdep = mysql_fetch_array($sdep);
    // ------------------ vote percentages
    $timein = $rdep['timein'] / 1000;
    $timeout = $rdep['timeout'] / 1000;
    // 1103259600 = 17 dec 2004
    echo "<div class=numedeputattitlu>" . $rdep['name'] . "</div>";
    echo "<table cellspacing=10 cellpadding=10 width=800><td>";
    $imgurl = str_replace('imagini', 'parlamentari', $rdep['imgurl']);
    echo "<img src=http://www.cdep.ro" . $imgurl . " width=283><br>";
    echo "</td><td valign=top class=info>";
    // ----------------- now print the times in office, if need be
    echo "<br>În Senat între: <b>";
    echo date("M Y", $timein) . " - " . ($timeout == 0 ? 'prezent' : date("M Y", $timeout));
    if ($rdep['timeout'] != 0) {
        echo $rdep['motif'] != "" ? "(" . $rdep['motif'] . ")" : "";
    }
    echo "</b>";
    $candidateVotes = $rdep['possible'];
    $percent = $rdep['percent'];
    $class = "blacktext";
    if ($percent < 0.5) {
        $class = "red";
    }
    if ($percent < 0.3) {
        $class = "brightred";
    }
    if ($timein < 1188621956) {
        echo "<br>Prezent la <b><span class={$class}>" . floor(10000 * $percent) / 100 . "%</span></b> din ";
        echo " voturile electronice dintre Septembrie 2007 și " . "Noiembrie 2008 (750).<br>";
    } else {
        echo "<br>Prezent la <b><span class={$class}>" . floor(10000 * $percent) / 100 . "%</span></b> din ";
        echo " voturile electronice dintre " . date("d M Y", $timein) . " și Noiembrie 2008 ({$candidateVotes}).<br>";
    }
    echo "<br><br>Partid: ";
    $parties = getPartiesForSenator($rdep['id']);
    echo getPartyName($parties[0]['name']);
    if (sizeof($parties) > 1) {
        echo ' (<span class="gray small">';
        for ($i = 1; $i < sizeof($parties); $i++) {
            echo "<b>" . getPartyName($parties[$i]['name']) . "</b> până în " . date("M Y", $parties[$i]['t'] / 1000);
            if ($i != sizeof($parties) - 1) {
                echo ", ";
            }
        }
        echo '</span>)';
    }
    if ($rdep['dep_url']) {
        echo "<br><br>Candidează la: " . getLinkFromThinkopolisUrl($rdep['col_url'], '');
    } else {
        echo "<br>Nu pare să candideze în 2008.<br>";
    }
    echo "<br><br>Informează-te despre această persoană: " . "<ul class=moreinfolist>" . "<li> <a href=\"http://www.cdep.ro/pls/parlam/structura.mp?idm=" . $rdep['idm'] . "&cam=1&leg=2004\">site-ul cdep.ro</a></li> ";
    if ($rdep['dep_url']) {
        echo "<li> <a href=\"http://www.alegeri-2008.ro" . $rdep['dep_url'] . "\">alegeri-2008.ro</a></li>";
    }
    echo "<li> <a href=\"http://www.google.ro/search?hl=ro&q=" . $rdep['name'] . "&meta=lr%3Dlang_ro\">căutare google</a></li>";
    echo "<li> <a href=\"http://www.google.ro/search?hl=ro&q=" . $rdep['name'] . "+site:wikipedia.org&&btnI=Mă Simt " . "Norocos&meta=lr%3Dlang_ro\">wikipedia</a></li>";
    echo "</ul>";
    echo "</td><tr><td colspan=2>";
    echo "</td></table>";
}