source: trunk/admin/modules/Elezioni/ele_affluenze.php@ 252

Last change on this file since 252 was 53, checked in by roby, 15 years ago

continua menu contestuale - correzione per visualizzazione grafici affluenze per referendum

File size: 8.1 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 Affluenze */
9/* Amministrazione */
10/************************************************************************/
11
12
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$currentlang=$_SESSION['lang'];
21$id_cons_gen=$_GET['id_cons_gen'];
22$perms=ChiSei(0);
23if ($perms<256 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
24$res = mysql_query("SELECT t1.tipo_cons,t2.genere,t1.descrizione FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_tipo as t2 where t1.tipo_cons=t2.tipo_cons and t1.id_cons_gen='$id_cons_gen' " , $dbi);
25list($tipo_cons,$genere,$descr_cons) = mysql_fetch_row($res);
26if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0;
27if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
28if (isset($_GET['ov'])) $ov=intval($_GET['ov']); else $ov='';
29if (isset($_GET['mv'])) $mv=intval($_GET['mv']); else $mv='';
30if (isset($_GET['gv'])) $gv=intval($_GET['gv']); else $gv='';
31if (isset($_GET['msv'])) $msv=intval($_GET['msv']); else $msv='';
32if (isset($_GET['av'])) $av=intval($_GET['av']); else $av='';
33if (isset($_GET['tipo'])) get_magic_quotes_gpc() ? $tipo=$param['tipo']:$tipo=addslashes($param['tipo']); else $tipo='';
34if (isset($_GET['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
35if (isset($_GET['modello'])) get_magic_quotes_gpc() ? $modello=$param['modello']:$modello=addslashes($param['modello']); else $modello='';
36if (isset($_GET['help'])) $help=intval($_GET['help']);
37
38include("modules/Elezioni/funzionidata.php");
39include("modules/Elezioni/ele.php");
40$offset=15;
41$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
42
43
44
45
46 /******************************************************/
47 /*Funzione di visualizzazione globale */
48 /*****************************************************/
49 //crea la pagina delle affluenze
50 function all() {
51 global $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min,$id_cons_gen,$language,$help;
52
53 if (isset($help)) include("language/$language/ele_affluenze.html");
54
55 echo "<hr><br><br> <table border=\"0\" width=\"60%\" align=\"center\">"
56 ."<tr><td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ORA."</b></td>"
57 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DATA."</b></td>";
58# echo "<td bgcolor=\"$bgcolor1\">&nbsp;</td>";
59 echo "<td bgcolor=\"$bgcolor1\">&nbsp;</td></tr>";
60 $res = mysql_query("SELECT * FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario", $dbi);
61 $max = mysql_num_rows($res);
62
63 echo "<form name=\"rilaff\" action=\"admin.php\">"
64 ."<input type=\"hidden\" name=\"op\" value=\"rec_add_aff\">"
65 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
66 ."<input type=\"hidden\" name=\"do\" value=1>";
67 echo "<tr align=\"center\"><td>";
68 echo "<select name= \"ov\" ><option value=\"11\" selected>11</option>"; ore();
69 echo "<select name= \"mv\" ><option value=\"00\" selected>00</option>"; minuti();
70 echo "</td><td>";
71 $aff = mysql_query("SELECT data_inizio,data_fine FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'", $dbi);
72 list($data,$fine) = mysql_fetch_row($aff);
73 list ($anno,$mese,$giorno)=explode('-',$data);
74 list ($annof,$mesef,$giornof)=explode('-',$fine);
75 echo "<select name= \"gv\" ><option value=\"$giorno\" selected>$giorno</option>"; giorno($giorno,$giornof);
76 echo "<select name= \"msv\" ><option value=\"$mese\" selected>$mese</option>"; mese();
77 echo "<select name= \"av\" ><option value=\"$anno\" selected>$anno</option>"; anno() ;
78 echo "</td>";
79
80 echo "<td><input type=\"hidden\" name=\"tipo\" value=\"add\">"
81 ."<input type=\"submit\" name=\"update\" value=\""._ADD."\"></td></tr>";
82
83 echo "</form><tr><td bgcolor=\"$bgcolor1\" colspan=\"3\">&nbsp;</td></tr>";
84 if ($max != "0") {
85 $i=1;
86 while(list($id_cons2,$orario,$data) = mysql_fetch_row($res)){
87 // esplode la data
88 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
89 list($av1,$msv1,$gv1) = explode("-",$data);
90 list($ov1,$mv1,$sv1) = explode(":",$orario);
91 $i++;
92
93 echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
94 echo "<td><b>$ov1,$mv1</b></td>";
95 echo "<td><b>$gv1-$msv1-$av1</b></td>";
96 echo "<td><form name=\"canc$i\" action=\"admin.php\">"
97 ."<input type=\"hidden\" name=\"op\" value=\"rec_add_aff\">";
98 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
99 ."<input type=\"hidden\" name=\"do\" value=2>";
100 echo "<input type=\"hidden\" name=\"ov\" value=\"$ov1\">"
101 ."<input type=\"hidden\" name=\"mv\" value=\"$mv1\">"
102 ."<input type=\"hidden\" name=\"gv\" value=\"$gv1\">"
103 ."<input type=\"hidden\" name=\"msv\" value=\"$msv1\">"
104 ."<input type=\"hidden\" name=\"av\" value=\"$av1\">"
105 ."<input type=\"hidden\" name=\"tipo\" value=\"delete\">"
106 ."<input type=\"hidden\" name=\"ok\" value=0>"
107 ."<input type=\"submit\" name=\"erase$i\" value=\""._DELETE."\"></form></td>"
108 ."</tr>";
109 }
110 }
111 echo "</table>";
112 }
113
114 // memorizza le affluenze
115 function rec_add_aff($do,$ov,$mv,$gv,$msv,$av,$tipo,$ok, $modello) {
116 global $prefix, $dbi,$id_cons_gen;
117 $perms=ChiSei(0);
118 if ($perms<256) die("Non hai i permessi per eseguire questa operazione!");
119 $data="$av-$msv-$gv";
120 $orario="$ov:$mv:00";
121 $confr = mysql_query("SELECT data_inizio, data_fine FROM ".$prefix."_ele_consultazione WHERE id_cons_gen ='$id_cons_gen'", $dbi);
122list($dadata, $adata) = mysql_fetch_row($confr);
123$dadata=strtotime($dadata);
124$adata=strtotime($adata);
125$cdata=strtotime($data);
126 // verifica se data e ora esiste e fa l'upgrade
127 $res = mysql_query("select * from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' and data='$data' and orario='$orario'", $dbi);
128 $tipo= mysql_num_rows($res);
129 if(($tipo==0) and ($dadata <= $cdata) and ($adata >= $cdata)){
130 if(checkdate(intval($msv),intval($gv),intval($av))){
131 $result = mysql_query("insert into ".$prefix."_ele_rilaff values ('$id_cons_gen','$orario','$data')", $dbi)|| die("Impossibile inserire i dati! ".mysql_error());
132 }
133 Header("Location: admin.php?op=rec_add_aff&id_cons_gen=$id_cons_gen");
134 } elseif ($do==2) {
135 if ($ok !="1") {
136 ele();
137 OpenTable();
138 echo "<center><br><br>"._DOMCANCELLA." ?<br>";
139 echo "[ <a href=\"admin.php?op=rec_add_aff&amp;id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=rec_add_aff&amp;id_cons_gen=$id_cons_gen&amp;do=$do&amp;ops=1&amp;ov=$ov&amp;mv=$mv&amp;gv=$gv&amp;msv=$msv&amp;av=$av&amp;tipo=delete&amp;ok=1\">"._YES."</a> ]";
140 CloseTable();
141 include("footer.php");
142 die();
143 }else{
144 $res = mysql_query("select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen'", $dbi);
145 while (list($id_cons2) = mysql_fetch_row($res))
146 mysql_query("delete from ".$prefix."_ele_voti_parziale where id_cons='$id_cons2' and data='$data' and orario='$orario'", $dbi)|| die("Impossibile cancellare i dati! ".mysql_error());
147 mysql_query("delete from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' and data='$data' and orario='$orario'", $dbi)|| die("Impossibile cancellare i dati! ".mysql_error());
148 Header("Location: admin.php?op=rec_add_aff&id_cons_gen=$id_cons_gen&contr=$data");
149 }
150 }else{
151 Header("Location: admin.php?op=rec_add_aff&id_cons_gen=$id_cons_gen&contr=$data");
152 }
153 }
154
155
156
157 if($do) rec_add_aff($do,$ov,$mv,$gv,$msv,$av,$tipo,$ok, $modello);
158 ele();
159 OpenTable();
160 all();
161 CloseTable();
162 include("footer.php");
163
164
165
166
167?>
168
Note: See TracBrowser for help on using the repository browser.