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

Last change on this file since 404 was 394, checked in by roby, 18 months ago

-- ADMIN

  • Inserito il controllo per la gestione del caso di sezione con zero votanti

-- CLIENT

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