1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
try{
$query = "SELECT * FROM marinterim_job_offers j
JOIN marimmo_villes v ON v.ville_id =j.job_ville ";
$where = array();
$param = array();
if (!empty($_REQUEST['job_searched']))
{ $where[] = "j.job_intitule=:job_intitule ";
$param[':job_intitule'] = $_REQUEST['job_searched'];
}
if (!empty($_REQUEST['job_keyword']))
{ $where[] = " j.job_descriptif LIKE CONCAT('%', :job_descriptif, '%') " ;
$param[':job_descriptif'] = $_REQUEST['job_keyword'];
}
$secteur_searched="";
if (!empty($_REQUEST['secteur_searched']) AND is_array($_REQUEST['secteur_searched']))
{ foreach ($_REQUEST["secteur_searched"] as $selectedOption)
$secteur_searched.=$selectedOption.",";
}
if ($secteur_searched)
{ $secteur_searched = rtrim($secteur_searched, ',');
$where[] = "j.job_secteur IN (:job_secteur) " ;
$param[':job_secteur']= $secteur_searched; // var_dump($secteur_searched);
}
$type_de_contrat="";
if(!empty($_REQUEST['type_de_contrat']) AND count($_REQUEST['type_de_contrat']) > 0 )
{foreach ($_REQUEST["type_de_contrat"] as $selectedCheckbox)
$type_de_contrat.=$selectedCheckbox.",";
}
if ($type_de_contrat)
{ $type_de_contrat = rtrim($type_de_contrat, ',');
$where[]= "j.job_contrat IN (:job_contrat) " ;
$param[':job_contrat']= $type_de_contrat; var_dump($type_de_contrat);
}
if (!empty($where))
{
$query.= ' WHERE ' . implode(' AND ', $where); // WHERE crite1 AND critere2 AND critere 3,
}
$query.= " ORDER BY j.job_date_insertion DESC"; echo $query;
$sth =$marInterim ->prepare($query);
$sth->execute($param);
//print_r($sth->errorInfo());
$compte = $sth->fetchAll();
$nb_resultats = count($compte);
$errors['nb_resultats_recherche'] = $nb_resultats; // ok
/********************/
if ( !empty($_REQUEST['afficher_x_resultats']))
{ $per_page=$_REQUEST['afficher_x_resultats'];
}
else {$per_page=10; }
/* Results per page */
$nb_pages = ceil($nb_resultats/$per_page);
$current_page = isset($_REQUEST['page']) && ($_REQUEST['page'] > 0) && ($_REQUEST['page'] <= $nb_pages) ? $_REQUEST['page'] : 1;
$start = ($current_page-1)*$per_page; // $param[':start']= $start;
$query2= $query." LIMIT $start,$per_page ";
echo '<br /> $query2 = '.$query2;
$sth2 =$marInterim ->prepare($query2);
$sth2-> execute($param);
//print_r($sth2->errorInfo());
while($datos= $sth2->fetch(PDO::FETCH_ASSOC))
{ $en_date_insertion=$datos['job_date_insertion'];
$explode_insertion= explode("-", $en_date_insertion);
$date_insertion_fr = $explode_insertion[2]."-".$explode_insertion[1]."-".$explode_insertion[0];
$job_id= $datos['job_id'];
$job_intitule= strtoupper($datos['job_intitule']);
$job_ville = $datos['ville_nom'];
$job_cp = $datos['cp'];
echo "
<div class='offers btns'>
<a class='link_vers_offre' href='job_offer_detail.php?job_id=$job_id'>
<table id='table_liste_des_offres'>
<tr>
<td class='liste_intitule'> " .$job_intitule." </td>
<td class='liste_ref'>Offre n°" .$job_id." du ".$date_insertion_fr ." </td>
<td class='liste_ville'> ".$job_cp. " ".$job_ville." </td>
</tr>
</table>
</a>
</div>
";
}
} catch(Exception $e)
{ exit('<b>Catched exception at line '. $e->getLine() .' :</b> '. $e->getMessage());
}
} |