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 gruppo */
|
---|
9 | /* Amministrazione */
|
---|
10 | /************************************************************************/
|
---|
11 | if (!defined('ADMIN_FILE')) {
|
---|
12 | die ("You can't access this file directly...");
|
---|
13 | }
|
---|
14 |
|
---|
15 | // Offset - visualizza il numero di elementi per pagina
|
---|
16 | $offset=5;
|
---|
17 |
|
---|
18 | $aid=$_SESSION['aid'];
|
---|
19 | $dbi=$_SESSION['dbi'];
|
---|
20 | $prefix=$_SESSION['prefix'];
|
---|
21 | $currentlang=$_SESSION['lang'];
|
---|
22 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
23 | $id_cons_gen=$param['id_cons_gen'];
|
---|
24 | $perms=ChiSei($id_cons_gen);
|
---|
25 | if ($perms<32 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
26 |
|
---|
27 | $id_comune=$_SESSION['id_comune'];
|
---|
28 | $res = mysql_query("SELECT t1.tipo_cons,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);
|
---|
29 | list($tipo_cons,$id_cons) = mysql_fetch_row($res);
|
---|
30 |
|
---|
31 | include("modules/Elezioni/funzionidata.php");
|
---|
32 | include("modules/Elezioni/ele.php");
|
---|
33 |
|
---|
34 | if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
35 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
36 | if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
|
---|
37 | if (isset($param['descrizione'])) get_magic_quotes_gpc() ?
|
---|
38 | $descrizione=$param['descrizione']:$descrizione=addslashes($param['descrizione']); else $descrizione='';
|
---|
39 | if (isset($param['id_conf'])) $id_conf=intval($param['id_conf']); else $id_conf='';
|
---|
40 | if (isset($param['limite'])) get_magic_quotes_gpc() ? $limite=$param['limite']:$limite=addslashes($param['limite']); else $limite='';
|
---|
41 | if (isset($param['consin'])) get_magic_quotes_gpc() ? $consin=$param['consin']:$consin=addslashes($param['consin']); else $consin='';
|
---|
42 | if (isset($param['infpremio'])) get_magic_quotes_gpc() ? $infpremio=$param['infpremio']:$infpremio=addslashes($param['infpremio']); else $infpremio='';
|
---|
43 | if (isset($param['listinfsbar'])) get_magic_quotes_gpc() ? $listinfsbar=$param['listinfsbar']:$listinfsbar=addslashes($param['listinfsbar']); else $listinfsbar='';
|
---|
44 | if (isset($param['infminpremio'])) get_magic_quotes_gpc() ? $infminpremio=$param['infminpremio']:$infminpremio=addslashes($param['infminpremio']); else $infminpremio='';
|
---|
45 | if (isset($param['listinfconta'])) get_magic_quotes_gpc() ? $listinfconta=$param['listinfconta']:$listinfconta=addslashes($param['listinfconta']); else $listinfconta='';
|
---|
46 | if (isset($param['suppremio'])) get_magic_quotes_gpc() ? $suppremio=$param['suppremio']:$suppremio=addslashes($param['suppremio']); else $suppremio='';
|
---|
47 | if (isset($param['supsbarramento'])) get_magic_quotes_gpc() ? $supsbarramento=$param['supsbarramento']:$supsbarramento=addslashes($param['supsbarramento']); else $supsbarramento='';
|
---|
48 | if (isset($param['supminpremio'])) get_magic_quotes_gpc() ? $supminpremio=$param['supminpremio']:$supminpremio=addslashes($param['supminpremio']); else $supminpremio='';
|
---|
49 | if (isset($param['listsupconta'])) get_magic_quotes_gpc() ? $listsupconta=$param['listsupconta']:$listsupconta=addslashes($param['listsupconta']); else $listsupconta='';
|
---|
50 | if (isset($param['help'])) $help=intval($param['help']);
|
---|
51 |
|
---|
52 | /******************************************************/
|
---|
53 | /*Funzione di visualizzazione globale */
|
---|
54 | /*****************************************************/
|
---|
55 | function all() {
|
---|
56 | global $tipo_cons,$param,$currentlang, $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $id_cons,$id_cons_gen,$id_comune,$do,$id_conf, $language,$help;
|
---|
57 |
|
---|
58 | // $restemp = mysql_query("select count(0) from ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi);
|
---|
59 | // list($numtemp)=mysql_fetch_row($restemp);
|
---|
60 |
|
---|
61 | if (isset($help)) include("language/$language/ele_confcons.html");
|
---|
62 |
|
---|
63 | echo "<center><br><table border=\"0\" width=\"100%\">";
|
---|
64 |
|
---|
65 | //-----------------------visualizza blocco inserimento -
|
---|
66 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_conf", $dbi); //da modificare
|
---|
67 | $max = mysql_num_rows($res);
|
---|
68 | $nuovo_gruppo=$max+1;
|
---|
69 | echo "<form name=\"gruppo2\" enctype=\"multipart/form-data\" action=\"admin.php\" method=\"post\">"
|
---|
70 | ."<input type=\"hidden\" name=\"op\" value=\"confconsiglio\">";
|
---|
71 | if ($do=='modify') {
|
---|
72 | $resl = mysql_query("SELECT * FROM ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi);
|
---|
73 | $gru=mysql_fetch_array($resl);
|
---|
74 | $nuovo_gruppo=$gru['id_conf'];
|
---|
75 | echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
76 | }else{
|
---|
77 | $gru['id_conf']=$nuovo_gruppo;$gru['descrizione']='';$gru['limite']='';$gru['consin']='';$gru['infpremio']='';$gru['listinfsbar']='';$gru['listinfconta']='';$gru['supminpremio']='';$gru['infminpremio']='';$gru['suppremio']='';$gru['supsbarramento']='';$gru['listsupconta']='';
|
---|
78 | echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
79 | }
|
---|
80 | echo "<tr bgcolor=\"$bgcolor2\"><td align=\"center\"><input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
81 | // echo "<b>"._NUM."</b></td><td><input type=\"hidden\" name=\"id_conf\" value=\"".$gru['id_conf']."\">".$gru['id_conf']."</td><td align=\"center\">"
|
---|
82 | echo "<input type=\"hidden\" name=\"id_conf\" value=\"".$gru['id_conf']."\"><b>"._DESCR."</b></td><td colspan=\"3\"><input type=\"text\" name=\"descrizione\" value=\"".$gru['descrizione']."\"></td></tr>"
|
---|
83 | ."<tr><td align=\"center\"><b>"._LIMITE."</b></td><td><select name=\"limite\"><option value=\"0\">"._NOFASCIA;
|
---|
84 |
|
---|
85 | $result1 = mysql_query("select id_fascia, abitanti from ".$prefix."_ele_fasce ", $dbi);
|
---|
86 | while(list($id,$descr)=mysql_fetch_row($result1)){
|
---|
87 | $sel= ($id == $gru['limite']) ? "selected":"";
|
---|
88 | echo "<option value=\"$id\" $sel>$descr";
|
---|
89 | }
|
---|
90 | echo "</select></td>";
|
---|
91 | $sel= ($gru['consin']==1) ? "selected":"";
|
---|
92 | echo "<td align=\"center\"><b>"._CONSIN."</b></td><td><select name=\"consin\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td></tr>"
|
---|
93 | ."<tr><td align=\"center\" colspan=\"4\" bgcolor=\"$bgcolor2\"><b>"._SISTEMA_MAGGIORITARIO."</b></td></tr>"
|
---|
94 | ."<tr><td align=\"center\"><b>"._INFPREMIO."</b></td><td><input type=\"text\" name=\"infpremio\" value=\"".$gru['infpremio']."\"></td>"
|
---|
95 | ."<td align=\"center\"><b>"._LISTINFSBAR."</b></td><td><input type=\"text\" name=\"listinfsbar\" value=\"".$gru['listinfsbar']."\"></td></tr>"
|
---|
96 | ."<tr><td align=\"center\"><b>"._INFMINPREMIO."</b></td><td><input type=\"text\" name=\"infminpremio\" value=\"".$gru['infminpremio']."\"></td>";
|
---|
97 | $sel= ($gru['listinfconta']==1) ? "selected":"";
|
---|
98 | echo"<td align=\"center\"><b>"._LISTINFCONTA."</b></td><td><select name=\"listinfconta\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td></tr>"
|
---|
99 | ."<tr><td align=\"center\" colspan=\"4\" bgcolor=\"$bgcolor2\"><b>"._SISTEMA_PROPORZIONALE."</b></td></tr>"
|
---|
100 | ."<tr><td align=\"center\"><b>"._SUPPREMIO."</b></td><td><input type=\"text\" name=\"suppremio\" value=\"".$gru['suppremio']."\"></td>"
|
---|
101 | ."<td align=\"center\"><b>"._SUPSBAR."</b></td><td><input type=\"text\" name=\"supsbarramento\" value=\"".$gru['supsbarramento']."\"></td></tr>"
|
---|
102 | ."<tr><td align=\"center\"><b>"._SUPMINPREMIO."</b></td><td><input type=\"text\" name=\"supminpremio\" value=\"".$gru['supminpremio']."\"></td>";
|
---|
103 | $sel= ($gru['listsupconta']==1) ? "selected":"";
|
---|
104 | echo "<td align=\"center\"><b>"._LISTSUPCONTA."</b></td><td><select name=\"listsupconta\"><option value=\"0\">No<option value=\"1\" $sel>Si</select>";
|
---|
105 | echo "<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
|
---|
106 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
107 | ."<input type=\"hidden\" name=\"min\" value=\"$min\"></td></tr><tr><td></td><td></td><td></td>";
|
---|
108 | if ($do=='modify')
|
---|
109 | echo "<td align=\"center\"><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td>";
|
---|
110 | else
|
---|
111 | echo "<td align=\"center\"><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td>";
|
---|
112 | echo "</tr></form>";
|
---|
113 |
|
---|
114 |
|
---|
115 |
|
---|
116 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_conf", $dbi);
|
---|
117 | $max = mysql_num_rows($res);
|
---|
118 | $result = mysql_query("select * from ".$prefix."_ele_conf ORDER BY id_conf LIMIT $min,$offset", $dbi);
|
---|
119 | while(list($id_conf,$descrizione,$limite, $consin,$infpremio, $supsbarramento, $suppremio, $listinfsbar, $listinfconta, $listsupconta) = mysql_fetch_row($result)) {
|
---|
120 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
121 | echo "<tr bgcolor=\"$bgcolor1\"><td align=\"center\"><b>$id_conf</b></td>"
|
---|
122 | ."<td align=\"left\"><b>$descrizione</b></td>"; /*
|
---|
123 | ."<td align=\"center\"><b>$limite</b></td>"
|
---|
124 | ."<td align=\"center\"><b>$consin</b></td>"
|
---|
125 | ."<td align=\"center\"><b>$infpremio</b></td>"
|
---|
126 | ."<td align=\"center\"><b>$supsbarramento</b></td>"
|
---|
127 | ."<td align=\"center\"><b>$suppremio</b></td>"
|
---|
128 | ."<td align=\"center\"><b>$listinfsbar</b></td>"
|
---|
129 | ."<td align=\"center\"><b>$listinfconta</b></td>"
|
---|
130 | ."<td align=\"center\"><b>$listsupconta</b></td>" */
|
---|
131 | echo "<td align=\"center\" nowrap>[<a
|
---|
132 | href=\"admin.php?op=confconsiglio&do=modify&id_conf=$id_conf&id_cons_gen=$id_cons_gen&min=$min\"><img src=\"modules/Elezioni/images/edit.gif\"
|
---|
133 | border=\"0\" align=\"center\"> "._EDIT."</a>]";
|
---|
134 |
|
---|
135 | if (!isset($numtemp))
|
---|
136 | echo "[<a href=\"admin.php?op=confconsiglio&do=delete&id_conf=$id_conf&id_cons_gen=$id_cons_gen&min=$min\">"._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"center\"></a>]";
|
---|
137 | else
|
---|
138 | echo "["._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"center\"></a>]";
|
---|
139 | echo "</td></tr>";
|
---|
140 | }
|
---|
141 | echo "</table></center>";
|
---|
142 |
|
---|
143 | // #'Pagina precedente' e 'Pagina Successiva'
|
---|
144 |
|
---|
145 | echo"<table align=\"center\" width=\"100%\" ><tr>";
|
---|
146 | $prev=$min-$offset;
|
---|
147 | if ($prev>=0) {
|
---|
148 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=confconsiglio&id_conf=$id_conf&id_cons_gen=$id_cons_gen&id_comune=$id_comune&min=$prev\">";
|
---|
149 | echo "<b>$offset "._PREV_MATCH."</b></a></td>";
|
---|
150 | }
|
---|
151 |
|
---|
152 | $next=$min+$offset;
|
---|
153 | if ($next>=($offset-1)) {
|
---|
154 | if($next>=$max) $next = $max;
|
---|
155 | else {
|
---|
156 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=confconsiglio&id_conf=$id_conf&id_cons_gen=$id_cons_gen&min=$next\">";
|
---|
157 | echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
|
---|
158 | }
|
---|
159 | }
|
---|
160 | echo "</tr></table><br>";
|
---|
161 |
|
---|
162 | }
|
---|
163 |
|
---|
164 | //***********************************************************
|
---|
165 | //Funzione di inserimento e gestione dei gruppi
|
---|
166 | //************************************************************
|
---|
167 |
|
---|
168 | function confcons($ok, $do) {
|
---|
169 | global $prefix, $dbi, $id_cons,$simbolo2,$genere,$id_cons_gen,$id_comune,$min,$id_conf,$descrizione, $limite,$consin,$infpremio,$listinfsbar,$infminpremio,$listinfconta,$supsbarramento,$suppremio,$supminpremio,$listsupconta;
|
---|
170 | $aid=$_SESSION['aid'];
|
---|
171 | $perms=ChiSei($id_cons_gen);
|
---|
172 | if ($perms >128) {
|
---|
173 | if ($do == "delete") {
|
---|
174 | if ($ok !="1") {
|
---|
175 | ele();
|
---|
176 | echo "<center><br><br>"._DOMCANCELLA." "._DESCR." $descrizione ?<br>";
|
---|
177 | echo "[ <a href=\"admin.php?op=confconsiglio&id_cons_gen=$id_cons_gen&id_conf=$id_conf\">"._NO."</a> ] - [<a href=\"admin.php?op=confconsiglio&do=delete&id_conf=$id_conf&id_cons_gen=$id_cons_gen&id_comune=$id_comune&ok=1\">"._YES."</a> ]";exit;
|
---|
178 | }else{
|
---|
179 | $result = mysql_query("delete from ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi);
|
---|
180 | if (!$result) return;
|
---|
181 | Header("Location: admin.php?op=confconsiglio&id_cons_gen=$id_cons_gen&id_conf=$id_conf&min=$min");
|
---|
182 | }
|
---|
183 | } elseif ($do == "add") {
|
---|
184 | if ($descrizione) {
|
---|
185 | $sqlset='';
|
---|
186 | $result = mysql_query("insert into ".$prefix."_ele_conf(id_conf,descrizione, limite,consin,infpremio,supsbarramento,suppremio,listinfsbar,listinfconta,listsupconta,infminpremio,supminpremio) values ('$id_conf','$descrizione','$limite','$consin','$infpremio','$supsbarramento','$suppremio','$listinfsbar','$listinfconta','$listsupconta','$infminpremio','$supminpremio')", $dbi) || die("Errore di aggiornamento dei dati!".mysql_error());
|
---|
187 | if (!$result) return;
|
---|
188 | Header("Location: admin.php?op=confconsiglio&id_cons_gen=$id_cons_gen&min=$min");
|
---|
189 | } else {
|
---|
190 | ele();
|
---|
191 | OpenTable();
|
---|
192 | echo "<center>"._GESTIONE." "._CONF." ";
|
---|
193 | echo "<br><br><a href=\"admin.php?op=confconsiglio&id_cons_gen=$id_cons_gen\">"._IMM." "._CONF."</a></center>";
|
---|
194 | CloseTable();
|
---|
195 | }
|
---|
196 | } elseif ($do == "update") {
|
---|
197 | $result = mysql_query("update ".$prefix."_ele_conf set descrizione='$descrizione', limite='$limite', consin='$consin', infpremio='$infpremio', supsbarramento='$supsbarramento', suppremio='$suppremio', listinfsbar='$listinfsbar', listinfconta='$listinfconta', listsupconta='$listsupconta', infminpremio='$infminpremio', supminpremio='$supminpremio' where id_conf='$id_conf' ", $dbi) || die("Errore di aggiornamento dei dati!".mysql_error());
|
---|
198 | Header("Location: admin.php?op=confconsiglio&id_cons_gen=$id_cons_gen&min=$min");
|
---|
199 | }
|
---|
200 |
|
---|
201 | }
|
---|
202 | }
|
---|
203 |
|
---|
204 | if ($do and $do!="modify")
|
---|
205 | confcons($ok, $do);
|
---|
206 | ele();
|
---|
207 | all();
|
---|
208 | echo"</td></tr></table>";
|
---|
209 | include("footer.php");
|
---|
210 |
|
---|
211 |
|
---|
212 |
|
---|
213 |
|
---|
214 | ?>
|
---|
215 |
|
---|