source: trunk/admin/modules/Elezioni/ele_cons_comuni.php@ 80

Last change on this file since 80 was 53, checked in by roby, 15 years ago

continua menu contestuale - correzione per visualizzazione grafici affluenze per referendum

File size: 11.8 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 definiione consultazione */
9/* Amministrazione */
10/************************************************************************/
11if (!defined('ADMIN_FILE')) {
12 die ("You can't access this file directly...");
13}
14
15$aid=$_SESSION['aid'];
16$dbi=$_SESSION['dbi'];
17$prefix=$_SESSION['prefix'];
18if($param)
19$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
20$vari= implode(',',$param);
21$id_cons_gen=$_GET['id_cons_gen'];
22$id_comune=$_SESSION['id_comune'];
23$perms=ChiSei(0);
24if ($perms<64 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
25$res = mysql_query("SELECT tipo_cons,descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' " , $dbi);
26list($tipo_cons,$descr_cons) = mysql_fetch_row($res);
27include("modules/Elezioni/funzionidata.php");
28include("modules/Elezioni/ele.php");
29if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
30if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
31if (isset($param['id_cons2'])) $id_cons2=intval($param['id_cons2']); else $id_cons2='';
32if (isset($param['min'])) $min=intval($param['min']); else $min=0;
33if (isset($param['duplica'])) $duplica=intval($param['duplica']); else $duplica='';
34if (isset($param['elettori'])) get_magic_quotes_gpc() ? $elettori=$param['elettori']:$elettori=addslashes($param['elettori']); else $elettori='';
35if (isset($param['predefinita'])) $predefinita=intval($param['predefinita']); else $predefinita='';
36if (isset($param['help'])) $help=intval($param['help']);
37
38$offset=10;
39$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
40
41
42/******************************************************/
43/*Funzione di visualizzazione globale */
44/*****************************************************/
45
46function all() {
47global $bgcolor1, $bgcolor2, $bgcolor6, $prefix, $dbi, $offset, $min, $id_cons,$id_cons2, $id_comune,$descr_cons,$id_cons_gen,$perms,$language,$help;
48
49 if (isset($help)) include("language/$language/ele_cons_comuni.html");
50
51 $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune=$id_comune", $dbi);
52 if (isset($res)) list($idpred) = mysql_fetch_row($res); else $idpred='';
53 $res = mysql_query("SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' " , $dbi);
54 $max = mysql_num_rows($res);
55 echo "<table border=\"0\" width=\"100%\" align=\"left\"><tr><td>";
56 echo "<form name=\"imppred\" action=\"admin.php\">";
57 echo "<table style=\"color: #000000;\"><tr><td bgcolor=\"$bgcolor1\">"
58 ."&nbsp;<b>"._CONSPRED."</b>&nbsp;</td><td><select name=\"predefinita\">";
59 echo "<option value=\"\">";
60 while($arr=mysql_fetch_array($res,3)){
61 $sel='';
62 if (($idpred))
63 $sel= ($arr['id_cons'] == $idpred) ? "selected":"";
64 echo "<option value=\"".$arr['id_cons']."\" $sel>".$arr['descrizione'];
65 }
66 echo "</select></td><td>";
67 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
68 echo "<input type=\"hidden\" name=\"op\" value=\"cons_comuni\">";
69 echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
70 echo "<input type=\"submit\" name=\"add\" value=\""._OK."\"></td>";
71 echo "</tr></table></form></td></tr></table><hr>";
72
73 echo "<center><font class=\"title\"><b><BR>"._COPIA." "._LA." "._STRUTTURA." "._DA." $descr_cons</b></font><br><br><table border=\"0\" width=\"100%\">"
74 ."<tr><td bgcolor=\"$bgcolor1\" align=\"center\">&nbsp;<b>"._DESCR."</b>&nbsp;</td>"
75 ."<td bgcolor=\"$bgcolor1\" align=\"center\">&nbsp;<b>"._DATAIN."</b>&nbsp;</td>"
76 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DATAFINE."</b></td>"
77 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._COPIA." "._NUM." "._ELETTORI."</b></td>"
78 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
79 $result = mysql_query("select t2.chiusa,t2.id_cons,t1.* from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t2.id_comune='$id_comune' and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons!=$id_cons ORDER BY data_fine desc LIMIT $min,$offset", $dbi);
80 $i=0;
81 while(list($chiusa,$id_cons2,$idconsgen2, $descr_cons, $data_inizio, $data_fine,$tipo) = mysql_fetch_row($result)) {
82 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
83 $ressez = mysql_query("select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'", $dbi);
84 list($somma)=mysql_fetch_row($ressez);
85 $data_inizio=form_data($data_inizio);$data_fine=form_data($data_fine);
86 echo "<tr bgcolor=\"$bgcolor1\" align=\"center\" ><td align=\"left\" ><a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$idconsgen2\"><b>$descr_cons</b></a></td>"
87 ."<td>$data_inizio</td>"
88 ."<td>$data_fine</td>";
89 if ($somma==0){
90 $i++;
91 echo "<form name=\"scelta$i\" action=\"admin.php\">";
92 echo "<td align=\"center\"><select name=\"elettori\">";
93 echo "<option value=\"false\">"._NO."</option>";
94 echo "<option value=\"true\">"._SI."</option>";
95 echo "</select></td>";
96 echo "<input type=\"hidden\" name=\"op\" value=\"cons_comuni\">";
97 echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
98 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
99 echo "<input type=\"hidden\" name=\"id_cons2\" value=\"$id_cons2\">";
100 echo "<td align=\"center\"><input type=\"submit\" value=\""._POPOLA."\"></td>";
101 echo "</form>";
102 }elseif($perms==256){
103 $i++;
104 echo "<form name=\"scelta$i\" action=\"admin.php\">";
105 echo "<td align=\"center\">Aggiorna il numero elettori</td>";
106 echo "<input type=\"hidden\" name=\"op\" value=\"cons_comuni\">";
107 echo "<input type=\"hidden\" name=\"do\" value=\"elettori\">";
108 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
109 echo "<input type=\"hidden\" name=\"id_cons2\" value=\"$id_cons2\">";
110 echo "<td align=\"center\"><input type=\"submit\" value=\""._UPDATE."\"></td>";
111 echo "</form>";
112
113 }
114 echo "</tr>";
115 }
116 echo "</table></center>";
117 #'Pagina precedente' e 'Pagina Successiva'
118 echo "<table align=\"center\" width=\"100%\" bgcolor=\"$bgcolor1\"><tr>";
119 $prev=$min-$offset;
120 if ($prev>=0) {
121 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor2\"><a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$id_cons_gen&amp;min=$prev\">";
122 echo "<b>$offset "._PREV_MATCH."</b></a></td>";
123 }
124
125 $next=$min+$offset;
126 if ($next>=($offset-1)) {
127 if($next>=$max) $next = $max;
128 else {
129 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor2\"><a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$id_cons_gen&amp;min=$next\">";
130 echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
131 }
132 }
133 echo "</tr></table><br>";
134}
135
136
137
138function cons_comuni($ok, $id_cons2,$do, $duplica,$elettori)
139{
140 global $prefix, $dbi,$id_comune,$id_cons_gen,$perms,$predefinita;
141if ($perms>32) {
142 $sql="select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune=$id_comune";
143 $res=mysql_query("$sql",$dbi);
144 list($id_consulta)=mysql_fetch_row($res);
145 $sql="select t1.descrizione from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t2.id_cons='$id_cons2' and t1.id_cons_gen=t2.id_cons_gen";
146 $res=mysql_query("$sql",$dbi);
147 list($descr_cons2)=mysql_fetch_row($res);
148 if ($do == "add") {
149 if ($id_cons2) {
150 // copia circoscrizione
151 $res=mysql_query("select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'", $dbi);
152 while (list($id,$idcirc,$num,$des)=mysql_fetch_row($res)){
153 $resconnew=mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'", $dbi);
154list($contr_circ)=mysql_fetch_row($resconnew);
155if (! $contr_circ){
156 mysql_query("insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')", $dbi) || die("Impossibile inserire i dati delle circoscrizioni! ".mysql_error());
157}
158 $res0=mysql_query("select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num", $dbi);
159 list($id_circ)=mysql_fetch_row($res0);
160 // copia sede
161 $res1=mysql_query("select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'", $dbi);
162 while(list($id1,$idsede1,$idcirc1,$ind,$tel,$tel2,$fax,$resp,$mappa2,$filemappa)=mysql_fetch_row($res1)){
163 $mappa=addslashes($mappa2);
164 $ressednew=mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'", $dbi);
165list($contr_sed)=mysql_fetch_row($ressednew);
166if (! $contr_sed){
167 mysql_query("insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons2','$id_circ','$ind','$tel','$tel2','$fax','$resp','$mappa','$filemappa')", $dbi) || die("Impossibile inserire i dati delle sedi! ".mysql_error());
168}
169 $res2=mysql_query("select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'", $dbi);
170 list($id_sede)=mysql_fetch_row($res2);
171 //copia sezione
172 $res3=mysql_query("select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1", $dbi);
173 while (list($id3,$idsez3,$idsede3,$numero,$maschi3,$femmine3,$validi3,$nulli3,
174 $bianchi3,$contest3,$sg3,$aut_m,$aut_f)=mysql_fetch_row($res3)){
175 if ($elettori=='true') $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez,maschi,femmine) values ('$id_cons2','$id_sede','$numero','$maschi3','$femmine3')";
176 else $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez) values ('$id_cons2','$id_sede','$numero')";
177 mysql_query("$sql", $dbi) || die("Impossibile inserire i dati delle sezioni! ".mysql_error());
178 }
179 }
180 }
181 # Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
182 }
183 }
184 if ($do == "elettori") {
185 if ($ok !="1") {
186 ele();
187 echo "<center><br><br>"._DOMAGGIORNA." Consultazione $descr_cons2 ?<br>";
188 echo "[ <a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=cons_comuni&amp;do=elettori&amp;id_cons_gen=$id_cons_gen&amp;id_cons2=$id_cons2&amp;ok=1\">"._YES."</a> ]";exit;
189 }else{
190 $result = mysql_query("update ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sezioni as t2 set t1.maschi=t2.maschi, t1.femmine=t2.femmine WHERE t1.id_cons=$id_cons2 and t2.id_cons=$id_consulta and t1.num_sez=t2.num_sez", $dbi);
191 if (!$result) return;
192 Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
193 }
194 }
195 if ($do == "update") {
196 if ($predefinita)
197 $result = mysql_query("update ".$prefix."_ele_comuni set id_cons='$predefinita' WHERE id_comune='$id_comune'", $dbi);
198 else
199 $result = mysql_query("update ".$prefix."_ele_cons_comune set chiusa='$chiusa' WHERE id_cons2='$id_cons2'", $dbi);
200 if (!$result) return;
201 Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
202 }
203}
204}
205
206function help_cons()
207{
208//da mettere
209}
210
211if ($do) {
212 cons_comuni($ok, $id_cons2,$do, $duplica, $elettori);
213}
214ele();
215//OpenTable();
216all();
217CloseTable();
218include("footer.php");
219?>
220
Note: See TracBrowser for help on using the repository browser.