Esempio n. 1
0
/**
 * Shows a list of all the deputies, sorted by the percentage of presence
 * in votes.
 */
function showPresencePercentage($sortby, $order)
{
    global $cid;
    $orderby = getSanitizedDeputiesSortBy($sortby, $order);
    $sql = "SELECT dep.id, dep.name, dep.idm, dep.timein, dep.timeout, dep.motif, " . "dep.idperson, " . "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, " . "alegeritv.urlatv, " . "results.winner, results.difference, results.reason, " . "results_agg.total, results_agg.college " . "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 " . "LEFT JOIN alegeritv ON alegeritv.idperson = dep.idperson " . "LEFT JOIN results_2008_candidates AS results " . "ON dep.idperson = results.idperson " . "LEFT JOIN results_2008_agg AS results_agg " . "ON results.college = results_agg.college " . "WHERE dep.timeout = 0 " . "ORDER BY {$orderby}";
    $sdep = mysql_query($sql);
    $numVotes = getNumberOfVotes();
    $count = 1;
    $stats = initStatsObject();
    echo "<table class=bigtable width=900>";
    $norder = $order == 'asc' ? 'desc' : 'asc';
    ?>
  <tr class=header><td></td><td>
    <a href=?cid=<?php 
    echo $cid;
    ?>
&sort=name&order=<?php 
    echo $norder;
    ?>
>Deputat</a></td>
  <td>
    <a href=?cid=<?php 
    echo $cid;
    ?>
&sort=percent&order=<?php 
    echo $norder;
    ?>
>Procent de voturi<br>la care a fost prezent</a></td>
  <td>
    <a href=?cid=<?php 
    echo $cid;
    ?>
&sort=idparty&order=<?php 
    echo $norder;
    ?>
>Partid</a></td>
  <td>
    <a href=?cid=<?php 
    echo $cid;
    ?>
&sort=seconds&order=<?php 
    echo $norder;
    ?>
>Luări de cuvânt</a></td>
  <td>Reales</td></tr>
  <?php 
    while ($rdep = mysql_fetch_array($sdep)) {
        // ------------------ vote percentages
        $timein = $rdep['timein'] / 1000;
        $timeout = $rdep['timeout'] / 1000;
        ?>
    <tr>
    <td align=right><?php 
        echo $count++;
        ?>
</td>
    <?php 
        $name = moveFirstNameLast($rdep['name']);
        ?>
    <td><a href="?name=<?php 
        urlencode($name);
        ?>
&cid=9&id=<?php 
        echo $rdep['idperson'];
        ?>
"><?echo $name ?></a>
    <br><span class="small gray">
    <?php 
        // ----------------- now print the times in office, if need be
        // 1103259600 = 17 dec 2004
        if ($timein != 1103259600 || $timeout != 0) {
            echo date("M Y", $timein) . " - " . ($timeout == 0 ? 'prezent' : date("M Y", $timeout));
            echo $rdep['motif'] != "" ? "(" . $rdep['motif'] . ")" : "";
        }
        echo getEuroParliamentString($rdep['id'], 2);
        echo "</span></td>";
        $sum = $rdep['possible'] * $rdep['percent'];
        $candidateVotes = $rdep['possible'];
        $percent = $rdep['percent'];
        $class = "blacktext";
        if ($percent < 0.5) {
            $class = "red";
        }
        if ($percent < 0.3) {
            $class = "brightred";
        }
        echo "<td><span class={$class}>" . floor(10000 * $percent) / 100 . " %</span>";
        if ($candidateVotes != $numVotes) {
            echo "<br><span class=\"small gray\"> din " . $candidateVotes . " voturi</span>";
            if ($awayVotes != 0) {
                echo "<br>Pentru {$awayVotes} a fost europarlamentar";
            }
        }
        echo "</td><td>";
        $parties = getPartiesFor($rdep['id'], 2004);
        echo getPartyName($parties[0]['name']);
        if (sizeof($parties) > 1) {
            echo '<br><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 "<br>";
                }
            }
            echo '</span>';
        }
        echo "</td>";
        echo "<td>" . getVideoCellText($rdep['idv'], $rdep['sessions'], $rdep['seconds']) . "</td>";
        echo "<td>";
        echo getReElectedString($rdep);
        $stats = countStats($stats, $rdep, $percent);
        echo "</tr>";
    }
    echo "</table>";
    printStats($stats);
}
/**
 * Tests whether there are values in the URL for the party percentage or
 * votes. If that is true, it simulates the elections system and then
 * it prints the people that would get elected.
 * @return {boolean} True if an election was simulated, false otherwise.
 *     This will be used to decide whether we will still display all the
 *     candidates or just the elected ones.
 */
function maybeDisplaySimulationResults()
{
    global $_GET;
    global $VOT_PRESENCE;
    $v = getSimulationSystemValuesFromGet();
    if ($v != null) {
        $seats = simulateDHondtSystem($v);
        echo "Cu aceste procente și o prezență generală la vot " . "de {$VOT_PRESENCE}%, aceștia ar fi europarlamentarii:";
        echo "<table cellspacing=5><tr bgcolor=\"#EEEEEE\"><td></td>" . "<td>Nume</td>";
        echo "<td></td><td></td><td></td><td></td>" . "<td>Partid</td>";
        $count = 1;
        foreach ($seats as $p => $v) {
            $idparty = substr($p, 1);
            switch ($idparty) {
                case "a":
                    $idparty = "10 AND e.idperson=3336 ";
                    break;
                case "b":
                    $idparty = "10 AND e.idperson=3335 ";
                    break;
            }
            $s = mysql_query("SELECT e.name, e.idperson, e.occupation, e.birthday, " . "p.name as pname, h4.what as wh4, " . "h1.what as wh1, h2.what as wh2, h3.what as wh3 " . "FROM euro_2009_candidates AS e " . "LEFT JOIN parties AS p ON p.id = e.idparty " . "LEFT JOIN people_history AS h1 " . "ON e.idperson = h1.idperson AND h1.what='catavencu/2008' " . "LEFT JOIN people_history AS h2 " . "ON e.idperson = h2.idperson AND h2.what='results/2008' " . "LEFT JOIN people_history AS h3 " . "ON e.idperson = h3.idperson AND h3.what='euro_parliament/2007' " . "LEFT JOIN people_history AS h4 " . "ON e.idperson = h4.idperson AND h4.what='qvorum/2009' " . "WHERE idparty={$idparty} " . "ORDER BY position ASC " . "LIMIT 0, {$seats[$p]}");
            if ($idparty != "10 AND e.idperson=3336 " && $idparty != "10 AND e.idperson=3335 ") {
                echo "<tr bgcolor=#FAFAFA>";
                echo "<td colspan=7 align=center>" . getPartyNameForId($idparty) . " - {$seats[$p]} locuri</td>";
            }
            while ($r = mysql_fetch_array($s)) {
                echo "<tr>";
                echo "<td align=right>" . $count++ . "</td>";
                $name = moveFirstNameLast(ucwords(strtolower_ro($r['name'])));
                echo "<td><a href=\"?name=" . urlencode($name) . "&cid=9&id={$r['idperson']}\">{$name}</a>";
                $age = round((time() * 1000 - $r['birthday']) / (1000 * 60 * 60 * 24 * 365));
                echo ", {$age} ani";
                $idperson = $r['idperson'];
                echo "</td>";
                echo "<td align=right>" . getIconHtml($r['wh1'], $idperson) . "</td>";
                echo "<td align=right>" . getIconHtml($r['wh2'], $idperson) . "</td>";
                echo "<td align=right>" . getIconHtml($r['wh3'], $idperson) . "</td>";
                echo "<td align=right>" . getIconHtml($r['wh4'], $idperson) . "</td>";
                //echo "<td><span class=\"small gray\">{$r['occupation']}</span></td>";
                echo "<td>{$r['pname']}</td>";
            }
        }
        echo "</table>";
        return true;
    }
    return false;
}
<?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 e.id, e.position, p.long_name, p.name " . "FROM euro_2009_candidates as e " . "LEFT JOIN parties as p ON p.id = e.idparty " . "WHERE e.idperson = {$person->id} ";
$se = mysql_query($sql);
$re = mysql_fetch_array($se);
echo "<div>";
echo "<a href=http://www.europarl.europa.eu/elections2009/default.htm?language=ro><img src=http://www.europarl.europa.eu/eplive/expert/photo/20090209PHT48834/th_pict_20090209PHT48834.jpg width=100 align=right border=0></a>";
// Print the party belonging during his senator years
echo "Candidează pe <a href=\"?c=alegeri+europarlamentare+2009&" . "cid=10&sid=0\">" . "lista " . ucwords($re['name']) . "</a> pe poziția <b>" . "<font color=darkred size=+1>" . $re['position'] . "</font></b>.";
echo " Vezi <a href=f/{$person->id}_euro_2009_1.pdf>" . "declarația de avere și interese</a> " . "<a href=f/{$person->id}_euro_2009_1.pdf>" . "<img src=images/icon_pdf.gif border=0></a>.";
echo "<div class=small>Candidatul ";
// Select the next and previous ID's
$s = mysql_query("SELECT id, idperson, name FROM euro_2009_candidates " . "WHERE id = " . ($re['id'] - 1) . " OR id = " . ($re['id'] + 1));
while ($r = mysql_fetch_array($s)) {
    $nume = urlencode(strtolower_ro(moveFirstNameLast($r['name'])));
    if ($r['id'] == $re['id'] - 1) {
        echo "<a href=\"?name={$nume}&cid=9&id={$r['idperson']}\">anterior</a> / ";
    }
    if ($r['id'] == $re['id'] + 1) {
        echo "<a href=\"?name={$nume}&cid=9&id={$r['idperson']}\">următor</a>";
    }
}
echo ". ";
?>
Mai multe despre alegeri
<a href="?c=alegeri+europarlamentare+2009&cid=10">aici</a>.</div>
<?php 
echo "</div>";