Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added posts to the feed #45

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public/assets/uploads/
public/assets/market-images
public/assets/products
composer.lock
public/assets/home-video-1.mp4
public/assets/home-video-1.mp4
*~
25 changes: 24 additions & 1 deletion controllers/TechnicianController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ public function viewTechnicianProfile($id)
return $this->render('_404');
}
// show($technician['fname']);
return $this->render('/customer/technician-profile', ['technician' => $technician]);
$postModel = new Post();
$posts = $postModel->getPostsByTechnicianId(intval($id[0]));

return $this->render('/customer/technician-profile', [
'technician' => $technician,
'posts' => $posts
]);
}

public function viewRequests()
Expand Down Expand Up @@ -146,5 +152,22 @@ public function updateRequestStatus($request)
}
Application::$app->response->redirect('/technician-requests');
}

public function profile($technicianId)
{
$technician = (new Technician)->findOne(['tech_id' => $technicianId]);
if (!$technician) {
Application::$app->response->setStatusCode(404);
return "Technician not found";
}

$postModel = new Post();
$posts = $postModel->getPostsByTechnicianId($technicianId);

return $this->render('/customer/technician-profile', [
'technician' => $technician,
'posts' => $posts
]);
}
}

13 changes: 12 additions & 1 deletion models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace app\models;

use app\core\DbModel;
use app\core\Application;

class Post extends DbModel
{
Expand Down Expand Up @@ -113,5 +114,15 @@ public function updateRules(): array

];
}
}

// In models/Post.php
public function getPostsByTechnicianId($id)
{
$sql = "SELECT * FROM post WHERE tech_id = :tech_id ORDER BY created_at DESC";
$stmt = self::prepare($sql);
$stmt->bindValue(':tech_id', $id);
$stmt->execute();
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
}

}
2 changes: 1 addition & 1 deletion public/css/customer/customer-dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ a {
font-weight: 500;
}

.status.inProgress {
.status.inprogress {
padding: 2px 4px;
background: #1795ce;
color: var(--white);
Expand Down
39 changes: 28 additions & 11 deletions public/css/customer/technician-profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,43 +111,59 @@ body {

.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Adjust 200px as needed */
gap: 16px; /* Spacing between cards */
padding: 16px;
justify-content: center;
}

.card {
background-color: white;
background: #fff;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
overflow: hidden;
transition: transform 0.3s ease, box-shadow 0.3s ease;
transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
transform: translateY(-5px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.card-image img {
width: 100%;
height: 150px;
height: 150px; /* Adjust height as needed */
object-fit: cover;
}

.card-content {
padding: 1rem;
text-align: center;
padding: 16px;
text-align: left;
}

.card-content h3 {
margin-bottom: 0.5rem;
color: #1a237e;
font-size: 1.2rem;
margin: 0 0 8px;
color: #333;
}

.card-content p {
font-size: 0.9rem;
color: #666;
margin-bottom: 1rem;
margin: 6px 0;
}

.card-content small {
font-size: 0.8rem;
color: #999;
}

/* Responsive Design */
@media (min-width: 768px) {
.cards {
grid-template-columns: repeat(5, 1fr); /* Exactly 5 columns for larger screens */
}
}

.visit-btn {
Expand All @@ -163,3 +179,4 @@ body {
.visit-btn:hover {
background-color: #1565c0;
}

3 changes: 2 additions & 1 deletion public/js/customer/technician-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ async function sendRequest(technicianId, customerId) {
alert('An error occurred while sending the request');
console.error('Error: ', e);
}
}
}

2 changes: 1 addition & 1 deletion views/customer/customer-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<td>' . $request['fname'] . ' ' . $request['lname'] . '</td>
<td>Rs. 500</td>
<td>Due</td>
<td><span class="status ' . $request['status'] . '">' . $request['status'] . '</span></td>
<td><span class="status ' . strtolower($request['status']) . '">' . ucfirst($request['status']) . '</span></td>
</tr>';
}
/* status: pending , in Progress, rejected, completed */
Expand Down
67 changes: 45 additions & 22 deletions views/customer/technician-profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,54 @@

<main class="content">
<div class="cards">
<!-- Card Template -->
<article class="card">
<div class="card-image">
<img src="https://via.placeholder.com/150" alt="Food Image">
</div>
<div class="card-content">
<h3>Shane Mario</h3>
<p>You and your family will love this refreshing salad that's perfect for warm days or summer meals!</p>
<button class="visit-btn">Visit Us</button>
</div>
</article>
<!-- Repeat as needed -->
<article class="card">
<div class="card-image">
<img src="https://via.placeholder.com/150" alt="Food Image">
</div>
<div class="card-content">
<h3>Shane Mario</h3>
<p>You and your family will love this refreshing salad that's perfect for warm days or summer meals!</p>
<button class="visit-btn">Visit Us</button>
</div>
</article>
<?php if (!empty($posts)): ?>
<?php foreach ($posts as $post): ?>
<article class="card">
<div class="card-image">
<img src="/assets/uploads/<?php echo $post['media']; ?>" alt="Post Media">
</div>
<div class="card-content">
<h3><?php echo $technician['fname'] . ' ' . $technician['lname']; ?></h3>
<p><?php echo htmlspecialchars($post['description'], ENT_QUOTES, 'UTF-8'); ?></p>
<p><small>Posted on <?php echo date('F j, Y, g:i a', strtotime($post['created_at'])); ?></small>
</p>
</div>
</article>
<?php endforeach; ?>
<?php else: ?>
<p>No posts to display.</p>
<?php endif; ?>
</div>
</main>


<!--<main class="content">-->
<!-- <div class="cards">-->
<!-- <!-- Card Template -->
<!-- <article class="card">-->
<!-- <div class="card-image">-->
<!-- <img src="https://via.placeholder.com/150" alt="Food Image">-->
<!-- </div>-->
<!-- <div class="card-content">-->
<!-- <h3>Shane Mario</h3>-->
<!-- <p>You and your family will love this refreshing salad that's perfect for warm days or summer meals!</p>-->
<!-- <button class="visit-btn">Visit Us</button>-->
<!-- </div>-->
<!-- </article>-->
<!-- <!-- Repeat as needed -->
<!-- <article class="card">-->
<!-- <div class="card-image">-->
<!-- <img src="https://via.placeholder.com/150" alt="Food Image">-->
<!-- </div>-->
<!-- <div class="card-content">-->
<!-- <h3>Shane Mario</h3>-->
<!-- <p>You and your family will love this refreshing salad that's perfect for warm days or summer meals!</p>-->
<!-- <button class="visit-btn">Visit Us</button>-->
<!-- </div>-->
<!-- </article>-->
<!-- </div>-->
<!--</main>-->

<!-- Overlay for the confirmation message -->
<div id="signOutOverlay" class="overlay">
<div class="overlay-content">
Expand Down
4 changes: 3 additions & 1 deletion views/technician/technician-requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
<tr>
<td><?= $request['cus_id'] ?></td>
<td><?= $request['cus_name'] ?></td>
<td><span class="status <?= strtolower($request['status']) ?>"><?= $request['status'] ?></span></td>
<td>
<span class="status <?= strtolower($request['status']) ?>"><?= ucfirst($request['status']) ?></span>
</td>
<td>
<?php if ($request['status'] == 'Pending' || $request['status'] == 'pending'): ?>
<form action="/technician-requests-update" method="POST" style="display:inline;">
Expand Down