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

Last change on this file since 404 was 400, checked in by roby, 9 months ago
  • ADMIN

-- Migliorata la gestione di operatori e responsabili

  • CLIENT

-- Nuovo tema BSItalia realizzato dal CED di Capo d'Orlando
-- Sistemata la funzione del widget privacy
-- Varie modifiche di allineamento oggetti

File size: 6.2 KB
RevLine 
[256]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();
[257]47 $row = $sth->fetch(PDO::FETCH_BOTH);
[256]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
[358]67 $sql = "SELECT t1.tipo_cons,t1.descrizione,t2.id_cons_gen FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".
68 $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 ";
[256]69}
70 $sth = $dbi->prepare("$sql");
71 $sth->execute();
72 $row = $sth->fetch(PDO::FETCH_BOTH);
73 $espandi=0;
74
75 if ($sth->rowCount()) $id_cons_gen=$row[2];
76# list($tipo_cons,$descr_cons,$id_cons_gen) = mysql_fetch_row($res);
77
78 $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'";
79 $sth = $dbi->prepare("$sql");
80 $sth->execute();
[257]81 if ($sth->rowCount()) list($id_cons) = $sth->fetch(PDO::FETCH_NUM);
[256]82 else $espandi=1;
83 if(!isset($tipo_cons))$tipo_cons=0;
84 if(!isset($id_cons))$id_cons=0;
85
86 $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'";
87 $sth = $dbi->prepare("$sql");
88 $sth->execute();
[257]89 if ($sth->rowCount()){
[285]90 list($limite) = $sth->fetch(PDO::FETCH_NUM);
[282]91 } else $limite=0;
[256]92 return($row);
93}
94
95function elenco_cons()
96{
97global $perms,$dbi,$prefix,$currentlang,$aid,$id_comune;
98 if ($perms<128) {
[400]99 $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 t1.permessi>0 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";
[256]100 }else{
101 $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";
102 }
103 $sth = $dbi->prepare("$sql");
104 $sth->execute();
105 $row = $sth->fetchAll();
106 return($row);
107}
108
109function elenco_comuni()
110{
111global $dbi,$prefix;
112 $sql="select * from ".$prefix."_ele_comuni order by descrizione asc";
113 $sth = $dbi->prepare("$sql");
114 $sth->execute();
115 $row = $sth->fetchAll();
116 return($row);
117
118}
119
120function elenco_consultazioni()
121{
122global $dbi,$prefix;
123 $sql="select * from ".$prefix."_ele_consultazione order by descrizione asc";
124 $sth = $dbi->prepare("$sql");
125 $sth->execute();
126 $row = $sth->fetchAll();
127 return($row);
128
129}
130
131function elenco_cons_comune()
132{
133$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' ";
134 $sth = $dbi->prepare("$sql");
135 $sth->execute();
136 $row = $sth->fetchAll();
137 return($row);
138}
139
140function elenco_tipi()
141{
142global $dbi,$prefix,$language,$currentlang;
143 $sql="SELECT * FROM ".$prefix."_ele_tipo where lingua='$currentlang'";
144 $sth = $dbi->prepare("$sql");
145 $sth->execute();
146 $row = $sth->fetchAll();
147 return($row);
148
149}
150
151function descr_comune()
152{
153global $dbi,$prefix,$id_comune;
154 $sql="select id_comune,descrizione,id_cons from ".$prefix."_ele_comuni where id_comune='$id_comune'";
155 $sth = $dbi->prepare("$sql");
156 $sth->execute();
157 $row = $sth->fetch(PDO::FETCH_BOTH);
158 return($row);
159
160}
161
162function descr_cons()
163{
164global $dbi,$prefix,$id_cons_gen;
165 $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' ";
166 $sth = $dbi->prepare("$sql");
167 $sth->execute();
168 $row = $sth->fetch(PDO::FETCH_BOTH);
169 return($row);
170
171}
172
173function cur_cons()
174{
175global $dbi,$prefix,$id_cons_gen,$id_comune;
176 $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'";
177 $sth = $dbi->prepare("$sql");
178 $sth->execute();
179 $row = $sth->fetch(PDO::FETCH_BOTH);
180 return($row);
181
182}
183
184function tipocons()
185{
186global $dbi,$prefix,$tipo_cons,$currentlang;
187 $sql="SELECT genere,voto_g,voto_l,voto_c,circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' and lingua='$currentlang'";
188 $sth = $dbi->prepare("$sql");
189 $sth->execute();
[257]190 $row = $sth->fetch(PDO::FETCH_BOTH);
[256]191 return($row);
192}
193
194?>
Note: See TracBrowser for help on using the repository browser.