source: trunk/client/modules/Elezioni/blocchi/cerca_candidato.php@ 270

Last change on this file since 270 was 270, checked in by roby, 6 years ago

sistemazione dei controlli di congruità per il rosatellum
adattamento del file per il linguaggio italiano

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