From 205967976cbc53ec91506ff8b73974c127f59f17 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 18:35:15 +0200 Subject: [PATCH] Can set a BOM to draft --- htdocs/bom/bom_card.php | 23 ++++++++----------- htdocs/core/actions_addupdatedelete.inc.php | 14 +++++++++++ htdocs/core/boxes/box_task.php | 1 - .../modulebuilder/template/myobject_card.php | 8 +++++-- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 8e6551e92ea..0949fa1a334 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -405,20 +405,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Confirmation of action xxxx - if ($action == 'xxx') + if ($action == 'setdraft') { + $text = $langs->trans('ConfirmSetToDraft', $object->ref); + $formquestion=array(); - /* - $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), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); } // Call Hook formConfirm @@ -568,6 +560,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Send //print '' . $langs->trans('SendMail') . ''."\n"; + if ($user->rights->bom->write && $object->status == BOM::STATUS_VALIDATED) + { + print '' . $langs->trans("SetToDraft") . ''; + } + // Modify if ($user->rights->bom->write) { @@ -594,7 +591,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Close / Cancel if ($user->rights->bom->write && $object->status == BOM::STATUS_VALIDATED) { - print '' . $langs->trans("Disable") . ''; + print '' . $langs->trans("Disable") . ''; } // Re-open diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 7082bc5e882..e87333e4c01 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -289,6 +289,20 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissionedit) } } +// Action setdraft object +if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissionedit) +{ + $result = $object->setDraft($user); + if ($result >= 0) + { + // Nothing else done + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + // Action reopen object if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissionedit) { diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index dbe1757d55d..67ed84c0797 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -201,7 +201,6 @@ class box_task extends ModeleBoxes dol_print_error($this->db); } } - } /** diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index c443641ffd6..5727d596a6d 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -114,8 +114,6 @@ $permissiontoadd=$user->rights->mymodule->write; // Used by the include of actio /* * Actions - * - * Put here all code to do according to value of "action" parameter */ $parameters=array(); @@ -437,6 +435,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Send print '' . $langs->trans('SendMail') . ''."\n"; + // Back to draft + if (! empty($user->rights->mymodule->write) && $object->status == BOM::STATUS_VALIDATED) + { + print '' . $langs->trans("SetToDraft") . ''; + } + // Modify if (! empty($user->rights->mymodule->write)) {