1 | <?php
|
---|
2 | if (!isset($_SESSION['aid'])) die ("You can't access this file directly...");
|
---|
3 | global $id_cons,$id_circ,$id_sez,$dbi,$prefix,$genere,$id_cons_gen;
|
---|
4 |
|
---|
5 | $sql="SELECT t1.voto_c,circo FROM ".$prefix."_ele_tipo as t1 left join ".$prefix."_ele_consultazione as t2 on t1.tipo_cons=t2.tipo_cons where id_cons_gen='$id_cons_gen'";
|
---|
6 | $res = $dbi->prepare("$sql");
|
---|
7 | $res->execute();
|
---|
8 | list($votoc,$circo)=$res->fetch(PDO::FETCH_NUM);
|
---|
9 | if ($circo) $iscirco="and id_circ=$id_circ"; else $iscirco='';
|
---|
10 | $sql="select * from ".$prefix."_ele_controlli where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
11 | $resc = $dbi->prepare("$sql");
|
---|
12 | $resc->execute();
|
---|
13 | $perr=$resc->rowCount();
|
---|
14 | #list($saff,$stato)=$resc->fetch(PDO::FETCH_NUM);
|
---|
15 | $sezstat=0;
|
---|
16 | if($perr) {
|
---|
17 | $sezstat=1;
|
---|
18 | $sql="UPDATE ".$prefix."_ele_sezioni set colore='#FF3300' where id_cons='$id_cons' and id_sez='$id_sez'"; #ROSSO
|
---|
19 | $res = $dbi->prepare("$sql");
|
---|
20 | $res->execute();
|
---|
21 | }else{ #candidati
|
---|
22 | $sql="SELECT t2.id_lista FROM ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on t1.id_cand=t2.id_cand where t1.id_cons='$id_cons' and t1.id_sez='$id_sez' group by t2.id_lista";
|
---|
23 | $res = $dbi->prepare("$sql");
|
---|
24 | $res->execute();
|
---|
25 | $liste=$res->rowCount();
|
---|
26 | list($listescru)=$res->fetch(PDO::FETCH_NUM);
|
---|
27 | if($res->rowCount() and $listescru==0) {$listescru=1;$liste=0;}
|
---|
28 | $sql="SELECT count(id_lista) FROM ".$prefix."_ele_lista where id_cons='$id_cons' $iscirco";
|
---|
29 | $res = $dbi->prepare("$sql");
|
---|
30 | $res->execute();
|
---|
31 | list($ltot)=$res->fetch(PDO::FETCH_NUM);
|
---|
32 | if(($liste && $liste==$ltot)){
|
---|
33 | $sezstat=2;
|
---|
34 | $sql="UPDATE ".$prefix."_ele_sezioni set colore='#99CC33' where id_cons='$id_cons' and id_sez='$id_sez'"; ;#VERDE
|
---|
35 | $res = $dbi->prepare("$sql");
|
---|
36 | $res->execute();
|
---|
37 | }elseif($liste){
|
---|
38 | $sezstat=2;
|
---|
39 | $sql="UPDATE ".$prefix."_ele_sezioni set colore='#99ee33' where id_cons='$id_cons' and id_sez='$id_sez'"; ;#VERDE
|
---|
40 | $res = $dbi->prepare("$sql");
|
---|
41 | $res->execute();
|
---|
42 |
|
---|
43 | }
|
---|
44 | if(!$sezstat) { #liste
|
---|
45 | if($genere==2)
|
---|
46 | $sql="SELECT id_gruppo FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
47 | else
|
---|
48 | $sql="SELECT id_lista FROM ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
49 | $res = $dbi->prepare("$sql");
|
---|
50 | $res->execute();
|
---|
51 | if($res->rowCount()>0){
|
---|
52 | $sezstat=3;
|
---|
53 | if($genere>3 and !$votoc)
|
---|
54 | $sql="UPDATE ".$prefix."_ele_sezioni set colore='#48D1CC' where id_cons='$id_cons' and id_sez='$id_sez'"; #"MEDIUMTORQUOISE"
|
---|
55 | else
|
---|
56 | $sql="UPDATE ".$prefix."_ele_sezioni set colore='#99CC33' where id_cons='$id_cons' and id_sez='$id_sez'"; #VERDE
|
---|
57 | $res = $dbi->prepare("$sql");
|
---|
58 | $res->execute();
|
---|
59 | }elseif(!$sezstat){ #gruppi
|
---|
60 | if($genere!=4){
|
---|
61 | if($genere)
|
---|
62 | $sql="SELECT id_gruppo FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
|
---|
63 | else{
|
---|
64 | $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";
|
---|
65 | $res = $dbi->prepare("$sql");
|
---|
66 | $res->execute();
|
---|
67 | $righeref=$res->rowCount();
|
---|
68 | $sql="SELECT id_gruppo FROM ".$prefix."_ele_voti_ref where id_sez='$id_sez'";
|
---|
69 | }
|
---|
70 | $res = $dbi->prepare("$sql");
|
---|
71 | $res->execute();
|
---|
72 | $righe=$res->rowCount();
|
---|
73 | }else $righe=0;
|
---|
74 | if($righe){
|
---|
75 | $sezstat=4;
|
---|
76 | if(($genere==0 and $righe==$righeref) or $genere==1)
|
---|
77 | $sql="UPDATE ".$prefix."_ele_sezioni set colore='#99CC33' where id_cons='$id_cons' and id_sez='$id_sez'"; #VERDE
|
---|
78 | else $sql="UPDATE ".$prefix."_ele_sezioni set colore='#B0C4DE' where id_cons='$id_cons' and id_sez='$id_sez'"; #"LIGHTSTEELBLUE"
|
---|
79 | $res = $dbi->prepare("$sql");
|
---|
80 | $res->execute();
|
---|
81 | }elseif(!$sezstat){ #voti
|
---|
82 | $sql="SELECT validi+nulli+bianchi+contestati as voti FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
83 | $res = $dbi->prepare("$sql");
|
---|
84 | $res->execute();
|
---|
85 | list($voti)=$res->fetch(PDO::FETCH_NUM);
|
---|
86 | if($voti) {
|
---|
87 | $sezstat=5;
|
---|
88 | $sql="UPDATE ".$prefix."_ele_sezioni set colore='#F5DEB3' where id_cons='$id_cons' and id_sez='$id_sez'"; #"WHEAT"
|
---|
89 | $res = $dbi->prepare("$sql");
|
---|
90 | $res->execute();
|
---|
91 | }elseif(!$sezstat) {
|
---|
92 | $sql="SELECT count(0) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
93 | $res = $dbi->prepare("$sql");
|
---|
94 | $res->execute();
|
---|
95 | list($righe)=$res->fetch(PDO::FETCH_NUM);
|
---|
96 | $num_ril=$righe % 4;
|
---|
97 |
|
---|
98 | if($num_ril==0) {$cursez="#DCDCDC";}#gainsboro
|
---|
99 | elseif($num_ril==1) {$cursez="#ADD8E6";}#lightblue
|
---|
100 | elseif($num_ril==2) {$cursez="#7FFFD4";} #aquamarine
|
---|
101 | elseif($num_ril==3) {$cursez="#E0FFFF";}#lightcyan
|
---|
102 | $sql="UPDATE ".$prefix."_ele_sezioni set colore='$cursez' where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
103 | $res = $dbi->prepare("$sql");
|
---|
104 | $res->execute();
|
---|
105 |
|
---|
106 |
|
---|
107 |
|
---|
108 | }
|
---|
109 | }
|
---|
110 | }
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 |
|
---|
115 | ?>
|
---|