<?php
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

require_once __DIR__ . "/../required.php";

redirectifnotloggedin();

if (!empty($VARS['id'])) {
    if ($database->has('people', ['personid' => $VARS['id']])) {
        $person = $database->get("people", ["firstname", "lastname", "address", "phone1", "email"], ['personid' => $VARS['id']]);
    } else {
        header('Location: app.php?page=people&msg=person_doesnt_exist');
        die();
    }
} else {
    header('Location: app.php?page=people&msg=person_doesnt_exist');
    die();
}
?>
<div class="row justify-content-center">
    <div class="col-12 col-sm-6 col-sm-offset-3">
        <div class="card border-red text-center">
            <h3 class="card-header text-red">
                <?php $Strings->get("Delete Person"); ?>
            </h3>
            <div class="card-body">
                <p><i class="fas fa-exclamation-triangle fa-10x"></i></p>
                <h4><?php $Strings->get("Are you sure you want to delete this person?") ?></h4>
                <h5><?php $Strings->get("This action cannot be undone!"); ?></h5>
                <div class="list-group">
                    <div class="list-group-item">
                        <i class="fas fa-fw fa-user"></i> <?php echo $person["firstname"] . " " . $person["lastname"]; ?>
                    </div>
                    <div class="list-group-item">
                        <i class="fas fa-fw fa-at"></i> <?php echo $person["email"]; ?>
                    </div>
                    <div class="list-group-item">
                        <i class="fas fa-fw fa-phone"></i> <?php echo $person["phone1"]; ?>
                    </div>
                </div>
            </div>
            <div class="card-footer d-flex">
                <a href="app.php?page=people" class="btn btn-primary mr-auto"><i class="fas fa-arrow-left"></i> <?php $Strings->get('Cancel'); ?></a>
                <a href="action.php?action=deleteperson&source=people&id=<?php echo htmlspecialchars($VARS['id']); ?>" class="btn btn-danger"><i class="fas fa-times"></i> <?php $Strings->get('Delete'); ?></a>
            </div>
        </div>
    </div>
</div>