source: trunk/admin/modules/Elezioni/ele_circo.php@ 382

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

Segue modifiche per la compatibilità php7.x

File size: 8.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 Circoscrizioni */
9/* Amministrazione */
10/************************************************************************/
11
12if (!defined('ADMIN_FILE')) {
13 die ("You can't access this file directly...");
14}
15global $dbi;
16$aid=$_SESSION['aid'];
17$prefix=$_SESSION['prefix'];
18$currentlang=$_SESSION['lang'];
19
20$id_comune=$_SESSION['id_comune'];
21$id_cons_gen=$_GET['id_cons_gen'];
22$perms=ChiSei($id_cons_gen);
23if ($perms<16 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
24
25$sql="SELECT t1.tipo_cons,t1.descrizione,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'";
26$res = $dbi->prepare("$sql");
27$res->execute();
28list($tipo_cons,$descr_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM);
29include("modules/Elezioni/funzionidata.php");
30include("modules/Elezioni/ele.php");
31// Offset - visualizza il numero di elementi per pagina
32if (isset($_GET['do'])) $do=addslashes($param['do']); else $do='';
33if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0;
34if (isset($_GET['id_circ'])) $id_circ=intval($_GET['id_circ']); else $id_circ='';
35if (isset($_GET['ok'])) $ok=intval($_GET['ok']); else $ok='';
36if (isset($_GET['num_circ'])) $num_circ=intval($_GET['num_circ']); else $num_circ='';
37if (isset($_GET['descr_circ'])) $descr_circ=addslashes($param['descr_circ']); else $descr_circ='';
38$offset=10;
39$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
40
41
42/******************************************************/
43/*Funzione di visualizzazione globale */
44/*****************************************************/
45
46function all() {
47 global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $id_cons,$id_cons_gen,$do,$id_circ;
48 echo "<center><font class=\"title\"><br><b>"._CIRCO."</b></font><br><br>";
49 echo "<form name=\"circo\" action=\"admin.php\">"
50 ."<input type=\"hidden\" name=\"op\" value=\"circo\">"
51 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
52 echo "<table border=\"0\" width=\"100%\"><tr>";
53 echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"5%\"><b>"._NUM."</b></td>"
54 ."<td bgcolor=\"$bgcolor1\" align=\"center\">&nbsp;<b>"._DESCR."</b>&nbsp;</td>"
55 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
56
57 if ($do == "modify"){
58 $sql = "SELECT * FROM ".$prefix."_ele_circoscrizione where id_circ='$id_circ'";
59 $res = $dbi->prepare("$sql");
60 $res->execute();
61 $pro= $res->fetch(PDO::FETCH_BOTH);
62 echo "<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
63 ."<input type=\"hidden\" name=\"do\" value=\"update\">";
64 echo "<tr><td align=\"right\"><input name=\"num_circ\" value=\"$pro[num_circ]\" size=\"3\"></td>";
65 echo "<td><input type=\"text\" name=\"descr_circ\" value=\"$pro[descrizione]\"maxlength=\"100\" size=\"40\"></td>"
66 ."<td align=\"center\"><input type=\"submit\" name=\"update\" value=\""._MODIFY."\"></td></tr>";
67 } else {
68 $sql = "select max(num_circ) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons'";
69 $result = $dbi->prepare("$sql");
70 $result->execute();
71 list($numc)=$result->fetch(PDO::FETCH_NUM);
72 $numc++;
73 echo "<tr><td align=\"right\"><input type=\"hidden\" name=\"do\" value=\"add\"><input type=\"text\" name=\"num_circ\" maxlength=\"3\" size=\"3\" value=\"$numc\"></td>"
74 ."<td><input type=\"text\" name=\"descr_circ\" maxlength=\"100\" size=\"40\"></td>";
75 echo "<td align=\"center\"><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr>";
76 }
77 $sql = "SELECT * FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
78 $res = $dbi->prepare("$sql");
79 $res->execute();
80 $max = $res->rowCount();
81 $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ORDER BY num_circ LIMIT $min,$offset";
82 $result = $dbi->prepare("$sql");
83 $result->execute();
84 while(list($id_cons2, $id_circ, $num_sez, $descr_circ) = $result->fetch(PDO::FETCH_NUM)) {
85 $sql="select count(0) from ".$prefix."_ele_sede where id_circ='$id_circ'";
86 $restemp = $dbi->prepare("$sql");
87 $restemp->execute();
88 list($numtemp)=$restemp->fetch(PDO::FETCH_NUM);
89 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
90 echo "<tr bgcolor=\"$bgcolor1\"><td align=\"right\"width=\"5%\"><b>$num_sez</b>"
91 ."</td><td align=\"left\"><b>$descr_circ</b>"
92 ."</td><td align=\"center\" nowrap>[<a
93 href=\"admin.php?op=circo&amp;do=modify&amp;id_circ=$id_circ&amp;id_cons=$id_cons&amp;id_cons_gen=$id_cons_gen\"><img src=\"modules/Elezioni/images/edit.gif\"
94 border=\"0\" align=\"middle\" alt=\"edit\"> "._EDIT."</a>]";
95 if (!$numtemp)
96 echo "[<a href=\"admin.php?op=circo&amp;do=delete&amp;id_circ=$id_circ&amp;descr_circ=$descr_circ&amp;id_cons=$id_cons&amp;id_cons_gen=$id_cons_gen\">"._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"center\" alt=\"delete\"></a>]";
97 else
98 echo "["._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"middle\" alt=\"delete\">]";
99 echo "</td></tr>";
100 }
101 echo "</table></form></center>";
102 #'Pagina precedente' e 'Pagina Successiva'
103 if ($max>$offset){
104 echo"<table align=\"center\" width=\"100%\" ><tr>";
105 $prev=$min-$offset;
106 if ($prev>=0) {
107 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=circo&amp;id_cons=$id_cons&amp;min=$prev&amp;id_cons_gen=$id_cons_gen\">";
108 echo "<b>$offset "._PREV_MATCH."</b></a></td>";
109 }
110
111 $next=$min+$offset;
112 if ($next>=($offset-1)) {
113 if($next>=$max) $next = $max;
114 else {
115 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=circo&amp;id_cons=$id_cons&amp;min=$next&amp;id_cons_gen=$id_cons_gen\">";
116 echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
117 }
118 }
119 echo "</tr></table><br>";
120 }
121
122}
123
124
125
126//***********************************
127// Consultazione
128// ricordarsi di aggiungere l'eliminazione di tutti
129// i dati della consultazione nelle altre tabelle
130// hai capito?
131//***********************************
132
133function circo($ok, $do, $id_cons ,$num_circ,$descr_cons, $id_circ, $descr_circ) {
134global $aid, $prefix, $dbi, $id_cons_gen;
135$perms= ChiSei($id_cons_gen);
136if ($perms>16) {
137 if ($do == "delete") {
138 if ($ok !="1") {
139 ele();
140 echo "<center><br><br>"._DOMCANCELLA." $descr_circ ?<br>";
141 echo "[ <a href=\"admin.php?op=circo&amp;id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=circo&amp;do=delete&amp;id_circ=$id_circ&amp;ok=1&amp;id_cons_gen=$id_cons_gen\">"._YES."</a> ]";
142 include("footer.php");
143 die();
144 }else{
145 $sql="select num_circ from ".$prefix."_ele_circoscrizione where id_circ=$id_circ";
146 $rescirc = $dbi->prepare("$sql");
147 $rescirc->execute();
148 if ($rescirc->rowCount()!=1) die("(1001) Grave errore nel database! contattare l'amministratore");
149 list($num_circ)=$rescirc->fetch(PDO::FETCH_NUM);
150 $sql="delete from ".$prefix."_ele_circoscrizione where id_circ='$id_circ'";
151 $result = $dbi->prepare("$sql");
152 $result->execute();
153 $sql="select id_circ,num_circ from ".$prefix."_ele_circoscrizione where num_circ>$num_circ and id_cons=$id_cons";
154 $rescirc = $dbi->prepare("$sql");
155 $rescirc->execute();
156 while (list($tmp_id,$tmp_num)=$rescirc->fetch(PDO::FETCH_NUM)){
157 $sql="update ".$prefix."_ele_circoscrizione set num_circ=".($tmp_num-1)." where id_circ=$tmp_id";
158 $result = $dbi->prepare("$sql");
159 $result->execute();
160 }
161 Header("Location: admin.php?op=circo&id_cons_gen=$id_cons_gen");
162 }
163 }elseif ($do == "add") {
164 if ($descr_circ) {
165 $sql="insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons','$num_circ','$descr_circ')";
166 $result = $dbi->prepare("$sql");
167 $result->execute();
168 Header("Location: admin.php?op=circo&id_cons_gen=$id_cons_gen");
169 }
170 }elseif ($do == "update") {
171
172 $sql="update ".$prefix."_ele_circoscrizione set num_circ='$num_circ' , descrizione='$descr_circ' WHERE id_circ='$id_circ'";
173 $result = $dbi->prepare("$sql");
174 $result->execute();
175 Header("Location: admin.php?op=circo&id_cons_gen=$id_cons_gen");
176 }
177
178
179}
180
181}
182
183
184if ($do!= "")
185 circo($ok,$do, $id_cons,$num_circ,$descr_cons,$id_circ,$descr_circ);
186ele();
187all();
188echo"</td></tr></table>";
189include("footer.php");
190?>
191
Note: See TracBrowser for help on using the repository browser.