FIX compatibility mysql 8. rank is reserved

FIX Permission for BOM menu
This commit is contained in:
Laurent Destailleur 2019-07-09 00:14:01 +02:00
parent 69db6e6aa7
commit e5d34de877
6 changed files with 11 additions and 10 deletions

View File

@ -889,7 +889,7 @@ class BOM extends CommonObject
$this->lines=array(); $this->lines=array();
$objectline = new BOMLine($this->db); $objectline = new BOMLine($this->db);
$result = $objectline->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_bom = '.$this->id)); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_bom = '.$this->id));
if (is_numeric($result)) if (is_numeric($result))
{ {
@ -1044,7 +1044,7 @@ class BOMLine extends CommonObject
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',), 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',),
'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), 'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'),
'rank' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'position'=>200, 'notnull'=>1,), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'position'=>200, 'notnull'=>1,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
); );
public $rowid; public $rowid;
@ -1053,7 +1053,7 @@ class BOMLine extends CommonObject
public $description; public $description;
public $qty; public $qty;
public $efficiency; public $efficiency;
public $rank; public $position;
public $import_key; public $import_key;
// END MODULEBUILDER PROPERTIES // END MODULEBUILDER PROPERTIES

View File

@ -2443,9 +2443,9 @@ abstract class CommonObject
*/ */
public function updateRangOfLine($rowid, $rang) public function updateRangOfLine($rowid, $rang)
{ {
$fieldposition = 'rang'; // @TODO Rename 'rang' and 'position' into 'rank' $fieldposition = 'rang'; // @TODO Rename 'rang' into 'position'
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
if (in_array($this->table_element_line, array('bom_bomline'))) $fieldposition = 'rank'; if (in_array($this->table_element_line, array('bom_bomline'))) $fieldposition = 'position';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang;
$sql.= ' WHERE rowid = '.$rowid; $sql.= ' WHERE rowid = '.$rowid;

View File

@ -1579,7 +1579,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
{ {
$langs->load("mrp"); $langs->load("mrp");
$newmenu->add("", $langs->trans("MenuBOM"), 0, $user->rights->service->lire, '', $mainmenu, 'service'); $newmenu->add("", $langs->trans("MenuBOM"), 0, $user->rights->bom->read, '', $mainmenu, 'bom');
$newmenu->add("/bom/bom_card.php?leftmenu=bom&action=create", $langs->trans("NewBOM"), 1, $user->rights->bom->write); $newmenu->add("/bom/bom_card.php?leftmenu=bom&action=create", $langs->trans("NewBOM"), 1, $user->rights->bom->write);
$newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read); $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read);
} }

View File

@ -252,12 +252,13 @@ CREATE TABLE llx_bom_bomline(
import_key varchar(14), import_key varchar(14),
qty double(24,8) NOT NULL, qty double(24,8) NOT NULL,
efficiency double(8,4) NOT NULL DEFAULT 1, efficiency double(8,4) NOT NULL DEFAULT 1,
rank integer NOT NULL position integer NOT NULL
-- END MODULEBUILDER FIELDS -- END MODULEBUILDER FIELDS
) ENGINE=innodb; ) ENGINE=innodb;
ALTER TABLE llx_bom_bomline ADD COLUMN efficiency double(8,4) DEFAULT 1; ALTER TABLE llx_bom_bomline ADD COLUMN efficiency double(8,4) DEFAULT 1;
ALTER TABLE llx_bom_bomline ADD COLUMN fk_bom_child integer NULL; ALTER TABLE llx_bom_bomline ADD COLUMN fk_bom_child integer NULL;
ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL;
create table llx_bom_bomline_extrafields create table llx_bom_bomline_extrafields
( (

View File

@ -23,6 +23,6 @@ CREATE TABLE llx_bom_bomline(
import_key varchar(14), import_key varchar(14),
qty double(24,8) NOT NULL, qty double(24,8) NOT NULL,
efficiency double(8,4) NOT NULL DEFAULT 1, efficiency double(8,4) NOT NULL DEFAULT 1,
rank integer NOT NULL position integer NOT NULL
-- END MODULEBUILDER FIELDS -- END MODULEBUILDER FIELDS
) ENGINE=innodb; ) ENGINE=innodb;

View File

@ -696,7 +696,7 @@ class MyObject extends CommonObject
$this->lines=array(); $this->lines=array();
$objectline = new MyObjectLine($this->db); $objectline = new MyObjectLine($this->db);
$result = $objectline->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id));
if (is_numeric($result)) if (is_numeric($result))
{ {
@ -781,5 +781,5 @@ class MyObject extends CommonObject
class MyObjectLine class MyObjectLine
{ {
// To complete with content of an object MyObjectLine // To complete with content of an object MyObjectLine
// We should have a field rowid, fk_myobject and rank // We should have a field rowid, fk_myobject and position
} }