From f72f409a0b4cf4a9a042fc76a1bdee201596e118 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sun, 7 Jan 2018 20:01:32 -0700 Subject: [PATCH] Update destinations.php --- resources/classes/destinations.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/resources/classes/destinations.php b/resources/classes/destinations.php index 5cc3a58040..b53bb6c3d9 100644 --- a/resources/classes/destinations.php +++ b/resources/classes/destinations.php @@ -299,10 +299,28 @@ class destinations { if ($action == 'delete') { foreach($destinations as $row) { if ($row['action'] == 'delete' or $row['checked'] == 'true') { - $sql = "delete from v_destinations "; - $sql .= "where destination_uuid = '".$row['destination_uuid']."'; "; - $this->db->query($sql); - unset($sql); + //get the list of dialplan uuid + $sql = "select * from v_destinations "; + $sql .= "where destination_uuid = '".$row['destination_uuid']."';"; + $prep_statement = $this->db->prepare($sql); + $prep_statement->execute(); + $destinations = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $row = $destinations[0]; + //delete th dialplan + $sql = "delete from v_dialplan_details "; + $sql .= "where dialplan_uuid = '".$row['dialplan_uuid']."';"; + $this->db->query($sql); + unset($sql); + //delete th dialplan + $sql = "delete from v_dialplans "; + $sql .= "where dialplan_uuid = '".$row['dialplan_uuid']."';"; + $this->db->query($sql); + unset($sql); + //delete the destinations + $sql = "delete from v_destinations "; + $sql .= "where destination_uuid = '".$row['destination_uuid']."';"; + $this->db->query($sql); + unset($sql); } } unset($destinations);