Clean code for adding a link to a related object
This commit is contained in:
parent
9796b1b268
commit
6b9d7763fe
@ -74,6 +74,7 @@ $ref = GETPOST('ref', 'alpha');
|
||||
$socid = GETPOST('socid', 'int');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$lineid = GETPOST('lineid', 'int');
|
||||
$userid = GETPOST('userid', 'int');
|
||||
$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
|
||||
@ -124,12 +125,22 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($cancel) $action='';
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
|
||||
|
||||
// Link invoice to order
|
||||
if (GETPOST('linkedOrder') && empty($cancel) && $id > 0)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
$result = $object->add_object_linked('commande', GETPOST('linkedOrder'));
|
||||
}
|
||||
|
||||
// Action clone object
|
||||
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) {
|
||||
// if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) {
|
||||
@ -1692,13 +1703,6 @@ if (empty($reshook))
|
||||
exit();
|
||||
}
|
||||
|
||||
// Link invoice to order
|
||||
if (GETPOST('linkedOrder')) {
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
$result = $object->add_object_linked('commande', GETPOST('linkedOrder'));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Send mail
|
||||
|
||||
@ -110,6 +110,14 @@ if (empty($reshook))
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
|
||||
|
||||
// Link invoice to order
|
||||
if (GETPOST('linkedOrder') && empty($cancel) && $id > 0)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
$result = $object->add_object_linked('order_supplier', GETPOST('linkedOrder'));
|
||||
}
|
||||
|
||||
// Action clone object
|
||||
if ($action == 'confirm_clone' && $confirm == 'yes')
|
||||
{
|
||||
@ -894,13 +902,6 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
// Link invoice to order
|
||||
if (GETPOST('linkedOrder')) {
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
$result = $object->add_object_linked('order_supplier', GETPOST('linkedOrder'));
|
||||
}
|
||||
|
||||
// Add file in email form
|
||||
if (GETPOST('addfile'))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user