NEW Add sortorder on units list

This commit is contained in:
Alexandre SPANGARO 2021-10-11 08:58:00 +02:00
parent da815476fd
commit 754b13a83f
5 changed files with 24 additions and 14 deletions

View File

@ -8,7 +8,7 @@
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com> * Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
* Copyright (C) 2011-2020 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2011-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
@ -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[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[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[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[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[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"; $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[34] = "code ASC";
$tabsqlsort[35] = "c.label ASC"; $tabsqlsort[35] = "c.label ASC";
$tabsqlsort[36] = "r.fk_c_exp_tax_cat ASC, r.range_ik 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[38] = "rowid, code ASC";
$tabsqlsort[39] = "sortorder ASC"; $tabsqlsort[39] = "sortorder ASC";
$tabsqlsort[40] = "code ASC"; $tabsqlsort[40] = "code ASC";
@ -324,7 +324,7 @@ $tabfield[33] = "code,label";
$tabfield[34] = "code,label"; $tabfield[34] = "code,label";
$tabfield[35] = "label"; $tabfield[35] = "label";
$tabfield[36] = "range_ik,fk_c_exp_tax_cat"; $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[38] = "code,label,url,icon,entity";
$tabfield[39] = "code,libelle,sortorder"; $tabfield[39] = "code,libelle,sortorder";
$tabfield[40] = "code,libelle,picto"; $tabfield[40] = "code,libelle,picto";
@ -370,7 +370,7 @@ $tabfieldvalue[33] = "code,label";
$tabfieldvalue[34] = "code,label"; $tabfieldvalue[34] = "code,label";
$tabfieldvalue[35] = "label"; $tabfieldvalue[35] = "label";
$tabfieldvalue[36] = "range_ik,fk_c_exp_tax_cat"; $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[38] = "code,label,url,icon";
$tabfieldvalue[39] = "code,libelle,sortorder"; $tabfieldvalue[39] = "code,libelle,sortorder";
$tabfieldvalue[40] = "code,libelle,picto"; $tabfieldvalue[40] = "code,libelle,picto";
@ -417,7 +417,7 @@ $tabfieldinsert[33] = "code,label";
$tabfieldinsert[34] = "code,label"; $tabfieldinsert[34] = "code,label";
$tabfieldinsert[35] = "label"; $tabfieldinsert[35] = "label";
$tabfieldinsert[36] = "range_ik,fk_c_exp_tax_cat"; $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[38] = "code,label,url,icon,entity";
$tabfieldinsert[39] = "code,label,sortorder"; $tabfieldinsert[39] = "code,label,sortorder";
$tabfieldinsert[40] = "code,libelle,picto"; $tabfieldinsert[40] = "code,libelle,picto";

View File

@ -240,6 +240,7 @@ class CUnits // extends CommonObject
$sql = 'SELECT'; $sql = 'SELECT';
$sql .= " t.rowid,"; $sql .= " t.rowid,";
$sql .= " t.code,"; $sql .= " t.code,";
$sql .= " t.sortorder,";
$sql .= " t.label,"; $sql .= " t.label,";
$sql .= " t.short_label,"; $sql .= " t.short_label,";
$sql .= " t.unit_type,"; $sql .= " t.unit_type,";
@ -280,8 +281,9 @@ class CUnits // extends CommonObject
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$record = new self($this->db); $record = new self($this->db);
$record->id = $obj->rowid; $record->id = $obj->rowid;
$record->code = $obj->code; $record->code = $obj->code;
$record->sortorder = $obj->sortorder;
$record->label = $obj->label; $record->label = $obj->label;
$record->short_label = $obj->short_label; $record->short_label = $obj->short_label;
$record->unit_type = $obj->unit_type; $record->unit_type = $obj->unit_type;
@ -318,6 +320,9 @@ class CUnits // extends CommonObject
if (isset($this->code)) { if (isset($this->code)) {
$this->code = trim($this->code); $this->code = trim($this->code);
} }
if (isset($this->sortorder)) {
$this->sortorder = trim($this->sortorder);
}
if (isset($this->label)) { if (isset($this->label)) {
$this->libelle = trim($this->label); $this->libelle = trim($this->label);
} }
@ -340,6 +345,7 @@ class CUnits // extends CommonObject
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET";
$sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $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 .= " 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 .= " 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").","; $sql .= " unit_type=".(isset($this->unit_type) ? "'".$this->db->escape($this->unit_type)."'" : "null").",";

View File

@ -4353,6 +4353,7 @@ class Form
if (!empty($unit_type)) { if (!empty($unit_type)) {
$sql .= " AND unit_type = '".$this->db->escape($unit_type)."'"; $sql .= " AND unit_type = '".$this->db->escape($unit_type)."'";
} }
$sql .= " ORDER BY sortorder";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql && $this->db->num_rows($resql) > 0) { if ($resql && $this->db->num_rows($resql) > 0) {

View File

@ -370,3 +370,5 @@ ALTER TABLE llx_hrm_skillrank ADD INDEX idx_hrm_skillrank_fk_skill (fk_skill);
ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid);
--END GRH/HRM MODULE --END GRH/HRM MODULE
ALTER TABLE llx_c_units ADD COLUMN sortorder smallint AFTER code;

View File

@ -19,11 +19,12 @@
-- ======================================================================== -- ========================================================================
create table llx_c_units( create table llx_c_units(
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(3), code varchar(3),
scale integer, sortorder smallint,
label varchar(50), scale integer,
short_label varchar(5), label varchar(50),
unit_type varchar(10), short_label varchar(5),
active tinyint DEFAULT 1 NOT NULL unit_type varchar(10),
active tinyint DEFAULT 1 NOT NULL
) ENGINE=innodb; ) ENGINE=innodb;