Fix: Maxi debug of holiday module

This commit is contained in:
Laurent Destailleur 2012-12-18 13:12:11 +01:00
parent 515f30591d
commit 4cc44292e7
7 changed files with 334 additions and 198 deletions

View File

@ -759,15 +759,16 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
} }
/** /**
* Function to return number of working days (and text of units) between two dates (jours ouvres) * Function to return number of working days (and text of units) between two dates (working days)
* *
* @param timestamp $timestampStart Timestamp for start date * @param timestamp $timestampStart Timestamp for start date
* @param timestamp $timestampEnd Timestamp for end date * @param timestamp $timestampEnd Timestamp for end date
* @param int $inhour 0: return number of days, 1: return number of hours (72 max) * @param int $inhour 0: return number of days, 1: return number of hours (72h max)
* @param int $lastday We include last day, 0: no, 1:yes * @param int $lastday We include last day, 0: no, 1:yes
* @return int Number of days or hours * @param int $halfday Tag to define half day when holiday start and end
* @return int Number of days or hours
*/ */
function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0) function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0)
{ {
global $langs; global $langs;
@ -784,13 +785,13 @@ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
$nbOpenDay = num_between_day($timestampStart, $timestampEnd, $lastday) - num_public_holiday($timestampStart, $timestampEnd, $lastday); $nbOpenDay = num_between_day($timestampStart, $timestampEnd, $lastday) - num_public_holiday($timestampStart, $timestampEnd, $lastday);
$nbOpenDay.= " " . $langs->trans("Days"); $nbOpenDay.= " " . $langs->trans("Days");
if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
return $nbOpenDay; return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
} }
elseif ($timestampStart == $timestampEnd) elseif ($timestampStart == $timestampEnd)
{ {
$nbOpenDay=$lastday; $nbOpenDay=$lastday;
if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
return $nbOpenDay; return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
} }
else else
{ {

View File

@ -30,17 +30,22 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/ */
class Holiday extends CommonObject class Holiday extends CommonObject
{ {
var $db; public $element='holiday';
public $table_element='holiday';
var $db;
var $error; var $error;
var $errors=array(); var $errors=array();
var $rowid; var $rowid;
var $ref;
var $fk_user; var $fk_user;
var $date_create=''; var $date_create='';
var $description; var $description;
var $date_debut=''; var $date_debut='';
var $date_fin=''; var $date_fin='';
var $halfday='';
var $statut=''; var $statut='';
var $fk_validator; var $fk_validator;
var $date_valid=''; var $date_valid='';
@ -97,15 +102,14 @@ class Holiday extends CommonObject
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday(";
$sql.= "fk_user,"; $sql.= "fk_user,";
$sql.= "date_create,"; $sql.= "date_create,";
$sql.= "description,"; $sql.= "description,";
$sql.= "date_debut,"; $sql.= "date_debut,";
$sql.= "date_fin,"; $sql.= "date_fin,";
$sql.= "halfday,";
$sql.= "statut,"; $sql.= "statut,";
$sql.= "fk_validator"; $sql.= "fk_validator";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
// User // User
@ -114,6 +118,7 @@ class Holiday extends CommonObject
$sql.= " '".addslashes($this->description)."',"; $sql.= " '".addslashes($this->description)."',";
$sql.= " '".$this->db->idate($this->date_debut)."',"; $sql.= " '".$this->db->idate($this->date_debut)."',";
$sql.= " '".$this->db->idate($this->date_fin)."',"; $sql.= " '".$this->db->idate($this->date_fin)."',";
$sql.= " ".$this->halfday.",";
$sql.= " '1',"; $sql.= " '1',";
$sql.= " '".$this->fk_validator."'"; $sql.= " '".$this->fk_validator."'";
@ -170,6 +175,7 @@ class Holiday extends CommonObject
$sql.= " cp.description,"; $sql.= " cp.description,";
$sql.= " cp.date_debut,"; $sql.= " cp.date_debut,";
$sql.= " cp.date_fin,"; $sql.= " cp.date_fin,";
$sql.= " cp.halfday,";
$sql.= " cp.statut,"; $sql.= " cp.statut,";
$sql.= " cp.fk_validator,"; $sql.= " cp.fk_validator,";
$sql.= " cp.date_valid,"; $sql.= " cp.date_valid,";
@ -193,11 +199,13 @@ class Holiday extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->rowid = $obj->rowid; // deprecated $this->rowid = $obj->rowid; // deprecated
$this->ref = $obj->rowid;
$this->fk_user = $obj->fk_user; $this->fk_user = $obj->fk_user;
$this->date_create = $this->db->jdate($obj->date_create); $this->date_create = $this->db->jdate($obj->date_create);
$this->description = $obj->description; $this->description = $obj->description;
$this->date_debut = $this->db->jdate($obj->date_debut); $this->date_debut = $this->db->jdate($obj->date_debut);
$this->date_fin = $this->db->jdate($obj->date_fin); $this->date_fin = $this->db->jdate($obj->date_fin);
$this->halfday = $obj->halfday;
$this->statut = $obj->statut; $this->statut = $obj->statut;
$this->fk_validator = $obj->fk_validator; $this->fk_validator = $obj->fk_validator;
$this->date_valid = $this->db->jdate($obj->date_valid); $this->date_valid = $this->db->jdate($obj->date_valid);
@ -240,6 +248,7 @@ class Holiday extends CommonObject
$sql.= " cp.description,"; $sql.= " cp.description,";
$sql.= " cp.date_debut,"; $sql.= " cp.date_debut,";
$sql.= " cp.date_fin,"; $sql.= " cp.date_fin,";
$sql.= " cp.halfday,";
$sql.= " cp.statut,"; $sql.= " cp.statut,";
$sql.= " cp.fk_validator,"; $sql.= " cp.fk_validator,";
$sql.= " cp.date_valid,"; $sql.= " cp.date_valid,";
@ -284,11 +293,13 @@ class Holiday extends CommonObject
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$tab_result[$i]['rowid'] = $obj->rowid; $tab_result[$i]['rowid'] = $obj->rowid;
$tab_result[$i]['ref'] = $obj->rowid;
$tab_result[$i]['fk_user'] = $obj->fk_user; $tab_result[$i]['fk_user'] = $obj->fk_user;
$tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create); $tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create);
$tab_result[$i]['description'] = $obj->description; $tab_result[$i]['description'] = $obj->description;
$tab_result[$i]['date_debut'] = $this->db->jdate($obj->date_debut); $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]['date_fin'] = $this->db->jdate($obj->date_fin);
$tab_result[$i]['halfday'] = $obj->halfday;
$tab_result[$i]['statut'] = $obj->statut; $tab_result[$i]['statut'] = $obj->statut;
$tab_result[$i]['fk_validator'] = $obj->fk_validator; $tab_result[$i]['fk_validator'] = $obj->fk_validator;
$tab_result[$i]['date_valid'] = $this->db->jdate($obj->date_valid); $tab_result[$i]['date_valid'] = $this->db->jdate($obj->date_valid);
@ -334,6 +345,7 @@ class Holiday extends CommonObject
$sql.= " cp.description,"; $sql.= " cp.description,";
$sql.= " cp.date_debut,"; $sql.= " cp.date_debut,";
$sql.= " cp.date_fin,"; $sql.= " cp.date_fin,";
$sql.= " cp.halfday,";
$sql.= " cp.statut,"; $sql.= " cp.statut,";
$sql.= " cp.fk_validator,"; $sql.= " cp.fk_validator,";
$sql.= " cp.date_valid,"; $sql.= " cp.date_valid,";
@ -342,10 +354,16 @@ class Holiday extends CommonObject
$sql.= " cp.fk_user_refuse,"; $sql.= " cp.fk_user_refuse,";
$sql.= " cp.date_cancel,"; $sql.= " cp.date_cancel,";
$sql.= " cp.fk_user_cancel,"; $sql.= " cp.fk_user_cancel,";
$sql.= " cp.detail_refuse"; $sql.= " cp.detail_refuse,";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; $sql.= " uu.name as user_lastname,";
$sql.= " WHERE cp.rowid > '0'"; // Hack pour la recherche sur le tableau $sql.= " uu.firstname as user_firstname,";
$sql.= " ua.name as validator_lastname,";
$sql.= " ua.firstname as validator_firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua";
$sql.= " WHERE cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau
// Filtrage de séléction // Filtrage de séléction
if(!empty($filter)) { if(!empty($filter)) {
@ -378,11 +396,13 @@ class Holiday extends CommonObject
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$tab_result[$i]['rowid'] = $obj->rowid; $tab_result[$i]['rowid'] = $obj->rowid;
$tab_result[$i]['ref'] = $obj->rowid;
$tab_result[$i]['fk_user'] = $obj->fk_user; $tab_result[$i]['fk_user'] = $obj->fk_user;
$tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create); $tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create);
$tab_result[$i]['description'] = $obj->description; $tab_result[$i]['description'] = $obj->description;
$tab_result[$i]['date_debut'] = $this->db->jdate($obj->date_debut); $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]['date_fin'] = $this->db->jdate($obj->date_fin);
$tab_result[$i]['halfday'] = $obj->halfday;
$tab_result[$i]['statut'] = $obj->statut; $tab_result[$i]['statut'] = $obj->statut;
$tab_result[$i]['fk_validator'] = $obj->fk_validator; $tab_result[$i]['fk_validator'] = $obj->fk_validator;
$tab_result[$i]['date_valid'] = $this->db->jdate($obj->date_valid); $tab_result[$i]['date_valid'] = $this->db->jdate($obj->date_valid);
@ -393,6 +413,12 @@ class Holiday extends CommonObject
$tab_result[$i]['fk_user_cancel'] = $obj->fk_user_cancel; $tab_result[$i]['fk_user_cancel'] = $obj->fk_user_cancel;
$tab_result[$i]['detail_refuse'] = $obj->detail_refuse; $tab_result[$i]['detail_refuse'] = $obj->detail_refuse;
$tab_result[$i]['user_firstname'] = $obj->user_firstname;
$tab_result[$i]['user_lastname'] = $obj->user_lastname;
$tab_result[$i]['validator_firstname'] = $obj->validator_firstname;
$tab_result[$i]['validator_lastname'] = $obj->validator_lastname;
$i++; $i++;
} }
// Retourne 1 et ajoute le tableau à la variable // Retourne 1 et ajoute le tableau à la variable
@ -403,7 +429,7 @@ class Holiday extends CommonObject
{ {
// Erreur SQL // Erreur SQL
$this->error="Error ".$this->db->lasterror(); $this->error="Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::fetchAll ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@ -435,6 +461,7 @@ class Holiday extends CommonObject
} else { } else {
$error++; $error++;
} }
$sql.= " halfday = ".$this->halfday.",";
if(!empty($this->statut) && is_numeric($this->statut)) { if(!empty($this->statut) && is_numeric($this->statut)) {
$sql.= " statut = '".$this->statut."',"; $sql.= " statut = '".$this->statut."',";
} else { } else {
@ -567,57 +594,112 @@ class Holiday extends CommonObject
* @param int $fk_user Id user * @param int $fk_user Id user
* @param date $dateDebut Start date * @param date $dateDebut Start date
* @param date $dateFin End date * @param date $dateFin End date
* @param int $halfday Tag to define half day when holiday start and end
* @return boolean * @return boolean
*/ */
function verifDateHolidayCP($fk_user,$dateDebut,$dateFin) function verifDateHolidayCP($fk_user, $dateDebut, $dateFin, $halfday=0)
{ {
$this->fetchByUser($fk_user,'',''); $this->fetchByUser($fk_user,'','');
foreach($this->holiday as $infos_CP) { foreach($this->holiday as $infos_CP)
{
if($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) { if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays
if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays
// TODO Also use halfday for the check
if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut'])
{
return false; return false;
} }
} }
return true; return true;
} }
/**
* Retourne la traduction du statut d'un congé payé
*
* @param int $statut int du statut du congé
* @return string retourne la traduction du statut
*/
function getStatutCP($statut) {
global $langs; /**
* Return clicable name (with picto eventually)
if(is_numeric($statut)) { *
* @param int $withpicto 0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
switch($statut) { * @return string String with URL
case 1: // Brouillon */
$statut = $langs->trans('DraftCP'); function getNomUrl($withpicto=0)
break; {
case 2: // En attente de validation global $langs;
$statut = $langs->trans('ToValidateCP');
break; $result='';
case 3: // Validée
$statut = $langs->trans('ValidateCP'); $lien = '<a href="'.DOL_URL_ROOT.'/holiday/fiche.php?id='.$this->id.'">';
break; $lienfin='</a>';
case 4: // Annulée
$statut = $langs->trans('CancelCP'); $picto='holiday';
break;
case 5: // Refusée $label=$langs->trans("Show").': '.$this->ref;
$statut = $langs->trans('RefuseCP');
} if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
return $statut; if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
} return $result;
} }
/**
* Returns the label status
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @return string Label
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->statut, $mode, $this->date_debut);
}
/**
* Returns the label of a statut
*
* @param int $statut id statut
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @param date $startdate Date holiday should start
* @return string Label
*/
function LibStatut($statut, $mode=0, $startdate='')
{
global $langs;
if ($mode == 0)
{
if ($statut == 1) return $langs->trans('DraftCP');
if ($statut == 2) return $langs->trans('ToValidateCP');
if ($statut == 3) return $langs->trans('ValidateCP');
if ($statut == 4) return $langs->trans('CancelCP');
if ($statut == 5) return $langs->trans('RefuseCP');
}
if ($mode == 2)
{
$pictoapproved='statut6';
if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4';
if ($statut == 1) return img_picto($langs->trans('DraftCP'),'statut0').' '.$langs->trans('DraftCP'); // Draft
if ($statut == 2) return img_picto($langs->trans('ToValidateCP'),'statut1').' '.$langs->trans('ToValidateCP'); // Waiting approval
if ($statut == 3) return img_picto($langs->trans('ValidateCP'),$pictoapproved).' '.$langs->trans('ValidateCP');
if ($statut == 4) return img_picto($langs->trans('CancelCP'),'statut5').' '.$langs->trans('CancelCP');
if ($statut == 5) return img_picto($langs->trans('RefuseCP'),'statut5').' '.$langs->trans('RefuseCP');
}
if ($mode == 5)
{
$pictoapproved='statut6';
if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4';
if ($statut == 1) return $langs->trans('DraftCP').' '.img_picto($langs->trans('DraftCP'),'statut0'); // Draft
if ($statut == 2) return $langs->trans('ToValidateCP').' '.img_picto($langs->trans('ToValidateCP'),'statut1'); // Waiting approval
if ($statut == 3) return $langs->trans('ValidateCP').' '.img_picto($langs->trans('ValidateCP'),$pictoapproved);
if ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'),'statut5');
if ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'),'statut5');
}
return $statut;
}
/** /**
* Affiche un select HTML des statuts de congés payés * Affiche un select HTML des statuts de congés payés
* *
@ -773,18 +855,19 @@ class Holiday extends CommonObject
if (empty($userID) && empty($nbHoliday)) if (empty($userID) && empty($nbHoliday))
{ {
// Si mise à jour pour tous le monde en début de mois // Si mise à jour pour tout le monde en début de mois
$now=dol_now();
// Mois actuel // Mois actuel
$month = date('m',time()); $month = date('m',$now);
$lastUpdate = $this->getConfCP('lastUpdate'); $lastUpdate = $this->getConfCP('lastUpdate');
$monthLastUpdate = date('m', $lastUpdate); $monthLastUpdate = date('m', $lastUpdate);
// Si la date du mois n'est pas la même que celle sauvegardé, on met à jour le timestamp // Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp
if ($month != $monthLastUpdate) if ($month != $monthLastUpdate)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
$sql.= " value = '".dol_now()."'"; $sql.= " value = '".$this->db->idate($now)."'";
$sql.= " WHERE name = 'lastUpdate'"; $sql.= " WHERE name = 'lastUpdate'";
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -838,7 +921,7 @@ class Holiday extends CommonObject
*/ */
function getCheckOption($name) { function getCheckOption($name) {
$sql = "SELECT *"; $sql = "SELECT value";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config";
$sql.= " WHERE name = '".$name."'"; $sql.= " WHERE name = '".$name."'";
@ -909,15 +992,15 @@ class Holiday extends CommonObject
*/ */
function getCPforUser($user_id) { function getCPforUser($user_id) {
$sql = "SELECT *"; $sql = "SELECT nb_holiday";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users";
$sql.= " WHERE fk_user = '".$user_id."'"; $sql.= " WHERE fk_user = '".$user_id."'";
dol_syslog(get_class($this).'::getCPforUser sql='.$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if($result) { if($result) {
$obj = $this->db->fetch_array($result); $obj = $this->db->fetch_object($result);
return number_format($obj['nb_holiday'],2); return number_format($obj->nb_holiday,2);
} else { } else {
return '0'; return '0';
} }
@ -1610,6 +1693,7 @@ class Holiday extends CommonObject
$this->date_debut=dol_now(); $this->date_debut=dol_now();
$this->date_fin=dol_now()+(24*3600); $this->date_fin=dol_now()+(24*3600);
$this->fk_validator=1; $this->fk_validator=1;
$this->halfday=0;
} }
} }

View File

@ -52,6 +52,8 @@ $now=dol_now();
// Si création de la demande // Si création de la demande
if ($action == 'create') if ($action == 'create')
{ {
$cp = new Holiday($db);
// Si pas le droit de créer une demande // Si pas le droit de créer une demande
if(!$user->rights->holiday->write) if(!$user->rights->holiday->write)
{ {
@ -59,9 +61,15 @@ if ($action == 'create')
exit; exit;
} }
$date_debut = dol_mktime(0, 0, 0, $_POST['date_debut_month'], $_POST['date_debut_day'], $_POST['date_debut_year']); $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
$date_fin = dol_mktime(0, 0, 0, $_POST['date_fin_month'], $_POST['date_fin_day'], $_POST['date_fin_year']); $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
$starthalfday=GETPOST('starthalfday');
$endhalfday=GETPOST('endhalfday');
$halfday=0;
if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday=2;
else if ($starthalfday == 'afternoon') $halfday=-1;
else if ($endhalfday == 'morning') $halfday=1;
$valideur = GETPOST('valideur'); $valideur = GETPOST('valideur');
$description = trim(GETPOST('description')); $description = trim(GETPOST('description'));
$userID = GETPOST('userID'); $userID = GETPOST('userID');
@ -80,21 +88,15 @@ if ($action == 'create')
exit; exit;
} }
$testDateDebut = $date_debut;
$testDateFin = $date_fin;
// Si date de début après la date de fin // Si date de début après la date de fin
if($testDateDebut > $testDateFin) if ($date_debut > $date_fin)
{ {
header('Location: fiche.php?action=request&error=datefin'); header('Location: fiche.php?action=request&error=datefin');
exit; exit;
} }
$cp = new Holiday($db); // Check if there is already holiday for this period
$verifCP = $cp->verifDateHolidayCP($userID, $date_debut, $date_fin, $halfday);
$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'); header('Location: fiche.php?action=request&error=alreadyCP');
@ -102,7 +104,7 @@ if ($action == 'create')
} }
// Si aucun jours ouvrés dans la demande // Si aucun jours ouvrés dans la demande
$nbopenedday=num_open_day($testDateDebut,$testDateFin,0,1); $nbopenedday=num_open_day($date_debut, $date_fin, 0, 1, $halfday);
if($nbopenedday < 1) if($nbopenedday < 1)
{ {
header('Location: fiche.php?action=request&error=DureeHoliday'); header('Location: fiche.php?action=request&error=DureeHoliday');
@ -121,7 +123,8 @@ if ($action == 'create')
$cp->date_debut = $date_debut; $cp->date_debut = $date_debut;
$cp->date_fin = $date_fin; $cp->date_fin = $date_fin;
$cp->fk_validator = $valideur; $cp->fk_validator = $valideur;
$cp->halfday = $halfday;
$verif = $cp->create($user_id); $verif = $cp->create($user_id);
// Si pas d'erreur SQL on redirige vers la fiche de la demande // Si pas d'erreur SQL on redirige vers la fiche de la demande
@ -141,9 +144,15 @@ if ($action == 'create')
if ($action == 'update') if ($action == 'update')
{ {
$date_debut = dol_mktime(0, 0, 0, $_POST['date_debut_month'], $_POST['date_debut_day'], $_POST['date_debut_year']); $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
$date_fin = dol_mktime(0, 0, 0, $_POST['date_fin_month'], $_POST['date_fin_day'], $_POST['date_fin_year']); $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
$starthalfday=GETPOST('starthalfday');
$endhalfday=GETPOST('endhalfday');
$halfday=0;
if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday=2;
else if ($starthalfday == 'afternoon') $halfday=-1;
else if ($endhalfday == 'morning') $halfday=1;
// Si pas le droit de modifier une demande // Si pas le droit de modifier une demande
if(!$user->rights->holiday->write) if(!$user->rights->holiday->write)
{ {
@ -175,11 +184,8 @@ if ($action == 'update')
exit; exit;
} }
$testDateDebut = $date_debut;
$testDateFin = $date_fin;
// Si date de début après la date de fin // Si date de début après la date de fin
if ($testDateDebut > $testDateFin) { if ($date_debut > $date_fin) {
header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=datefin'); header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=datefin');
exit; exit;
} }
@ -191,7 +197,7 @@ if ($action == 'update')
} }
// Si pas de jours ouvrés dans la demande // Si pas de jours ouvrés dans la demande
$nbopenedday=num_open_day($testDateDebut,$testDateFin,0,1); $nbopenedday=num_open_day($date_debut, $date_fin, 0, 1, $halfday);
if ($nbopenedday < 1) if ($nbopenedday < 1)
{ {
header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=DureeHoliday'); header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=DureeHoliday');
@ -202,10 +208,10 @@ if ($action == 'update')
$cp->date_debut = $date_debut; $cp->date_debut = $date_debut;
$cp->date_fin = $date_fin; $cp->date_fin = $date_fin;
$cp->fk_validator = $valideur; $cp->fk_validator = $valideur;
$cp->halfday = $halfday;
$verif = $cp->update($user->id);
// Update
// Si pas d'erreur SQL on redirige vers la fiche de la demande $verif = $cp->update($user->id);
if ($verif > 0) if ($verif > 0)
{ {
header('Location: fiche.php?id='.$_POST['holiday_id']); header('Location: fiche.php?id='.$_POST['holiday_id']);
@ -502,9 +508,9 @@ if ($action == 'confirm_cancel' && $_GET['confirm'] == 'yes')
$userID = $user->id; $userID = $user->id;
// Si statut en attente de validation et valideur = utilisateur // Si statut en attente de validation et valideur = utilisateur
if($cp->statut == 2 && $userID == $cp->fk_validator) if ($cp->statut == 2 && $userID == $cp->fk_validator)
{ {
$cp->date_cancel = date('Y-m-d H:i:s', time()); $cp->date_cancel = dol_now();
$cp->fk_user_cancel = $user->id; $cp->fk_user_cancel = $user->id;
$cp->statut = 4; $cp->statut = 4;
@ -569,6 +575,10 @@ if ($action == 'confirm_cancel' && $_GET['confirm'] == 'yes')
*/ */
$form = new Form($db); $form = new Form($db);
$cp = new Holiday($db);
$listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon"));
llxHeader(array(),$langs->trans('CPTitreMenu')); llxHeader(array(),$langs->trans('CPTitreMenu'));
@ -617,43 +627,39 @@ if (empty($id) || $action == 'add' || $action == 'request')
dol_htmloutput_mesg('',$errors,'error'); dol_htmloutput_mesg('',$errors,'error');
} }
$cp = new Holiday($db);
$delayForRequest = $cp->getConfCP('delayForRequest'); $delayForRequest = $cp->getConfCP('delayForRequest');
//$delayForRequest = $delayForRequest * (60*60*24); //$delayForRequest = $delayForRequest * (60*60*24);
$nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd');
print '<script type="text/javascript"> print '<script type="text/javascript">
//<![CDATA[ function valider()
{
function valider(){ if(document.demandeCP.date_debut_.value != "")
if(document.demandeCP.date_debut_.value != "") { {
if(document.demandeCP.date_fin_.value != "")
if(document.demandeCP.date_fin_.value != "") { {
if(document.demandeCP.valideur.value != "-1") {
if(document.demandeCP.valideur.value != "-1") { return true;
return true; }
} else {
else { alert("'.dol_escape_js($langs->transnoentities('InvalidValidatorCP')).'");
alert("'.dol_escape_js($langs->transnoentities('InvalidValidatorCP')).'"); return false;
return false; }
} }
else
} {
else { alert("'.dol_escape_js($langs->transnoentities('NoDateFin')).'");
alert("'.dol_escape_js($langs->transnoentities('NoDateFin')).'"); return false;
return false; }
} }
} else
{
else { alert("'.dol_escape_js($langs->transnoentities('NoDateDebut')).'");
alert("'.dol_escape_js($langs->transnoentities('NoDateDebut')).'"); return false;
return false; }
} }
}
//]]>
</script>'."\n"; </script>'."\n";
// Formulaire de demande // Formulaire de demande
@ -678,6 +684,8 @@ if (empty($id) || $action == 'add' || $action == 'request')
$tmpdate = dol_mktime(0, 0, 0, GETPOST('datepmonth'), GETPOST('datepday'), GETPOST('datepyear')); $tmpdate = dol_mktime(0, 0, 0, GETPOST('datepmonth'), GETPOST('datepday'), GETPOST('datepyear'));
$form->select_date($tmpdate,'date_debut_'); $form->select_date($tmpdate,'date_debut_');
} }
print ' &nbsp; &nbsp; ';
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):'morning'));
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
@ -690,6 +698,8 @@ if (empty($id) || $action == 'add' || $action == 'request')
$tmpdate = dol_mktime(0, 0, 0, GETPOST('datefmonth'), GETPOST('datefday'), GETPOST('datefyear')); $tmpdate = dol_mktime(0, 0, 0, GETPOST('datefmonth'), GETPOST('datefday'), GETPOST('datefyear'));
$form->select_date($tmpdate,'date_fin_'); $form->select_date($tmpdate,'date_fin_');
} }
print ' &nbsp; &nbsp; ';
print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):'afternoon'));
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
@ -738,7 +748,6 @@ else
// Affichage de la fiche d'une demande de congés payés // Affichage de la fiche d'une demande de congés payés
if ($id > 0) if ($id > 0)
{ {
$cp = new Holiday($db);
$cp->fetch($id); $cp->fetch($id);
$valideur = new User($db); $valideur = new User($db);
@ -834,7 +843,6 @@ else
dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday'); dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday');
if ($action == 'edit' && $user->id == $cp->fk_user && $cp->statut == 1) if ($action == 'edit' && $user->id == $cp->fk_user && $cp->statut == 1)
{ {
$edit = true; $edit = true;
@ -845,53 +853,69 @@ else
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tbody>'; print '<tbody>';
/*print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("InfosCP").'</td>';
print '</tr>';*/
$linkback='';
print '<tr>'; print '<tr>';
print '<td width="25%">'.$langs->trans("Ref").'</td>'; print '<td width="25%">'.$langs->trans("Ref").'</td>';
print '<td>'.$cp->rowid.'</td>'; print '<td>';
print $form->showrefnav($cp, 'id', $linkback, 1, 'rowid', 'ref');
print '</td>';
print '</tr>'; print '</tr>';
$starthalfday=($cp->halfday == -1 || $cp->halfday == 2)?'afternoon':'morning';
$endhalfday=($cp->halfday == 1 || $cp->halfday == 2)?'morning':'afternoon';
if(!$edit) { if(!$edit) {
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('DateDebCP').'</td>'; print '<td>'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td>'.dol_print_date($cp->date_debut,'day').'</td>'; print '<td>'.dol_print_date($cp->date_debut,'day');
print ' &nbsp; &nbsp; ';
print $langs->trans($listhalfday[$starthalfday]);
print '</td>';
print '</tr>'; print '</tr>';
} else { } else {
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('DateDebCP').'</td>'; print '<td>'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td>'; print '<td>';
$form->select_date($cp->date_debut,'date_debut_'); $form->select_date($cp->date_debut,'date_debut_');
print ' &nbsp; &nbsp; ';
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):$starthalfday));
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
if(!$edit) { if (!$edit)
{
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('DateFinCP').'</td>'; print '<td>'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td>'.dol_print_date($cp->date_fin,'day').'</td>'; print '<td>'.dol_print_date($cp->date_fin,'day');
print ' &nbsp; &nbsp; ';
print $langs->trans($listhalfday[$endhalfday]);
print '</td>';
print '</tr>'; print '</tr>';
} else { } else {
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('DateFinCP').'</td>'; print '<td>'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td>'; print '<td>';
$form->select_date($cp->date_fin,'date_fin_'); $form->select_date($cp->date_fin,'date_fin_');
print ' &nbsp; &nbsp; ';
print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):$endhalfday));
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('NbUseDaysCP').'</td>'; print '<td>'.$langs->trans('NbUseDaysCP').'</td>';
print '<td>'.num_open_day($cp->date_debut,$cp->date_fin,0,1).'</td>'; print '<td>'.num_open_day($cp->date_debut, $cp->date_fin, 0, 1, $cp->halfday).'</td>';
print '</tr>'; print '</tr>';
// Status // Status
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('StatutCP').'</td>'; print '<td>'.$langs->trans('StatutCP').'</td>';
print '<td><b>'.$cp->getStatutCP($cp->statut).'</b></td>'; print '<td>'.$cp->getLibStatut(2).'</td>';
print '</tr>'; print '</tr>';
if($cp->statut == 5) { if ($cp->statut == 5)
{
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('DetailRefusCP').'</td>'; print '<td>'.$langs->trans('DetailRefusCP').'</td>';
print '<td>'.$cp->detail_refuse.'</td>'; print '<td>'.$cp->detail_refuse.'</td>';
@ -899,12 +923,15 @@ else
} }
// Description // Description
if(!$edit) { if (!$edit)
{
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('DescCP').'</td>'; print '<td>'.$langs->trans('DescCP').'</td>';
print '<td>'.nl2br($cp->description).'</td>'; print '<td>'.nl2br($cp->description).'</td>';
print '</tr>'; print '</tr>';
} else { }
else
{
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('DescCP').'</td>'; print '<td>'.$langs->trans('DescCP').'</td>';
print '<td><textarea name="description" class="flat" rows="'.ROWS_3.'" cols="70">'.$cp->description.'</textarea></td>'; print '<td><textarea name="description" class="flat" rows="'.ROWS_3.'" cols="70">'.$cp->description.'</textarea></td>';
@ -995,23 +1022,27 @@ else
{ {
print '<a href="fiche.php?id='.$_GET['id'].'&action=edit" class="butAction">'.$langs->trans("EditCP").'</a>'; print '<a href="fiche.php?id='.$_GET['id'].'&action=edit" class="butAction">'.$langs->trans("EditCP").'</a>';
} }
if($user->rights->holiday->delete && $cp->statut == 1)
{
print '<a href="fiche.php?id='.$_GET['id'].'&action=delete" class="butAction">'.$langs->trans("DeleteCP").'</a>';
}
if($user->id == $cp->fk_user && $cp->statut == 1) if($user->id == $cp->fk_user && $cp->statut == 1)
{ {
print '<a href="fiche.php?id='.$_GET['id'].'&action=sendToValidate" class="butAction">'.$langs->trans("SendToValidationCP").'</a>'; print '<a href="fiche.php?id='.$_GET['id'].'&action=sendToValidate" class="butAction">'.$langs->trans("Validate").'</a>';
} }
if($user->rights->holiday->delete && $cp->statut == 1)
{
print '<a href="fiche.php?id='.$_GET['id'].'&action=delete" class="butActionDelete">'.$langs->trans("DeleteCP").'</a>';
}
// Si le statut est en attente de validation et que le valideur est connecté // Si le statut est en attente de validation et que le valideur est connecté
if($userID == $cp->fk_validator && $cp->statut == 2) if ($userID == $cp->fk_validator && $cp->statut == 2)
{ {
print '<a href="fiche.php?id='.$_GET['id'].'&action=valid" class="butAction">'.$langs->trans("ActionValidCP").'</a>'; print '<a href="fiche.php?id='.$_GET['id'].'&action=valid" class="butAction">'.$langs->trans("Approve").'</a>';
print '<a href="fiche.php?id='.$_GET['id'].'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>'; print '<a href="fiche.php?id='.$_GET['id'].'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>';
print '<a href="fiche.php?id='.$_GET['id'].'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
} }
if (($userID == $cp->fk_validator && $cp->statut == 2) || ($cp->date_debut > dol_now()) || $user->admin)
{
print '<a href="fiche.php?id='.$_GET['id'].'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
}
print '</div>'; print '</div>';
} }

View File

@ -57,7 +57,6 @@ $search_employe = GETPOST('search_employe');
$search_valideur = GETPOST('search_valideur'); $search_valideur = GETPOST('search_valideur');
$search_statut = GETPOST('select_statut'); $search_statut = GETPOST('select_statut');
$holiday = new Holiday($db);
/* /*
* Actions * Actions
@ -71,6 +70,9 @@ $holiday = new Holiday($db);
* View * View
*/ */
$holiday = new Holiday($db);
$holidaystatic=new Holiday($db);
$max_year = 5; $max_year = 5;
$min_year = 10; $min_year = 10;
$filter=''; $filter='';
@ -268,35 +270,44 @@ $holiday->selectStatutCP($search_statut);
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans('Search').'">'; print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans('Search').'">';
print "</td></tr>\n"; print "</td></tr>\n";
// Lines
if (! empty($holiday->holiday)) if (! empty($holiday->holiday))
{ {
$userstatic = new User($db);
$approbatorstatic = new User($db);
foreach($holiday->holiday as $infos_CP) foreach($holiday->holiday as $infos_CP)
{ {
$var=!$var; $var=!$var;
// Utilisateur // Utilisateur
$user = new User($db); $userstatic->id=$infos_CP['fk_user'];
$user->fetch($infos_CP['fk_user']); $userstatic->lastname=$infos_CP['user_lastname'];
$userstatic->firstname=$infos_CP['user_firstname'];
// Valideur // Valideur
$validator = new User($db); $approbatorstatic->id=$infos_CP['fk_validator'];
$validator->fetch($infos_CP['fk_validator']); $approbatorstatic->lastname=$infos_CP['validator_lastname'];
$approbatorstatic->firstname=$infos_CP['validator_firstname'];
$date = $infos_CP['date_create']; $date = $infos_CP['date_create'];
$statut = $holiday->getStatutCP($infos_CP['statut']);
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td><a href="./fiche.php?id='.$infos_CP['rowid'].'">CP '.$infos_CP['rowid'].'</a></td>';
print '<td style="text-align: center;">'.dol_print_date($date,'day').'</td>';
print '<td>'.$user->getNomUrl('1').'</td>';
print '<td>'.$validator->getNomUrl('1').'</td>';
print '<td style="text-align: center;">'.dol_print_date($infos_CP['date_debut'],'day').'</td>';
print '<td style="text-align: center;">'.dol_print_date($infos_CP['date_fin'],'day').'</td>';
print '<td>'; print '<td>';
$nbopenedday=num_open_day($infos_CP['date_debut'],$infos_CP['date_fin'],0,1); $holidaystatic->id=$infos_CP['rowid'];
$holidaystatic->ref=$infos_CP['rowid'];
print $holidaystatic->getNomUrl(1);
print '</td>';
print '<td style="text-align: center;">'.dol_print_date($date,'day').'</td>';
print '<td>'.$userstatic->getNomUrl('1').'</td>';
print '<td>'.$approbatorstatic->getNomUrl('1').'</td>';
print '<td align="center">'.dol_print_date($infos_CP['date_debut'],'day').'</td>';
print '<td align="center">'.dol_print_date($infos_CP['date_fin'],'day').'</td>';
print '<td align="right">';
$nbopenedday=num_open_day($infos_CP['date_debut'], $infos_CP['date_fin'] ,0, 1, $infos_CP['halfday']);
print $nbopenedday; print $nbopenedday;
print '<td align="center"><a href="./fiche.php?id='.$infos_CP['rowid'].'">'.$statut.'</a></td>'; print '<td align="right">'.$holidaystatic->LibStatut($infos_CP['statut'],5).'</td>';
print '</tr>'."\n"; print '</tr>'."\n";
} }

View File

@ -44,6 +44,7 @@ if(!$user->rights->holiday->month_report) accessforbidden();
$html = new Form($db); $html = new Form($db);
$htmlother = new FormOther($db); $htmlother = new FormOther($db);
$holidaystatic = new Holiday($db);
llxHeader(array(),$langs->trans('CPTitreMenu')); llxHeader(array(),$langs->trans('CPTitreMenu'));
@ -59,13 +60,12 @@ if(empty($year)) {
$year = date('Y'); $year = date('Y');
} }
$sql = "SELECT cp.fk_user, cp.date_debut, cp.date_fin"; $sql = "SELECT cp.rowid, cp.fk_user, cp.date_debut, cp.date_fin, cp.halfday";
$sql.= " FROM llx_holiday cp"; $sql.= " FROM llx_holiday cp";
$sql.= " LEFT JOIN llx_user u ON cp.fk_user = u.rowid"; $sql.= " LEFT JOIN llx_user u ON cp.fk_user = u.rowid";
$sql.= " WHERE cp.rowid > '0'"; $sql.= " WHERE cp.statut = 3"; // Approved
$sql.= " AND cp.statut = 3"; // TODO Use BETWEEN instead of date_format
$sql.= " AND (date_format(cp.date_debut, '%Y-%m') = '$year-$month' $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"; $sql.= " ORDER BY u.name,cp.date_debut";
$result = $db->query($sql); $result = $db->query($sql);
@ -77,53 +77,62 @@ print '<div class="tabBar">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n"; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print 'Choix mois : <input class="flat" type="text" size="1" maxlength="2" 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); $htmlother->select_year($year,'year_start',1,10,3);
print '<input type="submit" value="'.$langs->trans("Refresh").'" class="button" />'; print '<input type="submit" value="'.$langs->trans("Refresh").'" class="button" />';
print '</form>'; print '</form>';
print '<br />'; print '<br>';
$var=true; $var=true;
print '<table class="noborder" width="40%;">'; print '<table class="noborder" width="40%;">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>';
print '<td>'.$langs->trans('Employee').'</td>'; print '<td>'.$langs->trans('Employee').'</td>';
print '<td>'.$langs->trans('DateDebCP').'</td>'; print '<td>'.$langs->trans('DateDebCP').'</td>';
print '<td>'.$langs->trans('DateFinCP').'</td>'; print '<td>'.$langs->trans('DateFinCP').'</td>';
print '<td>'.$langs->trans('nbJours').'</td>'; print '<td align="right">'.$langs->trans('nbJours').'</td>';
print '</tr>'; print '</tr>';
if($num == '0') { if($num == '0') {
print '<tr class="pair">'; print '<tr class="pair">';
print '<td colspan="4" style="text-align: center; padding: 3px;">'.$langs->trans('NoCPforMonth').'</td>'; print '<td colspan="5">'.$langs->trans('None').'</td>';
print '</tr>'; print '</tr>';
} else { } else {
while($holiday = $db->fetch_array($result)){ while ($holiday = $db->fetch_array($result))
{
$user = new User($db); $user = new User($db);
$user->fetch($holiday['fk_user']); $user->fetch($holiday['fk_user']);
$var=!$var; $var=!$var;
if(substr($holiday['date_debut'],5,2)==$month-1){ $holidaystatic->id=$holiday['rowid'];
$holidaystatic->ref=$holiday['rowid'];
$start_date=$db->jdate($holiday['date_debut']);
$end_date=$db->jdate($holiday['date_fin']);
/*if(substr($holiday['date_debut'],5,2)==$month-1){
$holiday['date_debut'] = date('Y-'.$month.'-01'); $holiday['date_debut'] = date('Y-'.$month.'-01');
} }
if(substr($holiday['date_fin'],5,2)==$month+1){ if(substr($holiday['date_fin'],5,2)==$month+1){
$holiday['date_fin'] = date('Y-'.$month.'-t'); $holiday['date_fin'] = date('Y-'.$month.'-t');
} }*/
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td>'.$holidaystatic->getNomUrl(1).'</td>';
print '<td>'.$user->nom.' '.$user->prenom.'</td>'; print '<td>'.$user->nom.' '.$user->prenom.'</td>';
print '<td>'.$holiday['date_debut'].'</td>'; print '<td>'.dol_print_date($start_date,'day');
print '<td>'.$holiday['date_fin'].'</td>'; print '</td>';
print '<td>'; print '<td>'.dol_print_date($end_date,'day');
$nbopenedday=num_open_day($holiday['date_debut'],$holiday['date_fin'],0,1); print '</td>';
print '<td align="right">';
$nbopenedday=num_open_day($start_date, $end_date, 0, 1, $holiday['halfday']);
print $nbopenedday; print $nbopenedday;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';

View File

@ -15,12 +15,12 @@ DateFinCP=End date
DateCreateCP=Creation date DateCreateCP=Creation date
DraftCP=Draft DraftCP=Draft
ToValidateCP=Awaiting approval ToValidateCP=Awaiting approval
ValidateCP=Validated ValidateCP=Approved
CancelCP=Canceled CancelCP=Canceled
RefuseCP=Refused RefuseCP=Refused
ValidatorCP=Validator ValidatorCP=Approbator
ListeCP=List of holidays ListeCP=List of holidays
ValidateByCP=Will be validated by ValidateByCP=Will be approved by
DescCP=Description DescCP=Description
SendRequestCP=Creating demand for holidays SendRequestCP=Creating demand for holidays
DelayToRequestCP=Applications for holidays must be made at least <b>%s day(s)</b> before them. DelayToRequestCP=Applications for holidays must be made at least <b>%s day(s)</b> before them.
@ -47,17 +47,17 @@ StatutCP=Status
SendToValidationCP=Send to validation SendToValidationCP=Send to validation
TitleDeleteCP=Delete the request of holidays TitleDeleteCP=Delete the request of holidays
ConfirmDeleteCP=Confirm the deletion of this request for holidays? ConfirmDeleteCP=Confirm the deletion of this request for holidays?
ErrorCantDeleteCP=Error you don't have the right to delete this request of holidays. ErrorCantDeleteCP=Error you don't have the right to delete this holiday request.
CantCreateCP=You don't have the right to apply for holidays. CantCreateCP=You don't have the right to apply for holidays.
InvalidValidatorCP=You must choose a validator to your request of holidays. InvalidValidatorCP=You must choose an approbator to your holiday request.
UpdateButtonCP=Update UpdateButtonCP=Update
CantUpdate=You cannot update this request of holidays. CantUpdate=You cannot update this request of holidays.
NoDateDebut=You must select a start date. NoDateDebut=You must select a start date.
NoDateFin=You must select an end date. NoDateFin=You must select an end date.
ErrorDureeCP=Your request for holidays does not contain working day. ErrorDureeCP=Your request for holidays does not contain working day.
TitleValidCP=Validate the request holidays TitleValidCP=Approve the request holidays
ConfirmValidCP=Are you sure you want to validate the request of holidays? ConfirmValidCP=Are you sure you want to approve the holiday request?
DateValidCP=Date validation DateValidCP=Date approved
TitleToValidCP=Send request holidays TitleToValidCP=Send request holidays
ConfirmToValidCP=Are you sure you want to send the request of holidays? ConfirmToValidCP=Are you sure you want to send the request of holidays?
TitleRefuseCP=Refuse the request holidays TitleRefuseCP=Refuse the request holidays
@ -91,15 +91,15 @@ LastDayOfHoliday=Last day of holiday
ConfCP=Configuration of holidays module ConfCP=Configuration of holidays module
DescOptionCP=Description of the option DescOptionCP=Description of the option
ValueOptionCP=Value ValueOptionCP=Value
GroupToValidateCP=Group with the ability to validate holidays GroupToValidateCP=Group with the ability to approve holidays
ConfirmConfigCP=Validate the configuration ConfirmConfigCP=Validate the configuration
LastUpdateCP=Last updated automatically of holidays LastUpdateCP=Last updated automatically of holidays
UpdateConfCPOK=Updated successfully. UpdateConfCPOK=Updated successfully.
ErrorUpdateConfCP=An error occurred during the update, please try again. ErrorUpdateConfCP=An error occurred during the update, please try again.
AddCPforUsers=Please add the balance of holidays of users by <a href="../define_holiday.php" style="font-weight: normal; color: red; text-decoration: underline;">clicking here</a>. AddCPforUsers=Please add the balance of holidays of users by <a href="../define_holiday.php" style="font-weight: normal; color: red; text-decoration: underline;">clicking here</a>.
DelayForSubmitCP=Deadline to apply for holidays DelayForSubmitCP=Deadline to apply for holidays
AlertValidatorDelayCP=Prevent the validator if the holiday request does not match the deadline AlertapprobatortorDelayCP=Prevent the approbator if the holiday request does not match the deadline
AlertValidorSoldeCP=Prevent the validator if the holiday request exceed the balance AlertValidorSoldeCP=Prevent the approbator if the holiday request exceed the balance
nbUserCP=Number of users supported in the module holidays nbUserCP=Number of users supported in the module holidays
nbHolidayDeductedCP=Number of holidays to be deducted per day of holiday taken nbHolidayDeductedCP=Number of holidays to be deducted per day of holiday taken
nbHolidayEveryMonthCP=Number of holidays added every month nbHolidayEveryMonthCP=Number of holidays added every month

View File

@ -14,13 +14,13 @@ DateDebCP=Date Début
DateFinCP=Date Fin DateFinCP=Date Fin
DateCreateCP=Date de création DateCreateCP=Date de création
DraftCP=Brouillon DraftCP=Brouillon
ToValidateCP=En attente de validation ToValidateCP=En attente d'approbation
ValidateCP=Validée ValidateCP=Approuvé
CancelCP=Annulée CancelCP=Annulée
RefuseCP=Refusée RefuseCP=Refusée
ValidatorCP=Valideur ValidatorCP=Approbateur
ListeCP=Liste des congés ListeCP=Liste des congés
ValidateByCP=Sera validée par ValidateByCP=Sera approuvé par
DescCP=Description DescCP=Description
SendRequestCP=Envoyer la demande de congés SendRequestCP=Envoyer la demande de congés
DelayToRequestCP=Les demandes de congés doivent être faites au moins <b>%s jours</b> avant la date</b> de ceux-ci. DelayToRequestCP=Les demandes de congés doivent être faites au moins <b>%s jours</b> avant la date</b> de ceux-ci.
@ -49,7 +49,7 @@ TitleDeleteCP=Supprimer la demande de Congés
ConfirmDeleteCP=Confirmer la suppression de cette demande de congés ? ConfirmDeleteCP=Confirmer la suppression de cette demande de congés ?
ErrorCantDeleteCP=Erreur, vous n'avez pas le droit de supprimer cette demande de congés. ErrorCantDeleteCP=Erreur, vous n'avez pas le droit de supprimer cette demande de congés.
CantCreateCP=Vous n'avez pas le droit de faire des demandes de congés. CantCreateCP=Vous n'avez pas le droit de faire des demandes de congés.
InvalidValidatorCP=Vous devez choisir un valideur pour votre demande de congés. InvalidValidatorCP=Vous devez choisir un approbateur pour votre demande de congés.
UpdateButtonCP=Mettre à jour UpdateButtonCP=Mettre à jour
CantUpdate=Vous ne pouvez pas mettre à jour cette demande de congés. CantUpdate=Vous ne pouvez pas mettre à jour cette demande de congés.
NoDateDebut=Vous devez choisir une date de début. NoDateDebut=Vous devez choisir une date de début.
@ -57,7 +57,7 @@ NoDateFin=Vous devez choisir une date de fin.
ErrorDureeCP=Votre demande de congés payés ne contient aucun jour ouvré. ErrorDureeCP=Votre demande de congés payés ne contient aucun jour ouvré.
TitleValidCP=Valider la demande de Congés Payés TitleValidCP=Valider la demande de Congés Payés
ConfirmValidCP=Êtes-vous sûr de vouloir valider la demande de congés ? ConfirmValidCP=Êtes-vous sûr de vouloir valider la demande de congés ?
DateValidCP=Date de validation DateValidCP=Date d'approbation
TitleToValidCP=Envoyer la demande de Congés Payés TitleToValidCP=Envoyer la demande de Congés Payés
ConfirmToValidCP=Êtes-vous sûr de vouloir envoyer la demande de congés ? ConfirmToValidCP=Êtes-vous sûr de vouloir envoyer la demande de congés ?
TitleRefuseCP=Refuser la demande de Congés Payés TitleRefuseCP=Refuser la demande de Congés Payés