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

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

-- correzione per gestione consultazione nulla

File size: 6.1 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='';
41if (isset($_GET['scrutinata'])) {$scrutinata=$_GET['scrutinata']==false ? false : true;}else $scrutinata=false;
42#$_SESSION['scrutinata']=$scrutinata;
43#if(isset($_SESSION['scrutinata'])) $scrutinata=$_SESSION['scrutinata']; #else $scrutinata=false;
44global $prefix,$id_parz,$genere,$fileout,$id_cons;
45$sql="select solo_gruppo,disgiunto,chiusa from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
46$result = $dbi->prepare("$sql");
47$result->execute();
48list($flagsg,$disgiunto,$chiusa)=$result->fetch(PDO::FETCH_NUM);
49if($chiusa=1){
50 if (!isset($fileout)) $fileout='';
51 #if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
52 if ($fileout) while (!$fp = fopen($fileout,"a"));
53
54 $salvato=0;
55
56 ##################
57
58 $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
59 $result = $dbi->prepare("$sql");
60 $result->execute();
61 $ar=$result->fetch(PDO::FETCH_BOTH);
62 $validilista=$validi-$ar['solo_gruppo'];
63 $log_data= date("Y/m/d");
64 $log_ora=getdate(time());
65 $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
66
67 #if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
68 $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')";
69 $res = $dbi->prepare("$sql");
70 $res->execute();
71 $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' ";
72 $res = $dbi->prepare("$sql");
73 $res->execute();
74 if ($fileout) fwrite($fp,"$sql;\n");
75 ######
76 #include($sql."TEST: scru=$scrutinata");
77 if(isset($scrutinata))
78 {
79 $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and num_gruppo=0";
80 $res = $dbi->prepare("$sql");
81 $res->execute();
82 $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez' and num_lista=0";
83 $res = $dbi->prepare("$sql");
84 $res->execute();
85 $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez' and num_cand=0";
86 $res = $dbi->prepare("$sql");
87 $res->execute();
88 if($scrutinata==true)
89 {
90 # provare insert dei soli id_cons e id_sez
91 $sql="insert into ".$prefix."_ele_voti_gruppo (id_cons,id_sez,num_gruppo) values('$id_cons','$id_sez',0)";
92 $res = $dbi->prepare("$sql");
93 $res->execute();
94 $sql="insert into ".$prefix."_ele_voti_lista (id_cons,id_sez) values('$id_cons','$id_sez')";
95 $res = $dbi->prepare("$sql");
96 $res->execute();
97 $sql="insert into ".$prefix."_ele_voti_candidati (id_cons,id_sez,num_cand) values('$id_cons','$id_sez',0)";
98 $res = $dbi->prepare("$sql");
99 $res->execute();
100 #
101 }
102 }
103 /*}else{
104 $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')";
105 $res = $dbi->prepare("$sql");
106 $res->execute();
107 $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' ";
108 $res = $dbi->prepare("$sql");
109 $res->execute();
110 if ($fileout) fwrite($fp,"$sql;\n"); */
111 #}
112 include("ele_controlli.php");
113 controllo_voti($id_cons,$id_sez);
114 include("ele_colora_sez.php");
115 if ($fileout) fclose($fp);
116}
117$BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
118Header("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");
119#################################
120
121
122
123
124
125
126?>
Note: See TracBrowser for help on using the repository browser.