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