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 technician messages ui #46

Merged
merged 4 commits into from
Nov 27, 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
29 changes: 20 additions & 9 deletions controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function adminDashboard()
}



public function manageUsers()
{
$this->setLayout('auth');
Expand Down Expand Up @@ -71,13 +70,12 @@ public function adminLogin()
return $this->render('/admin/admin-login.php');
}


public function promotions()
{
$this->setLayout('auth');
return $this->render('/admin/admin-promotions');
}



public function customers()
Expand All @@ -102,39 +100,52 @@ public function technicians()

public function deleteCustomer(Request $request)
{
$data = $request->getBody(); // Assuming this already returns an array
// Decode JSON payload manually since getBody() does not handle JSON
$data = json_decode(file_get_contents('php://input'), true);

// Debug: Log incoming data
error_log('Request payload: ' . print_r($data, true));

if (isset($data['cus_id'])) {
$cus_id = $data['cus_id'];

// Call the model function to delete the customer
$result = Admin::deleteCustomerById($cus_id);

if ($result) {
// Debug: Log successful deletion
error_log("Customer with ID $cus_id deleted successfully.");
echo json_encode(['status' => 'success']);
} else {
// Debug: Log failure
error_log("Failed to delete customer with ID $cus_id.");
echo json_encode(['status' => 'error', 'message' => 'Failed to delete customer']);
}
} else {
// Debug: Log invalid request
error_log("Invalid customer ID in request payload.");
echo json_encode(['status' => 'error', 'message' => 'Invalid customer ID']);
}
}


public function deleteTechnician(Request $request)
{
$data = $request->getBody(); // Assuming this already returns an array
$data = json_decode(file_get_contents("php://input"), true);

if (isset($data['tech_id'])) {
$tech_id = $data['tech_id'];

// Call the model function to delete the technician
// Call model to delete technician
$result = Admin::deleteTechnicianById($tech_id);

if ($result) {
echo json_encode(['status' => 'success']);
return $response->json(['status' => 'success']);
} else {
echo json_encode(['status' => 'error', 'message' => 'Failed to delete technician']);
return $response->json(['status' => 'error', 'message' => 'Failed to delete technician']);
}
} else {
echo json_encode(['status' => 'error', 'message' => 'Invalid technician ID']);
return $response->json(['status' => 'error', 'message' => 'Invalid technician ID']);
}
}

Expand Down
15 changes: 0 additions & 15 deletions controllers/TechnicianController.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,6 @@ 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
]);
}
}

10 changes: 5 additions & 5 deletions models/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ public static function deleteCustomerById($cus_id)
$db = Application::$app->db; // Ensure this points to the correct Database instance
$sql = "DELETE FROM customer WHERE cus_id = :cus_id";
$stmt = $db->prepare($sql);
$stmt->bindParam(':cus_id', $cus_id, \PDO::PARAM_INT);
$stmt->bindValue(':cus_id', (int)$cus_id, \PDO::PARAM_INT);
return $stmt->execute();

}

public static function deleteTechnicianById($cus_id)
public static function deleteTechnicianById($tech_id)
{
$db = Application::$app->db; // Ensure this points to the correct Database instance
$db = Application::$app->db; // Database instance
$sql = "DELETE FROM technician WHERE tech_id = :tech_id";
$stmt = $db->prepare($sql);
$stmt->bindParam(':tech_id', $tech_id, \PDO::PARAM_INT);
$stmt->bindValue(':tech_id', (int)$tech_id, \PDO::PARAM_INT);
return $stmt->execute();

}


}
Binary file not shown.
42 changes: 39 additions & 3 deletions public/css/home/select-user-login.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,48 @@ section {
.container-left {
width: 50%;
display: flex;
justify-content: center;
justify-content: right;
align-items: center;
flex: 1; /* Takes up half of the screen */
flex: 1;
background-color: #010336;
/*padding-bottom: 140px;*/
}

.branding-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
margin-top: 200px;
padding: 2rem;
background-color: transparent;
}

.brand-name {
font-weight: bold;
font-size: 2rem;
margin-bottom: 1rem;
color: #333;
}

.brand-button {
padding: 0.25rem 0.5rem;
background: linear-gradient(to right, #183369, #1e8dc5);
border-radius: 0.5rem;
color: white;
font-size: 5rem;
display: inline-block;
float: right;
}

.tagline {
margin-top: 10px;
line-height: 1.5;
color: white;
text-align: right;
}


/* Right Column Styling */
.container-right {
width: 50%; /* Take up 50% of the width */
Expand All @@ -38,7 +74,7 @@ section {
display: flex;
flex-direction: column; /* Arrange cards in a column */
gap: 20px; /* Space between cards */
width: 40%; /* Restrict width for better alignment */
width: 40%; /* Restrict width for better alignment */
}

/* Card Styling */
Expand Down
Loading