require 'path.php';
init_cobalt('Delete barangay clearance');
if (isset($_GET['barangay_clearance_id'])) {
    $barangay_clearance_id = urldecode($_GET['barangay_clearance_id']);
    require_once 'form_data_barangay_clearance.php';
}
if (xsrf_guard()) {
    init_var($_POST['btn_cancel']);
    init_var($_POST['btn_delete']);
    require 'components/query_string_standard.php';
    if ($_POST['btn_cancel']) {
        log_action('Pressed cancel button');
        redirect("listview_barangay_clearance.php?{$query_string}");
    } elseif ($_POST['btn_delete']) {
        log_action('Pressed delete button');
        require_once 'subclasses/barangay_clearance.php';
        $dbh_barangay_clearance = new barangay_clearance();
        $object_name = 'dbh_barangay_clearance';
        require 'components/create_form_data.php';
        $dbh_barangay_clearance->delete($arr_form_data);
        redirect("listview_barangay_clearance.php?{$query_string}");
    }
}
require 'subclasses/barangay_clearance_html.php';
$html = new barangay_clearance_html();
$html->draw_header('Delete Barangay Clearance', $message, $message_type);
$html->draw_listview_referrer_info($filter_field_used, $filter_used, $page_from, $filter_sort_asc, $filter_sort_desc);
$html->draw_hidden('barangay_clearance_id');
$html->detail_view = TRUE;
$html->draw_controls('delete');
$html->draw_footer();
extract($citizen->fetch_assoc());
?>

<main>
<div class="fold-body">
    <h3 class="fold-complain-head" style="width: 650px">Mag-Request ng Barangay Clearance</h3>
    <hr class="hr"/>
    <p class="complain-desc">Patunayang ikaw ay isang mabuting mamamayan sa ating barangay! Ilagay ang iyong dahilan kung bakit kailangan mo nito</p>

<?php 
if (xsrf_guard()) {
    init_var($_POST['btn_cancel']);
    init_var($_POST['btn_submit']);
    require 'components/query_string_standard.php';
    require 'subclasses/barangay_clearance.php';
    $dbh_barangay_clearance = new barangay_clearance();
    $object_name = 'dbh_barangay_clearance';
    require 'components/create_form_data.php';
    extract($arr_form_data);
    if ($_POST['btn_cancel']) {
        log_action('Pressed cancel button');
        redirect("documents.php");
    }
    if ($_POST['btn_submit']) {
        log_action('Pressed submit button');
        $message .= $dbh_barangay_clearance->sanitize($arr_form_data)->lst_error;
        extract($arr_form_data);
        if ($dbh_barangay_clearance->check_uniqueness($arr_form_data)->is_unique) {
            //Good, no duplicate in database
        } else {
            $message = "Record already exists with the same primary identifiers!";
//Generated by Cobalt, a rapid application development framework. http://cobalt.jvroig.com
//Cobalt developed by JV Roig (jvroig@jvroig.com)
//****************************************************************************************
require 'path.php';
init_cobalt('View barangay clearance');
if (xsrf_guard()) {
    init_var($_POST['btn_cancel']);
    init_var($_POST['btn_submit']);
    if ($_POST['btn_cancel']) {
        log_action('Pressed cancel button');
        redirect("listview_barangay_clearance.php");
    }
    if ($_POST['btn_submit']) {
        log_action('Pressed submit button');
        require 'subclasses/barangay_clearance.php';
        $dbh_barangay_clearance = new barangay_clearance();
        if ($message == "") {
            log_action('Exported table data to CSV');
            $timestamp = date('Y-m-d');
            $token = generate_token(0, 'fs');
            $csv_name = $token . $_SESSION['user'] . '_barangay_clearance_' . $timestamp . '.csv';
            $filename = TMP_DIRECTORY . '/' . $csv_name;
            $csv_contents = $dbh_barangay_clearance->export_to_csv();
            $csv_file = fopen($filename, "wb");
            fwrite($csv_file, $csv_contents);
            fclose($csv_file);
            chmod($filename, 0755);
            $csv_name = urlencode($csv_name);
            $message = 'CSV file successfully generated: <a href="/' . BASE_DIRECTORY . '/download_generic.php?filename=' . $csv_name . '">Download the CSV file.</a>';
            $message_type = 'system';
        }
<?php

require 'components/get_listview_referrer.php';
require 'subclasses/barangay_clearance.php';
$dbh_barangay_clearance = new barangay_clearance();
$dbh_barangay_clearance->set_where("barangay_clearance_id='" . quote_smart($barangay_clearance_id) . "'");
if ($result = $dbh_barangay_clearance->make_query()->result) {
    $data = $result->fetch_assoc();
    extract($data);
}