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

Last change on this file since 256 was 256, checked in by roby, 6 years ago
File size: 12.8 KB
RevLine 
[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 definiione consultazione */
9/* Amministrazione */
10/************************************************************************/
11if (!defined('ADMIN_FILE')) {
12 die ("You can't access this file directly...");
13}
14
[256]15global $dbi;
[2]16$aid=$_SESSION['aid'];
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!");
25include("modules/Elezioni/funzionidata.php");
26include("modules/Elezioni/ele.php");
[256]27$row=descr_cons();
28$tipo_cons=$row[0];$descr_cons=$row[2];
29
[2]30if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
31if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
32if (isset($param['id_cons2'])) $id_cons2=intval($param['id_cons2']); else $id_cons2='';
33if (isset($param['min'])) $min=intval($param['min']); else $min=0;
34if (isset($param['duplica'])) $duplica=intval($param['duplica']); else $duplica='';
35if (isset($param['elettori'])) get_magic_quotes_gpc() ? $elettori=$param['elettori']:$elettori=addslashes($param['elettori']); else $elettori='';
36if (isset($param['predefinita'])) $predefinita=intval($param['predefinita']); else $predefinita='';
[122]37if (isset($param['help'])) $help=intval($param['help']);
[2]38
39$offset=10;
40$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
41
42
43/******************************************************/
44/*Funzione di visualizzazione globale */
45/*****************************************************/
46
47function all() {
[45]48global $bgcolor1, $bgcolor2, $bgcolor6, $prefix, $dbi, $offset, $min, $id_cons,$id_cons2, $id_comune,$descr_cons,$id_cons_gen,$perms,$language,$help;
[2]49
[122]50 if (isset($help)) include("language/$language/ele_cons_comuni.html");
[256]51 $row=descr_comune();
[2]52 $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune=$id_comune", $dbi);
[256]53 if (count($row)) $idpred = $row[2]; else $idpred='';
54# $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);
55 $row=elenco_cons_comune();
56
57 $max = count($row);
[2]58 echo "<table border=\"0\" width=\"100%\" align=\"left\"><tr><td>";
59 echo "<form name=\"imppred\" action=\"admin.php\">";
[53]60 echo "<table style=\"color: #000000;\"><tr><td bgcolor=\"$bgcolor1\">"
[2]61 ."&nbsp;<b>"._CONSPRED."</b>&nbsp;</td><td><select name=\"predefinita\">";
62 echo "<option value=\"\">";
[256]63 foreach($row as $arr){
[2]64 $sel='';
65 if (($idpred))
66 $sel= ($arr['id_cons'] == $idpred) ? "selected":"";
67 echo "<option value=\"".$arr['id_cons']."\" $sel>".$arr['descrizione'];
68 }
69 echo "</select></td><td>";
70 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
71 echo "<input type=\"hidden\" name=\"op\" value=\"cons_comuni\">";
72 echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
73 echo "<input type=\"submit\" name=\"add\" value=\""._OK."\"></td>";
74 echo "</tr></table></form></td></tr></table><hr>";
75
76 echo "<center><font class=\"title\"><b><BR>"._COPIA." "._LA." "._STRUTTURA." "._DA." $descr_cons</b></font><br><br><table border=\"0\" width=\"100%\">"
77 ."<tr><td bgcolor=\"$bgcolor1\" align=\"center\">&nbsp;<b>"._DESCR."</b>&nbsp;</td>"
78 ."<td bgcolor=\"$bgcolor1\" align=\"center\">&nbsp;<b>"._DATAIN."</b>&nbsp;</td>"
79 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DATAFINE."</b></td>"
80 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._COPIA." "._NUM." "._ELETTORI."</b></td>"
81 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
[256]82 $sql = "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";
83 $sth = $dbi->prepare("$sql");
84 $sth->execute();
85 $row = $sth->fetchAll();
[2]86 $i=0;
[256]87 foreach($row as $arr) {
88 $chiusa=$arr[0];$id_cons2=$arr[1];$idconsgen2=$arr[2]; $descr_cons=$arr[3]; $data_inizio=$arr[4]; $data_fine=$arr[5];$tipo=$arr[6];
[2]89 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
[256]90 $sql = "select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'";
91 $sth = $dbi->prepare("$sql");
92 $sth->execute();
93 $row = $sth->fetch(PDO::FETCH_BOTH);
94 $somma=$row[0];
[2]95 $data_inizio=form_data($data_inizio);$data_fine=form_data($data_fine);
96 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>"
97 ."<td>$data_inizio</td>"
98 ."<td>$data_fine</td>";
99 if ($somma==0){
100 $i++;
101 echo "<form name=\"scelta$i\" action=\"admin.php\">";
102 echo "<td align=\"center\"><select name=\"elettori\">";
103 echo "<option value=\"false\">"._NO."</option>";
104 echo "<option value=\"true\">"._SI."</option>";
105 echo "</select></td>";
106 echo "<input type=\"hidden\" name=\"op\" value=\"cons_comuni\">";
107 echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
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=\""._POPOLA."\"></td>";
111 echo "</form>";
112 }elseif($perms==256){
113 $i++;
114 echo "<form name=\"scelta$i\" action=\"admin.php\">";
115 echo "<td align=\"center\">Aggiorna il numero elettori</td>";
116 echo "<input type=\"hidden\" name=\"op\" value=\"cons_comuni\">";
117 echo "<input type=\"hidden\" name=\"do\" value=\"elettori\">";
118 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
119 echo "<input type=\"hidden\" name=\"id_cons2\" value=\"$id_cons2\">";
120 echo "<td align=\"center\"><input type=\"submit\" value=\""._UPDATE."\"></td>";
121 echo "</form>";
122
123 }
124 echo "</tr>";
125 }
126 echo "</table></center>";
127 #'Pagina precedente' e 'Pagina Successiva'
128 echo "<table align=\"center\" width=\"100%\" bgcolor=\"$bgcolor1\"><tr>";
129 $prev=$min-$offset;
130 if ($prev>=0) {
131 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\">";
132 echo "<b>$offset "._PREV_MATCH."</b></a></td>";
133 }
134
135 $next=$min+$offset;
136 if ($next>=($offset-1)) {
137 if($next>=$max) $next = $max;
138 else {
139 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\">";
140 echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
141 }
142 }
143 echo "</tr></table><br>";
144}
145
146
147
148function cons_comuni($ok, $id_cons2,$do, $duplica,$elettori)
149{
150 global $prefix, $dbi,$id_comune,$id_cons_gen,$perms,$predefinita;
151if ($perms>32) {
152 $sql="select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune=$id_comune";
[256]153 $sth = $dbi->prepare("$sql");
154 $sth->execute();
155 $row = $sth->fetch(PDO::FETCH_BOTH);
156 $id_consulta=$row[0];
[2]157 $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";
[256]158 $sth = $dbi->prepare("$sql");
159 $sth->execute();
160 $row = $sth->fetch(PDO::FETCH_BOTH);
161
162 $descr_cons2=$row[0];
[2]163 if ($do == "add") {
164 if ($id_cons2) {
165 // copia circoscrizione
[256]166 $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'";
167 $sth = $dbi->prepare("$sql");
168 $sth->execute();
169 $row = $sth->fetchAll();
170 foreach($row as $arr){
171 $id=$arr[0];$idcirc=$arr[1];$num=$arr[2];$des2=$arr[3];
172 $des=addslashes($des2);
173 $sql="select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'";
174 $sth = $dbi->prepare("$sql");
175 $sth->execute();
176 $row = $sth->fetch(PDO::FETCH_BOTH);
177 $contr_circ=$row[0];
178 if (! $contr_circ){
179 sql="insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')";
180 $sth = $dbi->prepare("$sql");
181 $sth->execute();
182
183 }
184 $sql="select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num";
185 $sth = $dbi->prepare("$sql");
186 $sth->execute();
187 $row = $sth->fetch(PDO::FETCH_BOTH);
188 $id_circ=$row[0];
[2]189 // copia sede
[256]190 $sql="select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'";
191 $sth = $dbi->prepare("$sql");
192 $sth->execute();
193 $row = $sth->fetchAll();
194 foreach($row as $row2) {
195 $id1=$row2[0];$idsede1=$row2[1];$idcirc1=$row2[2];$ind2=$row2[3];$tel=$row2[4];$tel2=$row2[5];$fax=$row2[6];$resp=$row2[7];$mappa2=$row2[8];$filemappa2=$row2[9];
[122]196 $filemappa=addslashes($filemappa2);
[2]197 $mappa=addslashes($mappa2);
[122]198 $ind=addslashes($ind2);
[256]199 $sql="select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'";
200 $sth = $dbi->prepare("$sql");
201 $sth->execute();
202 $row = $sth->fetch(PDO::FETCH_BOTH);
203 $contr_sed=$row[0];
204 if (! $contr_sed){
205 $sql="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')";
206 $sth = $dbi->prepare("$sql");
207 $sth->execute();
208 }
209 $sql"select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'";
[2]210 list($id_sede)=mysql_fetch_row($res2);
[256]211 $sth = $dbi->prepare("$sql");
212 $sth->execute();
213 $row = $sth->fetch(PDO::FETCH_BOTH);
214 $id_sede=$row[0];
[2]215 //copia sezione
[256]216 $sql="select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1";
217 $sth = $dbi->prepare("$sql");
218 $sth->execute();
219 $row = $sth->fetchAll();
220 foreach($row as $arr2)
221 {
222 $id3=$arr2[0];$idsez3=$arr2[1];$idsede3=$arr2[2];$numero=$arr2[3];$maschi3=$arr2[4];$femmine3=$arr2[5];$validi3=$arr2[6];$nulli3=$arr2[7];
223 $bianchi3=$arr2[8];$contest3=$arr2[9];$sg3,$aut_m=$arr2[10];$aut_f=$arr2[11];
[2]224 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')";
225 else $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez) values ('$id_cons2','$id_sede','$numero')";
[256]226 $sth = $dbi->prepare("$sql");
227 $sth->execute();
228
[2]229 }
230 }
231 }
232 # Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
233 }
234 }
235 if ($do == "elettori") {
236 if ($ok !="1") {
237 ele();
238 echo "<center><br><br>"._DOMAGGIORNA." Consultazione $descr_cons2 ?<br>";
239 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;
240 }else{
[256]241 $sql="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";
242 $sth = $dbi->prepare("$sql");
243 $result=$sth->execute();
244
[2]245 if (!$result) return;
246 Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
247 }
248 }
249 if ($do == "update") {
250 if ($predefinita)
[256]251 {
252 $sql="update ".$prefix."_ele_comuni set id_cons='$predefinita' WHERE id_comune='$id_comune'";
253 $sth = $dbi->prepare("$sql");
254 $result=$sth->execute();
255 }else{
256 $sql"update ".$prefix."_ele_cons_comune set chiusa='$chiusa' WHERE id_cons2='$id_cons2'";
257 $sth = $dbi->prepare("$sql");
258 $result=$sth->execute();
259 }
260 if (!$result) return;
[2]261 Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
262 }
263}
264}
265
266function help_cons()
267{
268//da mettere
269}
270
271if ($do) {
272 cons_comuni($ok, $id_cons2,$do, $duplica, $elettori);
273}
274ele();
275//OpenTable();
276all();
277CloseTable();
278include("footer.php");
279?>
280
Note: See TracBrowser for help on using the repository browser.