source: trunk/admin/modules/Elezioni/ele.php@ 195

Last change on this file since 195 was 195, checked in by roby, 11 years ago

segue modifiche per nuova gestione fasce

File size: 15.0 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 menu */
9/* Amministrazione */
10/************************************************************************/
11
12if (!defined('ADMIN_FILE')) {
13 die ("You can't access this file directly...");
14}
15if (!ini_get("register_globals")) {
16 $php_ver = phpversion();
17 $php_ver = explode(".", $php_ver);
18 $phpver = "$php_ver[0]$php_ver[1]";
19 if ($phpver >= 41) {
20 $PHP_SELF = $_SERVER['PHP_SELF'];
21 }
22}
23
24$aid=$_SESSION['aid'];
25$dbi=$_SESSION['dbi'];
26$id_comune=$_SESSION['id_comune'];
27$prefix=$_SESSION['prefix'];
28$currentlang=$_SESSION['lang'];
29$bgcolor1=$_SESSION['bgcolor1'];
30$bgcolor2=$_SESSION['bgcolor2'];
31$bgcolor1='#e7e7e7';
32$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
33
34if (!isset($id_cons_gen)) if (isset($param['id_cons_gen'])) $id_cons_gen=$param['id_cons_gen'];else $id_cons_gen='0';
35$perms=ChiSei($id_cons_gen);
36
37##modifica
38if ($perms>128){
39 if (isset($param['id_comune']) && intval($param['id_comune'])>0) {
40 $id_comune=intval($param['id_comune']);
41 $_SESSION['id_comune']=$id_comune;
42 }
43}
44
45if ($id_cons_gen) {
46 if ($id_comune and $perms<256)
47 $sql = "SELECT t1.tipo_cons,t1.descrizione,t2.id_cons_gen FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen'";
48 else
49 $sql = "SELECT t1.tipo_cons,t1.descrizione,t1.id_cons_gen FROM ".$prefix."_ele_consultazione as t1 where t1.id_cons_gen='$id_cons_gen'";
50}else{
51 if($perms>128)
52 $sql = "SELECT tipo_cons,descrizione,id_cons_gen FROM ".$prefix."_ele_consultazione order by data_fine desc limit 0,1 ";
53 else
54 $sql = "SELECT t1.tipo_cons,t1.descrizione,t2.id_cons_gen FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_operatori as t3 where t3.id_comune=$id_comune and t3.id_comune=t2.id_comune and t1.id_cons_gen=t2.id_cons_gen and t2.chiusa='0' and (t3.id_cons=t2.id_cons or t3.id_cons=0) and t3.permessi>0 and t3.aid='$aid' order by t1.data_fine desc limit 0,1 ";
55}
56
57 $res = mysql_query("$sql",$dbi);
58 $espandi=0;
59 if (mysql_num_rows($res))
60 list($tipo_cons,$descr_cons,$id_cons_gen) = mysql_fetch_row($res);
61 $res = mysql_query("SELECT t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'" , $dbi);
62 if (mysql_num_rows($res)) list($id_cons) = mysql_fetch_row($res);
63 else $espandi=1;
64 if(!isset($tipo_cons))$tipo_cons=0;
65 $res = mysql_query("SELECT genere,voto_g,voto_l,voto_c,circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' and lingua='$currentlang'" , $dbi);
66 list($genere,$votog,$votol,$votoc,$conscirc) = mysql_fetch_row($res);
67if (!$perms) $perms=ChiSei($id_cons_gen);
68 //include("modules/Elezioni/language/lang-$currentlang.php");
69 //**************************************************************************
70 // ELE
71 //**************************************************************************
72 if(!isset($id_cons))$id_cons=0;
73
74 $res = mysql_query("SELECT t1.limite FROM ".$prefix."_ele_conf as t1 left join ".$prefix."_ele_cons_comune as t2 on t1.id_conf=t2.id_conf where t2.id_cons='$id_cons'" , $dbi);
75 list($limite) = mysql_fetch_row($res);
76
77function ele() {
78
79 global $espandi, $aid, $bgcolor1, $bgcolor2,$bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons, $id_cons_gen,$tipo_cons,$genere,$op,$id_comune,$perms,$id_cons,$votog,$votol,$votoc,$votocirc,$tema,$fascia;
80
81 include ("header.php");
82 //immagine bullet
83 $bullet="<img src=\"temi/$tema/images/bullet.gif\" alt =\" \" align=\"left\" border=\"0\">";
84 $bgcolor1='#e7e7e7';
85 $sqlcomu="select descrizione from ".$prefix."_ele_comuni where id_comune='$id_comune'";
86 $res = mysql_query($sqlcomu);
87 list($descr_comu)=mysql_fetch_row($res);
88 $sqlcomu="select fascia from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
89 $res = mysql_query($sqlcomu);
90 list($fascia)=mysql_fetch_row($res);
91
92 $otable= "<table bgcolor=\"$bgcolor1\" width=\"100%\" cellpadding=\"0\" cellspacing=\"2\" BORDER=\"0\">\n <tr><td>&nbsp;&nbsp;&nbsp;</td><td valign=\"top\" align=\"left\">";
93 $otable1= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"2\" BORDER=\"0\">\n <tr><td valign=\"top\" width=\"180\">";
94 $ctable= "</td></tr></table>";
95$currentlang=$_SESSION['lang'];
96
97
98
99 echo "<form name=\"scelta\" action=\"admin.php\">";
100 echo $otable;
101 echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?id_cons_gen=\">";
102 echo "<input type=\"hidden\" name=\"op\" value=\"ele\">";
103
104 if ($perms<128) {
105 $res = mysql_query("select t3.id_cons, t2.descrizione,t4.genere, t2.id_cons_gen, t3.chiusa from ".$prefix."_ele_operatori as t1, ".$prefix."_ele_consultazione as t2, ".$prefix."_ele_cons_comune as t3, ".$prefix."_ele_tipo as t4 where t4.lingua='$currentlang' and t2.tipo_cons=t4.tipo_cons and t1.aid='$aid' and t3.id_cons_gen=t2.id_cons_gen and (t1.id_cons=t3.id_cons or t1.permessi=64) and t1.id_comune=t3.id_comune and t1.id_comune=$id_comune and t3.chiusa='0' order by t2.data_inizio desc", $dbi);
106 }else{
107 $res = mysql_query("SELECT '', t1.descrizione,t2.genere, t1.id_cons_gen,'' FROM ".$prefix."_ele_consultazione as t1,".$prefix."_ele_tipo as t2 where t2.lingua='$currentlang' and t1.tipo_cons=t2.tipo_cons order by t1.data_inizio desc", $dbi);
108 $sqlcomu="select id_comune,descrizione from ".$prefix."_ele_comuni order by descrizione asc";
109 }
110 echo "<font size=-1><b>"._SCELTA_CONS.":</b> </font><select name=\"id_cons_gen\" onChange=\"top.location.href=this.form.pag_cons.value+this.form.id_cons_gen.options[this.form.id_cons_gen.selectedIndex].value;return false\">";
111 while(list($id,$descrizione,$gen2,$idgen,$chiusa) = mysql_fetch_row($res)) {
112 if (($chiusa==0) OR ($perms>32)) {
113 if (($idgen==$id_cons_gen or !$id_cons_gen)) {
114 $sel = "selected";
115 $genere=$gen2;
116 $id_cons_gen=$idgen;
117 } else {
118 $sel = "";
119 }
120 echo "<option value=\"$idgen\" $sel>$descrizione";
121 }
122 }
123 echo "</select>";
124 // controllo delle opzioni utilizzabili: sono quelle che hanno genitori in quella precedente
125 // esempio si possono inserire i candidati solo se prima sono state inserite le liste
126 $resq = mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons", $dbi);
127 if ($resq) list($nrcirco)=mysql_fetch_row($resq); else $nrcirco=0;
128 $resq = mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons=$id_cons", $dbi);
129 if ($resq) list($nrsede)=mysql_fetch_row($resq); else $nrsede=0;
130 $resq = mysql_query("select count(0) from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
131 if ($resq) list($nrgruppo)=mysql_fetch_row($resq); else $nrgruppo=0;
132 $resq = mysql_query("select count(0) from ".$prefix."_ele_lista where id_cons=$id_cons", $dbi);
133 if ($resq) list($nrlista)=mysql_fetch_row($resq); else $nrlista=0;
134 $resq = mysql_query("SELECT sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons", $dbi);
135 if ($resq) list($nraff)=mysql_fetch_row($resq); else $nraff=0;
136 if ($genere==0) $tmpval='voti_ref'; else $tmpval='sezioni';
137 $resq = mysql_query("SELECT sum(validi) from ".$prefix."_ele_$tmpval where id_cons=$id_cons", $dbi);
138 if ($resq) list($nrvoti)=mysql_fetch_row($resq); else $nrvoti=0;
139 unset($resq);
140 if ($perms==256) // il superuser puo' scegliere il comune su cui lavorare
141 {
142 $rescomu= mysql_query("$sqlcomu",$dbi);
143 echo "<select name=\"id_comune\" onChange=\"top.location.href=this.form.pag_cons.value+$id_cons_gen+'&amp;id_comune='+this.form.id_comune.options[this.form.id_comune.selectedIndex].value;return false\"><option value=\"\">";
144 while (list($id,$descrizione)=mysql_fetch_row($rescomu))
145 {
146 $sel=($id == $id_comune) ? "selected":"";
147 echo "<option value=\"$id\" $sel>$descrizione";
148 }
149 }
150 echo "</select>";
151 echo $ctable;
152 echo "</form>";
153
154
155 echo "<br>";
156
157 echo $otable1;
158 echo "<table width=\"180\" align=\"left\"><tr><td><table>";
159 echo "<tr align=\"left\" bgcolor=\"$bgcolor1\"><td valign=\"top\" align=\"left\" width=\"150\" colspan=\"2\">
160 <a href=\"admin.php?op=$op&amp;id_cons_gen=$id_cons_gen&amp;help=1\">$bullet"._HELP."</a>
161 </td></tr>";
162
163 if ($perms>128) {
164
165
166# <a href=\"admin.php?op=inscollegi&amp;id_cons_gen=$id_cons_gen\">$bullet"._COLLEGI."</a><br>
167
168 echo "
169 <tr align=\"left\" bgcolor=\"$bgcolor1\">
170 <td valign=\"top\" align=\"center\" bgcolor=\"#000000\" rowspan=\"3\"><font face=\"Arial,Helvetica\" size=-1><font color=\"#ffffff\"><b>"._SUPER."
171
172 </b></font></font>
173
174 </td>
175<td valign=\"top\" align=\"left\" width=\"150\">
176
177
178 <a href=\"admin.php?op=configurazione&amp;id_cons_gen=$id_cons_gen\">$bullet"._CONFIGURAZIONE."</a><br>";
179 if($op=="configurazione" || $op=="widget" || $op=="plugin"){
180 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - <a href=\"admin.php?op=widget&amp;id_cons_gen=$id_cons_gen\"> "._WIDGET."</a>";
181 echo "<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - "._PLUGINS."";
182 echo "<hr>";
183 }
184 echo "
185 <a href=\"admin.php?op=constipi&amp;id_cons_gen=$id_cons_gen\">$bullet"._TIPO_ADM."</a><br>
186 <a href=\"admin.php?op=confconsiglio&amp;id_cons_gen=$id_cons_gen\">$bullet"._CONFCONS."</a>
187 </td></tr><tr align=\"left\" bgcolor=\"$bgcolor1\"><td>
188 <a href=\"admin.php?op=inscomuni&amp;id_cons_gen=$id_cons_gen\">$bullet"._DEFCOMUNE."</a><br>
189 <a href=\"admin.php?op=oper_admin&amp;id_cons_gen=$id_cons_gen\">$bullet"._AMMINISTRATORI."</a>
190 </td></tr><tr align=\"left\" bgcolor=\"$bgcolor1\"><td>
191 <a href=\"admin.php?op=consultazione&amp;id_cons_gen=$id_cons_gen\">$bullet"._CONSULTAZIONE_ADM."</a><br>
192
193 <a href=\"admin.php?op=rec_add_aff&amp;id_cons_gen=$id_cons_gen\">$bullet"._AFFLUENZE."</a><br>
194 <a href=\"admin.php?op=associazioni&amp;id_cons_gen=$id_cons_gen\">$bullet"._INSCOMUNE."</a>
195 </td></tr>";
196# <a href=\"admin.php?op=backup&amp;id_cons_gen=$id_cons_gen\">$bullet"._BACKUP."</a><br>
197# <a href=\"admin.php?op=restore&amp;id_cons_gen=$id_cons_gen\">$bullet"._RESTORE."</a>
198
199 }
200// Amministrazione locale solo superuser e adminuser
201 if ($perms>16 and ! $espandi) {
202 echo "
203 <tr bgcolor=\"$bgcolor1\">
204 <td valign=\"top\" align=\"center\" bgcolor=\"#000000\"><font face=\"Arial,Helvetica\" size=-1><font color=\"#ffffff\"><b>"._ADMIN."
205
206 </b></font></font>
207
208 </td>
209 <td valign=\"top\">";
210 if ($perms>32) {
211 echo "<a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$id_cons_gen\">$bullet"._CONSULTAZIONI."</a><br>
212 <a href=\"admin.php?op=scarica&amp;id_cons_gen=$id_cons_gen\">$bullet"._SCARICA."</a><br>";
213# if($nrgruppo==0 and $nrlista==0)
214 echo "<a href=\"admin.php?op=importa&amp;id_cons_gen=$id_cons_gen\">$bullet"._IMPORTA."</a><br>";
215 echo "<a href=\"admin.php?op=operatori&amp;id_cons_gen=$id_cons_gen\">$bullet"._OPERATORI."</a> <br><a href=\"admin.php?op=permessi&amp;id_cons_gen=$id_cons_gen\">$bullet"._PERMESSI."</a> <br>";
216 }
217 echo "<a href=\"admin.php?op=come&amp;vai=come&amp;id_cons_gen=$id_cons_gen\">$bullet "._COME."</a> <br>
218 <a href=\"admin.php?op=numeri&amp;vai=numeri&amp;id_cons_gen=$id_cons_gen\">$bullet "._NUMERI."</a> <br>
219 <a href=\"admin.php?op=servizi&amp;vai=servizi&amp;id_cons_gen=$id_cons_gen\">$bullet "._SERVIZI."</a> <br>
220 <a href=\"admin.php?op=link&amp;vai=link&amp;id_cons_gen=$id_cons_gen\">$bullet "._LINK."</a> <br>
221 <a href=\"admin.php?op=circo&amp;id_cons_gen=$id_cons_gen\">
222
223 $bullet"._CIRCO."</a> <br>";
224 if ($nrcirco){
225 echo "<a href=\"admin.php?op=sede&amp;id_cons_gen=$id_cons_gen\">$bullet "._SEDE."</a> <br>";
226 if ($nrsede){
227 echo "<a href=\"admin.php?op=sezione&amp;id_cons_gen=$id_cons_gen\">$bullet "._SEZIONE."</a><br>";
228 }
229 }
230 if ($genere!=4) { //gestisce gruppi if ($tipo_cons!=8){ $genere!=2 and
231 echo "<a href=\"admin.php?op=gruppo&amp;id_cons_gen=$id_cons_gen\">$bullet "._GRUPPO."</a><br>";
232 }
233
234 if ($genere>2 or $genere==1){ ####prova
235 if ($genere==4 or $nrgruppo){ // or $tipo_cons==10 or $tipo_cons==11){
236 echo "
237 <a href=\"admin.php?op=lista&amp;id_cons_gen=$id_cons_gen\">$bullet "._LISTA."</a> <br>";
238 if ($genere>2){ ####prova
239 if ($nrlista){
240 echo "<a href=\"admin.php?op=candidato&amp;id_cons_gen=$id_cons_gen\">$bullet"._CANDIDATO."</a> <br>";
241 }else{
242 echo "$bullet "._CANDIDATO." ";
243 }
244 }
245 }else{
246 echo "
247 $bullet"._LISTA." <br>";
248 echo "$bullet "._CANDIDATO." <br>";
249
250 }
251
252 }
253
254 echo "</td></tr>";
255 }
256
257
258 //Amministrazione normale operatore
259 echo "<tr bgcolor=\"$bgcolor1\">
260 <td valign=\"top\" align=\"center\" bgcolor=\"#000000\"><font face=\"Arial,Helvetica\" size=-1><font color=\"#ffffff\"><b>"._OPER."
261
262 </b></font></font>
263
264 </td>
265 <td valign=\"top\" width=\"150\">";
266 if ($op!='consultazione' and $perms>0 and $nrcirco and ($nrlista or $nrgruppo)) {
267 echo "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=spoglio\">$bullet "._GEST." "._SPOGLIO."</a><br>";
268 if ($nraff) {
269 echo "<a href=\"admin.php?op=controllo_votanti&amp;id_cons_gen=$id_cons_gen\">$bullet "._STATO." "._AFFLUENZE."</a><br>";
270 }else{
271 echo "<img src=\"modules/Elezioni/images/site.gif\" alt =\" \" align=\"center\" border=\"0\"> "._STATO." "._AFFLUENZE."<br>";
272 }
273 if ($nrvoti) {
274 echo "<a href=\"admin.php?op=controllo_voti&amp;id_cons_gen=$id_cons_gen\">$bullet "._STATO." "._VOTI."</a><br>";
275 }else{
276 echo "<img src=\"modules/Elezioni/images/site.gif\" alt =\" \" align=\"middle\" border=\"0\"> "._STATO." "._VOTI."<br>";
277 }
278 echo "<a href=\"admin.php?op=riepilogo&amp;id_cons_gen=$id_cons_gen\">$bullet "._RIEPILOGO."</a><br>";
279 }
280
281
282 echo "<br><a href=\"admin.php?op=cambiopwd&amp;id_cons_gen=$id_cons_gen\">$bullet"._CAMBIOPWD."</a><br>";
283
284 if (file_exists("../client/modules.php"))
285 echo "<hr><a href=\"../client/modules.php?id_comune=$id_comune&amp;id_cons_gen=$id_cons_gen\" target=\"_blank\">$bullet Guarda il sito</a><br><hr>";
286
287 //echo "<hr /><a href=\"../client/modules.php\" target=\"_blank\">$bullet Guarda il sito</a><br /><hr />";
288 echo "<a href=\"admin.php?op=logout\">$bullet "._ESCI."</a>";
289 echo "</td></tr></table>";
290 // continua la tabella su ele.voti con le sezioni
291 // altrimenti inizia la tabella centrale
292
293 if ($op!="voti")
294 echo "</td></tr></table></td><td valign=\"top\" align=left>";
295
296}
297
298 switch ($op){
299 case "ele":
300 ele();
301 global $language;
302 include("language/$language/ele.html");
303 echo"</td></tr></table>";
304 include("footer.php");
305
306 break;
307
308 }
309
310
311?>
Note: See TracBrowser for help on using the repository browser.