Spaces:
Sleeping
Sleeping
| // Include database connection and authentication | |
| require_once 'includes/db_connect.php'; | |
| require_once 'includes/domain_utils.php'; | |
| require_once 'includes/auth_check.php'; | |
| // Validate the parameters | |
| if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { | |
| header("Location: index.php"); | |
| exit; | |
| } | |
| $projectId = $_GET['id']; | |
| $domainNumber = isset($_GET['domain']) ? $_GET['domain'] : null; | |
| // Get domain descriptions from utility function | |
| $domainDescriptions = getDomainDescriptions($conn); | |
| // If domain number is not provided, find it by searching all domain tables | |
| if ($domainNumber === null) { | |
| $domainTables = getDomainTables($conn); | |
| foreach ($domainTables as $domainTable) { | |
| // Check for project in this domain | |
| $checkQuery = "SELECT * FROM $domainTable WHERE Project_ID = $projectId LIMIT 1"; | |
| $checkResult = $conn->query($checkQuery); | |
| if ($checkResult && $checkResult->num_rows > 0) { | |
| $domainNumber = str_replace('domain_', '', $domainTable); | |
| break; | |
| } | |
| } | |
| // If still not found, redirect | |
| if ($domainNumber === null) { | |
| header("Location: index.php"); | |
| exit; | |
| } | |
| } | |
| $domainTable = "domain_" . $domainNumber; | |
| // Get domain description | |
| $domainDescription = isset($domainDescriptions[$domainNumber]) ? $domainDescriptions[$domainNumber] : 'Domain ' . $domainNumber; | |
| // Check if table exists | |
| $tableExistsQuery = "SHOW TABLES LIKE '$domainTable'"; | |
| $tableExists = $conn->query($tableExistsQuery)->num_rows > 0; | |
| if (!$tableExists) { | |
| header("Location: index.php"); | |
| exit; | |
| } | |
| // Fetch project details | |
| $projectQuery = "SELECT * FROM $domainTable WHERE Project_ID = $projectId LIMIT 1"; | |
| $projectResult = $conn->query($projectQuery); | |
| if (!$projectResult || $projectResult->num_rows === 0) { | |
| header("Location: domain_projects.php?domain=$domainNumber"); | |
| exit; | |
| } | |
| $project = $projectResult->fetch_assoc(); | |
| // Get the correct project name field | |
| $projectNameField = getProjectNameField($conn, $domainTable); | |
| // Get project name using the correct field | |
| $projectName = $project[$projectNameField]; | |
| // Fetch students associated with this project if students_info table exists | |
| $studentsQuery = "SHOW TABLES LIKE 'students_info'"; | |
| $studentsTableExists = $conn->query($studentsQuery)->num_rows > 0; | |
| $students = []; | |
| if ($studentsTableExists) { | |
| $studentsQuery = "SELECT * FROM students_info WHERE Project_ID = $projectId"; | |
| $studentsResult = $conn->query($studentsQuery); | |
| if ($studentsResult && $studentsResult->num_rows > 0) { | |
| while ($student = $studentsResult->fetch_assoc()) { | |
| $students[] = $student; | |
| } | |
| } | |
| } | |
| // Include header | |
| include 'includes/header.php'; | |
| <div class="row mb-4"> | |
| <div class="col-md-12"> | |
| <nav aria-label="breadcrumb"> | |
| <ol class="breadcrumb"> | |
| <li class="breadcrumb-item"><a href="index.php">Home</a></li> | |
| <?php if (!$is_student): ?> | |
| <li class="breadcrumb-item"><a href="domains.php">Domains</a></li> | |
| <li class="breadcrumb-item"><a href="domain_projects.php?domain=<?php echo $domainNumber; ?>">Domain <?php echo $domainNumber; ?></a></li> | |
| <?php endif; ?> | |
| <li class="breadcrumb-item active">Project <?php echo $projectId; ?></li> | |
| </ol> | |
| </nav> | |
| </div> | |
| </div> | |
| <div class="row mb-4"> | |
| <div class="col-md-12"> | |
| <div class="card shadow-sm"> | |
| <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center"> | |
| <h4 class="mb-0"><i class="fas fa-project-diagram me-2"></i> Project Details</h4> | |
| <?php if ($is_faculty): ?> | |
| <div class="btn-group"> | |
| <a href="project_edit.php?domain=<?php echo urlencode($domainNumber); ?>&id=<?php echo urlencode($projectId); ?>" class="btn btn-light btn-sm"> | |
| <i class="fas fa-edit me-1"></i> Edit Project | |
| </a> | |
| <a href="project_delete.php?domain=<?php echo urlencode($domainNumber); ?>&id=<?php echo urlencode($projectId); ?>" class="btn btn-danger btn-sm"> | |
| <i class="fas fa-trash-alt me-1"></i> Delete Project | |
| </a> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| <div class="card-body"> | |
| <h2 class="card-title"><?php echo htmlspecialchars($projectName); ?></h2> | |
| <h6 class="card-subtitle mb-3 text-muted"> | |
| <span class="badge bg-secondary me-2">Domain <?php echo htmlspecialchars($domainNumber); ?>: <?php echo htmlspecialchars($domainDescription); ?></span> | |
| <?php if (isset($project['H/S'])): ?> | |
| <span class="badge bg-<?php echo strtolower($project['H/S']) === 'h' ? 'warning' : 'info'; ?>"> | |
| <?php echo strtolower($project['H/S']) === 'h' ? 'Hardware' : 'Software'; ?> | |
| </span> | |
| <?php endif; ?> | |
| </h6> | |
| <div class="row"> | |
| <div class="col-md-8"> | |
| <div class="card mb-3"> | |
| <div class="card-header bg-light"> | |
| <h5 class="mb-0"><i class="fas fa-align-left me-2"></i> Description</h5> | |
| </div> | |
| <div class="card-body"> | |
| <p><?php echo nl2br(htmlspecialchars($project['Description'])); ?></p> | |
| </div> | |
| </div> | |
| <?php if (!empty($project['Email'])): ?> | |
| <div class="card mb-3"> | |
| <div class="card-header bg-light"> | |
| <h5 class="mb-0"><i class="fas fa-envelope me-2"></i> Contact</h5> | |
| </div> | |
| <div class="card-body"> | |
| <p><strong>Email:</strong> <?php echo htmlspecialchars($project['Email']); ?></p> | |
| </div> | |
| </div> | |
| <?php endif; ?> | |
| <?php if (!empty($project['Links'])): ?> | |
| <div class="card mb-3"> | |
| <div class="card-header bg-light"> | |
| <h5 class="mb-0"><i class="fas fa-link me-2"></i> Resources</h5> | |
| </div> | |
| <div class="card-body"> | |
| <?php | |
| $links = explode(',', $project['Links']); | |
| foreach ($links as $link) { | |
| $link = trim($link); | |
| echo '<a href="' . htmlspecialchars($link) . '" class="btn btn-sm btn-outline-primary me-2 mb-2" target="_blank">'; | |
| echo '<i class="fas fa-external-link-alt me-1"></i> View Resource</a>'; | |
| } | |
| </div> | |
| </div> | |
| endif; | |
| </div> | |
| <div class="col-md-4"> | |
| <div class="card"> | |
| <div class="card-header bg-light"> | |
| <h5 class="mb-0"><i class="fas fa-info-circle me-2"></i> Project Info</h5> | |
| </div> | |
| <ul class="list-group list-group-flush"> | |
| <li class="list-group-item"><strong>Project ID:</strong> <?php echo htmlspecialchars($project['Project_ID']); ?></li> | |
| <li class="list-group-item"><strong>Domain ID:</strong> <?php echo htmlspecialchars($project['Domain_ID']); ?></li> | |
| <?php foreach ($project as $key => $value): | |
| // Skip already displayed fields and empty values | |
| if (in_array($key, [$projectNameField, 'Description', 'Email', 'Links', 'Project_ID', 'Domain_ID', 'H/S']) || empty($value)) { | |
| continue; | |
| } | |
| <li class="list-group-item"><strong><?php echo htmlspecialchars($key); ?>:</strong> <?php echo htmlspecialchars($value); ?></li> | |
| <?php endforeach; ?> | |
| </ul> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <?php if ($is_faculty && !empty($students)): ?> | |
| <div class="row"> | |
| <div class="col-md-12"> | |
| <div class="card shadow-sm"> | |
| <div class="card-header bg-info text-white"> | |
| <h5 class="mb-0"><i class="fas fa-users me-2"></i> Team Members</h5> | |
| </div> | |
| <div class="card-body"> | |
| <div class="table-responsive"> | |
| <table class="table table-striped table-hover"> | |
| <thead class="table-light"> | |
| <tr> | |
| <th>Student ID</th> | |
| <th>Name</th> | |
| <th>Division</th> | |
| <th>Roll No.</th> | |
| <th>Email</th> | |
| <th>Phone</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <?php foreach ($students as $student): ?> | |
| <tr> | |
| <td><?php echo htmlspecialchars($student['Student_ID']); ?></td> | |
| <td><?php echo htmlspecialchars($student['Name']); ?></td> | |
| <td><?php echo htmlspecialchars($student['Division']); ?></td> | |
| <td><?php echo htmlspecialchars($student['Roll_No']); ?></td> | |
| <td><?php echo htmlspecialchars($student['Email_ID']); ?></td> | |
| <td><?php echo htmlspecialchars($student['Phone_Number']); ?></td> | |
| </tr> | |
| <?php endforeach; ?> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <?php elseif ($is_student && !empty($students)): ?> | |
| <div class="row"> | |
| <div class="col-md-12"> | |
| <div class="card shadow-sm"> | |
| <div class="card-header bg-info text-white"> | |
| <h5 class="mb-0"><i class="fas fa-info-circle me-2"></i> Project Information</h5> | |
| </div> | |
| <div class="card-body"> | |
| <div class="alert alert-info"> | |
| <i class="fas fa-info-circle me-2"></i> This project has team members assigned. Contact your faculty advisor for more information. | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <?php endif; ?> | |
| <?php if ($is_faculty): ?> | |
| <div class="row mt-4"> | |
| <div class="col-md-12"> | |
| <div class="d-flex justify-content-end"> | |
| <a href="project_manage.php" class="btn btn-secondary me-2"> | |
| <i class="fas fa-list me-1"></i> All Projects | |
| </a> | |
| <a href="project_edit.php?domain=<?php echo urlencode($domainNumber); ?>&id=<?php echo urlencode($projectId); ?>" class="btn btn-primary me-2"> | |
| <i class="fas fa-edit me-1"></i> Edit Project | |
| </a> | |
| <a href="project_delete.php?domain=<?php echo urlencode($domainNumber); ?>&id=<?php echo urlencode($projectId); ?>" class="btn btn-danger"> | |
| <i class="fas fa-trash-alt me-1"></i> Delete Project | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| <?php endif; ?> | |
| <?php | |
| // Include footer | |
| include 'includes/footer.php'; | |
| // Close connection | |
| $conn->close(); | |
| ?> |