From f6274b84189bfd677996faa8d05bf05cf5b0e02b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jun 2021 16:29:42 +0200 Subject: [PATCH] Fix nb of holidays can be float --- htdocs/holiday/class/holiday.class.php | 10 +++++----- htdocs/holiday/define_holiday.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 76ea8555d85..e1a9d9d905b 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1393,7 +1393,7 @@ class Holiday extends CommonObject * Met à jour le timestamp de la dernière mise à jour du solde des CP * * @param int $userID Id of user - * @param int $nbHoliday Nb of days + * @param float $nbHoliday Nb of days * @param int $fk_type Type of vacation * @return int 0=Nothing done, 1=OK, -1=KO */ @@ -1477,7 +1477,7 @@ class Holiday extends CommonObject if ($num > 0) { // Update for user $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; - $sql .= " nb_holiday = ".((int) $nbHoliday); + $sql .= " nb_holiday = ".((float) $nbHoliday); $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $result = $this->db->query($sql); if (!$result) { @@ -1487,7 +1487,7 @@ class Holiday extends CommonObject } else { // Insert for user $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users(nb_holiday, fk_user, fk_type) VALUES ("; - $sql .= ((int) $nbHoliday); + $sql .= ((float) $nbHoliday); $sql .= ", ".(int) $userID.", ".(int) $fk_type.")"; $result = $this->db->query($sql); if (!$result) { @@ -1955,8 +1955,8 @@ class Holiday extends CommonObject $sql .= " ".((int) $fk_user_action).","; $sql .= " ".((int) $fk_user_update).","; $sql .= " '".$this->db->escape($label)."',"; - $sql .= " '".$this->db->escape($prev_solde)."',"; - $sql .= " '".$this->db->escape($new_solde)."',"; + $sql .= " ".((float) $prev_solde).","; + $sql .= " ".((float) $new_solde).","; $sql .= " ".((int) $fk_type); $sql .= ")"; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index b3d2c25adda..5daedf98ff5 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -126,16 +126,16 @@ if (empty($reshook)) { */ // Si il y a une action de mise à jour - if ($action == 'update' && isset($_POST['update_cp'])) { + if ($action == 'update' && GETPOSTISSET('update_cp')) { $error = 0; $typeleaves = $holiday->getTypes(1, 1); - $userID = array_keys($_POST['update_cp']); + $userID = array_keys(GETPOST('update_cp')); $userID = $userID[0]; foreach ($typeleaves as $key => $val) { - $userValue = $_POST['nb_holiday_'.$val['rowid']]; + $userValue = GETPOST('nb_holiday_'.$val['rowid']); $userValue = $userValue[$userID]; if (!empty($userValue) || (string) $userValue == '0') {