diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 2cae18c62be..5e4002b26a4 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -256,7 +256,7 @@ class modHoliday extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'holiday as d'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'holiday_extrafields as extra on d.rowid = extra.fk_object'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_holiday_types as t ON t.rowid = d.fk_type'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_holiday_types as t ON t.rowid = d.fk_type AND t.entity IN ('.getEntity('c_holiday_types').')'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua ON ua.rowid = d.fk_validator,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extrau ON u.rowid = extrau.fk_object'; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 9e523ccf8c0..8bf3c96ef74 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -755,7 +755,7 @@ class Holiday extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; - $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type); + $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type, true); if ($checkBalance > 0) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); @@ -878,7 +878,7 @@ class Holiday extends CommonObject { $error = 0; - $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type); + $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type, true); if ($checkBalance > 0) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); @@ -1006,7 +1006,7 @@ class Holiday extends CommonObject global $conf, $langs; $error = 0; - $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type); + $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type, true); if ($checkBalance > 0 && $this->status != self::STATUS_DRAFT) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); @@ -2277,6 +2277,7 @@ class Holiday extends CommonObject $sql = "SELECT rowid, code, label, affect, delay, newbymonth"; $sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types"; $sql .= " WHERE (fk_country IS NULL OR fk_country = ".((int) $mysoc->country_id).')'; + $sql .= " AND entity IN (".getEntity('c_holiday_types').")"; if ($active >= 0) { $sql .= " AND active = ".((int) $active); } diff --git a/htdocs/install/mysql/data/llx_c_holiday_type.sql b/htdocs/install/mysql/data/llx_c_holiday_types.sql similarity index 100% rename from htdocs/install/mysql/data/llx_c_holiday_type.sql rename to htdocs/install/mysql/data/llx_c_holiday_types.sql diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index 62e6e4399d7..78bde2c5283 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -407,6 +407,6 @@ UPDATE llx_c_units SET short_label = 'mn' WHERE short_label = 'i' AND code = 'MI -- missing entity field ALTER TABLE llx_c_holiday_types DROP INDEX uk_c_holiday_types; -ALTER TABLE llx_socpeople ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; +ALTER TABLE llx_c_holiday_types ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_c_holiday_types ADD UNIQUE INDEX uk_c_holiday_types (entity, code);