Fix: Several fixes into date functions
Qual: Add PHPUnit tests
This commit is contained in:
parent
d3ef78df47
commit
7d83fdce5b
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* 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>
|
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -236,7 +236,7 @@ if ($action == 'edit') // Edit
|
|||||||
print '<td width="20"> </td>';
|
print '<td width="20"> </td>';
|
||||||
print '</tr>';
|
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
|
// Show bugtrack link
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
@ -390,7 +390,7 @@ else // Show
|
|||||||
print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1);
|
print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1);
|
||||||
print '</td></tr>';
|
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
|
// Show bugtrack link
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|||||||
@ -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
|
* Called by function num_open_day
|
||||||
*
|
*
|
||||||
* @param timestamp $timestampStart Timestamp de debut
|
* @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
|
* 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 $timestampStart Timestamp de debut
|
||||||
* @param timestamp $timestampEnd Timestamp de fin
|
* @param timestamp $timestampEnd Timestamp de fin
|
||||||
* @param int $lastday On prend en compte le dernier jour, 0: non, 1:oui
|
* @param int $lastday Last day is included, 0: non, 1:oui
|
||||||
* @return int Nombre de jours
|
* @return int Number of days
|
||||||
*/
|
*/
|
||||||
function num_between_day($timestampStart, $timestampEnd, $lastday=0)
|
function num_between_day($timestampStart, $timestampEnd, $lastday=0)
|
||||||
{
|
{
|
||||||
@ -751,8 +752,9 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
|
|||||||
{
|
{
|
||||||
$bit = 1;
|
$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;
|
return $nbjours;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,22 +764,29 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
|
|||||||
* @param timestamp $timestampStart Timestamp de debut
|
* @param timestamp $timestampStart Timestamp de debut
|
||||||
* @param timestamp $timestampEnd Timestamp de fin
|
* @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 $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
|
* @return int Nombre de jours ou d'heures
|
||||||
*/
|
*/
|
||||||
function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
|
function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
|
||||||
{
|
{
|
||||||
global $langs;
|
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)
|
if ($timestampStart < $timestampEnd)
|
||||||
{
|
{
|
||||||
$bit = 0;
|
//print num_between_day($timestampStart, $timestampEnd, $lastday).' - '.num_public_holiday($timestampStart, $timestampEnd);
|
||||||
if ($lastday == 1) $bit = 1;
|
$nbOpenDay = num_between_day($timestampStart, $timestampEnd, $lastday) - num_public_holiday($timestampStart, $timestampEnd, $lastday);
|
||||||
$nbOpenDay = num_between_day($timestampStart, $timestampEnd, $bit) - num_public_holiday($timestampStart, $timestampEnd);
|
|
||||||
$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;
|
||||||
}
|
}
|
||||||
|
elseif ($timestampStart == $timestampEnd)
|
||||||
|
{
|
||||||
|
$nbOpenDay=$lastday;
|
||||||
|
if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
|
||||||
|
return $nbOpenDay=1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $langs->trans("Error");
|
return $langs->trans("Error");
|
||||||
|
|||||||
@ -109,8 +109,8 @@ class Holiday extends CommonObject
|
|||||||
}
|
}
|
||||||
$sql.= " NOW(),";
|
$sql.= " NOW(),";
|
||||||
$sql.= " '".addslashes($this->description)."',";
|
$sql.= " '".addslashes($this->description)."',";
|
||||||
$sql.= " '".$this->date_debut."',";
|
$sql.= " '".$this->db->idate($this->date_debut)."',";
|
||||||
$sql.= " '".$this->date_fin."',";
|
$sql.= " '".$this->db->idate($this->date_fin)."',";
|
||||||
$sql.= " '1',";
|
$sql.= " '1',";
|
||||||
if(is_numeric($this->fk_validator)) {
|
if(is_numeric($this->fk_validator)) {
|
||||||
$sql.= " '".$this->fk_validator."'";
|
$sql.= " '".$this->fk_validator."'";
|
||||||
@ -196,17 +196,17 @@ class Holiday extends CommonObject
|
|||||||
|
|
||||||
$this->rowid = $obj->rowid;
|
$this->rowid = $obj->rowid;
|
||||||
$this->fk_user = $obj->fk_user;
|
$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->description = $obj->description;
|
||||||
$this->date_debut = $obj->date_debut;
|
$this->date_debut = $this->db->jdate($obj->date_debut);
|
||||||
$this->date_fin = $obj->date_fin;
|
$this->date_fin = $this->db->jdate($obj->date_fin);
|
||||||
$this->statut = $obj->statut;
|
$this->statut = $obj->statut;
|
||||||
$this->fk_validator = $obj->fk_validator;
|
$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->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->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->fk_user_cancel = $obj->fk_user_cancel;
|
||||||
$this->detail_refuse = $obj->detail_refuse;
|
$this->detail_refuse = $obj->detail_refuse;
|
||||||
|
|
||||||
@ -289,17 +289,17 @@ class Holiday extends CommonObject
|
|||||||
|
|
||||||
$tab_result[$i]['rowid'] = $obj->rowid;
|
$tab_result[$i]['rowid'] = $obj->rowid;
|
||||||
$tab_result[$i]['fk_user'] = $obj->fk_user;
|
$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]['description'] = $obj->description;
|
||||||
$tab_result[$i]['date_debut'] = $obj->date_debut;
|
$tab_result[$i]['date_debut'] = $this->db->jdate($obj->date_debut);
|
||||||
$tab_result[$i]['date_fin'] = $obj->date_fin;
|
$tab_result[$i]['date_fin'] = $this->db->jdate($obj->date_fin);
|
||||||
$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'] = $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]['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]['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]['fk_user_cancel'] = $obj->fk_user_cancel;
|
||||||
$tab_result[$i]['detail_refuse'] = $obj->detail_refuse;
|
$tab_result[$i]['detail_refuse'] = $obj->detail_refuse;
|
||||||
|
|
||||||
@ -430,12 +430,12 @@ class Holiday extends CommonObject
|
|||||||
$sql.= " description= '".addslashes($this->description)."',";
|
$sql.= " description= '".addslashes($this->description)."',";
|
||||||
|
|
||||||
if(!empty($this->date_debut)) {
|
if(!empty($this->date_debut)) {
|
||||||
$sql.= " date_debut = '".$this->date_debut."',";
|
$sql.= " date_debut = '".$this->db->idate($this->date_debut)."',";
|
||||||
} else {
|
} else {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if(!empty($this->date_fin)) {
|
if(!empty($this->date_fin)) {
|
||||||
$sql.= " date_fin = '".$this->date_fin."',";
|
$sql.= " date_fin = '".$this->db->idate($this->date_fin)."',";
|
||||||
} else {
|
} else {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
@ -450,7 +450,7 @@ class Holiday extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if(!empty($this->date_valid)) {
|
if(!empty($this->date_valid)) {
|
||||||
$sql.= " date_valid = '".$this->date_valid."',";
|
$sql.= " date_valid = '".$this->db->idate($this->date_valid)."',";
|
||||||
} else {
|
} else {
|
||||||
$sql.= " date_valid = NULL,";
|
$sql.= " date_valid = NULL,";
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ class Holiday extends CommonObject
|
|||||||
$sql.= " fk_user_valid = NULL,";
|
$sql.= " fk_user_valid = NULL,";
|
||||||
}
|
}
|
||||||
if(!empty($this->date_refuse)) {
|
if(!empty($this->date_refuse)) {
|
||||||
$sql.= " date_refuse = '".$this->date_refuse."',";
|
$sql.= " date_refuse = '".$this->db->idate($this->date_refuse)."',";
|
||||||
} else {
|
} else {
|
||||||
$sql.= " date_refuse = NULL,";
|
$sql.= " date_refuse = NULL,";
|
||||||
}
|
}
|
||||||
@ -470,7 +470,7 @@ class Holiday extends CommonObject
|
|||||||
$sql.= " fk_user_refuse = NULL,";
|
$sql.= " fk_user_refuse = NULL,";
|
||||||
}
|
}
|
||||||
if(!empty($this->date_cancel)) {
|
if(!empty($this->date_cancel)) {
|
||||||
$sql.= " date_cancel = '".$this->date_cancel."',";
|
$sql.= " date_cancel = '".$this->db->idate($this->date_cancel)."',";
|
||||||
} else {
|
} else {
|
||||||
$sql.= " date_cancel = NULL,";
|
$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é
|
* Liste les évènements de congés payés enregistré
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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/html.formfile.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.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/class/html.formmail.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
|
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
|
||||||
|
|
||||||
// Get parameters
|
// Get parameters
|
||||||
$myparam = GETPOST("myparam");
|
$myparam = GETPOST("myparam");
|
||||||
$action=GETPOST('action');
|
$action=GETPOST('action');
|
||||||
|
$id=GETPOST('id');
|
||||||
|
|
||||||
// Protection if external user
|
// Protection if external user
|
||||||
if ($user->societe_id > 0) accessforbidden();
|
if ($user->societe_id > 0) accessforbidden();
|
||||||
@ -46,7 +48,7 @@ $user_id = $user->id;
|
|||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
// Si création de la demande
|
// Si création de la demande
|
||||||
if ($action == 'add')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
|
|
||||||
// Si pas le droit de créer une demande
|
// Si pas le droit de créer une demande
|
||||||
@ -92,14 +94,15 @@ if ($action == 'add')
|
|||||||
$verifCP = $cp->verifDateHolidayCP($userID,$date_debut,$date_fin);
|
$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
|
// 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');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si aucun jours ouvrés dans la demande
|
// 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');
|
header('Location: fiche.php?action=request&error=DureeHoliday');
|
||||||
exit;
|
exit;
|
||||||
@ -137,6 +140,8 @@ if ($action == 'add')
|
|||||||
|
|
||||||
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_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
|
// Si pas le droit de modifier une demande
|
||||||
if(!$user->rights->holiday->write)
|
if(!$user->rights->holiday->write)
|
||||||
@ -151,12 +156,9 @@ if ($action == 'update')
|
|||||||
// Si en attente de validation
|
// Si en attente de validation
|
||||||
if ($cp->statut == 1)
|
if ($cp->statut == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Si c'est le créateur ou qu'il a le droit de tout lire / modifier
|
// 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)
|
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'];
|
$valideur = $_POST['valideur'];
|
||||||
$description = trim($_POST['description']);
|
$description = trim($_POST['description']);
|
||||||
|
|
||||||
@ -172,8 +174,8 @@ if ($action == 'update')
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$testDateDebut = strtotime($date_debut);
|
$testDateDebut = $date_debut;
|
||||||
$testDateFin = strtotime($date_fin);
|
$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 ($testDateDebut > $testDateFin) {
|
||||||
@ -188,7 +190,9 @@ if ($action == 'update')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si pas de jours ouvrés dans la demande
|
// 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');
|
header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=DureeHoliday');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -284,9 +288,10 @@ if ($action == 'confirm_send')
|
|||||||
$message.= "Veuillez trouver ci-dessous une demande de congés payés à valider.\n";
|
$message.= "Veuillez trouver ci-dessous une demande de congés payés à valider.\n";
|
||||||
|
|
||||||
$delayForRequest = $cp->getConfCP('delayForRequest');
|
$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
|
// Si l'option pour avertir le valideur en cas de délai trop court
|
||||||
if($cp->getConfCP('AlertValidatorDelay')) {
|
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
|
// Si l'option pour avertir le valideur en cas de solde inférieur à la demande
|
||||||
if($cp->getConfCP('AlertValidatorSolde')) {
|
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.= "\n";
|
||||||
$message.= "L'utilisateur ayant fait cette demande de congés payés n'a pas le solde requis.\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
|
// Si Validation de la demande
|
||||||
if($action == 'confirm_valid')
|
if($action == 'confirm_valid')
|
||||||
{
|
{
|
||||||
|
|
||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
$cp->fetch($_GET['id']);
|
$cp->fetch($_GET['id']);
|
||||||
|
|
||||||
@ -344,7 +351,7 @@ if($action == 'confirm_valid')
|
|||||||
if($cp->statut == 2 && $userID == $cp->fk_validator)
|
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->fk_user_valid = $user->id;
|
||||||
$cp->statut = 3;
|
$cp->statut = 3;
|
||||||
|
|
||||||
@ -354,7 +361,7 @@ if($action == 'confirm_valid')
|
|||||||
if($verif > 0) {
|
if($verif > 0) {
|
||||||
|
|
||||||
// Retrait du nombre de jours prit
|
// 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);
|
$soldeActuel = $cp->getCpforUser($cp->fk_user);
|
||||||
$newSolde = $soldeActuel - ($nbJour*$cp->getConfCP('nbHolidayDeducted'));
|
$newSolde = $soldeActuel - ($nbJour*$cp->getConfCP('nbHolidayDeducted'));
|
||||||
@ -570,7 +577,7 @@ if ($action == 'confirm_cancel' && $_GET['confirm'] == 'yes')
|
|||||||
|
|
||||||
llxHeader(array(),$langs->trans('CPTitreMenu'));
|
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
|
// Si l'utilisateur n'a pas le droit de faire une demande
|
||||||
if(!$user->rights->holiday->write)
|
if(!$user->rights->holiday->write)
|
||||||
@ -619,9 +626,9 @@ if ($action == 'request')
|
|||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
|
|
||||||
$delayForRequest = $cp->getConfCP('delayForRequest');
|
$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">
|
print '<script type="text/javascript">
|
||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
@ -635,19 +642,19 @@ if ($action == 'request')
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert("'.$langs->transnoentities('InvalidValidatorCP').'");
|
alert("'.dol_escape_js($langs->transnoentities('InvalidValidatorCP')).'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert("'.$langs->trans('NoDateFin').'");
|
alert("'.dol_escape_js($langs->transnoentities('NoDateFin')).'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
alert("'.$langs->trans('NoDateDebut').'");
|
alert("'.dol_escape_js($langs->transnoentities('NoDateDebut')).'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -657,7 +664,7 @@ if ($action == 'request')
|
|||||||
|
|
||||||
// Formulaire de demande
|
// Formulaire de demande
|
||||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" onsubmit="return valider()" name="demandeCP">'."\n";
|
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 '<input type="hidden" name="userID" value="'.$user_id.'" />'."\n";
|
||||||
print '<div class="tabBar">';
|
print '<div class="tabBar">';
|
||||||
print '<span>'.$langs->trans('DelayToRequestCP',$cp->getConfCP('delayForRequest')).'</span><br /><br />';
|
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 '<table class="border" width="100%">';
|
||||||
print '<tbody>';
|
print '<tbody>';
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="fieldrequired">'.$langs->trans("DateDebCP").'</td>';
|
print '<td class="fieldrequired">'.$langs->trans("DateDebCP").' ('.$langs->trans("FirstDayOfHoliday").')</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
// Si la demande ne vient pas de l'agenda
|
// Si la demande ne vient pas de l'agenda
|
||||||
if(!isset($_GET['datep'])) {
|
if(!isset($_GET['datep'])) {
|
||||||
$html->select_date($nextMonth,'date_debut_');
|
$html->select_date(-1,'date_debut_');
|
||||||
} else {
|
} else {
|
||||||
$tmpdate = dol_mktime(0, 0, 0, GETPOST('datepmonth'), GETPOST('datepday'), GETPOST('datepyear'));
|
$tmpdate = dol_mktime(0, 0, 0, GETPOST('datepmonth'), GETPOST('datepday'), GETPOST('datepyear'));
|
||||||
$html->select_date($tmpdate,'date_debut_');
|
$html->select_date($tmpdate,'date_debut_');
|
||||||
@ -680,11 +687,11 @@ if ($action == 'request')
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
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>';
|
print '<td>';
|
||||||
// Si la demande ne vient pas de l'agenda
|
// Si la demande ne vient pas de l'agenda
|
||||||
if(!isset($_GET['datep'])) {
|
if(!isset($_GET['datep'])) {
|
||||||
$html->select_date($nextMonth,'date_fin_');
|
$html->select_date(-1,'date_fin_');
|
||||||
} else {
|
} else {
|
||||||
$tmpdate = dol_mktime(0, 0, 0, GETPOST('datefmonth'), GETPOST('datefday'), GETPOST('datefyear'));
|
$tmpdate = dol_mktime(0, 0, 0, GETPOST('datefmonth'), GETPOST('datefday'), GETPOST('datefyear'));
|
||||||
$html->select_date($tmpdate,'date_fin_');
|
$html->select_date($tmpdate,'date_fin_');
|
||||||
@ -706,7 +713,7 @@ if ($action == 'request')
|
|||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans("DescCP").'</td>';
|
print '<td>'.$langs->trans("DescCP").'</td>';
|
||||||
print '<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 '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</tbody>';
|
print '</tbody>';
|
||||||
@ -723,7 +730,7 @@ if ($action == 'request')
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif(isset($_GET['id']))
|
else
|
||||||
{
|
{
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
@ -735,10 +742,10 @@ elseif(isset($_GET['id']))
|
|||||||
else
|
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 ($_GET['id'] > 0)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
$cp->fetch($_GET['id']);
|
$cp->fetch($id);
|
||||||
|
|
||||||
$valideur = new User($db);
|
$valideur = new User($db);
|
||||||
$valideur->fetch($cp->fk_validator);
|
$valideur->fetch($cp->fk_validator);
|
||||||
@ -887,7 +894,7 @@ elseif(isset($_GET['id']))
|
|||||||
}
|
}
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans('NbUseDaysCP').'</td>';
|
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>';
|
print '</tr>';
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
@ -911,7 +918,7 @@ elseif(isset($_GET['id']))
|
|||||||
} 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="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 '</tr>';
|
||||||
}
|
}
|
||||||
print '</tbody>';
|
print '</tbody>';
|
||||||
@ -953,24 +960,24 @@ elseif(isset($_GET['id']))
|
|||||||
|
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans('DateCreateCP').'</td>';
|
print '<td>'.$langs->trans('DateCreateCP').'</td>';
|
||||||
print '<td>'.$cp->date_create.'</td>';
|
print '<td>'.dol_print_date($cp->date_create,'dayhour').'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
if($cp->statut == 3) {
|
if($cp->statut == 3) {
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans('DateValidCP').'</td>';
|
print '<td>'.$langs->trans('DateValidCP').'</td>';
|
||||||
print '<td>'.$cp->date_valid.'</td>';
|
print '<td>'.dol_print_date($cp->date_valid,'dayhour').'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
if($cp->statut == 4) {
|
if($cp->statut == 4) {
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans('DateCancelCP').'</td>';
|
print '<td>'.$langs->trans('DateCancelCP').'</td>';
|
||||||
print '<td>'.$cp->date_cancel.'</td>';
|
print '<td>'.dol_print_date($cp->date_cancel,'dayhour').'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
if($cp->statut == 5) {
|
if($cp->statut == 5) {
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans('DateRefusCP').'</td>';
|
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 '</tr>';
|
||||||
}
|
}
|
||||||
print '</tbody>';
|
print '</tbody>';
|
||||||
|
|||||||
@ -292,7 +292,9 @@ if (! empty($holiday->holiday))
|
|||||||
print '<td>'.$validator->getNomUrl('1').'</td>';
|
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_debut'].'</td>';
|
||||||
print '<td style="text-align: center;">'.$infos_CP['date_fin'].'</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 '<td align="center"><a href="./fiche.php?id='.$infos_CP['rowid'].'">'.$statut.'</a></td>';
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,6 @@ if(!$user->rights->holiday->month_report) accessforbidden();
|
|||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
$htmlother = new FormOther($db);
|
$htmlother = new FormOther($db);
|
||||||
|
|
||||||
|
|
||||||
llxHeader(array(),$langs->trans('CPTitreMenu'));
|
llxHeader(array(),$langs->trans('CPTitreMenu'));
|
||||||
|
|
||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
@ -53,10 +52,10 @@ $month = GETPOST('month_start');
|
|||||||
$year = GETPOST('year_start');
|
$year = GETPOST('year_start');
|
||||||
|
|
||||||
if(empty($month)) {
|
if(empty($month)) {
|
||||||
$month = date('m');
|
$month = date('m');
|
||||||
}
|
}
|
||||||
if(empty($year)) {
|
if(empty($year)) {
|
||||||
$year = date('Y');
|
$year = date('Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT cp.fk_user, cp.date_debut, cp.date_fin";
|
$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.= " WHERE cp.rowid > '0'";
|
||||||
$sql.= " AND cp.statut = 3";
|
$sql.= " AND cp.statut = 3";
|
||||||
$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);
|
||||||
@ -78,7 +77,7 @@ 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.'"> ';
|
name="month_start" value="'.$month.'"> ';
|
||||||
$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" />';
|
||||||
@ -90,47 +89,50 @@ 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('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>'.$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="4" style="text-align: center; padding: 3px;">'.$langs->trans('NoCPforMonth').'</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){
|
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>'.$user->nom.' '.$user->prenom.'</td>';
|
print '<td>'.$user->nom.' '.$user->prenom.'</td>';
|
||||||
print '<td>'.$holiday['date_debut'].'</td>';
|
print '<td>'.$holiday['date_debut'].'</td>';
|
||||||
print '<td>'.$holiday['date_fin'].'</td>';
|
print '<td>'.$holiday['date_fin'].'</td>';
|
||||||
print '<td>'.$cp->getOpenDays(strtotime($holiday['date_debut']),strtotime($holiday['date_fin'])).'</td>';
|
print '<td>';
|
||||||
print '</tr>';
|
$nbopenedday=num_open_day($holiday['date_debut'],$holiday['date_fin'],0,1);
|
||||||
}
|
print $nbopenedday;
|
||||||
|
print '</td>';
|
||||||
}
|
print '</tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
// Fin de page
|
// Fin de page
|
||||||
$db->close();
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
|
$db->close();
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -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
|
CREATE TABLE llx_holiday
|
||||||
(
|
(
|
||||||
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
|||||||
@ -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
|
CREATE TABLE llx_holiday_users
|
||||||
(
|
(
|
||||||
fk_user integer NOT NULL PRIMARY KEY,
|
fk_user integer NOT NULL PRIMARY KEY,
|
||||||
|
|||||||
@ -84,7 +84,8 @@ NewSoldeCP=New Balance
|
|||||||
alreadyCPexist=A request for holidays has already been done on this period.
|
alreadyCPexist=A request for holidays has already been done on this period.
|
||||||
UserName=Name
|
UserName=Name
|
||||||
Employee=Employee
|
Employee=Employee
|
||||||
|
FirstDayOfHoliday=First day of holiday
|
||||||
|
LastDayOfHoliday=Last day of holiday
|
||||||
|
|
||||||
## Configuration du Module ##
|
## Configuration du Module ##
|
||||||
ConfCP=Configuration of holidays module
|
ConfCP=Configuration of holidays module
|
||||||
|
|||||||
@ -84,7 +84,8 @@ NewSoldeCP=Nouveau Solde
|
|||||||
alreadyCPexist=Une demande de congés à déjà été effectuée sur cette période.
|
alreadyCPexist=Une demande de congés à déjà été effectuée sur cette période.
|
||||||
UserName=Nom Prénom
|
UserName=Nom Prénom
|
||||||
Employee=Salarié
|
Employee=Salarié
|
||||||
|
FirstDayOfHoliday=Premier jour de congès
|
||||||
|
LastDayOfHoliday=Dernier jour de congès
|
||||||
|
|
||||||
## Configuration du Module ##
|
## Configuration du Module ##
|
||||||
ConfCP=Configuration du module Congés
|
ConfCP=Configuration du module Congés
|
||||||
|
|||||||
@ -113,6 +113,47 @@ class DateLibTest extends PHPUnit_Framework_TestCase
|
|||||||
print __METHOD__."\n";
|
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
|
* testConvertTime2Seconds
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user