You are on page 1of 13

ADDING FOREIGN KEY

FOREIGN KEY TO REGISTER TABLE ID


CREATE TABLE additional_info (
info_id INT AUTO_INCREMENT PRIMARY KEY,
register_id INT,
additional_data VARCHAR(255),
FOREIGN KEY (register_id) REFERENCES register(id)
);

DATABASE CONNECTION FUNCTION


<?php
function config() {
$host = "localhost";
$email = "root";
$password = "";
$database = "brgy";

$con = mysqli_connect($host, $email, $password, $database);

if ($con->connect_error) {
die('Connection Failed : ' . $con->connect_error);
} else {
return $con;
}
}
function logout() {
if (!isset($_SESSION)) {
session_start();
}
$_SESSION['id'] = null;
unset($_SESSION['id']);
}
?>

CREATE READ UPDATE DELETE

<!DOCTYPE html>
<html>
<head>
<title>PHP INSERT UPDATE DELETE SEARCH</title>
</head>
<style>
table, th, td{
border: 1px solid black;
border-collapse: collapse;
padding: 5px;}
table{
margin-bottom: 20px;}
.add-form {
display: none;}
#showAddForm:checked ~ .add-form {
display: block;}
</style>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "brgy";

// Create connection
$con = new mysqli($servername, $username, $password, $dbname);

// DELETE operation
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['delete'])) {
$id = $_POST['id'];

$sql = "DELETE FROM user_data WHERE id=$id";


if ($con->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $con->error;
}
}
?>
<form action="" method="post">
<h2>Search Records</h2>
<input type="text" name="searchKeyword" placeholder="Last / Middle / First Name">
<input type="submit" name="search" value="Search">
</form><br>

<input type="checkbox" id="showAddForm">


<label for="showAddForm">Add Record</label><br><br>
<form action="" method="post" class="add-form">
<label>Full Name</label><br>
<input type="text" name="lname" placeholder="Last Name"><br>
<input type="text" name="fname" placeholder="First Name"><br>
<label>Address</label><br>
<input type="number" name="housenumber" placeholder="House Number"><br>
<input type="text" name="brgy" placeholder="Barangay"><br>
<input type="text" name="city" placeholder="City"><br><br>
<label>Birthdate</label><br>
<input type="date" name="birth"><br><br>
<label>Resident Type</label><br>
<select name="resident" required>
<option disabled selected>Please select</option>
<option value="Resident"> Resident </option>
<option value="Barangay Official">Barangay Official</option>
</select> <br><br>
<input style='font-size:15px;' type="submit" name="insert" value="Submit"> <br><br><br><br>
</form>
<?php
$rows = [];
if (isset($result) && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
}
//<button onclick="window.location.href='add.php'" style="float:right">Add Resident</button>
//<a href="index.php">Back</a>
?>
<table class="module1">
<tr>
<th>Resident Name and Date of Birth</th>
<th colspan='4'>Generated Resident Number</th>
</tr>
<?php
foreach ($rows as $row) {
echo "<tr>";
echo "<td>" . $row['lname'] . ", " . $row['fname'] . " " . $row['mname'] . "<br>" . date('F j, Y', strtotime($row['birth'])) . "<br>" . $row['housenumber'] . "
" . $row['street'] . " , " . $row['brgy'] . " ," . $row['zip'] . ", " . $row['city'] . "<br>" . $row['resident'] . "</td>";
echo "<td>" . $row['resident_id'] . "</td>";
echo "<td>";
echo "<form action='' method='post' onsubmit=\"return confirm('Are you sure you want to edit ". $row['lname'] . ", " . $row['fname'] . " " .
$row['mname'] . " record?');\">";
echo "<input type='hidden' name='id' value='" . $row['id'] . "'>";
echo "<input type='submit' name='edit' value='Edit'>";
echo "</form>";
echo "</td>";

echo "<td>";
echo "<form action='' method='post' onsubmit=\"return confirm('Are you sure you want to start transaction in ". $row['lname'] . ", " . $row['fname'] . "
" . $row['mname'] . "?');\">";
echo "<input type='hidden' name='id' value='" . $row['id'] . "'>";
echo "<input type='submit' name='transact' value='Transact'>";
echo "</form>";
echo "</td>";
echo "<td>";
echo "<form action='' method='post' onsubmit=\"return confirm('Are you sure you want to delete ". $row['lname'] . ", " . $row['fname'] . " " .
$row['mname'] . " record?');\">";
echo "<input type='hidden' name='id' value='" . $row['id'] . "'>";
echo "<input type='submit' name='delete' value='Delete'>";
echo "</form>";
echo "</td>";
echo "</tr>";
}
?>
</table>
<table class="module2">
<tr>
<th>Fields</th>
<th>Values</th>
</tr>
<?php
foreach ($rows as $row) {
$community_tax = 0;
$income = floatval($row['income']); // Convert income to float

if ($row['resident'] === 'Tenant') {


$additional_tax = floor($income / 1000) + 25;
$community_tax = 5 + $additional_tax;
} elseif ($row['resident'] === 'Homeowner') {
$additional_tax = floor($income / 1000);
$community_tax = 5 + $additional_tax;
}
echo "<tr>";
echo "<td>Resident Number</td><td>" . $row['resident_id'] . "</td></tr>";
echo "<tr><td>Resident Name</td><td>" . $row['lname'] . ", " . $row['fname'] . " " . $row['mname'] . "</td></tr>";
echo "<tr><td>Date of Birth</td><td>" . date('M j, Y', strtotime($row['birth'])) . "</td></tr>";
echo "<tr><td>Address</td><td>" . $row['housenumber'] . " " . $row['street'] . " , " . $row['brgy'] . " ," . $row['zip'] . ", " . $row['city'] . "</td></tr>";
echo "<tr><td>Resident Type</td><td>" . $row['resident'] . "</td></tr>";
echo "<tr><td colspan='2' style='background-color:white;border:none;'></td></tr>";
echo "<tr><td style='border:none;padding-left: 15px;'>Resident Number: " . $row['resident_id'] . "</td></tr>";
echo "<tr><td style='border:none;padding-left: 15px;'>Gross Annual Income: PhP " . number_format((float)$row['income'], 2, '.', ',') . "</td></tr>";
//echo "<tr><td colspan='2' style='background-color:white;border:none;'></td></tr>";
echo "<tr><td style='border:none;padding-left: 15px;'>Community tax certificate: PhP " . number_format((float)$community_tax, 2, '.', ',') .
"</td></tr>";
echo "</tr>";
}
?>
</table>

LOGIN PAGE

// SEARCH operation
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['search'])) {
$searchKeyword = $_POST['searchKeyword'];
$sql = "SELECT * FROM user_data WHERE lname LIKE '%$searchKeyword%' OR fname LIKE '%$searchKeyword%'";
$result = $con->query($sql);
} else {
// READ operation (when no search is performed)
$sql = "SELECT * FROM user_data";
$result = $con->query($sql);
}

// CREATE operation
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['insert'])) {
$fname = strtoupper($_POST['fname']);
$lname = strtoupper($_POST['lname']);
$mname = strtoupper($_POST['mname']);
$housenumber = $_POST['housenumber'];
$street = $_POST['street'];
$zip = $_POST['zip'];
$brgy = $_POST['brgy'];
$city = $_POST['city'];
$birth = $_POST['birth'];
$resident = $_POST['resident'];
$formatted_birthdate = strtoupper(date('dM', strtotime($birth))) . date('Y', strtotime($birth));

$resident_id = strtoupper(substr(preg_replace('/[^a-zA-Z]/', '', $lname), 0, 3)) . '-' . $housenumber . strtoupper(substr(preg_replace('/[^a-zA-Z]/', '',


$street), 0, 3)) . $zip . '-' . $formatted_birthdate;

$sql = "INSERT INTO user_data (resident_id, lname, fname, mname, housenumber, street, zip, city, birth, resident,brgy) VALUES ('$resident_id',
'$lname', '$fname', '$mname', '$housenumber', '$street', '$zip', '$city', '$birth', '$resident','$brgy')";
if ($con->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
}

<?php
if (isset($_POST['submit'])) {
$usernameOrMobile = mysqli_real_escape_string($con, $_POST['usernameOrMobile']);
$password = mysqli_real_escape_string($con, $_POST['password']);
if (empty($usernameOrMobile) || empty($password)) {
$registerErrorMsg = "Username or password is empty.";
} else {
if (substr($usernameOrMobile, 0, 2) === '09') {
$usernameOrMobile = '+63' . substr($usernameOrMobile, 1);
}
$sql = "SELECT id, username, mobile, password, approval_status
FROM register
WHERE (username = '$usernameOrMobile' OR mobile = '$usernameOrMobile')";
$result = $con->query($sql);
if ($result) {
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$storedHashedPassword = $row["password"];
if (password_verify($password, $storedHashedPassword)) {
$_SESSION['id'] = $row['id'];
header("Location: resident/announcement.php");
exit();
}
} else {
$registerErrorMsg = "Error in database query: " . $con->error;
}
}
}
?>
<body>
<div class="form">
<form method="post" action="" class="form-container">
<h1 style="font-size: 30px;">LOGIN</h1><br>
<label for="username">Username or Phone number</label>
<input type="text" id="username" name="usernameOrMobile">
<label for="pass">Password</label>
<div class="password-wrapper">
<input type="password" id="password" name="password">
</div>
<input type="submit" value="Login" name="submit">
<p>Don't have an account? <a href="Rsignup.php">Sign up now</a></p>
</form>

SIGNUP– email/pass

// UPDATE operation
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST['edit'])) {
if (isset($_POST['id'])) {
$id = $_POST['id'];

$sql = "SELECT * FROM user_data WHERE id = $id";


$edit_result = $con->query($sql);

if ($edit_result->num_rows > 0) {
$row = $edit_result->fetch_assoc();

echo "<h2>Edit Record</h2>";


echo "<form action='' method='post'>";
echo "<input type='hidden' name='id' value='" . $row['id'] . "'>";
echo "<input type='text' name='lname' value='" . $row['lname'] . "'><br>";
echo "<input type='text' name='fname' value='" . $row['fname'] . "'><br>";
echo "<input type='text' name='mname' value='" . $row['mname'] . "'><br>";
echo "<input type='number' name='housenumber' value='" . $row['housenumber'] . "'><br>";
echo "<input type='text' name='street' value='" . $row['street'] . "'><br>";
echo "<input type='text' name='brgy' value='" . $row['brgy'] . "'><br>";
echo "<input type='number' name='zip' value='" . $row['zip'] . "'><br>";
echo "<input type='text' name='city' value='" . $row['city'] . "'><br>";
echo "<input type='text' name='income' value='" . $row['income'] . "'><br>";
echo "<input type='date' name='birth' value='" . $row['birth'] . "'><br>";
echo "<label>Resident Type</label>";
echo "<select name='resident' required>";
echo "<option value='Homeowner' " . (($row['resident'] == 'Homeowner') ? 'selected' : '') . ">Homeowner</option>";
echo "<option value='Tenant' " . (($row['resident'] == 'Tenant') ? 'selected' : '') . ">Tenant</option>";
echo "</select><br><br>";

echo "<input type='submit' name='update' style='font-size:15px;' value='Submit'> ";


echo "</form><br><br><br><br><br><br><br>";
}
}
}

// TRANSACT operation
if (isset($_POST['transact'])) {
if (isset($_POST['id'])) {
$id = $_POST['id'];
$sql = "SELECT * FROM user_data WHERE id = $id";
$transact_result = $con->query($sql);

if ($transact_result && $transact_result->num_rows > 0) {


$row = $transact_result->fetch_assoc();

echo "<h2>Transact Record</h2>";


echo "<form action='' method='post'>";
echo "<input type='hidden' name='id' value='" . $row['id'] . "'>";
echo "<label>Resident Number: </label>";
echo "<label>" . $row['resident_id'] . "</label><br>";
echo "<label>Resident Type: </label>";
echo "<label>" . $row['resident'] . "</label><br>";
echo "</select><br>";
echo "<label>Gross Annual Income:</label><br>";
echo "<input type='text' name='income' value='" . $row['income'] . "'><br><br>";
echo "<input type='submit' name='trans' value='Transact Record'>";
echo "</form>";
}
}
}

// HANDLE TRANSACT
if (isset($_POST['trans'])) {
if (isset($_POST['income'], $_POST['id'])) {
$income = $_POST['income'];
$id = $_POST['id'];

$sql = "UPDATE user_data SET income='$income' WHERE id=$id";


if ($con->query($sql) === TRUE) {
echo "Income updated successfully";
} else {
echo "Error updating income: " . $con->error;
}
}
}

if (isset($_POST['update'])) {
if (isset($_POST['fname'], $_POST['lname'], $_POST['mname'], $_POST['housenumber'], $_POST['street'], $_POST['zip'], $_POST['brgy'],
$_POST['city'], $_POST['birth'], $_POST['resident'], $_POST['id'])) {

$fname = strtoupper($_POST['fname']);
$lname = strtoupper($_POST['lname']);
$mname = strtoupper($_POST['mname']);
$housenumber = $_POST['housenumber'];
$street = $_POST['street'];
$zip = $_POST['zip'];
$brgy = $_POST['brgy'];
$income = $_POST['income'];
$city = $_POST['city'];
$birth = $_POST['birth'];
$resident = $_POST['resident'];
$formatted_birthdate = strtoupper(date('dM', strtotime($birth))) . date('Y', strtotime($birth));

$resident_id = strtoupper(substr(preg_replace('/[^a-zA-Z]/', '', $lname), 0, 3)) . '-' . $housenumber . strtoupper(substr(preg_replace('/[^a-zA-Z]/', '',


$street), 0, 3)) . $zip . '-' . $formatted_birthdate;

$id = $_POST['id'];

$sql = "UPDATE user_data SET lname='$lname', fname='$fname', mname='$mname', housenumber='$housenumber', street='$street', zip='$zip',
city='$city', birth='$birth', resident='$resident', resident_id='$resident_id',brgy='$brgy',income='$income' WHERE id=$id";

if ($con->query($sql) === TRUE) {


echo "Record updated successfully";
} else {
echo "Error updating record: " . $con->error;
}
} else {
echo "Some form fields are missing in the POST request.";
}
}
}

CREATE TABLE user_data (


id int(11) NOT NULL AUTO_INCREMENT,
resident_id varchar(255) NOT NULL,
fname varchar(50),
lname varchar(50),
mname varchar(50) NOT NULL,
housenumber int(11),
street varchar(100),
zip int(11),
city varchar(50), birth date,
resident varchar(25) NOT NULL,
brgy varchar(50) NOT NULL,
income varchar(20) NOT NULL, );

<?php
if (!isset($_SESSION)){
session_start();
}
include_once("connection/connection.php");
$con = config();

if (isset($_POST['createacc'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$confirmPassword = $_POST['confirmPassword'];

if ($password != $confirmPassword) {
$errorMsg = 'Passwords do not match. Please try again.';
} else if (!preg_match('/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/', $password)) {
$errorMsg = 'Passwords must be at least 8 characters long and contain at least one uppercase and lowercase letter, and one number.';
} else {
$sql = "SELECT * FROM register WHERE username='$username'";
$result = mysqli_query($con, $sql);

if (mysqli_num_rows($result) > 0) {
$errorMsg = 'Username already taken. Please choose a different username.';
} else {
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$approval_status = 'Pending';

$sql = "INSERT INTO register (username, password, firstName,middleName, lastName, birthdate, age, mobile, proof)
VALUES ('$username', '$hashed_password', '$firstName','$middleName', '$lastName', '$birthdate','$age, '$username','$pname',)";

if (mysqli_query($con, $sql)) {
$inserted_id = mysqli_insert_id($con);
header("Location: RsignupInfo.php?id=" . $inserted_id);
exit;
} else {

echo "Error: " . mysqli_error($con);


}
}
}
mysqli_close($con);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Resident Signup</title>
</head>
<body>
<form name="signupFrm" onsubmit="return validateForm()" action="" method="post" class="form" id="signup-form">
<h2 class="title">Sign-up</h2>
<div class="inputContainer">
<input type="text" pattern="^^\w{5,20}$" name="username" class="input" id="username" placeholder="Enter username" required>
<label for="username" class="label">Username</label>
</div>
<div class="inputContainer">
<input id="password" name="password" type="password" class="input" placeholder="Password" required>
<label for="password" class="label">Password</label>
</div>
<div class="inputContainer">
<input name="confirmPassword" id="confirmPassword" type="password" class="input" placeholder="Confirm Password" required>
<label for="confirmPassword" class="label">Confirm Password</label>
</div>
<button type="submit" class="next" name="createacc">Next &raquo;</button>
<a href="index.php" class="previous" id="previous">&laquo; Back</a>

SIGNUP – PERSONAL INFORMATION

<?php
session_start();
include_once("connection/connection.php");
$con = config();
if (isset($_POST['createacc'])) {
$id = $_GET['id'];
$firstName = mysqli_real_escape_string($con, ($_POST['firstName']));
$lastName = mysqli_real_escape_string($con, ($_POST['lastName']));
$middleName = mysqli_real_escape_string($con, ($_POST['middleName']));
$birthdate = mysqli_real_escape_string($con, $_POST['birthdate']);
$mobile = mysqli_real_escape_string($con, $_POST['mobile']);
$age = mysqli_real_escape_string($con, $_POST['age']);
$mobile = '+63' . substr($mobile, 1);
$pname = rand(1000, 10000) . "-" . $_FILES["proof"]["name"];
$tname = $_FILES["proof"]["tmp_name"];
$upload_dir = $_SERVER['DOCUMENT_ROOT'] . "/upload_image";
else {
$sql = "UPDATE register SET firstName='$firstName', lastName='$lastName',birthdate='$birthdate', age='$age', mobile='$mobile', proof='$pname'
WHERE id = '$id'";
$result = mysqli_query($con, $sql);
if (empty($errorMessage) && empty($mobileError)) {
if ($result) {
echo '<div class="message.success">Data successfully updated. Please wait...</div>';
echo '<script>
setTimeout(function() {
window.location.href = "index.php";
}, 3000); // 3 seconds delay
</script>';
exit;
} else {
echo '<div class="message error">Error updating data: ' . mysqli_error($con) . '</div>';
}
}
}
mysqli_close($con);
}
unset($_SESSION['id']);
?>
<!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.0">
<title>Sign-up Information</title>
</head>
</style>
<script src="script.js" defer></script>
<body>
<div class="container">

<header>Personal Details</header>
<form action="" method="post" onsubmit="return validateForm()" enctype="multipart/form-data">
<div class="form first">
<div class="details personal">
<div class="fields">
<div class="input-field">
<label>First Name</label>
<input type="text" placeholder="First Name" name="firstName" required>
</div>
<div class="input-field">
<label>Middle Name</label>
<input type="text" placeholder="Middle Name" name="middleName">
</div>
<div class="input-field">
<label>Last Name</label>
<input type="text" placeholder="Last Name" name="lastName" required>
</div>
<div class="input-field">
<label>Date of Birth</label>
<input type="date" placeholder="Enter birth date" name="birthdate" required>
</div>
<div class="input-field">
<label>Age <small>(at least 18 years old and above)</small></label>
<input type="number" placeholder="Enter your age" name="age" required min="18" readonly>
</div>
<div class="input-field">
<label for="mobile">Mobile Number</label>
<input type="tel" id="mobile" name="mobile" pattern="09[0-9]{9}" placeholder="09XXXXXXXXX" required maxlength='11'>
</div>
<div class="input-field">
<label for="proof">Proof of Residency</label>
<p style="font-size: 12px;">(ex: water or electricity bills, rental agreements, and Voter registration card)</p>
<input type="file" id="proof" name="proof" accept="image/jpeg, image/png, image/gif" required>
</div>
<div class="input-field">
<button class="" name="createacc" style="margin: 0 30px;">Submit</button>
</div>
</div>
</div>
</form>

TRANSACTION MODULE – ADMIN


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="../pics/maragondon logo.png" type="image/icon type">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="main-container">
<sidebar>
<ul>
<li><a href="transaction.php">Transaction</a></li>
<li><a href="resident.php">Resident</a></li>
</ul>
</sidebar>
<main>
<div class="header-row">
<h2>Transactions</h2>
<input type="text" id="searchBar" placeholder="Search...">
</div>

<h3 style="text-align: left;">Complaints</h3><br>


<?php
$sql = "SELECT c.*, r.firstName, r.lastName,
DATE_FORMAT(c.complaint_date, '%M %d, %Y %h:%i %p') AS formatted_date
FROM complaint c
JOIN register r ON c.user_id = r.id
WHERE r.id IS NOT NULL
ORDER BY c.complaint_date ASC";
$result = $con->query($sql);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST["updateStatus"])) {
$complaintId = $_POST["complaintId"];
$Status = $_POST["Status"];
$remarks = ""; // Default value for remarks

if ($Status === 'Acknowledged') {


$remarks = "Please wait for the available officials that will take action.";
} elseif ($Status === 'Investigating') {
$remarks = "Let us investigate for 1 week to verify your concern.";
} elseif ($Status === 'Resolved') {
$remarks = "If you have any more concerns, feel free to contact us. Thank you for your patience.";
} elseif ($Status === 'Rejected') {
$remarks = "We have carefully reviewed your complaint. Based on the information, we are unable to proceed with your request at this time.";
}

// Perform an update query to change the status and remarks


$updateStatusQuery = "UPDATE complaint SET status = '$Status', remarks = '$remarks' WHERE id = $complaintId";
$con->query($updateStatusQuery);
} elseif (isset($_POST["updateAssignedOfficial"])) {
$complaintId = $_POST["complaintId"];
$newAssignedOfficial = $_POST["newAssignedOfficial"];
// Perform an update query to change the assigned official
$updateAssignedOfficialQuery = "UPDATE complaint SET assigned_Official = '$newAssignedOfficial' WHERE id = $complaintId";
$con->query($updateAssignedOfficialQuery);
}
elseif (isset($_POST["editRemarks"])) {
$complaintId = $_POST["complaintId"];
$editedRemarks = $_POST["editedRemarks"];
$updateRemarksQuery = "UPDATE complaint SET remarks = '$editedRemarks' WHERE id = $complaintId";
$con->query($updateRemarksQuery);
}
}
?>
<table style="max-height: 400px; overflow-y: auto;">
<thead>
<tr>
<th>Complainant</th>
<th>Type</th>
<th>Complainee</th>
<th>Description</th>
<th>Date of Complaint</th>
<th>Assigned Official</th>
<th>Status</th>
<th>Remarks</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
// Skip resolved complaints from being displayed
if ($row['status'] === 'Resolved' || $row['status'] === 'Rejected') {
continue;
}
echo "<tr>";
echo "<td>" . $row['firstName'] . " " . $row['lastName'] . "</td>";
echo "<td>" . $row['complaint_type'] . "</td>";
echo "<td>" . $row['complainee'] . "</td>";
echo "<td class='description'>" . $row['complaint_description'] . "</td>";
echo "<td>" . $row['formatted_date'] . "</td>";
echo "<td>" . $row['assigned_Official'] . "</td>";
echo "<td>" . $row['status'] . "</td>";
echo "<td>" . $row['remarks'] . "</td>"; // Display remarks
echo "<td>";
echo "<form method='post' action=''>";
echo "<input type='hidden' name='complaintId' value='" . $row['id'] . "'>";
echo "<select name='Status'>
<option value=''>Choose</option>
<option value='Rejected'>Rejected</option>
<option value='Acknowledged'>Acknowledged</option>
<option value='Investigating'>Investigating</option>
<option value='Resolved'>Resolved</option>
</select>";
echo "<button type='submit' name='updateStatus' onclick='return confirmUpdate()'>Update Status</button><br>";
echo "<select name='newAssignedOfficial'>
<option value='Not yet assigned'>Choose</option>
<option value='Ramil Delfin'>Ramil Delfin</option>
<option value='Peter Senobio'>Peter Senobio</option>
<option value='Edmon Tuico'>Edmon Tuico</option>
</select>";
echo "<button type='submit' name='updateAssignedOfficial' onclick='return confirmUpdate()'>Update Officer</button>";
echo "</form>";
echo "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='9'>No complaints found.</td></tr>";
}
?>
</tbody>
</table>
</main>
</div>
</body>
</html>

TRANSACTION MODULE– RESIDENT


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="main-container">
<sidebar>
<ul>
<li><a href="transaction.php">Transaction</a></li>
<li><a href="helpdesk.php">Help Desk</a></li>
</ul>
</sidebar>
<main>
<h2>Transactions</h2>
<?php
$user_id = $_SESSION['id']; // Assuming you have the user's ID in the session

$sql = "SELECT c.*, r.firstName, r.lastName, r.id,


DATE_FORMAT(c.complaint_date, '%M %d, %Y %h:%i %p') AS formatted_date
FROM complaint c
JOIN register r ON c.user_id = r.id
WHERE r.id IS NOT NULL AND r.id = $user_id";
$result = $con->query($sql);
?>
<table style="overflow: auto;">
<h2 style="text-align: left;">Complaint</h2><hr><br>
<thead>
<tr>
<th>Complainant</th>
<th>Type</th>
<th>Complainee</th>
<th>Description</th>
<th>Date Published</th>
<th>Assigned Official</th>
<th>Status</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row['firstName'] . " " . $row['lastName'] . "</td>"; // Combine first and last name
echo "<td>" . $row['complaint_type'] . "</td>"; // Use 'complaint_type' instead of 'type'
echo "<td>" . $row['complainee'] . "</td>";
echo "<td>" . $row['complaint_description'] . "</td>"; // Use 'complaint_description' instead of 'description'
echo "<td>" . $row['formatted_date'] . "</td>"; // Use 'complaint_date' instead of 'date'
echo "<td>" . $row['assigned_Official'] . "</td>"; // Use 'assigned_Official' instead of 'assigned_official'
echo "<td>" . $row['status'] . "</td>";
echo "<td>" . $row['remarks'] . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='7', rowspan='2'>No complaints found.</td></tr>";
}
?>
</tbody>
</table><br><br>
<?php
$user_id = $_SESSION['id']; // Assuming you have the user's ID in the session
$sql = "SELECT r.*, re.firstName, re.lastName, re.id,
DATE_FORMAT(r.created_at, '%M %d, %Y %h:%i %p') AS formatted_date
FROM request_form r
JOIN register re ON r.user_id = re.id
WHERE re.id IS NOT NULL AND re.id = $user_id";
$result = $con->query($sql);
?>
<table style="overflow: auto;"><h2 style="text-align: left;">Certificates</h2><hr><br>
<thead>
<tr>
<th>Requestor</th>
<th>Type</th>
<th>Purpose</th>
<th>Date Reqested</th>
<th>Amount</th>
<th>Status</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row['firstName'] . " " . $row['lastName'] . "</td>";
echo "<td>" . $row['certificate_type'] . "</td>";
echo "<td>" . $row['certificate_purpose'] . "</td>";
echo "<td>" . $row['formatted_date'] . "</td>";
echo "<td>" . $row['fee'] . "</td>";
echo "<td>" . $row['status'] . "</td>";
echo "<td>" . $row['remarks'] . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='7', rowspan='2'>No certificate requests found.</td></tr>";
}
?>
</tbody>
</table>
</main>
</div>

RESIDENT PROFILE – RESIDENT

<?php
session_start();
include_once("../connection/connection.php");
$con = config();

$id = $_SESSION['id'];
$sql = "SELECT * FROM register WHERE id = '$id'";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_assoc($result);

mysqli_close($con);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="../pics/maragondon logo.png" type="image/icon type">
<link rel="stylesheet" href="../css resident/profile.css">
<title>Profile | Barangay Maragondon</title>
</head>
<body>
<header>
<a href="" class="dashboard"><img src="../pics/maragondon logo.png" alt="B-Connect Icon" class="logo"></a>
<h1 style="font-size: 40px;">Barangay Maragondon, Real Quezon</h1>
<a href="logout.php" class="logout">Sign out</a>
</header>
<div class="main-container">
<sidebar>
<ul>
<li><a href="profile.php">Profile</a></li>
<li><a href="transaction.php">Transaction</a></li>
<li><a href="helpdesk.php">Help Desk</a></li>
</ul>
</sidebar>
<main>
<h2 style="font-size: 30px; text-align: left;">Profile</h2>
<div class="profile-container">
<div class="profile-section">
<h3>Personal Information</h3>
<table>
<tr>
<td><strong>Barangay ID:</strong></td>
<td><?php echo $row['brgyid']; ?></td>
</tr>
<tr>
<td><strong>Name:</strong></td>
<td><?php echo $row['lastName'] . "," . $row['firstName'] ." " .$row['middleName']; ?></td>
</tr>
<tr>
<td><strong>Gender:</strong></td>
<td><?php echo $row['gender']; ?></td>
</tr>
<tr>
<td><strong>Age:</strong></td>
<td><?php echo $row['age']; ?></td>
</tr>
<tr>
<td><strong>Birthdate:</strong></td>
<td><?php echo date("F j, Y", strtotime($row['birthdate'])); ?></td>
</tr>
<tr>
<td><strong>Address:</strong></td>
<td><?php echo $row['houseNumber']. " " .$row['Purok']. ', Barangay Maragondon, Real Quezon'; ?></td>
</tr>
<tr>
<td><strong>Contact Number:</strong></td>
<td>09<?php echo substr($row['mobile'], 4); ?></td>
</tr>
<tr>
<td><strong>PWD ID(if any):</strong></td>
<td><?php echo $row['pwdId']; ?></td>
</tr>

</table>
</div>
</div>
</main>
</div>

You might also like