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

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin : All Employee</title>
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css">
    <?php include("headerlink.php") ?>
</head>

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

        <div class="preloader flex-column justify-content-center align-items-center">
            <img class="animation__shake" src="dist/img/AdminLTELogo.png" alt="AdminLTELogo" height="60" width="60">
        </div>

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

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

        <div class="content-wrapper">

            <div class="content-header">
                <div class="container-fluid">
                    <div class="row mb-2">
                        <div class="col-sm-6">
                            <h1 class="m-0 fw-bold text-uppercase">Employee</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 active">Employee</li>
                                <li class="breadcrumb-item active">View All</li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>


            <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; ">
                                    <h3 class="card-title text-white text-bold text-uppercase">All Employee</h3>
                                </div>
                                <!-- /.card-header -->
                                <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 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>Date &amp; Time</th>
                                                                <th>Employee ID</th>
                                                                <th>Name</th>
                                                                <th>Number</th>
                                                                <th>Designation</th>
                                                                <th>Salary</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php
                                                            include('connection.php');
                                                            $query = "SELECT * FROM add_employee";
                                                            $result = mysqli_query($conn, $query);
                                                            while ($row = mysqli_fetch_assoc($result)) {
                                                            ?>
                                                            <tr>
                                                                <td><?php echo $row['datetime'] ?></td>

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

                                                            </tr>
                                                            <?php } ?>

                                                        </tbody>

                                                    </table>
                                                </table>
                                            </div>
                                        </div>

                                    </div>
                                </div>

                            </div>

                        </div>

                    </div>

                </div>

            </section>

        </div>

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


    <?php
    include('connection.php');
    $query = "SELECT * FROM add_employee";
    $result = mysqli_query($conn, $query);
    while ($row = mysqli_fetch_assoc($result)) {
    ?>
    <div class="modal fade" id="detailsModal<?php echo $row['employee_id']; ?>">
        <div class="modal-dialog modal-xl">
            <div class="modal-content">
                <div class="modal-header" style="background: #343a40; ">
                    <h4 class="modal-title text-white fw-bold text-uppercase">Employee Id :
                        <?php echo $row['employee_id']?></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="add_employee_update.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-8">
                                    <div class="row">
                                        <div class="col-6">
                                            <div class="form-group">
                                                <label for="exampleInputName">Employee Name</label>
                                                <input type="text" name="name" class="form-control"
                                                    value="<?php echo $row['name']; ?>">
                                            </div>
                                        </div>
                                        <div class="col-6">
                                            <div class="form-group">
                                                <label for="exampleInputPurpose">Generate Employee ID</label>
                                                <input type="text" name="employee_id" class="form-control"
                                                    value="<?php echo $row['employee_id']; ?>">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-6">
                                            <div class="form-group">
                                                <label for="exampleInputContact1">Contact Number 1</label>
                                                <input type="text" value="<?php echo $row['number1']; ?>"
                                                    class="form-control" id="exampleInputName"
                                                    placeholder="Contact Number" name="number1"
                                                    oninput="this.value=this.value.replace(/[^0-9]/g, '');">
                                            </div>
                                        </div>
                                        <div class="col-6">
                                            <div class="form-group">
                                                <label for="exampleInputContact1">Contact Number 2</label>
                                                <input type="text" class="form-control"
                                                    value="<?php echo $row['number2']; ?>" id="exampleInputName"
                                                    placeholder="Contact Number" name="number2"
                                                    oninput="this.value = this.value.replace(/[^0-9]/g, '');">
                                            </div>
                                        </div>

                                    </div>

                                </div>

                                <div class="col-4 text-center">
                                    <div class="profile-image" style="margin-left: 53px; margin-top: 16px;">
                                        <img src="<?php echo $row['profile_picture']; ?>" alt=""
                                            style="height: 150px; width: 150px" class="img-thumbnail">
                                        <input type="file" name="file" style="display: none;">
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputContact3">Contact Email 1</label>
                                        <input type="email" name="email1" class="form-control"
                                            value="<?php echo $row['email1']; ?>">
                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputContact3">Contact Email 2</label>
                                        <input type="email" name="email2" class="form-control"
                                            value="<?php echo $row['email2']; ?>">
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-3">
                                    <div class="form-group">
                                        <label for="exampleInputContact1">Designation</label>
                                        <input type="text" name="designation" class="form-control"
                                            value="<?php echo $row['designation']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="form-group">
                                        <label for="exampleInputContact2">Salary</label>
                                        <input type="text" name="salary" class="form-control"
                                            value="<?php echo $row['salary']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="form-group">
                                        <label for="exampleInputCompany">Contact Person</label>
                                        <input type="text" name="contact_person" class="form-control"
                                            value="<?php echo $row['contact_person']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="form-group">
                                        <label for="exampleInputContact3">Joining Date</label>
                                        <input type="date" name="joining_date" class="form-control"
                                            value="<?php echo $row['joining_date']; ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-3">
                                    <div class="form-group">
                                        <label for="exampleInputCompany">Previous Company</label>
                                        <input type="text" name="previous_company" class="form-control"
                                            value="<?php echo $row['previous_company']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="form-group">
                                        <label for="exampleInputCompany">Company Website</label>
                                        <input type="text" name="company_website" class="form-control"
                                            value="<?php echo $row['company_website']; ?>">
                                    </div>
                                </div>
                              
                                <div class="col-3">
                                    <div class="form-group">
                                        <label for="exampleInputCompany">Contact Number</label>
                                        <!-- <input type="number" name="contact_number" class="form-control"
                                            value="<?php echo $row['contact_number']; ?>"> -->
                                            <input type="text" class="form-control"  value="<?php echo $row['contact_number']; ?>" id="exampleInputName" placeholder="Contact Number" name="contact_number" oninput="this.value = this.value.replace(/[^0-9]/g, '');">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="form-group">
                                        <label for="exampleInputCompany">Last Salary</label>
                                        <input type="text" name="last_salary" class="form-control"
                                            value="<?php echo $row['last_salary']; ?>">
                                    </div>
                                </div>

                            </div>
                            <label for="exampleInputEmail1">Account Details</label>
                            <div class="row">
                                <div class="col-3">
                                    <div class="input-group mb-3">
                                        <input type="text" name="bank_name" class="form-control"
                                            value="<?php echo $row['bank_name']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="input-group mb-3">
                                        <input type="text" name="account_name" class="form-control"
                                            value="<?php echo $row['account_holder_name']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="input-group mb-3">

                                        <input type="text" name="account_number" class="form-control"
                                            value="<?php echo $row['account_number']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="input-group mb-3">
                                        <input type="text" name="ifsc_code" class="form-control"
                                            value="<?php echo $row['ifsc_code']; ?>">
                                    </div>
                                </div>
                            </div>
                            <label for="exampleInputEmail1">Social Handels</label>
                            <div class="row">
                                <div class="col-3">
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <a href="<?php echo $row['facebook']; ?>" target="_blank"
                                                class="input-group-text">
                                                <i class="fab fa-facebook"></i>
                                            </a>
                                        </div>
                                        <input type="text" name="facebook_username" class="form-control"
                                            value="<?php echo $row['facebook']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <a href="<?php echo $row['twitter']; ?>" target="_blank"
                                                class="input-group-text">
                                                <i class="fab fa-twitter"></i>
                                            </a>
                                        </div>
                                        <input type="text" name="twitter_username" class="form-control"
                                            value="<?php echo $row['twitter']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <a href="<?php echo $row['instagram']; ?>" target="_blank"
                                                class="input-group-text">
                                                <i class="fab fa-instagram fw-bold"></i>
                                            </a>
                                        </div>
                                        <input type="text" name="instagram_username" class="form-control"
                                            value="<?php echo $row['instagram']; ?>">
                                    </div>
                                </div>
                                <div class="col-3">
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <a href="<?php echo $row['linkedin']; ?>" target="_blank"
                                                class="input-group-text"><i class="nav-icon fa fa-linkedin"></i></a>
                                        </div>
                                        <input type="text" class="form-control" name="linkedin"
                                            value="<?php echo $row['linkedin']; ?>">

                                    </div>
                                </div>

                            </div>

                        </div>

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

            </div>

        </div>

    </div>
    <?php } ?>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></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>
    <?php include("footerlink.php") ?>

    <script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
    <script>
    const profileImageElements = document.querySelectorAll(".profile-image");
    profileImageElements.forEach(function(element) {
        element.addEventListener("click", function() {

            const fileInput = this.querySelector("input[type='file']");
            if (fileInput) {
                fileInput.click();
            }
        });
    });
    </script>
    <script>
    var $j = jQuery.noConflict();
    $j(document).ready(function() {
        $j('#example2').DataTable();
    });
    </script>
</body>

</html>