source: trunk/admin/modules/Elezioni/query.sql@ 340

Last change on this file since 340 was 285, checked in by roby, 6 years ago
File size: 6.2 KB
Line 
1<?php
2
3if (!defined('ADMIN_FILE')) {
4 die ("You can't access this file directly...");
5}
6
7function getaffluenze()
8{
9 global $dbi,$prefix, $id_cons_gen;
10 $sql = "SELECT * FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario";
11 $sth = $dbi->prepare("$sql");
12 $sth->execute();
13 $row = $sth->fetchAll();
14 return ($row);
15}
16
17function daticonsultazione()
18{
19 global $dbi,$prefix, $id_cons_gen;
20 $sql = "SELECT * FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'";
21 $sth = $dbi->prepare("$sql");
22 $sth->execute();
23 $row = $sth->fetch(PDO::FETCH_BOTH);
24 return ($row);
25
26
27}
28
29function daticonscom()
30{
31 global $dbi,$prefix, $id_cons;
32 $sql = "SELECT * FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
33 $sth = $dbi->prepare("$sql");
34 $sth->execute();
35 $row = $sth->fetch(PDO::FETCH_BOTH);
36 return ($row);
37
38
39}
40
41function datitipo($tipo,$lang)
42{
43 global $dbi,$prefix;
44 $sql = "SELECT * FROM ".$prefix."_ele_tipo where tipo_cons='$tipo' and lingua='$lang'";
45 $sth = $dbi->prepare("$sql");
46 $sth->execute();
47 $row = $sth->fetch(PDO::FETCH_BOTH);
48 return ($row);
49
50
51}
52
53
54function setconsultazione()
55{
56global $prefix,$dbi,$perms,$id_comune,$espandi,$id_cons_gen,$aid,$id_cons,$limite;
57
58if ($id_cons_gen) {
59 if ($id_comune and $perms<256)
60 $sql = "SELECT t1.tipo_cons,t1.descrizione,t2.id_cons_gen FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen'";
61 else
62 $sql = "SELECT t1.tipo_cons,t1.descrizione,t1.id_cons_gen FROM ".$prefix."_ele_consultazione as t1 where t1.id_cons_gen='$id_cons_gen'";
63}else{
64 if($perms>128)
65 $sql = "SELECT tipo_cons,descrizione,id_cons_gen FROM ".$prefix."_ele_consultazione order by data_fine desc limit 0,1 ";
66 else
67 $sql = "SELECT t1.tipo_cons,t1.descrizione,t2.id_cons_gen FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_operatori as t3 where t3.id_comune=$id_comune and t3.id_comune=t2.id_comune and t1.id_cons_gen=t2.id_cons_gen and t2.chiusa='0' and (t3.id_cons=t2.id_cons or t3.id_cons=0) and t3.permessi>0 and t3.aid='$aid' order by t1.data_fine desc limit 0,1 ";
68}
69 $sth = $dbi->prepare("$sql");
70 $sth->execute();
71 $row = $sth->fetch(PDO::FETCH_BOTH);
72 $espandi=0;
73
74 if ($sth->rowCount()) $id_cons_gen=$row[2];
75# list($tipo_cons,$descr_cons,$id_cons_gen) = mysql_fetch_row($res);
76
77 $sql = "SELECT t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
78 $sth = $dbi->prepare("$sql");
79 $sth->execute();
80 if ($sth->rowCount()) list($id_cons) = $sth->fetch(PDO::FETCH_NUM);
81 else $espandi=1;
82 if(!isset($tipo_cons))$tipo_cons=0;
83 if(!isset($id_cons))$id_cons=0;
84
85 $sql="SELECT t1.limite FROM ".$prefix."_ele_conf as t1 left join ".$prefix."_ele_cons_comune as t2 on t1.id_conf=t2.id_conf where t2.id_cons='$id_cons'";
86 $sth = $dbi->prepare("$sql");
87 $sth->execute();
88 if ($sth->rowCount()){
89 list($limite) = $sth->fetch(PDO::FETCH_NUM);
90 } else $limite=0;
91 return($row);
92}
93
94function elenco_cons()
95{
96global $perms,$dbi,$prefix,$currentlang,$aid,$id_comune;
97 if ($perms<128) {
98 $sql="select t3.id_cons, t2.descrizione,t4.genere, t2.id_cons_gen, t3.chiusa from ".$prefix."_ele_operatori as t1, ".$prefix."_ele_consultazione as t2, ".$prefix."_ele_cons_comune as t3, ".$prefix."_ele_tipo as t4 where t4.lingua='$currentlang' and t2.tipo_cons=t4.tipo_cons and t1.aid='$aid' and t3.id_cons_gen=t2.id_cons_gen and (t1.id_cons=t3.id_cons or t1.permessi=64) and t1.id_comune=t3.id_comune and t1.id_comune=$id_comune and t3.chiusa='0' order by t2.data_inizio desc";
99 }else{
100 $sql="SELECT '', t1.descrizione,t2.genere, t1.id_cons_gen,'' FROM ".$prefix."_ele_consultazione as t1,".$prefix."_ele_tipo as t2 where t2.lingua='$currentlang' and t1.tipo_cons=t2.tipo_cons order by t1.data_inizio desc";
101 }
102 $sth = $dbi->prepare("$sql");
103 $sth->execute();
104 $row = $sth->fetchAll();
105 return($row);
106}
107
108function elenco_comuni()
109{
110global $dbi,$prefix;
111 $sql="select * from ".$prefix."_ele_comuni order by descrizione asc";
112 $sth = $dbi->prepare("$sql");
113 $sth->execute();
114 $row = $sth->fetchAll();
115 return($row);
116
117}
118
119function elenco_consultazioni()
120{
121global $dbi,$prefix;
122 $sql="select * from ".$prefix."_ele_consultazione order by descrizione asc";
123 $sth = $dbi->prepare("$sql");
124 $sth->execute();
125 $row = $sth->fetchAll();
126 return($row);
127
128}
129
130function elenco_cons_comune()
131{
132$sql="SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' ";
133 $sth = $dbi->prepare("$sql");
134 $sth->execute();
135 $row = $sth->fetchAll();
136 return($row);
137}
138
139function elenco_tipi()
140{
141global $dbi,$prefix,$language,$currentlang;
142 $sql="SELECT * FROM ".$prefix."_ele_tipo where lingua='$currentlang'";
143 $sth = $dbi->prepare("$sql");
144 $sth->execute();
145 $row = $sth->fetchAll();
146 return($row);
147
148}
149
150function descr_comune()
151{
152global $dbi,$prefix,$id_comune;
153 $sql="select id_comune,descrizione,id_cons from ".$prefix."_ele_comuni where id_comune='$id_comune'";
154 $sth = $dbi->prepare("$sql");
155 $sth->execute();
156 $row = $sth->fetch(PDO::FETCH_BOTH);
157 return($row);
158
159}
160
161function descr_cons()
162{
163global $dbi,$prefix,$id_cons_gen;
164 $sql="SELECT t1.tipo_cons,t2.genere,t1.descrizione FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_tipo as t2 where t1.tipo_cons=t2.tipo_cons and t1.id_cons_gen='$id_cons_gen' ";
165 $sth = $dbi->prepare("$sql");
166 $sth->execute();
167 $row = $sth->fetch(PDO::FETCH_BOTH);
168 return($row);
169
170}
171
172function cur_cons()
173{
174global $dbi,$prefix,$id_cons_gen,$id_comune;
175 $sql="SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
176 $sth = $dbi->prepare("$sql");
177 $sth->execute();
178 $row = $sth->fetch(PDO::FETCH_BOTH);
179 return($row);
180
181}
182
183function tipocons()
184{
185global $dbi,$prefix,$tipo_cons,$currentlang;
186 $sql="SELECT genere,voto_g,voto_l,voto_c,circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' and lingua='$currentlang'";
187 $sth = $dbi->prepare("$sql");
188 $sth->execute();
189 $row = $sth->fetch(PDO::FETCH_BOTH);
190 return($row);
191}
192
193?>
Note: See TracBrowser for help on using the repository browser.