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

Last change on this file since 347 was 347, checked in by roby, 3 years ago

Aggiornamento per compatibilità con php7.4

File size: 4.9 KB
RevLine 
[315]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 */
[347]10# http://localhost/ele3/trunk/client/modules.php?cognome=vince&id_comune=58047&op=gruppo&name=Elezioni&file=index&id_cons_gen=66
11# http://localhost/ele3/trunk/client/modules.php?op=gruppo&name=Elezioni&id_comune=58047&file=index&id_cons_gen=66
[315]12if (!defined('MODULE_FILE')) {
13 die ("You can't access this file dirrectly...");
14}
[347]15global $id_comune,$id_cons_gen,$op;
[315]16
17# validatore form
18echo '
[347]19 <script>
[315]20function 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
[347]33#$url=$_SERVER['REQUEST_URI']; // url della pagina per il reload
34
35echo "
[315]36 <div><h5>Cerca il candidato</h5>
[347]37 <form method=\"get\" name=\"form_candi\" action=\"modules.php\" onsubmit='return validateForm()' >
[315]38 Inserisci il cognome o/e il nome intero del candidato da cercare<br/>
[347]39 <input type=\"text\" name=\"cognome\" maxlength=\"30\" size=\"10\" value=\"\">";
40echo "<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"><input type=\"hidden\" name=\"op\" value=\"$op\"><input type=\"hidden\" name=\"name\" value=\"Elezioni\"><input type=\"hidden\" name=\"file\" value=\"index\"><input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
41echo "<input type=\"submit\" value=\"Cerca\">
[315]42 </form>
43 </div>
[347]44";
[315]45
46
47
48
[347]49
[315]50$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
[344]51if (isset($param['cognome'])) $cognome=addslashes($param['cognome']); else $cognome='';
[315]52$chiave="$cognome";
[347]53$cerca_cand="";
54$_SESSION['cerca_cand']='';
[315]55
56if($cognome!=''){
57 # divide nome e cognome
58 $arr = explode(" ", $cognome);
59 $num_arr=count($arr);
60 if ($num_arr==2){
61 $cognome=$arr[0];
62 $nome=$arr[1];
63 $numeratore= " AND "; // cognome e nome
64 }else{
65 $nome=$cognome;
66 $numeratore= " OR "; // cognome o nome
67 }
68
69 $sql="SELECT * FROM ".$prefix."_ele_candidati where ((cognome like '%$cognome%' $numeratore nome like '%$nome%') OR (cognome like '%$nome%'
[265]70 $numeratore nome like '%$cognome%')) and id_cons in(select id_cons from ".$prefix."_ele_cons_comune where id_comune='$id_comune')";
71 $res = $dbi->prepare("$sql");
72 $res->execute();
[315]73
74 $num_tot = $res->rowCount();
[265]75 $sql="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";
76 $res = $dbi->prepare("$sql");
77 $res->execute();
[315]78
79 while (list($id_cand,$id_cons2,$id_lista,$cognome,$nome,$note,$simbolo,$num_candidato) = $res->fetch(PDO::FETCH_NUM)) {
[265]80 $sql="SELECT id_cons_gen FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons2'" ;
81 $resl = $dbi->prepare("$sql");
82 $resl->execute();
[315]83
84 list($id_cons_gen_cand) = $resl->fetch(PDO::FETCH_NUM);
[265]85 $sql="SELECT descrizione, tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen_cand'" ;
86 $res2 = $dbi->prepare("$sql");
87 $res2->execute();
[315]88
89 list($descr_consultazione,$tipo_consul) = $res2->fetch(PDO::FETCH_NUM);
[265]90 $sql="SELECT descrizione FROM ".$prefix."_ele_lista where id_lista='$id_lista'" ;
91 $res3 = $dbi->prepare("$sql");
92 $res3->execute();
[315]93
94 list($descr_lista) = $res3->fetch(PDO::FETCH_NUM);
95
[265]96 $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons2'";
97 $res4 = $dbi->prepare("$sql");
98 $res4->execute();
[315]99
100 $sezioni=$res4->rowCount();
101 $cerca_cand .= "<div style=\"text-align:left\"><hr/>";
[347]102 $cerca_cand .= "<img src=\"modules.php?name=Elezioni&amp;file=foto&amp;id_lista=$id_lista\" alt=\"foto\" style=\"width:30px; text-align:left;\">";
[315]103
104 if($tipo_consul!='4'){ // non Ú circoscrizione
105 $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=\">
106 $cognome $nome</a> $descr_consultazione - $descr_lista ";
107 }else{
108 $cerca_cand .= "$cognome $nome</a> $descr_consultazione - $descr_lista ";
109 }
110 $cerca_cand .='</div>';
111
112 }
113
114 $cerca_cand .="<hr/>Trovati n.$num_tot con chiave <b>$chiave</b>";
115 if($num_tot>="8") $cerca_cand .="<br/>Raffina la ricerca...";
116
117 $_SESSION['cerca_cand']=$cerca_cand;
[347]118# header("location:$url");
[315]119 //$cognome='';
120}
[347]121if(isset($_SESSION['cerca_cand'])) $cerca_cand=$_SESSION['cerca_cand']; else $cerca_cand="";
122echo $cerca_cand;
123$_SESSION['cerca_cand']='';
[315]124
125
126?>
Note: See TracBrowser for help on using the repository browser.