Calendrier multi-usage en php (sans bdd)

Description

Voici encore un calendrier PHP. Celui-ci dispose de nombreuses fonctionnalités et est entièrement et facilement paramètrable. Il y a une description et des explications plus approfondies dans la doc au format pdf.

Source / Exemple :

&#65279;<?php

/********************************************************************************************
                       calendrier.php  -  Fonction PHP permettant l'ajout d'un calendrier

                             -------------------
  Version phptools4u.com

    Début des travaux    : Juin 2002 pour la version simple de phptools4u.com

    Version				 : 2.1 (Jan 04)

    copyleft             : (C) 2002-2003 PHPtools4U.com - Mathieu LESNIAK

	email                : support@phptools4u.com
	
  Version modifiée par Jérémie WALTER
    Début des travaux    : Janvier 2009
    Version              : 3.0 (Janvier 2009)
    copyleft             : Jérémie WALTER - GNU/GPL v3
    email                : jeremie.walter@gmail.com

*********************************************************************************************/



/********************************************************************************************

 *

 *   This program is free software; you can redistribute it and/or modify

 *   it under the terms of the GNU General Public License as published by

 *   the Free Software Foundation; either version 2 of the License, or

 *   (at your option) any later version.

 *

 ********************************************************************************************/





### Version Francaise

$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');



### Version Anglaise

$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');

										

### Version Espagnol

$calendar_txt['spanish']['monthes']     = array('', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio',

											'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');

$calendar_txt['spanish']['days']        = array('Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado', 'Domingo');

$calendar_txt['spanish']['first_day']   = 0;

$calendar_txt['spanish']['misc']        = array('Mes anterior', 'Mes pr&oacute;ximo', 'd&iacute;a anterior', 'd&iacute;a siguiente');

											

### Version Allemande

$calendar_txt['german']['monthes']	    = array('', 'Januar', 'Februar', 'M&auml;rz', 'April', 'Mai', 'Juni', 'Juli',

											'August', 'September', 'Oktober','November', 'Dezember');

$calendar_txt['german']['days']         = array('Montag', 'Dienstag', 'Mittwoch', 'Donnerstag','Freitag','Samstag', 'Sonntag');

$calendar_txt['german']['first_day']    = 0;

$calendar_txt['german']['misc']         = array('Vorhergehender Monat', 'Folgender Monat', 'Vorabend', 'Am n&auml;chsten Tag');





function calendar($url='',$lnk='',$params=Array()) {

	$date = '';

	Global $link_on_day, $PHP_SELF;

	Global $calendar_txt;

	$img = $url;			//Permet d'utiliser la fonction calendrier à un endroit différent de son répertoire de stockage



	### Paramêtres par défaut (utilisés si le tableau $params n'est pas donné en entrée)

	

	$param_d['calendar_id']			= 1; // ID du calendrier. Par défaut à 1, incrémenter cette valeur pour utiliser plusieurs calendriers sur la même page.

	$param_d['calendar_columns'] 	= 5; // Nombre de colonnes. Par défaut à 7, modifier ce nombre pour diminuer / augmenter le nombres de colonnes.

	$param_d['show_day'] 			= 1; // Par défaut à 1, permet d'afficher la barre des jours en haut du calendrier (L M M J V S D)

	$param_d['show_month']			= 1; // Par défaut à 1, permet d'afficher le nom du mois et l'année en haut du calendrier

	$param_d['nav_link']			= 1; // Par défaut à 1, affiche les liens pour les jours et mois précédents / suivants

	$param_d['link_after_date']		= 1; // Par défaut à 0, si activé, affiche les liens de la navigation (cf ci-dessus) pour les dates supérieures au jour en cours

	$param_d['link_before_date']	= 1; // Par défaut à 0, si activé, affiche les liens de la navigation (cf ci-dessus) pour les dates antérieures au jour en cours

	//$param_d['link_on_day']			= $PHP_SELF.'?'.$lnk; // Lien à attribuer sur les jours du calendrier. A chaque lien est rajouté la date en argument. Prévoir de mettre '?argument=' en fin de lien
	$param_d['link_on_day']			= $PHP_SELF.'?'.$lnk.'date=%%dd%%';

	$param_d['font_face']			= 'Verdana, Arial, Helvetica'; // Police a utiliser (par défaut : 'Verdana, Arial, Helvetica')

	$param_d['font_size']			= 10; // Taille de la police moyenne en pixels (10 par défaut)	

	$param_d['bg_color']			= '#FFFFFF'; // Couleur du fond des cases des jours (blanc - #FFFFFF par défaut)

	$param_d['today_bg_color']		= '#A0C0C0'; // Couleur de fond de la case du jour en cours

	$param_d['font_today_color']	= '#990000'; // Couleur de la police pour le jour en cours

	$param_d['font_color']			= '#000000'; // Couleur de la police

	$param_d['font_nav_bg_color']	= '#A9B4B3'; // Couleur de fond pour la barre des jours (L M M J V S D)

	$param_d['font_nav_color']		= '#FFFFFF'; // Couleur de la police pour la barre des jours (L M M J V S D)

	$param_d['font_header_color']	= '#FFFFFF'; // Couleur de la police pour le nom du mois

	$param_d['border_color']		= '#3f6551'; // Couleur pour les séparation des cases et des bordures

	$param_d['use_img']				= 1; // Utilise des fichiers gif à côté du nom du mois et pour la barre de navigation en bas. Si défini à '0', affiche les liens textes.

	$param_d['lang']				= 'french'; // Permet de changer la langue utilisée pour le calendrier. Les valeurs sont french (par défaut), english, german et spanish

	$param_d['font_highlight_color']= '#000000'; // Couleur de la police pour les jours mis en valeur.

	$param_d['bg_highlight_color']  = '#FF0000'; // Couleur de fond de la cellule pour les jours mis en valeur.

	$param_d['day_mode']			= 0; // Passé à 1, cette variable permet d'afficher le calendrier pour un seul jour avec les heures.

	$param_d['time_step']			= 30; // Nombre de minutes séparant chaque étape pour le calendrier en mode jour (day_mode = 1).

	$param_d['time_start']			= '0:00'; // Heure de départ pour le calendrier en mode jour (day_mode = 1). Format : HH:MM

	$param_d['time_stop']			= '24:00'; // Heure de fin pour le calendrier en mode jour (day_mode = 1). Format : HH:MM.

	$param_d['highlight']			= ''; // Tableau PHP (array) pour mettre en valeur certains jours ou heures. Pour les jours, le format est : array('AAAAMMJJ' => 'mon texte'), alors que pour les heures, le format est : array('AAAAMMJJHHmm' => 'mon texte') (Plus de détail dans la documentation)

    $param_d['highlight_type']      = 'highlight'; // Permet d'afficher un texte pour un jour mis en valeur (highlight_type = text), ou juste une mise en valeur (highlight_type = highlight).

    $param_d['cell_width']          = 20; // Définit la largeur des cases en pixels.

    $param_d['cell_height']         = 20; // Définit la hauteur des cases en pixels.

    $param_d['short_day_name']      = 1; // Si cette valeur vaut 0, les jours dans la barre du haut sont affichés en complet (Lundi, Mardi, etc), sinon de manière raccourcie (L, M, M, J, etc).

    $param_d['link_on_hour']        = $PHP_SELF.'?'.$lnk.'hour=%%hh%%'; // Lien appliqué sur les heures en mode jour (day_mode = 1). ex : index.php?heure=%%hh%%. Les %%hh%% seront automatiquement remplacé lors de l'affichage
    
    ### Paramètres pour la multi-coloration 
    $param_d['use_multistatut'] = false; // Permet d'utiliser le mode multi-statut (plus de détail dans la documentation)
    $param_d['statut'] = Array(); // Tableau multi-dimensionnel comportant les statut du table $dates (plus de détail dans la documentation)
    $param_d['aff_link'] = false; // Permet de choisir si l'on veut afficher les liens sur les jours/heures du calendrier
    $param_d['nav_bar'] = false; // Permet l'affichage d'un formulaire de choix de date

	

	### Fin des paramètres par défaut

	

	### Construction du tableau des paramètres. Si des paramètres persos sont utilisés ($params) ils sont pris sinon, on utilise ceux par défaut.

	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"));

	

	### Création de la feuille de style

	$output  = '<style type="text/css">'."\n";

	$output .= '<!--'."\n";

	$output .= '	.calendarNav'.$param['calendar_id'].' 	{  font-family: '.$param['font_face'].'; font-size: '.($param['font_size']-1).'px; font-style: normal; background-color: '.$param['border_color'].'}'."\n";

	$output .= '	.calendarTop'.$param['calendar_id'].' 	{  font-family: '.$param['font_face'].'; font-size: '.($param['font_size']+1).'px; font-style: normal; color: '.$param['font_header_color'].'; font-weight: bold;  background-color: '.$param['border_color'].'}'."\n";

	$output .= '	.calendarToday'.$param['calendar_id'].' {  font-family: '.$param['font_face'].'; font-size: '.$param['font_size'].'px; font-weight: bold; color: '.$param['font_today_color'].'; background-color: '.$param['today_bg_color'].';}'."\n";

	$output .= '	.calendarDays'.$param['calendar_id'].' 	{  width:'.$param['cell_width'].'; height:'.$param['cell_height'].'; font-family: '.$param['font_face'].'; font-size: '.$param['font_size'].'px; font-style: normal; color: '.$param['font_color'].'; background-color: '.$param['bg_color'].'; text-align: center}'."\n";

	$output .= '	.calendarHL'.$param['calendar_id'].' 	{  width:'.$param['cell_width'].'; height:'.$param['cell_height'].';font-family: '.$param['font_face'].'; font-size: '.$param['font_size'].'px; font-style: normal; color: '.$param['font_highlight_color'].'; background-color: '.$param['bg_highlight_color'].'; text-align: center}'."\n";
	//Debut CSS pour la partie multi-statut
	if ($param['use_multistatut']) {
		foreach($param['statut'] as $cle => $tab) {
			foreach($tab as $couleur) {
				$output .= '	.calendarHL'.$cle.$param['calendar_id'].' 	{  width:'.$param['cell_width'].'; height:'.$param['cell_height'].';font-family: '.$param['font_face'].'; font-size: '.$param['font_size'].'px; font-style: normal; color: '.$param['font_highlight_color'].'; background-color: '.$couleur.'; text-align: center}'."\n";
			}
		}
	}
	//Fin CSS pour la partie multi-statut
	

	$output .= '	.calendarHeader'.$param['calendar_id'].'{  font-family: '.$param['font_face'].'; font-size: '.($param['font_size']-1).'px; background-color: '.$param['font_nav_bg_color'].'; color: '.$param['font_nav_color'].';}'."\n";

	$output .= '	.calendarTable'.$param['calendar_id'].' {  background-color: '.$param['border_color'].'; border: 1px '.$param['border_color'].' solid}'."\n";

	$output .= '-->'."\n";

	$output .= '</style>'."\n";

	$output .= '<table align="center" border="0" class="calendarTable'.$param['calendar_id'].'" cellpadding="2" cellspacing="1">'."\n";

	

	### Affichage du mois et de l'année

	if ($param['show_month'] == 1) {

		$output .= '<tr>'."\n";

		$output .= '	<td colspan="'.$param['calendar_columns'].'" align="center" class="calendarTop'.$param['calendar_id'].'">'."\n";

		### Affichage de l'image a coté du mois

		if ($param['use_img'] ) {

			$output .= '<img src="'.$img.'mois.gif">';

		}

		if ( $param['day_mode'] == 1 ) {

			$output .= '		'.$current_day_name.' '.$current_day.' '.$current_month_name.' '.$current_year."\n";

		}

		else {

			$output .= '		'.$current_month_name.' '.$current_year."\n";

		}

		$output .= '	</td>'."\n";

		$output .= '</tr>'."\n";

	}

	

	### Création de la table des jours

	if ($param['show_day'] == 1 && $param['day_mode'] == 0) {

		$output .= '<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];

			$output .= '	<td class="calendarHeader'.$param['calendar_id'].'"><b>'.$day_name.'</b></td>'."\n";

		}

		

		$output .= '</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;	

	}

	

	$output .= '<tr align="center">';

	$int_counter = 0;

	

	

	if ( $param['day_mode'] == 1 ) { // Cas du mode jour/heure

		list($hour_start, $min_start) 	= explode(':', $param['time_start']);

		list($hour_end, $min_end)		= explode(':', $param['time_stop']);

		$ts_start 	= ( $hour_start * 60 ) + $min_start;

		$ts_end		= ( $hour_end * 60 ) + $min_end;

		$nb_steps	= ceil( ($ts_end - $ts_start) / $param['time_step'] );

		

		for ( $i = 0; $i <= $nb_steps; $i++ ) {

            $current_ts		= ($ts_start) + $i * $param['time_step'];

			$current_hour 	= floor($current_ts / 60);

			$current_min 	= $current_ts % 60;

			$current_hour 	= (strlen($current_hour) < 2) ? '0'.$current_hour : $current_hour;

			$current_min 	= (strlen($current_min) < 2) ? '0'.$current_min : $current_min;

		

   			$highlight_current  = ( isset($param['highlight'][date('Ymd', $timestamp).$current_hour.$current_min]) );

            $css_2_use          = ( $highlight_current ) ? 'HL' : 'Days';

            $txt_2_use          = ( $highlight_current && $param['highlight_type'] == 'text') ? $param['highlight'][date('Ymd', $timestamp).$current_hour.$current_min] : '';
            //DEBUT PHP multi-statut
            if($highlight_current and $param['use_multistatut']) {
            	$css = 'HL';
				$statut = $param['highlight'][date('Ymd', $timestamp).$current_hour.$current_min];
				$css_2_use = $css.$statut;
            }
            //FIN PHP multi-statut


			$output .= '<tr>'."\n";

            if ( $param['link_on_hour'] != '') {
            	if($param['aff_link']) {

	                $output .= '	<td class="calendar'.$css_2_use.$param['calendar_id'].'" width="10%"><a href="'.str_replace('%%hh%%', date('Ymd', $timestamp).$current_hour.$current_min, $param['link_on_hour']).'">'.$current_hour.':'.$current_min.'</a></td>'."\n";
	               } else {
	               	$output .= '	<td class="calendar'.$css_2_use.$param['calendar_id'].'" width="10%">'.$current_hour.':'.$current_min.'</td>'."\n";
	               }

            }

            else {

                $output .= '	<td class="calendar'.$css_2_use.$param['calendar_id'].'" width="10%">'.$current_hour.':'.$current_min.'</td>'."\n";

            }

			$output .= '    <td class="calendar'.$css_2_use.$param['calendar_id'].'">'.$txt_2_use.'</td>	'."\n";

			$output .= '</tr>'."\n";	

		}

		

	}

	else { // Cas du mode mois/jour

		# Remplissage en début de tableau avec des cellules vides si necessaire

		for ($i = 1; $i < $first_decalage; $i++) {

			$output .= '<td class="calendarDays'.$param['calendar_id'].'">&nbsp;</td>'."\n";

			$int_counter++;

		}

		### Construction de la table

		for ($i = 1; $i <= $nb_days_month; $i++) {

			### Coloration du jours en cours si demandé

			$i_2 = ($i < 10) ? '0'.$i : $i;		

		    $highlight_current = ( isset($param['highlight'][date('Ym', $timestamp).$i_2]) );
		    

			### Début de la ligne de jours

			if ( ($i + $first_decalage) % $param['calendar_columns'] == 2 && $i != 1) {

				$output .= '<tr align="center">'."\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] : '';
            //DEBUT PHP multi-statut
            if($highlight_current and $param['use_multistatut']) {
            	$css = 'HL';
				$statut = $param['highlight'][date('Ym', $timestamp).$i_2];
				$css_2_use = $css.$statut;
            }
            //FIN PHP multi-statut

            

            if ($i == $current_day) {

				$output .= '<td class="calendarToday'.$param['calendar_id'].'" align="center">'.$i.$txt_2_use.'</td>'."\n";

			}

			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)) ){

					$output .= '<td class="calendar'.$css_2_use.$param['calendar_id'].'">'.$i.$txt_2_use.'</td>'."\n";

				}

				else {
					if($param['aff_link']) {

						$output .= '<td class="calendar'.$css_2_use.$param['calendar_id'].'"><a href="'.str_replace('%%dd%%', $current_year.$current_month_2.$i_2,$param['link_on_day']).'">'.$i.'</a>'.$txt_2_use.'</td>'."\n";
					} else {
						$output .= '<td class="calendar'.$css_2_use.$param['calendar_id'].'">'.$i.$txt_2_use.'</td>'."\n";
					}

				}

			}

			else {

				$output .= '<td class="calendar'.$css_2_use.$param['calendar_id'].'">'.$i.'</td>'."\n";

			}	

			$int_counter++;

			

			### Fin de la ligne

			if (  ($i + $first_decalage) % ($param['calendar_columns'] ) == 1 ) {

				$output .= '</tr>'."\n";	

			}

		}

		$cell_missing = $param['calendar_columns'] - $int_counter;

		

		for ($i = 0; $i < $cell_missing; $i++) {

			$output .= '<td class="calendarDays'.$param['calendar_id'].'">&nbsp;</td>'."\n";

		}

		$output .= '</tr>'."\n";

	}

	### Affichage des liens de navigation en fin de 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']) { // Lien sous forme d'image si demandé

			$g 	= '<img src="'.$img.'g.gif" border="0">';

			$gg = '<img src="'.$img.'gg.gif" border="0">';

			$d 	= '<img src="'.$img.'d.gif" border="0">';

			$dd = '<img src="'.$img.'dd.gif" border="0">';

		}

		else {

			$g 	= '&lt;';

			$gg = '&lt;&lt;';

			$d = '&gt;';

			$dd = '&gt;&gt;';

		}



		if ( ($param['link_after_date'] == 0) 

				&& ($current_timestamp <= mktime(0,0,0, $current_month, $current_day+1, $current_year))

			) {

			$next_day_link = '&nbsp;';

		}

		else {

			$next_day_link 		= '<a href="'.$PHP_SELF.'?'.$lnk.'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, $current_year))

			){

			$previous_day_link = '&nbsp;';

		}

		else {

			$previous_day_link 		= '<a href="'.$PHP_SELF.'?'.$lnk.'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 = '&nbsp;';		

		}

		else {

			$next_month_link 	= '<a href="'.$PHP_SELF.'?'.$lnk.'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-1, $current_day, $current_year))

			){

			$previous_month_link = '&nbsp;';		

		}

		else {

			$previous_month_link 	= '<a href="'.$PHP_SELF.'?'.$lnk.'date='.$previous_month.'" title="'.$calendar_txt[$param['lang']]['misc'][0].'">'.$gg.'</a>'."\n";

		}

		
		// Génération du code source

		$output .= '<tr>'."\n";

		$output .= '	<td colspan="'.$param['calendar_columns'].'" class="calendarDays'.$param['calendar_id'].'">'."\n";

		$output .= '		<table width="100%" border="0" >';

		$output .= '		<tr>'."\n";

		$output .= '			<td width="25%" align="left" class="calendarDays'.$param['calendar_id'].'">'."\n";

		$output .= 					$previous_month_link;

		$output .= '			</td>'."\n";

		$output .= '			<td width="25%" align="center" class="calendarDays'.$param['calendar_id'].'">'."\n";

		$output .= 					$previous_day_link;

		$output .= '			</td>'."\n";

		$output .= '			<td width="25%" align="center" class="calendarDays'.$param['calendar_id'].'">'."\n";

		$output .= 					$next_day_link;

		$output .= '			</td>'."\n";

		$output .= '			<td width="25%" align="right" class="calendarDays'.$param['calendar_id'].'">'."\n";

		$output .= 					$next_month_link;

		$output .= '			</td>'."\n";

		$output .= '		</tr>';

		$output .= '		</table>';

		$output .= '	</td>'."\n";

		$output .= '</tr>'."\n";

		

	}

	$output .= '</table>'."\n";
	
	// Affichage de la légende légende
	if ($param['use_multistatut']) {
		$output .= '<p style="text-align:center;">'."\n";
		$output .= 'Legende : '."\n";
		foreach ($param['statut'] as $tab) {
			foreach ($tab as $legende => $couleur) {
				$output .= '<br/><span style="background-color:'.$couleur.';">'.$legende.'</span>'."\n";
			}
		}
		$output .= '</p>'."\n";
	}
	
	//Affichage du formulaire de recherche de date
	if($param['nav_bar']) {
		$output .= '<p style="text-align:center;">';

		$output .= '<select id="jour">';

		for($i=1;$i<32;$i++) {

			$output .= '<option value="'.$i.'">'.$i.'</option>';

		}

		$output .= '</select>';
		
		$output .= '<select id="mois">';


		$mois = $monthes_name;

		foreach($mois as $cle => $valeur) {
			switch(true) {
				case $cle == 0:		break;
				case $cle > 0 and $cle < 10:
									$output .= '<option value="0'.$cle.'">'.$valeur.'</option>';
									break;
				default:

									$output .= '<option value="'.$cle.'">'.$valeur.'</option>';
									break;
			}

		}

		$output .= '</select>';
		
		$output .= '<select id="annee">';

		$annee = intval(date('Y'));

		for($i=$annee;$i<$annee+6;$i++) {

			$output .= '<option value="'.$i.'">'.$i.'</option>';

		}

		$output .= '</select>';
	
		$output .= '<input type="button" id="go" value="Go" />';
		$output .= '<input type="button" id="td" value="Aujourd\'hui" />';

		$output .= '</p>';

	

		$output .= '<script type="text/javascript">';

		$output .= 'var jour = document.getElementById("jour");';

		$output .= 'var mois = document.getElementById("mois");';

		$output .= 'var annee = document.getElementById("annee");';

		$output .= 'var go = document.getElementById("go");';
		$output .= 'var td = document.getElementById("td");';

	

		$output .= 'function goDate() {';

		   $output .= 'var djour = jour.value;';

		   $output .= 'var dmois = mois.value;';

		   $output .= 'var dannee = annee.value;';

		   $output .= 'var d = dannee+dmois+djour;';

		   $output .= 'window.location.replace("?'.$lnk.'date="+d);';

		$output .= '}';
		
		$output .= 'function goToday() {';

		   $output .= 'window.location.replace("?'.$lnk.'");';

		$output .= '}';

	

		$output .= 'go.onclick = goDate;';
		$output .= 'td.onclick = goToday;';

		$output .= '</script>';
	}
	
	

	return $output;

}


// Fonction permettant de récupérer les valeurs passés en POST ou en GET pour le calendrier (fonction de navigation ou de consultation)

function priv_reg_glob_calendar($var) {	

	if (isset($_GET[$var])) {

		return $_GET[$var];

	}

	elseif (isset($_POST[$var])) {

		return $_POST[$var];

	}

	else {

		return '';

	}	

}



?>

Conclusion :

Il y a bien sûr encore des modifications à apporter. Il y a une liste de modifs auquels j'ai pensé et je travaille dessus mais je suis bien sur ouvert à toutes vos propositions.

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.

Du même auteur (jwalter57370)