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 | /************************************************************************/
|
---|
11 | if (!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'];
|
---|
18 | if($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);
|
---|
24 | if ($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);
|
---|
26 | list($tipo_cons,$descr_cons) = mysql_fetch_row($res);
|
---|
27 | include("modules/Elezioni/funzionidata.php");
|
---|
28 | include("modules/Elezioni/ele.php");
|
---|
29 | if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
30 | if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
|
---|
31 | if (isset($param['id_cons2'])) $id_cons2=intval($param['id_cons2']); else $id_cons2='';
|
---|
32 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
33 | if (isset($param['duplica'])) $duplica=intval($param['duplica']); else $duplica='';
|
---|
34 | if (isset($param['elettori'])) get_magic_quotes_gpc() ? $elettori=$param['elettori']:$elettori=addslashes($param['elettori']); else $elettori='';
|
---|
35 | if (isset($param['predefinita'])) $predefinita=intval($param['predefinita']); else $predefinita='';
|
---|
36 | if (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 |
|
---|
46 | function all() {
|
---|
47 | global $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 | ." <b>"._CONSPRED."</b> </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\"> <b>"._DESCR."</b> </td>"
|
---|
75 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"> <b>"._DATAIN."</b> </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&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&id_cons_gen=$id_cons_gen&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&id_cons_gen=$id_cons_gen&min=$next\">";
|
---|
130 | echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
|
---|
131 | }
|
---|
132 | }
|
---|
133 | echo "</tr></table><br>";
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 | function cons_comuni($ok, $id_cons2,$do, $duplica,$elettori)
|
---|
139 | {
|
---|
140 | global $prefix, $dbi,$id_comune,$id_cons_gen,$perms,$predefinita;
|
---|
141 | if ($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,$des2)=mysql_fetch_row($res)){
|
---|
153 | $des=addslashes($des2);
|
---|
154 | $resconnew=mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'", $dbi);
|
---|
155 | list($contr_circ)=mysql_fetch_row($resconnew);
|
---|
156 | if (! $contr_circ){
|
---|
157 | 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());
|
---|
158 | }
|
---|
159 | $res0=mysql_query("select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num", $dbi);
|
---|
160 | list($id_circ)=mysql_fetch_row($res0);
|
---|
161 | // copia sede
|
---|
162 | $res1=mysql_query("select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'", $dbi);
|
---|
163 | while(list($id1,$idsede1,$idcirc1,$ind2,$tel,$tel2,$fax,$resp,$mappa2,$filemappa2)=mysql_fetch_row($res1)){
|
---|
164 | $filemappa=addslashes($filemappa2);
|
---|
165 | $mappa=addslashes($mappa2);
|
---|
166 | $ind=addslashes($ind2);
|
---|
167 | $ressednew=mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'", $dbi);
|
---|
168 | list($contr_sed)=mysql_fetch_row($ressednew);
|
---|
169 | if (! $contr_sed){
|
---|
170 | 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());
|
---|
171 | }
|
---|
172 | $res2=mysql_query("select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'", $dbi);
|
---|
173 | list($id_sede)=mysql_fetch_row($res2);
|
---|
174 | //copia sezione
|
---|
175 | $res3=mysql_query("select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1", $dbi);
|
---|
176 | while (list($id3,$idsez3,$idsede3,$numero,$maschi3,$femmine3,$validi3,$nulli3,
|
---|
177 | $bianchi3,$contest3,$sg3,$aut_m,$aut_f)=mysql_fetch_row($res3)){
|
---|
178 | 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')";
|
---|
179 | else $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez) values ('$id_cons2','$id_sede','$numero')";
|
---|
180 | mysql_query("$sql", $dbi) || die("Impossibile inserire i dati delle sezioni! ".mysql_error());
|
---|
181 | }
|
---|
182 | }
|
---|
183 | }
|
---|
184 | # Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
|
---|
185 | }
|
---|
186 | }
|
---|
187 | if ($do == "elettori") {
|
---|
188 | if ($ok !="1") {
|
---|
189 | ele();
|
---|
190 | echo "<center><br><br>"._DOMAGGIORNA." Consultazione $descr_cons2 ?<br>";
|
---|
191 | echo "[ <a href=\"admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=cons_comuni&do=elettori&id_cons_gen=$id_cons_gen&id_cons2=$id_cons2&ok=1\">"._YES."</a> ]";exit;
|
---|
192 | }else{
|
---|
193 | $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);
|
---|
194 | if (!$result) return;
|
---|
195 | Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
|
---|
196 | }
|
---|
197 | }
|
---|
198 | if ($do == "update") {
|
---|
199 | if ($predefinita)
|
---|
200 | $result = mysql_query("update ".$prefix."_ele_comuni set id_cons='$predefinita' WHERE id_comune='$id_comune'", $dbi);
|
---|
201 | else
|
---|
202 | $result = mysql_query("update ".$prefix."_ele_cons_comune set chiusa='$chiusa' WHERE id_cons2='$id_cons2'", $dbi);
|
---|
203 | if (!$result) return;
|
---|
204 | Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
|
---|
205 | }
|
---|
206 | }
|
---|
207 | }
|
---|
208 |
|
---|
209 | function help_cons()
|
---|
210 | {
|
---|
211 | //da mettere
|
---|
212 | }
|
---|
213 |
|
---|
214 | if ($do) {
|
---|
215 | cons_comuni($ok, $id_cons2,$do, $duplica, $elettori);
|
---|
216 | }
|
---|
217 | ele();
|
---|
218 | //OpenTable();
|
---|
219 | all();
|
---|
220 | CloseTable();
|
---|
221 | include("footer.php");
|
---|
222 | ?>
|
---|
223 |
|
---|