diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 9251ead9041..229193d6da8 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2020 Alexandre Spangaro + * Copyright (C) 2011-2021 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud * Copyright (C) 2019-2020 Frédéric France @@ -232,7 +232,7 @@ $tabsql[33] = "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_h $tabsql[34] = "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; $tabsql[35] = "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c"; $tabsql[36] = "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r"; -$tabsql[37] = "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r"; +$tabsql[37] = "SELECT r.rowid, r.code, r.sortorder, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r"; $tabsql[38] = "SELECT rowid, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; $tabsql[39] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; $tabsql[40] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcommcontact"; @@ -278,7 +278,7 @@ $tabsqlsort[33] = "code ASC"; $tabsqlsort[34] = "code ASC"; $tabsqlsort[35] = "c.label ASC"; $tabsqlsort[36] = "r.fk_c_exp_tax_cat ASC, r.range_ik ASC"; -$tabsqlsort[37] = "r.unit_type ASC, r.scale ASC, r.code ASC"; +$tabsqlsort[37] = "sortorder ASC"; $tabsqlsort[38] = "rowid, code ASC"; $tabsqlsort[39] = "sortorder ASC"; $tabsqlsort[40] = "code ASC"; @@ -324,7 +324,7 @@ $tabfield[33] = "code,label"; $tabfield[34] = "code,label"; $tabfield[35] = "label"; $tabfield[36] = "range_ik,fk_c_exp_tax_cat"; -$tabfield[37] = "code,label,short_label,unit_type,scale"; +$tabfield[37] = "code,label,short_label,unit_type,scale,sortorder"; $tabfield[38] = "code,label,url,icon,entity"; $tabfield[39] = "code,libelle,sortorder"; $tabfield[40] = "code,libelle,picto"; @@ -370,7 +370,7 @@ $tabfieldvalue[33] = "code,label"; $tabfieldvalue[34] = "code,label"; $tabfieldvalue[35] = "label"; $tabfieldvalue[36] = "range_ik,fk_c_exp_tax_cat"; -$tabfieldvalue[37] = "code,label,short_label,unit_type,scale"; +$tabfieldvalue[37] = "code,label,short_label,unit_type,scale,sortorder"; $tabfieldvalue[38] = "code,label,url,icon"; $tabfieldvalue[39] = "code,libelle,sortorder"; $tabfieldvalue[40] = "code,libelle,picto"; @@ -417,7 +417,7 @@ $tabfieldinsert[33] = "code,label"; $tabfieldinsert[34] = "code,label"; $tabfieldinsert[35] = "label"; $tabfieldinsert[36] = "range_ik,fk_c_exp_tax_cat"; -$tabfieldinsert[37] = "code,label,short_label,unit_type,scale"; +$tabfieldinsert[37] = "code,label,short_label,unit_type,scale,sortorder"; $tabfieldinsert[38] = "code,label,url,icon,entity"; $tabfieldinsert[39] = "code,label,sortorder"; $tabfieldinsert[40] = "code,libelle,picto"; diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index f2a672ec1a7..7219f901c9f 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -240,6 +240,7 @@ class CUnits // extends CommonObject $sql = 'SELECT'; $sql .= " t.rowid,"; $sql .= " t.code,"; + $sql .= " t.sortorder,"; $sql .= " t.label,"; $sql .= " t.short_label,"; $sql .= " t.unit_type,"; @@ -280,8 +281,9 @@ class CUnits // extends CommonObject while ($obj = $this->db->fetch_object($resql)) { $record = new self($this->db); - $record->id = $obj->rowid; + $record->id = $obj->rowid; $record->code = $obj->code; + $record->sortorder = $obj->sortorder; $record->label = $obj->label; $record->short_label = $obj->short_label; $record->unit_type = $obj->unit_type; @@ -318,6 +320,9 @@ class CUnits // extends CommonObject if (isset($this->code)) { $this->code = trim($this->code); } + if (isset($this->sortorder)) { + $this->sortorder = trim($this->sortorder); + } if (isset($this->label)) { $this->libelle = trim($this->label); } @@ -340,6 +345,7 @@ class CUnits // extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; + $sql .= " sortorder=".(isset($this->sortorder) ? "'".$this->db->escape($this->sortorder)."'" : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " short_label=".(isset($this->short_label) ? "'".$this->db->escape($this->short_label)."'" : "null").","; $sql .= " unit_type=".(isset($this->unit_type) ? "'".$this->db->escape($this->unit_type)."'" : "null").","; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index aa940e1f03a..88151e7c288 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4353,6 +4353,7 @@ class Form if (!empty($unit_type)) { $sql .= " AND unit_type = '".$this->db->escape($unit_type)."'"; } + $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); if ($resql && $this->db->num_rows($resql) > 0) { diff --git a/htdocs/install/mysql/data/llx_c_units.sql b/htdocs/install/mysql/data/llx_c_units.sql index 3a11453c9f8..59692793fe2 100644 --- a/htdocs/install/mysql/data/llx_c_units.sql +++ b/htdocs/install/mysql/data/llx_c_units.sql @@ -1,7 +1,9 @@ -- ======================================================================== --- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville --- Copyright (C) 2004 Laurent Destailleur --- Copyright (C) 2019 Florian Henry +-- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville +-- Copyright (C) 2004 Laurent Destailleur +-- Copyright (C) 2019 Florian Henry +-- Copyright (C) 2021 Alexandre Spangaro +-- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or @@ -17,45 +19,45 @@ -- -- ======================================================================== -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('T', '3','WeightUnitton','T', 'weight', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('KG', '0','WeightUnitkg','kg', 'weight', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('G', '-3','WeightUnitg','g', 'weight', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MG','-6','WeightUnitmg','mg', 'weight', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('OZ','98','WeightUnitounce','Oz', 'weight', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('LB','99','WeightUnitpound','lb', 'weight', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('T', '100', '3','WeightUnitton','T', 'weight', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('KG','110', '0','WeightUnitkg','kg', 'weight', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('G', '120','-3','WeightUnitg','g', 'weight', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('MG','130','-6','WeightUnitmg','mg', 'weight', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('OZ','140','98','WeightUnitounce','Oz', 'weight', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('LB','150','99','WeightUnitpound','lb', 'weight', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('M', '0','SizeUnitm','m', 'size', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('DM','-1','SizeUnitdm','dm', 'size', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('CM','-2','SizeUnitcm','cm', 'size', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MM','-3','SizeUnitmm','mm', 'size', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('FT','98','SizeUnitfoot','ft', 'size', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('IN','99','SizeUnitinch','in', 'size', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('M', '200', '0','SizeUnitm','m', 'size', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('DM','210','-1','SizeUnitdm','dm', 'size', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('CM','220','-2','SizeUnitcm','cm', 'size', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('MM','230','-3','SizeUnitmm','mm', 'size', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('FT','240','98','SizeUnitfoot','ft', 'size', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('IN','250','99','SizeUnitinch','in', 'size', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('M2', '0','SurfaceUnitm2','m2', 'surface', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('DM2','-2','SurfaceUnitdm2','dm2', 'surface', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('CM2','-4','SurfaceUnitcm2','cm2', 'surface', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MM2','-6','SurfaceUnitmm2','mm2', 'surface', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('FT2','98','SurfaceUnitfoot2','ft2', 'surface', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('IN2','99','SurfaceUnitinch2','in2', 'surface', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('M2', '300', '0','SurfaceUnitm2','m2', 'surface', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('DM2','310','-2','SurfaceUnitdm2','dm2', 'surface', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('CM2','320','-4','SurfaceUnitcm2','cm2', 'surface', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('MM2','330','-6','SurfaceUnitmm2','mm2', 'surface', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('FT2','340','98','SurfaceUnitfoot2','ft2', 'surface', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('IN2','350','99','SurfaceUnitinch2','in2', 'surface', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('M3', '0','VolumeUnitm3','m3', 'volume', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('DM3','-3','VolumeUnitdm3','dm3', 'volume', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('CM3','-6','VolumeUnitcm3','cm3', 'volume', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MM3','-9','VolumeUnitmm3','mm3', 'volume', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('FT3','88','VolumeUnitfoot3','ft3', 'volume', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('IN3','89','VolumeUnitinch3','in3', 'volume', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('OZ3','97','VolumeUnitounce','Oz', 'volume', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('L', '98','VolumeUnitlitre','L', 'volume', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('M3', '400', '0','VolumeUnitm3','m3', 'volume', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('DM3','410','-3','VolumeUnitdm3','dm3', 'volume', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('CM3','420','-6','VolumeUnitcm3','cm3', 'volume', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('MM3','430','-9','VolumeUnitmm3','mm3', 'volume', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('FT3','440','88','VolumeUnitfoot3','ft3', 'volume', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('IN3','450','89','VolumeUnitinch3','in3', 'volume', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('OZ3','460','97','VolumeUnitounce','Oz', 'volume', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('L', '470','98','VolumeUnitlitre','L', 'volume', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('GAL','480','99','VolumeUnitgallon','gal', 'volume', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('P', '0','Piece','p', 'qty', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('SET', '0','Set','set', 'qty', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('P', '500', '0','Piece','p', 'qty', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('SET','510', '0','Set','set', 'qty', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('S', '0','second','s', 'time', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MI', '60','minute','i', 'time', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('H', '3600','hour','h', 'time', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('D', '86400','day','d', 'time', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('W', '604800','week','w', 'time', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MO','2629800','month','m', 'time', 1); -INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('Y','31557600','year','y', 'time', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('S', '600', '0','second','s', 'time', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('MI','610', '60','minute','i', 'time', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('H', '620', '3600','hour','h', 'time', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('D', '630', '86400','day','d', 'time', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('W', '640', '604800','week','w', 'time', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('MO','650', '2629800','month','m', 'time', 1); +INSERT INTO llx_c_units (code, sortorder, scale, label, short_label, unit_type, active) VALUES ('Y', '660','31557600','year','y', 'time', 1); diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 44f7d08bab1..34e8859596a 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -371,6 +371,8 @@ ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_user_creat FOR --END GRH/HRM MODULE +ALTER TABLE llx_c_units ADD COLUMN sortorder smallint AFTER code; + -- Manage accountancy auxiliary account for thirdparties per entity ALTER TABLE llx_societe_perentity ADD COLUMN accountancy_code_customer varchar(24) AFTER entity; -- equivalent to code_compta in llx_societe ALTER TABLE llx_societe_perentity ADD COLUMN accountancy_code_supplier varchar(24) AFTER accountancy_code_customer; -- equivalent to code_compta_supplier in llx_societe diff --git a/htdocs/install/mysql/tables/llx_c_units.sql b/htdocs/install/mysql/tables/llx_c_units.sql index d4ff78b79f1..ef77703ae6e 100644 --- a/htdocs/install/mysql/tables/llx_c_units.sql +++ b/htdocs/install/mysql/tables/llx_c_units.sql @@ -19,11 +19,12 @@ -- ======================================================================== create table llx_c_units( - rowid integer AUTO_INCREMENT PRIMARY KEY, - code varchar(3), - scale integer, - label varchar(50), - short_label varchar(5), - unit_type varchar(10), - active tinyint DEFAULT 1 NOT NULL + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(3), + sortorder smallint, + scale integer, + label varchar(50), + short_label varchar(5), + unit_type varchar(10), + active tinyint DEFAULT 1 NOT NULL ) ENGINE=innodb;