[254] | 1 | <?php
|
---|
| 2 | /************************************************************************/
|
---|
| 3 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 4 | /* by Roberto Gigli & Luciano Apolito */
|
---|
| 5 | /* http://www.eleonline.it */
|
---|
| 6 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
| 7 | /************************************************************************/
|
---|
| 8 | /* widget cerca candidato
|
---|
| 9 | by luciano apolito 2015 */
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | if (!defined('MODULE_FILE')) {
|
---|
| 13 | die ("You can't access this file dirrectly...");
|
---|
| 14 | }
|
---|
| 15 | global $id_comune;
|
---|
| 16 |
|
---|
| 17 | # validatore form
|
---|
| 18 | echo '
|
---|
| 19 | <script type="text/javascript">
|
---|
| 20 | function validateForm()
|
---|
| 21 | {
|
---|
| 22 | var x=document.forms["form_candi"]["cognome"].value;
|
---|
| 23 | if (x==null || x=="")
|
---|
| 24 | {
|
---|
| 25 |
|
---|
| 26 | return false;
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 | </script>
|
---|
| 30 | ';
|
---|
| 31 |
|
---|
| 32 | # form
|
---|
| 33 | echo '
|
---|
| 34 | <div><h5>Cerca il candidato</h5>
|
---|
| 35 | <form method="post" name="form_candi" action="" onsubmit="return validateForm()" >
|
---|
| 36 | Inserisci il cognome o/e il nome intero del candidato da cercare<br/>
|
---|
| 37 | <input type="text" name="cognome" maxlength="30" size="10" value="">';
|
---|
| 38 | echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\">";
|
---|
| 39 | echo '<input type="submit" value="Cerca">
|
---|
| 40 | </form>
|
---|
| 41 | </div>
|
---|
| 42 | ';
|
---|
| 43 |
|
---|
| 44 | if(isset($_SESSION['cerca_cand'])) $cerca_cand=$_SESSION['cerca_cand']; else $cerca_cand="";
|
---|
| 45 | echo $cerca_cand;
|
---|
| 46 | $_SESSION['cerca_cand']='';
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | $url=$_SERVER['REQUEST_URI']; // url della pagina per il reload
|
---|
| 50 |
|
---|
| 51 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
| 52 | if (isset($param['cognome'])) get_magic_quotes_gpc() ? $cognome=$param['cognome']:$cognome=addslashes($param['cognome']); else $cognome='';
|
---|
| 53 | $chiave="$cognome";
|
---|
| 54 | global $id_comune;
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | if($cognome!=''){
|
---|
| 58 | # divide nome e cognome
|
---|
| 59 | $arr = explode(" ", $cognome);
|
---|
| 60 | $num_arr=count($arr);
|
---|
| 61 | if ($num_arr==2){
|
---|
| 62 | $cognome=$arr[0];
|
---|
| 63 | $nome=$arr[1];
|
---|
| 64 | $numeratore= " AND "; // cognome e nome
|
---|
| 65 | }else{
|
---|
| 66 | $nome=$cognome;
|
---|
| 67 | $numeratore= " OR "; // cognome o nome
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | $sql_cand= mysql_query("SELECT * FROM ".$prefix."_ele_candidati where ((cognome like '%$cognome%' $numeratore nome like '%$nome%') OR (cognome like '%$nome%'
|
---|
| 71 | $numeratore nome like '%$cognome%')) and id_cons in(select id_cons from ".$prefix."_ele_cons_comune where id_comune='$id_comune')", $dbi);
|
---|
| 72 | $num_tot = mysql_num_rows($sql_cand);
|
---|
| 73 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_candidati where ((cognome like '%$cognome%' $numeratore nome like '%$nome%') OR (cognome like '%$nome%' $numeratore nome like '%$cognome%')) and id_cons in(select id_cons from ".$prefix."_ele_cons_comune where id_comune='$id_comune') ORDER BY id_cand DESC LIMIT 0,7", $dbi);
|
---|
| 74 | while (list($id_cand,$id_cons2,$id_lista,$cognome,$nome,$note,$simbolo,$num_candidato) = mysql_fetch_row($res)) {
|
---|
| 75 | $res1 = mysql_query("SELECT id_cons_gen FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons2'" , $dbi);
|
---|
| 76 | list($id_cons_gen_cand) = mysql_fetch_row($res1);
|
---|
| 77 | $res2 = mysql_query("SELECT descrizione, tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen_cand'" , $dbi);
|
---|
| 78 | list($descr_consultazione,$tipo_consul) = mysql_fetch_row($res2);
|
---|
| 79 | $res3 = mysql_query("SELECT descrizione FROM ".$prefix."_ele_lista where id_lista='$id_lista'" , $dbi);
|
---|
| 80 | list($descr_lista) = mysql_fetch_row($res3);
|
---|
| 81 |
|
---|
| 82 | $res4 = mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons2'",$dbi);
|
---|
| 83 | $sezioni=mysql_num_rows($res4);
|
---|
| 84 | $cerca_cand .= "<div style=\"text-align:left\"><hr/>";
|
---|
| 85 | $cerca_cand .= "<img src=\"modules.php?name=Elezioni&file=foto&id_lista=$id_lista\" width=\"30\" heigth=\"30\" align=\"left\">";
|
---|
| 86 |
|
---|
| 87 | if($tipo_consul!='4'){ // non Ú circoscrizione
|
---|
| 88 | $cerca_cand .="<a href=\"modules.php?name=Elezioni&id_cons_gen=$id_cons_gen_cand&id_comune=$id_comune&op=candidato_sezione&min=$num_candidato&offset=$num_candidato&id_lista=$id_lista&orvert=1&offsetsez=$sezioni&id_circ=\">
|
---|
| 89 | $cognome $nome</a> $descr_consultazione - $descr_lista ";
|
---|
| 90 | }else{
|
---|
| 91 | $cerca_cand .= "$cognome $nome</a> $descr_consultazione - $descr_lista ";
|
---|
| 92 | }
|
---|
| 93 | $cerca_cand .='</div>';
|
---|
| 94 |
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | $cerca_cand .="<hr/>Trovati n.$num_tot con chiave <b>$chiave</b>";
|
---|
| 98 | if($num_tot>="8") $cerca_cand .="<br/>Raffina la ricerca...";
|
---|
| 99 |
|
---|
| 100 | $_SESSION['cerca_cand']=$cerca_cand;
|
---|
| 101 | header("location:$url ");
|
---|
| 102 | //$cognome='';
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | ?>
|
---|