source: trunk/admin/modules/Elezioni/ele_permessi.php@ 358

Last change on this file since 358 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: 9.7 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Roberto Gigli & Luciano Apolito */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8/* Modulo Permessi */
9/* Amministrazione */
10/************************************************************************/
11
12if (!defined('ADMIN_FILE')) {
13 die ("You can't access this file directly...");
14}
15
16$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
17$id_cons_gen=$param['id_cons_gen'];
18
19$perms=ChiSei($id_cons_gen);
20if ($perms<64 or !$id_cons_gen) die("Non hai i permessi per inserire dati ($perms)($id_cons_gen), o non hai scelto la consultazione!");
21$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'";
22$res = $dbi->prepare("$sql");
23$res->execute();
24list($tipo_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM);
25if (isset($param['aid2'])) $aid2=addslashes($param['aid2']); else $aid2='';
26if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede=0;
27if (isset($param['do'])) $do=addslashes($param['do']); else $do='';
28if (isset($param['permessi'])) $permessi=addslashes($param['permessi']); else $permessi='';
29if (isset($param['id_comune2'])) $id_comune2=intval($param['id_comune2']); else $id_comune2='';
30if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
31if (isset($param['mex'])) $mex=addslashes($param['mex']); else $mex='';
32if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez=0;
33
34include("modules/Elezioni/funzionidata.php");
35include("modules/Elezioni/ele.php");
36
37/******************************************************/
38/*Funzione di visualizzazione globale */
39/*****************************************************/
40//crea la pagina delle affluenze
41function all() {
42 global $adminop,$adminsuper,$admincomune,$aid, $offset, $prefix, $dbi,$id_cons,$aid2,$permessi,$id_sede,$id_cons_gen,$id_comune,$mex,$id_sez;
43 $bgcolor1=$_SESSION['bgcolor1'];
44 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
45
46 ."//-->\n";
47 echo "function controlloref(idsede,idsez) {\n";
48 echo "let element = window.document.getElementById(idsede); \n";
49 echo "let elecontr = window.document.getElementById(idsez); \n";
50 echo "element.selectedIndex = 0 ; \n";
51 echo "}\n";
52 echo "function controllosez(idsez, idsede) {\n";
53 echo "let element = window.document.getElementById(idsez); \n";
54 echo "let elecontr = window.document.getElementById(idsede); \n";
55 echo "element.selectedIndex = 0; \n";
56 echo "}\n";
57 echo "</script>\n";
58 if (isset($mex)){
59 echo "<table align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0)\">";
60 echo $mex;
61 echo "</td></tr></table>";
62 }
63 OpenTable();
64 $sql="SELECT * FROM ".$prefix."_ele_operatori where id_cons=$id_cons and permessi<64 order by aid";
65 $resmod = $dbi->prepare("$sql");
66 $resmod->execute();
67
68 echo "<br><table><tr align=\"center\" bgcolor=\"$bgcolor1\">";
69 echo "<td><b>"._UTENTE."</b></td>"
70 ."<td bgcolor=\"$bgcolor1\"><b>"._SEDE."</b></td>"
71 ."<td bgcolor=\"$bgcolor1\"><b>"._SEZIONE."</b></td>"
72 ."<td bgcolor=\"$bgcolor1\"><b>"._PERMESSI."</b></td>";
73 echo "<td bgcolor=\"$bgcolor1\"><b>"._FUNZIONI."</b></td></tr>";
74
75
76
77 $sql="SELECT aid FROM ".$prefix."_ele_operatori where id_cons=$id_cons and permessi<64 order by aid";
78 $restmp = $dbi->prepare("$sql");
79 $restmp->execute();
80 if($restmp) {
81 $listmp='';$virg='';
82 while (list($artmp) = $restmp->fetch(PDO::FETCH_NUM)){ //elenco degli operatori gia' autorizzati
83 $listmp .= $virg."'".$artmp."'";
84 $virg=',';
85 }
86 }
87
88 if (!$listmp) $listmp="''";
89 $sql="select aid from ".$prefix."_authors where id_comune=$id_comune and (admincomune=0 and adminop=0 and aid not in ($listmp)) order by aid"; // operatori registrati ma non ancora autorizzati
90 $resins = $dbi->prepare("$sql");
91 $resins->execute();
92
93 echo "<form name=\"autorizza\" action=\"admin.php\">"
94 ."<input type=\"hidden\" name=\"op\" value=\"permessi\">";
95 echo "<tr align=\"center\">";
96 echo "<td><select name=\"aid2\">";
97 echo "<option value=\"\">";
98 if($resins->rowCount()) {
99 while(list($utente)=$resins->fetch(PDO::FETCH_NUM)){
100 echo "<option value=\"$utente\">$utente";
101 }
102 }
103 echo "</select></td>";
104 $sql="SELECT id_sede, indirizzo from ".$prefix."_ele_sede where id_cons=$id_cons";
105 $ressede = $dbi->prepare("$sql");
106 $ressede->execute();
107 echo "<td><select id=\"id_sede\" name=\"id_sede\" onchange=controllosez('id_sez','id_sede')>";
108 echo "<option value=\"0\"> "._TUTTESEDI;
109 if($ressede->rowCount())
110 while(list($id,$descr)=$ressede->fetch(PDO::FETCH_NUM)){
111 $sel= ($id == $id_sede) ? "selected":"";
112 $arr[$id]=$descr;
113 echo "<option value=\"$id\" $sel>$descr";
114 }
115 echo "</select></td>";
116 $sql="SELECT id_sez, num_sez from ".$prefix."_ele_sezioni where id_cons=$id_cons order by num_sez";
117 $ressez = $dbi->prepare("$sql");
118 $ressez->execute();
119 echo "<td><select id=\"id_sez\" name=\"id_sez\" onchange=controlloref('id_sede','id_sez')>";
120 echo "<option value=\"0\"> ";
121 if($ressez->rowCount())
122 while(list($id,$descr)=$ressez->fetch(PDO::FETCH_NUM)){
123 $sel= ($id == $id_sez) ? "selected":"";
124 $arr[$id]=$descr;
125 echo "<option value=\"$id\" $sel>$descr";
126 }
127 echo "</select></td>";
128 echo "<td><select name=\"permessi\">";
129 if(!isset($permessi)) $permessi=16;
130 $sel=($permessi==32) ? "selected":"";
131 echo "<option value=\"32\" $sel>"._IMPOSTA_DATI;
132 $sel=($permessi==16) ? "selected":"";
133 echo "<option value=\"16\" $sel>"._INSERISCE_DATI;
134 $sel=($permessi==0) ? "selected":"";
135 echo "<option value=\"0\" $sel>"._SOSPESO;
136 echo "</select></td>";
137 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
138 echo "<input type=\"hidden\" name=\"ok\" value=0>";
139 echo "<input type=\"hidden\" name=\"do\" value=\"autorizza\">";
140 echo "<td><input type=\"submit\" name=\"add\" value=\""._AGGIUNGI."\"></td></tr></form></table>";
141 echo "<br><hr><br><table>";
142 if($resmod->rowCount()){
143 $i=1;
144 while (list($id_cons2,$id_sede2,$id_comunetemp,$perm,$utente,$id_circ2,$id_sez2) = $resmod->fetch(PDO::FETCH_NUM)){
145 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
146 echo "<form name=\"modello$i\" action=\"admin.php\">"
147 ."<input type=\"hidden\" name=\"op\" value=\"permessi\">";
148 echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
149 echo "<input type=\"hidden\" name=\"aid2\" value=\"$utente\">";
150 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
151 echo "<input type=\"hidden\" name=\"ok\" value=0>";
152 echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
153 echo "<td align=\"center\" width=\"32\"><b>$utente</b></td>";
154 $sql="SELECT id_sede, indirizzo from ".$prefix."_ele_sede where id_cons=$id_cons";
155 $ressede = $dbi->prepare("$sql");
156 $ressede->execute();
157 echo "<td><select id=\"id_sede$i\" name=\"id_sede\" onchange=controllosez('id_sez$i','id_sede$i')>";
158# if($id_sez2)
159# echo "<option value=\"0\"> ";
160# else
161 echo "<option value=\"0\"> "._TUTTESEDI;
162 while(list($id,$descr)=$ressede->fetch(PDO::FETCH_NUM)){
163 $sel= ($id == $id_sede2) ? "selected":"";
164 $arr[$id]=$descr;
165 echo "<option value=\"$id\" $sel>$descr";
166 }
167 echo "</select></td>";
168 $sql="SELECT id_sez, num_sez from ".$prefix."_ele_sezioni where id_cons=$id_cons order by num_sez";
169 $ressez = $dbi->prepare("$sql");
170 $ressez->execute();
171 echo "<td><select id=\"id_sez$i\" name=\"id_sez\" onchange=controlloref('id_sede$i','id_sez$i')>";
172 echo "<option value=\"0\"> ";
173 if($ressez->rowCount())
174 while(list($id,$descr)=$ressez->fetch(PDO::FETCH_NUM)){
175 $sel= ($id == $id_sez2) ? "selected":"";
176 $arr[$id]=$descr;
177 echo "<option value=\"$id\" $sel>$descr";
178 }
179 echo "</select></td>";
180 echo "<td><select name=\"permessi\">";
181 if(!isset($perm)) $perm=16;
182 $sel=($perm==32) ? "selected":"";
183 echo "<option value=\"32\" $sel>"._IMPOSTA_DATI;
184 $sel=($perm==16) ? "selected":"";
185 echo "<option value=\"16\" $sel>"._INSERISCE_DATI;
186 $sel=($perm==0) ? "selected":"";
187 echo "<option value=\"0\" $sel>"._SOSPESO;
188 echo "</select></td>";
189 echo "<td><input type=\"submit\" name=\"add\" value=\""._OK."\"></td></tr></form>";
190 $i++;
191 }
192 }
193 echo "</table>";
194 CloseTable();
195}
196
197function permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune,$id_sez) {
198 global $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang;
199 $perms=ChiSei($id_cons_gen);
200 if ($perms!=256) $id_comune=$_SESSION['id_comune'];
201 if ($perms>32 and $permessi<$perms and $aid2) {
202 if ($do == "autorizza") {
203 $sql="insert into ".$prefix."_ele_operatori (id_cons,id_sede,id_comune,permessi,aid,id_sez) values ('$id_cons','$id_sede','$id_comune','$permessi','$aid2','$id_sez')";
204 $res = $dbi->prepare("$sql");
205 $res->execute();
206 Header("Location: admin.php?op=permessi&id_cons_gen=$id_cons_gen");
207 } elseif ($do == "update") {
208 $sql="update ".$prefix."_ele_operatori set id_sede='$id_sede', permessi='$permessi', id_sez='$id_sez' where id_cons='$id_cons' and aid='$aid2' ";
209 $res = $dbi->prepare("$sql");
210 $res->execute();
211 $result=$res->rowCount();
212 if (!$result) return;
213 Header("Location: admin.php?op=permessi&id_cons_gen=$id_cons_gen");
214 }
215 }
216}
217
218
219//****************************
220// switch
221//****************************
222 if ($do) permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune,$id_sez);
223 ele();
224 all();
225 include("footer.php");
226?>
227
Note: See TracBrowser for help on using the repository browser.