[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 Circoscrizioni */
|
---|
| 9 | /* Amministrazione */
|
---|
| 10 | /************************************************************************/
|
---|
| 11 |
|
---|
| 12 | if (!defined('ADMIN_FILE')) {
|
---|
| 13 | die ("You can't access this file directly...");
|
---|
| 14 | }
|
---|
[257] | 15 | global $dbi;
|
---|
[2] | 16 | $aid=$_SESSION['aid'];
|
---|
| 17 | $prefix=$_SESSION['prefix'];
|
---|
| 18 | $currentlang=$_SESSION['lang'];
|
---|
| 19 |
|
---|
| 20 | $id_comune=$_SESSION['id_comune'];
|
---|
| 21 | $id_cons_gen=$_GET['id_cons_gen'];
|
---|
| 22 | $perms=ChiSei($id_cons_gen);
|
---|
| 23 | if ($perms<16 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
| 24 |
|
---|
[257] | 25 | $sql="SELECT t1.tipo_cons,t1.descrizione,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
|
---|
| 26 | $res = $dbi->prepare("$sql");
|
---|
| 27 | $res->execute();
|
---|
| 28 | list($tipo_cons,$descr_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 29 | include("modules/Elezioni/funzionidata.php");
|
---|
| 30 | include("modules/Elezioni/ele.php");
|
---|
| 31 | // Offset - visualizza il numero di elementi per pagina
|
---|
| 32 | if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
| 33 | if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0;
|
---|
| 34 | if (isset($_GET['id_circ'])) $id_circ=intval($_GET['id_circ']); else $id_circ='';
|
---|
| 35 | if (isset($_GET['ok'])) $ok=intval($_GET['ok']); else $ok='';
|
---|
| 36 | if (isset($_GET['num_circ'])) $num_circ=intval($_GET['num_circ']); else $num_circ='';
|
---|
| 37 | if (isset($_GET['descr_circ'])) get_magic_quotes_gpc() ? $descr_circ=$param['descr_circ']:$descr_circ=addslashes($param['descr_circ']); else $descr_circ='';
|
---|
| 38 | $offset=10;
|
---|
| 39 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | /******************************************************/
|
---|
| 43 | /*Funzione di visualizzazione globale */
|
---|
| 44 | /*****************************************************/
|
---|
| 45 |
|
---|
| 46 | function all() {
|
---|
| 47 | global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $id_cons,$id_cons_gen,$do,$id_circ;
|
---|
| 48 | echo "<center><font class=\"title\"><br><b>"._CIRCO."</b></font><br><br>";
|
---|
[80] | 49 | echo "<form name=\"circo\" action=\"admin.php\">"
|
---|
| 50 | ."<input type=\"hidden\" name=\"op\" value=\"circo\">"
|
---|
| 51 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
[2] | 52 | echo "<table border=\"0\" width=\"100%\"><tr>";
|
---|
| 53 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"5%\"><b>"._NUM."</b></td>"
|
---|
| 54 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"> <b>"._DESCR."</b> </td>"
|
---|
| 55 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
|
---|
| 56 |
|
---|
| 57 | if ($do == "modify"){
|
---|
[257] | 58 | $sql = "SELECT * FROM ".$prefix."_ele_circoscrizione where id_circ='$id_circ'";
|
---|
| 59 | $res = $dbi->prepare("$sql");
|
---|
| 60 | $res->execute();
|
---|
| 61 | $pro= $res->fetch(PDO::FETCH_BOTH);
|
---|
[2] | 62 | echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
| 63 | ."<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
| 64 | echo "<tr><td align=\"right\"><input name=\"num_circ\" value=\"$pro[num_circ]\" size=\"3\"></td>";
|
---|
| 65 | echo "<td><input type=\"text\" name=\"descr_circ\" value=\"$pro[descrizione]\"maxlength=\"100\" size=\"40\"></td>"
|
---|
| 66 | ."<td align=\"center\"><input type=\"submit\" name=\"update\" value=\""._MODIFY."\"></td></tr>";
|
---|
| 67 | } else {
|
---|
[257] | 68 | $sql = "select max(num_circ) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons'";
|
---|
| 69 | $result = $dbi->prepare("$sql");
|
---|
| 70 | $result->execute();
|
---|
| 71 | list($numc)=$result->fetch(PDO::FETCH_NUM);
|
---|
[2] | 72 | $numc++;
|
---|
[80] | 73 | echo "<tr><td align=\"right\"><input type=\"hidden\" name=\"do\" value=\"add\"><input type=\"text\" name=\"num_circ\" maxlength=\"3\" size=\"3\" value=\"$numc\"></td>"
|
---|
[2] | 74 | ."<td><input type=\"text\" name=\"descr_circ\" maxlength=\"100\" size=\"40\"></td>";
|
---|
| 75 | echo "<td align=\"center\"><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr>";
|
---|
| 76 | }
|
---|
[257] | 77 | $sql = "SELECT * FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
|
---|
| 78 | $res = $dbi->prepare("$sql");
|
---|
| 79 | $res->execute();
|
---|
| 80 | $max = $res->rowCount();
|
---|
| 81 | $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ORDER BY num_circ LIMIT $min,$offset";
|
---|
| 82 | $result = $dbi->prepare("$sql");
|
---|
| 83 | $result->execute();
|
---|
| 84 | while(list($id_cons2, $id_circ, $num_sez, $descr_circ) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
| 85 | $sql="select count(0) from ".$prefix."_ele_sede where id_circ='$id_circ'";
|
---|
| 86 | $restemp = $dbi->prepare("$sql");
|
---|
| 87 | $restemp->execute();
|
---|
| 88 | list($numtemp)=$restemp->fetch(PDO::FETCH_NUM);
|
---|
[2] | 89 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
| 90 | echo "<tr bgcolor=\"$bgcolor1\"><td align=\"right\"width=\"5%\"><b>$num_sez</b>"
|
---|
| 91 | ."</td><td align=\"left\"><b>$descr_circ</b>"
|
---|
| 92 | ."</td><td align=\"center\" nowrap>[<a
|
---|
| 93 | href=\"admin.php?op=circo&do=modify&id_circ=$id_circ&id_cons=$id_cons&id_cons_gen=$id_cons_gen\"><img src=\"modules/Elezioni/images/edit.gif\"
|
---|
[80] | 94 | border=\"0\" align=\"middle\" alt=\"edit\"> "._EDIT."</a>]";
|
---|
[2] | 95 | if (!$numtemp)
|
---|
[80] | 96 | echo "[<a href=\"admin.php?op=circo&do=delete&id_circ=$id_circ&descr_circ=$descr_circ&id_cons=$id_cons&id_cons_gen=$id_cons_gen\">"._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"center\" alt=\"delete\"></a>]";
|
---|
[2] | 97 | else
|
---|
[80] | 98 | echo "["._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"middle\" alt=\"delete\">]";
|
---|
[2] | 99 | echo "</td></tr>";
|
---|
| 100 | }
|
---|
[80] | 101 | echo "</table></form></center>";
|
---|
[2] | 102 | #'Pagina precedente' e 'Pagina Successiva'
|
---|
[80] | 103 | if ($max>$offset){
|
---|
[2] | 104 | echo"<table align=\"center\" width=\"100%\" ><tr>";
|
---|
| 105 | $prev=$min-$offset;
|
---|
| 106 | if ($prev>=0) {
|
---|
| 107 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=circo&id_cons=$id_cons&min=$prev&id_cons_gen=$id_cons_gen\">";
|
---|
| 108 | echo "<b>$offset "._PREV_MATCH."</b></a></td>";
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | $next=$min+$offset;
|
---|
| 112 | if ($next>=($offset-1)) {
|
---|
| 113 | if($next>=$max) $next = $max;
|
---|
| 114 | else {
|
---|
| 115 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=circo&id_cons=$id_cons&min=$next&id_cons_gen=$id_cons_gen\">";
|
---|
| 116 | echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 | echo "</tr></table><br>";
|
---|
[80] | 120 | }
|
---|
[2] | 121 |
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | //***********************************
|
---|
| 127 | // Consultazione
|
---|
| 128 | // ricordarsi di aggiungere l'eliminazione di tutti
|
---|
| 129 | // i dati della consultazione nelle altre tabelle
|
---|
| 130 | // hai capito?
|
---|
| 131 | //***********************************
|
---|
| 132 |
|
---|
| 133 | function circo($ok, $do, $id_cons ,$num_circ,$descr_cons, $id_circ, $descr_circ) {
|
---|
| 134 | global $aid, $prefix, $dbi, $id_cons_gen;
|
---|
| 135 | $perms= ChiSei($id_cons_gen);
|
---|
| 136 | if ($perms>16) {
|
---|
| 137 | if ($do == "delete") {
|
---|
| 138 | if ($ok !="1") {
|
---|
| 139 | ele();
|
---|
| 140 | echo "<center><br><br>"._DOMCANCELLA." $descr_circ ?<br>";
|
---|
| 141 | echo "[ <a href=\"admin.php?op=circo&id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=circo&do=delete&id_circ=$id_circ&ok=1&id_cons_gen=$id_cons_gen\">"._YES."</a> ]";
|
---|
| 142 | include("footer.php");
|
---|
| 143 | die();
|
---|
| 144 | }else{
|
---|
[257] | 145 | $sql="select num_circ from ".$prefix."_ele_circoscrizione where id_circ=$id_circ";
|
---|
| 146 | $rescirc = $dbi->prepare("$sql");
|
---|
| 147 | $rescirc->execute();
|
---|
| 148 | if ($rescirc->rowCount()!=1) die("(1001) Grave errore nel database! contattare l'amministratore");
|
---|
| 149 | list($num_circ)=$rescirc->fetch(PDO::FETCH_NUM);
|
---|
| 150 | $sql="delete from ".$prefix."_ele_circoscrizione where id_circ='$id_circ'";
|
---|
| 151 | $result = $dbi->prepare("$sql");
|
---|
| 152 | $result->execute();
|
---|
| 153 | $sql="select id_circ,num_circ from ".$prefix."_ele_circoscrizione where num_circ>$num_circ and id_cons=$id_cons";
|
---|
| 154 | $rescirc = $dbi->prepare("$sql");
|
---|
| 155 | $rescirc->execute();
|
---|
| 156 | while (list($tmp_id,$tmp_num)=$rescirc->fetch(PDO::FETCH_NUM)){
|
---|
| 157 | $sql="update ".$prefix."_ele_circoscrizione set num_circ=".($tmp_num-1)." where id_circ=$tmp_id";
|
---|
| 158 | $result = $dbi->prepare("$sql");
|
---|
| 159 | $result->execute();
|
---|
| 160 | }
|
---|
[2] | 161 | Header("Location: admin.php?op=circo&id_cons_gen=$id_cons_gen");
|
---|
| 162 | }
|
---|
| 163 | }elseif ($do == "add") {
|
---|
| 164 | if ($descr_circ) {
|
---|
[257] | 165 | $sql="insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons','$num_circ','$descr_circ')";
|
---|
| 166 | $result = $dbi->prepare("$sql");
|
---|
| 167 | $result->execute();
|
---|
[2] | 168 | Header("Location: admin.php?op=circo&id_cons_gen=$id_cons_gen");
|
---|
| 169 | }
|
---|
| 170 | }elseif ($do == "update") {
|
---|
| 171 |
|
---|
[257] | 172 | $sql="update ".$prefix."_ele_circoscrizione set num_circ='$num_circ' , descrizione='$descr_circ' WHERE id_circ='$id_circ'";
|
---|
| 173 | $result = $dbi->prepare("$sql");
|
---|
| 174 | $result->execute();
|
---|
[2] | 175 | Header("Location: admin.php?op=circo&id_cons_gen=$id_cons_gen");
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 |
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 | if ($do!= "")
|
---|
| 185 | circo($ok,$do, $id_cons,$num_circ,$descr_cons,$id_circ,$descr_circ);
|
---|
| 186 | ele();
|
---|
| 187 | all();
|
---|
| 188 | echo"</td></tr></table>";
|
---|
| 189 | include("footer.php");
|
---|
| 190 | ?>
|
---|
| 191 |
|
---|