dsl cyrano
<?php
include "connexion.php";
### Script trouvé sur PHPtools4u
############################
## Donnée préliminaires ##
############################
### French Version
$calendar_txt['french']['monthes'] = array('', 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet',
'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre');
$calendar_txt['french']['days'] = array('Lundi', 'Mardi', 'Mercredi','Jeudi', 'Vendredi', 'Samedi', 'Dimanche');
$calendar_txt['french']['first_day'] = 0;
$calendar_txt['french']['misc'] = array('Mois précédent', 'Mois suivant','Jour précédent', 'Jour suivant');
### English version
$calendar_txt['english']['monthes'] = array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October','November', 'December');
$calendar_txt['english']['days'] = array('Monday', 'Tuesday', 'Wednesday','Thursday', 'Friday', 'Saturday','Sunday');
$calendar_txt['english']['first_day'] = -1;
$calendar_txt['english']['misc'] = array('Previous month', 'Next month', 'Previous day', 'Next day');
function calendar($date = '') {
Global $link_on_day, $PHP_SELF, $params;
Global $HTTP_POST_VARS, $HTTP_GET_VARS;
Global $calendar_txt;
### Default Params
$param_d['calendar_id'] = 1; // Calendar ID
$param_d['calendar_columns'] = 5; // Nb of columns
$param_d['show_day'] = 1; // Show the day bar
$param_d['show_month'] = 1; // Show the month bar
$param_d['nav_link'] = 1; // Add a nav bar below
$param_d['link_after_date'] = 1; // Enable link on days after the current day
$param_d['link_before_date'] = 0; // Enable link on days before the current day
$param_d['link_on_day'] = $PHP_SELF.'?date=%%dd%%'; // Link to put on each day
$param_d['font_face'] = 'Verdana, Arial, Helvetica'; // Default font to use
$param_d['font_size'] = 10; // Font size in px
$param_d['bg_color'] = '#FFFFFF';
$param_d['today_bg_color'] = '#A9B4B3';
$param_d['font_today_color'] = '#FFFFFF';
$param_d['font_color'] = '#000000';
$param_d['font_nav_bg_color'] = '#A9B4B3';
$param_d['font_nav_color'] = '#FFFFFF';
$param_d['font_header_color'] = '#FFFFFF';
$param_d['border_color'] = '#3f6551';
$param_d['use_img'] = 1; // Use gif for nav bar on the bottom
### New params V2
$param_d['lang'] = 'french';
$param_d['font_highlight_color']= '#FF0000';
$param_d['bg_highlight_color'] = '#00FF00';
$param_d['day_mode'] = 0;
$param_d['time_step'] = 30;
$param_d['time_start'] = '0:00';
$param_d['time_stop'] = '24:00';
$param_d['highlight'] = array();
// Can be 'hightlight' or 'text'
$param_d['highlight_type'] = 'highlight';
$param_d['cell_width'] = 20;
$param_d['cell_height'] = '60px';
$param_d['short_day_name'] = 1;
$param_d['link_on_hour'] = $PHP_SELF.'?hour=%%hh%%';
### /Params
#######################
## Début du script ##
#######################
### Getting all params
while (list($key, $val) = each($param_d)) {
if (isset($params[$key])) {
$param[$key] = $params[$key];
}
else {
$param[$key] = $param_d[$key];
}
}
$monthes_name = $calendar_txt[$param['lang']]['monthes'];
$param['calendar_columns'] = ($param['show_day']) ? 7 : $param['calendar_columns'];
$date = priv_reg_glob_calendar('date');
if ($date == '') {
$timestamp = time();
}
else {
$month = substr($date, 4 ,2);
$day = substr($date, 6, 2);
$year = substr($date, 0 ,4);
$timestamp = mktime(0, 0, 0, $month, $day, $year);
}
$current_day = date("d", $timestamp);
$current_month = date('n', $timestamp);
$current_month_2 = date('m', $timestamp);
$current_year = date('Y', $timestamp);
$first_decalage = date("w", mktime(0, 0, 0, $current_month, 1, $current_year));
### Sunday is the _LAST_ day
$first_decalage = ( $first_decalage == 0 ) ? 7 : $first_decalage;
$current_day_index = date('w', $timestamp) + $calendar_txt[$param['lang']]['first_day'] - 1;
$current_day_index = ($current_day_index == -1) ? 7 : $current_day_index;
$current_day_name = $calendar_txt[$param['lang']]['days'][$current_day_index];
$current_month_name = $monthes_name[$current_month];
$nb_days_month = date("t", $timestamp);
$current_timestamp = mktime(23,59,59,date("m"), date("d"), date("Y"));
echo '<table width="80%" align="center" border="0" class="calendarTable" cellpadding="2" cellspacing="1">'."\n";
### Displaying the current month/year
echo '<tr>'."\n";
echo ' <td height="30" colspan="7" align="center" class="calendarTop">'."\n";
### Insert an img at will
### Si le calendrier est en day_mode
if ( $param['day_mode'] == 1 ) {
echo ' '.$current_day_name.' '.$current_day.' '.$current_month_name.' '.$current_year."\n";
}
else {
echo ' '.$current_month_name.' '.$current_year."\n";
}
echo ' </td>'."\n";
echo '</tr>'."\n";
### Building the table row with the days
if ($param['show_day'] == 1 && $param['day_mode'] == 0) {
echo '<tr align="center">'."\n";
$first_day = $calendar_txt[$param['lang']]['first_day'];
for ($i = $first_day; $i < 7 + $first_day; $i++) {
$index = ( $i >= 7) ? (7 + $i): $i;
$index = ($i < 0) ? (7 + $i) : $i;
$day_name = ( $param['short_day_name'] == 1 ) ? substr($calendar_txt[$param['lang']]['days'][$index], 0, 1) : $calendar_txt[$param['lang']]['days'][$index];
echo ' <td height="30" class="calendarHeader"><b>'.$day_name.'</b></td>'."\n";
}
echo '</tr>'."\n";
$first_decalage = $first_decalage - $calendar_txt[$param['lang']]['first_day'];
$first_decalage = ( $first_decalage > 7 ) ? $first_decalage - 7 : $first_decalage;
}
else {
$first_decalage = 0;
}
echo '<tr>';
$int_counter = 0;
# Filling with empty cells at the begining
for ($i = 1; $i < $first_decalage; $i++) {
echo '<td class="calendarDays"></td>'."\n";
$int_counter++;
}
### Building the table
for ($i = 1; $i <= $nb_days_month; $i++) {
### Do we highlight the current day ?
$i_2 = ($i < 10) ? '0'.$i : $i;
$highlight_current = ( isset($param['highlight'][date('Ym', $timestamp).$i_2]) );
### Row start
if ( ($i + $first_decalage) % $param['calendar_columns'] == 2 && $i != 1) {
echo '<tr>'."\n";
$int_counter = 0;
}
$css_2_use = ( $highlight_current ) ? 'HL' : 'Days';
$txt_2_use = ( $highlight_current && $param['highlight_type'] == 'text') ? '<br>'.$param['highlight'][date('Ym', $timestamp).$i_2] : '';
if ($i == $current_day) {
?>
<td class="calendarToday" onMouseover="javascript:this.style.background='#DDDDDD'" onMouseout="javascript:this.style.background='#A9B4B3'" onClick="location='form_calendar.php?d=<?php echo $current_year."-".$current_month."-".$i; ?>'" style="cursor:pointer;">
<?php echo $i.$txt_2_use; ?>
<?php
// récuperation de l'initiale du jour pour autoriser que les Samedi et Dimanche
$d = date("l", mktime(0,0,0,$current_month,$i,$current_year));
if (($d=='Friday') || ($d=='Saturday'))
{
?>
<table width="100%" border="0" align="center">
<tr>
<?php
$date = $current_year."-".$current_month."-".$i;
$sql_check_soiree = "SELECT id_soiree, date, pc_libres
FROM calendar_soiree
WHERE date='".$date."'";
$query_check_soiree = mysql_query($sql_check_soiree);
if ($result_check_soiree = mysql_fetch_array($query_check_soiree))
{
$soiree = 1;
// on recupere le nombre de pc libres pour cette soirée
$pc_libres = $result_check_soiree['pc_libres'];
}
else
{
$soiree = 0;
$pc_libres = '18';
}
$pc_res = 18 - $pc_libres;
//echo $pc_libres;
for ($i=1; $i<$pc_res; $i++)
{
?>
<td class="pc_res"></td>
<?php
if ($i > 6)
{
echo "</tr><tr>";
}
}
?>
</tr>
</table>
<?php
}
?>
</td>
<?php
}
elseif ($param['link_on_day'] != '') {
$loop_timestamp = mktime(0,0,0, $current_month, $i, $current_year);
if (( ($param['link_after_date'] == 0) && ($current_timestamp < $loop_timestamp)) || (($param['link_before_date'] == 0) && ($current_timestamp >= $loop_timestamp)) ){
?>
<td class="calendar<?php echo $css_2_use; ?>" onMouseover="javascript:this.style.background='#DDDDDD'" onMouseout="javascript:this.style.background='#FFFFFF'" onClick="location='form_calendar.php?d=<?php echo $current_year."-".$current_month."-".$i; ?>'" style="cursor:pointer;">
<?php echo $i.$txt_2_use; ?>
<?php
// récuperation de l'initiale du jour pour autoriser que les Samedi et Dimanche
$d = date("l", mktime(0,0,0,$current_month,$i,$current_year));
if (($d=='Friday') || ($d=='Saturday'))
{
?>
<br />
<table width="100%" border="0" align="center">
<tr>
<?php
$date = $current_year."-".$current_month."-".$i;
$sql_check_soiree = "SELECT id_soiree, date, pc_libres
FROM calendar_soiree
WHERE date='".$date."'";
$query_check_soiree = mysql_query($sql_check_soiree);
if ($result_check_soiree = mysql_fetch_array($query_check_soiree))
{
$soiree = 1;
// on recupere le nombre de pc libres pour cette soirée
$pc_libres = $result_check_soiree['pc_libres'];
}
else
{
$soiree = 0;
$pc_libres = '18';
}
echo $pc_libres;
$pc_res = 18 - $pc_libres;
//$pc_res = 5;
for ($i=1; $i<=$pc_res; $i+=1)
{
if (($i-1) % 6 == 0)
{
echo "</tr><tr>";
}
//construction cellule rouge
echo "<td background=\"#A41215\">$i</td>";
}
for ($nb_cases=$i;$nb_cases<=18;$nb_cases+=1)
{
if (($nb_cases-1) % 6 ==0)
{
echo "</tr><tr>";
}
//construction cellule blanche
echo "<td>$nb_cases</td>";
}
?>
</table>
<?php
}
?>
</td>
<?php
}
else {
?>
<td class="calendar<?php echo $css_2_use; ?>" onMouseover="javascript:this.style.background='#DDDDDD'" onMouseout="javascript:this.style.background='#FFFFFF'" onClick="location='form_calendar.php?d=<?php echo $current_year."-".$current_month."-".$i; ?>'" style="cursor:pointer;">
<?php echo $i.$txt_2_use; ?>
<?php
// récuperation de l'initiale du jour pour autoriser que les Samedi et Dimanche
$d = date("l", mktime(0,0,0,$current_month,$i,$current_year));
if (($d=='Friday') || ($d=='Saturday'))
{
?>
<table width="100%" border="0" align="center">
<tr>
<td class="pc_res">
<?php
$date = $current_year."-".$current_month."-".$i;
$sql_check_soiree = "SELECT id_soiree, date, pc_libres
FROM calendar_soiree
WHERE date='".$date."'";
$query_check_soiree = mysql_query($sql_check_soiree);
if ($result_check_soiree = mysql_fetch_array($query_check_soiree))
{
$soiree = 1;
// on recupere le nombre de pc libres pour cette soirée
$pc_libres = $result_check_soiree['pc_libres'];
}
else
{
$soiree = 0;
$pc_libres = '18';
}
echo $pc_libres;
?>
</td>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
</tr>
<tr>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
</tr>
<tr>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
<td class="pc_res"></td>
</tr>
</table>
<?php
}
?>
</td>
<?php
}
}
else {
echo '<td class="calendar'.$css_2_use.'">'.$i.'</td>'."\n";
}
$int_counter++;
### Row end
if ( ($i + $first_decalage) % ($param['calendar_columns'] ) == 1 ) {
echo '</tr>'."\n";
}
}
$cell_missing = $param['calendar_columns'] - $int_counter;
for ($i = 0; $i < $cell_missing; $i++) {
echo '<td class="calendarDays"></td>'."\n";
}
echo '</tr>'."\n";
### Display the nav links on the bottom of the table
if ($param['nav_link'] == 1) {
$previous_month = date("Ymd",
mktime( 12,
0,
0,
($current_month - 1),
$current_day,
$current_year
)
);
$previous_day = date("Ymd",
mktime( 12,
0,
0,
$current_month,
$current_day - 1,
$current_year
)
);
$next_day = date("Ymd",
mktime( 1,
12,
0,
$current_month,
$current_day + 1,
$current_year
)
);
$next_month = date("Ymd",
mktime( 1,
12,
0,
$current_month + 1,
$current_day,
$current_year
)
);
if ($param['use_img']) {
$g = '<img src="g.gif" border="0">';
$gg = '<img src="gg.gif" border="0">';
$d = '<img src="d.gif" border="0">';
$dd = '<img src="dd.gif" border="0">';
}
else {
$g = '<';
$gg = '<<';
$d = '>';
$dd = '>>';
}
if ( ($param['link_after_date'] == 0)
&& ($current_timestamp < mktime(0,0,0, $current_month, $current_day+1, $current_year))
) {
$next_day_link = '';
}
else {
$next_day_link = '<a href="'.$PHP_SELF.'?date='.$next_day.'" title="'.$calendar_txt[$param['lang']]['misc'][3].'">'.$d.'</a>'."\n";
}
if ( ($param['link_before_date'] == 0)
&& ($current_timestamp > mktime(0,0,0, $current_month, $current_day-1, $current_year))
){
$previous_day_link = '';
}
else {
$previous_day_link = '<a href="'.$PHP_SELF.'?date='.$previous_day.'" title="'.$calendar_txt[$param['lang']]['misc'][2].'">'.$g.'</a>'."\n";
}
if ( ($param['link_after_date'] == 0)
&& ($current_timestamp < mktime(0,0,0, $current_month+1, $current_day, $current_year))
) {
$next_month_link = '';
}
else {
$next_month_link = '<a href="'.$PHP_SELF.'?date='.$next_month.'" title="'.$calendar_txt[$param['lang']]['misc'][1].'">'.$dd.'</a>'."\n";
}
if ( ($param['link_before_date'] == 0)
&& ($current_timestamp >= mktime(0,0,0, $current_month, $current_day, $current_year))
){
$previous_month_link = '';
}
else {
$previous_month_link = '<a href="'.$PHP_SELF.'?date='.$previous_month.'" title="'.$calendar_txt[$param['lang']]['misc'][0].'">'.$gg.'</a>'."\n";
}
echo '<tr>'."\n";
echo ' <td colspan="'.$param['calendar_columns'].'" class="calendarBottom">'."\n";
echo ' <table width="100%" border="0" >';
echo ' <tr>'."\n";
echo ' <td width="50%" align="left" style="padding-left:20px;">'."\n";
echo $previous_month_link;
echo ' </td>'."\n";
echo ' <td width="50%" align="right" style="padding-right:20px;">'."\n";
echo $next_month_link;
echo ' </td>'."\n";
echo ' </tr>';
echo ' </table>';
echo ' </td>'."\n";
echo '</tr>'."\n";
}
echo '</table>'."\n";
}
function priv_reg_glob_calendar($var) {
Global $HTTP_GET_VARS, $HTTP_POST_VARS;
if (isset($HTTP_GET_VARS[$var])) {
return $HTTP_GET_VARS[$var];
}
elseif (isset($HTTP_POST_VARS[$var])) {
return $HTTP_POST_VARS[$var];
}
else {
return '';
}
}
?>
