//-----------AFF LA DISPOS J----------------------
if($room->cal =="J")
{
//$title_cal='<h4><a href="#"><<</a> '.$this_month_letter.' '.$this_year_letter.' <a href="#" >>></a></h4>';
//va contenir trois tableau html 1 mois de l'année
//pour trois mois a partir de today
$table_cal= array();
$month1 = date('m');
$year1 = date('Y');
//show months ab today
for($r=0 ;$r<4 ;$r++)
{
//2 764 800 sec sur d'aller au mois suivant (32 (31 +1) jours)
//$this_month_letter=date('F',($r*2764800+time()));
//$this_month = JHTML::_('date', ($r*2764800+time()), '%B');
// annee de type aaaa
// $this_year_letter=date('Y',($r*2764800+time()));
//2 764 800 sec sur d'aller au mois suivant (32 (31 +1) jours)
$newdate = date("Y-m-d", mktime(0, 0, 0, $month1+$r, 1, $year1));
//$this_month_letter=date('F',($r*2764800+time()));
$this_month = JHTML::_('date', $newdate, '%B');
// annee de type aaaa
$this_year_letter= JHTML::_('date', $newdate, '%Y');
$table='<table border="1" style="width:150px; text-align:center;" >'."\n";
$table.='<tr><td colspan="7"><b>'.$this_month." ".$this_year_letter.'</b></td></tr>';
$table.='<tr style="background-color:#FDF5E6;"><td>'.JText::_( 'Mon').'</td>
<td>'.JText::_( 'Tue').'</td>
<td>'.JText::_( 'Wed').'</td>
<td>'.JText::_( 'Thu').'</td>
<td>'.JText::_( 'Fri').'</td>
<td>'.JText::_( 'Sat').'</td>
<td>'.JText::_( 'Sun').'</td></tr>';
$today_date= JHTML::_('date', $newdate, '%d-%m-%Y');
$today_num= JHTML::_('date', $newdate, '%d');
$today_letters= JHTML::_('date', $newdate, '%a');
$this_year=JHTML::_('date', $newdate, '%Y');
$this_month=JHTML::_('date', $newdate, '%m');
// $this_month+=$r;
//$fev= is_bissextile($this_year) ? 29 : 28 ;
//année bisextile
if( (is_int($this_year/4) && !is_int($this_year/100)) || is_int($this_year/400))
{
// Année bissextile
// vous remplacez le retour par ce que vou voulez
$fev=29;
}
else
{
$fev=28;
}
$max_day_month_array= array("31",$fev,"31","30","31","30","31","31","30","31","30","31") ;
$last_day_this_month= $max_day_month_array[$this_month-1];
$nb_weeks_before_today=ceil($today_num/7);
//nb semaine dans le mois arrondi a l'entier superieur
$nb_weeks_in_month= ceil($last_day_this_month/7);
//remontons les dispos pour chaque mois
// depuis lbresa_cal avec un between
// 1 jour du mois au dernier
$first_day_sql=$this_year."-".$this_month."-01";
$last_day_sql=$this_year."-".$this_month."-".$last_day_this_month;
$query="select
*
from
#__lbresa_cal
where
id_room=$room->id
and
date between
'$first_day_sql'
and
'$last_day_sql'
order by date asc ";
$db->setQuery($query);
$cal_liste=$db->loadObjectList();
//les jours de la semaine
$week= array("Mon","Tue","Wed","Thu","Fri","Sat","Sun");
//remplir la premiere semaine
//connaitre le nom du premier jour du mois
$first_day_month_letter=date('D',strtotime($this_year."-".$this_month."-01"));
//cherchons l'index de ce premier jour dans notre tableau week
$index=0;
for($i=0;$i<count($week);$i++)
{
if($week[$i]==$first_day_month_letter)
{
$index=$i;
}
}
//remplissons maintenant la premiere semaine de notre calendar
//les jour qui ne font pas parti du mois seront des cases blanches
$table.='<tr>';
for($i=0; $i<$index ; $i++)
{
$vide_space=" ";
$table.='<td style="background-color:#708090;">'.$vide_space.'</td>';
}
//les premiers jour du mois à remplir
$day_number=0;
for($i=$index; $i<count($week) ;$i++)
{
$day_number++;
//couleur des dispos
//$font_color=($cal_liste[$day_number-1]->dispo > 0) ? "green;" : "red;" ;
$cdate = date("Y-m-d",time());
if($cal_liste[$day_number-1]->dispo > 0 and $cal_liste[$day_number-1]->date >= $cdate)
{
$font_color = "black;";
$free=1;
}
else
{
$font_color = "white;";
$free=0;
}
//couleur des prix reduits
//$bg_color=($cal_liste[$day_number-1]->prixred>0) ? "#FFFF00;" :"#DCDCDC;";
if($cal_liste[$day_number-1]->prixred>0 and $cal_liste[$day_number-1]->date >= $cdate)
{
$bg_color = "#FFFF00;";
}
else
{
$bg_color = "#DCDCDC;";
}
if($cal_liste[$day_number-1]->prixred>0) { $day_price = $cal_liste[$day_number-1]->prixred." ".$monaie; } else { $day_price = $cal_liste[$day_number-1]->prix." ".$monaie; }
//italique et gras pour le today
$date=$day_number."-".$this_month."-".$this_year;
$font_style= ($date==date("d-m-Y",time())) ? "italic;" : "normal;";
$font_weight= ($date==date("d-m-Y",time())) ? "bold;" : "normal;";
$add = JHTML::_('date', $cal_liste[$day_number-1]->date, '%d-%m-%Y');
$add2 = JHTML::_('date', $cal_liste[$day_number-1]->date, '%Y-%m-%d');
if($free==1)
{
$table.='<td style="background-color:#86b200;"><a href="javascript:add_date(\''.$add.'\', \''.$add2.'\')" alt="'.$day_price.'" title="'.$day_price.'" style="color:'.$font_color.' font-style:'.$font_style.' font-weight:'.$font_weight.'">'.$day_number.'</a></td>';
}
else
{
$table.='<td style="background-color:red;"><span style="color:'.$font_color.' font-style:'.$font_style.' font-weight:'.$font_weight.'">'.$day_number.'</span></td>';
}
}
$table.='</tr>'."\n";
//on commence a compter le nombre de lignes ecrite pour corriger sir fevrier insuffisant
$nb_lines=1;
//remplissons les semaines restantes
//on part de 1 car nous avons deja rempli la premiere semaine
for($i=1;$i<=($nb_weeks_in_month);$i++)
{
$table.="<tr>";
for($j=0;$j<count($week);$j++)
{
$day_number++;
// day number ne doit pas depasser 30 ou 31
// au delà on y met un vide_space dans la case
if($day_number<=$last_day_this_month)
{
//couleur des dispos
//$font_color=($cal_liste[$day_number-1]->dispo > 0) ? "green;" : "red;" ;
$cdate = date("Y-m-d",time());
if($cal_liste[$day_number-1]->dispo > 0 and $cal_liste[$day_number-1]->date >= $cdate)
{
$font_color = "black;";
$free=1;
}
else
{
$font_color = "white;";
$free=0;
}
//couleur des prix reduits
//$bg_color=($cal_liste[$day_number-1]->prixred>0) ? "#FFFF00;" :"#DCDCDC;";
if($cal_liste[$day_number-1]->prixred>0 and $cal_liste[$day_number-1]->date >= $cdate)
{
$bg_color = "#FFFF00;";
}
else
{
$bg_color = "#DCDCDC;";
}
if($cal_liste[$day_number-1]->prixred>0) { $day_price = $cal_liste[$day_number-1]->prixred." ".$monaie; } else { $day_price = $cal_liste[$day_number-1]->prix." ".$monaie; }
//italique et gras pour le today
$date=$day_number."-".$this_month."-".$this_year;
$font_style= (date("d-m-Y",strtotime($date))==date("d-m-Y",time())) ? "italic;" : "normal;";
$font_weight= (date("d-m-Y",strtotime($date))==date("d-m-Y",time())) ? "bold;" : "normal;";
$add = JHTML::_('date', $cal_liste[$day_number-1]->date, '%d-%m-%Y');
$add2 = JHTML::_('date', $cal_liste[$day_number-1]->date, '%Y-%m-%d');
if($free==1)
{
$table.="<td style='background-color:#86b200;'><a href='javascript:add_date(\"".$add."\", \"".$add2."\")' alt='".$day_price."' title='".$day_price."' style='color:".$font_color." font-style:".$font_style." font-weight:".$font_weight." '>".$day_number."</a></td>";
}
else
{
$table.="<td style='background-color:red;'><span style='color:".$font_color." font-style:".$font_style." font-weight:".$font_weight." '>".$day_number."</span></td>";
}
}
else
{
$table.="<td style='background-color:#708090; color:#708090;'>".$vide_space."0</td>";
}
}
$table.="</tr>\n";
$nb_lines++;
}
// on verifie que le nombre de ligne est suffisant sinon on l'ajoute
if($nb_lines==5)
{
$table.="<tr>";
for($l=0;$l<count($week);$l++)
{
$table.="<td style='background-color:#708090; color:#708090;'>".$vide_space."0</td>";
}
$table.="</tr>\n";
}
$table.='</table>';
$table_cal[]=$table;
}// end for $r
// print_r($table_cal);
$topdate = date("Y-m-d", mktime(0, 0, 0, date('m')+3, 1, date('Y')));
$backdate = date("Y-m-d", mktime(0, 0, 0, date('m'), 1, date('Y')));
// erstellung des Kalender HTML Codes...
$dom_html= "<table width='100%' id='Kalenderloc' >\n";
$dom_html.= "<tr> <td width='5%'><!-- <img src='components/com_joomloc/images/fleche-G.gif' /> --></td>\n";
foreach($table_cal as $table)
{
$dom_html.="<td>".$table."</td>";
}
$dom_html.= "<td width='5%'><a href='javascript:moove_cal(2,\"".$topdate."\", $room->id)'><!-- <img src='components/com_joomloc/images/fleche-D.gif' /></a> --></td></tr></table>";
// aussgabe des Kalenders ...
echo $dom_html ;
echo "</div>";
}//END IF room cal J