}
//get the entry
$entry = $dbc->get_entry_by_id($entry_id);
//if the report is not found throw an error of if the report has a status of disabled
if (empty($entry)) {
    print_error('entrynotfouund', 'block_ilp');
}
if (empty($report->frequency)) {
    //entries can only be deleted from reports that allow multiple entries
    print_error('entrycannotbedeleted', 'block_ilp');
}
//check if the user has the delete record capability
if (empty($access_report_deletereports)) {
    //the user doesnt have the capability to create this type of report entry
    print_error('userdoesnothavedeletecapability', 'block_ilp');
}
// instantiate the db
$dbc = new ilp_db();
//get all of the fields in the current report, they will be returned in order as
//no position has been specified
$reportfields = $dbc->get_report_fields_by_position($report_id);
if (!empty($reportfields)) {
    foreach ($reportfields as $field) {
        //get the plugin record that for the plugin
        $pluginrecord = $dbc->get_plugin_by_id($field->plugin_id);
        $dbc->delete_element_record_by_id($pluginrecord->tablename . '_ent', $field->id);
    }
}
$dbc->delete_entry_by_id($entry_id);
$return_url = $CFG->wwwroot . "/blocks/ilp/actions/view_main.php?user_id={$user_id}&course_id={$course_id}&selectedtab={$selectedtab}&tabitem={$tabitem}";
redirect($return_url, get_string('entrydeleted', 'block_ilp'), ILP_REDIRECT_DELAY);