diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 0cac7664b6a..d0ce7f0b2d3 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -245,10 +245,10 @@ if ($_POST['action'] == 'addmilestone') { $milestone = new Milestone($db); - $milestone->label = $_POST['milestone_label']; + $milestone->label = $_POST['milestone_label']; $milestone->description = $_POST['milestone_desc']; $milestone->elementtype = $propal->element; - $milestone->fk_element = $propal->id; + $milestone->elementid = $propal->id; $ret = $milestone->create($user); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 890f6a20638..b30b65cb3fa 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -783,15 +783,8 @@ class CommonObject $rang = $row[0]; } - /* Lecture du rang max de la facture */ - $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; - $resql = $this->db->query($sql); - if ($resql) - { - $row = $this->db->fetch_row($resql); - $max = $row[0]; - } + // Get max value for rang + $max = $this->line_max(); if ($rang < $max) { @@ -813,6 +806,21 @@ class CommonObject } } } + + /** + * \brief Get max value for rang + */ + function line_max() + { + $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + return $row[0]; + } + } /** * \brief Update private note of element