Changeset 257 for trunk/admin/modules/Elezioni/ele_candidato.php
- Timestamp:
- Feb 9, 2019, 8:45:24 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/modules/Elezioni/ele_candidato.php
r97 r257 13 13 die ("You can't access this file directly..."); 14 14 } 15 15 global $dbi; 16 16 $aid=$_SESSION['aid']; 17 $dbi=$_SESSION['dbi'];18 17 $prefix=$_SESSION['prefix']; 19 18 $currentlang=$_SESSION['lang']; … … 23 22 $perms=ChiSei($id_cons_gen); 24 23 if ($perms<32 or !$id_cons_gen) die("$id_cons_gen -Non hai i permessi per inserire dati, o non hai scelto la consultazione!"); 25 $res = mysql_query("SELECT t1.tipo_cons,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); 26 list($tipo_cons,$id_cons) = mysql_fetch_row($res); 27 $res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi); 28 list($genere) = mysql_fetch_row($res); 24 $sql = "SELECT t1.tipo_cons,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' "; 25 $sth = $dbi->prepare("$sql"); 26 $sth->execute(); 27 28 list($tipo_cons,$id_cons) = $sth->fetch(PDO::FETCH_NUM); 29 $sql = "SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' "; 30 $sth = $dbi->prepare("$sql"); 31 $sth->execute(); 32 list($genere) = $sth->fetch(PDO::FETCH_NUM); 29 33 include("modules/Elezioni/funzionidata.php"); 30 34 include("modules/Elezioni/ele.php"); … … 78 82 $circo='';$circo2=''; 79 83 $currentlang=$_SESSION['lang']; 80 $res = mysql_query("SELECT circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' and lingua='$currentlang'", $dbi); 81 list($cons_circ)= mysql_fetch_row($res); 84 $sql = "SELECT circo FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' and lingua='$currentlang'"; 85 $sth = $dbi->prepare("$sql"); 86 $sth->execute(); 87 list($cons_circ)= $sth->fetch(PDO::FETCH_NUM); 82 88 if($cons_circ) //elezioni circoscrizionali 83 89 { 84 90 echo "<form name=\"circo\" action=\"admin.php\" method=\"post\">"; 85 91 echo "<br><br><table border=\"1\" width=\"50%\" ><tr bgcolor=\"$bgcolor1\"><td>"._SCEGLI_CIRCO.": </td>"; 86 $res = mysql_query("SELECT * FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons'", $dbi);87 92 echo "<input type=\"hidden\" name=\"pag\" value=\"admin.php?op=candidato&id_cons_gen=$id_cons_gen&id_circ=\">"; 88 93 echo "<td><select name=\"id_circ\" onChange=\"top.location.href=this.form.pag.value+this.form.id_circ.options[this.form.id_circ.selectedIndex].value;return false\">"; 89 94 echo "<option value=\"\">"; 90 while($arr=mysql_fetch_array($res,3)){ 95 $sql = "SELECT * FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons'"; 96 $sth = $dbi->prepare("$sql"); 97 $sth->execute(); 98 while($arr=$sth->fetch(PDO::FETCH_BOTH)){ 91 99 if (!$id_circ) $id_circ=$arr['id_circ']; 92 100 $sel= ($arr['id_circ'] == $id_circ) ? "selected":""; … … 99 107 if($id_cand) 100 108 { 101 $res = mysql_query("SELECT * FROM ".$prefix."_ele_candidati where id_cand='$id_cand'", $dbi); 102 $pro= mysql_fetch_array($res, 3); 109 $sql = "SELECT * FROM ".$prefix."_ele_candidati where id_cand='$id_cand'"; 110 $sth = $dbi->prepare("$sql"); 111 $sth->execute(); 112 $pro= $sth->fetch(PDO::FETCH_BOTH); 103 113 }else{ 104 114 $pro['cognome']='';$pro['num_cand']='';$pro['nome']=''; 105 115 } 106 116 if (!isset($id_lista)) { 107 $res_lista=mysql_query("SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo and num_lista=1", $dbi); 108 list($id_lista)=mysql_fetch_row($res_lista); 117 $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo and num_lista=1"; 118 $sth = $dbi->prepare("$sql"); 119 $sth->execute(); 120 list($id_lista)=$sth->fetch(PDO::FETCH_NUM); 109 121 } 110 122 $cond=($id_lista>0) ? "and t1.id_lista=".$id_lista :''; … … 143 155 } 144 156 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>"; 145 $result = mysql_query($query, $dbi); 157 $result = $dbi->prepare("$query"); 158 $result->execute(); 159 # list($id_lista)=$result->fetch(PDO::FETCH_NUM); 146 160 if($cons_circ) 147 $ res = mysql_query("SELECT count(0) FROM ".$prefix."_ele_candidati as t1,".$prefix."_ele_lista as t2 where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons and t2.id_circ=$id_circ and t1.id_lista=t2.id_lista $cond ", $dbi);161 $sql = "SELECT count(0) FROM ".$prefix."_ele_candidati as t1,".$prefix."_ele_lista as t2 where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons and t2.id_circ=$id_circ and t1.id_lista=t2.id_lista $cond "; 148 162 else 149 $res = mysql_query("SELECT count(0) FROM ".$prefix."_ele_candidati as t1 where t1.id_cons='$id_cons' $cond ", $dbi); 150 list($max) = mysql_fetch_row($res); 163 $sql = "SELECT count(0) FROM ".$prefix."_ele_candidati as t1 where t1.id_cons='$id_cons' $cond "; 164 $sth = $dbi->prepare("$sql"); 165 $sth->execute(); 166 list($max) = $sth->rowCount(); 151 167 if($id_lista){ 152 168 $numero=$max+1;} else $numero=''; … … 166 182 echo "<input type=\"hidden\" name=\"pag\" value=\"admin.php?op=candidato&id_cons=$id_cons&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=$id_circ&id_lista=\">"; 167 183 echo "<td width=\"10%\"><select width=\"10\" name=\"id_lista\" onChange=\"aggiorna()\">"; 168 $res= mysql_query("SELECT id_lista,num_lista,descrizione FROM ".$prefix."_ele_lista where id_cons='$id_cons' $circo order by num_lista", $dbi); 184 $sql= "SELECT id_lista,num_lista,descrizione FROM ".$prefix."_ele_lista where id_cons='$id_cons' $circo order by num_lista"; 185 $lis = $dbi->prepare("$sql"); 186 $lis->execute(); 169 187 echo "<option value=\"\">"; 170 while(list($id,$numlist,$descr) = mysql_fetch_row($res)) { 188 189 while(list($id,$numlist,$descr) = $lis->fetch(PDO::FETCH_NUM)) { 171 190 if (!isset($id_lista)){$id_lista=$id;} 172 191 $sel= ($id == $id_lista) ? "selected":""; … … 198 217 if ($result) 199 218 while(list($id_cand,$id_lista2,$num_cand,$cognome, $nome,$simbolo,$simb_lista, 200 $descr_lista,$simb_gruppo,$descr_gruppo) = mysql_fetch_row($result)) {219 $descr_lista,$simb_gruppo,$descr_gruppo) = $result->fetch(PDO::FETCH_NUM)) { 201 220 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1']; 202 221 echo "<tr bgcolor=\"$bgcolor1\"><td align=\"center\"><b>$num_cand</b>" … … 245 264 if ($perms >16) { 246 265 if($id_cand) { 247 $ res = mysql_query("SELECT * FROM ".$prefix."_ele_candidati where id_cand='$id_cand'", $dbi);266 $sql = "SELECT * FROM ".$prefix."_ele_candidati where id_cand='$id_cand'"; 248 267 }else{ 249 $ res = mysql_query("SELECT * FROM ".$prefix."_ele_candidati where id_lista='$id_lista'250 and id_cons= $id_cons and cognome=$cognome and nome=$nome", $dbi);268 $sql="SELECT * FROM ".$prefix."_ele_candidati where id_lista='$id_lista' 269 and id_cons='$id_cons' and cognome='$cognome' and nome='$nome'"; 251 270 } 271 $sthcan = $dbi->prepare("$sql"); 272 $sthcan->execute(); 273 252 274 $username=$aid; 253 275 $data=date("Y/m/d"); … … 260 282 echo "[ <a href=\"admin.php?op=candidato&id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=candidato&do=delete&id_cand=$id_cand&id_gruppo=$id_gruppo&id_cons=$id_cons&id_circ=$id_circ&ok=1&id_cons_gen=$id_cons_gen&id_lista=$id_lista&id_comune=$id_comune&min=$min\">"._YES."</a> ]"; 261 283 }else{ 262 $pro= mysql_fetch_array($res, MYSQL_ASSOC); 263 $result = mysql_query("delete from ".$prefix."_ele_candidati where id_cand='$id_cand'", $dbi); 264 mysql_query("insert into ".$prefix."_ele_log values ('$id_cons','$id_sez','$username','$data','$tempo','DELETE:id_lista:$pro[id_lista],cognome:$pro[cognome],nome:$pro[nome]','','".$prefix."_ele_candidati')", $dbi); 265 if (!$result)return; 284 $pro= $sthcan->fetch(PDO::FETCH_BOTH); 285 $sql="delete from ".$prefix."_ele_candidati where id_cand='$id_cand'"; 286 $sth = $dbi->prepare("$sql"); 287 $sth->execute(); 288 $result=$sth->rowCount(); 289 $sql="insert into ".$prefix."_ele_log values ('$id_cons','$id_sez','$username','$data','$tempo','DELETE:id_lista:$pro[id_lista],cognome:$pro[cognome],nome:$pro[nome]','','".$prefix."_ele_candidati')"; 290 $sth = $dbi->prepare("$sql"); 291 $sth->execute(); 292 if (!$result->rowCount())return; 266 293 Header("Location: admin.php?op=candidato&id_cons=$id_cons&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=$id_circ&id_lista=$id_lista&min=$min"); 267 294 } … … 270 297 // dati gruppo 271 298 if (!$num_cand){ 272 $result = mysql_query("select max(num_cand) from ".$prefix."_ele_candidati where id_lista='$id_lista'", $dbi); 273 if ($result) list($num_cand)=mysql_fetch_row($result); 299 $sql="select max(num_cand) from ".$prefix."_ele_candidati where id_lista='$id_lista'"; 300 $result = $dbi->prepare("$sql"); 301 $result->execute(); 302 if ($result->rowCount()) list($num_cand)=$result->fetch(PDO::FETCH_NUM); 274 303 else $num_cand=0; 275 304 $num_cand++; 276 305 } 277 $result = mysql_query("select id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'", $dbi); 278 list($id_gruppo)=mysql_fetch_row($result); 279 $result = mysql_query("insert into ".$prefix."_ele_candidati(id_cons,id_lista,cognome,nome,note,simbolo,num_cand) values ('$id_cons','$id_lista','$cognome','$nome','$note','$simbolo','$num_cand')", $dbi); 280 mysql_query("insert into ".$prefix."_ele_log values ('$id_cons','$id_sez','$username','$data','$tempo','','ADD:id_lista:$id_lista,cognome:$cognome,nome:$nome','".$prefix."_ele_candidati')", $dbi); 306 $sql="select id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'"; 307 $sth = $dbi->prepare("$sql"); 308 $sth->execute(); 309 list($id_gruppo)=$sth->fetch(PDO::FETCH_NUM); 310 $sql="insert into ".$prefix."_ele_candidati(id_cons,id_lista,cognome,nome,note,simbolo,num_cand) values ('$id_cons','$id_lista','$cognome','$nome','$note','$simbolo','$num_cand')"; 311 $sth = $dbi->prepare("$sql"); 312 $sth->execute(); 313 $result=$sth->rowCount(); 314 $sql="insert into ".$prefix."_ele_log values ('$id_cons','$id_sez','$username','$data','$tempo','','ADD:id_lista:$id_lista,cognome:$cognome,nome:$nome','".$prefix."_ele_candidati')"; 315 $sth = $dbi->prepare("$sql"); 316 $sth->execute(); 281 317 if (!$result) return; 282 318 Header("Location: admin.php?op=candidato&id_cons=$id_cons&id_lista=$id_lista&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=$id_circ&min=$min"); … … 289 325 } 290 326 }elseif ($do == "update") { 327 $pro= $sthcan->fetch(PDO::FETCH_BOTH); 291 328 292 $pro= mysql_fetch_array($res, MYSQL_ASSOC); 293 $result = mysql_query("select id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'", $dbi); 294 list($id_gruppo)=mysql_fetch_row($result); 329 $sql="select id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'"; 330 $sth = $dbi->prepare("$sql"); 331 $sth->execute(); 332 list($id_gruppo)=$sth->fetch(PDO::FETCH_NUM); 295 333 $cond=''; 296 334 if (isset($note)) {$cond=", note='$note'";} 297 335 if (isset($simbolo)) {$cond.=", simbolo='$simbolo'";} 298 $result = mysql_query("update ".$prefix."_ele_candidati set id_lista='$id_lista', cognome='$cognome', nome='$nome', num_cand='$num_cand' $cond where id_cand='$id_cand' ", $dbi); 299 mysql_query("insert into ".$prefix."_ele_log values ('$id_cons','$id_sez','$username','$data','$tempo','UPDATE:id_lista:$pro[id_lista],cognome:$pro[cognome],nome:$pro[nome],num_cand:$pro[num_cand]','id_lista:$id_lista,cognome:$cognome,nome:$nome,num_cand:$num_cand','".$prefix."_ele_candidati')", $dbi); 300 if (!$result) return; 301 Header("Location: admin.php?op=candidato&id_cons=$id_cons&id_lista=$id_lista&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=$id_circ&min=$min"); 336 $sql="update ".$prefix."_ele_candidati set id_lista='$id_lista', cognome='$cognome', nome='$nome', num_cand='$num_cand' $cond where id_cand='$id_cand' "; 337 $sth = $dbi->prepare("$sql"); 338 $sth->execute(); 339 $result=$sth->rowCount(); 340 $sql="insert into ".$prefix."_ele_log values ('$id_cons','$id_sez','$username','$data','$tempo','UPDATE:id_lista:$pro[id_lista],cognome:$pro[cognome],nome:$pro[nome],num_cand:$pro[num_cand]','id_lista:$id_lista,cognome:$cognome,nome:$nome,num_cand:$num_cand','".$prefix."_ele_candidati')"; 341 $sth = $dbi->prepare("$sql"); 342 $sth->execute(); 343 if (!$result) {return;} 344 # Header("Location: admin.php?op=candidato&id_cons=$id_cons&id_lista=$id_lista&id_cons_gen=$id_cons_gen&id_comune=$id_comune&id_circ=$id_circ&min=$min"); 302 345 } 303 346 … … 306 349 307 350 308 309 if ($do and $do!='modify') 351 echo "qui si if ($do and $do!='modify')"; 352 if ($do and $do!='modify'){ele(); 310 353 candidato($ok, $do,$id_cand, $id_lista,$id_circ, $id_gruppo,$cognome, $nome, $note, $simbolo,$id_cand2,$num_cand); 311 else ele(); 354 } else { ele(); } 312 355 //if (!$do)ele(); 313 356 all();
Note:
See TracChangeset
for help on using the changeset viewer.