<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Job/Project Table</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />

    <style>
        .alljobposting{
        body {
            font-family: Arial, sans-serif;
            font-size: 15px;
        }
        table {
            border-collapse: collapse;
            transform: scale(0.7);
            transform-origin: 0 0;
            width:130%;
            margin-left:80px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            transition: transform 0.3s ease, background-color 0.3s ease;
        }
        th {
            background-color: #F2F2F2;
            white-space: normal;
        }
        tr:nth-child(even) {
            background-color: #F2F2F2;
        }
        a {
            text-decoration: none;
        }
        .AllJobsearch {
            display: inline-block;
            position: relative;
        }
        .AllJobsearch input[type="text"] {
            border-radius: 5px;
            height: 33px;
            width: 180px; /* Adjusted width */
            padding-left: 30px; /* Space for the search icon */
            border: 1px solid black;
        }
        .AllJobsearch .fa-magnifying-glass {
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            color: black;
        }
        .table-container {
            margin-left: 240px;
            max-height: 900px; /* Set the height as needed */

        }

        td {
            word-break: break-word;
            white-space: normal;
            text-align:center;
        }
    .modal {
    display: none; /* Hidden by default */
    position: fixed;  /* Sit on top */
    left: 200px;
    top: 30px;
    width: 40%; /* Full width */
    height: 80%; /* Full height */

}

.modal-content {
    background-color: #fff;
    margin: 15% auto; /* 15% from the top and centered */
    padding: 20px;
    border: 1px white;
    width: 50%; /* Could be more or less, depending on screen size */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border-radius: 5px;

}
   .close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: red;
    text-decoration: none;
    cursor: pointer;
}
}

    </style>
</head>
<body>
<div class="alljobposting">
  <div id="AllJobPostingTable" style="margin-top:70px;">
    <div style="position: relative;">
        <h2 style="display: inline-block; margin-left: 300px;">All Job Posting</h2>
        <div class="" style="display: inline-block;">
            <div class="AllJobsearch">
                <i class="fa-solid fa-magnifying-glass" style="position: absolute; left: 160px; top: 58%; transform: translateY(-50%); color: black;"></i>
                <input type="text" id="searchInput" placeholder="Search by JobId" onkeyup="searchJob()">
            </div>
        </div>
    </div>
    <br>
    <div class="table-container">
        <table id="alljobposting" >
            <tr>
                <th>Client</th>
                <th>JobId</th>
                <th>Header</th>
                <th>SPOC</th>
                <th>No of Postings</th>
                <th>Start Date</th>
                <th>Budget Max Rs</th>
                <th>Location</th>
                <th>JD</th>
            </tr>
            {% for posting in job_postings %}
            <tbody>
                <td><a href="#" class="client-link"  data-client="{{ posting.Client }}">{{ posting.Client }}</a></td>
                <td><a href="#" class="jobId-link" data-JobId="{{ posting.JobID }}">{{ posting.JobID }}</a></td>
                <td>{{ posting.Header }}</td>
                <td>{{ posting.SPOC }}</td>
                <td>{{ posting.NoOfPosting }}</td>
                <td>{{ posting.StartDate }}</td>
                <td>{{ posting.maxAmount }}</td>
                <td>{{ posting.Location }}</td>
                <td><a href="{{ posting.JD }}">{{ posting.slice_JD }}</a></td>
            </tbody>
            {% endfor %}
        </table>
        <input id="restrictedField" value="{{ restricted|yesno:'True,False' }}" style="display:none;margin-left: 500px;">
    </div>
    <!-- Modal Structure -->
<div id="detailsModal" class="modal" style="margin-left:300px; display:none; width:60%; height:auto;">
    <div class="modal-content">
        <p><strong>Parent Company:</strong> <span id="parentCompany" style="margin-left:10px;"></span></p><br>
        <p><strong>GST No:</strong> <span id="gstNo" style="margin-left:75px;"></span></p><br>
        <p><strong>Location ID:</strong> <span id="locationId" style="margin-left:47px;"></span></p><br>
        <p><strong>Address 1:</strong> <span id="address1" style="margin-left:57px;"></span></p><br>
        <p><strong>Address 2:</strong> <span id="address2" style="margin-left:57px;"></span></p><br>
        <p><strong>City:</strong> <span id="city" style="margin-left:100px;"></span></p><br>
        <p><strong>State:</strong> <span id="state" style="margin-left:90px;"></span></p><br>
        <p><strong>Pincode:</strong> <span id="pincode" style="margin-left:70px;"></span></p><br>
        <p><strong>Country:</strong> <span id="country" style="margin-left:72px;"></span></p><br>
        <button id="closePopup" style="background-color:red; color:white; border-radius:5px; border: 1px red;padding: 10px;
              width:60px; margin-left:150px" >close</button>
    </div>

</div>

<div id="detailsModal2" class="modal" style="margin-left:300px; display:none; margin-top:-80px; width:60%; height:auto;">
    <div class="modal-content">
        <p><strong>Client:</strong> <span id="Client" style="margin-left:85px;"></span></p><br>
        <p><strong>JobID:</strong> <span id="JobID" style="margin-left:87px;"></span></p><br>
        <p><strong>Location:</strong> <span id="Location" style="margin-left:65px;"></span></p><br>
        <p><strong>SPOC:</strong> <span id="SPOC" style="margin-left:87px;"></span></p><br>
        <p><strong>SPOC2:</strong> <span id="SPOC2" style="margin-left:81px;;"></span></p><br>
        <p><strong>NoOfPosting:</strong> <span id="NoOfPosting" style="margin-left:42px;"></span></p><br>
        <p><strong>StartDate:</strong> <span id="StartDate" style="margin-left:70px;"></span></p><br>
        <p><strong>CloseDate:</strong> <span id="CloseDate" style="margin-left:65px;"></span></p><br>
        <p><strong>Experience_in_Yrs:</strong> <span id="Experience_in_Yrs" style="margin-left:10px;"></span></p><br>
        <p><strong>BudgetMin:</strong> <span id="BudgetMin" style="margin-left:63px;"></span></p><br>
        <p><strong>Qualification:</strong> <span id="Qualification" style="margin-left:50px;"></span></p><br>
        <p><strong>Header:</strong> <span id="Header" style="margin-left:90px;"></span></p><br>
        <p><strong>JobDescription:</strong> <span id="JobDescription" style="margin-left:33px;"></span></p><br>
        <p><strong>SpecialInstructions:</strong> <span id="SpecialInstructions" style="margin-left:7px;"></span></p><br>

        <button id="closePopup2" style="background-color:red; color:white; border-radius:5px; border: 1px red;padding: 10px;
              width:60px; margin-left:150px" >close</button>
    </div>

</div>

  </div>
    </div>
    <script>
        function searchJob() {
            var input, filter, table, tr, td, i, txtValue;
            input = document.getElementById("searchInput");
            filter = input.value.toUpperCase();
            table = document.getElementById("alljobposting");
            tr = table.getElementsByTagName("tr");
            for (i = 1; i < tr.length; i++) {
                td = tr[i].getElementsByTagName("td")[1]; // Get the second column (JobID)
                if (td) {
                    txtValue = td.textContent || td.innerText;
                    if (txtValue.toUpperCase().indexOf(filter) > -1) {
                        tr[i].style.display = "";
                    } else {
                        tr[i].style.display = "none";
                    }
                }
            }
        }
    </script>
</body>
</html>
