source: trunk/admin/modules/Elezioni/salva_aff.php@ 429

Last change on this file since 429 was 415, checked in by roby, 6 months ago
  • ADMIN

-- correzione per gestione consultazione nulla

File size: 4.3 KB
RevLine 
[258]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
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
26
27if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
28if (isset($_GET['op'])) $op=intval($_GET['op']); else $op='0';
29if (isset($_GET['id_circ'])) $id_circ=intval($_GET['id_circ']); else $id_circ='0';
30if (isset($_GET['id_sez'])) $id_sez=intval($_GET['id_sez']); else $id_sez='';
31if (isset($_GET['id_sede'])) $id_sede=intval($_GET['id_sede']); else $id_sede='0';
32if (isset($_GET['voti_u'])) $voti_u=intval($_GET['voti_u']); else $voti_u='0';
33if (isset($_GET['voti_d'])) $voti_d=intval($_GET['voti_d']); else $voti_d='0';
34if (isset($_GET['voti_t'])) $voti_t=intval($_GET['voti_t']); else $voti_t='0';
[344]35if (isset($_GET['orario'])) $orario=addslashes($_GET['orario']); else $orario='';
36if (isset($_GET['data'])) $data=addslashes($_GET['data']); else $data='01-01-1900';
[258]37if (isset($_GET['id_comune'])) $id_comune=intval($_GET['id_comune']); else $id_comune='0';
38if (isset($_GET['id_gruppo'])) $id_gruppo=intval($_GET['id_gruppo']); else $id_gruppo='0';
[262]39if (isset($_GET['genere'])) $genere=intval($_GET['genere']); else $genere='0';
[344]40if (isset($_GET['delete'])) $delete=addslashes($_GET['delete']); else $delete='';
[258]41global $prefix,$id_parz,$tempo,$username,$aid,$dbi,$genere;
42
43if (!isset($fileout)) $fileout='';
44if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
45
46$salvato=0;
[407]47$query="select id_cons,chiusa from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$id_comune'";
[258]48$res = $dbi->prepare("$query");
49$res->execute();
[407]50list($id_cons,$chiusa)=$res->fetch(PDO::FETCH_NUM);
[415]51if($chiusa!=1){
[407]52 $query="select id_parz from ".$prefix."_ele_voti_parziale where data='$data' and orario='$orario' and id_sez='$id_sez' and id_gruppo='$id_gruppo'";
53 $res = $dbi->prepare("$query");
54 $res->execute();
55 $righe=$res->rowCount();
56 list($id_parz)=$res->fetch(PDO::FETCH_NUM);
57 if($righe){ #la riga Ú presente e viene aggiorata
58 $arr=$res->fetch(PDO::FETCH_BOTH);
59 $sql="update ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u',voti_donne='$voti_d',voti_complessivi='$voti_t' where id_parz='$id_parz'";
60 $compl = $dbi->prepare("$sql");
61 $compl->execute();
62 if($compl->rowCount()) $salvato=1;
63 if($delete=="true"){
64 $sql="delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz'";
65 $res = $dbi->prepare("$sql");
66 $res->execute();
67 if($res->rowCount()) $salvato=1;
68 }
69 }else{ # Ú un nuovo inserimento
70 $sql="insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','0','$orario','$data','$voti_u','$voti_d','$voti_t','$id_gruppo')";
[258]71 $res = $dbi->prepare("$sql");
72 $res->execute();
[407]73 if($res->rowCount()) $salvato=1;
[258]74 }
[407]75 if ($fileout) {
76 while (!$fp = fopen($fileout,"a"));
77 fwrite($fp,"$sql;\n");
78 fclose($fp);
79 }
80 if($salvato){
81 $riga=addslashes($sql);
82 $sqlog="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$data','$orario','','$riga','".$prefix."_ele_voti_parziale')";
83 $res = $dbi->prepare("$sqlog");
84 $res->execute();
85 }
86 #controllo_aff($id_cons,$id_sez,$id_parz);
87 include("ele_controlli.php");
88 controllo_aff($id_cons,$id_sez,$id_parz);
89 include("ele_colora_sez.php");
[258]90}
[358]91$BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
[258]92
93Header("Location: ".$BASE."admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&ops=1&do=spoglio");
94
95
96?>
Note: See TracBrowser for help on using the repository browser.