<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin : View Resume</title>
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css">
    <?php include("headerlink.php") ?>
    <style>
    .password-toggle-icon {
        display: none;
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        cursor: pointer;
    }

    .password-input-container {
        position: relative;
    }
    </style>
</head>

<body class="hold-transition sidebar-mini">
    <div class="wrapper">

        <?php include("navbar.php") ?>

        <?php include("sidebar.php") ?>

        <div class="content-wrapper">

            <section class="content-header">
                <div class="container-fluid">
                    <div class="row mb-2">
                        <div class="col-sm-6">
                            <h1 class=" text-bold text-uppercase">Other Panel</h1>
                        </div>
                        <div class="col-sm-6">
                            <ol class="breadcrumb float-sm-right">
                                <li class="breadcrumb-item"><a href="#">Home</a></li>
                                <li class="breadcrumb-item"><a href="#">Panel</a></li>
                                <li class="breadcrumb-item active">View All</li>
                            </ol>
                        </div>
                    </div>

                </div>

            </section>

            <section class="content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-12">
                            <div class="card shadow">
                                <div class="card-header" style="background: #343a40; ">
                                    <div class="row">
                                        <div class="col-10">
                                            <h3 class="card-title text-white text-bold text-uppercase pt-1">All Panel
                                            </h3>
                                        </div>

                                    </div>

                                </div>


                                <div class="card-body">
                                    <div id="example2_wrapper" class="dataTables_wrapper dt-bootstrap4">
                                        <div class="row">

                                            <div class="col-sm-12 col-md-6">
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <table class="table-responsive">
                                                    <table id="example2"
                                                        class="table text-center table-bordered table-hover dataTable dtr-inline display"
                                                        aria-describedby="example2_info">
                                                        <thead>
                                                            <tr>
                                                                <th>Sr No.</th>
                                                                <th>Date</th>
                                                                <!-- <th>Company Name</th> -->
                                                                <!-- <th>Company Website</th> -->
                                                                <!-- <th>Concern Person</th> -->
                                                                <th>Contact Number</th>
                                                                <th>Email</th>
                                                                <th>Service</th>
                                                                <th>Rate</th>
                                                                <!-- <th>service_url</th> -->
                                                                <th>Username</th>
                                                                <th>password</th>
                                                                <th>Action</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php

                                                            include('connection.php');

                                                            $sql = "SELECT * FROM add_panel ";
                                                            $query = mysqli_query($conn, $sql);
                                                            while ($row = mysqli_fetch_assoc($query)) {

                                                            ?>
                                                            <tr>
                                                                <td><?php echo $row['id']?></td>
                                                                <td> <?php echo $row['datetime'] ?></td>
                                                           
                                                                <td><?php echo $row['contact_number'] ?></td>

                                                                <td class="view-details-button fw-bold text-danger"
                                                                    style="text-decoration: none; " data-toggle="modal"
                                                                    data-target="#detailsModal<?php echo $row['id']; ?>">
                                                                    <?php echo $row['email'] ?>
                                                                </td>

                                                                <td><?php echo $row['service'] ?></td>
                                                                <td><?php echo $row['rate'] ?></td>
                                                              
                                                                <td><?php echo $row['Username'] ?></td>
                                                                <td><?php echo $row['password'] ?></td>
                                                                <td>
                                                                    <a href="delete_other_panel.php?delete=<?php echo $row['id']?>" class="btn btn-danger btn-sm">Delete</a>
                                                                   
                                                                </td>


                                                            </tr>

                                                            <?php } ?>
                                                        </tbody>

                                                    </table>
                                                </table>

                                            </div>
                                        </div>

                                    </div>
                                </div>

                            </div>

                        </div>

                    </div>

                </div>

            </section>
        </div>

        <?php include("footer.php") ?>

    </div>
    <?php
    $query = "SELECT * FROM add_panel";
    $result = mysqli_query($conn, $query);
    while ($row = mysqli_fetch_assoc($result)) {
    ?>

    <div class="modal fade" id="detailsModal<?php echo $row['id']; ?>">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header" style="background: #343a40; ">
                    <h4 class="modal-title text-white fw-bold text-uppercase">Service : <?php echo $row['service'] ?>
                    </h4>
                    <button type="button " class="close text-white" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form method="POST" action="update_otherpannel_code.php" enctype="multipart/form-data">
                        <div class="card-body">

                            <input type="hidden" name="id" value="<?php echo $row['id']; ?>">

                            <div class="row">
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputtitle">Company Name</label>
                                        <input type="text" class="form-control" id="exampleInputtitle"
                                            placeholder="Website" name="company_name"
                                            value="<?php echo $row['company_name']; ?>">
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputtitle">Company's Website</label>
                                        <input type="text" class="form-control" id="exampleInputtitle"
                                            placeholder="Username" name="company_website"
                                            value="<?php echo $row['company_website']; ?>">
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputtitle">Concern Person</label>
                                        <input type="text" class="form-control" id="exampleInputtitle"
                                            placeholder="Concern Person" name="concern_person"
                                            value="<?php echo $row['concern_person']; ?>">
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputtitle">Contact Number</label>
                                        <input type="text" class="form-control" id="exampleInputName"
                                            placeholder="Contact Number" value="<?php echo $row['contact_number']; ?>"
                                            name="contact_number"
                                            oninput="this.value = this.value.replace(/[^0-9]/g, '');">
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputtitle">Email </label>
                                        <input type="text" class="form-control" id="exampleInputtitle"
                                            placeholder="Email" name="email" value="<?php echo $row['email']; ?>">
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputtitle">Service </label>
                                        <input type="text" class="form-control" id="exampleInputtitle"
                                            placeholder="Service" name="service" value="<?php echo $row['service']; ?>">
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputtitle">Rate</label>
                                        <input type="text" class="form-control" value="<?php echo $row['rate']; ?>"
                                            id="exampleInputName" placeholder="Rate" name="rate"
                                            oninput="this.value = this.value.replace(/[^0-9]/g, '');">
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputtitle">Service URL</label>
                                        <input type="text" value="<?php echo $row['service_url']; ?>"
                                            class="form-control" id="exampleInputtitle" placeholder="Service URL"
                                            name="service_url">
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputtitle">Username</label>
                                        <input type="text" value="<?php echo $row['Username']; ?>" class="form-control"
                                            id="exampleInputtitle" placeholder="Username" name="Username">
                                    </div>
                                </div>

                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputPassword">Password</label>
                                        <div class="password-input-container">
                                            <input type="password" value="<?php echo $row['password']; ?>" class="form-control" id="exampleInputPassword"
                                                placeholder="Password" name="password">
                                            <i class="fa fa-eye-slash password-toggle-icon" id="passwordToggle"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>


                        </div>
                        <div class="modal-footer justify-content-between">
                            <button type="submit" class="btn text-white fw-bold" style="background: #343a40;">Update
                                changes</button>
                        </div>
                    </form>


                </div>

            </div>

        </div>

    </div>
    <?php } ?>


    <?php include("footerlink.php") ?>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>

    <script>
    const passwordInput = document.getElementById("exampleInputPassword");
    const passwordToggleIcon = document.getElementById("passwordToggle");

    passwordInput.addEventListener("input", function() {
        if (passwordInput.value.length > 0) {
            passwordToggleIcon.style.display = "inline";
        } else {
            passwordToggleIcon.style.display = "none";
        }
    });

    passwordToggleIcon.addEventListener("click", function() {
        if (passwordInput.type === "password") {
            passwordInput.type = "text";
            passwordToggleIcon.classList.remove("fa-eye-slash");
            passwordToggleIcon.classList.add("fa-eye");
        } else {
            passwordInput.type = "password";
            passwordToggleIcon.classList.remove("fa-eye");
            passwordToggleIcon.classList.add("fa-eye-slash");
        }
    });
    </script>

    <script>
    $(document).ready(function() {
        <?php if (isset($_GET['error'])) { ?>
        Swal.fire({
            title: 'Error',
            text: '<?php echo $_GET['error']; ?>',
            icon: 'error',
            confirmButtonText: 'OK',
            confirmButtonClass: 'btn btn-success btn-lg',
        });
        <?php } ?>
        <?php if (isset($_GET['success'])) { ?>
        Swal.fire({
            title: 'Success',
            text: '<?php echo $_GET['success']; ?>',
            icon: 'success',
            confirmButtonText: 'OK',
            confirmButtonClass: 'btn btn-success btn-lg',
        });
        <?php } ?>
    });
    </script>



    <script>
    // Use noConflict to avoid conflicts with other scripts
    var $j = jQuery.noConflict();
    $j(document).ready(function() {
        $j('#example2').DataTable();
    });
    </script>
</body>

</html>