diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 1abc33f9bce..ce9a284200b 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -553,10 +553,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$res = $object->fetchLinesbytypeproduct(0);
$object->calculateCosts();
- if ($res > 0) {
- print load_fiche_titre($langs->trans('BOMProductsList'), '', 'product');
+ print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMProductsList'), '', 'product');
- print '
\n";
-
- mrpCollapseBomManagement();
+ if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
+ include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}
+ print '';
+ if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
+ print '
';
+ }
+
+ if (!empty($object->lines)) {
+ $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl');
+ }
+
+ // Form to add new line
+ if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
+ if ($action != 'editline') {
+ // Add products form
+
+
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ if (empty($reshook))
+ $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl');
+ }
+ }
+
+ if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
+ print '
';
+ }
+ print '
';
+
+ print "\n";
+
+ mrpCollapseBomManagement();
+
+
//Services
$filtertype = 1;
$res = $object->fetchLinesbytypeproduct(1);
$object->calculateCosts();
- if ($res > 0) {
- print load_fiche_titre($langs->trans('BOMServicesList'), '', 'service');
+ print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service');
+ print ' \n";
}
+ $res = $object->fetchLines();
// Buttons for actions
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index db03f6bf0bd..e3aa0180cf5 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -444,7 +444,7 @@ class BOM extends CommonObject
$i++;
}
- return 1;
+ return $num_rows;
} else {
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;