<!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">Task</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">Task</li>
                                <li class="breadcrumb-item active">Add New</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"> Group Add Task</h3>
                                </div>

                                <form method="POST" action="add-taskcode.php" enctype="multipart/form-data">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-4">
                                                <div class="form-group">
                                                    <label for="exampleInputName">Task Title</label>
                                                    <input type="text" class="form-control" id="exampleInputName"
                                                        placeholder="Ex: GMB 10 Reviews" name="title">
                                                </div>
                                            </div>
                                            <div class="col-4">
                                                <div class="form-group">
                                                    <label for="exampleInputName">Platform </label>
                                                    
                                                    <select name="platfrom"  class="form-control">
                                                        <?php
                                                            include('connection.php');
                                                            $sql1 = "SELECT * FROM add_platform";
                                                            $res1 = mysqli_query($conn, $sql1);
                                                            while ($row = mysqli_fetch_assoc($res1)) {
                                                            ?>
                                                        <option value="<?php echo $row['name']; ?>">
                                                            <?php echo $row['name']; ?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-4">
                                                <div class="form-group">
                                                    <label for="exampleInputPurpose">URL</label>
                                                    <input type="text" name="url" class="form-control"
                                                        id="exampleInputPurpose" placeholder="URL">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-12">
                                                <div class="form-group">
                                                    <label for="exampleInputContact1">Task Discription</label>
                                                    <textarea id="" rows="5" class="form-control"
                                                        placeholder="Type Task Discription here...."
                                                        name="discription"></textarea>
                                                </div>
                                            </div>

                                        </div>


                                        <div class="row">
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputFile">Video Upload</label>
                                                    <input type="file" class="form-control" name="video_file">
                                                </div>
                                            </div>
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputFile">Image Upload</label>
                                                    <input type="file" class="form-control" name="image_file">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputFile">Audio Upload</label>
                                                    <input type="file" class="form-control" name="audio_file">

                                                </div>
                                            </div>
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputFile">Pdf Upload</label>
                                                    <input type="file" class="form-control" name="pdf_file">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputName">Assign To Group Task</label>
                                                    <select name="group" id="group" class="form-control">
                                                        <?php
                                                            include('connection.php');
                                                            $sql1 = "SELECT * FROM groups";
                                                            $res1 = mysqli_query($conn, $sql1);
                                                            while ($row = mysqli_fetch_assoc($res1)) {
                                                            ?>
                                                        <option value="<?php echo $row['group_name']; ?>">
                                                            <?php echo $row['group_name']; ?></option>
                                                        <?php } ?>
                                                    </select>

                                                </div>
                                            </div>

                                        </div>
                                    </div>

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


            <section class="content my-5">
                <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"> Member Add Task</h3>
                                </div>

                                <form method="POST" action="member_add-taskcode.php" enctype="multipart/form-data">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-4">
                                                <div class="form-group">
                                                    <label for="exampleInputName">Task Title</label>
                                                    <input type="text" class="form-control" id="exampleInputName"
                                                        placeholder="Ex: GMB 10 Reviews" name="title">
                                                </div>
                                            </div>
                                            <div class="col-4">
                                                <div class="form-group">
                                                    <label for="exampleInputName">Platform </label>
                                                    <select name="platfrom"  class="form-control">
                                                        <?php
                                                            include('connection.php');
                                                            $sql1 = "SELECT * FROM add_platform";
                                                            $res1 = mysqli_query($conn, $sql1);
                                                            while ($row = mysqli_fetch_assoc($res1)) {
                                                            ?>
                                                        <option value="<?php echo $row['name']; ?>">
                                                            <?php echo $row['name']; ?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-4">
                                                <div class="form-group">
                                                    <label for="exampleInputPurpose">URL</label>
                                                    <input type="text" name="url" class="form-control"
                                                        id="exampleInputPurpose" placeholder="URL">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-12">
                                                <div class="form-group">
                                                    <label for="exampleInputContact1">Task Discription</label>
                                                    <textarea id="" rows="5" class="form-control"
                                                        placeholder="Type Task Discription here...."
                                                        name="discription"></textarea>
                                                </div>
                                            </div>

                                        </div>


                                        <div class="row">
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputFile">Video Upload</label>
                                                    <input type="file" class="form-control" name="video_file">
                                                </div>
                                            </div>
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputFile">Image Upload</label>
                                                    <input type="file" class="form-control" name="image_file">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputFile">Audio Upload</label>
                                                    <input type="file" class="form-control" name="audio_file">

                                                </div>
                                            </div>
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputFile">Pdf Upload</label>
                                                    <input type="file" class="form-control" name="pdf_file">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-6">
                                                <div class="form-group">
                                                    <label for="exampleInputName">Assign To Member Task</label>
                                                    <select name="member" class="form-control">
                                                        <?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>

                                    <div class="card-footer">
                                        <button type="submit" class="btn text-white fw-bold"
                                            style="background: #343a40;">Create Task</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>
        document.getElementById('group').addEventListener('change', function() {
            var selectedGroup = this.value;
            var xhr = new XMLHttpRequest();
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    document.getElementById('members').innerHTML = xhr.responseText;
                }
            };
            xhr.open('GET', 'get_members.php?group=' + selectedGroup, true);
            xhr.send();
        });
        </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("footer.php")?>
    </div>
    <?php include("footerlink.php")?>
</body>

</html>