diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 18a38ca3d8fb0fef01a3a2d44a8a41c8fb25fd4e..84c160351bd3c1db9c2736583194d7db1f00d80f 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2001-2005	Rodolphe Quiedeville	<rodolphe@quiedeville.org>
- * Copyright (C) 2004-2011	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2012	Laurent Destailleur		<eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012	Regis Houssin			<regis@dolibarr.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -236,7 +236,7 @@ if ($action == 'edit')	// Edit
 	print '<td width="20">&nbsp;</td>';
 	print '</tr>';
 
-	if ($conf->global->MAIN_FEATURES_LEVEL > 1)
+	if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || ! empty($conf->global->MAIN_BUGTRACK_ENABLELINK))
 	{
 		 // Show bugtrack link
 		$var=!$var;
@@ -390,7 +390,7 @@ else	// Show
     print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1);
     print '</td></tr>';
 
-    if ($conf->global->MAIN_FEATURES_LEVEL > 1)
+    if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || ! empty($conf->global->MAIN_BUGTRACK_ENABLELINK))
     {
     	// Show bugtrack link
     	$var=!$var;
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index b021db48448168b085fa8034b440ed611eb7d82d..b0d2c997d052d7417ba09137eca67dc5cc224357 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -601,7 +601,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
 }
 
 /**
- *	Fonction retournant le nombre de jour fieries samedis et dimanches entre 2 dates entrees en timestamp
+ *	Fonction retournant le nombre de jour feries samedis et dimanches entre 2 dates entrees en timestamp
  *	Called by function num_open_day
  *
  *	@param	    timestamp	$timestampStart     Timestamp de debut
@@ -733,11 +733,12 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR')
 
 /**
  *	Fonction retournant le nombre de jour entre deux dates
+ *  Example: 2012-01-01 2012-01-02 => 1 if lastday=0, 2 if lastday=1
  *
  *	@param	   timestamp	$timestampStart     Timestamp de debut
  *	@param	   timestamp	$timestampEnd       Timestamp de fin
- *	@param     int			$lastday            On prend en compte le dernier jour, 0: non, 1:oui
- *	@return    int								Nombre de jours
+ *	@param     int			$lastday            Last day is included, 0: non, 1:oui
+ *	@return    int								Number of days
  */
 function num_between_day($timestampStart, $timestampEnd, $lastday=0)
 {
@@ -751,8 +752,9 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
 		{
 			$bit = 1;
 		}
-		$nbjours = round(($timestampEnd - $timestampStart)/(60*60*24)-$bit);
+		$nbjours = (int) floor(($timestampEnd - $timestampStart)/(60*60*24)) + 1 - $bit;
 	}
+	//print ($timestampEnd - $timestampStart) - $lastday;
 	return $nbjours;
 }
 
@@ -762,22 +764,29 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
  *	@param	   timestamp	$timestampStart     Timestamp de debut
  *	@param	   timestamp	$timestampEnd       Timestamp de fin
  *	@param     int			$inhour             0: sort le nombre de jour , 1: sort le nombre d'heure (72 max)
- *	@param     int			$lastday            On prend en compte le dernier jour, 0: non, 1:oui
+ *	@param     int			$lastday            We include last day, 0: non, 1:oui
  *	@return    int								Nombre de jours ou d'heures
  */
 function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
 {
 	global $langs;
 
+	dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday);
+	//print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday;
 	if ($timestampStart < $timestampEnd)
 	{
-		$bit = 0;
-		if ($lastday == 1) $bit = 1;
-		$nbOpenDay = num_between_day($timestampStart, $timestampEnd, $bit) - num_public_holiday($timestampStart, $timestampEnd);
+		//print num_between_day($timestampStart, $timestampEnd, $lastday).' - '.num_public_holiday($timestampStart, $timestampEnd);
+		$nbOpenDay = num_between_day($timestampStart, $timestampEnd, $lastday) - num_public_holiday($timestampStart, $timestampEnd, $lastday);
 		$nbOpenDay.= " ".$langs->trans("Days");
 		if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
 		return $nbOpenDay;
 	}
+	elseif ($timestampStart == $timestampEnd)
+	{
+		$nbOpenDay=$lastday;
+		if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
+		return $nbOpenDay=1;
+	}
 	else
 	{
 		return $langs->trans("Error");
diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php
index 3a476b109a538ca00b4b9870b7b302213a096a02..83c1a38ed0aca4742d6cf3d6224b5a1c2854bd7f 100644
--- a/htdocs/holiday/class/holiday.class.php
+++ b/htdocs/holiday/class/holiday.class.php
@@ -109,8 +109,8 @@ class Holiday extends CommonObject
         }
         $sql.= " NOW(),";
         $sql.= " '".addslashes($this->description)."',";
-        $sql.= " '".$this->date_debut."',";
-        $sql.= " '".$this->date_fin."',";
+        $sql.= " '".$this->db->idate($this->date_debut)."',";
+        $sql.= " '".$this->db->idate($this->date_fin)."',";
         $sql.= " '1',";
         if(is_numeric($this->fk_validator)) {
             $sql.= " '".$this->fk_validator."'";
@@ -196,17 +196,17 @@ class Holiday extends CommonObject
 
                 $this->rowid    = $obj->rowid;
                 $this->fk_user = $obj->fk_user;
-                $this->date_create = $obj->date_create;
+                $this->date_create = $this->db->jdate($obj->date_create);
                 $this->description = $obj->description;
-                $this->date_debut = $obj->date_debut;
-                $this->date_fin = $obj->date_fin;
+                $this->date_debut = $this->db->jdate($obj->date_debut);
+                $this->date_fin = $this->db->jdate($obj->date_fin);
                 $this->statut = $obj->statut;
                 $this->fk_validator = $obj->fk_validator;
-                $this->date_valid = $obj->date_valid;
+                $this->date_valid = $this->db->jdate($obj->date_valid);
                 $this->fk_user_valid = $obj->fk_user_valid;
-                $this->date_refuse = $obj->date_refuse;
+                $this->date_refuse = $this->db->jdate($obj->date_refuse);
                 $this->fk_user_refuse = $obj->fk_user_refuse;
-                $this->date_cancel = $obj->date_cancel;
+                $this->date_cancel = $this->db->jdate($obj->date_cancel);
                 $this->fk_user_cancel = $obj->fk_user_cancel;
                 $this->detail_refuse = $obj->detail_refuse;
 
@@ -289,17 +289,17 @@ class Holiday extends CommonObject
 
                 $tab_result[$i]['rowid'] = $obj->rowid;
                 $tab_result[$i]['fk_user'] = $obj->fk_user;
-                $tab_result[$i]['date_create'] = $obj->date_create;
+                $tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create);
                 $tab_result[$i]['description'] = $obj->description;
-                $tab_result[$i]['date_debut'] = $obj->date_debut;
-                $tab_result[$i]['date_fin'] = $obj->date_fin;
+                $tab_result[$i]['date_debut'] = $this->db->jdate($obj->date_debut);
+                $tab_result[$i]['date_fin'] = $this->db->jdate($obj->date_fin);
                 $tab_result[$i]['statut'] = $obj->statut;
                 $tab_result[$i]['fk_validator'] = $obj->fk_validator;
-                $tab_result[$i]['date_valid'] = $obj->date_valid;
+                $tab_result[$i]['date_valid'] = $this->db->jdate($obj->date_valid);
                 $tab_result[$i]['fk_user_valid'] = $obj->fk_user_valid;
-                $tab_result[$i]['date_refuse'] = $obj->date_refuse;
+                $tab_result[$i]['date_refuse'] = $this->db->jdate($obj->date_refuse);
                 $tab_result[$i]['fk_user_refuse'] = $obj->fk_user_refuse;
-                $tab_result[$i]['date_cancel'] = $obj->date_cancel;
+                $tab_result[$i]['date_cancel'] = $this->db->jdate($obj->date_cancel);
                 $tab_result[$i]['fk_user_cancel'] = $obj->fk_user_cancel;
                 $tab_result[$i]['detail_refuse'] = $obj->detail_refuse;
 
@@ -430,12 +430,12 @@ class Holiday extends CommonObject
         $sql.= " description= '".addslashes($this->description)."',";
 
         if(!empty($this->date_debut)) {
-            $sql.= " date_debut = '".$this->date_debut."',";
+            $sql.= " date_debut = '".$this->db->idate($this->date_debut)."',";
         } else {
             $error++;
         }
         if(!empty($this->date_fin)) {
-            $sql.= " date_fin = '".$this->date_fin."',";
+            $sql.= " date_fin = '".$this->db->idate($this->date_fin)."',";
         } else {
             $error++;
         }
@@ -450,7 +450,7 @@ class Holiday extends CommonObject
             $error++;
         }
         if(!empty($this->date_valid)) {
-            $sql.= " date_valid = '".$this->date_valid."',";
+            $sql.= " date_valid = '".$this->db->idate($this->date_valid)."',";
         } else {
             $sql.= " date_valid = NULL,";
         }
@@ -460,7 +460,7 @@ class Holiday extends CommonObject
             $sql.= " fk_user_valid = NULL,";
         }
         if(!empty($this->date_refuse)) {
-            $sql.= " date_refuse = '".$this->date_refuse."',";
+            $sql.= " date_refuse = '".$this->db->idate($this->date_refuse)."',";
         } else {
             $sql.= " date_refuse = NULL,";
         }
@@ -470,7 +470,7 @@ class Holiday extends CommonObject
             $sql.= " fk_user_refuse = NULL,";
         }
         if(!empty($this->date_cancel)) {
-            $sql.= " date_cancel = '".$this->date_cancel."',";
+            $sql.= " date_cancel = '".$this->db->idate($this->date_cancel)."',";
         } else {
             $sql.= " date_cancel = NULL,";
         }
@@ -1214,56 +1214,6 @@ class Holiday extends CommonObject
     }
 
 
-    /**
-     *	Retourne le nombre de jours ouvrés entre deux dates
-     *  Prise en compte des jours fériés en France
-     *
-     *  @param	date	$date_start     Start date
-     *  @param	date	$date_stop		Stop date
-     *  @return	int						Nb of days
-     */
-
-    function getOpenDays($date_start, $date_stop) {
-
-        // Tableau des jours feriés
-        $arr_bank_holidays = array();
-
-        // On boucle dans le cas où l'année de départ serait différente de l'année d'arrivée
-        $diff_year = date('Y', $date_stop) - date('Y', $date_start);
-
-        for ($i = 0; $i <= $diff_year; $i++) {
-            $year = (int) date('Y', $date_start) + $i;
-            // Liste des jours feriés
-            $arr_bank_holidays[] = '1_1_'.$year; // Jour de l'an
-            $arr_bank_holidays[] = '1_5_'.$year; // Fete du travail
-            $arr_bank_holidays[] = '8_5_'.$year; // Victoire 1945
-            $arr_bank_holidays[] = '14_7_'.$year; // Fete nationale
-            $arr_bank_holidays[] = '15_8_'.$year; // Assomption
-            $arr_bank_holidays[] = '1_11_'.$year; // Toussaint
-            $arr_bank_holidays[] = '11_11_'.$year; // Armistice 1918
-            $arr_bank_holidays[] = '25_12_'.$year; // Noel
-            // Récupération de paques. Permet ensuite d'obtenir le jour de l'ascension et celui de la pentecote
-            $easter = easter_date($year);
-            $arr_bank_holidays[] = date('j_n_'.$year, $easter + 86400); // Paques
-            $arr_bank_holidays[] = date('j_n_'.$year, $easter + (86400*39)); // Ascension
-            $arr_bank_holidays[] = date('j_n_'.$year, $easter + (86400*50)); // Pentecote
-        }
-
-        $nb_days_open = 0;
-
-        while ($date_start <= $date_stop) {
-            // Si le jour suivant n'est ni un dimanche (0) ou un samedi (6), ni un jour férié, on incrémente les jours ouvrés
-            if (!in_array(date('w', $date_start), array(0, 6)) && !in_array(date('j_n_'.date('Y', $date_start), $date_start), $arr_bank_holidays)) {
-                $nb_days_open++;
-            }
-
-            $date_start = mktime(date('H', $date_start), date('i', $date_start), date('s', $date_start), date('m', $date_start), date('d', $date_start) + 1, date('Y', $date_start));
-        }
-
-        // On retourne le nombre de jours ouvrés
-        return $nb_days_open;
-    }
-
     /**
      *  Liste les évènements de congés payés enregistré
      *
diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php
index 11ba6d0eb3ed25c8693a804b91098df2c7be5a64..9bfaaf8b32f22875347d6fb27b4788e73e0da459 100644
--- a/htdocs/holiday/fiche.php
+++ b/htdocs/holiday/fiche.php
@@ -28,11 +28,13 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
 
 // Get parameters
 $myparam = GETPOST("myparam");
 $action=GETPOST('action');
+$id=GETPOST('id');
 
 // Protection if external user
 if ($user->societe_id > 0) accessforbidden();
@@ -46,7 +48,7 @@ $user_id = $user->id;
 ********************************************************************/
 
 // Si création de la demande
-if ($action == 'add')
+if ($action == 'create')
 {
 
     // Si pas le droit de créer une demande
@@ -92,14 +94,15 @@ if ($action == 'add')
     $verifCP = $cp->verifDateHolidayCP($userID,$date_debut,$date_fin);
 
     // On vérifie si il n'y a pas déjà des congés payés sur cette période
-    if(!$verifCP)
+    if (! $verifCP)
     {
         header('Location: fiche.php?action=request&error=alreadyCP');
         exit;
     }
 
     // Si aucun jours ouvrés dans la demande
-    if($cp->getOpenDays($testDateDebut,$testDateFin) < 1)
+    $nbopenedday=num_open_day($testDateDebut,$testDateFin,0,1);
+    if($nbopenedday < 1)
     {
         header('Location: fiche.php?action=request&error=DureeHoliday');
         exit;
@@ -137,6 +140,8 @@ if ($action == 'add')
 
 if ($action == 'update')
 {
+	$date_debut = dol_mktime(0, 0, 0, $_POST['date_debut_month'], $_POST['date_debut_day'], $_POST['date_debut_year']);
+	$date_fin = dol_mktime(0, 0, 0, $_POST['date_fin_month'], $_POST['date_fin_day'], $_POST['date_fin_year']);
 
     // Si pas le droit de modifier une demande
     if(!$user->rights->holiday->write)
@@ -151,12 +156,9 @@ if ($action == 'update')
     // Si en attente de validation
     if ($cp->statut == 1)
     {
-
         // Si c'est le créateur ou qu'il a le droit de tout lire / modifier
         if ($user->id == $cp->fk_user || $user->rights->holiday->lire_tous)
         {
-            $date_debut = $_POST['date_debut_year'].'-'.str_pad($_POST['date_debut_month'],2,"0",STR_PAD_LEFT).'-'.str_pad($_POST['date_debut_day'],2,"0",STR_PAD_LEFT);
-            $date_fin = $_POST['date_fin_year'].'-'.str_pad($_POST['date_fin_month'],2,"0",STR_PAD_LEFT).'-'.str_pad($_POST['date_fin_day'],2,"0",STR_PAD_LEFT);
             $valideur = $_POST['valideur'];
             $description = trim($_POST['description']);
 
@@ -172,8 +174,8 @@ if ($action == 'update')
                 exit;
             }
 
-            $testDateDebut = strtotime($date_debut);
-            $testDateFin = strtotime($date_fin);
+            $testDateDebut = $date_debut;
+            $testDateFin = $date_fin;
 
             // Si date de début après la date de fin
             if ($testDateDebut > $testDateFin) {
@@ -188,7 +190,9 @@ if ($action == 'update')
             }
 
             // Si pas de jours ouvrés dans la demande
-            if ($cp->getOpenDays($testDateDebut,$testDateFin) < 1) {
+            $nbopenedday=num_open_day($testDateDebut,$testDateFin,0,1);
+            if ($nbopenedday < 1)
+            {
                 header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=DureeHoliday');
                 exit;
             }
@@ -284,9 +288,10 @@ if ($action == 'confirm_send')
             $message.= "Veuillez trouver ci-dessous une demande de congés payés à valider.\n";
 
             $delayForRequest = $cp->getConfCP('delayForRequest');
-            $delayForRequest = $delayForRequest * (60*60*24);
+            //$delayForRequest = $delayForRequest * (60*60*24);
 
-            $nextMonth = date('Y-m-d', time()+$delayForRequest);
+            $now=dol_now();
+            $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd');
 
             // Si l'option pour avertir le valideur en cas de délai trop court
             if($cp->getConfCP('AlertValidatorDelay')) {
@@ -299,7 +304,9 @@ if ($action == 'confirm_send')
 
             // Si l'option pour avertir le valideur en cas de solde inférieur à la demande
             if($cp->getConfCP('AlertValidatorSolde')) {
-                if($cp->getOpenDays(strtotime($cp->date_debut),strtotime($cp->date_fin)) > $cp->getCPforUser($cp->fk_user)) {
+            	$nbopenedday=num_open_day($cp->date_debut,$cp->date_fin,0,1);
+                if ($nbopenedday > $cp->getCPforUser($cp->fk_user))
+                {
                     $message.= "\n";
                     $message.= "L'utilisateur ayant fait cette demande de congés payés n'a pas le solde requis.\n";
                 }
@@ -331,10 +338,10 @@ if ($action == 'confirm_send')
     }
 }
 
+
 // Si Validation de la demande
 if($action == 'confirm_valid')
 {
-
     $cp = new Holiday($db);
     $cp->fetch($_GET['id']);
 
@@ -344,7 +351,7 @@ if($action == 'confirm_valid')
     if($cp->statut == 2 && $userID == $cp->fk_validator)
     {
 
-        $cp->date_valid = date('Y-m-d H:i:s', time());
+        $cp->date_valid = dol_now();
         $cp->fk_user_valid = $user->id;
         $cp->statut = 3;
 
@@ -354,7 +361,7 @@ if($action == 'confirm_valid')
         if($verif > 0) {
 
             // Retrait du nombre de jours prit
-            $nbJour = $cp->getOpenDays(strtotime($cp->date_debut),strtotime($cp->date_fin));
+            $nbJour = $nbopenedday=num_open_day($cp->date_debut,$cp->date_fin,0,1);
 
             $soldeActuel = $cp->getCpforUser($cp->fk_user);
             $newSolde = $soldeActuel - ($nbJour*$cp->getConfCP('nbHolidayDeducted'));
@@ -570,7 +577,7 @@ if ($action == 'confirm_cancel' && $_GET['confirm'] == 'yes')
 
 llxHeader(array(),$langs->trans('CPTitreMenu'));
 
-if ($action == 'request')
+if (empty($id) || $action == 'add' || $action == 'request')
 {
     // Si l'utilisateur n'a pas le droit de faire une demande
     if(!$user->rights->holiday->write)
@@ -619,9 +626,9 @@ if ($action == 'request')
         $cp = new Holiday($db);
 
         $delayForRequest = $cp->getConfCP('delayForRequest');
-        $delayForRequest = $delayForRequest * (60*60*24);
+        //$delayForRequest = $delayForRequest * (60*60*24);
 
-        $nextMonth = date('Y-m-d', time()+$delayForRequest);
+        $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd');
 
         print '<script type="text/javascript">
        //<![CDATA[
@@ -635,19 +642,19 @@ if ($action == 'request')
                  return true;
                }
                else {
-                 alert("'.$langs->transnoentities('InvalidValidatorCP').'");
+                 alert("'.dol_escape_js($langs->transnoentities('InvalidValidatorCP')).'");
                  return false;
                }
 
             }
             else {
-              alert("'.$langs->trans('NoDateFin').'");
+              alert("'.dol_escape_js($langs->transnoentities('NoDateFin')).'");
               return false;
             }
          }
 
          else {
-           alert("'.$langs->trans('NoDateDebut').'");
+           alert("'.dol_escape_js($langs->transnoentities('NoDateDebut')).'");
            return false;
          }
        }
@@ -657,7 +664,7 @@ if ($action == 'request')
 
         // Formulaire de demande
         print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" onsubmit="return valider()" name="demandeCP">'."\n";
-        print '<input type="hidden" name="action" value="add" />'."\n";
+        print '<input type="hidden" name="action" value="create" />'."\n";
         print '<input type="hidden" name="userID" value="'.$user_id.'" />'."\n";
         print '<div class="tabBar">';
         print '<span>'.$langs->trans('DelayToRequestCP',$cp->getConfCP('delayForRequest')).'</span><br /><br />';
@@ -668,11 +675,11 @@ if ($action == 'request')
         print '<table class="border" width="100%">';
         print '<tbody>';
         print '<tr>';
-        print '<td class="fieldrequired">'.$langs->trans("DateDebCP").'</td>';
+        print '<td class="fieldrequired">'.$langs->trans("DateDebCP").' ('.$langs->trans("FirstDayOfHoliday").')</td>';
         print '<td>';
         // Si la demande ne vient pas de l'agenda
         if(!isset($_GET['datep'])) {
-            $html->select_date($nextMonth,'date_debut_');
+            $html->select_date(-1,'date_debut_');
         } else {
             $tmpdate = dol_mktime(0, 0, 0, GETPOST('datepmonth'), GETPOST('datepday'), GETPOST('datepyear'));
             $html->select_date($tmpdate,'date_debut_');
@@ -680,11 +687,11 @@ if ($action == 'request')
         print '</td>';
         print '</tr>';
         print '<tr>';
-        print '<td class="fieldrequired">'.$langs->trans("DateFinCP").'</td>';
+        print '<td class="fieldrequired">'.$langs->trans("DateFinCP").' ('.$langs->trans("LastDayOfHoliday").')</td>';
         print '<td>';
         // Si la demande ne vient pas de l'agenda
         if(!isset($_GET['datep'])) {
-            $html->select_date($nextMonth,'date_fin_');
+            $html->select_date(-1,'date_fin_');
         } else {
             $tmpdate = dol_mktime(0, 0, 0, GETPOST('datefmonth'), GETPOST('datefday'), GETPOST('datefyear'));
             $html->select_date($tmpdate,'date_fin_');
@@ -706,7 +713,7 @@ if ($action == 'request')
         print '<tr>';
         print '<td>'.$langs->trans("DescCP").'</td>';
         print '<td>';
-        print '<textarea name="description" class="flat" rows="2" cols="70"></textarea>';
+        print '<textarea name="description" class="flat" rows="'.ROWS_3.'" cols="70"></textarea>';
         print '</td>';
         print '</tr>';
         print '</tbody>';
@@ -723,7 +730,7 @@ if ($action == 'request')
     }
 
 }
-elseif(isset($_GET['id']))
+else
 {
     if ($error)
     {
@@ -735,10 +742,10 @@ elseif(isset($_GET['id']))
     else
     {
         // Affichage de la fiche d'une demande de congés payés
-        if ($_GET['id'] > 0)
+        if ($id > 0)
         {
             $cp = new Holiday($db);
-            $cp->fetch($_GET['id']);
+            $cp->fetch($id);
 
             $valideur = new User($db);
             $valideur->fetch($cp->fk_validator);
@@ -887,7 +894,7 @@ elseif(isset($_GET['id']))
                 }
                 print '<tr>';
                 print '<td>'.$langs->trans('NbUseDaysCP').'</td>';
-                print '<td>'.$cp->getOpenDays(strtotime($cp->date_debut),strtotime($cp->date_fin)).'</td>';
+                print '<td>'.num_open_day($cp->date_debut,$cp->date_fin,0,1).'</td>';
                 print '</tr>';
 
                 // Status
@@ -911,7 +918,7 @@ elseif(isset($_GET['id']))
                 } else {
                     print '<tr>';
                     print '<td>'.$langs->trans('DescCP').'</td>';
-                    print '<td><textarea name="description" class="flat" rows="2" cols="70">'.$cp->description.'</textarea></td>';
+                    print '<td><textarea name="description" class="flat" rows="'.ROWS_3.'" cols="70">'.$cp->description.'</textarea></td>';
                     print '</tr>';
                 }
                 print '</tbody>';
@@ -953,24 +960,24 @@ elseif(isset($_GET['id']))
 
                 print '<tr>';
                 print '<td>'.$langs->trans('DateCreateCP').'</td>';
-                print '<td>'.$cp->date_create.'</td>';
+                print '<td>'.dol_print_date($cp->date_create,'dayhour').'</td>';
                 print '</tr>';
                 if($cp->statut == 3) {
                     print '<tr>';
                     print '<td>'.$langs->trans('DateValidCP').'</td>';
-                    print '<td>'.$cp->date_valid.'</td>';
+                    print '<td>'.dol_print_date($cp->date_valid,'dayhour').'</td>';
                     print '</tr>';
                 }
                 if($cp->statut == 4) {
                     print '<tr>';
                     print '<td>'.$langs->trans('DateCancelCP').'</td>';
-                    print '<td>'.$cp->date_cancel.'</td>';
+                    print '<td>'.dol_print_date($cp->date_cancel,'dayhour').'</td>';
                     print '</tr>';
                 }
                 if($cp->statut == 5) {
                     print '<tr>';
                     print '<td>'.$langs->trans('DateRefusCP').'</td>';
-                    print '<td>'.$cp->date_refuse.'</td>';
+                    print '<td>'.dol_print_date($cp->date_refuse,'dayhour').'</td>';
                     print '</tr>';
                 }
                 print '</tbody>';
diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php
index c2c865dc1a65f88a9126133c50a6e296184521be..01d3d7210a7cb255225c717f6fe5acb556625d91 100644
--- a/htdocs/holiday/index.php
+++ b/htdocs/holiday/index.php
@@ -292,7 +292,9 @@ if (! empty($holiday->holiday))
 		print '<td>'.$validator->getNomUrl('1').'</td>';
 		print '<td style="text-align: center;">'.$infos_CP['date_debut'].'</td>';
 		print '<td style="text-align: center;">'.$infos_CP['date_fin'].'</td>';
-		print '<td>'.$holiday->getOpenDays(strtotime($infos_CP['date_debut']),strtotime($infos_CP['date_fin'])).' '.$langs->trans('Jours').'</td>';
+		print '<td>';
+		$nbopenedday=num_open_day($infos_CP['date_debut'],$infos_CP['date_fin'],0,1);
+		print $nbopenedday.' '.$langs->trans('Jours');
 		print '<td align="center"><a href="./fiche.php?id='.$infos_CP['rowid'].'">'.$statut.'</a></td>';
 		print '</tr>'."\n";
 
diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php
index ef0ff913bf86a647b5c72df93e80f90e1490ebcb..f8156ef04d0fdad44eb77560cafb32ffc969c986 100644
--- a/htdocs/holiday/month_report.php
+++ b/htdocs/holiday/month_report.php
@@ -44,7 +44,6 @@ if(!$user->rights->holiday->month_report) accessforbidden();
 $html = new Form($db);
 $htmlother = new FormOther($db);
 
-
 llxHeader(array(),$langs->trans('CPTitreMenu'));
 
 $cp = new Holiday($db);
@@ -53,10 +52,10 @@ $month = GETPOST('month_start');
 $year = GETPOST('year_start');
 
 if(empty($month)) {
-      $month = date('m');
+	$month = date('m');
 }
 if(empty($year)) {
-      $year = date('Y');
+	$year = date('Y');
 }
 
 $sql = "SELECT cp.fk_user, cp.date_debut, cp.date_fin";
@@ -65,7 +64,7 @@ $sql.= " LEFT JOIN llx_user u ON cp.fk_user = u.rowid";
 $sql.= " WHERE cp.rowid > '0'";
 $sql.= " AND cp.statut = 3";
 $sql.= " AND (date_format(cp.date_debut, '%Y-%m') = '$year-$month'
-               OR date_format(cp.date_fin, '%Y-%m') = '$year-$month')";
+OR date_format(cp.date_fin, '%Y-%m') = '$year-$month')";
 $sql.= " ORDER BY u.name,cp.date_debut";
 
 $result  = $db->query($sql);
@@ -78,7 +77,7 @@ print '<div class="tabBar">';
 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
 
 print 'Choix mois : <input class="flat" type="text" size="1" maxlength="2"
-                              name="month_start" value="'.$month.'">&nbsp;';
+name="month_start" value="'.$month.'">&nbsp;';
 $htmlother->select_year($year,'year_start',1,10,3);
 
 print '<input type="submit" value="'.$langs->trans("Refresh").'" class="button" />';
@@ -90,47 +89,50 @@ print '<br />';
 $var=true;
 print '<table class="noborder" width="40%;">';
 
-   print '<tr class="liste_titre">';
-      print '<td>'.$langs->trans('Employee').'</td>';
-      print '<td>'.$langs->trans('DateDebCP').'</td>';
-      print '<td>'.$langs->trans('DateFinCP').'</td>';
-      print '<td>'.$langs->trans('nbJours').'</td>';
-   print '</tr>';
-
-   if($num == '0') {
-
-      print '<tr class="pair">';
-         print '<td colspan="4" style="text-align: center; padding: 3px;">'.$langs->trans('NoCPforMonth').'</td>';
-      print '</tr>';
-
-   } else {
-
-      while($holiday = $db->fetch_array($result)){
-         $user = new User($db);
-         $user->fetch($holiday['fk_user']);
-         $var=!$var;
-
-         if(substr($holiday['date_debut'],5,2)==$month-1){
-            $holiday['date_debut'] = date('Y-'.$month.'-01');
-         }
-
-         if(substr($holiday['date_fin'],5,2)==$month+1){
-            $holiday['date_fin'] = date('Y-'.$month.'-t');
-         }
-
-         print '<tr '.$bc[$var].'>';
-            print '<td>'.$user->nom.' '.$user->prenom.'</td>';
-            print '<td>'.$holiday['date_debut'].'</td>';
-            print '<td>'.$holiday['date_fin'].'</td>';
-            print '<td>'.$cp->getOpenDays(strtotime($holiday['date_debut']),strtotime($holiday['date_fin'])).'</td>';
-         print '</tr>';
-      }
-
-   }
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans('Employee').'</td>';
+print '<td>'.$langs->trans('DateDebCP').'</td>';
+print '<td>'.$langs->trans('DateFinCP').'</td>';
+print '<td>'.$langs->trans('nbJours').'</td>';
+print '</tr>';
+
+if($num == '0') {
+
+	print '<tr class="pair">';
+	print '<td colspan="4" style="text-align: center; padding: 3px;">'.$langs->trans('NoCPforMonth').'</td>';
+	print '</tr>';
+
+} else {
+
+	while($holiday = $db->fetch_array($result)){
+		$user = new User($db);
+		$user->fetch($holiday['fk_user']);
+		$var=!$var;
+
+		if(substr($holiday['date_debut'],5,2)==$month-1){
+			$holiday['date_debut'] = date('Y-'.$month.'-01');
+		}
+
+		if(substr($holiday['date_fin'],5,2)==$month+1){
+			$holiday['date_fin'] = date('Y-'.$month.'-t');
+		}
+
+		print '<tr '.$bc[$var].'>';
+		print '<td>'.$user->nom.' '.$user->prenom.'</td>';
+		print '<td>'.$holiday['date_debut'].'</td>';
+		print '<td>'.$holiday['date_fin'].'</td>';
+		print '<td>';
+		$nbopenedday=num_open_day($holiday['date_debut'],$holiday['date_fin'],0,1);
+		print $nbopenedday;
+		print '</td>';
+		print '</tr>';
+	}
+}
 print '</table>';
 print '</div>';
 
 // Fin de page
-$db->close();
 llxFooter();
+
+$db->close();
 ?>
diff --git a/htdocs/install/mysql/tables/llx_holiday.sql b/htdocs/install/mysql/tables/llx_holiday.sql
index 935de76ef9e99c3e1eb559d2ee39d451b4575cc2..08e9679994916793ac2baa2d58c3851964e80011 100644
--- a/htdocs/install/mysql/tables/llx_holiday.sql
+++ b/htdocs/install/mysql/tables/llx_holiday.sql
@@ -1,3 +1,21 @@
+-- ===================================================================
+-- Copyright (C) 2012      Laurent Destailleur  <eldy@users.sourceforge.net>
+--
+-- 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.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+--
+-- ===================================================================
+
 CREATE TABLE llx_holiday 
 (
 rowid          integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
diff --git a/htdocs/install/mysql/tables/llx_holiday_users.sql b/htdocs/install/mysql/tables/llx_holiday_users.sql
index a6aa6bd91d6f3c49a9c8ba6e32c01fb638fffcff..2edff816e7cb18f9147f979a5ba9656177c73c6b 100644
--- a/htdocs/install/mysql/tables/llx_holiday_users.sql
+++ b/htdocs/install/mysql/tables/llx_holiday_users.sql
@@ -1,3 +1,21 @@
+-- ===================================================================
+-- Copyright (C) 2012      Laurent Destailleur  <eldy@users.sourceforge.net>
+--
+-- 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.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+--
+-- ===================================================================
+
 CREATE TABLE llx_holiday_users 
 (
 fk_user     integer NOT NULL PRIMARY KEY,
diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang
index 85b9854eb07e5334469a7f2502b109258d6aff0b..619b1cca9c64f404713a03ab5de03af39f7c1542 100755
--- a/htdocs/langs/en_US/holiday.lang
+++ b/htdocs/langs/en_US/holiday.lang
@@ -84,7 +84,8 @@ NewSoldeCP=New Balance
 alreadyCPexist=A request for holidays has already been done on this period.
 UserName=Name
 Employee=Employee
-
+FirstDayOfHoliday=First day of holiday
+LastDayOfHoliday=Last day of holiday
 
 ## Configuration du Module ##
 ConfCP=Configuration of holidays module
diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang
index d6960b2c8dd4b51674b26661e7b8218698ce4c6a..0406c833673847cf8d78af46aa2e3469ccf76224 100644
--- a/htdocs/langs/fr_FR/holiday.lang
+++ b/htdocs/langs/fr_FR/holiday.lang
@@ -84,7 +84,8 @@ NewSoldeCP=Nouveau Solde
 alreadyCPexist=Une demande de congés à déjà été effectuée sur cette période.
 UserName=Nom Prénom
 Employee=Salarié
-
+FirstDayOfHoliday=Premier jour de congès
+LastDayOfHoliday=Dernier jour de congès
 
 ## Configuration du Module ##
 ConfCP=Configuration du module Congés
diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php
index c56b39f5cf417a3e1e444e0684076062ce1adcdc..6bf864748ce30b0f759e06b20c256c295c6cb070 100644
--- a/test/phpunit/DateLibTest.php
+++ b/test/phpunit/DateLibTest.php
@@ -113,6 +113,47 @@ class DateLibTest extends PHPUnit_Framework_TestCase
     	print __METHOD__."\n";
     }
 
+    /**
+     * testNumBetweenDay
+     *
+     * @return	void
+     */
+    public function testNumBetweenDay()
+    {
+    	global $conf,$user,$langs,$db;
+		$conf=$this->savconf;
+		$user=$this->savuser;
+		$langs=$this->savlangs;
+		$db=$this->savdb;
+
+		// With same hours
+		$date1=dol_mktime(0, 0, 0, 1, 1, 2012);
+		$date2=dol_mktime(0, 0, 0, 1, 2, 2012);
+
+		$result=num_between_day($date1,$date2,1);
+    	print __METHOD__." result=".$result."\n";
+		$this->assertEquals(2,$result);
+
+		$result=num_between_day($date1,$date2,0);
+    	print __METHOD__." result=".$result."\n";
+		$this->assertEquals(1,$result);
+
+		// With different hours
+		$date1=dol_mktime(0, 0, 0, 1, 1, 2012);
+		$date2=dol_mktime(12, 0, 0, 1, 2, 2012);
+
+		$result=num_between_day($date1,$date2,1);
+    	print __METHOD__." result=".$result."\n";
+		$this->assertEquals(2,$result);
+
+		$result=num_between_day($date1,$date2,0);
+    	print __METHOD__." result=".$result."\n";
+		$this->assertEquals(1,$result);
+
+		return $result;
+    }
+
+
     /**
      * testConvertTime2Seconds
      *