diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 87396dccb30..3f1be6c7e4c 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -155,6 +155,8 @@ if (empty($reshook)) if (!$error) { + $lastposition = 0; + $bomline = new BOMLine($db); $bomline->fk_bom = $id; $bomline->fk_product = $idprod; @@ -163,6 +165,12 @@ if (empty($reshook)) $bomline->disable_stock_change = (int) $disable_stock_change; $bomline->efficiency = $efficiency; + // Rang to use + $rangmax = $object->line_max(0); + $ranktouse = $rangmax + 1; + + $bomline->position = ($ranktouse + 1); + $result = $bomline->create($user); if ($result <= 0) { diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c4c0aed1756..e0a1fd35092 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -508,7 +508,7 @@ class CMailFile $res = false; - if (empty($conf->global->MAIN_DISABLE_ALL_MAILS) || !empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 76dd30f40fe..39bdc678fc4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2744,10 +2744,13 @@ abstract class CommonObject public function line_max($fk_parent_line = 0) { // phpcs:enable + $positionfield = 'rang'; + if ($this->table_element == 'bom') $positionfield = 'position'; + // Search the last rang with fk_parent_line if ($fk_parent_line) { - $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; $sql .= ' AND fk_parent_line = '.$fk_parent_line; @@ -2769,7 +2772,7 @@ abstract class CommonObject // If not, search the last rang of element else { - $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; dol_syslog(get_class($this)."::line_max", LOG_DEBUG); diff --git a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php index dd20e957d5b..96ab2f4cbb6 100644 --- a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php +++ b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php @@ -6880,7 +6880,7 @@ class TCPDF { if (!@TCPDF_STATIC::file_exists($file)) { // DOL CHANGE If we keep this, the image is not visible on pages after the first one. //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file))); - //return false; + //return false; } if (($imsize = @getimagesize($file)) === FALSE) { if (in_array($file, $this->imagekeys)) {