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

Last change on this file was 406, checked in by roby, 2 months ago

Modifiche alla gestione degli operatori

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