source: trunk/admin/modules/Elezioni/ele_associazioni.php@ 54

Last change on this file since 54 was 54, checked in by roby, 14 years ago

continua menu contestuale

File size: 11.2 KB
Line 
1<?php
2
3/************************************************************************/
4/* Eleonline - Raccolta e diffusione dei dati elettorali */
5/* by Roberto Gigli & Luciano Apolito */
6/* http://www.eleonline.it */
7/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
8/************************************************************************/
9/* Modulo Autorizzazione Comuni */
10/* Amministrazione */
11/************************************************************************/
12# e' l'unico file in cui Ú presente un controllo su tipo_cons, per ora va bene così. Per toglierlo va inserito un campo-flag in ele_tipo per indicare se per il tipo di consultazione si dovra' procedere al calcolo dell'assegnazione dei seggi
13if (!defined('ADMIN_FILE')) {
14 die ("You can't access this file directly...");
15}
16
17$aid=$_SESSION['aid'];
18$dbi=$_SESSION['dbi'];
19$prefix=$_SESSION['prefix'];
20$id_comune=$_SESSION['id_comune'];
21$id_cons_gen=intval($_GET['id_cons_gen']);
22$perms=ChiSei(0);
23if ($perms<128 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
24$res = mysql_query("SELECT t1.tipo_cons,t1.descrizione,t2.id_cons,t2.id_conf FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune='$id_comune' " , $dbi);
25list($tipo_cons,$descr_cons,$id_cons,$id_conf) = mysql_fetch_row($res);
26
27$res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
28 list($genere) = mysql_fetch_row($res);
29
30include("modules/Elezioni/funzionidata.php");
31include("modules/Elezioni/ele.php");
32if (isset($_GET['descr_comu'])) get_magic_quotes_gpc() ? $descr_comu=$param['descr_comu']:$descr_comu=addslashes($param['descr_comu']); else $descr_comu='';
33if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
34if (isset($_GET['ok'])) $ok=intval($_GET['ok']); else $ok='';
35if (isset($_GET['id_cons_comu'])) $id_cons_comu=intval($_GET['id_cons_comu']); else $id_cons_comu='';
36if (isset($_GET['id_collegio'])) $id_collegio=intval($_GET['id_collegio']); else $id_collegio='';
37if (isset($_GET['idcomune'])) $idcomune=intval($_GET['idcomune']); else $idcomune='';
38if (isset($_GET['idcomunenew'])) $idcomunenew=intval($_GET['idcomunenew']); else $idcomunenew='';
39if (isset($_GET['chiusa'])) $chiusa=intval($_GET['chiusa']); else $chiusa='';
40if (isset($_GET['id_conf'])) $id_conf=intval($_GET['id_conf']); else $id_conf=0;
41if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0;
42if (isset($_GET['help'])) $help=intval($_GET['help']);
43
44$offset=15;
45$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
46
47
48 /******************************************************/
49 /*Funzione di visualizzazione globale */
50 /*****************************************************/
51 //crea la pagina delle affluenze
52 function all() {
53 global $user, $admin, $bgcolor1, $bgcolor2, $prefix,$descr_cons, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$id_cons_gen,$id_collegio,$idcomune,$chiusa,$id_conf,$tipo_cons,$language,$help;
54$aid=$_SESSION['aid'];
55$dbi=$_SESSION['dbi'];
56$prefix=$_SESSION['prefix'];
57
58 if (isset($help)) include("language/$language/ele_associazioni.html");
59 OpenTable();
60 echo "<hr><br>";
61 $res = mysql_query("SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi);
62 list ($descr_cons) = mysql_fetch_row($res);
63//inserire avviso su mancanza dei permessi
64 echo "<form name=\"model\" action=\"admin.php\">";
65 echo "<table>";
66 echo "<tr align=\"center\"><td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
67# echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
68 echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
69 echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
70 if($tipo_cons==3)
71 echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
72 echo "</tr>";
73 echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
74 echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
75 echo "<tr align=\"center\">";
76 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"><td>$descr_cons</td>";
77# $ressede = mysql_query("SELECT id_collegio, descrizione from ".$prefix."_ele_collegi where id_cons_gen='$id_cons_gen' order by descrizione desc", $dbi);
78# if ($num_coll=mysql_num_rows($ressede)){
79# echo "<td><select name=\"id_collegio\">";
80# while(list($id,$descr_coll)=mysql_fetch_row($ressede)){
81# $sel= ($id == $id_collegio) ? "selected":"";
82# echo "<option value=\"$id\" $sel>$descr_coll";
83# }
84# echo "</select></td>";
85# } else echo "<td></td>";
86 $rescomu = mysql_query("SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc", $dbi);
87 echo "<td><select name=\"idcomunenew\">";
88 echo "<option value=\"0\"> ";
89 while(list($id,$descr_comu)=mysql_fetch_row($rescomu)){
90 $sel= ($id == $idcomune) ? "selected":"";
91 echo "<option value=\"$id\" $sel>$descr_comu";
92 }
93 echo "</select></td>";
94 $selez['0']='';
95 $selez['1']='';
96 $selez['2']='';
97 $selez[$chiusa]="selected";
98 echo "<td><select name=\"chiusa\">";
99 echo "<option value=\"0\" ".$selez[0].">"._ATTIVA;
100 echo "<option value=\"1\" ".$selez[1].">"._CHIUSA;
101 echo "<option value=\"2\" ".$selez[2].">"._NULLA;
102 echo "</select></td>";
103 if($tipo_cons==3){
104 $rescomu = mysql_query("SELECT id_conf, descrizione from ".$prefix."_ele_conf order by descrizione asc", $dbi);
105 echo "<td><select name=\"id_conf\">";
106 echo "<option value=\"0\"> ";
107 while(list($id,$descr_conf)=mysql_fetch_row($rescomu)){
108 $sel='';
109 if ($idcomune and $id == $id_conf) $sel="selected"; elseif ($id==1) $sel="selected";
110 echo "<option value=\"$id\" $sel>$descr_conf";
111 }
112 echo "</select></td>";
113 }
114 unset($sel);
115 echo "<input type=\"hidden\" name=\"ok\" value=0>";
116 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
117 if ($idcomune) {
118 echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
119 echo "<input type=\"hidden\" name=\"idcomune\" value=\"$idcomune\">";
120 echo "<td><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr></form>";
121 }else{
122 echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
123 echo "<td><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr></form>";
124 }
125 $i=0;
126# if ($num_coll>0)
127# $resmod = mysql_query("SELECT t1.id_collegio,t1.id_comune,t2.descrizione as descr,t1.id_cons, t3.descrizione, t4.chiusa,t4.id_conf FROM ".$prefix."_ele_comu_collegi as t1, ".$prefix."_ele_collegi as t2, ".$prefix."_ele_comuni as t3, ".$prefix."_ele_cons_comune as t4 where t1.id_cons_gen='$id_cons_gen' and t1.id_collegio=t2.id_collegio and t1.id_comune=t3.id_comune and t1.id_comune=t4.id_comune and t2.id_cons_gen=t4.id_cons_gen order by t2.descrizione, t3.descrizione", $dbi);
128# else
129 $resmod = mysql_query("SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons_gen='$id_cons_gen' and t1.id_comune=t2.id_comune order by t2.descrizione", $dbi);
130 while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
131 $resconf = mysql_query("SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi);
132 list($descr_conf) = mysql_fetch_row($resconf);
133 $i++;
134 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
135 echo "<form name=\"modello$i\" action=\"admin.php\">"
136 ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
137// echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
138 echo "<input type=\"hidden\" name=\"id_collegio\" value=\"$id_collegio\">";
139 echo "<input type=\"hidden\" name=\"idcomune\" value=\"$id_comune2\">";
140 echo "<input type=\"hidden\" name=\"id_cons_comu\" value=\"$id_cons_comu\">";
141 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
142 echo "<input type=\"hidden\" name=\"desc\" value=\"$descr_cons\">";
143 echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
144 echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
145 echo "<td width=\"32\"><b>$descr_coll</b></td>";
146 echo "<td width=\"32\"><b>$descr_comu</b></td>";
147 $stato['0']=_ATTIVA;
148 $stato['1']=_CHIUSA;
149 $stato['2']=_NULLA;
150 echo "<td width=\"32\"><b>".$stato[$chiusa]."</b></td>";
151 if($tipo_cons==3)
152 echo "<td width=\"32\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
153 echo "<input type=\"hidden\" name=\"ok\" value=0>";
154 echo "</td>";
155 echo "<td><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
156 ."</td></tr></form>";
157 }
158 echo "</table>";
159 CloseTable();
160 }
161
162function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf) {
163 global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew;
164 if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
165 $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
166 $max = mysql_num_rows($rescomu); //esiste autorizzazione?
167 if (!$max){ //se no la inserisce
168 $result = mysql_query("insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf) values ('0','$idcomunenew','$id_cons_gen','$id_conf')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
169 $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
170 }
171 list($id_cons_comu)=mysql_fetch_row($rescomu);
172 if ($do == "update") {
173 if ($idcomunenew>0) $newid=", id_comune = $idcomunenew ";
174 else $newid='';
175 $result = mysql_query("update ".$prefix."_ele_comu_collegi set id_collegio= '$id_collegio' $newid where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi) || die(mysql_error());
176 if (!$result) return;
177 $result = mysql_query("update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi)|| die(mysql_error());
178 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
179 }elseif ($do == "add") {
180 if ($id_collegio)
181 $result = mysql_query("insert into ".$prefix."_ele_comu_collegi (id_collegio,id_cons,id_comune,id_cons_gen) values ('$id_collegio','$id_cons_comu','$idcomunenew','$id_cons_gen')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
182 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
183 }
184 }
185}
186
187
188//****************************
189// switch
190//****************************
191 if ($op=="associazioni"){
192 associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$idcomune,$chiusa,$id_conf);
193 }
194 ele();
195 if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
196 all();
197 include("footer.php");
198
199?>
200
Note: See TracBrowser for help on using the repository browser.