Fix nb of holidays can be float
This commit is contained in:
parent
d0173044ac
commit
f6274b8418
@ -1393,7 +1393,7 @@ class Holiday extends CommonObject
|
|||||||
* Met à jour le timestamp de la dernière mise à jour du solde des CP
|
* Met à jour le timestamp de la dernière mise à jour du solde des CP
|
||||||
*
|
*
|
||||||
* @param int $userID Id of user
|
* @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
|
* @param int $fk_type Type of vacation
|
||||||
* @return int 0=Nothing done, 1=OK, -1=KO
|
* @return int 0=Nothing done, 1=OK, -1=KO
|
||||||
*/
|
*/
|
||||||
@ -1477,7 +1477,7 @@ class Holiday extends CommonObject
|
|||||||
if ($num > 0) {
|
if ($num > 0) {
|
||||||
// Update for user
|
// Update for user
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET";
|
$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;
|
$sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type;
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -1487,7 +1487,7 @@ class Holiday extends CommonObject
|
|||||||
} else {
|
} else {
|
||||||
// Insert for user
|
// Insert for user
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users(nb_holiday, fk_user, fk_type) VALUES (";
|
$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.")";
|
$sql .= ", ".(int) $userID.", ".(int) $fk_type.")";
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -1955,8 +1955,8 @@ class Holiday extends CommonObject
|
|||||||
$sql .= " ".((int) $fk_user_action).",";
|
$sql .= " ".((int) $fk_user_action).",";
|
||||||
$sql .= " ".((int) $fk_user_update).",";
|
$sql .= " ".((int) $fk_user_update).",";
|
||||||
$sql .= " '".$this->db->escape($label)."',";
|
$sql .= " '".$this->db->escape($label)."',";
|
||||||
$sql .= " '".$this->db->escape($prev_solde)."',";
|
$sql .= " ".((float) $prev_solde).",";
|
||||||
$sql .= " '".$this->db->escape($new_solde)."',";
|
$sql .= " ".((float) $new_solde).",";
|
||||||
$sql .= " ".((int) $fk_type);
|
$sql .= " ".((int) $fk_type);
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
|
|
||||||
|
|||||||
@ -126,16 +126,16 @@ if (empty($reshook)) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Si il y a une action de mise à jour
|
// Si il y a une action de mise à jour
|
||||||
if ($action == 'update' && isset($_POST['update_cp'])) {
|
if ($action == 'update' && GETPOSTISSET('update_cp')) {
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$typeleaves = $holiday->getTypes(1, 1);
|
$typeleaves = $holiday->getTypes(1, 1);
|
||||||
|
|
||||||
$userID = array_keys($_POST['update_cp']);
|
$userID = array_keys(GETPOST('update_cp'));
|
||||||
$userID = $userID[0];
|
$userID = $userID[0];
|
||||||
|
|
||||||
foreach ($typeleaves as $key => $val) {
|
foreach ($typeleaves as $key => $val) {
|
||||||
$userValue = $_POST['nb_holiday_'.$val['rowid']];
|
$userValue = GETPOST('nb_holiday_'.$val['rowid']);
|
||||||
$userValue = $userValue[$userID];
|
$userValue = $userValue[$userID];
|
||||||
|
|
||||||
if (!empty($userValue) || (string) $userValue == '0') {
|
if (!empty($userValue) || (string) $userValue == '0') {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user