Skip to content

Commit cfd8fa7

Browse files
authored
Merge pull request #45 from kasunmendis7/develop
added posts to the feed
2 parents baca42e + a0bbe45 commit cfd8fa7

9 files changed

+118
-40
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ public/assets/uploads/
55
public/assets/market-images
66
public/assets/products
77
composer.lock
8-
public/assets/home-video-1.mp4
8+
public/assets/home-video-1.mp4
9+
*~

controllers/TechnicianController.php

+24-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ public function viewTechnicianProfile($id)
116116
return $this->render('_404');
117117
}
118118
// show($technician['fname']);
119-
return $this->render('/customer/technician-profile', ['technician' => $technician]);
119+
$postModel = new Post();
120+
$posts = $postModel->getPostsByTechnicianId(intval($id[0]));
121+
122+
return $this->render('/customer/technician-profile', [
123+
'technician' => $technician,
124+
'posts' => $posts
125+
]);
120126
}
121127

122128
public function viewRequests()
@@ -146,5 +152,22 @@ public function updateRequestStatus($request)
146152
}
147153
Application::$app->response->redirect('/technician-requests');
148154
}
155+
156+
public function profile($technicianId)
157+
{
158+
$technician = (new Technician)->findOne(['tech_id' => $technicianId]);
159+
if (!$technician) {
160+
Application::$app->response->setStatusCode(404);
161+
return "Technician not found";
162+
}
163+
164+
$postModel = new Post();
165+
$posts = $postModel->getPostsByTechnicianId($technicianId);
166+
167+
return $this->render('/customer/technician-profile', [
168+
'technician' => $technician,
169+
'posts' => $posts
170+
]);
171+
}
149172
}
150173

models/Post.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace app\models;
44

55
use app\core\DbModel;
6+
use app\core\Application;
67

78
class Post extends DbModel
89
{
@@ -113,5 +114,15 @@ public function updateRules(): array
113114

114115
];
115116
}
116-
}
117117

118+
// In models/Post.php
119+
public function getPostsByTechnicianId($id)
120+
{
121+
$sql = "SELECT * FROM post WHERE tech_id = :tech_id ORDER BY created_at DESC";
122+
$stmt = self::prepare($sql);
123+
$stmt->bindValue(':tech_id', $id);
124+
$stmt->execute();
125+
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
126+
}
127+
128+
}

public/css/customer/customer-dashboard.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ a {
386386
font-weight: 500;
387387
}
388388

389-
.status.inProgress {
389+
.status.inprogress {
390390
padding: 2px 4px;
391391
background: #1795ce;
392392
color: var(--white);

public/css/customer/technician-profile.css

+28-11
Original file line numberDiff line numberDiff line change
@@ -111,43 +111,59 @@ body {
111111

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

118120
.card {
119-
background-color: white;
121+
background: #fff;
122+
border: 1px solid #ddd;
120123
border-radius: 8px;
121124
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
122125
overflow: hidden;
123-
transition: transform 0.3s ease, box-shadow 0.3s ease;
126+
transition: transform 0.3s, box-shadow 0.3s;
124127
}
125128

126129
.card:hover {
127130
transform: translateY(-5px);
128-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
131+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
129132
}
130133

131134
.card-image img {
132135
width: 100%;
133-
height: 150px;
136+
height: 150px; /* Adjust height as needed */
134137
object-fit: cover;
135138
}
136139

137140
.card-content {
138-
padding: 1rem;
139-
text-align: center;
141+
padding: 16px;
142+
text-align: left;
140143
}
141144

142145
.card-content h3 {
143-
margin-bottom: 0.5rem;
144-
color: #1a237e;
146+
font-size: 1.2rem;
147+
margin: 0 0 8px;
148+
color: #333;
145149
}
146150

147151
.card-content p {
148152
font-size: 0.9rem;
149153
color: #666;
150-
margin-bottom: 1rem;
154+
margin: 6px 0;
155+
}
156+
157+
.card-content small {
158+
font-size: 0.8rem;
159+
color: #999;
160+
}
161+
162+
/* Responsive Design */
163+
@media (min-width: 768px) {
164+
.cards {
165+
grid-template-columns: repeat(5, 1fr); /* Exactly 5 columns for larger screens */
166+
}
151167
}
152168

153169
.visit-btn {
@@ -163,3 +179,4 @@ body {
163179
.visit-btn:hover {
164180
background-color: #1565c0;
165181
}
182+

public/js/customer/technician-profile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ async function sendRequest(technicianId, customerId) {
3737
alert('An error occurred while sending the request');
3838
console.error('Error: ', e);
3939
}
40-
}
40+
}
41+

views/customer/customer-dashboard.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<td>' . $request['fname'] . ' ' . $request['lname'] . '</td>
100100
<td>Rs. 500</td>
101101
<td>Due</td>
102-
<td><span class="status ' . $request['status'] . '">' . $request['status'] . '</span></td>
102+
<td><span class="status ' . strtolower($request['status']) . '">' . ucfirst($request['status']) . '</span></td>
103103
</tr>';
104104
}
105105
/* status: pending , in Progress, rejected, completed */

views/customer/technician-profile.php

+45-22
Original file line numberDiff line numberDiff line change
@@ -72,31 +72,54 @@
7272

7373
<main class="content">
7474
<div class="cards">
75-
<!-- Card Template -->
76-
<article class="card">
77-
<div class="card-image">
78-
<img src="https://via.placeholder.com/150" alt="Food Image">
79-
</div>
80-
<div class="card-content">
81-
<h3>Shane Mario</h3>
82-
<p>You and your family will love this refreshing salad that's perfect for warm days or summer meals!</p>
83-
<button class="visit-btn">Visit Us</button>
84-
</div>
85-
</article>
86-
<!-- Repeat as needed -->
87-
<article class="card">
88-
<div class="card-image">
89-
<img src="https://via.placeholder.com/150" alt="Food Image">
90-
</div>
91-
<div class="card-content">
92-
<h3>Shane Mario</h3>
93-
<p>You and your family will love this refreshing salad that's perfect for warm days or summer meals!</p>
94-
<button class="visit-btn">Visit Us</button>
95-
</div>
96-
</article>
75+
<?php if (!empty($posts)): ?>
76+
<?php foreach ($posts as $post): ?>
77+
<article class="card">
78+
<div class="card-image">
79+
<img src="/assets/uploads/<?php echo $post['media']; ?>" alt="Post Media">
80+
</div>
81+
<div class="card-content">
82+
<h3><?php echo $technician['fname'] . ' ' . $technician['lname']; ?></h3>
83+
<p><?php echo htmlspecialchars($post['description'], ENT_QUOTES, 'UTF-8'); ?></p>
84+
<p><small>Posted on <?php echo date('F j, Y, g:i a', strtotime($post['created_at'])); ?></small>
85+
</p>
86+
</div>
87+
</article>
88+
<?php endforeach; ?>
89+
<?php else: ?>
90+
<p>No posts to display.</p>
91+
<?php endif; ?>
9792
</div>
9893
</main>
9994

95+
96+
<!--<main class="content">-->
97+
<!-- <div class="cards">-->
98+
<!-- <!-- Card Template -->
99+
<!-- <article class="card">-->
100+
<!-- <div class="card-image">-->
101+
<!-- <img src="https://via.placeholder.com/150" alt="Food Image">-->
102+
<!-- </div>-->
103+
<!-- <div class="card-content">-->
104+
<!-- <h3>Shane Mario</h3>-->
105+
<!-- <p>You and your family will love this refreshing salad that's perfect for warm days or summer meals!</p>-->
106+
<!-- <button class="visit-btn">Visit Us</button>-->
107+
<!-- </div>-->
108+
<!-- </article>-->
109+
<!-- <!-- Repeat as needed -->
110+
<!-- <article class="card">-->
111+
<!-- <div class="card-image">-->
112+
<!-- <img src="https://via.placeholder.com/150" alt="Food Image">-->
113+
<!-- </div>-->
114+
<!-- <div class="card-content">-->
115+
<!-- <h3>Shane Mario</h3>-->
116+
<!-- <p>You and your family will love this refreshing salad that's perfect for warm days or summer meals!</p>-->
117+
<!-- <button class="visit-btn">Visit Us</button>-->
118+
<!-- </div>-->
119+
<!-- </article>-->
120+
<!-- </div>-->
121+
<!--</main>-->
122+
100123
<!-- Overlay for the confirmation message -->
101124
<div id="signOutOverlay" class="overlay">
102125
<div class="overlay-content">

views/technician/technician-requests.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
<tr>
3737
<td><?= $request['cus_id'] ?></td>
3838
<td><?= $request['cus_name'] ?></td>
39-
<td><span class="status <?= strtolower($request['status']) ?>"><?= $request['status'] ?></span></td>
39+
<td>
40+
<span class="status <?= strtolower($request['status']) ?>"><?= ucfirst($request['status']) ?></span>
41+
</td>
4042
<td>
4143
<?php if ($request['status'] == 'Pending' || $request['status'] == 'pending'): ?>
4244
<form action="/technician-requests-update" method="POST" style="display:inline;">

0 commit comments

Comments
 (0)