Can set a BOM to draft

This commit is contained in:
Laurent Destailleur 2019-10-16 18:35:15 +02:00
parent 7960c91955
commit 205967976c
4 changed files with 30 additions and 16 deletions

View File

@ -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 '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
if ($user->rights->bom->write && $object->status == BOM::STATUS_VALIDATED)
{
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=setdraft">' . $langs->trans("SetToDraft") . '</a>';
}
// 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 '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=close">' . $langs->trans("Disable") . '</a>';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=close">' . $langs->trans("Disable") . '</a>';
}
// Re-open

View File

@ -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)
{

View File

@ -201,7 +201,6 @@ class box_task extends ModeleBoxes
dol_print_error($this->db);
}
}
}
/**

View File

@ -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 '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
// Back to draft
if (! empty($user->rights->mymodule->write) && $object->status == BOM::STATUS_VALIDATED)
{
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=setdraft">' . $langs->trans("SetToDraft") . '</a>';
}
// Modify
if (! empty($user->rights->mymodule->write))
{