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 domain parameter | |
| if (!isset($_GET['domain']) || !is_numeric($_GET['domain'])) { | |
| header("Location: domains.php"); | |
| exit; | |
| } | |
| $domainNumber = $_GET['domain']; | |
| $domainTable = "domain_" . $domainNumber; | |
| // Check if the domain table exists | |
| $tableCheckQuery = "SHOW TABLES LIKE '$domainTable'"; | |
| $tableExists = $conn->query($tableCheckQuery)->num_rows > 0; | |
| if (!$tableExists) { | |
| header("Location: domains.php"); | |
| exit; | |
| } | |
| // Get domain descriptions | |
| $domainDescriptions = getDomainDescriptions($conn); | |
| $domainDescription = isset($domainDescriptions[$domainNumber]) ? $domainDescriptions[$domainNumber] : "Domain $domainNumber"; | |
| // Get the correct project name field for this domain | |
| $projectNameField = getProjectNameField($conn, $domainTable); | |
| // Get projects for this domain | |
| $projectsQuery = "SELECT * FROM $domainTable ORDER BY Project_ID"; | |
| $projectsResult = $conn->query($projectsQuery); | |
| // 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> | |
| <li class="breadcrumb-item"><a href="domains.php">Domains</a></li> | |
| <li class="breadcrumb-item active">Domain <?php echo $domainNumber; ?> Projects</li> | |
| </ol> | |
| </nav> | |
| <div class="d-flex justify-content-between align-items-center"> | |
| <h2><i class="fas fa-layer-group me-2"></i> Projects in Domain <?php echo $domainNumber; ?></h2> | |
| <?php if ($is_faculty): ?> | |
| <div> | |
| <a href="project_add.php?domain=<?php echo urlencode($domainNumber); ?>" class="btn btn-primary"> | |
| <i class="fas fa-plus-circle me-1"></i> Add Project | |
| </a> | |
| <a href="project_manage.php?domain=<?php echo urlencode($domainNumber); ?>" class="btn btn-secondary"> | |
| <i class="fas fa-cog me-1"></i> Manage Projects | |
| </a> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| <p class="lead"><?php echo htmlspecialchars($domainDescription); ?></p> | |
| </div> | |
| </div> | |
| <div class="row"> | |
| <?php if ($projectsResult && $projectsResult->num_rows > 0): ?> | |
| <?php while ($project = $projectsResult->fetch_assoc()): ?> | |
| <div class="col-md-6 col-lg-4 mb-4"> | |
| <div class="card h-100 shadow-sm <?php echo (isset($project['H/S']) && strtolower($project['H/S']) === 'h') ? 'hardware' : 'software'; ?> project-card"> | |
| <div class="card-body"> | |
| <h5 class="card-title"><?php echo htmlspecialchars($project[$projectNameField]); ?></h5> | |
| <?php if (isset($project['H/S'])): ?> | |
| <h6 class="card-subtitle mb-2 text-muted"> | |
| <span class="badge bg-<?php echo strtolower($project['H/S']) === 'h' ? 'warning' : 'info'; ?>"> | |
| <?php echo strtolower($project['H/S']) === 'h' ? 'Hardware' : 'Software'; ?> | |
| </span> | |
| </h6> | |
| <?php endif; ?> | |
| <p class="card-text"> | |
| <?php if (isset($project['Description'])): ?> | |
| <?php echo (strlen($project['Description']) > 100) ? htmlspecialchars(substr($project['Description'], 0, 100)) . '...' : htmlspecialchars($project['Description']); ?> | |
| <?php else: ?> | |
| <em>No description available</em> | |
| <?php endif; ?> | |
| </p> | |
| </div> | |
| <div class="card-footer bg-transparent d-flex justify-content-between align-items-center"> | |
| <a href="project_details.php?domain=<?php echo urlencode($domainNumber); ?>&id=<?php echo urlencode($project['Project_ID']); ?>" class="btn btn-sm btn-primary"> | |
| <i class="fas fa-info-circle me-1"></i> Details | |
| </a> | |
| <?php if ($is_faculty): ?> | |
| <div class="btn-group btn-group-sm"> | |
| <a href="project_edit.php?domain=<?php echo urlencode($domainNumber); ?>&id=<?php echo urlencode($project['Project_ID']); ?>" class="btn btn-outline-success" title="Edit Project"> | |
| <i class="fas fa-edit"></i> | |
| </a> | |
| <a href="project_delete.php?domain=<?php echo urlencode($domainNumber); ?>&id=<?php echo urlencode($project['Project_ID']); ?>" class="btn btn-outline-danger" title="Delete Project"> | |
| <i class="fas fa-trash-alt"></i> | |
| </a> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| </div> | |
| </div> | |
| <?php endwhile; ?> | |
| <?php else: ?> | |
| <div class="col-md-12"> | |
| <div class="alert alert-info"> | |
| <i class="fas fa-info-circle me-2"></i> No projects found in this domain. | |
| <?php if ($is_faculty): ?> | |
| <a href="project_add.php?domain=<?php echo urlencode($domainNumber); ?>" class="alert-link">Add a project</a> to get started. | |
| <?php endif; ?> | |
| </div> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| <?php | |
| // Include footer | |
| include 'includes/footer.php'; | |
| // Close connection | |
| $conn->close(); | |
| ?> |