[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 Consultazioni */
|
---|
| 9 | /* Amministrazione */
|
---|
| 10 | /************************************************************************/
|
---|
| 11 | if (!defined('ADMIN_FILE')) {
|
---|
| 12 | die ("You can't access this file directly...");
|
---|
| 13 | }
|
---|
[257] | 14 | global $dbi;
|
---|
[2] | 15 | $aid=$_SESSION['aid'];
|
---|
| 16 | $prefix=$_SESSION['prefix'];
|
---|
| 17 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
| 18 | $id_cons_gen=$param['id_cons_gen'];
|
---|
| 19 | $perms=ChiSei(0);
|
---|
| 20 | //if ($perms<128 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
| 21 | if ($perms!=256) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
[257] | 22 | $sql="SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen=$id_cons_gen ";
|
---|
| 23 | $res = $dbi->prepare("$sql");
|
---|
| 24 | $res->execute();
|
---|
| 25 | list($tipo_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 26 |
|
---|
| 27 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
| 28 | if (isset($param['ok'])) $ok=intval($param['ok']); else $ok=0;
|
---|
[344] | 29 | if (isset($param['do'])) $do=addslashes($param['do']); else $do='';
|
---|
| 30 | if (isset($param['referendum'])) $referendum=addslashes($param['referendum']); else $referendum='';
|
---|
| 31 | if (isset($param['liste'])) $liste=addslashes($param['liste']); else $liste='';
|
---|
| 32 | if (isset($param['gruppi'])) $gruppi=addslashes($param['gruppi']); else $gruppi='';
|
---|
| 33 | if (isset($param['votigruppo'])) $votigruppo=addslashes($param['votigruppo']); else $votigruppo='';
|
---|
| 34 | if (isset($param['votilista'])) $votilista=addslashes($param['votilista']); else $votilista='';
|
---|
| 35 | if (isset($param['voticandi'])) $voticandi=addslashes($param['voticandi']); else $voticandi='';
|
---|
| 36 | if (isset($param['ballo'])) $ballo=addslashes($param['ballo']); else $ballo='';
|
---|
| 37 | if (isset($param['circo'])) $circo=addslashes($param['circo']); else $circo='';
|
---|
| 38 | if (isset($param['descr_cons2'])) $descr_cons2=addslashes($param['descr_cons2']); else $descr_cons2='';
|
---|
| 39 | if (isset($param['tipocons'])) $tipocons=addslashes($param['tipocons']); else $tipocons=$tipo_cons;
|
---|
[54] | 40 | if (isset($param['help'])) $help=intval($param['help']);
|
---|
[2] | 41 |
|
---|
| 42 | $id_comune=$_SESSION['id_comune'];
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | include("modules/Elezioni/funzionidata.php");
|
---|
| 46 | include("modules/Elezioni/ele.php");
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | // Offset - visualizza il numero di elementi per pagina
|
---|
| 50 |
|
---|
| 51 | $offset=10;
|
---|
| 52 | if (!isset($min)) $min=0;
|
---|
| 53 |
|
---|
| 54 | /******************************************************/
|
---|
| 55 | /*Funzione di visualizzazione globale */
|
---|
| 56 | /*****************************************************/
|
---|
| 57 |
|
---|
| 58 | function all() {
|
---|
[54] | 59 | global $genere, $bgcolor1, $bgcolor2, $bgcolor6, $prefix, $dbi, $offset, $min, $id_cons_gen, $perms,$tipo_cons, $tipocons,$do, $help;
|
---|
[2] | 60 | $language=$_SESSION['lang'];
|
---|
| 61 | if (($perms>64)) {
|
---|
[54] | 62 | if (isset($help)) include("language/$language/ele_consultazionitipi.html");
|
---|
[2] | 63 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
| 64 | ."//-->\n";
|
---|
| 65 | echo "function scegli_ref() {\n";
|
---|
| 66 | echo "if (document.consultazione.referendum.checked==true) {\n";
|
---|
| 67 | echo "document.consultazione.gruppi.checked=false \n";
|
---|
| 68 | echo "document.consultazione.votigruppo.checked=false \n";
|
---|
| 69 | echo "document.consultazione.votilista.checked=false \n";
|
---|
| 70 | echo "document.consultazione.voticandi.checked=false \n";
|
---|
| 71 | echo "document.consultazione.circo.checked=false \n";
|
---|
| 72 | echo "document.consultazione.liste.checked=false \n";
|
---|
| 73 | echo "document.consultazione.ballo.checked=false }\n";
|
---|
| 74 | echo "}\n";
|
---|
| 75 | echo "function scegli_cons() {\n";
|
---|
| 76 | echo "if (document.consultazione.gruppi.checked==true || document.consultazione.circo.checked==true || document.consultazione.liste.checked==true || document.consultazione.votilista.checked==true || document.consultazione.voticandi.checked==true) {\n";
|
---|
| 77 | echo "document.consultazione.referendum.checked=false \n";
|
---|
| 78 | echo "document.consultazione.ballo.checked=false }\n";
|
---|
| 79 | echo "if (document.consultazione.gruppi.checked==false) {\n";
|
---|
| 80 | echo "document.consultazione.votigruppo.checked=false }\n";
|
---|
| 81 | echo "}\n";
|
---|
| 82 | echo "function scegli_ballo() {\n";
|
---|
| 83 | echo "if (document.consultazione.ballo.checked==true) {\n";
|
---|
| 84 | echo "document.consultazione.votigruppo.checked=false \n";
|
---|
| 85 | echo "document.consultazione.votilista.checked=false \n";
|
---|
| 86 | echo "document.consultazione.voticandi.checked=false \n";
|
---|
| 87 | echo "document.consultazione.gruppi.checked=false \n";
|
---|
| 88 | echo "document.consultazione.circo.checked=false \n";
|
---|
| 89 | echo "document.consultazione.referendum.checked=false \n";
|
---|
| 90 | echo "document.consultazione.liste.checked=false }\n";
|
---|
| 91 | echo "}\n";
|
---|
| 92 | echo "</script>\n";
|
---|
| 93 | if ($do == "modify") {
|
---|
[257] | 94 | $sql="SELECT * FROM ".$prefix."_ele_tipo where tipo_cons='$tipocons' and lingua='$language'";
|
---|
| 95 | $rest = $dbi->prepare("$sql");
|
---|
| 96 | $rest->execute();
|
---|
| 97 | $pro_t=$rest->fetch(PDO::FETCH_BOTH);
|
---|
[2] | 98 |
|
---|
| 99 | echo "<form name=\"consultazione\" method=\"post\" action=\"admin.php\" >"
|
---|
| 100 | ."<input type=\"hidden\" name=\"op\" value=\"constipi\">"
|
---|
| 101 | ."<input type=\"hidden\" name=\"do\" value=\"update\">"
|
---|
| 102 | ."<input type=\"hidden\" name=\"tipocons\" value=\"$tipocons\">"
|
---|
| 103 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
| 104 | ."<table width=\"100%\">"._MODIFY." ".$pro_t['descrizione']." <br><br>";
|
---|
| 105 | switch ($pro_t['genere']) {
|
---|
| 106 | case "0" : $gencons=_GENCONS0;break;
|
---|
| 107 | case "1" : $gencons=_GENCONS1;break;
|
---|
| 108 | case "2" : $gencons=_GENCONS2;break;
|
---|
| 109 | case "3" : $gencons=_GENCONS3;break;
|
---|
| 110 | case "4" : $gencons=_GENCONS4;break;
|
---|
| 111 | case "5" : {
|
---|
| 112 | if (!$pro_t['voto_g'] and !$pro_t['voto_c']) $gencons=_GENCONS5;
|
---|
[254] | 113 | elseif (!$pro_t['voto_g'] and $pro_t['voto_c']) $gencons=_GENCONS3;
|
---|
[2] | 114 | else $gencons=_GENCONS6;
|
---|
| 115 | break;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | default :$gencons="";
|
---|
| 119 | }
|
---|
| 120 | echo "<tr><td>"._TIPO."</td><td>$gencons</td></tr>";
|
---|
| 121 | echo "<tr bgcolor=\"$bgcolor2\"><td>"._DESCR. "</td><td><input name=\"descr_cons2\" value=\"".$pro_t['descrizione']."\" size=\"15\"></td></tr>";
|
---|
| 122 |
|
---|
| 123 | echo "<tr><td>"
|
---|
| 124 | ."<input type=\"submit\" name=\"update\" value=\""._MODIFY."\">"
|
---|
| 125 | ."</form></td></tr></table>";
|
---|
| 126 | } else {
|
---|
| 127 | echo "<form name=\"consultazione\" action=\"admin.php\">"
|
---|
| 128 | ."<input type=\"hidden\" name=\"op\" value=\"constipi\">"
|
---|
| 129 | ."<input type=\"hidden\" name=\"tipocons\" value=\"$tipocons\">"
|
---|
| 130 | ."<input type=\"hidden\" name=\"do\" value=\"add\">"
|
---|
| 131 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
| 132 | ."<table whidth=\"100%\"><hr><h6>"._ADD." "._TIPO."<br><br>";
|
---|
| 133 | echo _DEFCONS.":<br>";
|
---|
| 134 | echo "<input type=\"checkbox\" name=\"referendum\" value=\"true\" onClick=\"scegli_ref()\"> "._REFERENDUM." <br>"
|
---|
| 135 | ."<input type=\"checkbox\" name=\"gruppi\" value=\"true\" onClick=\"scegli_cons()\"> "._CON_GRUPPI."<br> "
|
---|
| 136 | ." <input type=\"checkbox\" name=\"votigruppo\" value=\"true\" onClick=\"scegli_cons()\"> "._NO_VOTO_GRUPPO."<br> "
|
---|
| 137 | ."<br><input type=\"checkbox\" name=\"liste\" value=\"true\" onClick=\"scegli_cons()\"> "._LISTE_UNI."<br>"
|
---|
| 138 | ." <input type=\"checkbox\" name=\"votilista\" value=\"true\" onClick=\"scegli_cons()\"> "._NO_VOTO_LISTA."<br> "
|
---|
| 139 | ." <input type=\"checkbox\" name=\"voticandi\" value=\"true\" onClick=\"scegli_cons()\"> "._NO_VOTO_CANDI."<br> "
|
---|
| 140 | ."<input type=\"checkbox\" name=\"circo\" value=\"true\" onClick=\"scegli_cons()\"> "._ELE_CIRCO."<br>"
|
---|
| 141 | ."<input type=\"checkbox\" name=\"ballo\" value=\"true\" onClick=\"scegli_ballo()\"> "._BALLO."<br></h6>";
|
---|
| 142 |
|
---|
| 143 | # echo "<tr><td>";
|
---|
| 144 |
|
---|
| 145 | echo "<tr><td><b>"._DESCR. "</b></td><td><input type=\"text\" name=\"descr_cons2\" maxlength=\"100\"></td></tr>";
|
---|
| 146 | echo "</td></tr>"
|
---|
| 147 | ."</table>"
|
---|
| 148 | ."<input type=\"submit\" name=\"add\" value=\""._ADD."\">"
|
---|
| 149 | ."</form>";
|
---|
| 150 | }
|
---|
| 151 | echo "<center><font class=\"title\"><b>"._MODIFY." "._TIPO."</b></font><br><br><table border=\"0\" width=\"100%\">"
|
---|
| 152 | ."<tr><td bgcolor=\"$bgcolor1\" align=\"center\"> <b>"._NUM."</b> </td><td bgcolor=\"$bgcolor1\" align=\"center\"> <b>"._DESCR."</b> </td>"
|
---|
| 153 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
|
---|
| 154 |
|
---|
[257] | 155 | $sql="SELECT tipo_cons,descrizione FROM ".$prefix."_ele_tipo where lingua='$language' LIMIT $min,$offset";
|
---|
| 156 | $result = $dbi->prepare("$sql");
|
---|
| 157 | $result->execute();
|
---|
| 158 | while(list($tipocons, $descr_cons) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
[2] | 159 |
|
---|
| 160 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
| 161 | echo "<tr ><td align=\"center\" >$tipocons</td><td bgcolor=\"$bgcolor1\" align=\"left\" ><b>$descr_cons</b></a>"
|
---|
| 162 | ."</td><td align=\"center\" nowrap bgcolor=\"$bgcolor1\">[<a
|
---|
| 163 | href=\"admin.php?op=constipi&do=modify&id_cons_gen=$id_cons_gen&tipocons=$tipocons\"><img src=\"modules/Elezioni/images/edit.gif\"
|
---|
| 164 | border=\"0\" align=\"middle\"> "._EDIT."</a>]"
|
---|
| 165 | ."</td></tr>";
|
---|
| 166 | }
|
---|
| 167 | echo "</table></center>";
|
---|
| 168 | #'Pagina precedente' e 'Pagina Successiva'
|
---|
| 169 | echo"<table align=\"center\" width=\"100%\" bgcolor=\"$bgcolor1\"><tr>";
|
---|
| 170 | $prev=$min-$offset;
|
---|
| 171 | if ($prev>=0) {
|
---|
| 172 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor2\"><a href=\"admin.php?op=constipi&id_cons_gen=$id_cons_gen&min=$prev\">";
|
---|
| 173 | echo "<b>$offset "._PREV_MATCH."</b></a></td>";
|
---|
| 174 | }
|
---|
| 175 | $next=$min+$offset;
|
---|
[257] | 176 | $sql="SELECT * FROM ".$prefix."_ele_tipo where lingua='$language' ";
|
---|
| 177 | $res = $dbi->prepare("$sql");
|
---|
| 178 | $res->execute();
|
---|
| 179 | $max = $res->rowCount();
|
---|
[2] | 180 | if ($next>=($offset-1)) {
|
---|
| 181 | if($next>=$max) $next = $max;
|
---|
| 182 | else {
|
---|
| 183 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor2\"><a href=\"admin.php?op=constipi&id_cons_gen=$id_cons_gen&min=$next\">";
|
---|
| 184 | echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
|
---|
| 185 | }
|
---|
| 186 | }
|
---|
| 187 | echo "</tr></table><br>";
|
---|
| 188 | }
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 |
|
---|
| 192 |
|
---|
| 193 | function tipo() {
|
---|
| 194 | global $id_cons_gen,$bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons2,$tipocons,$perms,$do,$votigruppo,$votilista,$voticandi,$circo, $referendum,$ballo,$liste,$gruppi;
|
---|
| 195 | $language=$_SESSION['lang'];
|
---|
| 196 |
|
---|
| 197 | if ($perms==256) {
|
---|
| 198 | if ($do == "add") {
|
---|
| 199 | if ($tipocons) {
|
---|
| 200 | if($referendum=='true') {
|
---|
| 201 | $genere=0;
|
---|
| 202 | } elseif ($ballo=='true') {
|
---|
| 203 | $genere=1;
|
---|
| 204 | }else{
|
---|
| 205 | $genere=2;
|
---|
| 206 | if($liste!='true') {$genere+=2;}
|
---|
| 207 | if($gruppi=='true') {$genere+=1;}
|
---|
| 208 | }
|
---|
| 209 | $votigruppo=$votigruppo=='true'? 1:0;
|
---|
| 210 | $votilista=$votilista=='true'? 1:0;
|
---|
| 211 | $voticandi=$voticandi=='true'? 1:0;
|
---|
| 212 | $circo=$circo=='true'? 1:0;
|
---|
[257] | 213 | $sql="select max(tipo_cons) from ".$prefix."_ele_tipo where lingua='$language'";
|
---|
| 214 | $result = $dbi->prepare("$sql");
|
---|
| 215 | $result->execute();
|
---|
| 216 | list($max)=$result->fetch(PDO::FETCH_NUM);
|
---|
[2] | 217 | $max++;
|
---|
| 218 |
|
---|
[257] | 219 | $sql="insert into ".$prefix."_ele_tipo (tipo_cons,descrizione,lingua,genere,voto_g,voto_l,voto_c,circo) values ('$max','$descr_cons2','$language','$genere','$votigruppo','$votilista','$voticandi','$circo')";
|
---|
| 220 | $result = $dbi->prepare("$sql");
|
---|
| 221 | $result->execute();
|
---|
[2] | 222 |
|
---|
| 223 |
|
---|
| 224 | }
|
---|
| 225 | }else if ($do == "update") {
|
---|
[257] | 226 | $sql="update ".$prefix."_ele_tipo set descrizione='$descr_cons2' WHERE tipo_cons='$tipocons' and lingua='$language'";
|
---|
| 227 | $result = $dbi->prepare("$sql");
|
---|
| 228 | $result->execute();
|
---|
| 229 | if (!$result->rowCount()) return;
|
---|
[2] | 230 | Header("Location: admin.php?op=constipi&id_cons_gen=$id_cons_gen");
|
---|
| 231 | }
|
---|
| 232 | }
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | function help_cons()
|
---|
| 236 | {
|
---|
| 237 | //da mettere
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | if (isset($do))
|
---|
| 241 | tipo();
|
---|
| 242 | ele();
|
---|
| 243 | all();
|
---|
| 244 | echo"</td></tr></table>";
|
---|
| 245 | include("footer.php");
|
---|
| 246 |
|
---|
| 247 |
|
---|
| 248 |
|
---|
| 249 | ?>
|
---|
| 250 |
|
---|