vtenext/modules/Vendors/updateRelations.php
2021-04-28 20:10:26 +02:00

48 lines
1.5 KiB
PHP

<?php
/*************************************
* SPDX-FileCopyrightText: 2009-2020 Vtenext S.r.l. <info@vtenext.com>
* SPDX-License-Identifier: AGPL-3.0-only
************************************/
global $adb, $currentModule;//crmv@203484 removed global singlepane
global $table_prefix;
//crmv@203484
$VTEP = VTEProperties::getInstance();
$singlepane_view = $VTEP->getProperty('layout.singlepane_view');
//crmv@203484e
$idlist = vtlib_purify($_REQUEST['idlist']);
$dest_mod = vtlib_purify($_REQUEST['destination_module']);
$parenttab = getParentTab();
$forCRMRecord = vtlib_purify($_REQUEST['parentid']);
if($singlepane_view == true)//crmv@203484 changed to normal bool true, not string 'true'
$action = "DetailView";
else
$action = "CallRelatedList";
$storearray = array();
if(!empty($_REQUEST['idlist'])) {
// Split the string of ids
$storearray = explode (";",trim($idlist,";"));
} else if(!empty($_REQUEST['entityid'])){
$storearray = array($_REQUEST['entityid']);
}
$focus = CRMEntity::getInstance($currentModule);
foreach($storearray as $id)
{
if($id != '')
{
if($dest_mod == 'Contacts')
$adb->pquery("insert into ".$table_prefix."_vendorcontactrel values (?,?)", array($forCRMRecord, $id));
elseif($dest_mod == 'Products')
$adb->pquery("update ".$table_prefix."_products set vendor_id=? where productid=?", array($forCRMRecord, $id));
else {
$focus->save_related_module($currentModule, $forCRMRecord, $dest_mod, $id);
}
}
}
header("Location: index.php?action=$action&module=$currentModule&record=".$forCRMRecord."&parenttab=".$parenttab);
?>