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

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin : Add Task</title>
    <?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">Group</h1>
                        </div>
                        <div class="col-sm-6">
                            <ol class="breadcrumb float-sm-right">
                                <li class="breadcrumb-item"><a href="index.php">Home</a></li>
                                <li class="breadcrumb-item active">Group</li>
                                <li class="breadcrumb-item active">Create Group</li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>


            <section class="content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card ">
                                <div class="card-header" style="background: #343a40;">
                                    <h3 class="card-title text-white fw-bold">Create Group</h3>
                                </div>
                                <form method="POST" action="add-group_code.php" enctype="multipart/form-data">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-12">
                                                <div class="form-group">
                                                    <label for="exampleInputName">Name Of Group</label>
                                                    <input type="text" class="form-control" id="exampleInputName"
                                                        name="title">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label>Add Member</label>
                                                <select class="select2" name="member[]" multiple="multiple"
                                                    data-placeholder="Add Member" style="width: 100%;">
                                                    <?php
                                                                    include('connection.php');
                                                                    $sql1 = "SELECT * FROM add_employee";
                                                                    $res1 = mysqli_query($conn, $sql1);
                                                                    while ($row = mysqli_fetch_assoc($res1)) {
                                                                    ?>
                                                    <option><?php echo $row['employee_id']; ?></option>
                                                    <?php  }  ?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="card-footer">
                                        <button type="submit" class="btn text-white fw-bold"
                                            style="background: #343a40;">Add Group</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
        <!-- <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 src="plugins/select2/js/select2.full.min.js"></script> -->
        <?php include("footerlink.php")?>

        <script>
        const employeeSelect = document.getElementById('employee-select');
        const selectedEmployeeDisplay = document.getElementById('selected-employee');
        const selectedOptionDisplay = document.getElementById('selected-option-display');

        employeeSelect.addEventListener('change', function() {
            const selectedOption = employeeSelect.options[employeeSelect.selectedIndex];
            const selectedText = selectedOption.textContent;

            if (selectedText !== 'Select an Employee') {
                selectedEmployeeDisplay.textContent = selectedText;
                selectedOptionDisplay.style.display = 'block';
            } else {
                selectedOptionDisplay.style.display = 'none';
            }
        });
        </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 } ?>
        });


        $('.select2').select2()

        //Initialize Select2 Elements
        $('.select2bs4').select2({
            theme: 'bootstrap4'
        })
        </script>
        <?php include("footer.php")?>

    </div>

</body>

</html>