Example #1
0
 public function testGetMappedLicenseRefView()
 {
     $this->testDb = new TestPgDb();
     $this->testDb->createPlainTables(array('license_ref', 'license_map'));
     $this->dbManager = $this->testDb->getDbManager();
     $this->dbManager->queryOnce("CREATE TABLE license_candidate (group_fk integer) INHERITS (license_ref)");
     $this->dbManager->insertTableRow('license_map', array('license_map_pk' => 0, 'rf_fk' => 2, 'rf_parent' => 1, 'usage' => LicenseMap::CONCLUSION));
     $this->dbManager->insertTableRow('license_ref', array('rf_pk' => 1, 'rf_shortname' => 'One', 'rf_fullname' => 'One-1'));
     $this->dbManager->insertTableRow('license_ref', array('rf_pk' => 2, 'rf_shortname' => 'Two', 'rf_fullname' => 'Two-2'));
     $this->dbManager->insertTableRow('license_candidate', array('rf_pk' => 3, 'rf_shortname' => 'Three', 'rf_fullname' => 'Three-3', 'group_fk' => $this->groupId));
     $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
     $view = LicenseMap::getMappedLicenseRefView(LicenseMap::CONCLUSION);
     $stmt = __METHOD__;
     $this->dbManager->prepare($stmt, $view);
     $res = $this->dbManager->execute($stmt);
     $map = $this->dbManager->fetchAll($res);
     $this->dbManager->freeResult($res);
     assertThat($map, is(arrayWithSize(2)));
     $expected = array(array('rf_origin' => 1, 'rf_pk' => 1, 'rf_shortname' => 'One', 'rf_fullname' => 'One-1'), array('rf_origin' => 2, 'rf_pk' => 1, 'rf_shortname' => 'One', 'rf_fullname' => 'One-1'));
     assertThat($map, containsInAnyOrder($expected));
 }
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_FILES['image']['type'] === 'image/jpeg') {
        $ext = '.jpg';
    } else {
        if ($_FILES['image']['type'] === 'image/png') {
            $ext = '.png';
        }
    }
    $filepath = DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR . "users" . DIRECTORY_SEPARATOR . time() . $ext;
    move_uploaded_file($_FILES['image']['tmp_name'], '..' . $filepath);
    $db = new DbManager();
    $db->execute("INSERT INTO users (name, position_id, contact_number, profile_image_path, user_name, password) VALUES (?, ?, ?, ?, ?, ?);", array($_POST['name'], $_POST['position'], $_POST['contact_number'], $filepath, $_POST['user_name'], $_POST['password']));
}
<?php

session_start();
require "./lib/db.php";
require "./lib/util.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $myusername = addslashes($_POST['username']);
    $mypassword = md5(addslashes($_POST['password']));
    $db = new DbManager();
    $users = $db->execute("SELECT id, full_name FROM users WHERE user_name = ? AND password = ?", array($myusername, $mypassword));
    if (count($users) > 0) {
        $_SESSION['login_username'] = $myusername;
        $_SESSION['login_id'] = $users[0]['id'];
        $_SESSION['login_full_name'] = $users[0]['full_name'];
        header("location: pages/index.php");
    } else {
        header("location: index.php");
        $_SESSION['error'] = 'Incorrect input';
    }
}
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "GET" && !empty($_POST['id'])) {
    $db = new DbManager();
    $user = $db->execute("SELECT u.name, p.name, u.contact_number, u.profile_image_path users u INNER JOIN positions p ON p.id = u.position_id WHERE id = ?;", array($_POST['id']));
    echo json_encode($user);
}
<?php

include "../includes/header.php";
include "../includes/sidebar.php";
require "../lib/db.php";
require "../lib/util.php";
$db = new DbManager();
$options = $db->execute("SELECT id, genre, name FROM options ORDER BY id ASC", array());
$operators = $db->execute("SELECT id, genre, name FROM operators WHERE genre = 1 ORDER BY id ASC", array());
?>
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header"><i class="fa fa-folder fa-fw"></i> Reports</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
				<div class="panel panel-primary">
                        <div class="panel-heading">
                            Generate Report
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <form class="form-inline">
							  <div class="form-group">
								<select id="option" class="form-control">
<?php 
foreach ($options as $i) {
    ?>
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $db = new DbManager();
    $id = $db->execute("INSERT INTO residents (full_name, relationship_id, birth_date, birth_place, civil_status_id, years_of_residency, occupation, citizenship, religion, gender_id, highest_education_attainment_id, deleted) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", array($_POST['full_name'], $_POST['relationship_id'], $_POST['birth_date'], $_POST['birth_place'], $_POST['civil_status_id'], $_POST['years_of_residency'], $_POST['occupation'], $_POST['citizenship'], $_POST['religion'], $_POST['gender_id'], $_POST['highest_education_attainment_id'], 0));
    $db->execute("INSERT INTO owner_residents (owner_id, resident_id) VALUES (?, ?);", array($_POST['pk_owner'], $id));
    echo $id;
}
<?php

include "includes/header.html";
include "includes/sidebar.html";
require "lib/db.php";
require "lib/util.php";
$db = new DbManager();
if (!empty($_GET['id'])) {
    $i = $db->execute("SELECT * FROM residents WHERE id = ?", array($_GET['id']));
}
$genders = $db->execute("SELECT id, name FROM genders ORDER BY id ASC", array());
$martial_statuses = $db->execute("SELECT id, name FROM martial_statuses ORDER BY id ASC", array());
?>
  

        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Resident Registration
                        </h1>
                    </div>
                </div>
                <!-- /.row -->
			<form role="form" method="post" action="registration.php">
            <input name="id" type="hidden" value="<?php 
echo $_GET['id'];
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $db = new DbManager();
    $db->execute("DELETE users WHERE id = ?;", array($_POST['id']));
}
<?php

include "../includes/header.php";
include "../includes/sidebar.php";
require "../lib/db.php";
require "../lib/util.php";
$id = $_GET['id'];
$db = new DbManager();
$genders = $db->execute("SELECT id, name FROM genders ORDER BY id ASC", array());
$ownerships = $db->execute("SELECT id, name FROM ownerships ORDER BY id ASC", array());
$educations = $db->execute("SELECT id, name FROM educations ORDER BY id ASC", array());
$civil_statuses = $db->execute("SELECT id, name FROM civil_statuses ORDER BY id ASC", array());
$relationships_dependent = $db->execute("SELECT id, name FROM relationships WHERE genre = 1 ORDER BY id ASC", array());
$relationships_boarder = $db->execute("SELECT id, name FROM relationships WHERE genre = 2 ORDER BY id ASC", array());
$house_statuses = $db->execute("SELECT id, name FROM house_statuses ORDER BY id ASC", array());
$owner = $db->execute("SELECT\n      o.id\n    , o.full_name\n    , o.address\n    , o.house_number\n    , o.birth_date\n    , o.birth_place\n    , o.citizenship\n    , o.religion\n    , o.occupation\n    , o.years_of_residency\n    , os.id AS ownership_id\n    , os.name AS ownership_name\n    , e.id AS education_id\n    , e.name AS education_name\n    , c.id AS civil_status_id\n    , c.name AS civil_status_name\n    , g.id AS gender_id\n    , g.name AS gender_name\n    , h.id AS house_status_id\n    , h.name AS house_status_name\n    FROM owners o\n    INNER JOIN ownerships os\n    ON os.id = o.type_of_ownership_id\n    INNER JOIN educations e\n    ON e.id = o.highest_education_attainment_id\n    INNER JOIN civil_statuses c\n    ON c.id = o.civil_status_id\n    INNER JOIN genders g\n    ON g.id = o.gender_id\n    INNER JOIN house_statuses h\n    ON h.id = o.house_status_id\n    WHERE o.id = ?\n", array($id));
$owner = $owner[0];
$residents = $db->execute("SELECT\n      res.id\n    , res.full_name\n    , res.birth_date\n    , res.birth_place\n    , res.occupation\n    , res.years_of_residency\n    , r.id AS relationship_id\n    , r.genre AS relationship_genre\n    , r.name AS relationship_name\n    , e.id AS education_id\n    , e.name AS education_name\n    , c.id AS civil_status_id\n    , c.name AS civil_status_name\n    , g.id AS gender_id\n    , g.name AS gender_name\n    FROM residents res\n    INNER JOIN owner_residents ors\n    ON ors.resident_id = res.id\n    INNER JOIN owners o\n    ON o.id = ors.owner_id\n    INNER JOIN relationships r\n    ON r.id = res.relationship_id\n    INNER JOIN educations e\n    ON e.id = res.highest_education_attainment_id\n    INNER JOIN civil_statuses c\n    ON c.id = res.civil_status_id\n    INNER JOIN genders g\n    ON g.id = res.gender_id\n    WHERE o.id = ?\n", array($id));
?>
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header"><i class="fa fa-pencil"></i> Edit House</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
			
            <div class="row">
                <div class="col-lg-12">
				<!-- Nav tabs -->
<?php

include "includes/header.html";
include "includes/sidebar.html";
require "lib/db.php";
require "lib/util.php";
$db = new DbManager();
if (!empty($_GET['id'])) {
    $i = $db->execute("SELECT id, first_name, middle_name, last_name, suffix, birth_date, TIMESTAMPDIFF(YEAR,birth_date,CURDATE()) AS age, address_line_1, address_line_2, address_line_3, address_line_4, address_line_5, gender_id, martial_status_id, citizenship, contact_number FROM residents WHERE id = ?", array($_GET['id']));
}
$genders = $db->execute("SELECT id, name FROM genders ORDER BY id ASC", array());
$martial_statuses = $db->execute("SELECT id, name FROM martial_statuses ORDER BY id ASC", array());
?>
  

        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Resident Registration
                        </h1>
                    </div>
                </div>
                <!-- /.row -->
				
			<form role="form">
            <input name="id" type="hidden" value="<?php 
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $db = new DbManager();
    $db->execute("UPDATE residents SET\n        full_name = ?\n        , birth_date = ?\n        , birth_place = ?\n        , years_of_residency = ?\n        , occupation = ?\n        , citizenship = ?\n        , religion = ?\n        , relationship_id = ?\n        , highest_education_attainment_id = ?\n        , civil_status_id = ?\n        , gender_id = ?\n        , status_id = ?\n        WHERE id = ?;\n    ", array($_POST['full_name'], $_POST['birth_date'], $_POST['birth_place'], $_POST['years_of_residency'], $_POST['occupation'], $_POST['citizenship'], $_POST['religion'], $_POST['relationship_id'], $_POST['highest_education_attainment_id'], $_POST['civil_status_id'], $_POST['gender_id'], $_POST['status_id'], $_POST['resident_id']));
}
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $db = new DbManager();
    $operators = $db->execute("SELECT\n          opr.id AS id\n        , opr.name AS name\n        FROM options opt\n        INNER JOIN operators opr\n        ON opr.genre = opt.genre OR opr.genre = 1\n        WHERE opt.id = ?\n        ORDER BY opr.id ASC;\n        ", array($_GET['option_id']));
    $r = '';
    foreach ($operators as $k => $v) {
        $r = $r . '<option value="' . $v['id'] . '">' . $v['name'] . '&nbsp;</option>';
    }
    echo $r;
}
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $db = new DbManager();
    $residents = $db->execute("SELECT\n              res.id\n            , res.full_name\n            , rel.name AS rel_name\n            , gen.name AS gen_name\n            , res.birth_date\n            , res.birth_place\n            , civ.name AS civ_name\n            , res.years_of_residency\n            , res.occupation\n            , edu.name AS edu_name\n        FROM residents res\n        LEFT OUTER JOIN relationships rel\n        ON rel.id = res.relationship_id\n        LEFT OUTER JOIN genders gen\n        ON gen.id = res.gender_id\n        LEFT OUTER JOIN civil_statuses civ\n        ON civ.id = res.civil_status_id\n        LEFT OUTER JOIN educations edu\n        ON edu.id = res.highest_education_attainment_id\n        LEFT OUTER JOIN owner_residents ors\n        ON ors.resident_id = res.id\n        WHERE ors.owner_id = ? AND rel.genre = ?\n        ORDER BY res.id ASC;\n        ", array($_GET['pk_owner'], $_GET['genre']));
    $r = '<tr><th></th><th>Full Name</th><th>Relationship</th><th>Gender</th><th>Birth Date</th><th>Birth Place</th><th>Civil Status</th><th>Years of Residency</th><th>Occupation</th><th>Highest Education Attainment</th></tr>';
    foreach ($residents as $k => $v) {
        $r = $r . '<tr>';
        foreach ($v as $k2 => $v2) {
            if (isset($_GET['edit']) && $k2 === 'id') {
                $r = $r . '<td><button value="' . $v2 . '" style="float:right" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-remove"></span> </button></td>';
            } else {
                if ($k2 !== 'id') {
                    $r = $r . '<td>' . $v2 . '&nbsp;</td>';
                }
            }
        }
        $r = $r . '</tr>';
    }
    echo $r;
}
<?php

require $_SERVER['DOCUMENT_ROOT'] . "/lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $db = new DbManager();
    if (empty($_POST['pk_owner'])) {
        $id = $db->execute("INSERT INTO owners (house_number, type_of_ownership_id, full_name, address, birth_date, birth_place, citizenship, religion, highest_education_attainment_id, years_of_residency, civil_status_id, occupation, gender_id, deleted) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", array($_POST['house_number'], $_POST['type_of_ownership_id'], $_POST['full_name'], $_POST['address'], $_POST['birth_date'], $_POST['birth_place'], $_POST['citizenship'], $_POST['religion'], $_POST['highest_education_attainment_id'], $_POST['years_of_residency'], $_POST['civil_status_id'], $_POST['occupation'], $_POST['gender_id'], 0));
        echo $id;
    } else {
        $id = $db->execute("UPDATE owners SET house_number = ?, type_of_ownership_id = ?, full_name = ?, address = ?, birth_date = ?, birth_place = ?, citizenship = ?, religion = ?, highest_education_attainment_id = ?, years_of_residency = ?, civil_status_id = ?, occupation = ?, gender_id = ? WHERE id = ?;", array($_POST['house_number'], $_POST['type_of_ownership_id'], $_POST['full_name'], $_POST['address'], $_POST['birth_date'], $_POST['birth_place'], $_POST['citizenship'], $_POST['religion'], $_POST['highest_education_attainment_id'], $_POST['years_of_residency'], $_POST['civil_status_id'], $_POST['occupation'], $_POST['gender_id'], $_POST['pk_owner']));
        echo $id;
    }
}
<?php

include "../includes/header.php";
include "../includes/sidebar.php";
require '../lib/db.php';
if (isset($_POST['id'])) {
    $id = $_SESSION['login_id'];
    $db = new DbManager();
    if ($_POST['password'] == "") {
        $query = $db->execute("UPDATE users SET full_name = ? WHERE id = ?", array($_POST['full_name'], $id));
        header("location: user_settings.php");
        $_SESSION['info'] = 'Successfully updated!';
        $_SESSION['login_full_name'] = $_POST['full_name'];
    } else {
        $query = $db->execute("UPDATE users SET full_name = ?, password = md5(?) WHERE id = ?", array($_POST['full_name'], $_POST['password'], $id));
        header("Refresh:0");
        $_SESSION['info'] = 'Successfully updated!';
        $_SESSION['login_full_name'] = $_POST['full_name'];
    }
}
?>
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header"><i class="fa fa-gear fa-fw"></i> User Settings</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
               <div class="col-lg-6">
<?php

include "includes/header.html";
include "includes/sidebar.html";
require "lib/db.php";
$db = new DbManager();
$pos = $db->execute("SELECT id, name FROM positions ORDER BY id ASC", array());
?>
 
        <div id="page-wrapper">
            <div id="message"></div>
            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                           System Users
                        </h1>
                    </div>
                </div>
                <!-- /.row -->

				<div class="panel panel-info">
			  <div class="panel-heading">
			  <button style="float:right" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#myModalAdd"><span class="glyphicon glyphicon-plus"></span> Add New</button>
				<h3 class="panel-title">
				List of system users</h3>
			  </div>
			  <div class="panel-body">
			  <table class="table table-hover">
         $where = $where . " '%" . $v[1] . "%' ";
     } else {
         if ($type === 'str' && strpos($k, 'Gender') === 0) {
             $where = $where . " '" . $v[1] . "' ";
         } else {
             if ($type === 'int') {
                 $where = $where . " " . $v[1] . " ";
             }
         }
     }
     if ($first) {
         $first = false;
     }
 }
 $sql = $sql1 . $where . ' UNION ' . $sql2 . $where;
 $residents = $db->execute($sql, array());
 $h = '<thead><tr>';
 if (count($residents) > 0) {
     foreach ($residents[0] as $k => $v) {
         $h = $h . '<td>' . $k . '&nbsp;</td>';
     }
     $h = $h . '</tr></thead>';
 }
 $r = '<tbody>';
 foreach ($residents as $k => $v) {
     $r = $r . '<tr>';
     foreach ($v as $k2 => $v2) {
         $r = $r . '<td>' . $v2 . '&nbsp;</td>';
     }
     $r = $r . '</tr>';
 }
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_FILES['image']['type'] === 'image/jpeg') {
        $ext = '.jpg';
    } else {
        if ($_FILES['image']['type'] === 'image/png') {
            $ext = '.png';
        }
    }
    $filepath = DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR . "users" . DIRECTORY_SEPARATOR . time() . $ext;
    move_uploaded_file($_FILES['image']['tmp_name'], '..' . $filepath);
    $db = new DbManager();
    $db->execute("UPDATE users SET name = ?, position_id = ?, contact_number = ?, profile_image_path = ? WHERE id = ?;", array($_POST['name'], $_POST['position'], $_POST['contact_number'], $filepath, $_POST['id']));
}
        if ($_SERVER["REQUEST_METHOD"] == "GET" && !empty($_GET['words'])) {
            $condition = "WHERE first_name LIKE ? OR middle_name LIKE ? OR last_name LIKE ? OR suffix LIKE ? OR address_line_1 LIKE ? OR address_line_2 LIKE ? OR address_line_3 LIKE ? OR address_line_4 LIKE ? OR address_line_5 LIKE ? OR citizenship LIKE ?";
            $words = preg_split('/[\\s]+/', $_GET['words'], -1, PREG_SPLIT_NO_EMPTY);
            $word = $words[0];
            $param = array('%' . $word . '%', '%' . $word . '%', '%' . $word . '%', '%' . $word . '%', '%' . $word . '%', '%' . $word . '%', '%' . $word . '%', '%' . $word . '%', '%' . $word . '%', '%' . $word . '%');
        } else {
            if (!empty($_GET['page'])) {
                $page = (int) $_GET['page'];
            }
        }
    }
}
$db = new DbManager();
$offset = ($page - 1) * 10;
$sql = "SELECT id, CONCAT(first_name, ' ', IFNULL(middle_name, ''), ' ', last_name, ' ', IFNULL(suffix, '')) as full_name, birth_date, TIMESTAMPDIFF(YEAR,birth_date,CURDATE()) AS age, CONCAT(address_line_1, ' ', address_line_2, ' ', address_line_3, ' ', address_line_4, ' ', address_line_5) AS address FROM residents {$condition} ORDER BY modified_date_time DESC LIMIT {$offset}, 10;";
$residents = $db->execute($sql, $param);
$count = $db->execute("SELECT COUNT(1) AS c FROM residents {$condition} ;", $param);
$number_of_pages = (int) ceil($count[0]['c'] / 10);
?>

        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Resident Registration
                        </h1>
                    </div>
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $db = new DbManager();
    $residents = $db->execute("SELECT\n              own.house_number\n            , gen.name AS gender\n            , res.full_name\n            , own.address\n            , res.birth_date\n            , res.birth_place\n            , res.citizenship\n            , res.religion\n            , edu.name AS education\n            , res.years_of_residency\n            , civ.name AS civil_status\n            , res.occupation\n            , sts.name AS status\n        FROM residents res\n        LEFT OUTER JOIN relationships rel\n        ON rel.id = res.relationship_id\n        LEFT OUTER JOIN genders gen\n        ON gen.id = res.gender_id\n        LEFT OUTER JOIN civil_statuses civ\n        ON civ.id = res.civil_status_id\n        LEFT OUTER JOIN statuses sts\n        ON sts.id = res.status_id\n        LEFT OUTER JOIN educations edu\n        ON edu.id = res.highest_education_attainment_id\n        LEFT OUTER JOIN owner_residents ors\n        ON ors.resident_id = res.id\n        LEFT OUTER JOIN owners own\n        ON own.id = ors.owner_id\n        WHERE ors.resident_id = ?\n        ORDER BY res.id ASC;\n        ", array($_GET['resident_id']));
    $r = '{';
    foreach ($residents as $k => $v) {
        foreach ($v as $k2 => $v2) {
            $r = $r . '"' . $k2 . '":"' . $v2 . '",';
        }
    }
    $r = preg_replace("/,\$/", "", $r);
    $r = $r . '}';
    echo $r;
}
<?php

include "../config/db_config.php";
include "../includes/header.php";
include "../includes/sidebar.php";
require "../lib/db.php";
require "../lib/util.php";
?>

<?php 
$db = new DbManager();
$genders = $db->execute("SELECT id, name FROM genders ORDER BY id ASC", array());
$ownerships = $db->execute("SELECT id, name FROM ownerships ORDER BY id ASC", array());
$educations = $db->execute("SELECT id, name FROM educations ORDER BY id ASC", array());
$civil_statuses = $db->execute("SELECT id, name FROM civil_statuses ORDER BY id ASC", array());
$relationships_dependent = $db->execute("SELECT id, name FROM relationships WHERE genre = 1 ORDER BY id ASC", array());
$relationships_boarder = $db->execute("SELECT id, name FROM relationships WHERE genre = 2 ORDER BY id ASC", array());
$statuses = $db->execute("SELECT id, name FROM statuses ORDER BY id ASC", array());
$owner_id = $_GET['owner_id'];
if (isset($_GET['resident_id'])) {
    $resident_id = $_GET['resident_id'];
} else {
    $resident_id = '1000000';
}
if (isset($_GET["resident_id"])) {
    $sqlResident = "\n\t\tselect\n\t\thouse_number\n\t\t, gen.name as gender\n\t\t, res.full_name\n\t\t, own.address\n\t\t, res.birth_date\n\t\t, res.birth_place\n\t\t, res.citizenship\n\t\t, res.religion\n\t\t, gen.id AS gen_id\n\t\t, gen.name as gender\n\t\t, edu.id AS edu_id\n\t\t, edu.name as education\n\t\t, res.years_of_residency\n\t\t, civ.id AS civ_id\n\t\t, civ.name as civil_statuses\n\t\t, res.occupation\n\t\t, sts.id AS sts_id\n\t\t, sts.name as status\n\t\t, rel.id AS rel_id\n\t\t, rel.genre AS rel_genre\n\t\t, rel.name AS relationship\n\t\tfrom residents res\n\t\tinner join owner_residents ors\n\t\ton ors.resident_id = resident_id\n\t\tinner join owners own\n\t\ton own.id = ors.owner_id\n\t\tinner join educations edu\n\t\ton edu.id = res.highest_education_attainment_id\n\t\tleft outer join statuses sts\n\t\ton sts.id = res.status_id\n\t\tinner join civil_statuses civ\n\t\ton civ.id = res.civil_status_id\n\t\tinner join genders gen\n\t\ton gen.id = res.gender_id\n\t\tinner join relationships rel\n\t\ton rel.id = res.relationship_id\n\t\twhere res.id = " . $_GET["resident_id"];
    $resultResident = $conn->query($sqlResident);
    $rowResident = $resultResident->fetch_assoc();
} else {
    $sqlOwner = "\n\t\tselect\n\t\town.house_number\n\t\t, gen.name as gender\n\t\t, own.full_name\n\t\t, own.address\n\t\t, own.birth_date\n\t\t, own.birth_place\n\t\t, own.citizenship\n\t\t, own.religion\n\t\t, edu.name as education\n\t\t, own.years_of_residency\n\t\t, civ.name as civil_status\n\t\t, own.occupation\n\t\t, sts.name as status\n\t\tfrom owners own\n\t\tinner join educations edu\n\t\ton edu.id = own.highest_education_attainment_id\n\t\tleft outer join statuses sts\n\t\ton sts.id = own.status_id\n\t\tinner join civil_statuses civ\n\t\ton civ.id = own.civil_status_id\n\t\tinner join genders gen\n\t\ton gen.id = own.gender_id\n\t\twhere own.id = " . $owner_id;
    $resultOwner = $conn->query($sqlOwner);
<?php

require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $db = new DbManager();
    $db->execute("DELETE FROM residents WHERE id = ?;", array($_POST['id']));
    $db->execute("DELETE FROM owner_residents WHERE resident_id = ?;", array($_POST['id']));
}
<?php

include "includes/header.html";
include "includes/sidebar.html";
require "lib/db.php";
require "lib/util.php";
$db = new DbManager();
$genders = $db->execute("SELECT id, name FROM genders ORDER BY id ASC", array());
$martial_statuses = $db->execute("SELECT id, name FROM martial_statuses ORDER BY id ASC", array());
?>
  

        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Resident Registration
                        </h1>
                    </div>
                </div>
                <!-- /.row -->
			<form role="form" method="post" action="registration.php">
			
			<div class="panel panel-info">
			  <div class="panel-heading">
				<h3 class="panel-title">Personal Information</h3>
			  </div>