Changeset 257 for trunk/admin/modules/Elezioni/ele_associazioni.php
- Timestamp:
- Feb 9, 2019, 8:45:24 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/modules/Elezioni/ele_associazioni.php
r256 r257 14 14 die ("You can't access this file directly..."); 15 15 } 16 16 global $dbi; 17 17 $aid=$_SESSION['aid']; 18 $dbi=$_SESSION['dbi'];19 18 $prefix=$_SESSION['prefix']; 20 19 $id_comune=$_SESSION['id_comune']; … … 22 21 $perms=ChiSei(0); 23 22 if ($perms<128 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!"); 24 $res = mysql_query("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' " , $dbi); 25 list($tipo_cons,$descr_cons,$id_cons,$id_conf) = mysql_fetch_row($res); 26 27 $res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi); 28 list($genere) = mysql_fetch_row($res); 23 $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' "; 24 $res = $dbi->prepare("$sql"); 25 $res->execute(); 26 # $gru = $sth->fetch(PDO::FETCH_BOTH); 27 list($tipo_cons,$descr_cons,$id_cons,$id_conf) = $res->fetch(PDO::FETCH_NUM); 28 29 $sql="SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' "; 30 $res = $dbi->prepare("$sql"); 31 $res->execute(); 32 list($genere) = $res->fetch(PDO::FETCH_NUM); 29 33 30 34 include("modules/Elezioni/funzionidata.php"); … … 59 63 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; 60 64 $aid=$_SESSION['aid']; 61 $dbi=$_SESSION['dbi'];62 65 $prefix=$_SESSION['prefix']; 63 66 ############# Controllo flag per cancellazione consultazione … … 117 120 OpenTable(); 118 121 echo "<tr><td><hr><br>"; 119 $res = mysql_query("SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi); 120 list ($descr_cons) = mysql_fetch_row($res); 122 $sql="SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'"; 123 $res = $dbi->prepare("$sql"); 124 $res->execute(); 125 list ($descr_cons) = $res->fetch(PDO::FETCH_NUM); 121 126 //inserire avviso su mancanza dei permessi 122 127 echo "<form name=\"model\" action=\"admin.php\">"; … … 137 142 echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">"; 138 143 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>"; 139 $rescomu = mysql_query("SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc", $dbi); 144 $sql = "SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc"; 145 $rescomu = $dbi->prepare("$sql"); 146 $rescomu->execute(); 140 147 echo "<td>"; 141 148 if($idcomune) { 142 while ($listele= mysql_fetch_array($rescomu))149 while ($listele=$rescomu->fetch(PDO::FETCH_BOTH)) 143 150 if($listele['id_comune']==$idcomune) { 144 151 echo $listele['descrizione']; … … 149 156 echo "<select name=\"idcomunenew\">"; 150 157 echo "<option value=\"0\"> "; 151 while(list($id,$descr_comu)= mysql_fetch_row($rescomu)){158 while(list($id,$descr_comu)=$rescomu->fetch(PDO::FETCH_NUM)){ 152 159 $sel= ($id == $idcomune) ? "selected":""; 153 160 echo "<option value=\"$id\" $sel>$descr_comu"; … … 171 178 if($tipo_cons==3){ 172 179 if($idcomune) { 173 $rescomu = mysql_query("SELECT id_fascia from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomune'", $dbi); 174 if($rescomu) 175 list($fasciacom)=mysql_fetch_row($rescomu); 180 $sql="SELECT id_fascia from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomune'"; 181 $rescomu = $dbi->prepare("$sql"); 182 $rescomu->execute(); 183 if($rescomu->rowCount()) 184 list($fasciacom)=$rescomu->fetch(PDO::FETCH_NUM); 176 185 } else $fasciacom=0; 177 $rescomu = mysql_query("SELECT id_conf, descrizione from ".$prefix."_ele_conf order by id_conf desc", $dbi); 186 $sql="SELECT id_conf, descrizione from ".$prefix."_ele_conf order by id_conf desc"; 187 $rescomu = $dbi->prepare("$sql"); 188 $rescomu->execute(); 178 189 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');\">"; 179 190 echo "<option value=\"0\"> "; 180 while(list($id,$descr_conf)= mysql_fetch_row($rescomu)){191 while(list($id,$descr_conf)=$rescomu->fetch(PDO::FETCH_NUM)){ 181 192 $sel=''; 182 193 if ($idcomune and $id == $id_conf) $sel="selected"; … … 185 196 echo "</select></td>"; 186 197 if(!$id_conf) $id_conf=1; 187 $rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi); 198 $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'"; 199 $rescomu = $dbi->prepare("$sql"); 200 $rescomu->execute(); 188 201 189 202 echo "<td id=\"fasceconf\"><select name=\"idfascia\">"; 190 203 echo "<option value=\"0\"> "; 191 204 $inffascia=0; 192 while(list($id,$abitanti)= mysql_fetch_row($rescomu)){205 while(list($id,$abitanti)=$rescomu->fetch(PDO::FETCH_NUM)){ 193 206 $sel=''; 194 207 if ($idcomune and $id == $fasciacom) $sel="selected"; elseif ($id==1) $sel="selected"; … … 201 214 } 202 215 unset($sel); 203 $rescomu = mysql_query("SELECT vismf,solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons_comu'", $dbi); 204 list($vismf,$sg,$disgiunto)=mysql_fetch_row($rescomu); 216 $sql = "SELECT vismf,vismf,solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons_comu'"; 217 $rescomu = $dbi->prepare("$sql"); 218 $rescomu->execute(); 219 list($vismf,$sg,$disgiunto)=$rescomu->fetch(PDO::FETCH_NUM); 205 220 echo "<td><select name=\"vismf\">"; 206 221 if ($vismf==0) $sel="selected"; else $sel=""; … … 250 265 echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b> "._FUNZIONI."</b></td></tr>"; 251 266 252 $resmod = mysql_query("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", $dbi); 253 while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf2,$sg2,$disgiunto2) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti 254 $resconf = mysql_query("SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi); 255 list($descr_conf) = mysql_fetch_row($resconf); 267 $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"; 268 $resmod = $dbi->prepare("$sql"); 269 $resmod->execute(); 270 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 271 $sql="SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'"; 272 $resconf = $dbi->prepare("$sql"); 273 $resconf->execute(); 274 list($descr_conf) = $resconf->fetch(PDO::FETCH_NUM); 256 275 $i++; 257 276 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1']; … … 266 285 if($tipo_cons==3){ 267 286 echo "<td><b>".$descr_conf."</b></td>"; 268 $rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi); 287 $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'"; 288 $rescomu = $dbi->prepare("$sql"); 289 $rescomu->execute(); 269 290 $inffascia=0; 270 if ( mysql_num_rows($rescomu)==0) echo "<td></td>";271 while(list($id,$abitanti)= mysql_fetch_row($rescomu)){291 if ($rescomu->rowCount()==0) echo "<td></td>"; 292 while(list($id,$abitanti)=$rescomu->fetch(PDO::FETCH_NUM)){ 272 293 $sel=''; 273 294 if ($id == $fasciacom) … … 304 325 $delcons=0; 305 326 if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) { 306 $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi); 307 $max = mysql_num_rows($rescomu); //esiste autorizzazione? 308 list($delcons)=mysql_fetch_row($rescomu); 309 if (!$max){ //se no la inserisce 310 $result = mysql_query("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')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error()); 311 $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi); 312 list($id_cons_comu)=mysql_fetch_row($rescomu); 313 $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$idcomunenew' ", $dbi); 314 list($id_cons_pred)=mysql_fetch_row($res); 315 if (!$id_cons_pred) 316 $res = mysql_query("update ".$prefix."_ele_comuni set id_cons='$id_cons_comu' where id_comune='$idcomunenew' ", $dbi); 317 327 $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'"; 328 $rescomu = $dbi->prepare("$sql"); 329 $rescomu->execute(); 330 $max = $rescomu->rowCount(); //esiste autorizzazione? 331 list($delcons)=$rescomu->fetch(PDO::FETCH_NUM); 332 if (!$max){ //se no la inserisce 333 $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')"; 334 $result = $dbi->prepare("$sql"); 335 $result->execute(); 336 $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'"; 337 $rescomu = $dbi->prepare("$sql"); 338 $rescomu->execute(); 339 list($id_cons_comu)=$rescomu->fetch(PDO::FETCH_NUM); 340 $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$idcomunenew' "; 341 $res = $dbi->prepare("$sql"); 342 $res->execute(); 343 list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM); 344 if (!$id_cons_pred) { 345 $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_comu' where id_comune='$idcomunenew' "; 346 $res = $dbi->prepare("$sql"); 347 $res->execute(); 348 } 318 349 } 319 350 if ($do == "update") { … … 321 352 else $newid=''; 322 353 $result = mysql_query("update ".$prefix."_ele_comu_collegi set id_collegio= '$id_collegio' $newid where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi) || die(mysql_error()); 323 if (!$result) return; 324 $result = mysql_query("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'", $dbi)|| die(mysql_error()); 354 $result = $dbi->prepare("$sql"); 355 $result->execute(); 356 if (!$result->rowCount()) return; 357 $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'"; 358 $result = $dbi->prepare("$sql"); 359 $result->execute(); 325 360 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen"); 326 361 }elseif ($do == "add") { 327 362 if ($id_collegio){ 328 $result = mysql_query("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')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error()); 363 $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')"; 364 $result = $dbi->prepare("$sql"); 365 $result->execute(); 329 366 } 330 367 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen"); 331 368 }elseif ($do == "delete" and $delcons>0) { 332 369 $idcns=$delcons; 333 $res_del = mysql_query("delete from ".$prefix."_ele_voti_ref where id_cons=$idcns" ,$dbi); 334 $res_del = mysql_query("delete from ".$prefix."_ele_voti_candidati where id_cons=$idcns" ,$dbi); 335 $res_del = mysql_query("delete from ".$prefix."_ele_voti_lista where id_cons=$idcns" ,$dbi); 336 $res_del = mysql_query("delete from ".$prefix."_ele_voti_gruppo where id_cons=$idcns" ,$dbi); 337 $res_del = mysql_query("delete from ".$prefix."_ele_voti_parziale where id_cons=$idcns" ,$dbi); 338 $res_del = mysql_query("delete from ".$prefix."_ele_controllosez where id_cons=$idcns" ,$dbi); 370 $sql="delete from ".$prefix."_ele_voti_ref where id_cons=$idcns"; 371 $result = $dbi->prepare("$sql"); 372 $result->execute(); 373 $sql="delete from ".$prefix."_ele_voti_candidati where id_cons=$idcns"; 374 $result = $dbi->prepare("$sql"); 375 $result->execute(); 376 $sql="delete from ".$prefix."_ele_voti_lista where id_cons=$idcns"; 377 $result = $dbi->prepare("$sql"); 378 $result->execute(); 379 $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons=$idcns"; 380 $result = $dbi->prepare("$sql"); 381 $result->execute(); 382 $sql="delete from ".$prefix."_ele_voti_parziale where id_cons=$idcns"; 383 $result = $dbi->prepare("$sql"); 384 $result->execute(); 385 $sql="delete from ".$prefix."_ele_controllosez where id_cons=$idcns"; 386 $result = $dbi->prepare("$sql"); 387 $result->execute(); 339 388 if ($pwd4==1){ 340 $res_del = mysql_query("delete from ".$prefix."_ele_candidati where id_cons=$idcns" ,$dbi); 341 $res_del = mysql_query("delete from ".$prefix."_ele_lista where id_cons=$idcns" ,$dbi); 342 $res_del = mysql_query("delete from ".$prefix."_ele_gruppo where id_cons=$idcns" ,$dbi); 343 $res_del = mysql_query("delete from ".$prefix."_ele_sezioni where id_cons=$idcns" ,$dbi); 344 $res_del = mysql_query("delete from ".$prefix."_ele_cons_comune where id_cons=$idcns" ,$dbi); 345 $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ", $dbi); 346 list($id_cons_pred)=mysql_fetch_row($res); 389 $sql="delete from ".$prefix."_ele_candidati where id_cons=$idcns"; 390 $result = $dbi->prepare("$sql"); 391 $result->execute(); 392 $sql="delete from ".$prefix."_ele_lista where id_cons=$idcns"; 393 $result = $dbi->prepare("$sql"); 394 $result->execute(); 395 $sql="delete from ".$prefix."_ele_gruppo where id_cons=$idcns"; 396 $result = $dbi->prepare("$sql"); 397 $result->execute(); 398 $sql="delete from ".$prefix."_ele_sezioni where id_cons=$idcns"; 399 $result = $dbi->prepare("$sql"); 400 $result->execute(); 401 $sql="delete from ".$prefix."_ele_cons_comune where id_cons=$idcns"; 402 $result = $dbi->prepare("$sql"); 403 $result->execute(); 404 $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$id_comune' "; 405 $res = $dbi->prepare("$sql"); 406 $res->execute(); 407 list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM); 347 408 if ($idcns==$id_cons_pred) { 348 $res = mysql_query("select id_cons from ".$prefix."_ele_cons_comune where id_comune=$id_comune order by id_cons desc limit 0,1" ,$dbi); 349 list($id_cons_pred)=mysql_fetch_row($res); 350 $res = mysql_query("update ".$prefix."_ele_comuni set id_cons='$id_cons_pred' where id_comune='$id_comune' ", $dbi); 409 $sql="select id_cons from ".$prefix."_ele_cons_comune where id_comune=$id_comune order by id_cons desc limit 0,1"; 410 $res = $dbi->prepare("$sql"); 411 $res->execute(); 412 list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM); 413 $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_pred' where id_comune='$id_comune' "; 414 $res = $dbi->prepare("$sql"); 415 $res->execute(); 351 416 } 352 417 }else{ 353 $res_del = mysql_query("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' where id_cons=$idcns" ,$dbi); 354 418 $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' where id_cons=$idcns"; 419 $result = $dbi->prepare("$sql"); 420 $result->execute(); 355 421 } 356 422 Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
Note:
See TracChangeset
for help on using the changeset viewer.