function mod_cdep_2008_summary()
{
    global $parties;
    global $person;
    global $cid;
    $t = new Smarty();
    $sql = "SELECT dep.idperson, dep.id, dep.name, dep.idm, dep.timein, dep.timeout,\n      dep.motif,\n      votes_agg.possible, votes_agg.percent, votes_agg.maverick,\n      belong_agg.idparty,\n      dep.imgurl\n    FROM cdep_2008_deputies as dep\n      LEFT JOIN cdep_2008_votes_agg AS votes_agg\n        ON votes_agg.idperson = dep.idperson\n      LEFT JOIN cdep_2008_belong_agg AS belong_agg\n        ON belong_agg.idperson = dep.idperson\n    WHERE dep.idperson = {$person->id}";
    $sdep = mysql_query($sql);
    $rdep = mysql_fetch_array($sdep);
    $numVotes = getNumberOfVotes();
    // Vote percentages
    $timein = $rdep['timein'] / 1000;
    $timeout = $rdep['timeout'] / 1000;
    // 1103259600 = 17 dec 2004
    // Print the times in office, if need be
    $t->assign('dep_time_in', date("M Y", $timein));
    $t->assign('dep_time_out', $timeout == 0 ? 'prezent' : date("M Y", $timeout));
    if ($rdep['timeout'] != 0) {
        $t->assign('dep_motif', $rdep['motif'] != "" ? " (" . $rdep['motif'] . ")" : "");
    }
    $parties = getPartiesFor($rdep['idperson'], 2008);
    $t->assign('dep_party', getPartyName($parties[0]['name']));
    // -----------------------------------------------------
    // TODO(vivi): Also move this into a nice template loop!
    // -----------------------------------------------------
    if (sizeof($parties) > 1) {
        $extraParties = ' (<span class="gray small">';
        for ($i = 1; $i < sizeof($parties); $i++) {
            $extraParties .= "<b>" . getPartyName($parties[$i]['name']) . "</b> până în " . date("M Y", $parties[$i]['t'] / 1000);
            if ($i != sizeof($parties) - 1) {
                $extraParties .= ", ";
            }
        }
        $extraParties .= '</span>)';
    }
    $candidateVotes = $rdep['possible'];
    $percent = $rdep['percent'];
    $class = "blacktext";
    if ($percent < 0.5) {
        $class = "red";
    }
    if ($percent < 0.3) {
        $class = "brightred";
    }
    $maverick = $rdep['maverick'];
    $t->assign('dep_percent', 100 * $percent);
    $t->assign('dep_absent', 100 - 100 * $percent);
    $t->assign('dep_possible_votes', $candidateVotes);
    $t->assign('maverick', 100 * $maverick);
    $t->assign('dep_idm', $rdep['idm']);
    $t->assign('cid', $cid);
    $t->assign('idperson', $person->id);
    $t->assign('name', $person->getUrlName());
    $t->assign('chd1', 100 * ($percent - $percent * $maverick));
    $t->assign('chd2', 100 * ($percent * $maverick));
    $t->assign('chd3', 100 * (1 - $percent));
    $t->display('mod_cdep_2008_summary.tpl');
}
<?php

// Prints all the stuff that a guy did that was in the 2004-2008
// house of reps.
// We know that the person we are talking about is $person.
$sql = "SELECT dep.id, dep.idperson, dep.name, dep.idm, dep.timein, dep.timeout, " . "dep.motif, " . "video.seconds, video.idv, video.sessions, " . "votes_agg.possible, votes_agg.percent, " . "belong_agg.idparty, " . "dep.imgurl " . "FROM cdep_2004_deputies as dep " . "LEFT JOIN cdep_2004_video AS video ON video.idperson = dep.idperson " . "LEFT JOIN cdep_2004_votes_agg AS votes_agg " . "ON votes_agg.idperson = dep.idperson " . "LEFT JOIN cdep_2004_belong_agg AS belong_agg " . "ON belong_agg.idperson = dep.idperson " . "WHERE dep.idperson = {$person->id} ";
$sdep = mysql_query($sql);
$rdep = mysql_fetch_array($sdep);
$numVotes = getNumberOfVotes();
// Vote percentages
$timein = $rdep['timein'] / 1000;
$timeout = $rdep['timeout'] / 1000;
// 1103259600 = 17 dec 2004
$t = new Smarty();
// Print the 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'] . ")" : "");
}
$parties = getPartiesFor($rdep['idperson'], 2004);
$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'];
Beispiel #3
0
/**
 * Shows all information related to a deputy.
 * To be replaced with the more generic function to show a person.
 */
function showDeputy($id)
{
    $sql = "SELECT dep.id, dep.name, dep.idm, dep.timein, dep.timeout, dep.motif, " . "video.seconds, video.idv, video.sessions, " . "votes_agg.possible, votes_agg.percent, " . "belong_agg.idparty, " . "cand.url as dep_url, " . "colleges.url as col_url, " . "dep.imgurl " . "FROM cdep_2004_deputies as dep " . "LEFT JOIN cdep_2004_video AS video ON video.idperson = dep.idperson " . "LEFT JOIN cdep_2004_votes_agg AS votes_agg " . "ON votes_agg.idperson = dep.idperson " . "LEFT JOIN cdep_2004_belong_agg AS belong_agg " . "ON belong_agg.idperson = dep.idperson " . "LEFT JOIN alegeri_2008_candidates AS cand " . "ON cand.idperson = dep.idperson " . "LEFT JOIN alegeri_2008_colleges as colleges " . "ON cand.college_id = colleges.id " . "WHERE dep.id = {$id} ";
    $sdep = mysql_query($sql);
    $rdep = mysql_fetch_array($sdep);
    $numVotes = getNumberOfVotes();
    // ------------------ 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/l2004', 'parlamentari/l2004/mari', $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 Camera Deputaților î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 < 1139201156) {
        echo "<br>Prezent la <b><span class={$class}>" . floor(10000 * $percent) / 100 . "%</span></b> din ";
        echo " voturile electronice dintre Februarie 2006 și " . "Noiembrie 2008 (3590).<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>Luări de cuvânt: " . getVideoCellText2($rdep['idv'], $rdep['sessions'], $rdep['seconds']);
    echo "<br><br>Partid: ";
    $parties = getPartiesFor($rdep['id'], 2004);
    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>";
    echo "<li> <a href=\"http://www.cdep.ro/pls/parlam/structura.mp?" . "idm=" . $rdep['idm'] . "&cam=2&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>";
}