[2] | 1 | <?php
|
---|
| 2 | /************************************************************************/
|
---|
| 3 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 4 | /* by Roberto Gigli & Luciano Apolito */
|
---|
| 5 | /* http://www.eleonline.it */
|
---|
| 6 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
| 7 | /************************************************************************/
|
---|
| 8 | /* Modulo definizione collegi o zone */
|
---|
| 9 | /* Amministrazione */
|
---|
| 10 | /************************************************************************/
|
---|
| 11 |
|
---|
| 12 | if (!defined('ADMIN_FILE')) {
|
---|
| 13 | die ("You can't access this file directly...");
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | $aid=$_SESSION['aid'];
|
---|
| 17 | $dbi=$_SESSION['dbi'];
|
---|
| 18 | $prefix=$_SESSION['prefix'];
|
---|
| 19 | $id_cons_gen=$_GET['id_cons_gen'];
|
---|
| 20 | $perms=ChiSei(0);
|
---|
| 21 | if ($perms<128 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
| 22 | include("modules/Elezioni/funzionidata.php");
|
---|
| 23 | include("modules/Elezioni/ele.php");
|
---|
| 24 |
|
---|
| 25 | // Offset - visualizza il numero di elementi per pagina
|
---|
| 26 |
|
---|
| 27 | $offset=15;
|
---|
| 28 | if (isset($_GET['desc'])) get_magic_quotes_gpc() ? $desc=$param['desc']:$desc=addslashes($param['desc']);else $desc='';
|
---|
| 29 | if (isset($_GET['id_collegio'])) $id_collegio=intval($_GET['id_collegio']);else $id_collegio='';
|
---|
| 30 | if (isset($_GET['ok'])) $ok=intval($_GET['ok']); else $ok='';
|
---|
| 31 | if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']);else $do='';
|
---|
| 32 | if (isset($_GET['op'])) get_magic_quotes_gpc() ? $op=$param['op']:$op=addslashes($param['op']);else $op='';
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | /******************************************************/
|
---|
| 36 | /*Funzione di visualizzazione globale */
|
---|
| 37 | /*****************************************************/
|
---|
| 38 | //crea la pagina delle affluenze
|
---|
| 39 | function all() {
|
---|
| 40 | global $bgcolor1, $bgcolor2, $prefix, $dbi,$id_cons,$desc,$id_cons_gen,$id_collegio;
|
---|
| 41 |
|
---|
| 42 | OpenTable();
|
---|
[257] | 43 | $sql = "SELECT t1.id_collegio, t1.descrizione, t2.descrizione FROM ".$prefix."_ele_collegi as t1, ".$prefix."_ele_consultazione as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen=$id_cons_gen order by t1.descrizione asc";
|
---|
| 44 | $resmod = $dbi->prepare("$sql");
|
---|
| 45 | $resmod->execute();
|
---|
[2] | 46 | echo "<table><tr ALIGN=\"CENTER\">";
|
---|
| 47 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
|
---|
| 48 | echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
|
---|
| 49 | echo "</tr>";
|
---|
| 50 | echo "<form name=\"modello\" action=\"admin.php\">"
|
---|
| 51 | ."<input type=\"hidden\" name=\"op\" value=\"inscollegi\">";
|
---|
| 52 | echo "<input type=\"hidden\" name=\"id_collegio\" value=\"$id_collegio\">";
|
---|
| 53 | echo "<tr align=\"center\">";
|
---|
[257] | 54 | $sql = "SELECT descrizione from ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'";
|
---|
| 55 | $ressede = $dbi->prepare("$sql");
|
---|
| 56 | $ressede->execute();
|
---|
| 57 | list($descr_cons)=$ressede->fetch(PDO::FETCH_NUM);
|
---|
[2] | 58 | echo "<td>$descr_cons</td>";
|
---|
| 59 | echo "<td align=\"center\" width=\"32\"><input name=\"desc\" value=\"$desc\"></td>";
|
---|
| 60 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 61 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
| 62 | if ($desc) {
|
---|
| 63 | echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
| 64 | echo "<td><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr></form>";
|
---|
| 65 | }else{
|
---|
| 66 | echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
| 67 | echo "<td><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr></form>";
|
---|
| 68 | }
|
---|
| 69 | $i=0;
|
---|
[257] | 70 | while (list($id_collegio2,$desc,$descr_cons) = $resmod->fetch(PDO::FETCH_NUM)){ //elenco dei modelli inseriti
|
---|
[2] | 71 | $i++;
|
---|
| 72 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
| 73 | echo "<form name=\"modello$i\" action=\"admin.php\">"
|
---|
| 74 | ."<input type=\"hidden\" name=\"op\" value=\"inscollegi\">";
|
---|
| 75 | echo "<input type=\"hidden\" name=\"do\" value=\"delete\">";
|
---|
| 76 | echo "<input type=\"hidden\" name=\"desc\" value=\"$desc\">";
|
---|
| 77 | echo "<input type=\"hidden\" name=\"id_collegio\" value=\"$id_collegio2\">";
|
---|
| 78 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 79 | echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
|
---|
| 80 | echo "<td></td>";
|
---|
| 81 | echo "<td align=\"center\" width=\"32\"><b>$desc</b></td>";
|
---|
| 82 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
| 83 | echo "</td><td align=\"center\" nowrap>[<a
|
---|
| 84 | href=\"admin.php?op=inscollegi&desc=$desc&id_cons_gen=$id_cons_gen&id_collegio=$id_collegio2\"><img src=\"modules/Elezioni/images/edit.gif\"
|
---|
| 85 | border=\"0\" align=\"center\"> "._EDIT."</a>]";
|
---|
| 86 | echo "<td><input type=\"submit\" name=\"erase$i\" value=\""._DELETE."\">"
|
---|
| 87 | ."</td></tr></form>";
|
---|
| 88 | }
|
---|
| 89 | echo "</table>";
|
---|
| 90 | CloseTable();
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | function collegi($ok, $do,$desc,$id_collegio) {
|
---|
| 94 | global $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons, $id_cons_gen,$genere;
|
---|
| 95 | if ($do !="") {
|
---|
| 96 | if ($do == "delete") {
|
---|
| 97 | if ($ok !="1") {
|
---|
| 98 | ele();
|
---|
| 99 | echo "<center><br><br>"._DOMCANCELLA." "._COLLEGIO." $desc ?<br>";
|
---|
| 100 | echo "[ <a href=\"admin.php?op=inscollegi&id_cons_gen=$id_cons_gen&id_collegio=$id_collegio&desc=$desc\">"._NO."</a> ] - [<a href=\"admin.php?op=inscollegi&do=delete&id_cons_gen=$id_cons_gen&desc=$desc&id_collegio=$id_collegio&ok=1\">"._YES."</a> ]";
|
---|
| 101 | die();
|
---|
| 102 | }else{
|
---|
[257] | 103 | $sql = "delete from ".$prefix."_ele_collegi where id_collegio='$id_collegio'";
|
---|
| 104 | $result = $dbi->prepare("$sql");
|
---|
| 105 | $result->execute();
|
---|
| 106 | if (!$result->rowCount()) return;
|
---|
[2] | 107 | Header("Location: admin.php?op=inscollegi&id_cons_gen=$id_cons_gen");
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
| 110 | if ($do == "add") {
|
---|
[257] | 111 | $sql = "insert into ".$prefix."_ele_collegi(id_cons_gen,descrizione) values ('$id_cons_gen','$desc')";
|
---|
| 112 | $result = $dbi->prepare("$sql");
|
---|
| 113 | $result->execute();
|
---|
[2] | 114 | }
|
---|
| 115 | if ($do == "update") {
|
---|
[257] | 116 | $sql= "update ".$prefix."_ele_collegi set descrizione='$desc' , id_cons_gen='$id_cons_gen' where id_collegio='$id_collegio'";
|
---|
| 117 | $result = $dbi->prepare("$sql");
|
---|
| 118 | $result->execute();
|
---|
| 119 | if (!$result->rowCount()) return;
|
---|
| 120 | Header("Location: admin.php?op=inscollegi&id_cons_gen=$id_cons_gen&id_collegio=$id_collegio");
|
---|
[2] | 121 | }
|
---|
| 122 | }
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | //****************************
|
---|
| 126 | switch ($op){
|
---|
| 127 | case "inscollegi":
|
---|
| 128 | if ($desc){
|
---|
| 129 | collegi($ok, $do,$desc,$id_collegio);
|
---|
| 130 | }else collegi('','','','');
|
---|
| 131 | break;
|
---|
| 132 | }
|
---|
| 133 | ele();
|
---|
| 134 | all();
|
---|
| 135 | include("footer.php");
|
---|
| 136 |
|
---|
| 137 | ?>
|
---|
| 138 |
|
---|