From 63c2de5e954081498aaa8e0f337387dcef3f8fa7 Mon Sep 17 00:00:00 2001 From: appu <apparao@vtiger.com> Date: Wed, 10 Jan 2024 15:10:27 +0530 Subject: [PATCH] #Fixes::158108634::Appu::When we unlink the record from the relative tab ,it is deleting from the source module too --- modules/PurchaseOrder/PurchaseOrder.php | 42 ++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/PurchaseOrder/PurchaseOrder.php b/modules/PurchaseOrder/PurchaseOrder.php index 625bcfb62..8a6f646d0 100644 --- a/modules/PurchaseOrder/PurchaseOrder.php +++ b/modules/PurchaseOrder/PurchaseOrder.php @@ -514,27 +514,27 @@ class PurchaseOrder extends CRMEntity { // Function to unlink an entity with given Id from another entity function unlinkRelationship($id, $return_module, $return_id) { - global $log; - if(empty($return_module) || empty($return_id)) return; - - if($return_module == 'Vendors') { - $sql_req ='UPDATE vtiger_crmentity SET deleted = 1 WHERE crmid= ?'; - $this->db->pquery($sql_req, array($id)); - } elseif($return_module == 'Contacts') { - $sql_req ='UPDATE vtiger_purchaseorder SET contactid=? WHERE purchaseorderid = ?'; - $this->db->pquery($sql_req, array(null, $id)); - } elseif($return_module == 'Documents') { - $sql = 'DELETE FROM vtiger_senotesrel WHERE crmid=? AND notesid=?'; - $this->db->pquery($sql, array($id, $return_id)); - } elseif($return_module == 'Accounts') { - $sql ='UPDATE vtiger_purchaseorder SET accountid=? WHERE purchaseorderid=?'; - $this->db->pquery($sql, array(null, $id)); - } else { - parent::unlinkRelationship($id, $return_module, $return_id); - } - } - - function insertIntoEntityTable($table_name, $module, $fileid = '') { + global $log; + if (empty($return_module) || empty($return_id)) return; + + if ($return_module == 'Vendors') { + $sql_req = 'UPDATE vtiger_purchaseorder SET vendorid = ? WHERE purchaseorderid = ?'; + $this->db->pquery($sql_req, array(null, $id)); + } elseif ($return_module == 'Contacts') { + $sql_req = 'UPDATE vtiger_purchaseorder SET contactid=? WHERE purchaseorderid = ?'; + $this->db->pquery($sql_req, array(null, $id)); + } elseif ($return_module == 'Documents') { + $sql = 'DELETE FROM vtiger_senotesrel WHERE crmid=? AND notesid=?'; + $this->db->pquery($sql, array($id, $return_id)); + } elseif ($return_module == 'Accounts') { + $sql = 'UPDATE vtiger_purchaseorder SET accountid = ? WHERE purchaseorderid = ?'; + $this->db->pquery($sql, array(null, $id)); + } else { + parent::unlinkRelationship($id, $return_module, $return_id); + } + } + + function insertIntoEntityTable($table_name, $module, $fileid = '') { //Ignore relation table insertions while saving of the record if($table_name == 'vtiger_inventoryproductrel') { return; -- GitLab