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