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

Last change on this file since 26 was 2, checked in by root, 15 years ago

importo il progetto

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