source: trunk/admin/modules/Elezioni/salva_voti.php@ 382

Last change on this file since 382 was 352, checked in by roby, 3 years ago

Segue adattamento per php7
modifica gestione consultazioni con e senza voto nullo di lista

File size: 4.6 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/************************************************************************/
5/* Modulo salva affluenze */
6/* Amministrazione */
7/************************************************************************/
8session_name('sesadmin');
9 // gestione sessione
10$a = session_id();
11if(empty($a)) session_start();
12if(!$_SESSION['aid'])
13 die ("You can't access this file directly...");
14$aid=$_SESSION['aid'];
15include("../../config.php");
16 try{
17 $dbi = new PDO("mysql:host=$dbhost;charset=latin1", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
18 $sql = "use $dbname";
19 $dbi->exec($sql);
20 }
21 catch(PDOException $e)
22 {
23 echo $sql . "<br>" . $e->getMessage();
24 }
25
26if (isset($_GET['genere'])) $genere=intval($_GET['genere']); else $genere='';
27if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='';
28if (isset($_GET['id_cons'])) $id_cons=intval($_GET['id_cons']); else $id_cons='';
29if (isset($_GET['op'])) $op=intval($_GET['op']); else $op='';
30if (isset($_GET['id_circ'])) $id_circ=intval($_GET['id_circ']); else $id_circ='';
31if (isset($_GET['id_sez'])) $id_sez=intval($_GET['id_sez']); else $id_sez='';
32if (isset($_GET['id_sede'])) $id_sede=intval($_GET['id_sede']); else $id_sede='';
33if (isset($_GET['validi'])) $validi=intval($_GET['validi']); else $validi='';
34if (isset($_GET['nulli'])) $nulli=intval($_GET['nulli']); else $nulli='';
35if (isset($_GET['bianchi'])) $bianchi=intval($_GET['bianchi']); else $bianchi='';
36if (isset($_GET['contestati'])) $contestati=intval($_GET['contestati']); else $contestati='';
37if (isset($_GET['votinulli'])) $votinulli=intval($_GET['votinulli']); else $votinulli='01-01-1900';
38if (isset($_GET['id_comune'])) $id_comune=intval($_GET['id_comune']); else $id_comune='';
39if (isset($_GET['ops'])) $ops=intval($_GET['ops']); else $ops='';
40if (isset($_GET['delete'])) $delete=intval($_GET['delete']); else $delete='';
41
42global $prefix,$id_parz,$genere,$fileout,$id_cons;
43if (!isset($fileout)) $fileout='';
44#if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
45if ($fileout) while (!$fp = fopen($fileout,"a"));
46
47$salvato=0;
48
49##################
50$sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
51$result = $dbi->prepare("$sql");
52$result->execute();
53list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
54$sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
55$result = $dbi->prepare("$sql");
56$result->execute();
57$ar=$result->fetch(PDO::FETCH_BOTH);
58$validilista=$validi-$ar['solo_gruppo'];
59$log_data= date("Y/m/d");
60$log_ora=getdate(time());
61$orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
62
63#if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
64 $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$aid','$log_data','$orario','validi_lista:$ar[14] nulli:$ar[7] bianchi:$ar[8] ','validi_lista=$validilista, nulli=$nulli,bianchi=$bianchi','_ele_sezioni')";
65 $res = $dbi->prepare("$sql");
66 $res->execute();
67 $sql="update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', nulli='$nulli',bianchi='$bianchi', voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ";
68 $res = $dbi->prepare("$sql");
69 $res->execute();
70 if ($fileout) fwrite($fp,"$sql;\n");
71/*}else{
72 $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$aid','','','validi:$ar[6] nulli:$ar[7] bianchi:$ar[8] contestati:$ar[9] voti_nulli:$ar[13]','validi=$validi, nulli=$nulli,bianchi=$bianchi,contestati=$contestati, voti_nulli=$votinulli','_ele_sezioni')";
73 $res = $dbi->prepare("$sql");
74 $res->execute();
75 $sql="update ".$prefix."_ele_sezioni set validi='$validi', nulli='$nulli',bianchi='$bianchi',contestati='$contestati',voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ";
76 $res = $dbi->prepare("$sql");
77 $res->execute();
78 if ($fileout) fwrite($fp,"$sql;\n"); */
79#}
80include("ele_controlli.php");
81controllo_voti($id_cons,$id_sez);
82include("ele_colora_sez.php");
83
84if ($fileout) fclose($fp);
85$BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
86Header("Location: ".$BASE."admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=$ops");
87#################################
88
89
90
91
92
93
94?>
Note: See TracBrowser for help on using the repository browser.