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

Last change on this file since 418 was 344, checked in by roby, 4 years ago

Segue modifiche per la compatibilità php7.x

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