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
|
function createwhere() {
$session =& JFactory::getSession();
$where = ' where published = 1 ';
if($type) {
//$typevalue = implode('","', $type);
$where .= ' and id_soustype='.$type.' ';
}
$retour = JRequest::getvar('retour');
if(!$retour){
$ou = JRequest::getvar('ou',false);
$quand = JRequest::getvar('quand',false);
$horaire = JRequest::getvar('horaire',false);
$qui = JRequest::getvar('qui',false);
$type = JRequest::getvar('type',false);
//$retour = JRequest::getvar('retour',false);
$limitstar = JRequest::getvar('limitstart',$session->get('qui',false));
}else{
$ou = $session->get('ou');
$quand = $session->get('quand');
$horaire = $session->get('horaire');
$qui = $session->get('qui');
$type = $session->get('type');
//$retour = $session->get('retour');
$limitstar = $session->get('limitstart');
}
$session->set('ou',$ou);
$session->set('quand',$quand);
$session->set('horaire',$horaire);
$session->set('qui',$qui);
$session->set('type',$type);
//$session->set('retour',$retour);
$session->set('limitstart',$limitstar);
$this->limitstart = $limitstar;
if($ou) {
$ouvalue = implode(',', $ou);
$where .= ' and lieu in ('.$ouvalue.') ';
}
if($quand) {
$quandvalue = explode(',', $quand);
$where .= ' and JOUR_DEBUT ="'.$quandvalue[0].'" and JOUR_FIN ="'.$quandvalue[1].'"';
}
if($horaire) {
/*$horairevalue = implode('","', $horaire);
$where .= ' and horaire_afficher in ("'.$horairevalue.'") ';*/
if(in_array('matin',$horaire)) {
$horairearray[] = ' HFIN < "12:00" ';
}
if(in_array('midi',$horaire)) {
$horairearray[] = ' (HDEB >= "12:00" and HFIN <= "14:00") ';
}
if(in_array('apresmidi',$horaire)) {
$horairearray[] = ' (HDEB > "14:00" and HFIN <= "18:00") ';
}
if(in_array('soir',$horaire)) {
$horairearray[] = ' HDEB > "18:00" ';
}
if(in_array('journeeentiere',$horaire)) {
$horairearray[] = ' (HDEB <= "10:00" and HFIN >= "17:00") ';
}
$where .= 'and ( '.implode(' or ', $horairearray ).' )';
}
if($qui) {
switch($qui){
case 'Adultes':
$where .= ' and age_min <= 24 and age_max >= 18';
break;
case 'Seniors':
$where .= ' and age_min >= 25 ';
break;
default :
$where .= ' and age_min <= '.$qui.' and age_max >= '.$qui.'';
break;
}
}
if($type) {
//$typevalue = implode('","', $type);
$where .= ' and id_soustype='.$type.' ';
}
return $where ;
} |
Partager