source: trunk/admin/modules/Elezioni/ele_confcons.php@ 343

Last change on this file since 343 was 336, checked in by roby, 4 years ago

Admin: prime modifiche per compatibilità con php 7.4

File size: 13.8 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 gruppo */
9/* Amministrazione */
10/************************************************************************/
11if (!defined('ADMIN_FILE')) {
12 die ("You can't access this file directly...");
13}
14
15// Offset - visualizza il numero di elementi per pagina
16$offset=5;
17global $db1;
18$aid=$_SESSION['aid'];
19$prefix=$_SESSION['prefix'];
20$currentlang=$_SESSION['lang'];
21$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
22$id_cons_gen=$param['id_cons_gen'];
23$perms=ChiSei($id_cons_gen);
24if ($perms<32 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
25
26$id_comune=$_SESSION['id_comune'];
27$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' ";
28$res = $dbi->prepare("$sql");
29$res->execute();
30list($tipo_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM);
31
32include("modules/Elezioni/funzionidata.php");
33include("modules/Elezioni/ele.php");
34
35if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
36if (isset($param['min'])) $min=intval($param['min']); else $min=0;
37if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
38if (isset($param['descrizione'])) get_magic_quotes_gpc() ?
39$descrizione=$param['descrizione']:$descrizione=addslashes($param['descrizione']); else $descrizione='';
40if (isset($param['id_conf'])) $id_conf=intval($param['id_conf']); else $id_conf='';
41if (isset($param['limite'])) get_magic_quotes_gpc() ? $limite=$param['limite']:$limite=addslashes($param['limite']); else $limite='';
42if (isset($param['consin'])) get_magic_quotes_gpc() ? $consin=$param['consin']:$consin=addslashes($param['consin']); else $consin='';
43if (isset($param['infpremio'])) get_magic_quotes_gpc() ? $infpremio=$param['infpremio']:$infpremio=addslashes($param['infpremio']); else $infpremio='';
44if (isset($param['listinfsbar'])) get_magic_quotes_gpc() ? $listinfsbar=$param['listinfsbar']:$listinfsbar=addslashes($param['listinfsbar']); else $listinfsbar='';
45if (isset($param['infminpremio'])) get_magic_quotes_gpc() ? $infminpremio=$param['infminpremio']:$infminpremio=addslashes($param['infminpremio']); else $infminpremio='';
46if (isset($param['listinfconta'])) get_magic_quotes_gpc() ? $listinfconta=$param['listinfconta']:$listinfconta=addslashes($param['listinfconta']); else $listinfconta='';
47if (isset($param['suppremio'])) get_magic_quotes_gpc() ? $suppremio=$param['suppremio']:$suppremio=addslashes($param['suppremio']); else $suppremio='';
48if (isset($param['supsbarramento'])) get_magic_quotes_gpc() ? $supsbarramento=$param['supsbarramento']:$supsbarramento=addslashes($param['supsbarramento']); else $supsbarramento='';
49if (isset($param['supminpremio'])) get_magic_quotes_gpc() ? $supminpremio=$param['supminpremio']:$supminpremio=addslashes($param['supminpremio']); else $supminpremio='';
50if (isset($param['listsupconta'])) get_magic_quotes_gpc() ? $listsupconta=$param['listsupconta']:$listsupconta=addslashes($param['listsupconta']); else $listsupconta='';
51#if (isset($param['infdisgiunto'])) get_magic_quotes_gpc() ? $infdisgiunto=$param['infdisgiunto']:$infdisgiunto=addslashes($param['infdisgiunto']); else $infdisgiunto='';
52#if (isset($param['supdisgiunto'])) get_magic_quotes_gpc() ? $supdisgiunto=$param['supdisgiunto']:$supdisgiunto=addslashes($param['supdisgiunto']); else $supdisgiunto='';
53if (isset($param['help'])) $help=intval($param['help']);
54
55/******************************************************/
56/*Funzione di visualizzazione globale */
57/*****************************************************/
58 function all() {
59 global $tipo_cons,$param,$currentlang, $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $id_cons,$id_cons_gen,$id_comune,$do,$id_conf, $language,$help;
60
61 if (isset($help)) include("language/$language/ele_confcons.html");
62 echo "<center><br><table border=\"0\" width=\"100%\">";
63
64 //-----------------------visualizza blocco inserimento -
65 $sql="SELECT * FROM ".$prefix."_ele_conf"; //da modificare
66 $res = $dbi->prepare("$sql");
67 $res->execute();
68 $max = $res->rowCount();
69 $nuovo_gruppo=$max+1;
70 echo "<form name=\"gruppo2\" enctype=\"multipart/form-data\" action=\"admin.php\" method=\"post\">"
71 ."<input type=\"hidden\" name=\"op\" value=\"confconsiglio\">";
72 if ($do=='modify') {
73 $sql="SELECT * FROM ".$prefix."_ele_conf where id_conf='$id_conf'";
74 $resl = $dbi->prepare("$sql");
75 $resl->execute();
76 $gru=$resl->fetch(PDO::FETCH_BOTH);
77 $nuovo_gruppo=$gru['id_conf'];
78 echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
79 }else{
80 $gru['id_conf']=$nuovo_gruppo;$gru['descrizione']='';$gru['limite']='';$gru['consin']='';$gru['infpremio']='';$gru['listinfsbar']='';$gru['listinfconta']='';$gru['supminpremio']='';$gru['infminpremio']='';$gru['suppremio']='';$gru['supsbarramento']='';$gru['listsupconta']='';
81 echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
82 }
83 echo "<tr bgcolor=\"$bgcolor2\"><td align=\"center\"><input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
84// echo "<b>"._NUM."</b></td><td><input type=\"hidden\" name=\"id_conf\" value=\"".$gru['id_conf']."\">".$gru['id_conf']."</td><td align=\"center\">"
85 echo "<input type=\"hidden\" name=\"id_conf\" value=\"".$gru['id_conf']."\"><b>"._DESCR."</b></td><td colspan=\"3\"><input type=\"text\" name=\"descrizione\" value=\"".$gru['descrizione']."\"></td></tr>"
86 ."<tr><td align=\"center\"><b>"._LIMITE."</b></td><td><select name=\"limite\"><option value=\"0\">"._NOFASCIA;
87
88 $sql="select id_fascia, abitanti from ".$prefix."_ele_fasce where id_conf='".$gru['id_conf']."' order by id_fascia";
89 $result1 = $dbi->prepare("$sql");
90 $result1->execute();
91 while(list($id,$descr)=$result1->fetch(PDO::FETCH_NUM)){
92 $sel= ($id == $gru['limite']) ? "selected":"";
93 echo "<option value=\"$id\" $sel>$descr";
94 }
95 echo "</select></td>";
96 $sel= ($gru['consin']==1) ? "selected":"";
97 echo "<td align=\"center\"><b>"._CONSIN."</b></td><td><select name=\"consin\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td></tr>"
98 ."<tr><td align=\"center\" colspan=\"4\" bgcolor=\"$bgcolor2\"><b>"._SISTEMA_MAGGIORITARIO."</b></td></tr>";
99 echo "<tr><td align=\"center\"><b>"._INFPREMIO."</b></td><td><input type=\"text\" name=\"infpremio\" value=\"".$gru['infpremio']."\"></td>"
100 ."<td align=\"center\"><b>"._LISTINFSBAR."</b></td><td><input type=\"text\" name=\"listinfsbar\" value=\"".$gru['listinfsbar']."\"></td></tr>"
101 ."<tr><td align=\"center\"><b>"._INFMINPREMIO."</b></td><td><input type=\"text\" name=\"infminpremio\" value=\"".$gru['infminpremio']."\"></td>";
102 $sel= ($gru['listinfconta']==1) ? "selected":"";
103 echo"<td align=\"center\"><b>"._LISTINFCONTA."</b></td><td><select name=\"listinfconta\"><option value=\"0\">No<option value=\"1\" $sel>Si</select></td></tr>"
104 ."<tr><td align=\"center\" colspan=\"4\" bgcolor=\"$bgcolor2\"><b>"._SISTEMA_PROPORZIONALE."</b></td></tr>";
105 echo "<tr><td align=\"center\"><b>"._SUPPREMIO."</b></td><td><input type=\"text\" name=\"suppremio\" value=\"".$gru['suppremio']."\"></td>"
106 ."<td align=\"center\"><b>"._SUPSBAR."</b></td><td><input type=\"text\" name=\"supsbarramento\" value=\"".$gru['supsbarramento']."\"></td></tr>"
107 ."<tr><td align=\"center\"><b>"._SUPMINPREMIO."</b></td><td><input type=\"text\" name=\"supminpremio\" value=\"".$gru['supminpremio']."\"></td>";
108 $sel= ($gru['listsupconta']==1) ? "selected":"";
109 echo "<td align=\"center\"><b>"._LISTSUPCONTA."</b></td><td><select name=\"listsupconta\"><option value=\"0\">No<option value=\"1\" $sel>Si</select>";
110 echo "<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
111 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
112 ."<input type=\"hidden\" name=\"min\" value=\"$min\"></td></tr><tr><td></td><td></td><td></td>";
113 if ($do=='modify')
114 echo "<td align=\"center\"><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td>";
115 else
116 echo "<td align=\"center\"><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td>";
117 echo "</tr></form>";
118
119
120
121 $sql="SELECT * FROM ".$prefix."_ele_conf";
122 $res = $dbi->prepare("$sql");
123 $res->execute();
124 $max = $res->rowCount();
125 $sql="select * from ".$prefix."_ele_conf ORDER BY id_conf LIMIT $min,$offset";
126 $result = $dbi->prepare("$sql");
127 $result->execute();
128 while(list($id_conf,$descrizione,$limite, $consin,$infpremio, $supsbarramento, $suppremio, $listinfsbar, $listinfconta, $listsupconta) = $result->fetch(PDO::FETCH_NUM)) {
129 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
130 echo "<tr bgcolor=\"$bgcolor1\"><td align=\"center\"><b>$id_conf</b></td>"
131 ."<td align=\"left\"><b>$descrizione</b></td>"; /*
132 ."<td align=\"center\"><b>$limite</b></td>"
133 ."<td align=\"center\"><b>$consin</b></td>"
134 ."<td align=\"center\"><b>$infpremio</b></td>"
135 ."<td align=\"center\"><b>$supsbarramento</b></td>"
136 ."<td align=\"center\"><b>$suppremio</b></td>"
137 ."<td align=\"center\"><b>$listinfsbar</b></td>"
138 ."<td align=\"center\"><b>$listinfconta</b></td>"
139 ."<td align=\"center\"><b>$listsupconta</b></td>" */
140 echo "<td align=\"center\" nowrap>[<a
141 href=\"admin.php?op=confconsiglio&amp;do=modify&amp;id_conf=$id_conf&amp;id_cons_gen=$id_cons_gen&amp;min=$min\"><img src=\"modules/Elezioni/images/edit.gif\"
142 border=\"0\" align=\"center\"> "._EDIT."</a>]";
143
144 if (!isset($numtemp))
145 echo "[<a href=\"admin.php?op=confconsiglio&amp;do=delete&amp;id_conf=$id_conf&amp;id_cons_gen=$id_cons_gen&amp;min=$min\">"._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"center\"></a>]";
146 else
147 echo "["._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"center\"></a>]";
148 echo "</td></tr>";
149 }
150 echo "</table></center>";
151
152// #'Pagina precedente' e 'Pagina Successiva'
153
154 echo"<table align=\"center\" width=\"100%\" ><tr>";
155 $prev=$min-$offset;
156 if ($prev>=0) {
157 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=confconsiglio&amp;id_conf=$id_conf&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;min=$prev\">";
158 echo "<b>$offset "._PREV_MATCH."</b></a></td>";
159 }
160
161 $next=$min+$offset;
162 if ($next>=($offset-1)) {
163 if($next>=$max) $next = $max;
164 else {
165 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=confconsiglio&amp;id_conf=$id_conf&amp;id_cons_gen=$id_cons_gen&amp;min=$next\">";
166 echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
167 }
168 }
169 echo "</tr></table><br>";
170
171 }
172
173//***********************************************************
174//Funzione di inserimento e gestione dei gruppi
175//************************************************************
176
177function confcons($ok, $do) {
178 global $prefix, $dbi, $id_cons,$simbolo2,$genere,$id_cons_gen,$id_comune,$min,$id_conf,$descrizione, $limite,$consin,$infpremio,$listinfsbar,$infminpremio,$listinfconta,$supsbarramento,$suppremio,$supminpremio,$listsupconta;
179 $aid=$_SESSION['aid'];
180 $perms=ChiSei($id_cons_gen);
181 if ($perms >128) {
182 if ($do == "delete") {
183 if ($ok !="1") {
184 ele();
185 echo "<center><br><br>"._DOMCANCELLA." "._DESCR." $descrizione ?<br>";
186 echo "[ <a href=\"admin.php?op=confconsiglio&amp;id_cons_gen=$id_cons_gen&amp;id_conf=$id_conf\">"._NO."</a> ] - [<a href=\"admin.php?op=confconsiglio&amp;do=delete&amp;id_conf=$id_conf&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;ok=1\">"._YES."</a> ]";exit;
187 }else{
188 $sql="delete from ".$prefix."_ele_conf where id_conf='$id_conf'";
189 $result = $dbi->prepare("$sql");
190 $result->execute();
191 if (!$result->rowCount()) return;
192 Header("Location: admin.php?op=confconsiglio&id_cons_gen=$id_cons_gen&id_conf=$id_conf&min=$min");
193 }
194 } elseif ($do == "add") {
195 if ($descrizione) {
196 $sqlset='';
197 $sql="insert into ".$prefix."_ele_conf(id_conf,descrizione, limite,consin,infpremio,supsbarramento,suppremio,listinfsbar,listinfconta,listsupconta,infminpremio,supminpremio) values ('$id_conf','$descrizione','$limite','$consin','$infpremio','$supsbarramento','$suppremio','$listinfsbar','$listinfconta','$listsupconta','$infminpremio','$supminpremio')";
198 $result = $dbi->prepare("$sql");
199 $result->execute();
200 if (!$result->rowCount()) return;
201 Header("Location: admin.php?op=confconsiglio&id_cons_gen=$id_cons_gen&min=$min");
202 } else {
203 ele();
204 OpenTable();
205 echo "<center>"._GESTIONE." "._CONF." ";
206 echo "<br><br><a href=\"admin.php?op=confconsiglio&amp;id_cons_gen=$id_cons_gen\">"._IMM." "._CONF."</a></center>";
207 CloseTable();
208 }
209 } elseif ($do == "update") {
210 $sql="update ".$prefix."_ele_conf set descrizione='$descrizione', limite='$limite', consin='$consin', infpremio='$infpremio', supsbarramento='$supsbarramento', suppremio='$suppremio', listinfsbar='$listinfsbar', listinfconta='$listinfconta', listsupconta='$listsupconta', infminpremio='$infminpremio', supminpremio='$supminpremio' where id_conf='$id_conf' ";
211 $result = $dbi->prepare("$sql");
212 $result->execute();
213 Header("Location: admin.php?op=confconsiglio&id_cons_gen=$id_cons_gen&min=$min");
214 }
215
216 }
217}
218
219if ($do and $do!="modify")
220 confcons($ok, $do);
221ele();
222all();
223echo"</td></tr></table>";
224include("footer.php");
225
226
227
228
229?>
230
Note: See TracBrowser for help on using the repository browser.