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

Last change on this file since 424 was 424, checked in by roby, 5 months ago
  • ADMIN

-- Inserito il file admin/variabili.php che contiene le variabili per personalizzare il software
-- Nuovo sistema di backup, permette di avere una installazione di produzione ed una che può essere facilmente aggiornata con i dati della prima
-- Modificato il file dei controlli
-- Modificata la scheda Tabella dei totali

  • CLIENT

-- Inserito il file client/variabili.php che contiene le variabili per personalizzare il software
-- Modificata per compatibilità con alcune installazioni la funzione di assegnazione dei seggi
-- Modificato il colore dei link per il tema -altro-

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