} else {
        // No, they don't...
        $id = '0';
        // ...so it's gottabee a new one
    }
}
$parameters = ['id' => $id, 'delete' => $delete, 'parameters' => $parameters, 'record' => $record];
$mform = new mdl_param_form(null, $parameters);
if ($mform->is_cancelled()) {
    redirect($url);
} else {
    if ($mform_data = $mform->get_data()) {
        if (isset($mform_data->submitbutton)) {
            // 'Save' or 'Confirm Deletion'
            if ($mform_data->submitbutton == get_string('save', 'local_obu_application')) {
                write_parameter($mform_data);
                redirect($url);
            } else {
                if ($mform_data->submitbutton == get_string('confirm_delete', 'local_obu_application')) {
                    delete_parameter($mform_data->id);
                    redirect($url);
                }
            }
        } else {
            if (isset($mform_data->deletebutton) && $mform_data->deletebutton == get_string('delete', 'local_obu_application')) {
                // Delete
                redirect($url . '?id=' . $id . '&delete=1');
                // Come back and ask for confirmation
            }
        }
    }
                }
                fputcsv($fp, $fields, $delimiter);
                // Flag the application as processed
                if ($mform_data->xfer_type == 1 && $application->admissions_xfer == 0) {
                    $application->admissions_xfer = $xfer_id;
                    update_application($application);
                } else {
                    if ($mform_data->xfer_type == 2 && $application->finance_xfer == 0) {
                        $application->finance_xfer = $xfer_id;
                        update_application($application);
                    }
                }
            }
            fclose($fp);
            // Update the parameter record if necessary
            if ($xfer_id > $param->number) {
                $param->number = $xfer_id;
                write_parameter($param);
            }
            exit;
        }
    }
}
echo $OUTPUT->header();
echo $OUTPUT->heading($heading);
if ($message) {
    notice($message, $url);
} else {
    $mform->display();
}
echo $OUTPUT->footer();