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

Last change on this file since 22 was 2, checked in by root, 15 years ago

importo il progetto

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