diff --git a/methods/schulzeResults.php b/methods/schulzeResults.php
new file mode 100644
index 0000000..873c6ea
--- /dev/null
+++ b/methods/schulzeResults.php
@@ -0,0 +1,67 @@
+ $d[$j][$i])
+ {
+ $p[$i][$j] = $d[$i][$j];
+ }else
+ {
+ $p[$i][$j] = 0;
+ }
+ }
+ }
+ for ($i=1;$i<=$ncandidats;$i++)
+ {
+ for ($j=1;$j<=$ncandidats;$j++)
+ {
+ for ($k=1;$k<=$ncandidats;$k++)
+ {
+ if ($j != $k)
+ {
+ $p[$j][$k] = max($p[$j][$k], min($p[$j][$i],$p[$i][$k]));
+ }
+ }
+ }
+ return $p;
+ }
+ }
+}
+?>
diff --git a/test.php b/test.php
new file mode 100644
index 0000000..af51899
--- /dev/null
+++ b/test.php
@@ -0,0 +1,4 @@
+test();
+?>
diff --git a/vote.form.php b/vote.form.php
index 45b6c5a..57cfb93 100644
--- a/vote.form.php
+++ b/vote.form.php
@@ -12,9 +12,9 @@ $idVotation = $_GET["v"];
$dolibarr = new dbDolibarr();
$query = "SELECT * FROM llx_adherent as a LEFT JOIN llx_adherent_type as t ON a.fk_adherent_type=t.rowid WHERE a.login='" . $dolibarr->protect($idVotant) . "' AND (DATE(a.datefin)>=CURDATE() OR t.subscription=0) AND t.vote=1";
-print $query .EOLH;
+print $query . EOLH;
$result = $dolibarr->query($query);
-print_r($dolibarr);
+//print_r($dolibarr);
$votant = $dolibarr->result->fetch_array();
print('
diff --git a/vote.resultat.php b/vote.resultat.php
index 91d28a9..9a5ac63 100644
--- a/vote.resultat.php
+++ b/vote.resultat.php
@@ -64,41 +64,48 @@ print('
$votes = $db->result->fetch_all(MYSQLI_ASSOC);
foreach ($votes as $vote)
{
- $total = 0;
- echo "
"; - //$resultatCandidats = ''; + switch ($vote["method"]) + { + case 1: + $total = 0; + echo "" . $vote["libelle"] . "
"; + $query='SELECT * FROM liste_candidats WHERE idVotation=' . $idVotation . ' AND idVote=' . $vote["id"]; + $result = $db->query($query); + $candidats = $db->result->fetch_all(MYSQLI_ASSOC); + echo ""; + //$resultatCandidats = ''; - $query='SELECT COUNT(*) as n FROM votes WHERE idVotation=' . $db->protect($idVotation) . ' AND idVote=' . $vote["id"] .' AND idCandidat=0'; - $result = $db->query($query); - $resultat = $db->result->fetch_array(MYSQLI_ASSOC); - $blanc = $resultat["n"]; - echo 'Votes blancs : ' . $blanc . '
'; - foreach($candidats as $candidat) - { - $query='SELECT COUNT(*) as n FROM votes WHERE idVotation=' . $db->protect($idVotation) . ' AND idVote=' . $vote["id"] .' AND idCandidat=' . $candidat["id"]; - $result = $db->query($query); - $resultat = $db->result->fetch_array(MYSQLI_ASSOC); - echo $candidat["candidat"] . ' :' . $resultat["n"] . '
'; - $resultatCandidats[$candidat['candidat']] = $resultat["n"]; - $total += $resultat["n"]; + $query='SELECT COUNT(*) as n FROM votes WHERE idVotation=' . $db->protect($idVotation) . ' AND idVote=' . $vote["id"] .' AND idCandidat=0'; + $result = $db->query($query); + $resultat = $db->result->fetch_array(MYSQLI_ASSOC); + $blanc = $resultat["n"]; + echo 'Votes blancs : ' . $blanc . '
'; + foreach($candidats as $candidat) + { + $query='SELECT COUNT(*) as n FROM votes WHERE idVotation=' . $db->protect($idVotation) . ' AND idVote=' . $vote["id"] .' AND idCandidat=' . $candidat["id"]; + $result = $db->query($query); + $resultat = $db->result->fetch_array(MYSQLI_ASSOC); + echo $candidat["candidat"] . ' :' . $resultat["n"] . '
'; + $resultatCandidats[$candidat['candidat']] = $resultat["n"]; + $total += $resultat["n"]; + } + array_multisort($resultatCandidats, SORT_DESC, SORT_NUMERIC); + reset($resultatCandidats); + if ($total >= $blanc) + { + print("Remporte le vote : " . key($resultatCandidats)); + unset($resultatCandidats); + print("
"); + }else + { + print("Aucun candidat n'emporte le vote, car il y a plus de 50% de votes blancs.
"); + } + listeVotants($idVotation, $vote["id"], $listeAdherents); + print("
" . EOLH); + break; + default: + break; } - array_multisort($resultatCandidats, SORT_DESC, SORT_NUMERIC); - reset($resultatCandidats); - if ($total >= $blanc) - { - print("Remporte le vote : " . key($resultatCandidats)); - unset($resultatCandidats); - print("
"); - }else - { - print("Aucun candidat n'emporte le vote, car il y a plus de 50% de votes blancs.
"); - } - listeVotants($idVotation, $vote["id"], $listeAdherents); - print("