2015-07-28 14:13:16 +02:00
|
|
|
<?php
|
2016-08-04 11:57:37 +02:00
|
|
|
/* Copyright (C) 2015-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
2015-07-28 14:13:16 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
* or see https://www.gnu.org/
|
2015-07-28 14:13:16 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file htdocs/core/actions_dellink.inc.php
|
2016-08-04 11:57:37 +02:00
|
|
|
* \brief Code for actions on linking and deleting link between elements
|
2015-07-28 14:13:16 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $action must be defined
|
|
|
|
|
// $object must be defined
|
|
|
|
|
// $permissiondellink must be defined
|
|
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
$dellinkid = GETPOST('dellinkid', 'int');
|
|
|
|
|
$addlinkid = GETPOST('idtolinkto', 'int');
|
2015-07-28 14:13:16 +02:00
|
|
|
|
2016-08-04 11:57:37 +02:00
|
|
|
// Link invoice to order
|
2020-04-10 10:59:32 +02:00
|
|
|
if ($action == 'addlink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0)
|
2016-08-04 11:57:37 +02:00
|
|
|
{
|
2020-03-23 15:54:02 +01:00
|
|
|
$object->fetch($id);
|
|
|
|
|
$object->fetch_thirdparty();
|
|
|
|
|
$result = $object->add_object_linked(GETPOST('addlink', 'alpha'), $addlinkid);
|
2016-08-04 11:57:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete link
|
2020-04-10 10:59:32 +02:00
|
|
|
if ($action == 'dellink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $dellinkid > 0)
|
2015-07-28 14:13:16 +02:00
|
|
|
{
|
2020-04-10 10:59:32 +02:00
|
|
|
$result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid);
|
2019-01-27 11:55:16 +01:00
|
|
|
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
2015-07-28 14:13:16 +02:00
|
|
|
}
|