Changeset 256 for trunk/admin/modules/Elezioni/ele_cons_comuni.php
- Timestamp:
- Jan 16, 2019, 7:06:35 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/modules/Elezioni/ele_cons_comuni.php
r122 r256 13 13 } 14 14 15 global $dbi; 15 16 $aid=$_SESSION['aid']; 16 $dbi=$_SESSION['dbi'];17 17 $prefix=$_SESSION['prefix']; 18 18 if($param) … … 23 23 $perms=ChiSei(0); 24 24 if ($perms<64 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!"); 25 $res = mysql_query("SELECT tipo_cons,descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' " , $dbi);26 list($tipo_cons,$descr_cons) = mysql_fetch_row($res);27 25 include("modules/Elezioni/funzionidata.php"); 28 26 include("modules/Elezioni/ele.php"); 27 $row=descr_cons(); 28 $tipo_cons=$row[0];$descr_cons=$row[2]; 29 29 30 if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do=''; 30 31 if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok=''; … … 48 49 49 50 if (isset($help)) include("language/$language/ele_cons_comuni.html"); 50 51 $row=descr_comune(); 51 52 $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune=$id_comune", $dbi); 52 if (isset($res)) list($idpred) = mysql_fetch_row($res); else $idpred=''; 53 $res = mysql_query("SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' " , $dbi); 54 $max = mysql_num_rows($res); 53 if (count($row)) $idpred = $row[2]; else $idpred=''; 54 # $res = mysql_query("SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' " , $dbi); 55 $row=elenco_cons_comune(); 56 57 $max = count($row); 55 58 echo "<table border=\"0\" width=\"100%\" align=\"left\"><tr><td>"; 56 59 echo "<form name=\"imppred\" action=\"admin.php\">"; … … 58 61 ." <b>"._CONSPRED."</b> </td><td><select name=\"predefinita\">"; 59 62 echo "<option value=\"\">"; 60 while($arr=mysql_fetch_array($res,3)){63 foreach($row as $arr){ 61 64 $sel=''; 62 65 if (($idpred)) … … 77 80 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._COPIA." "._NUM." "._ELETTORI."</b></td>" 78 81 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>"; 79 $result = mysql_query("select t2.chiusa,t2.id_cons,t1.* from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t2.id_comune='$id_comune' and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons!=$id_cons ORDER BY data_fine desc LIMIT $min,$offset", $dbi); 82 $sql = "select t2.chiusa,t2.id_cons,t1.* from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t2.id_comune='$id_comune' and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons!=$id_cons ORDER BY data_fine desc LIMIT $min,$offset"; 83 $sth = $dbi->prepare("$sql"); 84 $sth->execute(); 85 $row = $sth->fetchAll(); 80 86 $i=0; 81 while(list($chiusa,$id_cons2,$idconsgen2, $descr_cons, $data_inizio, $data_fine,$tipo) = mysql_fetch_row($result)) { 87 foreach($row as $arr) { 88 $chiusa=$arr[0];$id_cons2=$arr[1];$idconsgen2=$arr[2]; $descr_cons=$arr[3]; $data_inizio=$arr[4]; $data_fine=$arr[5];$tipo=$arr[6]; 82 89 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1']; 83 $ressez = mysql_query("select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'", $dbi); 84 list($somma)=mysql_fetch_row($ressez); 90 $sql = "select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'"; 91 $sth = $dbi->prepare("$sql"); 92 $sth->execute(); 93 $row = $sth->fetch(PDO::FETCH_BOTH); 94 $somma=$row[0]; 85 95 $data_inizio=form_data($data_inizio);$data_fine=form_data($data_fine); 86 96 echo "<tr bgcolor=\"$bgcolor1\" align=\"center\" ><td align=\"left\" ><a href=\"admin.php?op=cons_comuni&id_cons_gen=$idconsgen2\"><b>$descr_cons</b></a></td>" … … 141 151 if ($perms>32) { 142 152 $sql="select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune=$id_comune"; 143 $res=mysql_query("$sql",$dbi); 144 list($id_consulta)=mysql_fetch_row($res); 153 $sth = $dbi->prepare("$sql"); 154 $sth->execute(); 155 $row = $sth->fetch(PDO::FETCH_BOTH); 156 $id_consulta=$row[0]; 145 157 $sql="select t1.descrizione from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t2.id_cons='$id_cons2' and t1.id_cons_gen=t2.id_cons_gen"; 146 $res=mysql_query("$sql",$dbi); 147 list($descr_cons2)=mysql_fetch_row($res); 158 $sth = $dbi->prepare("$sql"); 159 $sth->execute(); 160 $row = $sth->fetch(PDO::FETCH_BOTH); 161 162 $descr_cons2=$row[0]; 148 163 if ($do == "add") { 149 164 if ($id_cons2) { 150 165 // copia circoscrizione 151 $res=mysql_query("select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'", $dbi); 152 while (list($id,$idcirc,$num,$des2)=mysql_fetch_row($res)){ 153 $des=addslashes($des2); 154 $resconnew=mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'", $dbi); 155 list($contr_circ)=mysql_fetch_row($resconnew); 156 if (! $contr_circ){ 157 mysql_query("insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')", $dbi) || die("Impossibile inserire i dati delle circoscrizioni! ".mysql_error()); 158 } 159 $res0=mysql_query("select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num", $dbi); 160 list($id_circ)=mysql_fetch_row($res0); 166 $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'"; 167 $sth = $dbi->prepare("$sql"); 168 $sth->execute(); 169 $row = $sth->fetchAll(); 170 foreach($row as $arr){ 171 $id=$arr[0];$idcirc=$arr[1];$num=$arr[2];$des2=$arr[3]; 172 $des=addslashes($des2); 173 $sql="select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'"; 174 $sth = $dbi->prepare("$sql"); 175 $sth->execute(); 176 $row = $sth->fetch(PDO::FETCH_BOTH); 177 $contr_circ=$row[0]; 178 if (! $contr_circ){ 179 sql="insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')"; 180 $sth = $dbi->prepare("$sql"); 181 $sth->execute(); 182 183 } 184 $sql="select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num"; 185 $sth = $dbi->prepare("$sql"); 186 $sth->execute(); 187 $row = $sth->fetch(PDO::FETCH_BOTH); 188 $id_circ=$row[0]; 161 189 // copia sede 162 $res1=mysql_query("select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'", $dbi); 163 while(list($id1,$idsede1,$idcirc1,$ind2,$tel,$tel2,$fax,$resp,$mappa2,$filemappa2)=mysql_fetch_row($res1)){ 190 $sql="select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'"; 191 $sth = $dbi->prepare("$sql"); 192 $sth->execute(); 193 $row = $sth->fetchAll(); 194 foreach($row as $row2) { 195 $id1=$row2[0];$idsede1=$row2[1];$idcirc1=$row2[2];$ind2=$row2[3];$tel=$row2[4];$tel2=$row2[5];$fax=$row2[6];$resp=$row2[7];$mappa2=$row2[8];$filemappa2=$row2[9]; 164 196 $filemappa=addslashes($filemappa2); 165 197 $mappa=addslashes($mappa2); 166 198 $ind=addslashes($ind2); 167 $ressednew=mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'", $dbi); 168 list($contr_sed)=mysql_fetch_row($ressednew); 169 if (! $contr_sed){ 170 mysql_query("insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons2','$id_circ','$ind','$tel','$tel2','$fax','$resp','$mappa','$filemappa')", $dbi) || die("Impossibile inserire i dati delle sedi! ".mysql_error()); 171 } 172 $res2=mysql_query("select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'", $dbi); 199 $sql="select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'"; 200 $sth = $dbi->prepare("$sql"); 201 $sth->execute(); 202 $row = $sth->fetch(PDO::FETCH_BOTH); 203 $contr_sed=$row[0]; 204 if (! $contr_sed){ 205 $sql="insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons2','$id_circ','$ind','$tel','$tel2','$fax','$resp','$mappa','$filemappa')"; 206 $sth = $dbi->prepare("$sql"); 207 $sth->execute(); 208 } 209 $sql"select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'"; 173 210 list($id_sede)=mysql_fetch_row($res2); 211 $sth = $dbi->prepare("$sql"); 212 $sth->execute(); 213 $row = $sth->fetch(PDO::FETCH_BOTH); 214 $id_sede=$row[0]; 174 215 //copia sezione 175 $res3=mysql_query("select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1", $dbi); 176 while (list($id3,$idsez3,$idsede3,$numero,$maschi3,$femmine3,$validi3,$nulli3, 177 $bianchi3,$contest3,$sg3,$aut_m,$aut_f)=mysql_fetch_row($res3)){ 216 $sql="select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1"; 217 $sth = $dbi->prepare("$sql"); 218 $sth->execute(); 219 $row = $sth->fetchAll(); 220 foreach($row as $arr2) 221 { 222 $id3=$arr2[0];$idsez3=$arr2[1];$idsede3=$arr2[2];$numero=$arr2[3];$maschi3=$arr2[4];$femmine3=$arr2[5];$validi3=$arr2[6];$nulli3=$arr2[7]; 223 $bianchi3=$arr2[8];$contest3=$arr2[9];$sg3,$aut_m=$arr2[10];$aut_f=$arr2[11]; 178 224 if ($elettori=='true') $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez,maschi,femmine) values ('$id_cons2','$id_sede','$numero','$maschi3','$femmine3')"; 179 225 else $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez) values ('$id_cons2','$id_sede','$numero')"; 180 mysql_query("$sql", $dbi) || die("Impossibile inserire i dati delle sezioni! ".mysql_error()); 226 $sth = $dbi->prepare("$sql"); 227 $sth->execute(); 228 181 229 } 182 230 } … … 191 239 echo "[ <a href=\"admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=cons_comuni&do=elettori&id_cons_gen=$id_cons_gen&id_cons2=$id_cons2&ok=1\">"._YES."</a> ]";exit; 192 240 }else{ 193 $result = mysql_query("update ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sezioni as t2 set t1.maschi=t2.maschi, t1.femmine=t2.femmine WHERE t1.id_cons=$id_cons2 and t2.id_cons=$id_consulta and t1.num_sez=t2.num_sez", $dbi); 241 $sql="update ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sezioni as t2 set t1.maschi=t2.maschi, t1.femmine=t2.femmine WHERE t1.id_cons=$id_cons2 and t2.id_cons=$id_consulta and t1.num_sez=t2.num_sez"; 242 $sth = $dbi->prepare("$sql"); 243 $result=$sth->execute(); 244 194 245 if (!$result) return; 195 246 Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen"); … … 198 249 if ($do == "update") { 199 250 if ($predefinita) 200 $result = mysql_query("update ".$prefix."_ele_comuni set id_cons='$predefinita' WHERE id_comune='$id_comune'", $dbi); 201 else 202 $result = mysql_query("update ".$prefix."_ele_cons_comune set chiusa='$chiusa' WHERE id_cons2='$id_cons2'", $dbi); 203 if (!$result) return; 251 { 252 $sql="update ".$prefix."_ele_comuni set id_cons='$predefinita' WHERE id_comune='$id_comune'"; 253 $sth = $dbi->prepare("$sql"); 254 $result=$sth->execute(); 255 }else{ 256 $sql"update ".$prefix."_ele_cons_comune set chiusa='$chiusa' WHERE id_cons2='$id_cons2'"; 257 $sth = $dbi->prepare("$sql"); 258 $result=$sth->execute(); 259 } 260 if (!$result) return; 204 261 Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen"); 205 262 }
Note:
See TracChangeset
for help on using the changeset viewer.