Skip to content

Commit

Permalink
Merge pull request #54 from wanderlust-group-project-1/sandali
Browse files Browse the repository at this point in the history
tipsStarted
  • Loading branch information
Sandali-Upekha authored Oct 31, 2023
2 parents 3243ba9 + 632912a commit 8e531a8
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 75 deletions.
20 changes: 20 additions & 0 deletions app/controllers/Tips.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class Tips
{
use Controller;

public function index(string $a = '', string $b = '', string $c = ''): void
{
$this->view('admin/tips');
}

public function update(string $a = '', string $b = '', string $c = ''): void
{

$tips = new TipsModel();
$tips->updateTips($_POST);

redirect('profile'); //methana mokadda?
}
}
42 changes: 42 additions & 0 deletions app/models/Tips.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

class TipsModel
{
use Model;

protected string $table = 'tips';
protected array $allowedColumns = [
//'id',
'title',
'description',
];

public function validateCustomerSignup(array $data)
{
$this->errors = [];

if (empty($data['title'])) {
$this->errors['title'] = "Title is required";
}

if (empty($data['description'])) {
$this->errors['description'] = "Description is required";
}
return empty($this->errors);
}

public function updateTips(array $data)
{

// $user = new UserModel;

$data['id'] = $_SESSION['USER']->id;

// alowed column
$data = array_filter($data, function ($key) {
return in_array($key, $this->allowedColumns);
}, ARRAY_FILTER_USE_KEY);

return $this->update($_SESSION['USER']->id, $data, 'id');
}
}
162 changes: 88 additions & 74 deletions app/views/admin/layout/sidebar.php
Original file line number Diff line number Diff line change
@@ -1,79 +1,93 @@
<nav class="sidebar sidebar-offcanvas" id="sidebar">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="index.html">
<i class="ti-shield menu-icon"></i>
<span class="menu-title">Dashboard</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="rentalServices" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Rental Services</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="index.html">
<i class="ti-shield menu-icon"></i>
<span class="menu-title">Dashboard</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="rentalServices" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Rental Services</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="guides" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Guides</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="guides" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Guides</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="customers" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Customers</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="customers" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Customers</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="index.html">
<i class="ti-shield menu-icon"></i>
<span class="menu-title">Blogs</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.html">
<i class="ti-shield menu-icon"></i>
<span class="menu-title">Tips and Know-hows</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="item" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Items</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="item" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Items</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="charts" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Charts</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="charts" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Charts</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</nav>
</div>
</li>
</ul>
</nav>
101 changes: 101 additions & 0 deletions app/views/admin/tips.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php
require_once('../app/views/admin/layout/header.php');
require_once('../app/views/admin/layout/sidebar.php');

?>

<div class="table-container">
<table class="data-table">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>Lahiru Sandaruwan</td>
<td>lahiru@example.com</td>
<td><span class="status accepted">Accepted</span></td>
<td><button class="view-button">View</button></td>
</tr>
<tr>
<td>Dasun Thathsara</td>
<td>dasun@example.com</td>
<td><span class="status not-accepted">Not Accepted</span></td>
<td><button class="view-button">View</button></td>
</tr>

<!-- Add more rows as needed -->
</tbody>
</table>
</div>

<!-- Modal -->
<div class="rental-services-modal" id="rental-services-modal">
<div class="modal-content">
<span class="close">&times;</span>
<div class="profile-info">
<img src="<?php echo ROOT_DIR ?>/assets/images/dp.jpg" alt="Profile Image" class="profile-image">
<h2 id="profile-name">Lahiru Sandaruwan </h2>
<p id="profile-email">lahiru@example.com</p>
<p id="profile-address">Kandy</p>
<p id="profile-status" class="accepted">Accepted</p>
<div class="profile-links">
<a href="#" id="link-1">Link 1</a>
<a href="#" id="link-2">Link 2</a>
</div>
</div>
</div>
</div>


<script>
// Get the modal
var modal = document.getElementById("rental-services-modal");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// Get all view buttons
var viewButtons = document.querySelectorAll('.view-button');

// Function to handle modal display
function openModal(content) {
// document.getElementById("modal-content").innerHTML = content;
modal.style.display = "block";
}

// Add click event listener to view buttons
viewButtons.forEach(function(button) {
button.addEventListener('click', function() {

var name = this.parentElement.parentElement.querySelector('td:first-child').textContent;
var email = this.parentElement.parentElement.querySelector('td:nth-child(2)').textContent;
openModal("Name: " + name + "<br>Email: " + email);
});
});

// Close the modal when the close button is clicked
span.onclick = function() {
modal.style.display = "none";
}

// Close the modal if the user clicks outside of it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>




<?php
require_once('../app/views/admin/layout/footer.php');


?>
2 changes: 1 addition & 1 deletion app/views/guide/GuideDashboard.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<input type="text" name="name" id="name" value="<?= $user->name ?>" required>

<label for="address">Address</label>
<input type="text" name="address" id="address" value="<?= $user->address ?>" required>
<input type="text" name="address" id="address" value="<?= $user->address ?>" disabled>

<label for="email">Email</label>
<input type="text" name="email" id="email" value="<?= $user->email ?>" required>
Expand Down

0 comments on commit 8e531a8

Please sign in to comment.