mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: Debug holiday module
This commit is contained in:
parent
005716af99
commit
ddb3cf6f42
|
|
@ -759,25 +759,30 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
|
|||
}
|
||||
|
||||
/**
|
||||
* Fonction retournant le nombre de jour entre deux dates sans les jours feries (jours ouvres)
|
||||
* Function to return number of working days (and text of units) between two dates (jours ouvres)
|
||||
*
|
||||
* @param timestamp $timestampStart Timestamp de debut
|
||||
* @param timestamp $timestampEnd Timestamp de fin
|
||||
* @param int $inhour 0: sort le nombre de jour , 1: sort le nombre d'heure (72 max)
|
||||
* @param int $lastday We include last day, 0: non, 1:oui
|
||||
* @return int Nombre de jours ou d'heures
|
||||
* @param timestamp $timestampStart Timestamp for start 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 $lastday We include last day, 0: no, 1:yes
|
||||
* @return int Number of days or hours
|
||||
*/
|
||||
function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday);
|
||||
|
||||
// Check parameters
|
||||
if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day';
|
||||
if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day';
|
||||
|
||||
//print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday;
|
||||
if ($timestampStart < $timestampEnd)
|
||||
{
|
||||
//print num_between_day($timestampStart, $timestampEnd, $lastday).' - '.num_public_holiday($timestampStart, $timestampEnd);
|
||||
$nbOpenDay = num_between_day($timestampStart, $timestampEnd, $lastday) - num_public_holiday($timestampStart, $timestampEnd, $lastday);
|
||||
$nbOpenDay.= " ".$langs->trans("Days");
|
||||
$nbOpenDay.= " " . $langs->trans("Days");
|
||||
if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
|
||||
return $nbOpenDay;
|
||||
}
|
||||
|
|
@ -785,7 +790,7 @@ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
|
|||
{
|
||||
$nbOpenDay=$lastday;
|
||||
if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
|
||||
return $nbOpenDay=1;
|
||||
return $nbOpenDay;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -380,13 +380,13 @@ class Holiday extends CommonObject
|
|||
|
||||
$tab_result[$i]['rowid'] = $obj->rowid;
|
||||
$tab_result[$i]['fk_user'] = $obj->fk_user;
|
||||
$tab_result[$i]['date_create'] = $obj->date_create;
|
||||
$tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create);
|
||||
$tab_result[$i]['description'] = $obj->description;
|
||||
$tab_result[$i]['date_debut'] = $obj->date_debut;
|
||||
$tab_result[$i]['date_fin'] = $obj->date_fin;
|
||||
$tab_result[$i]['date_debut'] = $this->db->jdate($obj->date_debut);
|
||||
$tab_result[$i]['date_fin'] = $this->db->jdate($obj->date_fin);
|
||||
$tab_result[$i]['statut'] = $obj->statut;
|
||||
$tab_result[$i]['fk_validator'] = $obj->fk_validator;
|
||||
$tab_result[$i]['date_valid'] = $obj->date_valid;
|
||||
$tab_result[$i]['date_valid'] = $this->db->jdate($obj->date_valid);
|
||||
$tab_result[$i]['fk_user_valid'] = $obj->fk_user_valid;
|
||||
$tab_result[$i]['date_refuse'] = $obj->date_refuse;
|
||||
$tab_result[$i]['fk_user_refuse'] = $obj->fk_user_refuse;
|
||||
|
|
|
|||
|
|
@ -563,13 +563,12 @@ if ($action == 'confirm_cancel' && $_GET['confirm'] == 'yes')
|
|||
|
||||
|
||||
|
||||
/***************************************************
|
||||
/*
|
||||
* View
|
||||
****************************************************/
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
|
||||
llxHeader(array(),$langs->trans('CPTitreMenu'));
|
||||
|
||||
if (empty($id) || $action == 'add' || $action == 'request')
|
||||
|
|
@ -753,35 +752,36 @@ else
|
|||
//print_fiche_titre($langs->trans('TitreRequestCP'));
|
||||
|
||||
// Si il y a une erreur
|
||||
if (GETPOST('error')) {
|
||||
|
||||
switch(GETPOST('error')) {
|
||||
if (GETPOST('error'))
|
||||
{
|
||||
switch(GETPOST('error'))
|
||||
{
|
||||
case 'datefin' :
|
||||
$errors[] = $langs->trans('ErrorEndDateCP');
|
||||
$errors[] = $langs->transnoentitiesnoconv('ErrorEndDateCP');
|
||||
break;
|
||||
case 'SQL_Create' :
|
||||
$errors[] = $langs->trans('ErrorSQLCreateCP').' <b>'.htmlentities($_GET['msg']).'</b>';
|
||||
$errors[] = $langs->transnoentitiesnoconv('ErrorSQLCreateCP').' '.$_GET['msg'];
|
||||
break;
|
||||
case 'CantCreate' :
|
||||
$errors[] = $langs->trans('CantCreateCP');
|
||||
$errors[] = $langs->transnoentitiesnoconv('CantCreateCP');
|
||||
break;
|
||||
case 'Valideur' :
|
||||
$errors[] = $langs->trans('InvalidValidatorCP');
|
||||
$errors[] = $langs->transnoentitiesnoconv('InvalidValidatorCP');
|
||||
break;
|
||||
case 'nodatedebut' :
|
||||
$errors[] = $langs->trans('NoDateDebut');
|
||||
$errors[] = $langs->transnoentitiesnoconv('NoDateDebut');
|
||||
break;
|
||||
case 'nodatedebut' :
|
||||
$errors[] = $langs->trans('NoDateFin');
|
||||
$errors[] = $langs->transnoentitiesnoconv('NoDateFin');
|
||||
break;
|
||||
case 'DureeHoliday' :
|
||||
$errors[] = $langs->trans('ErrorDureeCP');
|
||||
$errors[] = $langs->transnoentitiesnoconv('ErrorDureeCP');
|
||||
break;
|
||||
case 'NoMotifRefuse' :
|
||||
$errors[] = $langs->trans('NoMotifRefuseCP');
|
||||
$errors[] = $langs->transnoentitiesnoconv('NoMotifRefuseCP');
|
||||
break;
|
||||
case 'mail' :
|
||||
$errors[] = $langs->trans('ErrorMailNotSend').'<br /><b>'.$_GET['error_content'].'</b>';
|
||||
$errors[] = $langs->transnoentitiesnoconv('ErrorMailNotSend')."\n".$_GET['error_content'];
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -795,7 +795,7 @@ else
|
|||
if ($action == 'delete' && $cp->statut == 1) {
|
||||
if($user->rights->holiday->delete)
|
||||
{
|
||||
$ret=$form->form_confirm("fiche.php?id=".$_GET['id'],$langs->trans("TitleDeleteCP"),$langs->trans("ConfirmDeleteCP"),"confirm_delete", '', 0, 1);
|
||||
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleDeleteCP"),$langs->trans("ConfirmDeleteCP"),"confirm_delete", '', 0, 1);
|
||||
if ($ret == 'html') print '<br />';
|
||||
}
|
||||
}
|
||||
|
|
@ -803,14 +803,14 @@ else
|
|||
// Si envoi en validation
|
||||
if ($action == 'sendToValidate' && $cp->statut == 1 && $userID == $cp->fk_user)
|
||||
{
|
||||
$ret=$form->form_confirm("fiche.php?id=".$_GET['id'],$langs->trans("TitleToValidCP"),$langs->trans("ConfirmToValidCP"),"confirm_send", '', 0, 1);
|
||||
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleToValidCP"),$langs->trans("ConfirmToValidCP"),"confirm_send", '', 1, 1);
|
||||
if ($ret == 'html') print '<br />';
|
||||
}
|
||||
|
||||
// Si validation de la demande
|
||||
if ($action == 'valid' && $cp->statut == 2 && $userID == $cp->fk_validator)
|
||||
{
|
||||
$ret=$form->form_confirm("fiche.php?id=".$_GET['id'],$langs->trans("TitleValidCP"),$langs->trans("ConfirmValidCP"),"confirm_valid", '', 0, 1);
|
||||
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleValidCP"),$langs->trans("ConfirmValidCP"),"confirm_valid", '', 1, 1);
|
||||
if ($ret == 'html') print '<br />';
|
||||
}
|
||||
|
||||
|
|
@ -818,19 +818,28 @@ else
|
|||
if ($action == 'refuse' && $cp->statut == 2 && $userID == $cp->fk_validator)
|
||||
{
|
||||
$array_input = array(array('type'=>"text",'label'=>"Entrez ci-dessous un motif de refus :",'name'=>"detail_refuse",'size'=>"50",'value'=>""));
|
||||
$ret=$form->form_confirm("fiche.php?id=".$_GET['id']."&action=confirm_refuse",$langs->trans("TitleRefuseCP"),"","confirm_refuse",$array_input,"",0);
|
||||
$ret=$form->form_confirm("fiche.php?id=".$id."&action=confirm_refuse",$langs->trans("TitleRefuseCP"),"","confirm_refuse", $array_input, 1 ,0);
|
||||
if ($ret == 'html') print '<br />';
|
||||
}
|
||||
|
||||
// Si annulation de la demande
|
||||
if ($action == 'cancel' && $cp->statut == 2 && $userID == $cp->fk_validator)
|
||||
{
|
||||
$ret=$form->form_confirm("fiche.php?id=".$_GET['id'],$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 0, 1);
|
||||
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1);
|
||||
if ($ret == 'html') print '<br />';
|
||||
}
|
||||
|
||||
|
||||
dol_fiche_head(array(),'card',$langs->trans("CPTitreMenu"),0,'holiday');
|
||||
$h=0;
|
||||
$head = array();
|
||||
$head[$h][0] = DOL_URL_ROOT . '/holiday/fiche.php?id='.$id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$cp,$head,$h,'holiday');
|
||||
|
||||
dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday');
|
||||
|
||||
|
||||
if ($action == 'edit' && $user->id == $cp->fk_user && $cp->statut == 1)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ $search_employe = GETPOST('search_employe');
|
|||
$search_valideur = GETPOST('search_valideur');
|
||||
$search_statut = GETPOST('select_statut');
|
||||
|
||||
$holiday = new Holiday($db);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -147,12 +148,10 @@ $user_id = $user->id;
|
|||
// Récupération des congés payés de l'utilisateur ou de tous les users
|
||||
if(!$user->rights->holiday->lire_tous)
|
||||
{
|
||||
$holiday = new Holiday($db);
|
||||
$holiday_payes = $holiday->fetchByUser($user_id,$order,$filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
$holiday = new Holiday($db);
|
||||
$holiday_payes = $holiday->fetchAll($order,$filter);
|
||||
}
|
||||
|
||||
|
|
@ -282,21 +281,20 @@ if (! empty($holiday->holiday))
|
|||
$validator = new User($db);
|
||||
$validator->fetch($infos_CP['fk_validator']);
|
||||
|
||||
$date = date_create($infos_CP['date_create']);
|
||||
$date = date_format($date,'Y-m-d');
|
||||
$date = $infos_CP['date_create'];
|
||||
|
||||
$statut = $holiday->getStatutCP($infos_CP['statut']);
|
||||
|
||||
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;">'.$date.'</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;">'.$infos_CP['date_debut'].'</td>';
|
||||
print '<td style="text-align: center;">'.$infos_CP['date_fin'].'</td>';
|
||||
print '<td>';
|
||||
$nbopenedday=num_open_day($infos_CP['date_debut'],$infos_CP['date_fin'],0,1);
|
||||
print $nbopenedday.' '.$langs->trans('Jours');
|
||||
print $nbopenedday;
|
||||
print '<td align="center"><a href="./fiche.php?id='.$infos_CP['rowid'].'">'.$statut.'</a></td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ foreach($cp->logs as $logs_CP)
|
|||
if($log_holiday == '2')
|
||||
{
|
||||
print '<tr>';
|
||||
print '<td colspan="7" class="pair" style="text-align: center; padding: 5px;">'.$langs->trans('NoResult').'</td>';
|
||||
print '<td colspan="7" class="pair" style="text-align: center; padding: 5px;">'.$langs->trans('NoResults').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ AddThisArticle=Add this article
|
|||
RestartSelling=Go back on sell
|
||||
SellFinished=Sell finished
|
||||
PrintTicket=Print ticket
|
||||
NoResults=No results
|
||||
NoProductFound=No article found
|
||||
ProductFound=product found
|
||||
ProductsFound=products found
|
||||
|
|
|
|||
|
|
@ -627,6 +627,7 @@ BySalesRepresentative=By sales representative
|
|||
LinkedToSpecificUsers=Linked to a particular user contact
|
||||
DeleteAFile=Delete a file
|
||||
ConfirmDeleteAFile=Are you sure you want to delete file
|
||||
NoResults=No results
|
||||
|
||||
# Week day
|
||||
Monday=Monday
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ AddThisArticle=Ajouter cet article
|
|||
RestartSelling=Reprendre la vente
|
||||
SellFinished=Vente terminée
|
||||
PrintTicket=Imprimer ticket
|
||||
NoResults=Aucun résultat
|
||||
NoProductFound=Aucun article trouvé
|
||||
ProductFound=produit trouvé
|
||||
ProductsFound=produits trouvés
|
||||
|
|
|
|||
|
|
@ -629,6 +629,7 @@ BySalesRepresentative=Par commerciaux
|
|||
LinkedToSpecificUsers=Liés à un contact utilisateur particulier
|
||||
DeleteAFile=Suppression de fichier
|
||||
ConfirmDeleteAFile=Confirmez-vous la suppression du fichier
|
||||
NoResults=Aucun résultat
|
||||
|
||||
# Week day
|
||||
Monday=Lundi
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user