Skip to content

Commit

Permalink
Merge pull request #220 from DasunThathsara/view_security_profile
Browse files Browse the repository at this point in the history
feat: pass the data set to frontend
  • Loading branch information
DasunThathsara authored Dec 28, 2023
2 parents c89f84f + cb374b6 commit 4e0e7a2
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 10 deletions.
45 changes: 37 additions & 8 deletions app/controllers/Land.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,12 @@ public function landRegister(){
// Validation is completed and no error found*/
if (empty($data['err'])){
// Generate QR code
$path = PUBLICROOT.'/QRs/';
$img_name = 'QR-'.time().'.'.uniqid();
$qrcode = $path.$img_name.'.png';
QRcode :: png("dasun thaths", $qrcode, 'H', 4, 4);

$data['qrcode'] = $img_name.'.png';
// $path = PUBLICROOT.'/QRs/';
// $img_name = 'QR-'.time().'.'.uniqid();
// $qrcode = $path.$img_name.'.png';
// QRcode :: png("dasun thaths", $qrcode, 'H', 4, 4);
//
// $data['qrcode'] = $img_name.'.png';

// Register land
if ($this->landModel->registerLand($data)){
Expand Down Expand Up @@ -494,7 +494,12 @@ public function landUpdate(){

// Success property register page
public function successPropertyRegister($data){
$this->view('parkingOwner/lands/successPropertyRegister', $data);
$other_data['notification_count'] = 0;

if ($other_data['notification_count'] < 10)
$other_data['notification_count'] = '0'.$other_data['notification_count'];

$this->view('parkingOwner/lands/successPropertyRegister', $data, $other_data);
}

// ------------------------------ Price ------------------------------
Expand Down Expand Up @@ -566,7 +571,6 @@ public function sendRequest(){
}
}


// Cancel request for security
public function cancelRequest(){
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
Expand All @@ -585,4 +589,29 @@ public function cancelRequest(){
}
}
}

// View security
public function viewSecurity($security_ID = null){
if (sizeof($_GET) > 1){
$data = [
'id' => trim($_GET['id'])
];

redirect('land/viewSecurity/'.$data['id']);
}
else{
$data = [
'id' => $security_ID
];

$security = $this->securityModel->viewSecurityProfile($data);

$security['notification_count'] = 0;

if ($security['notification_count'] < 10)
$security['notification_count'] = '0'.$security['notification_count'];

$this->view('parkingOwner/securities/viewProfile', $data, $security);
}
}
}
4 changes: 2 additions & 2 deletions app/models/LandModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(){
public function registerLand($data): bool
{
// Prepare statement
$this->db->query('INSERT INTO land (name, city, street, deed, car, bike, threeWheel, contactNo, uid, status, availability, QR, address, district, province) VALUES (:name, :city, :street, :deed, :car, :bike, :threeWheel, :contactNo, :uid, :status, :availability, :QR, :address, :district, :province)');
$this->db->query('INSERT INTO land (name, city, street, deed, car, bike, threeWheel, contactNo, uid, status, availability, address, district, province) VALUES (:name, :city, :street, :deed, :car, :bike, :threeWheel, :contactNo, :uid, :status, :availability, :address, :district, :province)');

// Bind values
$this->db->bind(':name', $data['name']);
Expand All @@ -35,7 +35,7 @@ public function registerLand($data): bool
$this->db->bind(':uid', $_SESSION['user_id']);
$this->db->bind(':status', 0);
$this->db->bind(':availability', 0);
$this->db->bind(':QR', $data['qrcode']);
// $this->db->bind(':QR', $data['qrcode']);
$this->db->bind(':address', $data['address']);
$this->db->bind(':district', $data['district']);
$this->db->bind(':province', $data['province']);
Expand Down
12 changes: 12 additions & 0 deletions app/models/SecurityModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ public function viewSecurities($id){
return $row;
}

// View security profile
public function viewSecurityProfile($data){
$this->db->query('SELECT u.*, s.* FROM user u JOIN security s ON u.id = s.id WHERE u.id = :id;');

// Bind values
$this->db->bind(':id', $data['id']);

$row = $this->db->resultSet();

return $row;
}

// View all securities
public function viewAvailableSecurities (){
// $this->db->query('SELECT * FROM security_land_request slr LEFT JOIN security s ON slr.sid = s.id WHERE s.landID = 0;');
Expand Down
109 changes: 109 additions & 0 deletions app/views/parkingOwner/securities/viewProfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php
print_r($other_data[0]);
?>

<?php require APPROOT.'/views/inc/header.php'; ?>
<!-- TOP NAVIGATION -->
<?php //require APPROOT.'/views/inc/components/topnavbar.php'; ?>

<!-- SIDE NAVIGATION -->
<?php
$section = 'profile';
require APPROOT.'/views/inc/components/sidenavbar.php';
?>

<main class="page-container">
<section class="section" id="main">
<div class="container">
<div class="form-container">
<h1 style="text-align: center;">Security profile</h1>
<?php if (!empty($data['err'])){?>
<div class="error-msg">
<span class="form-invalid"><?php echo $data["err"] ?></span>
</div>
<?php } ?>

<form action="<?php echo URLROOT ?>/users/updateProfile" method="post" enctype="multipart/form-data">
<div class="profile-container">
<?php if($_SESSION['profile_photo']){ ?>
<img class="profile-pic" id="preview" src="<?php echo URLROOT ?>/profile_pics/<?php echo $data['profile_photo']?>" alt="<?php echo $_SESSION['user_name'] ?>">
<?php }
else{ ?>
<img class="profile-pic" id="preview" src="<?php echo URLROOT ?>/images/user.png" alt="<?php echo $_SESSION['user_name'] ?>">
<?php } ?>

<div class="profile-dropdown-container">
<img class="profile-pic-edit" src="<?php echo URLROOT ?>/images/edit-solid.svg" alt="" onclick="dropdownBtn()">
<div class="profile-dropdown-content">
<input type="file" id="profile_photo" name="profile_photo" hidden onchange="previewImage(this)"/>
<label for="profile_photo" class="dropdown-item" onclick="dropdownBtn()">Choose File</label>
<a class="dropdown-item" href="<?php echo URLROOT ?>/users/profilePhotoRemove" onclick="return confirmSubmit();">Remove photo</a>
</div>
</div>
</div>

<!-- Username -->
<div class="form-input-title">Username:</div>
<input type="text" name="username" id="username" required value="<?php echo $data['username'] ?>" />

<!-- Name -->
<div class="form-input-title">Name:</div>
<input type="text" name="name" id="name" required value="<?php echo $data['name'] ?>" />

<!-- Email -->
<div class="form-input-title">Email:</div>
<input type="email" name="email" id="email" required value="<?php echo $data['email'] ?>" />

<!-- Contact number -->
<div class="form-input-title">Contact number:</div>
<input type="text" name="contact_no" id="contact_no" required value="<?php echo $data['contact_no'] ?>" />

<br><br>

<!-- Submit -->
<input type="submit" value="Submit">
</form>
</div>
</div>
</section>
</main>

<script>
const actualBtn = document.getElementById('profile_photo');

actualBtn.addEventListener('change', function(){
fileChosen.textContent = this.files[0].name;
previewImage(this);
});

function previewImage(input) {
const preview = document.getElementById('preview');
const file = input.files[0];
const reader = new FileReader();

reader.onloadend = function () {
preview.src = reader.result;
}

if (file) {
reader.readAsDataURL(file);
} else {
preview.src = "<?php echo URLROOT ?>/images/user.png";
}
}

function confirmSubmit() {
return confirm("Are you sure you want to remove your profile photo?");
}

function dropdownBtn() {
var element1, element2;
element1 = document.querySelector('.profile-dropdown-content');
element1.classList.toggle("profile-dropdown-content-active");

element2 = document.querySelector('.profile-pic-edit');
element2.classList.toggle("profile-pic-edit-active");
}
</script>

<?php require APPROOT.'/views/inc/footer.php'; ?>
Binary file added public/deeds/DEED-658bcebdec34c3.58685544.pdf
Binary file not shown.
Binary file added public/deeds/DEED-658bcf14685076.94506406.pdf
Binary file not shown.
Binary file added public/deeds/DEED-658bcf439dc479.72940362.pdf
Binary file not shown.
Binary file added public/deeds/DEED-658bd064508bb8.55662300.pdf
Binary file not shown.
Binary file added public/deeds/DEED-658bd06689e405.48756522.pdf
Binary file not shown.
Binary file added public/deeds/DEED-658bd927d23fa3.12466904.pdf
Binary file not shown.
Binary file added public/deeds/DEED-658bd9a6748768.19730036.pdf
Binary file not shown.
Binary file added public/deeds/DEED-658bd9c3d78657.48910939.pdf
Binary file not shown.
Binary file added public/deeds/DEED-658bd9e8105654.77129002.pdf
Binary file not shown.

0 comments on commit 4e0e7a2

Please sign in to comment.