$user_login = getpost_variable('user_login');
$date_debut = getpost_variable('date_debut');
$date_fin = getpost_variable('date_fin');
$choix_format = getpost_variable('choix_format');
/*************************************/
//connexion mysql
if ($action == "export") {
    if ($choix_format == "ical") {
        export_ical($user_login, $date_debut, $date_fin, $DEBUG);
    } else {
        export_vcal($user_login, $date_debut, $date_fin, $DEBUG);
    }
    $comment_log = "export ical/vcal ({$date_debut} -> {$date_fin}) ";
    log_action(0, "", $user_login, $comment_log, $DEBUG);
} else {
    form_saisie($user_login, $date_debut, $date_fin, $DEBUG);
}
/*******************************************************************************/
/**********  FONCTIONS  ********************************************************/
function form_saisie($user, $date_debut, $date_fin, $DEBUG = FALSE)
{
    $PHP_SELF = $_SERVER['PHP_SELF'];
    $session = session_id();
    $date_today = date("d-m-Y");
    if ($date_debut == "") {
        $date_debut = $date_today;
    }
    if ($date_fin == "") {
        $date_fin = $date_today;
    }
    header_popup();
include_once ROOT_PATH . 'fonctions_conges.php';
include_once INCLUDE_PATH . 'fonction.php';
include_once INCLUDE_PATH . 'session.php';
/*** initialisation des variables ***/
$session = session_id();
/************************************/
/*************************************/
// recup des parametres reçus :
// SERVER
$PHP_SELF = $_SERVER['PHP_SELF'];
// GET	/ POST
$action = getpost_variable('action');
$new_mois = getpost_variable('new_mois', date("m"));
$new_year = getpost_variable('new_year', date("Y"));
/*************************************/
form_saisie($action, $new_mois, $new_year);
/*******************************************************************************/
/**********  FONCTIONS  ********************************************************/
function form_saisie($action, $new_mois, $new_year)
{
    $PHP_SELF = $_SERVER['PHP_SELF'];
    $session = session_id();
    header_popup();
    if ($action == "imprim") {
        ouvre_calendrier($new_mois, $new_year);
    }
    echo "<center>\n";
    echo "<h3>" . _('imprim_calendrier_titre') . "</h3>\n";
    echo "<form action=\"{$PHP_SELF}?session={$session}\" method=\"POST\">\n";
    echo "<table>\n";
    // choix du mois et annee
include INCLUDE_PATH . 'session.php';
$DEBUG = FALSE;
//$DEBUG=TRUE
/*** initialisation des variables ***/
$session = session_id();
/************************************/
/*************************************/
// recup des parametres reçus :
// SERVER
$PHP_SELF = $_SERVER['PHP_SELF'];
// GET	/ POST
$action = getpost_variable('action');
$new_mois = getpost_variable('new_mois', date("m"));
$new_year = getpost_variable('new_year', date("Y"));
/*************************************/
form_saisie($action, $new_mois, $new_year, $DEBUG);
/*******************************************************************************/
/**********  FONCTIONS  ********************************************************/
function form_saisie($action, $new_mois, $new_year, $DEBUG = FALSE)
{
    $PHP_SELF = $_SERVER['PHP_SELF'];
    $session = session_id();
    header_popup();
    if ($action == "imprim") {
        ouvre_calendrier($new_mois, $new_year, $DEBUG);
    }
    echo "<center>\n";
    echo "<h3>" . _('imprim_calendrier_titre') . "</h3>\n";
    echo "<form action=\"{$PHP_SELF}?session={$session}\" method=\"POST\">\n";
    echo "<table>\n";
    // choix du mois et annee