[2] | 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 |
|
---|
[255] | 17 | global $dbi;
|
---|
[2] | 18 | $aid=$_SESSION['aid'];
|
---|
[255] | 19 | #$dbi=$_SESSION['dbi'];
|
---|
[2] | 20 | $prefix=$_SESSION['prefix'];
|
---|
[344] | 21 | $language=$_SESSION['lang'];
|
---|
[2] | 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!");
|
---|
[255] | 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 |
|
---|
[2] | 31 | if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0;
|
---|
[344] | 32 | if (isset($_GET['do'])) $do=addslashes($param['do']); else $do='';
|
---|
[2] | 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='';
|
---|
[344] | 38 | if (isset($_GET['tipo'])) $tipo=addslashes($param['tipo']); else $tipo='';
|
---|
| 39 | if (isset($_GET['ok'])) $ok=addslashes($param['ok']); else $ok='';
|
---|
| 40 | if (isset($_GET['modello'])) $modello=addslashes($param['modello']); else $modello='';
|
---|
[45] | 41 | if (isset($_GET['help'])) $help=intval($_GET['help']);
|
---|
[2] | 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() {
|
---|
[45] | 54 | global $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min,$id_cons_gen,$language,$help;
|
---|
[2] | 55 |
|
---|
[45] | 56 | if (isset($help)) include("language/$language/ele_affluenze.html");
|
---|
[2] | 57 |
|
---|
[53] | 58 | echo "<hr><br><br> <table border=\"0\" width=\"60%\" align=\"center\">"
|
---|
[2] | 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>";
|
---|
[255] | 63 | $row=getaffluenze();
|
---|
| 64 | $max = count($row);
|
---|
[2] | 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>";
|
---|
[255] | 73 | $aff = daticonsultazione();
|
---|
| 74 | $data=$aff['data_inizio'];$fine=$aff['data_fine'];
|
---|
[2] | 75 | list ($anno,$mese,$giorno)=explode('-',$data);
|
---|
[36] | 76 | list ($annof,$mesef,$giornof)=explode('-',$fine);
|
---|
| 77 | echo "<select name= \"gv\" ><option value=\"$giorno\" selected>$giorno</option>"; giorno($giorno,$giornof);
|
---|
[2] | 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;
|
---|
[255] | 88 | foreach($row as $aff)
|
---|
| 89 | {
|
---|
| 90 | $id_cons2=$aff[0];
|
---|
| 91 | $orario=$aff[1];
|
---|
| 92 | $data=$aff[2];
|
---|
[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 | }
|
---|
[255] | 116 | }
|
---|
[2] | 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";
|
---|
[255] | 127 | $row = daticonsultazione();
|
---|
[336] | 128 | $dadata=$row['data_inizio']; $adata=$row['data_fine'];
|
---|
| 129 | $dadata=strtotime($dadata);
|
---|
| 130 | $adata=strtotime($adata);
|
---|
| 131 | $cdata=strtotime($data);
|
---|
[2] | 132 | // verifica se data e ora esiste e fa l'upgrade
|
---|
[255] | 133 | $sql = "select * from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' and data='$data' and orario='$orario'";
|
---|
| 134 | $sth = $dbi->prepare("$sql");
|
---|
| 135 | $sth->execute();
|
---|
| 136 | $tipo= $sth->rowCount();
|
---|
[2] | 137 | if(($tipo==0) and ($dadata <= $cdata) and ($adata >= $cdata)){
|
---|
| 138 | if(checkdate(intval($msv),intval($gv),intval($av))){
|
---|
[255] | 139 | $sql="insert into ".$prefix."_ele_rilaff values ('$id_cons_gen','$orario','$data')";
|
---|
| 140 | $sth = $dbi->prepare("$sql");
|
---|
| 141 | $sth->execute();
|
---|
[2] | 142 | }
|
---|
| 143 | Header("Location: admin.php?op=rec_add_aff&id_cons_gen=$id_cons_gen");
|
---|
| 144 | } elseif ($do==2) {
|
---|
| 145 | if ($ok !="1") {
|
---|
| 146 | ele();
|
---|
| 147 | OpenTable();
|
---|
| 148 | echo "<center><br><br>"._DOMCANCELLA." ?<br>";
|
---|
| 149 | 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> ]";
|
---|
| 150 | CloseTable();
|
---|
| 151 | include("footer.php");
|
---|
| 152 | die();
|
---|
| 153 | }else{
|
---|
[255] | 154 | $sql = "select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen'";
|
---|
| 155 | $sth = $dbi->prepare("$sql");
|
---|
| 156 | $sth->execute();
|
---|
| 157 | $row2 = $sth->fetchAll();
|
---|
| 158 | foreach($row2 as $id_cons2) {
|
---|
| 159 | $sql = "delete from ".$prefix."_ele_voti_parziale where id_cons='$id_cons2' and data='$data' and orario='$orario'";
|
---|
| 160 | $sth = $dbi->prepare("$sql");
|
---|
| 161 | $sth->execute();
|
---|
| 162 | }
|
---|
| 163 | $sql = "delete from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' and data='$data' and orario='$orario'";
|
---|
| 164 | $sth = $dbi->prepare("$sql");
|
---|
| 165 | $sth->execute();
|
---|
[2] | 166 | Header("Location: admin.php?op=rec_add_aff&id_cons_gen=$id_cons_gen&contr=$data");
|
---|
| 167 | }
|
---|
| 168 | }else{
|
---|
| 169 | Header("Location: admin.php?op=rec_add_aff&id_cons_gen=$id_cons_gen&contr=$data");
|
---|
| 170 | }
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | if($do) rec_add_aff($do,$ov,$mv,$gv,$msv,$av,$tipo,$ok, $modello);
|
---|
| 176 | ele();
|
---|
| 177 | OpenTable();
|
---|
| 178 | all();
|
---|
| 179 | CloseTable();
|
---|
| 180 | include("footer.php");
|
---|
| 181 |
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 |
|
---|
| 185 | ?>
|
---|
| 186 |
|
---|