<?php
    session_start();
    if (!isset($_SESSION['username'])) {
        $_SESSION['login_msg'] = "Please login first to continue.";
        header("Location: login.php");
        exit();
    }
    
    
    require_once('include/config.php');
    require_once('include/startup.php');                           
    $alltables = new AllTables();
    
    
    // Count from Tables
    $sql = "SELECT COUNT(*) AS total FROM contact_person";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    
    // echo $row['total']; // total number of rows
    $contact_person_count = $row['total'];
    

    
    // View Service Requests
    $sql="SELECT * FROM service_requests";
    $result = $conn->query($sql);
    
    $airconrequest="";
    
    while($rows = $result->fetch_assoc()) {
        
        $cardId = $rows['id']; // unique DB id
        
        $status = $rows['status'];
        
        if($status == 1){
            $currentstatus = "pending";
        }
        elseif($status == 2){
            $currentstatus = "approved";
        }
        elseif($status == 3){
            $currentstatus = "rejected";
        }
        else{
            $currentstatus = "pending";
        }
         
        $requeststatus .= "<div class='col-md-12 mb-2'>
                                <div class='card border-0 border-bottom'>
                                    <div class='card-body p-2'>     
                                        <div class='row'>
                                            <div class='col-3 d-flex justify-content-center'>    
                                                <div class='$currentstatus'></div>
                                            </div>
                                            <div class='col-9'>
                                                <p class='m-0'><small>". $rows['request']."</small></p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>";
    }
    
    
    


    include('include/header.php'); 
    include_once('index1.html');
    include('include/footer.php'); 
?>