diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 3c188077237..a80792705ee 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -147,328 +147,326 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
// Add line
-if ($action == 'addline' && $user->rights->bom->write) {
- $langs->load('errors');
- $error = 0;
+ if ($action == 'addline' && $user->rights->bom->write) {
+ $langs->load('errors');
+ $error = 0;
- // Set if we used free entry or predefined product
- $bom_child_id = (int) GETPOST('bom_id', 'int');
- if ($bom_child_id > 0) {
- $bom_child = new BOM($db);
- $res = $bom_child->fetch($bom_child_id);
- if ($res) {
- $idprod = $bom_child->fk_product;
- }
- } else {
- $idprod = (!empty(GETPOST('idprodservice', 'int')) ? GETPOST('idprodservice', 'int') : (int) GETPOST('idprod', 'int'));
- }
-
- $qty = price2num(GETPOST('qty', 'alpha'), 'MS');
- $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS');
- $disable_stock_change = GETPOST('disable_stock_change', 'int');
- $efficiency = price2num(GETPOST('efficiency', 'alpha'));
- $fk_unit = GETPOST('fk_unit', 'alphanohtml');
- if ($qty == '') {
- setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
- $error++;
- }
- if (!($idprod > 0)) {
- setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Product')), null, 'errors');
- $error++;
- }
-
- if ($object->fk_product == $idprod) {
- setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors');
- $error++;
- }
-
- if (!$error) {
- $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null, $fk_unit);
-
- if ($result <= 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- $action = '';
+ // Set if we used free entry or predefined product
+ $bom_child_id = (int) GETPOST('bom_id', 'int');
+ if ($bom_child_id > 0) {
+ $bom_child = new BOM($db);
+ $res = $bom_child->fetch($bom_child_id);
+ if ($res) {
+ $idprod = $bom_child->fk_product;
+ }
} else {
- unset($_POST['idprod']);
- unset($_POST['idprodservice']);
- unset($_POST['qty']);
- unset($_POST['qty_frozen']);
- unset($_POST['disable_stock_change']);
-
+ $idprod = (!empty(GETPOST('idprodservice', 'int')) ? GETPOST('idprodservice', 'int') : (int) GETPOST('idprod', 'int'));
}
- $object->fetchLines();
+ $qty = price2num(GETPOST('qty', 'alpha'), 'MS');
+ $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS');
+ $disable_stock_change = GETPOST('disable_stock_change', 'int');
+ $efficiency = price2num(GETPOST('efficiency', 'alpha'));
+ $fk_unit = GETPOST('fk_unit', 'alphanohtml');
+ if ($qty == '') {
+ setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
+ $error++;
+ }
+ if (!($idprod > 0)) {
+ setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Product')), null, 'errors');
+ $error++;
+ }
- $object->calculateCosts();
+ if ($object->fk_product == $idprod) {
+ setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors');
+ $error++;
+ }
+
+ if (!$error) {
+ $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null, $fk_unit);
+
+ if ($result <= 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = '';
+ } else {
+ unset($_POST['idprod']);
+ unset($_POST['idprodservice']);
+ unset($_POST['qty']);
+ unset($_POST['qty_frozen']);
+ unset($_POST['disable_stock_change']);
+ }
+
+ $object->fetchLines();
+
+ $object->calculateCosts();
+ }
}
-}
// Update line
-if ($action == 'updateline' && $user->rights->bom->write) {
- $langs->load('errors');
- $error = 0;
+ if ($action == 'updateline' && $user->rights->bom->write) {
+ $langs->load('errors');
+ $error = 0;
- // Set if we used free entry or predefined product
- $qty = price2num(GETPOST('qty', 'alpha'), 'MS');
- $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS');
- $disable_stock_change = GETPOST('disable_stock_change', 'int');
- $efficiency = price2num(GETPOST('efficiency', 'alpha'));
- $fk_unit = GETPOST('fk_unit', 'alphanohtml');
-
- if ($qty == '') {
- setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
- $error++;
- }
-
- if (!$error) {
- $bomline = new BOMLine($db);
- $bomline->fetch($lineid);
-
- $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key, $fk_unit);
-
- if ($result <= 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- $action = '';
- } else {
- unset($_POST['idprod']);
- unset($_POST['idprodservice']);
- unset($_POST['qty']);
- unset($_POST['qty_frozen']);
- unset($_POST['disable_stock_change']);
+ // Set if we used free entry or predefined product
+ $qty = price2num(GETPOST('qty', 'alpha'), 'MS');
+ $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS');
+ $disable_stock_change = GETPOST('disable_stock_change', 'int');
+ $efficiency = price2num(GETPOST('efficiency', 'alpha'));
+ $fk_unit = GETPOST('fk_unit', 'alphanohtml');
+ if ($qty == '') {
+ setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
+ $error++;
}
- $object->fetchLines();
+ if (!$error) {
+ $bomline = new BOMLine($db);
+ $bomline->fetch($lineid);
- $object->calculateCosts();
- }
-}
+ $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key, $fk_unit);
+ if ($result <= 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = '';
+ } else {
+ unset($_POST['idprod']);
+ unset($_POST['idprodservice']);
+ unset($_POST['qty']);
+ unset($_POST['qty_frozen']);
+ unset($_POST['disable_stock_change']);
+ }
+ $object->fetchLines();
-/*
- * View
- */
-
-$form = new Form($db);
-$formfile = new FormFile($db);
-
-
-$title = $langs->trans('BOM');
-$help_url ='EN:Module_BOM';
-llxHeader('', $title, $help_url);
-
-// Part to create
-if ($action == 'create') {
- print load_fiche_titre($langs->trans("NewBOM"), '', 'bom');
-
- print '
';
-}
-
-// Part to edit record
-if (($id || $ref) && $action == 'edit') {
- print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes');
-
- print '';
-}
-
-// Part to show record
-if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
- $head = bomPrepareHead($object);
- print dol_get_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom');
-
- $formconfirm = '';
-
- // Confirmation to delete
- if ($action == 'delete') {
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1);
- }
- // Confirmation to delete line
- if ($action == 'deleteline') {
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
+ $object->calculateCosts();
+ }
}
- // Confirmation of validation
- if ($action == 'validate') {
- // We check that object has a temporary ref
- $ref = substr($object->ref, 1, 4);
- if ($ref == 'PROV') {
- $object->fetch_product();
- $numref = $object->getNextNumRef($object->product);
- } else {
- $numref = $object->ref;
+
+
+ /*
+ * View
+ */
+
+ $form = new Form($db);
+ $formfile = new FormFile($db);
+
+
+ $title = $langs->trans('BOM');
+ $help_url ='EN:Module_BOM';
+ llxHeader('', $title, $help_url);
+
+ // Part to create
+ if ($action == 'create') {
+ print load_fiche_titre($langs->trans("NewBOM"), '', 'bom');
+
+ print '';
+ }
+
+ // Part to edit record
+ if (($id || $ref) && $action == 'edit') {
+ print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes');
+
+ print '';
+ }
+
+ // Part to show record
+ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
+ $head = bomPrepareHead($object);
+ print dol_get_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom');
+
+ $formconfirm = '';
+
+ // Confirmation to delete
+ if ($action == 'delete') {
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1);
+ }
+ // Confirmation to delete line
+ if ($action == 'deleteline') {
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
}
- $text = $langs->trans('ConfirmValidateBom', $numref);
- /*if (! empty($conf->notification->enabled))
- {
+ // Confirmation of validation
+ if ($action == 'validate') {
+ // We check that object has a temporary ref
+ $ref = substr($object->ref, 1, 4);
+ if ($ref == 'PROV') {
+ $object->fetch_product();
+ $numref = $object->getNextNumRef($object->product);
+ } else {
+ $numref = $object->ref;
+ }
+
+ $text = $langs->trans('ConfirmValidateBom', $numref);
+ /*if (! empty($conf->notification->enabled))
+ {
require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
$notify = new Notify($db);
$text .= '
';
$text .= $notify->confirmMessage('BOM_VALIDATE', $object->socid, $object);
- }*/
+ }*/
- $formquestion = array();
- if (!empty($conf->bom->enabled)) {
- $langs->load("mrp");
- $forcecombo = 0;
- if ($conf->browser->name == 'ie') {
- $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
- }
- $formquestion = array(
+ $formquestion = array();
+ if (!empty($conf->bom->enabled)) {
+ $langs->load("mrp");
+ $forcecombo = 0;
+ if ($conf->browser->name == 'ie') {
+ $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
+ }
+ $formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- );
+ );
+ }
+
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220);
}
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220);
- }
-
- // Confirmation of closing
- if ($action == 'close') {
- $text = $langs->trans('ConfirmCloseBom', $object->ref);
- /*if (! empty($conf->notification->enabled))
- {
+ // Confirmation of closing
+ if ($action == 'close') {
+ $text = $langs->trans('ConfirmCloseBom', $object->ref);
+ /*if (! empty($conf->notification->enabled))
+ {
require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
$notify = new Notify($db);
$text .= '
';
$text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object);
- }*/
+ }*/
- $formquestion = array();
- if (!empty($conf->bom->enabled)) {
- $langs->load("mrp");
- $forcecombo = 0;
- if ($conf->browser->name == 'ie') {
- $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
- }
- $formquestion = array(
+ $formquestion = array();
+ if (!empty($conf->bom->enabled)) {
+ $langs->load("mrp");
+ $forcecombo = 0;
+ if ($conf->browser->name == 'ie') {
+ $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
+ }
+ $formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- );
+ );
+ }
+
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_close', $formquestion, 0, 1, 220);
}
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_close', $formquestion, 0, 1, 220);
- }
+ // Confirmation of reopen
+ if ($action == 'reopen') {
+ $text = $langs->trans('ConfirmReopenBom', $object->ref);
+ /*if (! empty($conf->notification->enabled))
+ {
+ require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
+ $notify = new Notify($db);
+ $text .= '
';
+ $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object);
+ }*/
- // Confirmation of reopen
- if ($action == 'reopen') {
- $text = $langs->trans('ConfirmReopenBom', $object->ref);
- /*if (! empty($conf->notification->enabled))
- {
- require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
- $notify = new Notify($db);
- $text .= '
';
- $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object);
- }*/
-
- $formquestion = array();
- if (!empty($conf->bom->enabled)) {
- $langs->load("mrp");
- require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
- $forcecombo = 0;
- if ($conf->browser->name == 'ie') {
- $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
- }
- $formquestion = array(
+ $formquestion = array();
+ if (!empty($conf->bom->enabled)) {
+ $langs->load("mrp");
+ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
+ $forcecombo = 0;
+ if ($conf->browser->name == 'ie') {
+ $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
+ }
+ $formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- );
+ );
+ }
+
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $text, 'confirm_reopen', $formquestion, 0, 1, 220);
}
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $text, 'confirm_reopen', $formquestion, 0, 1, 220);
- }
+ // Clone confirmation
+ if ($action == 'clone') {
+ // Create an array for form
+ $formquestion = array();
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneBillOfMaterials', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
+ }
- // Clone confirmation
- if ($action == 'clone') {
- // Create an array for form
- $formquestion = array();
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneBillOfMaterials', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
- }
+ // Confirmation of action xxxx
+ if ($action == 'setdraft') {
+ $text = $langs->trans('ConfirmSetToDraft', $object->ref);
- // Confirmation of action xxxx
- if ($action == 'setdraft') {
- $text = $langs->trans('ConfirmSetToDraft', $object->ref);
+ $formquestion = array();
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220);
+ }
- $formquestion = array();
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220);
- }
+ // Call Hook formConfirm
+ $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) {
+ $formconfirm .= $hookmanager->resPrint;
+ } elseif ($reshook > 0) {
+ $formconfirm = $hookmanager->resPrint;
+ }
- // Call Hook formConfirm
- $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
- $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) {
- $formconfirm .= $hookmanager->resPrint;
- } elseif ($reshook > 0) {
- $formconfirm = $hookmanager->resPrint;
- }
-
- // Print form confirm
- print $formconfirm;
+ // Print form confirm
+ print $formconfirm;
- // Object card
- // ------------------------------------------------------------
- $linkback = ''.$langs->trans("BackToList").'';
+ // Object card
+ // ------------------------------------------------------------
+ $linkback = ''.$langs->trans("BackToList").'';
- $morehtmlref = '';
- /*
- // Ref bis
- $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1);
- $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1);
- // Thirdparty
- $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
- // Project
- if (! empty($conf->project->enabled))
- {
+ $morehtmlref = '
';
+ /*
+ // Ref bis
+ $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
+ // Project
+ if (! empty($conf->project->enabled))
+ {
$langs->load("projects");
$morehtmlref.='
'.$langs->trans('Project') . ' ';
if ($permissiontoadd)
@@ -495,51 +493,51 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtmlref.='';
}
}
- }
- */
- $morehtmlref .= '
';
+ }
+ */
+ $morehtmlref .= '
';
- dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
- print '';
- print '
';
- print '
';
- print '
'."\n";
+ print '';
+ print '
';
+ print '
';
+ print '
'."\n";
- // Common attributes
- $keyforbreak = 'duration';
- include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
- $object->calculateCosts();
- print '| '.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).' | '.price($object->total_cost).' |
';
- print '| '.$langs->trans("UnitCost").' | '.price($object->unit_cost).' |
';
-
- // Other attributes
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
-
- print '
';
- print '
';
- print '
';
-
- print '';
-
- print dol_get_fiche_end();
-
-
-
- /*
- * Lines
- */
-
- if (!empty($object->table_element_line)) {
- //Products
- $res = $object->fetchLinesbytypeproduct(0);
+ // Common attributes
+ $keyforbreak = 'duration';
+ include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
$object->calculateCosts();
+ print '| '.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).' | '.price($object->total_cost).' |
';
+ print '| '.$langs->trans("UnitCost").' | '.price($object->unit_cost).' |
';
- print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMProductsList'), '', 'product');
+ // Other attributes
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
- print '
';
+ print '
';
+ print '
';
+
+ print '';
+
+ print dol_get_fiche_end();
+
+
+
+ /*
+ * Lines
+ */
+
+ if (!empty($object->table_element_line)) {
+ //Products
+ $res = $object->fetchLinesbytypeproduct(0);
+ $object->calculateCosts();
+
+ print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMProductsList'), '', 'product');
+
+ print ' \n";
+
+ mrpCollapseBomManagement();
+
+
+ //Services
+ $filtertype = 1;
+ $res = $object->fetchLinesbytypeproduct(1);
+ $object->calculateCosts();
+
+ print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service');
+
+ print '