public function delete($pk = null) { if ($pk) { $taxHelper = new taxHelper(); // Check whether zone is allowed to delete or not. If not the enqueue error message accordingly. $count_id = $taxHelper->isAllowedToDelTaxrate($pk); if ($count_id === true) { $this->load($pk); $result = parent::delete($pk); if ($result) { } return $result; } } return false; }
/** * Method to delete a row from the database table by primary key value. * * @param array $items An array of primary key value to delete. * * @return int Returns count of success */ public function delete($items) { $user = JFactory::getUser(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $successCount = 0; $app = JFactory::getApplication(); if (is_array($items)) { $taxHelper = new taxHelper(); foreach ($items as $id) { // Check whether zone is allowed to delete or not. If not the enqueue error message accordingly. $count_id = $taxHelper->isAllowedToDelTaxrate($id); if ($count_id === true) { try { $query = $db->getQuery(true)->delete('#__kart_taxrates')->where('id =' . $id); $db->setQuery($query); if (!$db->execute()) { $this->setError($this->_db->getErrorMsg()); return $successCount; } } catch (RuntimeException $e) { $this->setError($e->getMessage()); throw new Exception($this->_db->getErrorMsg()); return $successCount; } $successCount++; } } } return $successCount; }