/**
 * 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;
}
Ejemplo n.º 2
0
<?php

include '_top.php';
include 'pages/euro_2009/europarlament_functions.php';
include 'hp-includes/people_lib.php';
include 'functions.php';
$v = getSimulationSystemValuesFromGet();
$VOT_PRESENCE = $_GET["vot"] && is_numeric($_GET["vot"]) ? $_GET["vot"] : "30.0";
maybeDisplaySimulationResults();
include '_bottom.php';