Fix nb of holidays can be float

This commit is contained in:
Laurent Destailleur 2021-06-15 16:29:42 +02:00
parent d0173044ac
commit f6274b8418
2 changed files with 8 additions and 8 deletions

View File

@ -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 .= ")";

View File

@ -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') {