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

Last change on this file since 219 was 196, checked in by roby, 11 years ago
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 if ($res)
91 list($fascia)=mysql_fetch_row($res);
92 else
93 $fascia=0;
94 $otable= "<table bgcolor=\"$bgcolor1\" width=\"100%\" cellpadding=\"0\" cellspacing=\"2\" BORDER=\"0\">\n <tr><td>&nbsp;&nbsp;&nbsp;</td><td valign=\"top\" align=\"left\">";
95 $otable1= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"2\" BORDER=\"0\">\n <tr><td valign=\"top\" width=\"180\">";
96 $ctable= "</td></tr></table>";
97$currentlang=$_SESSION['lang'];
98
99
100
101 echo "<form name=\"scelta\" action=\"admin.php\">";
102 echo $otable;
103 echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?id_cons_gen=\">";
104 echo "<input type=\"hidden\" name=\"op\" value=\"ele\">";
105
106 if ($perms<128) {
107 $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);
108 }else{
109 $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);
110 $sqlcomu="select id_comune,descrizione from ".$prefix."_ele_comuni order by descrizione asc";
111 }
112 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\">";
113 while(list($id,$descrizione,$gen2,$idgen,$chiusa) = mysql_fetch_row($res)) {
114 if (($chiusa==0) OR ($perms>32)) {
115 if (($idgen==$id_cons_gen or !$id_cons_gen)) {
116 $sel = "selected";
117 $genere=$gen2;
118 $id_cons_gen=$idgen;
119 } else {
120 $sel = "";
121 }
122 echo "<option value=\"$idgen\" $sel>$descrizione";
123 }
124 }
125 echo "</select>";
126 // controllo delle opzioni utilizzabili: sono quelle che hanno genitori in quella precedente
127 // esempio si possono inserire i candidati solo se prima sono state inserite le liste
128 $resq = mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons", $dbi);
129 if ($resq) list($nrcirco)=mysql_fetch_row($resq); else $nrcirco=0;
130 $resq = mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons=$id_cons", $dbi);
131 if ($resq) list($nrsede)=mysql_fetch_row($resq); else $nrsede=0;
132 $resq = mysql_query("select count(0) from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
133 if ($resq) list($nrgruppo)=mysql_fetch_row($resq); else $nrgruppo=0;
134 $resq = mysql_query("select count(0) from ".$prefix."_ele_lista where id_cons=$id_cons", $dbi);
135 if ($resq) list($nrlista)=mysql_fetch_row($resq); else $nrlista=0;
136 $resq = mysql_query("SELECT sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons", $dbi);
137 if ($resq) list($nraff)=mysql_fetch_row($resq); else $nraff=0;
138 if ($genere==0) $tmpval='voti_ref'; else $tmpval='sezioni';
139 $resq = mysql_query("SELECT sum(validi) from ".$prefix."_ele_$tmpval where id_cons=$id_cons", $dbi);
140 if ($resq) list($nrvoti)=mysql_fetch_row($resq); else $nrvoti=0;
141 unset($resq);
142 if ($perms==256) // il superuser puo' scegliere il comune su cui lavorare
143 {
144 $rescomu= mysql_query("$sqlcomu",$dbi);
145 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=\"\">";
146 while (list($id,$descrizione)=mysql_fetch_row($rescomu))
147 {
148 $sel=($id == $id_comune) ? "selected":"";
149 echo "<option value=\"$id\" $sel>$descrizione";
150 }
151 }
152 echo "</select>";
153 echo $ctable;
154 echo "</form>";
155
156
157 echo "<br>";
158
159 echo $otable1;
160 echo "<table width=\"180\" align=\"left\"><tr><td><table>";
161 echo "<tr align=\"left\" bgcolor=\"$bgcolor1\"><td valign=\"top\" align=\"left\" width=\"150\" colspan=\"2\">
162 <a href=\"admin.php?op=$op&amp;id_cons_gen=$id_cons_gen&amp;help=1\">$bullet"._HELP."</a>
163 </td></tr>";
164
165 if ($perms>128) {
166
167
168# <a href=\"admin.php?op=inscollegi&amp;id_cons_gen=$id_cons_gen\">$bullet"._COLLEGI."</a><br>
169
170 echo "
171 <tr align=\"left\" bgcolor=\"$bgcolor1\">
172 <td valign=\"top\" align=\"center\" bgcolor=\"#000000\" rowspan=\"3\"><font face=\"Arial,Helvetica\" size=-1><font color=\"#ffffff\"><b>"._SUPER."
173
174 </b></font></font>
175
176 </td>
177<td valign=\"top\" align=\"left\" width=\"150\">
178
179
180 <a href=\"admin.php?op=configurazione&amp;id_cons_gen=$id_cons_gen\">$bullet"._CONFIGURAZIONE."</a><br>";
181 if($op=="configurazione" || $op=="widget" || $op=="plugin"){
182 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - <a href=\"admin.php?op=widget&amp;id_cons_gen=$id_cons_gen\"> "._WIDGET."</a>";
183 echo "<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - "._PLUGINS."";
184 echo "<hr>";
185 }
186 echo "
187 <a href=\"admin.php?op=constipi&amp;id_cons_gen=$id_cons_gen\">$bullet"._TIPO_ADM."</a><br>
188 <a href=\"admin.php?op=confconsiglio&amp;id_cons_gen=$id_cons_gen\">$bullet"._CONFCONS."</a>
189 </td></tr><tr align=\"left\" bgcolor=\"$bgcolor1\"><td>
190 <a href=\"admin.php?op=inscomuni&amp;id_cons_gen=$id_cons_gen\">$bullet"._DEFCOMUNE."</a><br>
191 <a href=\"admin.php?op=oper_admin&amp;id_cons_gen=$id_cons_gen\">$bullet"._AMMINISTRATORI."</a>
192 </td></tr><tr align=\"left\" bgcolor=\"$bgcolor1\"><td>
193 <a href=\"admin.php?op=consultazione&amp;id_cons_gen=$id_cons_gen\">$bullet"._CONSULTAZIONE_ADM."</a><br>
194
195 <a href=\"admin.php?op=rec_add_aff&amp;id_cons_gen=$id_cons_gen\">$bullet"._AFFLUENZE."</a><br>
196 <a href=\"admin.php?op=associazioni&amp;id_cons_gen=$id_cons_gen\">$bullet"._INSCOMUNE."</a>
197 </td></tr>";
198# <a href=\"admin.php?op=backup&amp;id_cons_gen=$id_cons_gen\">$bullet"._BACKUP."</a><br>
199# <a href=\"admin.php?op=restore&amp;id_cons_gen=$id_cons_gen\">$bullet"._RESTORE."</a>
200
201 }
202// Amministrazione locale solo superuser e adminuser
203 if ($perms>16 and ! $espandi) {
204 echo "
205 <tr bgcolor=\"$bgcolor1\">
206 <td valign=\"top\" align=\"center\" bgcolor=\"#000000\"><font face=\"Arial,Helvetica\" size=-1><font color=\"#ffffff\"><b>"._ADMIN."
207
208 </b></font></font>
209
210 </td>
211 <td valign=\"top\">";
212 if ($perms>32) {
213 echo "<a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$id_cons_gen\">$bullet"._CONSULTAZIONI."</a><br>
214 <a href=\"admin.php?op=scarica&amp;id_cons_gen=$id_cons_gen\">$bullet"._SCARICA."</a><br>";
215# if($nrgruppo==0 and $nrlista==0)
216 echo "<a href=\"admin.php?op=importa&amp;id_cons_gen=$id_cons_gen\">$bullet"._IMPORTA."</a><br>";
217 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>";
218 }
219 echo "<a href=\"admin.php?op=come&amp;vai=come&amp;id_cons_gen=$id_cons_gen\">$bullet "._COME."</a> <br>
220 <a href=\"admin.php?op=numeri&amp;vai=numeri&amp;id_cons_gen=$id_cons_gen\">$bullet "._NUMERI."</a> <br>
221 <a href=\"admin.php?op=servizi&amp;vai=servizi&amp;id_cons_gen=$id_cons_gen\">$bullet "._SERVIZI."</a> <br>
222 <a href=\"admin.php?op=link&amp;vai=link&amp;id_cons_gen=$id_cons_gen\">$bullet "._LINK."</a> <br>
223 <a href=\"admin.php?op=circo&amp;id_cons_gen=$id_cons_gen\">
224
225 $bullet"._CIRCO."</a> <br>";
226 if ($nrcirco){
227 echo "<a href=\"admin.php?op=sede&amp;id_cons_gen=$id_cons_gen\">$bullet "._SEDE."</a> <br>";
228 if ($nrsede){
229 echo "<a href=\"admin.php?op=sezione&amp;id_cons_gen=$id_cons_gen\">$bullet "._SEZIONE."</a><br>";
230 }
231 }
232 if ($genere!=4) { //gestisce gruppi if ($tipo_cons!=8){ $genere!=2 and
233 echo "<a href=\"admin.php?op=gruppo&amp;id_cons_gen=$id_cons_gen\">$bullet "._GRUPPO."</a><br>";
234 }
235
236 if ($genere>2 or $genere==1){ ####prova
237 if ($genere==4 or $nrgruppo){ // or $tipo_cons==10 or $tipo_cons==11){
238 echo "
239 <a href=\"admin.php?op=lista&amp;id_cons_gen=$id_cons_gen\">$bullet "._LISTA."</a> <br>";
240 if ($genere>2){ ####prova
241 if ($nrlista){
242 echo "<a href=\"admin.php?op=candidato&amp;id_cons_gen=$id_cons_gen\">$bullet"._CANDIDATO."</a> <br>";
243 }else{
244 echo "$bullet "._CANDIDATO." ";
245 }
246 }
247 }else{
248 echo "
249 $bullet"._LISTA." <br>";
250 echo "$bullet "._CANDIDATO." <br>";
251
252 }
253
254 }
255
256 echo "</td></tr>";
257 }
258
259
260 //Amministrazione normale operatore
261 echo "<tr bgcolor=\"$bgcolor1\">
262 <td valign=\"top\" align=\"center\" bgcolor=\"#000000\"><font face=\"Arial,Helvetica\" size=-1><font color=\"#ffffff\"><b>"._OPER."
263
264 </b></font></font>
265
266 </td>
267 <td valign=\"top\" width=\"150\">";
268 if ($op!='consultazione' and $perms>0 and $nrcirco and ($nrlista or $nrgruppo)) {
269 echo "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=spoglio\">$bullet "._GEST." "._SPOGLIO."</a><br>";
270 if ($nraff) {
271 echo "<a href=\"admin.php?op=controllo_votanti&amp;id_cons_gen=$id_cons_gen\">$bullet "._STATO." "._AFFLUENZE."</a><br>";
272 }else{
273 echo "<img src=\"modules/Elezioni/images/site.gif\" alt =\" \" align=\"center\" border=\"0\"> "._STATO." "._AFFLUENZE."<br>";
274 }
275 if ($nrvoti) {
276 echo "<a href=\"admin.php?op=controllo_voti&amp;id_cons_gen=$id_cons_gen\">$bullet "._STATO." "._VOTI."</a><br>";
277 }else{
278 echo "<img src=\"modules/Elezioni/images/site.gif\" alt =\" \" align=\"middle\" border=\"0\"> "._STATO." "._VOTI."<br>";
279 }
280 echo "<a href=\"admin.php?op=riepilogo&amp;id_cons_gen=$id_cons_gen\">$bullet "._RIEPILOGO."</a><br>";
281 }
282
283
284 echo "<br><a href=\"admin.php?op=cambiopwd&amp;id_cons_gen=$id_cons_gen\">$bullet"._CAMBIOPWD."</a><br>";
285
286 if (file_exists("../client/modules.php"))
287 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>";
288
289 //echo "<hr /><a href=\"../client/modules.php\" target=\"_blank\">$bullet Guarda il sito</a><br /><hr />";
290 echo "<a href=\"admin.php?op=logout\">$bullet "._ESCI."</a>";
291 echo "</td></tr></table>";
292 // continua la tabella su ele.voti con le sezioni
293 // altrimenti inizia la tabella centrale
294
295 if ($op!="voti")
296 echo "</td></tr></table></td><td valign=\"top\" align=left>";
297
298}
299
300 switch ($op){
301 case "ele":
302 ele();
303 global $language;
304 include("language/$language/ele.html");
305 echo"</td></tr></table>";
306 include("footer.php");
307
308 break;
309
310 }
311
312
313?>
Note: See TracBrowser for help on using the repository browser.