source: trunk/admin/modules/Elezioni/ele_sezione.php@ 254

Last change on this file since 254 was 254, checked in by roby, 7 years ago

adeguata la funzione di installazione al php7

File size: 11.5 KB
Line 
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 sezioni */
9/* Amministrazione */
10/************************************************************************/
11if (!defined('ADMIN_FILE')) {
12 die ("You can't access this file directly...");
13}
14$id_comune=$_SESSION['id_comune'];
15$id_cons_gen=$_GET['id_cons_gen'];
16$perms=ChiSei($id_cons_gen);
17if ($perms<32 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
18
19
20$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);
21list($tipo_cons,$id_cons) = mysql_fetch_row($res);
22if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
23if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='';
24if (isset($param['min'])) $min=intval($param['min']); else $min=0;
25if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
26if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez='';
27if (isset($param['aut_m'])) $aut_m=intval($param['aut_m']); else $aut_m='';
28if (isset($param['aut_f'])) $aut_f=intval($param['aut_f']); else $aut_f='';
29if (isset($param['maschi'])) $maschi=intval($param['maschi']); else $maschi='';
30if (isset($param['femmine'])) $femmine=intval($param['femmine']); else $femmine='';
31if (isset($param['id_sez2'])) $id_sez2=intval($param['id_sez2']); else $id_sez2='';
32if (isset($param['num_sez'])) $num_sez=intval($param['num_sez']); else $num_sez='';
33
34include("modules/Elezioni/funzionidata.php");
35include("modules/Elezioni/ele.php");
36// Offset - visualizza il numero di elementi per pagina
37$offset=10;
38$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
39
40
41/******************************************************/
42/*Funzione di visualizzazione globale */
43/*****************************************************/
44
45function all() {
46 global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $id_cons,$id_cons_gen;
47# OpenTable();
48 $y=0;
49 echo "<center><font class=\"title\"><a NAME=riga><b>"._SEZIONE."</b></a></font><br><br><table border=\"0\" width=\"95%\"><tr>"
50 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NUM."</b></td>"
51 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._INDIRIZZO."</b></td>"
52 ."<td bgcolor=\"$bgcolor1\" align=\"center\" ><b>"._MASCHI."</b></td>"
53 ."<td bgcolor=\"$bgcolor1\" align=\"center\" ><b>"._FEMMINE."</b></td>"
54 ."<td bgcolor=\"$bgcolor1\" align=\"center\" ><b>"._TOTS." "._ISCRITTI."</b></td>"
55 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
56 $res = mysql_query("SELECT * FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' ", $dbi);
57 $max = mysql_num_rows($res);
58 echo "<tr align=\"center\"><form name=\"sezi\" action=\"admin.php\">"
59 ."<input type=\"hidden\" name=\"op\" value=\"sezione\">"
60 ."<input type=\"hidden\" name=\"do\" value=\"add\">";
61
62 $nuova= $max+1;
63 $res = mysql_query("SELECT id_sede FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez='$max' ", $dbi);
64 list($id_sede_old) = mysql_fetch_row($res);
65
66 echo "<td><input type=\"text\" name=\"num_sez\" value=\"$nuova\" size=\"5\"></td>";
67
68 echo "<td><select name=\"id_sede\">";
69 $res= mysql_query("SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' order by indirizzo", $dbi);
70 while(list($id,$indir) = mysql_fetch_row($res)) {
71 if ($id == $id_sede_old) {
72 $sel = "selected";
73 } else {
74 $sel = "";
75 }
76 echo "<option value=\"$id\" $sel>$indir";
77 }
78 echo "</select></td>";
79 //*************************************
80
81 echo "<td><input type=\"text\" name=\"maschi\" size=\"4\"></td>";
82
83
84 echo "<td><input type=\"text\" name=\"femmine\" size=\"4\"></td>";
85
86 echo "<td><input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
87 echo "<input type=\"hidden\" name=\"min\" value=\"$min\">"
88 ."</td><td><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr>"
89 ."</form>";
90
91
92
93
94
95 $result = mysql_query("select id_cons, id_sez, id_sede, num_sez, maschi, femmine, autorizzati_m, autorizzati_f from ".$prefix."_ele_sezioni where id_cons='$id_cons' ORDER BY num_sez LIMIT $min,$offset", $dbi);
96 while(list($id_cons2,$id_sez,$id_sede,$num_sez, $maschi, $femmine,$aut_m,$aut_f) = mysql_fetch_row($result)) {
97 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
98 // dati circoscrizione
99 $result1 = mysql_query("select indirizzo from ".$prefix."_ele_sede where id_sede='$id_sede'", $dbi);
100 list($indir)=mysql_fetch_row($result1);
101 $totali=$maschi+$femmine+$aut_m+$aut_f;
102 $y++;
103 echo "<form name=\"sez$y\" action=\"admin.php\">"
104 ."<input type=\"hidden\" name=\"op\" value=\"sezione\">"
105 ."<input type=\"hidden\" name=\"do\" value=\"update\">"
106 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
107 ."<input type=\"hidden\" name=\"min\" value=\"$min\">"
108 ."<input type=\"hidden\" name=\"id_sez2\" value=\"$id_sez\">"
109 ."<input type=\"hidden\" name=\"num_sez\" value=\"$num_sez\">";
110
111 echo "<tr bgcolor=\"$bgcolor1\"><td align=\"right\" size=\"90\"><b>$num_sez</b></td>";
112 echo "<td align=\"right\" size=\"120\"><select name=\"id_sede\">";
113 $res= mysql_query("SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' order by indirizzo", $dbi);
114 while(list($id,$indir) = mysql_fetch_row($res)) {
115 if ($id == $id_sede) {
116 $sel = "selected";
117 } else {
118 $sel = "";
119 }
120 echo "<option value=\"$id\" $sel>$indir";
121 }
122 echo "</select></td>";
123
124 echo "<td align=\"center\"><b><input type=\"text\" size=\"4\" name=\"maschi\" value=\"$maschi\"></b>";
125 echo "</td><td align=\"center\"><b><input type=\"text\" size=\"4\" name=\"femmine\" value=\"$femmine\"></b>";
126 echo "</td><td align=\"center\"><b>$totali</b>"
127 ."</td><td align=\"center\" nowrap><table><tr><td align=\"center\" width=\"50%\">"
128 ."<input type=\"submit\" name=\"update$y\" value=\""._OK."\">" ;
129 echo "</td><td align=\"center\" nowrap width=\"50%\">"
130 ."[<a href=\"admin.php?op=sezione&amp;do=delete&amp;id_sede=$id_sede&amp;id_sez=$id_sez&amp;id_cons_gen=$id_cons_gen&amp;num_sez=$num_sez&amp;min=$min\">"._DELETE."<img src=\"modules/Elezioni/images/delete.gif\"
131 border=\"0\" align=\"center\"></a>]</td></tr></table>";
132 echo "</td></tr></form>\n";
133 }
134 echo "</table></center>";
135 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
136 ."document.sez2.maschi.focus()\n"
137 ."document.sez2.maschi.select()\n"
138 ."//-->\n"
139 ."</script>\n";
140
141 #'Pagina precedente' e 'Pagina Successiva'
142 echo"<table align=\"center\" width=\"100%\"><tr>";
143 if ($min<$offset and $min!=0) $min=$offset;
144 $prev=$min-$offset;
145
146 if ($prev>=0) {
147 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=sezione&amp;id_sede=$id_sede&amp;id_sez=$id_sez&amp;id_cons_gen=$id_cons_gen&amp;min=$prev\">";
148 echo "<b>"._PREV_MATCH."</b></a></td>";
149 }
150
151 $next=$min+$offset;
152 if ($next>=($offset-1)) {
153 if($next>=$max) $next = $max;
154 else {
155
156 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=sezione&amp;id_sede=$id_sede&amp;id_sez=$id_sez&amp;id_cons_gen=$id_cons_gen&amp;min=$next\">";
157 echo "<b>"._NEXT_MATCH."</b></a></td>";
158 }
159 }
160 echo "</tr></table><br>";
161#CloseTable();
162#include("footer.php");
163}
164
165
166
167function sezione($ok, $do,$id_sede,$id_sez, $num_sez, $aut_ma, $aut_fe, $maschi, $femmine, $id_sez2,$min) {
168global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons, $id_cons,$id_cons_gen;
169$perms=ChiSei($id_cons_gen);
170if ($perms>16) {
171 $aut_m=intval($aut_ma);
172 $aut_f=intval($aut_fe);
173 if ($do == "delete") {
174 if ($ok !="1") {
175 ele();
176 echo "<center><br><br>"._DOMCANCELLA." "._NUM." "._SEZIONE." $num_sez ?<br>";
177 echo "[ <a href=\"admin.php?op=sezione&amp;id_cons_gen=$id_cons_gen&amp;min=$min\">"._NO."</a> ] - [<a href=\"admin.php?op=sezione&amp;do=delete&amp;id_sede=$id_sede&amp;id_sez=$id_sez&amp;id_cons_gen=$id_cons_gen&amp;ok=1&amp;min=$min\">"._YES."</a> ]";
178 include("footer.php");
179 die();
180 }else{
181 $result = mysql_query("delete from ".$prefix."_ele_voti_candidati where id_sez='$id_sez'", $dbi)|| die("(1104) Non e' stato possibile eliminare i dati dal database! contattare l'amministratore".mysql_error());
182 $result = mysql_query("delete from ".$prefix."_ele_voti_lista where id_sez='$id_sez'", $dbi)|| die("(1104) Non e' stato possibile eliminare i dati dal database! contattare l'amministratore".mysql_error());
183 $result = mysql_query("delete from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'",$dbi)|| die("(1104) Non e' stato possibile eliminare i dati dal database! contattare l'amministratore".mysql_error());
184 $result = mysql_query("delete from ".$prefix."_ele_voti_ref where id_sez='$id_sez'", $dbi)|| die("(1104) Non e' stato possibile eliminare i dati dal database! contattare l'amministratore".mysql_error());
185 $result = mysql_query("delete from ".$prefix."_ele_voti_parziale where id_sez='$id_sez'", $dbi)|| die("(1104) Non e' stato possibile eliminare i dati dal database! contattare l'amministratore".mysql_error());
186 $result = mysql_query("delete from ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi)|| die("(1104) Non e' stato possibile eliminare i dati dal database! contattare l'amministratore".mysql_error());
187 Header("Location: admin.php?op=sezione&id_cons_gen=$id_cons_gen&min=$min");
188 }
189 }elseif ($do == "add") {
190 if ($num_sez) {
191 $result = mysql_query("insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez,maschi,femmine, autorizzati_m,autorizzati_f) values ('$id_cons', '$id_sede', '$num_sez','$maschi','$femmine','$aut_m', '$aut_f')", $dbi)|| die("(1104) Non e' stato possibile inserire i dati nel database! contattare l'amministratore".mysql_error());
192 Header("Location: admin.php?op=sezione&id_cons_gen=$id_cons_gen&min=$min");
193 } else {
194 ele();
195 OpenTable();
196 echo "<center>"._GESTIONE." "._SEZIONE." ";
197 echo "<br><br><a href=\"admin.php?op=sezione&amp;id_cons_gen=$id_cons_gen&amp;min=$min\">"._IMM." "._SEZIONE."</a></center>";
198 CloseTable();
199 }
200 }elseif ($do == "update") {
201 $result = mysql_query("update ".$prefix."_ele_sezioni set id_sede='$id_sede', maschi='$maschi', femmine='$femmine', autorizzati_m='$aut_m', autorizzati_f='$aut_f' where id_sez='$id_sez2' ", $dbi)|| die("(1104) Non e' stato possibile aggiornare i dati nel database! contattare l'amministratore".mysql_error());
202 $num_sez--;
203 Header("Location: admin.php?op=sezione&id_cons_gen=$id_cons_gen&min=$num_sez");
204 }
205
206}
207}
208
209
210
211
212
213if ($op=="sezione")
214 sezione($ok, $do,$id_sede,$id_sez, $num_sez, $aut_m, $aut_f, $maschi, $femmine, $id_sez2, $min);
215ele();
216all();
217 echo"</td></tr></table>";
218include ("footer.php");
219
220?>
221
Note: See TracBrowser for help on using the repository browser.