File size: 3,861 Bytes
102fe5c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
// Include database connection
require_once 'includes/db_connect.php';
require_once 'includes/domain_utils.php';
require_once 'includes/auth_check.php';

// Get domain descriptions
$domainDescriptions = getDomainDescriptions($conn);

// Get all domain tables and sort them numerically
$domainTables = getDomainTables($conn);
usort($domainTables, function($a, $b) {
    $numA = intval(preg_replace('/[^0-9]/', '', $a));
    $numB = intval(preg_replace('/[^0-9]/', '', $b));
    return $numA - $numB;
});

// 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 active">Domains</li>

            </ol>

        </nav>

        <div class="d-flex justify-content-between align-items-center">

            <h2><i class="fas fa-layer-group me-2"></i> Project Domains</h2>

        </div>

        <p class="lead">Browse project domains to find projects in different areas of interest.</p>

    </div>

</div>



<div class="row">

    <?php foreach ($domainTables as $domainTable): 

        // Extract domain number from table name

        preg_match('/domain_(\d+)/', $domainTable, $matches);

        if (isset($matches[1])):

            $domainNumber = $matches[1];

            

            // Get project count for this domain

            $countQuery = "SELECT COUNT(*) as count FROM $domainTable";

            $countResult = $conn->query($countQuery);

            $projectCount = $countResult->fetch_assoc()['count'];

            

            // Get domain description

            $domainDescription = isset($domainDescriptions[$domainNumber]) ? $domainDescriptions[$domainNumber] : "Domain $domainNumber";

    ?>

        <div class="col-md-6 col-lg-4 mb-4">

            <div class="card h-100 shadow-sm domain-card">

                <div class="card-header bg-primary text-white">

                    <h5 class="mb-0">Domain <?php echo htmlspecialchars($domainNumber); ?></h5>

                </div>

                <div class="card-body">

                    <p class="card-text"><?php echo htmlspecialchars($domainDescription); ?></p>

                    <div class="d-flex justify-content-between align-items-end mt-3">

                        <span class="badge bg-secondary fs-6">

                            <i class="fas fa-clipboard-list me-1"></i> <?php echo $projectCount; ?> Project<?php echo $projectCount != 1 ? 's' : ''; ?>

                        </span>

                        <div>

                            <a href="domain_projects.php?domain=<?php echo urlencode($domainNumber); ?>" class="btn btn-outline-primary">

                                <i class="fas fa-eye me-1"></i> View Projects

                            </a>

                            <?php if ($is_faculty): ?>

                            <a href="project_add.php?domain=<?php echo urlencode($domainNumber); ?>" class="btn btn-outline-success">

                                <i class="fas fa-plus-circle me-1"></i> Add Project

                            </a>

                            <?php endif; ?>

                        </div>

                    </div>

                </div>

            </div>

        </div>

    <?php 

        endif;

    endforeach; 

    

    if (count($domainTables) == 0):

    ?>

        <div class="col-md-12">

            <div class="alert alert-info">

                <i class="fas fa-info-circle me-2"></i> No domains found in the database.

            </div>

        </div>

    <?php endif; ?>

</div>



<?php

// Include footer

include 'includes/footer.php';



// Close connection

$conn->close();

?>