From d6e907b69bf72bddae93ac5de264430f7649be5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Feb 2013 19:25:55 +0100 Subject: [PATCH 1/3] Fix: Nb of holidays was not using correct user --- htdocs/holiday/index.php | 99 +++++++++++++++++++++++---------- htdocs/langs/en_US/holiday.lang | 2 +- htdocs/langs/fr_FR/holiday.lang | 2 +- 3 files changed, 71 insertions(+), 32 deletions(-) diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php index 4dbb299a825..a3ebf0f1c1c 100644 --- a/htdocs/holiday/index.php +++ b/htdocs/holiday/index.php @@ -30,6 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; + +$langs->load('users'); +$langs->load('holidays'); // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -46,6 +51,8 @@ $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; +$id = GETPOST('id'); + $search_ref = GETPOST('search_ref'); $month_create = GETPOST('month_create'); $year_create = GETPOST('year_create'); @@ -72,6 +79,7 @@ $search_statut = GETPOST('select_statut'); $holiday = new Holiday($db); $holidaystatic=new Holiday($db); +$fuser = new User($db); // Update sold $holiday->updateSold(); @@ -151,28 +159,22 @@ if(!empty($search_statut) && $search_statut != -1) { // Récupération de l'ID de l'utilisateur $user_id = $user->id; +if ($id > 0) +{ + // Charge utilisateur edite + $fuser->fetch($id); + $fuser->getrights(); + $user_id = $fuser->id; +} // Récupération des congés payés de l'utilisateur ou de tous les users -if (!$user->rights->holiday->lire_tous) +if (!$user->rights->holiday->lire_tous || $id > 0) { - $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); + $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); } else { $holiday_payes = $holiday->fetchAll($order,$filter); } - -// Si pas de congés payés -if ($holiday_payes == 0) -{ - print_fiche_titre($langs->trans('CPTitreMenu')); - - print '
'; - print ''.$langs->trans('NoCPforUser').'

'; - print ''.$langs->trans('AddCP').'
'; - print '
'; - exit(); -} - // Si erreur SQL if ($holiday_payes == '-1') { @@ -189,14 +191,48 @@ if ($holiday_payes == '-1') * Affichage du tableau des congés payés *************************************/ -$var=true; $num = count($holiday->holiday); -$html = new Form($db); -$htmlother = new FormOther($db); -print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num); +$var=true; $num = count($holiday->holiday); +$form = new Form($db); +$formother = new FormOther($db); -print '
'; +if ($id > 0) +{ + $head = user_prepare_head($fuser); + + $title = $langs->trans("User"); + dol_fiche_head($head, 'paidholidays', $title, 0, 'user'); -$nbaquis=$holiday->getCPforUser($user->id); + print ''; + + // Ref + print ''; + print ''; + print ''; + + // Nom + print ''; + print ''; + print "\n"; + + // Prenom + print ''; + print ''; + print "\n"; + + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin); + print '
'.$langs->trans("LastName").''.$fuser->lastname.'
'.$langs->trans("FirstName").''.$fuser->firstname.'

'; + +} +else +{ + print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num); + + print '
'; +} + + +$nbaquis=$holiday->getCPforUser($user_id); $nbdeduced=$holiday->getConfCP('nbHolidayDeducted'); $nb_holiday = $nbaquis / $nbdeduced; print $langs->trans('SoldeCPUser',round($nb_holiday,2)).($nbdeduced != 1 ? ' ('.$nbaquis.' / '.$nbdeduced.')' : ''); @@ -223,13 +259,13 @@ print ''; print ''; -$htmlother->select_year($year_create,'year_create',1, $min_year, $max_year); +$formother->select_year($year_create,'year_create',1, $min_year, $max_year); print ''; // UTILISATEUR if($user->rights->holiday->lire_tous) { print ''; - $html->select_users($search_employe,"search_employe",1,"",0,''); + $form->select_users($search_employe,"search_employe",1,"",0,''); print ''; } else { print ' '; @@ -246,7 +282,7 @@ if($user->rights->holiday->lire_tous){ $validator = new UserGroup($db,$idGroupValid); $valideur = $validator->listUsersForGroup(); - $html->select_users($search_valideur,"search_valideur",1,"",0,$valideur,''); + $form->select_users($search_valideur,"search_valideur",1,"",0,$valideur,''); print ''; } else { print ' '; @@ -255,13 +291,13 @@ if($user->rights->holiday->lire_tous){ // DATE DEBUT print ''; print ''; -$htmlother->select_year($year_start,'year_start',1, $min_year, $max_year); +$formother->select_year($year_start,'year_start',1, $min_year, $max_year); print ''; // DATE FIN print ''; print ''; -$htmlother->select_year($year_end,'year_end',1, $min_year, $max_year); +$formother->select_year($year_end,'year_end',1, $min_year, $max_year); print ''; // DUREE @@ -327,10 +363,13 @@ if($holiday_payes == '2') print ''; print ''; -print '
'; -print '
'; -print ''.$langs->trans('AddCP').''; -print '
'; +if ($user_id == $user->id) +{ + print '
'; + print '
'; + print ''.$langs->trans('AddCP').''; + print '
'; +} llxFooter(); diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 2b83b1fcb1d..abf2b1dc514 100755 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -26,7 +26,7 @@ SendRequestCP=Creating demand for holidays DelayToRequestCP=Applications for holidays must be made at least %s day(s) before them. MenuConfCP=Edit balance of holidays UpdateAllCP=Update the holidays -SoldeCPUser=Your balance of holidays is %s days. +SoldeCPUser=Holidays balance is %s days. ErrorEndDateCP=You must select an end date greater than the start date. ErrorSQLCreateCP=An SQL error occurred during the creation: ErrorIDFicheCP=An error has occurred, the request for holidays does not exist. diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index 60c7594fe90..ed8d339af75 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -26,7 +26,7 @@ SendRequestCP=Envoyer la demande de congés DelayToRequestCP=Les demandes de congés doivent être faites au moins %s jours avant la date de ceux-ci. MenuConfCP=Mettre à jour solde UpdateAllCP=Mettre à jour les congés -SoldeCPUser=Votre solde de congés est de %s jours. +SoldeCPUser=Solde de congés: %s jours. ErrorEndDateCP=Vous devez choisir une date de fin supérieur à la date de début. ErrorSQLCreateCP=Une erreur SQL est survenue durant la création : ErrorIDFicheCP=Une erreur est survenue, cette demande de congés n'existe pas. From f82bec552b344627f0ca1d9211ae5fee414de34c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Feb 2013 12:57:14 +0100 Subject: [PATCH 2/3] Fix: Check id field are mandatory --- htdocs/societe/soc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 063d33a27f3..135bd6f2295 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -224,19 +224,20 @@ if (empty($reshook)) { $langs->load("errors"); $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel); - $action = ($action=='add'?'create':'edit'); + $action = (($action=='add'||$action=='create')?'create':'edit'); } } $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; + if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); - $action = ($action=='add'?'create':'edit'); + $action = (($action=='add'||$action=='create')?'create':'edit'); } - } + } } if (! $error) @@ -714,8 +715,7 @@ else print "
\n"; } - - dol_htmloutput_errors($error,$errors); + dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); print '
'; From b5260e4ab1b086a179cccd0182127249258480ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Feb 2013 14:13:02 +0100 Subject: [PATCH 3/3] Fix: Translation --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 2 +- htdocs/langs/fr_FR/holiday.lang | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9586ce352a8..7bcb30a2d62 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -967,7 +967,7 @@ NotificationsDesc=EMails notifications feature allows you to silently send autom ModelModules=Documents templates DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT files for OpenOffice, KOffice, TextEdit,...) WatermarkOnDraft=Watermark on draft document -CompanyIdProfChecker=Professional Id unique +CompanyIdProfChecker=Rules ono Professional Ids MustBeUnique=Must be unique ? MustBeMandatory=Must be mandatory ? Miscellanous=Miscellaneous diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index adb0a063d5d..ffa72893e4a 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -962,7 +962,7 @@ NotificationsDesc= La fonction des notifications par emails permet d'envoyer aut ModelModules=Modèle de documents DocumentModelOdt=Genération depuis des modèles OpenDocument (Fichier .ODT OpenOffice, KOffice, TextEdit...) WatermarkOnDraft=Filigrane sur les documents brouillons -CompanyIdProfChecker=Id professionel unique +CompanyIdProfChecker=Règles sur les Ids professionels MustBeUnique=Doit être unique ? MustBeMandatory=Doit être obligatoire? Miscellanous=Divers diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index ed8d339af75..ad8ebd7fcf1 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -91,7 +91,7 @@ LastDayOfHoliday=Dernier jour de congès ConfCP=Configuration du module Congés DescOptionCP=Description de l'option ValueOptionCP=Valeur -GroupToValidateCP=Groupe ayant la possibilité de valider les congés +GroupToValidateCP=Groupe ayant la possibilité d'approuver les congés ConfirmConfigCP=Valider la configuration LastUpdateCP=Dernière mise à jour automatique des congés UpdateConfCPOK=Mise à jour effectuée avec succès.