source: trunk/elezioni/trunk/admin/modules/Elezioni/ele_affluenze.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 7.9 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,data_fine FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'", $dbi);
70 list($data,$fine) = mysql_fetch_row($aff);
71 list ($anno,$mese,$giorno)=explode('-',$data);
72 list ($annof,$mesef,$giornof)=explode('-',$fine);
73 echo "<select name= \"gv\" ><option value=\"$giorno\" selected>$giorno</option>"; giorno($giorno,$giornof);
74 echo "<select name= \"msv\" ><option value=\"$mese\" selected>$mese</option>"; mese();
75 echo "<select name= \"av\" ><option value=\"$anno\" selected>$anno</option>"; anno() ;
76 echo "</td>";
77
78 echo "<td><input type=\"hidden\" name=\"tipo\" value=\"add\">"
79 ."<input type=\"submit\" name=\"update\" value=\""._ADD."\"></td></tr>";
80
81 echo "</form><tr><td bgcolor=\"$bgcolor1\" colspan=\"3\">&nbsp;</td></tr>";
82 if ($max != "0") {
83 $i=1;
84 while(list($id_cons2,$orario,$data) = mysql_fetch_row($res)){
85 // esplode la data
86 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
87 list($av1,$msv1,$gv1) = explode("-",$data);
88 list($ov1,$mv1,$sv1) = explode(":",$orario);
89 $i++;
90
91 echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
92 echo "<td><b>$ov1,$mv1</b></td>";
93 echo "<td><b>$gv1-$msv1-$av1</b></td>";
94 echo "<td><form name=\"canc$i\" action=\"admin.php\">"
95 ."<input type=\"hidden\" name=\"op\" value=\"rec_add_aff\">";
96 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
97 ."<input type=\"hidden\" name=\"do\" value=2>";
98 echo "<input type=\"hidden\" name=\"ov\" value=\"$ov1\">"
99 ."<input type=\"hidden\" name=\"mv\" value=\"$mv1\">"
100 ."<input type=\"hidden\" name=\"gv\" value=\"$gv1\">"
101 ."<input type=\"hidden\" name=\"msv\" value=\"$msv1\">"
102 ."<input type=\"hidden\" name=\"av\" value=\"$av1\">"
103 ."<input type=\"hidden\" name=\"tipo\" value=\"delete\">"
104 ."<input type=\"hidden\" name=\"ok\" value=0>"
105 ."<input type=\"submit\" name=\"erase$i\" value=\""._DELETE."\"></form></td>"
106 ."</tr>";
107 }
108 }
109 echo "</table>";
110 }
111
112 // memorizza le affluenze
113 function rec_add_aff($do,$ov,$mv,$gv,$msv,$av,$tipo,$ok, $modello) {
114 global $prefix, $dbi,$id_cons_gen;
115 $perms=ChiSei(0);
116 if ($perms<256) die("Non hai i permessi per eseguire questa operazione!");
117 $data="$av-$msv-$gv";
118 $orario="$ov:$mv:00";
119 $confr = mysql_query("SELECT data_inizio, data_fine FROM ".$prefix."_ele_consultazione WHERE id_cons_gen ='$id_cons_gen'", $dbi);
120list($dadata, $adata) = mysql_fetch_row($confr);
121$dadata=strtotime($dadata);
122$adata=strtotime($adata);
123$cdata=strtotime($data);
124 // verifica se data e ora esiste e fa l'upgrade
125 $res = mysql_query("select * from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' and data='$data' and orario='$orario'", $dbi);
126 $tipo= mysql_num_rows($res);
127 if(($tipo==0) and ($dadata <= $cdata) and ($adata >= $cdata)){
128 if(checkdate(intval($msv),intval($gv),intval($av))){
129 $result = mysql_query("insert into ".$prefix."_ele_rilaff values ('$id_cons_gen','$orario','$data')", $dbi)|| die("Impossibile inserire i dati! ".mysql_error());
130 }
131 Header("Location: admin.php?op=rec_add_aff&id_cons_gen=$id_cons_gen");
132 } elseif ($do==2) {
133 if ($ok !="1") {
134 ele();
135 OpenTable();
136 echo "<center><br><br>"._DOMCANCELLA." ?<br>";
137 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> ]";
138 CloseTable();
139 include("footer.php");
140 die();
141 }else{
142 $res = mysql_query("select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen'", $dbi);
143 while (list($id_cons2) = mysql_fetch_row($res))
144 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());
145 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());
146 Header("Location: admin.php?op=rec_add_aff&id_cons_gen=$id_cons_gen&contr=$data");
147 }
148 }else{
149 Header("Location: admin.php?op=rec_add_aff&id_cons_gen=$id_cons_gen&contr=$data");
150 }
151 }
152
153
154
155 if($do) rec_add_aff($do,$ov,$mv,$gv,$msv,$av,$tipo,$ok, $modello);
156 ele();
157 OpenTable();
158 all();
159 CloseTable();
160 include("footer.php");
161
162
163
164
165?>
166
Note: See TracBrowser for help on using the repository browser.