Changeset 257 for trunk/admin/modules/Elezioni/ele_cons_comuni.php
- Timestamp:
- Feb 9, 2019, 8:45:24 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/modules/Elezioni/ele_cons_comuni.php
r256 r257 13 13 } 14 14 15 $aid=$_SESSION['aid']; 15 16 global $dbi; 16 $aid=$_SESSION['aid'];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 $sql="SELECT tipo_cons,descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' "; 26 $res = $dbi->prepare("$sql"); 27 $res->execute(); 28 list($tipo_cons,$descr_cons) = $res->fetch(PDO::FETCH_NUM); 25 29 include("modules/Elezioni/funzionidata.php"); 26 30 include("modules/Elezioni/ele.php"); 27 $row=descr_cons();28 $tipo_cons=$row[0];$descr_cons=$row[2];29 30 31 if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do=''; 31 32 if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok=''; … … 49 50 50 51 if (isset($help)) include("language/$language/ele_cons_comuni.html"); 51 $row=descr_comune(); 52 $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune=$id_comune", $dbi); 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); 52 53 $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune=$id_comune"; 54 $res = $dbi->prepare("$sql"); 55 $res->execute(); 56 if ($res->rowCount()) list($idpred) = $res->fetch(PDO::FETCH_NUM); else $idpred=''; 57 $sql="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' "; 58 $res = $dbi->prepare("$sql"); 59 $res->execute(); 60 $max = $res->rowCount(); 58 61 echo "<table border=\"0\" width=\"100%\" align=\"left\"><tr><td>"; 59 62 echo "<form name=\"imppred\" action=\"admin.php\">"; … … 61 64 ." <b>"._CONSPRED."</b> </td><td><select name=\"predefinita\">"; 62 65 echo "<option value=\"\">"; 63 foreach($row as $arr){66 while($arr=$res->fetch(PDO::FETCH_BOTH)){ 64 67 $sel=''; 65 68 if (($idpred)) … … 80 83 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._COPIA." "._NUM." "._ELETTORI."</b></td>" 81 84 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>"; 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(); 85 $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"; 86 $res = $dbi->prepare("$sql"); 87 $res->execute(); 86 88 $i=0; 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]; 89 while(list($chiusa,$id_cons2,$idconsgen2, $descr_cons, $data_inizio, $data_fine,$tipo) = $res->fetch(PDO::FETCH_NUM)) { 89 90 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1']; 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]; 91 $sql="select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'"; 92 $ressez = $dbi->prepare("$sql"); 93 $ressez->execute(); 94 list($somma)=$ressez->fetch(PDO::FETCH_NUM); 95 95 $data_inizio=form_data($data_inizio);$data_fine=form_data($data_fine); 96 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>" … … 151 151 if ($perms>32) { 152 152 $sql="select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune=$id_comune"; 153 $sth = $dbi->prepare("$sql"); 154 $sth->execute(); 155 $row = $sth->fetch(PDO::FETCH_BOTH); 156 $id_consulta=$row[0]; 153 $res = $dbi->prepare("$sql"); 154 $res->execute(); 155 list($id_consulta)=$res->fetch(PDO::FETCH_NUM); 157 156 $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"; 158 $sth = $dbi->prepare("$sql"); 159 $sth->execute(); 160 $row = $sth->fetch(PDO::FETCH_BOTH); 161 162 $descr_cons2=$row[0]; 157 $res = $dbi->prepare("$sql"); 158 $res->execute(); 159 list($descr_cons2)=$res->fetch(PDO::FETCH_NUM); 163 160 if ($do == "add") { 164 161 if ($id_cons2) { 165 162 // copia circoscrizione 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 } 163 $res=mysql_query("select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'", $dbi); 164 $res = $dbi->prepare("$sql"); 165 $res->execute(); 166 while (list($id,$idcirc,$num,$des2)=$res->fetch(PDO::FETCH_NUM)){ 167 $des=addslashes($des2); 168 $sql="select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'"; 169 $resconnew = $dbi->prepare("$sql"); 170 $resconnew->execute(); 171 list($contr_circ)=$resconnew->fetch(PDO::FETCH_NUM); 172 if (! $contr_circ){ 173 $sql="insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')"; 174 $res = $dbi->prepare("$sql"); 175 $res->execute(); 176 } 184 177 $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]; 178 $res0 = $dbi->prepare("$sql"); 179 $res0->execute(); 180 list($id_circ)=$res0->fetch(PDO::FETCH_NUM); 189 181 // copia sede 190 182 $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]; 183 $res1 = $dbi->prepare("$sql"); 184 $res1->execute(); 185 while(list($id1,$idsede1,$idcirc1,$ind2,$tel,$tel2,$fax,$resp,$mappa2,$filemappa2)=$res1->fetch(PDO::FETCH_NUM)){ 196 186 $filemappa=addslashes($filemappa2); 197 187 $mappa=addslashes($mappa2); 198 188 $ind=addslashes($ind2); 199 189 $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]; 190 $resswdnew = $dbi->prepare("$sql"); 191 $ressednew->execute(); 192 list($contr_sed)=$ressednew->fetch(PDO::FETCH_NUM); 204 193 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'"; 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]; 194 $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')"; 195 $res0 = $dbi->prepare("$sql"); 196 $res0->execute(); 197 } 198 $sql="select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'"; 199 $res2 = $dbi->prepare("$sql"); 200 $res2->execute(); 201 list($id_sede)=$res2->fetch(PDO::FETCH_NUM); 215 202 //copia sezione 216 203 $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]; 204 $res3 = $dbi->prepare("$sql"); 205 $res3->execute(); 206 while (list($id3,$idsez3,$idsede3,$numero,$maschi3,$femmine3,$validi3,$nulli3, 207 $bianchi3,$contest3,$sg3,$aut_m,$aut_f)=$res3->fetch(PDO::FETCH_NUM)){ 224 208 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')"; 225 209 else $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez) values ('$id_cons2','$id_sede','$numero')"; 226 $sth = $dbi->prepare("$sql"); 227 $sth->execute(); 228 210 $res3 = $dbi->prepare("$sql"); 211 $res3->execute(); 229 212 } 230 213 } … … 240 223 }else{ 241 224 $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 245 if (!$result) return; 225 $result = $dbi->prepare("$sql"); 226 $result->execute(); 227 if (!$result->rowCount()) return; 246 228 Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen"); 247 229 } 248 230 } 249 231 if ($do == "update") { 250 if ($predefinita) 251 { 232 if ($predefinita) { 252 233 $sql="update ".$prefix."_ele_comuni set id_cons='$predefinita' WHERE id_comune='$id_comune'"; 253 $ sth= $dbi->prepare("$sql");254 $result =$sth->execute();234 $result = $dbi->prepare("$sql"); 235 $result->execute(); 255 236 }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;237 $sql="update ".$prefix."_ele_cons_comune set chiusa='$chiusa' WHERE id_cons2='$id_cons2'"; 238 $result = $dbi->prepare("$sql"); 239 $result->execute(); 240 } 241 if (!$result->rowCount()) return; 261 242 Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen"); 262 243 }
Note:
See TracChangeset
for help on using the changeset viewer.