[2] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | /************************************************************************/
|
---|
| 4 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 5 | /* by Roberto Gigli & Luciano Apolito */
|
---|
| 6 | /* http://www.eleonline.it */
|
---|
| 7 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
| 8 | /************************************************************************/
|
---|
| 9 | /* Modulo Autorizzazione Comuni */
|
---|
| 10 | /* Amministrazione */
|
---|
| 11 | /************************************************************************/
|
---|
| 12 | # e' l'unico file in cui Ú presente un controllo su tipo_cons, per ora va bene così. Per toglierlo va inserito un campo-flag in ele_tipo per indicare se per il tipo di consultazione si dovra' procedere al calcolo dell'assegnazione dei seggi
|
---|
| 13 | if (!defined('ADMIN_FILE')) {
|
---|
| 14 | die ("You can't access this file directly...");
|
---|
| 15 | }
|
---|
[257] | 16 | global $dbi;
|
---|
[2] | 17 | $aid=$_SESSION['aid'];
|
---|
| 18 | $prefix=$_SESSION['prefix'];
|
---|
| 19 | $id_comune=$_SESSION['id_comune'];
|
---|
[282] | 20 | $sql = $dbi->prepare("SELECT * FROM ".$prefix."_config");
|
---|
| 21 | $sql->execute();
|
---|
| 22 | $riga = $sql->fetchAll(PDO::FETCH_ASSOC);
|
---|
| 23 | $row=$riga[0];
|
---|
| 24 | $language = $row['language'];
|
---|
[2] | 25 | $id_cons_gen=intval($_GET['id_cons_gen']);
|
---|
| 26 | $perms=ChiSei(0);
|
---|
| 27 | if ($perms<128 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
[257] | 28 | $sql="SELECT t1.tipo_cons,t1.descrizione,t2.id_cons,t2.id_conf FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune='$id_comune' ";
|
---|
| 29 | $res = $dbi->prepare("$sql");
|
---|
| 30 | $res->execute();
|
---|
| 31 | # $gru = $sth->fetch(PDO::FETCH_BOTH);
|
---|
| 32 | list($tipo_cons,$descr_cons,$id_cons,$id_conf) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 33 |
|
---|
[257] | 34 | $sql="SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
|
---|
| 35 | $res = $dbi->prepare("$sql");
|
---|
| 36 | $res->execute();
|
---|
| 37 | list($genere) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 38 |
|
---|
| 39 | include("modules/Elezioni/funzionidata.php");
|
---|
| 40 | include("modules/Elezioni/ele.php");
|
---|
| 41 | if (isset($_GET['descr_comu'])) get_magic_quotes_gpc() ? $descr_comu=$param['descr_comu']:$descr_comu=addslashes($param['descr_comu']); else $descr_comu='';
|
---|
| 42 | if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
| 43 | if (isset($_GET['ok'])) $ok=intval($_GET['ok']); else $ok='';
|
---|
[282] | 44 | if (isset($_GET['id_cons_comu'])) $id_cons_comu=intval($_GET['id_cons_comu']); else $id_cons_comu='0';
|
---|
| 45 | if (isset($_GET['id_collegio'])) $id_collegio=intval($_GET['id_collegio']); else $id_collegio='0';
|
---|
[2] | 46 | if (isset($_GET['idcomune'])) $idcomune=intval($_GET['idcomune']); else $idcomune='';
|
---|
[282] | 47 | if (isset($_GET['idcomunenew'])) $idcomunenew=intval($_GET['idcomunenew']); else $idcomunenew='0';
|
---|
| 48 | if (isset($_GET['chiusa'])) $chiusa=intval($_GET['chiusa']); else $chiusa='0';
|
---|
[2] | 49 | if (isset($_GET['id_conf'])) $id_conf=intval($_GET['id_conf']); else $id_conf=0;
|
---|
[189] | 50 | if (isset($_GET['idfascia'])) $idfascia=intval($_GET['idfascia']); else $idfascia=0;
|
---|
[2] | 51 | if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0;
|
---|
[282] | 52 | if (isset($_GET['help'])) $help=intval($_GET['help']); else $help='';
|
---|
| 53 | if (isset($_GET['pwd4'])) $pwd4=intval($_GET['pwd4']); else $pwd4='';
|
---|
[185] | 54 | if (isset($_GET['preferenze'])) $preferenze=intval($_GET['preferenze']); else $preferenze=1;
|
---|
[189] | 55 | if (isset($_GET['vismf'])) $vismf=intval($_GET['vismf']); else $vismf=0;
|
---|
[235] | 56 | if (isset($_GET['sg'])) $sg=intval($_GET['sg']); else $sg=0;
|
---|
[254] | 57 | if (isset($_GET['disgiunto'])) $disgiunto=intval($_GET['disgiunto']); else $disgiunto=0;
|
---|
[2] | 58 |
|
---|
| 59 | $offset=15;
|
---|
| 60 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | /******************************************************/
|
---|
| 64 | /*Funzione di visualizzazione globale */
|
---|
| 65 | /*****************************************************/
|
---|
[77] | 66 | //
|
---|
[2] | 67 | function all() {
|
---|
[315] | 68 | global $user, $admin, $bgcolor1, $bgcolor2, $prefix,$descr_cons, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$id_cons_gen,$id_collegio,$idcomune,$chiusa,$id_conf,$tipo_cons,$language,$help,$preferenze,$idfascia,$vismf,$sg,$disgiunto,$id_cons_comu,$genere;
|
---|
[2] | 69 | $aid=$_SESSION['aid'];
|
---|
[86] | 70 | $prefix=$_SESSION['prefix'];
|
---|
| 71 | ############# Controllo flag per cancellazione consultazione
|
---|
[87] | 72 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
| 73 | ."//-->\n";
|
---|
| 74 | echo "function del_cons() {\n";
|
---|
| 75 | echo "if (document.getElementById('pwd3').checked==false) {\n";
|
---|
| 76 | echo "if (document.getElementById('chiusa').selectedIndex==3) document.getElementById('chiusa').options[0].selected=true \n";
|
---|
| 77 | echo "document.getElementById('pwd4').checked=false \n";
|
---|
| 78 | echo "document.getElementById('trspunta').style.visibility='hidden' \n";
|
---|
| 79 | echo "} \n";
|
---|
| 80 | echo "else document.getElementById('trspunta').style.visibility='visible' \n";
|
---|
| 81 | echo "if (document.getElementById('chiusa').selectedIndex!=3) { \n";
|
---|
| 82 | echo "document.getElementById('add').value=\""._MODIFY."\" \n";
|
---|
| 83 | echo "document.getElementById('do').value=\"update\" \n";
|
---|
| 84 | echo "}else{\n";
|
---|
| 85 | echo "if (document.getElementById('pwd4').checked==false) \n";
|
---|
| 86 | echo "document.getElementById('add').value=\""._DELETE." "._DATI."\" \n";
|
---|
| 87 | echo "else document.getElementById('add').value=\""._DELETE." "._CONSULTA."\" \n";
|
---|
| 88 | echo "document.getElementById('do').value=\"delete\" \n";
|
---|
| 89 | echo "} \n";
|
---|
| 90 | echo "} \n";
|
---|
| 91 | echo "</script>\n";
|
---|
| 92 |
|
---|
[192] | 93 | echo "<script type=\"text/javascript\" language=\"JavaScript\" >\n\n<!--\n"
|
---|
| 94 | ."//-->\n";
|
---|
| 95 | echo "function showdate(str,posiz,tempo)\n";
|
---|
| 96 | echo "{\n";
|
---|
| 97 | echo "if (str==\"\")\n";
|
---|
| 98 | echo " {\n";
|
---|
| 99 | echo " document.getElementById(posiz).innerHTML=\"\";\n";
|
---|
| 100 | echo " return;\n";
|
---|
| 101 | echo " }\n";
|
---|
| 102 | echo "if (window.XMLHttpRequest)\n";
|
---|
| 103 | echo " {// code for IE7+, Firefox, Chrome, Opera, Safari\n";
|
---|
| 104 | echo " xmlhttp=new XMLHttpRequest();\n";
|
---|
| 105 | echo " }\n";
|
---|
| 106 | echo "else\n";
|
---|
| 107 | echo " {// code for IE6, IE5\n";
|
---|
| 108 | echo " xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
|
---|
| 109 | echo " }\n";
|
---|
| 110 | echo "xmlhttp.onreadystatechange=function()\n";
|
---|
| 111 | echo " {\n";
|
---|
| 112 | echo " if (xmlhttp.readyState==4 && xmlhttp.status==200 && posiz!=null)\n";
|
---|
| 113 | echo " {\n";
|
---|
| 114 | echo " document.getElementById(posiz).innerHTML=xmlhttp.responseText;\n";
|
---|
| 115 | echo " }\n";
|
---|
| 116 | echo " }\n";
|
---|
| 117 | echo "xmlhttp.open(\"GET\",str,true);\n";
|
---|
| 118 | echo "xmlhttp.send();\n";
|
---|
[87] | 119 |
|
---|
[192] | 120 | echo "}\n";
|
---|
| 121 | echo "</script>\n";
|
---|
| 122 |
|
---|
[77] | 123 | #########################
|
---|
[282] | 124 | if ($help) include("language/$language/ele_associazioni.html");
|
---|
[86] | 125 | OpenTable();
|
---|
[77] | 126 | echo "<tr><td><hr><br>";
|
---|
[257] | 127 | $sql="SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'";
|
---|
| 128 | $res = $dbi->prepare("$sql");
|
---|
| 129 | $res->execute();
|
---|
| 130 | list ($descr_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 131 | //inserire avviso su mancanza dei permessi
|
---|
| 132 | echo "<form name=\"model\" action=\"admin.php\">";
|
---|
[77] | 133 | echo "<table width=\"100%\" border=\"3\">";
|
---|
[2] | 134 | echo "<tr align=\"center\"><td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
|
---|
| 135 | echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
|
---|
[185] | 136 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
|
---|
[189] | 137 | echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
|
---|
| 138 | if($tipo_cons==3){
|
---|
| 139 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
|
---|
| 140 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
|
---|
| 141 | }
|
---|
| 142 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
|
---|
[292] | 143 | $sql = "SELECT * from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons_comu'";
|
---|
| 144 | $rescomu = $dbi->prepare("$sql");
|
---|
| 145 | $rescomu->execute();
|
---|
| 146 | $tardi=$rescomu->rowCount();
|
---|
[315] | 147 | if (!$tardi && $genere==5){
|
---|
[292] | 148 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
|
---|
| 149 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
|
---|
| 150 | }
|
---|
[189] | 151 | echo "</tr>";
|
---|
[77] | 152 | echo "<tr align=\"center\"><td>";
|
---|
[189] | 153 | echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
|
---|
[77] | 154 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>";
|
---|
[257] | 155 | $sql = "SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc";
|
---|
| 156 | $rescomu = $dbi->prepare("$sql");
|
---|
| 157 | $rescomu->execute();
|
---|
[86] | 158 | echo "<td>";
|
---|
| 159 | if($idcomune) {
|
---|
[257] | 160 | while ($listele=$rescomu->fetch(PDO::FETCH_BOTH))
|
---|
[86] | 161 | if($listele['id_comune']==$idcomune) {
|
---|
| 162 | echo $listele['descrizione'];
|
---|
| 163 | echo "<input type=\"hidden\" name=\"idcomunenew\" value=\"$idcomune\">";
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | }else{
|
---|
[77] | 167 | echo "<select name=\"idcomunenew\">";
|
---|
[2] | 168 | echo "<option value=\"0\"> ";
|
---|
[257] | 169 | while(list($id,$descr_comu)=$rescomu->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 170 | $sel= ($id == $idcomune) ? "selected":"";
|
---|
| 171 | echo "<option value=\"$id\" $sel>$descr_comu";
|
---|
| 172 | }
|
---|
[86] | 173 | echo "</select>";
|
---|
| 174 | }
|
---|
[77] | 175 | echo "</td>";
|
---|
[185] | 176 | echo "<td><input type=\"text\" name=\"preferenze\" value=\"$preferenze\" size=\"2\"></td>";
|
---|
[2] | 177 | $selez['0']='';
|
---|
| 178 | $selez['1']='';
|
---|
[86] | 179 | $selez['2']='';
|
---|
[77] | 180 | $selez['3']='';
|
---|
[2] | 181 | $selez[$chiusa]="selected";
|
---|
[87] | 182 | echo "<td><select name=\"chiusa\" id=\"chiusa\" onChange=\"javascript:del_cons()\">";
|
---|
[2] | 183 | echo "<option value=\"0\" ".$selez[0].">"._ATTIVA;
|
---|
| 184 | echo "<option value=\"1\" ".$selez[1].">"._CHIUSA;
|
---|
| 185 | echo "<option value=\"2\" ".$selez[2].">"._NULLA;
|
---|
[86] | 186 |
|
---|
[77] | 187 | if($idcomune) echo "<option value=\"3\" ".$selez[3].">"._ELIMINA;
|
---|
[2] | 188 | echo "</select></td>";
|
---|
| 189 | if($tipo_cons==3){
|
---|
[189] | 190 | if($idcomune) {
|
---|
[257] | 191 | $sql="SELECT id_fascia from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomune'";
|
---|
| 192 | $rescomu = $dbi->prepare("$sql");
|
---|
| 193 | $rescomu->execute();
|
---|
| 194 | if($rescomu->rowCount())
|
---|
| 195 | list($fasciacom)=$rescomu->fetch(PDO::FETCH_NUM);
|
---|
[318] | 196 | else $fasciacom=0;
|
---|
[189] | 197 | } else $fasciacom=0;
|
---|
[257] | 198 | $sql="SELECT id_conf, descrizione from ".$prefix."_ele_conf order by id_conf desc";
|
---|
| 199 | $rescomu = $dbi->prepare("$sql");
|
---|
| 200 | $rescomu->execute();
|
---|
[189] | 201 | echo "<td><select name=\"id_conf\" id=\"id_conf\" onchange=\"javascript:showdate('modules/Elezioni/ele_desc_fasce.php?fascia=$fasciacom&id_conf=' + model.id_conf.options[model.id_conf.selectedIndex].value,'fasceconf');\">";
|
---|
[2] | 202 | echo "<option value=\"0\"> ";
|
---|
[257] | 203 | while(list($id,$descr_conf)=$rescomu->fetch(PDO::FETCH_NUM)){
|
---|
[2] | 204 | $sel='';
|
---|
[208] | 205 | if ($idcomune and $id == $id_conf) $sel="selected";
|
---|
[2] | 206 | echo "<option value=\"$id\" $sel>$descr_conf";
|
---|
| 207 | }
|
---|
| 208 | echo "</select></td>";
|
---|
[189] | 209 | if(!$id_conf) $id_conf=1;
|
---|
[257] | 210 | $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'";
|
---|
| 211 | $rescomu = $dbi->prepare("$sql");
|
---|
| 212 | $rescomu->execute();
|
---|
[189] | 213 |
|
---|
| 214 | echo "<td id=\"fasceconf\"><select name=\"idfascia\">";
|
---|
| 215 | echo "<option value=\"0\"> ";
|
---|
| 216 | $inffascia=0;
|
---|
[257] | 217 | while(list($id,$abitanti)=$rescomu->fetch(PDO::FETCH_NUM)){
|
---|
[189] | 218 | $sel='';
|
---|
| 219 | if ($idcomune and $id == $fasciacom) $sel="selected"; elseif ($id==1) $sel="selected";
|
---|
| 220 | echo "<option value=\"$id\" $sel>$inffascia - $abitanti";
|
---|
| 221 | $inffascia=$abitanti;
|
---|
| 222 | }
|
---|
| 223 | echo "</select></td>";
|
---|
| 224 |
|
---|
| 225 |
|
---|
[2] | 226 | }
|
---|
| 227 | unset($sel);
|
---|
[282] | 228 | $sql = "SELECT vismf,solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons_comu'";
|
---|
[257] | 229 | $rescomu = $dbi->prepare("$sql");
|
---|
| 230 | $rescomu->execute();
|
---|
| 231 | list($vismf,$sg,$disgiunto)=$rescomu->fetch(PDO::FETCH_NUM);
|
---|
[189] | 232 | echo "<td><select name=\"vismf\">";
|
---|
| 233 | if ($vismf==0) $sel="selected"; else $sel="";
|
---|
| 234 | echo "<option value=\"0\" $sel>No";
|
---|
| 235 | if ($vismf==1) $sel="selected"; else $sel="";
|
---|
| 236 | echo "<option value=\"1\" $sel>Si";
|
---|
| 237 | echo "</select></td>";
|
---|
[292] | 238 | $sql = "SELECT * from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons_comu'";
|
---|
| 239 | $rescomu = $dbi->prepare("$sql");
|
---|
| 240 | $rescomu->execute();
|
---|
[315] | 241 | if (!$tardi &&$genere==5){
|
---|
[292] | 242 | echo "<td><select name=\"sg\">";
|
---|
| 243 | if ($sg==0) $sel="selected"; else $sel="";
|
---|
| 244 | echo "<option value=\"0\" $sel>No";
|
---|
| 245 | if ($sg==1) $sel="selected"; else $sel="";
|
---|
| 246 | echo "<option value=\"1\" $sel>Si";
|
---|
| 247 | echo "</select></td>";
|
---|
| 248 | echo "<td><select name=\"disgiunto\">";
|
---|
| 249 | if ($disgiunto==0) $sel="selected"; else $sel="";
|
---|
| 250 | echo "<option value=\"0\" $sel>No";
|
---|
| 251 | if ($disgiunto==1) $sel="selected"; else $sel="";
|
---|
| 252 | echo "<option value=\"1\" $sel>Si";
|
---|
| 253 | echo "</select></td>";
|
---|
| 254 | }
|
---|
[77] | 255 | echo "<td><input type=\"hidden\" name=\"ok\" value=0>";
|
---|
[315] | 256 | if ($tardi && $genere==5) echo "<input type=\"hidden\" name=\"sg\" value=$sg><input type=\"hidden\" name=\"disgiunto\" value=$disgiunto>";
|
---|
[2] | 257 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 258 | if ($idcomune) {
|
---|
[87] | 259 | echo "<input type=\"hidden\" id=\"do\" name=\"do\" value=\"update\">";
|
---|
[2] | 260 | echo "<input type=\"hidden\" name=\"idcomune\" value=\"$idcomune\">";
|
---|
[87] | 261 | echo "<input type=\"submit\" id=\"add\" name=\"add\" value=\""._MODIFY."\" ></td></tr>";
|
---|
[185] | 262 | echo "<tr><td colspan=\"5\"><fieldset><legend>"._SPUNTALABEL1."</legend><label id=\"prov1\">"._SPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_cons()\"></label></fieldset></td></tr>";
|
---|
[87] | 263 | echo "<tr id=\"trspunta\" style=\"visibility:hidden\"><td colspan=\"4\"><fieldset><legend>"._SPUNTALABEL2."</legend><label id=\"prov\">"._VIASPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd4\" name=\"pwd4\" value=\"1\" onclick=\"javascript:del_cons()\"></label></fieldset>";
|
---|
[2] | 264 | }else{
|
---|
| 265 | echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
[77] | 266 | echo "<input type=\"submit\" name=\"add\" value=\""._ADD."\">";
|
---|
[2] | 267 | }
|
---|
[86] | 268 | $i=0;
|
---|
[77] | 269 | echo "</td></tr></table></form>";
|
---|
| 270 | echo "<hr><br><table width=\"100%\" border=\"3\">";
|
---|
[258] | 271 | echo "<tr align=\"center\"><td width=\"15%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
|
---|
[189] | 272 | echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
|
---|
[185] | 273 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
|
---|
| 274 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
|
---|
[189] | 275 | if($tipo_cons==3){
|
---|
| 276 | echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
|
---|
| 277 | echo "<td width=\"20%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
|
---|
| 278 | }
|
---|
| 279 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
|
---|
[315] | 280 | if ($genere==5){
|
---|
| 281 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
|
---|
| 282 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
|
---|
| 283 | }
|
---|
[256] | 284 | echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b> "._FUNZIONI."</b></td></tr>";
|
---|
[86] | 285 |
|
---|
[257] | 286 | $sql="SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze,t1.id_fascia,t1.vismf,t1.solo_gruppo,t1.disgiunto FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons_gen='$id_cons_gen' and t1.id_comune=t2.id_comune order by t2.descrizione";
|
---|
| 287 | $resmod = $dbi->prepare("$sql");
|
---|
| 288 | $resmod->execute();
|
---|
| 289 | while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf2,$sg2,$disgiunto2) = $resmod->fetch(PDO::FETCH_NUM)){ //elenco dei modelli inseriti
|
---|
| 290 | $sql="SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'";
|
---|
| 291 | $resconf = $dbi->prepare("$sql");
|
---|
| 292 | $resconf->execute();
|
---|
| 293 | list($descr_conf) = $resconf->fetch(PDO::FETCH_NUM);
|
---|
[2] | 294 | $i++;
|
---|
[86] | 295 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
[256] | 296 | echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
|
---|
| 297 | echo "<td><b>$descr_cons</b></td>";
|
---|
| 298 | echo "<td><b>$descr_comu</b></td>";
|
---|
| 299 | echo "<td><b>$preferenze2</b></td>";
|
---|
[2] | 300 | $stato['0']=_ATTIVA;
|
---|
| 301 | $stato['1']=_CHIUSA;
|
---|
| 302 | $stato['2']=_NULLA;
|
---|
[256] | 303 | echo "<td><b>".$stato[$chiusa]."</b></td>";
|
---|
[189] | 304 | if($tipo_cons==3){
|
---|
[256] | 305 | echo "<td><b>".$descr_conf."</b></td>";
|
---|
[257] | 306 | $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'";
|
---|
| 307 | $rescomu = $dbi->prepare("$sql");
|
---|
| 308 | $rescomu->execute();
|
---|
[189] | 309 | $inffascia=0;
|
---|
[257] | 310 | if ($rescomu->rowCount()==0) echo "<td></td>";
|
---|
| 311 | while(list($id,$abitanti)=$rescomu->fetch(PDO::FETCH_NUM)){
|
---|
[189] | 312 | $sel='';
|
---|
| 313 | if ($id == $fasciacom)
|
---|
[256] | 314 | echo "<td>$inffascia - $abitanti</td>";
|
---|
[189] | 315 | $inffascia=$abitanti;
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | }
|
---|
[254] | 319 | if ($vismf2==0) $sel=_NO; else $sel=_SI;
|
---|
[256] | 320 | echo "<td>$sel</td>";
|
---|
[315] | 321 | if ($genere==5){
|
---|
| 322 | if ($sg2==0) $sel=_NO; else $sel=_SI;
|
---|
| 323 | echo "<td>$sel</td>";
|
---|
| 324 | if ($disgiunto2==0) $sel=_NO; else $sel=_SI;
|
---|
| 325 | echo "<td>$sel</td>";
|
---|
| 326 | }
|
---|
[256] | 327 | echo "<td>";
|
---|
| 328 | echo "<form name=\"modello$i\" action=\"admin.php\">"
|
---|
| 329 | ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
|
---|
| 330 | echo "<input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\">";
|
---|
| 331 | echo "<input type=\"hidden\" name=\"idcomune\" value=\"$id_comune2\">";
|
---|
| 332 | echo "<input type=\"hidden\" name=\"id_cons_comu\" value=\"$id_cons_comu\">";
|
---|
| 333 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 334 | echo "<input type=\"hidden\" name=\"desc\" value=\"$descr_cons\">";
|
---|
| 335 | echo "<input type=\"hidden\" name=\"preferenze\" value=\"$preferenze2\">";
|
---|
| 336 | echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
|
---|
| 337 | echo "<input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
|
---|
| 338 | ."</form></td></tr>\n";
|
---|
[2] | 339 | }
|
---|
[256] | 340 | echo "</table></td></tr></table>";
|
---|
[86] | 341 | CloseTable();
|
---|
[2] | 342 | }
|
---|
| 343 |
|
---|
[185] | 344 | function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf,$preferenze) {
|
---|
[254] | 345 | global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4,$idfascia,$vismf,$sg,$disgiunto;
|
---|
[86] | 346 | $delcons=0;
|
---|
[2] | 347 | if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
|
---|
[258] | 348 | $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'";
|
---|
[257] | 349 | $rescomu = $dbi->prepare("$sql");
|
---|
| 350 | $rescomu->execute();
|
---|
| 351 | $max = $rescomu->rowCount(); //esiste autorizzazione?
|
---|
| 352 | list($delcons)=$rescomu->fetch(PDO::FETCH_NUM);
|
---|
| 353 | if (!$max){ //se no la inserisce
|
---|
| 354 | $sql="insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf,preferenze,id_fascia,vismf,solo_gruppo,disgiunto) values ('0','$idcomunenew','$id_cons_gen','$id_conf','$preferenze','$idfascia','$vismf','$sg','$disgiunto')";
|
---|
| 355 | $result = $dbi->prepare("$sql");
|
---|
| 356 | $result->execute();
|
---|
| 357 | $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'";
|
---|
| 358 | $rescomu = $dbi->prepare("$sql");
|
---|
| 359 | $rescomu->execute();
|
---|
| 360 | list($id_cons_comu)=$rescomu->fetch(PDO::FETCH_NUM);
|
---|
| 361 | $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$idcomunenew' ";
|
---|
| 362 | $res = $dbi->prepare("$sql");
|
---|
| 363 | $res->execute();
|
---|
| 364 | list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM);
|
---|
| 365 | if (!$id_cons_pred) {
|
---|
| 366 | $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_comu' where id_comune='$idcomunenew' ";
|
---|
| 367 | $res = $dbi->prepare("$sql");
|
---|
| 368 | $res->execute();
|
---|
| 369 | }
|
---|
[2] | 370 | }
|
---|
| 371 | if ($do == "update") {
|
---|
| 372 | if ($idcomunenew>0) $newid=", id_comune = $idcomunenew ";
|
---|
| 373 | else $newid='';
|
---|
[258] | 374 | $sql="update ".$prefix."_ele_comu_collegi set id_collegio= '$id_collegio' $newid where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'";
|
---|
[257] | 375 | $result = $dbi->prepare("$sql");
|
---|
| 376 | $result->execute();
|
---|
| 377 | $sql="update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa', preferenze='$preferenze',id_fascia='$idfascia',vismf='$vismf',solo_gruppo='$sg',disgiunto='$disgiunto' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'";
|
---|
| 378 | $result = $dbi->prepare("$sql");
|
---|
| 379 | $result->execute();
|
---|
[2] | 380 | Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
|
---|
| 381 | }elseif ($do == "add") {
|
---|
[95] | 382 | if ($id_collegio){
|
---|
[257] | 383 | $sql="insert into ".$prefix."_ele_comu_collegi (id_collegio,id_cons,id_comune,id_cons_gen) values ('$id_collegio','$id_cons_comu','$idcomunenew','$id_cons_gen')";
|
---|
| 384 | $result = $dbi->prepare("$sql");
|
---|
| 385 | $result->execute();
|
---|
[95] | 386 | }
|
---|
[2] | 387 | Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
|
---|
[86] | 388 | }elseif ($do == "delete" and $delcons>0) {
|
---|
[77] | 389 | $idcns=$delcons;
|
---|
[257] | 390 | $sql="delete from ".$prefix."_ele_voti_ref where id_cons=$idcns";
|
---|
| 391 | $result = $dbi->prepare("$sql");
|
---|
| 392 | $result->execute();
|
---|
| 393 | $sql="delete from ".$prefix."_ele_voti_candidati where id_cons=$idcns";
|
---|
| 394 | $result = $dbi->prepare("$sql");
|
---|
| 395 | $result->execute();
|
---|
| 396 | $sql="delete from ".$prefix."_ele_voti_lista where id_cons=$idcns";
|
---|
| 397 | $result = $dbi->prepare("$sql");
|
---|
| 398 | $result->execute();
|
---|
| 399 | $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons=$idcns";
|
---|
| 400 | $result = $dbi->prepare("$sql");
|
---|
| 401 | $result->execute();
|
---|
| 402 | $sql="delete from ".$prefix."_ele_voti_parziale where id_cons=$idcns";
|
---|
| 403 | $result = $dbi->prepare("$sql");
|
---|
| 404 | $result->execute();
|
---|
| 405 | $sql="delete from ".$prefix."_ele_controllosez where id_cons=$idcns";
|
---|
| 406 | $result = $dbi->prepare("$sql");
|
---|
| 407 | $result->execute();
|
---|
[86] | 408 | if ($pwd4==1){
|
---|
[257] | 409 | $sql="delete from ".$prefix."_ele_candidati where id_cons=$idcns";
|
---|
| 410 | $result = $dbi->prepare("$sql");
|
---|
| 411 | $result->execute();
|
---|
| 412 | $sql="delete from ".$prefix."_ele_lista where id_cons=$idcns";
|
---|
| 413 | $result = $dbi->prepare("$sql");
|
---|
| 414 | $result->execute();
|
---|
| 415 | $sql="delete from ".$prefix."_ele_gruppo where id_cons=$idcns";
|
---|
| 416 | $result = $dbi->prepare("$sql");
|
---|
| 417 | $result->execute();
|
---|
| 418 | $sql="delete from ".$prefix."_ele_sezioni where id_cons=$idcns";
|
---|
| 419 | $result = $dbi->prepare("$sql");
|
---|
| 420 | $result->execute();
|
---|
| 421 | $sql="delete from ".$prefix."_ele_cons_comune where id_cons=$idcns";
|
---|
| 422 | $result = $dbi->prepare("$sql");
|
---|
| 423 | $result->execute();
|
---|
| 424 | $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
|
---|
| 425 | $res = $dbi->prepare("$sql");
|
---|
| 426 | $res->execute();
|
---|
| 427 | list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM);
|
---|
[95] | 428 | if ($idcns==$id_cons_pred) {
|
---|
[257] | 429 | $sql="select id_cons from ".$prefix."_ele_cons_comune where id_comune=$id_comune order by id_cons desc limit 0,1";
|
---|
| 430 | $res = $dbi->prepare("$sql");
|
---|
| 431 | $res->execute();
|
---|
| 432 | list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM);
|
---|
| 433 | $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_pred' where id_comune='$id_comune' ";
|
---|
| 434 | $res = $dbi->prepare("$sql");
|
---|
| 435 | $res->execute();
|
---|
[95] | 436 | }
|
---|
[86] | 437 | }else{
|
---|
[316] | 438 | $sql="update ".$prefix."_ele_sezioni set validi='0', nulli='0', bianchi='0', contestati='0', solo_gruppo='0', autorizzati_m='0', autorizzati_f='0', voti_nulli='0', validi_lista='0', contestati_lista='0', voti_nulli_lista='0', colore='' where id_cons=$idcns";
|
---|
[257] | 439 | $result = $dbi->prepare("$sql");
|
---|
| 440 | $result->execute();
|
---|
[86] | 441 | }
|
---|
[77] | 442 | Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
|
---|
[2] | 443 | }
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 |
|
---|
[86] | 447 |
|
---|
| 448 |
|
---|
| 449 |
|
---|
[2] | 450 |
|
---|
| 451 | //****************************
|
---|
| 452 | // switch
|
---|
| 453 | //****************************
|
---|
| 454 | if ($op=="associazioni"){
|
---|
[185] | 455 | associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$idcomune,$chiusa,$id_conf,$preferenze);
|
---|
[2] | 456 | }
|
---|
| 457 | ele();
|
---|
| 458 | if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
|
---|
| 459 | all();
|
---|
| 460 | include("footer.php");
|
---|
| 461 |
|
---|
| 462 | ?>
|
---|
| 463 |
|
---|
[87] | 464 |
|
---|