From 1e0972f0a18635e262c34ee3747d370db65bad46 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 19 May 2022 12:34:05 +0200 Subject: [PATCH] NEW : sortorder on holiday type dictionnary --- htdocs/admin/dict.php | 9 +++++---- htdocs/holiday/class/holiday.class.php | 1 + htdocs/install/mysql/data/llx_c_holiday_type.sql | 10 +++++----- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_c_holiday_types.sql | 1 + 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 493203231b5..3287cadc774 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -225,7 +225,7 @@ $tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFI $tabsql[25] = "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity = ".getEntity($tabname[25]); //$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcomm"; -$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; +$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.sortorder, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; $tabsql[29] = "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; $tabsql[30] = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; //$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; @@ -319,7 +319,7 @@ $tabfield[24] = "code,label"; $tabfield[25] = "code,label"; //$tabfield[26]= "code,label,short_label"; $tabfield[27] = "code,libelle,picto"; -$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative"; +$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative,sortorder"; $tabfield[29] = "code,label,percent,position"; $tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfield[31]= "pcg_version,label"; @@ -366,7 +366,7 @@ $tabfieldvalue[24] = "code,label"; $tabfieldvalue[25] = "code,label"; //$tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27] = "code,libelle,picto"; -$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country,block_if_negative"; +$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country,block_if_negative,sortorder"; $tabfieldvalue[29] = "code,label,percent,position"; $tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldvalue[31]= "pcg_version,label"; @@ -413,7 +413,7 @@ $tabfieldinsert[24] = "code,label"; $tabfieldinsert[25] = "code,label"; //$tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27] = "code,libelle,picto"; -$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative"; +$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative,sortorder"; $tabfieldinsert[29] = "code,label,percent,position"; $tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldinsert[31]= "pcg_version,label"; @@ -709,6 +709,7 @@ if (empty($reshook)) { // Check that all mandatory fields are filled $ok = 1; foreach ($listfield as $f => $value) { + // Discard check of mandatory fields for country for some tables if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) { continue; // For some pages, country is not mandatory diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 1582317f27f..bef89f4462e 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2168,6 +2168,7 @@ class Holiday extends CommonObject if ($affect >= 0) { $sql .= " AND affect = ".((int) $affect); } + $sql .= " ORDER BY sortorder"; $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/install/mysql/data/llx_c_holiday_type.sql b/htdocs/install/mysql/data/llx_c_holiday_type.sql index 65f9a51b037..99ddc9e61e5 100644 --- a/htdocs/install/mysql/data/llx_c_holiday_type.sql +++ b/htdocs/install/mysql/data/llx_c_holiday_type.sql @@ -25,12 +25,12 @@ -- -- Generic to all countries -insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, active) values ('LEAVE_SICK', 'Sick leave', 0, 0, 0, NULL, 1); -insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, active) values ('LEAVE_OTHER', 'Other leave', 0, 0, 0, NULL, 1); +insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, sortorder, active) values ('LEAVE_SICK', 'Sick leave', 0, 0, 0, NULL, 1, 1); +insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, sortorder, active) values ('LEAVE_OTHER', 'Other leave', 0, 0, 0, NULL, 2, 1); -- Not enabled by default, we prefer to have an entrey dedicated to country -insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, active) values ('LEAVE_PAID', 'Paid vacation', 1, 7, 0, NULL, 0); +insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, sortorder, active) values ('LEAVE_PAID', 'Paid vacation', 1, 7, 0, NULL, 3, 0); -- Leaves specific to France -insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, active) values ('LEAVE_RTT_FR', 'RTT' , 1, 7, 0.83, 1, 1); -insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, active) values ('LEAVE_PAID_FR', 'Paid vacation', 1, 30, 2.08334, 1, 1); +insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, sortorder, active) values ('LEAVE_RTT_FR', 'RTT' , 1, 7, 0.83, 1, 4, 1); +insert into llx_c_holiday_types(code, label, affect, delay, newbymonth, fk_country, sortorder, active) values ('LEAVE_PAID_FR', 'Paid vacation', 1, 30, 2.08334, 1, 5, 1); diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 501aa0fe751..2a12c7c2722 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -361,4 +361,4 @@ ALTER TABLE llx_c_email_template ADD COLUMN email_to varchar(255); ALTER TABLE llx_c_email_template ADD COLUMN email_tocc varchar(255); ALTER TABLE llx_c_email_template ADD COLUMN email_tobcc varchar(255); - +ALTER TABLE llx_c_holiday_types ADD COLUMN sortorder smallint; diff --git a/htdocs/install/mysql/tables/llx_c_holiday_types.sql b/htdocs/install/mysql/tables/llx_c_holiday_types.sql index 63a6e522822..438c2deb400 100644 --- a/htdocs/install/mysql/tables/llx_c_holiday_types.sql +++ b/htdocs/install/mysql/tables/llx_c_holiday_types.sql @@ -25,5 +25,6 @@ CREATE TABLE llx_c_holiday_types ( newbymonth double(8,5) DEFAULT 0 NOT NULL, -- Amount of new days for each user each month fk_country integer DEFAULT NULL, -- This type is dedicated to a country block_if_negative integer NOT NULL DEFAULT 0, + sortorder smallint, active integer DEFAULT 1 ) ENGINE=innodb;