<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate, max-age=0">
    <meta name="author" content="Ehsan Elahi">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT">
    <meta property="og:title" content="CDP - Al Fares Transportation">
    <title>SABIC Invoice Portal</title>
    <link rel="icon" type="image/webp" href="images/favicon.webp">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Mada:wght@400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="styles.css?v=1.0">
    <style>
        body {
            background: url('') no-repeat center 10px fixed;
background-position: 20% calc(100% - -1px); /* 30px from the bottom edge, horizontally centered */
background-size: 105.5%;
            font-family: 'Roboto', sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100%;
            margin-top: -31px;
            color: #333;
            overflow: hidden; /* Disable scrolling */
        }

        .container {
            border-radius: 8px;
            padding: 19px;
            max-width: 400px;
            width: 90%;
            text-align: left;
            justify-content: center;
            margin: 20px;
        }
        .header {
    background-color: #2C3E50;
    padding: 15px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    }

 .header2 {
   background-color: #2C3E50; 
   border-top-left-radius: 8px;
   padding: 15px;
   border-top-right-radius: 8px; 
   color: #fff; /* Changed 'text-color' to 'color' */
   text-align: center; /* Corrected 'text-color' to 'color' */
}

.header2 h2 {
            font-size: 15px; /* Add this line to reduce font size */
        }

        .header img {
            width: 100px;
            margin-bottom: 10px;
        }
        .header h2 {
            color: #fff;
            margin: 0;
            padding: 0;
        }
        .header p {
            color: #ecf0f1;
            font-size: 0.9em;
            margin: 0; /* Ensure no margin between elements */
            padding: 0;
        }

/* Set search box as boundary for header */
#searchInput {
    margin-top: 5px; /* Adjust this value to match the height of your header */
}

        footer {
            margin-top: 0px;
            font-size: 0.9em;
            color: #aaa;
            text-align: center;
            padding: 0px;
            text-align: center;
            width: 100%;
            position: fixed;
            bottom: 0;
        }
        .footer-content {
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .separator {
            width: 1px;
            height: 50px; /* Adjust height as needed */
            background-color: #000000; /* Color of the separator */
            margin: 0 10px; /* Adjust spacing around the separator */
            margin-bottom: -5px;
        }

/* Center the WhatsApp button */
        .whatsapp-share-button {
            display: block;
            margin-top: 10px;
            text-decoration: none;
            color: black; /* Change color as needed */
            font-size: 16px; /* Change font size as needed */
            padding: 8px 10px;
            background-color: #5cb85c; /* Change background color as needed */
            border-radius: 5px;
            text-align: center; /* Center the text inside the button */
            width: auto; /* Adjust width to fit content */
            margin-left: auto; /* Center horizontally */
            margin-right: auto; /* Center horizontally */
        }

        .whatsapp-share-button:hover {
            background-color: #449d44; /* Change hover background color as needed */
        }

#searchResultsContainer {
    overflow-y: auto; /* Enable vertical scrolling */
    max-height: 370px; /* Adjust max-height as needed */
    min-height: 0px; /* Set a minimum height for the container */
    text-align: center; /* Center the text */
}

#searchResults {
    list-style-type: none; /* Remove default list styles */
    padding: 0; /* Remove default padding */
    margin: 0; /* Remove default margin */
    display: inline-block; /* Make the list inline-block to center it within the container */
    max-width: 80%;
    text-align: left; /* Center the text */
}

/* Adjust the margin-top of the search input */
#searchInput {
    width: calc(100% - 20px); /* Adjust width to fit the container */
    padding: 10px;
    box-sizing: border-box;
    margin-top: 110px; /* Adjust margin-top to position below the logo and h1 */
    position: relative; /* Add relative positioning */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Remove rounded corners when search input is focused */
#searchInput:focus {
    border-radius: 0; /* Remove border-radius */
    outline: none; /* Optional: Remove the default outline */
}


/* Style for individual search results */
#searchResults {
    list-style-type: none; /* Remove default list styles */
    padding: 0; /* Remove default padding */
    margin: 0; /* Remove default margin */
}

#searchResults li {
    padding: 10px; /* Add padding for better readability */
    cursor: pointer; /* Change cursor to pointer on hover */
    background-color: #f9f9f9; /* Set background color */
    border-bottom: 1px solid #ddd; /* Add bottom border to separate results */
    text-align: left; /* Align text to the left */
}


/* Style for selected search result */
#searchResults li.selected {
    background-color: #ccc; /* Change background color for selected item */
}



        #dataSection input[type="text"] {
            width: 100%;
            padding: 10px;
            margin-top: 10px;
            box-sizing: border-box;
        }
        #dataSection ul {
            list-style-type: none;
            padding: 0;
            margin: 10px 0;
        }

        .hidden {
            display: none;
        }
        .input-group {
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        #content {
            flex: 1;
        }
    
#dataSection input[type="text"] {
            width: 100%;
            padding: 10px;
            margin-top: 10px;
            box-sizing: border-box;
        }
        #dataSection ul {
            list-style-type: none;
            padding: 0;
            margin: 10px 0;
        }

        .logo {
            width: 100%;
            max-width: 250px;
            margin-bottom: 9px;
        }
        h2, p {
            margin: 0;
            padding: 0;
        }

/* Hamburger Menu Styles */
.hamburger-menu {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 999;
}

.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    font-size: 20px;
    color: #333;
}

/* Navigation Menu Styles */
.nav-menu {
    position: fixed;
    top: 0;
    right: 0px; /* Initially off-screen */
    background-color: #fff;
    width: 200px;
    height: 100%;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease-in-out; /* Add transition for smooth sliding */
}

/* Show navigation menu by translating it into view */
.nav-menu.active {
    transform: translateX(-100%);
}

/* Hide navigation menu by default */
.nav-menu.hidden {
    transform: translateX(-100%);
}

.nav-menu a {
    display: block;
    text-decoration: none;
    display: flex; /* Use flexbox for layout */
    align-items: center; /* Align items vertically */
    color: #333;
    margin-bottom: 8px; /* Increase the margin */
    padding-bottom: 8px; /* Add padding bottom */
    font-size: 13px;
    border-bottom: 1px solid #ccc; /* Add border bottom */  
    transition: color 0.2s ease-in-out; /* Add transition for color */
}

.nav-menu a:hover {
    color: 000;
}

.close-btn {
    background: none;
    border: none;
    position: absolute;
    top: 12px;
    right: 13px;
    font-size: 35px;
    cursor: pointer;
    color: #333;
}

/* Navigation Menu Styles */
.nav-menu {
    /* Your existing styles */
}

/* Hide navigation menu by default */
.nav-menu.hidden {
    /* Your existing styles */
}

/* Remove border bottom from the last link */
.nav-menu a:last-child {
    border-bottom: none;
    margin-bottom: 0; /* Remove margin from the last link */
}

.nav-menu h2 {
    font-size: 14px;
    margin-bottom: 15px;
    align-items: left; /* Align items vertically */
    justify-content: left;
    text-align: left; /* Align items vertically */
    color: #333;
}

.nav-menu a img {
    width: 15%; /* Adjust the width of the icon */
    margin-right: 10px; /* Add margin to the right of the icon */
}

/* Override hover effect for the specific link */
.nav-menu a.no-hover:hover {
    transform: none; /* Remove the transform effect */
}

.bottom-image {
    /* New styles for the bottom image */
    display: block;
    margin: 0px auto 0; /* Centers the image horizontally and adds margin at the top */
    max-width: auto; /* Ensures the image does not overflow the container */
    height: 130px; /* Maintains the aspect ratio */
    opacity: 1;
}
.version-info {
            text-align: center;
            margin-top: 0px;
            font-size: 11px;
            color: #888;
        }
        .developer-info {
            text-align: center;
            margin-top: 0px;
            font-size: 12px;
        }
        .developer-info div {
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .developer-info a {
            text-decoration: none;
        }
        .developer-info i {
            font-size: 16px;
            color: green;
            margin-top: 0px;
            margin-bottom: 0px;
            margin-right: 0px;
        }

.my-iframe {
        margin-top: 0px;
        margin-left: -300px;
        background-color: transparent; /* Make background color transparent */
        background: transparent;
    }

.user-dropdown {
    position: relative;
    display: inline-block;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    z-index: 1000; /* Ensure dropdown is on top */
}

.user-dropdown #fullNameDisplay {
    display: inline-flex; /* Ensures horizontal alignment */
    align-items: center; /* Aligns items vertically in the center */
    font-size: 17px;
    font-family: 'Mada', sans-serif;
}

.user-dropdown #fullNameDisplay i {
    margin-left: 5px; /* Add space between the name and the arrow */
    font-size: 17px; /* Adjust the size of the arrow */
}

.user-dropdown i {
    margin-left: 1px; /* Space between the name and the arrow */
    font-size: 17px; /* Adjust the size of the arrow */
    vertical-align: middle; /* Aligns the icon in the middle vertically */
    margin-top: -1px; /* Adjust this value to move the arrow down */
}


.user-dropdown ul {
    position: absolute;
    top: 19px; /* Ensures the menu appears below the username */
    transform: translateX(-15%); /* Adjust for perfect centering */
    background: #ffffff; /* Crisp white background for clarity */
    color: #555555; /* Slightly lighter text color for readability */
    list-style: none;
    right: auto;
left: auto;
    border: 1px solid #3d3d3d; /* Soft light border */
    margin: autopx;
    padding: 10px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 1px 5px rgba(0, 0, 0, 0.2);
    border-radius: 4px; /* Smooth rounded corners */
    min-width: auto; /* Increased width for better item spacing */
    height: 54px; /* Dynamic height based on content */
    display: none; /* Initially hidden */
    z-index: 2000; /* Ensure dropdown is above other elements */
    transition: all 0.3s ease-in-out; /* Smooth transition effect */
}


.user-dropdown ul li {
    padding: 0px 20px;
    border: none; /* Remove border */
    background: Transparent; /* Prevents any background change */
    color: #000; /* Keeps the text color the same as the default */
}

.user-dropdown ul li a {
    text-decoration: none;
    color: #000;
    margin-top: 17px;
    font-size: 15px;
    display: block;
    border: none; /* Remove border from the anchor tag */
}

#dropdownMenu li a {
    display: flex;
    align-items: center;
}

#dropdownMenu li a i {
    margin-right: 8px; /* Adjust the spacing between the icon and text */
}    

/* Media query for smaller screens (e.g., mobile devices) */
        @media (max-width: 600px) {
            .my-iframe {
                width: 390px; /* Adjust height for mobile */
            }
        }

        /* Optional: You can adjust height further for even smaller devices */
        @media (max-width: 400px) {
            .my-iframe {
                width: 390px;
            }
        }
    </style>
</head>
<body style="display: none;"> <!-- Hide content initially with display:none -->
    <script>
        document.addEventListener("DOMContentLoaded", function () {
            // Function to check the session and permissions
            fetch('check_session.php')
                .then(response => response.json())
                .then(data => {
                    if (data.success) {
                        const userPermissions = data.allowed_pages; // Permissions list
                        console.log("User permissions:", userPermissions);

                         // Display full name
                            document.getElementById('fullNameDisplay').textContent = data.full_name_ar;

                        // Normalize the current page path to match the session's allowed pages
                        const currentPage = window.location.pathname.split('/').pop(); // Extract the page name (e.g., "report.html")

                        // Check if the current page is in the allowed pages list
                        if (userPermissions.some(page => page.endsWith(currentPage))) {
                            // User is logged in and has access to this page, unhide content
                            document.body.style.display = 'flex'; // Change visibility to flex or block

                            // Select all links with `data-permission` attribute
                            const navLinks = document.querySelectorAll('[data-permission]');

                            // Show or hide links based on permissions
                            navLinks.forEach(link => {
                                const permission = link.getAttribute('data-permission');
                                if (userPermissions.includes(permission)) {
                                    link.style.display = 'flex'; // Show link if permission matches
                                } else {
                                    link.style.display = 'none'; // Hide link if no permission
                                }
                            });
                        } else {
                            // User doesn't have access to this page, redirect to Access Denied page
                            window.location.href = 'access_denied.php';
                        }
                    } else {
                        // User is not logged in or session is invalid, redirect to Access Denied page
                        window.location.href = 'access_denied.php';
                    }
                })
                .catch(error => {
                    console.error('Error fetching session data:', error);
                    // Redirect to Access Denied page if there's an error
                    window.location.href = 'access_denied.php';
                });
        });
    </script>

<!-- Hamburger Menu -->
    <div class="hamburger-menu">
        <button class="hamburger-btn" id="hamburgerBtn">
            <i class="fa fa-bars"></i>
        </button>
        <nav class="nav-menu hidden" id="navMenu">
    <!-- Wrap the h2 tag with an <a> tag -->
    <a href="/indexapp.html" class="no-hover">
    <img src="images/fares.webp" alt="" class="nav-icon">
        <h2><br>Al-Fares<br>Transportation Co.</h2>
    </a>
    <!-- Close button -->
    <button class="close-btn" id="closeBtn">&times;</button>
           <!-- Your navigation links here -->
<a href="/report.html" data-permission="/report.html" style="display: none;">
    <img src="images/back.webp" style="height: 20px; width: auto;">
    Reporting Portal
</a>
<a href="/dportal.html" data-permission="/dportal.html" target="_blank" style="display: none;">
    <img src="images/sf.webp" style="height: auto; width: 21px;">
    Driver Details Portal
</a>
<a href="/ddf.html" data-permission="/ddf.html" target="_blank" style="display: none;">
    <img src="images/driver.webp" style="height: 20px; width: 18px;">
    Add / Change Driver Details
</a>
<a href="/twb-dxr.html" data-permission="/twb-dxr.html" target="_blank" style="display: none;">
    <img src="images/dxload.webp" style="height: 22px; width: 21px;">
    Waybill Downloader
</a>
<a href="/portal.html" data-permission="/portal.html" target="_blank" style="display: none;">
    <img src="images/inv.webp" style="height: 22px; width: 21px;">
    SABIC Invoice Portal
</a>
<a href="/loc.html" data-permission="/loc.html" target="_blank" style="display: none;">
    <img src="images/loc.webp" style="height: 20px; width: 21px;">
    Customer Details
</a>
<a href="/cdf.html" data-permission="/cdf.html" target="_blank" style="display: none;">
    <img src="images/nc.webp" style="height: auto; width: 21px;">
    Add New Client Details
</a>
<a href="/pdfxtr.html" data-permission="/pdfxtr.html" style="display: none;">
    <img src="images/pdf.webp" style="height: 22px; width: 21px;">
    PDF Converter & Merger
</a>
<a href="/rename.html" data-permission="/rename.html" style="display: none;">
    <img src="images/scan88.webp" style="height: 22px; width: 21px;">
    Waybill Renamer
</a>
<!-- Add your image here -->
    <img src="images/truck2.webp" alt="" class="bottom-image">
    <div class="version-info">
        Version 4.7.0
    </div>
    <div class="developer-info">
        <b><br>Designed & Developed By</b>
        <div>
            <a href="https://wa.me/966505305180" target="_blank" rel="nofollow">
                <i class="fa">&#xf232;</i> 
            <span style="color: black; margin-top: 0px; font-size: 12px">‎ Ehsan Elahi</span></a>
        </div>
    </div>
        </nav>
    </div>

    <!-- Data section -->
    <div class="container" id="dataSection">
        <header>
    <div id="headerContent">
<a href="portal.html" id="logoLink">
  <img src="images/logo-tr.webp" alt="Home" class="logo" />
</a>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

<div class="header2">
        <h2>SABIC Invoice Portal</h2>
        <div class="user-dropdown">
    <span id="fullNameDisplay">User Name </span> <!-- Replace with dynamic user name -->
    <i id="dropdownArrow" class="fa fa-caret-down"></i>
    <ul id="dropdownMenu" class="hidden">
        <li><a href="/logout.php"><i class="fa fa-power-off" aria-hidden="true"></i>Logout‎</a></li>
    </ul>
</div>
        </div>
</div>
</header>


<iframe 
    src="https://script.google.com/macros/s/AKfycbyvnlEy6rizagI1-iAWm9aMmXjeJeBNLCZZfElIpst2LMRtWkLCKE3NLoPoBcuKPolbAA/exec"
    width="100vw" 
    height="455"
    frameborder="0"
    class="my-iframe"
    allowtransparency="true"
    style="background: transparent; width: 100vw; margin: 0; padding: 0; position: absolute; left: 0;"
    allowfullscreen>
</iframe>




   <div id="searchResultsContainer">
    <ul id="searchResults"></ul>
    </div>
</div>

    <footer style="width: 70%; padding: 0px; font-size: 0.7em;">
   <div class="footer-content" style="margin-top: 0px;">
        <span style="margin-bottom: 10px; font-size: 12px">‎&copy; 2024 Al-Fares Transportation Co.<br>All Rights Reserved<br></span>
        </div>
    </div>
</footer>

    <script>
      $(document).ready(function() {
    // Toggle navigation menu on hamburger menu button click
    $('#hamburgerBtn').click(function() {
        $('#navMenu').toggleClass('hidden');
    });

    // Close navigation menu on close button click
    $('#closeBtn').click(function() {
        $('#navMenu').addClass('hidden');
    });

    // Hide navigation menu and apply blur effect when clicking outside the menu
    $(document).on('click', function(e) {
        if (!$(e.target).closest('.hamburger-menu').length && !$(e.target).closest('.nav-menu').length) {
            if (!$('#navMenu').hasClass('hidden')) {
                $('#navMenu').addClass('hidden');
            }
        }
    });
});

$(document).ready(function() {
    // Toggle dropdown visibility when clicking on the username
    $('#fullNameDisplay').click(function(e) {
        e.stopPropagation(); // Prevent event bubbling
        $('.user-dropdown ul').toggle(); // Toggle visibility of the dropdown
    });

    // Toggle dropdown visibility when clicking on the username
    $('#dropdownArrow').click(function(e) {
        e.stopPropagation(); // Prevent event bubbling
        $('.user-dropdown ul').toggle(); // Toggle visibility of the dropdown
    });

    // Close the dropdown if the user clicks anywhere outside of the .user-dropdown
    $(document).click(function(e) {
        // Check if the clicked element is not inside the dropdown menu
        if (!$(e.target).closest('.user-dropdown').length) {
            $('.user-dropdown ul').hide(); // Hide the dropdown
        }
    });
});
    </script>

</body>
</html>