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

Last change on this file since 404 was 358, checked in by roby, 3 years ago

Admin: aggiunta la funzione di gestione dello spoglio per la singola sezione tramite tema per cellulari

File size: 6.0 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='0';
27if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
28if (isset($_GET['id_cons'])) $id_cons=intval($_GET['id_cons']); else $id_cons='0';
29if (isset($_GET['op'])) $op=intval($_GET['op']); else $op='0';
30if (isset($_GET['id_circ'])) $id_circ=intval($_GET['id_circ']); else $id_circ='0';
31if (isset($_GET['id_sez'])) $id_sez=intval($_GET['id_sez']); else $id_sez='0';
32if (isset($_GET['id_sede'])) $id_sede=intval($_GET['id_sede']); else $id_sede='0';
33if (isset($_GET['do'])) $do=intval($_GET['do']); else $do='0';
34if (isset($_GET['validi'])) $validi=intval($_GET['validi']); else $validi='0';
35if (isset($_GET['nulli'])) $nulli=intval($_GET['nulli']); else $nulli='0';
36if (isset($_GET['bianchi'])) $bianchi=intval($_GET['bianchi']); else $bianchi='0';
37if (isset($_GET['contestati'])) $contestati=intval($_GET['contestati']); else $contestati='0';
38if (isset($_GET['votinulli'])) $votinulli=intval($_GET['votinulli']); else $votinulli='0';
39if (isset($_GET['id_comune'])) $id_comune=intval($_GET['id_comune']); else $id_comune='0';
40if (isset($_GET['ops'])) $ops=intval($_GET['ops']); else $ops='4';
41if (isset($_GET['sololista'])) $sololista=intval($_GET['sololista']); else $sololista='0';
42if (isset($_GET['delete'])) $delete=intval($_GET['delete']); else $delete='';
43if (isset($_GET['circo'])) $circo=addslashes($_GET['circo']); else $circo='';
44
45global $prefix,$id_parz,$fileout;
46$sql="SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" ;
47$res = $dbi->prepare("$sql");
48$res->execute();
49list($tipo_cons) = $res->fetch(PDO::FETCH_NUM);
50$sql="SELECT circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
51$res = $dbi->prepare("$sql");
52$res->execute();
53list($circo)=$res->fetch(PDO::FETCH_NUM);
54
55if ($circo) $circo="and id_circ=$id_circ"; else $circo='';
56$sql="select num_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
57$result = $dbi->prepare("$sql");
58$result->execute();
59while(list($i)=$result->fetch(PDO::FETCH_BOTH)) {
60 $vot="voti$i";$solo="solog$i";$grupp="num_gruppo$i";
61 if (isset($_GET[$grupp])) $num_gruppo[$i]=intval($_GET[$grupp]); else $num_gruppo[$i]='0';
62 if (isset($_GET[$vot]) && $_GET[$vot]) $voti[$i]=intval($_GET[$vot]); else $voti[$i]='0';
63 if (isset($_GET[$solo])) $solog[$i]=intval($_GET[$solo]); else $solog[$i]='0';
64
65}
66
67if (!isset($fileout)) $fileout='';
68#if(($voti_u+$voti_d) and !$voti_t) $voti_t=$voti_u+$voti_d;
69if ($fileout) while (!$fp = fopen($fileout,"a"));
70
71##################
72 if($do==1) {
73 $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
74 $res = $dbi->prepare("$sql");
75 $res->execute();
76 $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
77 $res = $dbi->prepare("$sql");
78 $res->execute();
79 $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'";
80 $res = $dbi->prepare("$sql");
81 $res->execute();
82 $sql="update ".$prefix."_ele_sezioni set validi_lista='0',contestati_lista='0',voti_nulli_lista='0',solo_gruppo='0',solo_lista='0' where id_cons='$id_cons' and id_sez='$id_sez'";
83 $res = $dbi->prepare("$sql");
84 $res->execute();
85 }else{
86 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
87 $res = $dbi->prepare("$sql");
88 $res->execute();
89 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
90 if($disgiunto){
91 }
92 $sql="update ".$prefix."_ele_sezioni set solo_lista='$sololista' where id_cons='$id_cons' and id_sez='$id_sez'";
93 $result = $dbi->prepare("$sql");
94 $result->execute();
95 $sql="select num_gruppo from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
96 $result = $dbi->prepare("$sql");
97 $result->execute();
98 if($result->rowCount()) {
99 while(list($i)=$result->fetch(PDO::FETCH_NUM)){
100 $sql="update ".$prefix."_ele_voti_gruppo set voti='".$voti[$i]."',solo_gruppo='".$solog[$i]."' where id_cons='$id_cons' and id_sez='$id_sez' and num_gruppo='".$num_gruppo[$i]."'";
101 $res = $dbi->prepare("$sql");
102 $res->execute();
103 }
104 }else{
105 $sql="select num_gruppo,id_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
106 $result = $dbi->prepare("$sql");
107 $result->execute();
108 while(list($i,$id_gruppo)=$result->fetch(PDO::FETCH_NUM)){
109 $sql="insert into ".$prefix."_ele_voti_gruppo values('$id_cons','$id_gruppo','$id_sez','$i','".$voti[$i]."','".$solog[$i]."')";
110 $res = $dbi->prepare("$sql");
111 $res->execute();
112 }
113
114 }
115}
116
117
118include("ele_controlli.php");
119controllo_votig($id_cons,$id_sez,$genere);
120include("ele_colora_sez.php");
121
122if ($fileout) fclose($fp);
123$BASE=substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['REQUEST_URI'], "/")-16);
124Header("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");
125
126#################################
127
128
129
130
131
132
133?>
Note: See TracBrowser for help on using the repository browser.