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

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin : All Vendors</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">
        <!-- Preloader -->
        <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") ?>
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <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">Update Task</h1>
                        </div><!-- /.col -->
                        <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">View All</li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.content-header -->

            <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">Update All Task</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="text-center table table-bordered table-hover dataTable dtr-inline display" aria-describedby="example2_info">
                                                        <thead>
                                                            <tr>
                                                                <th>Date &amp; Time</th>
                                                                <th>Title</th>
                                                                <th>Employee Id</th>
                                                                <th>Description</th>
                                                                <th>Message</th>
                                                                <th>Url</th>
                                                                <th>Status</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php

                                                            include('connection.php');

                                                            $sql = "SELECT * FROM `member_update_task` where status='pending'";

                                                            $query = mysqli_query($conn, $sql);

                                                            while ($row = mysqli_fetch_assoc($query)) {

                                                            ?>
                                                                <tr>
                                                                    <td><?php echo $row['datetime'] ?></td>
                                                                    <td><?php echo $row['title'] ?></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['id']; ?>">
                                                                        <?php echo $row['member'] ?>
                                                                    </td>
                                                                
                                                                    <td><?php echo $row['description'] ?></td>
                                                                    <td><?php echo $row['msg'] ?></td>
                                                                    <td><?php echo $row['url'] ?></td>


                                                                    <td>
                                                                        <form method="POST" action="update_member_taskstatus_code.php">
                                                                            <input type="hidden" name="item_id" value="<?php echo $row['id']; ?>">
                                                                            <input type="hidden" name="current_status" value="<?php echo $row['status']; ?>">

                                                                            <?php if ($row['status'] == 'complete') { ?>
                                                                                <input type="submit" name="change_status" value="Pending" class="btn btn-danger" style="font-weight: 600; font-size: 12px; height: 30px;">
                                                                            <?php } else { ?>
                                                                                <input type="submit" name="change_status" value="Complete" class="btn btn-success" style="font-weight: 600; font-size: 12px; height: 30px;">
                                                                            <?php } ?>
                                                                        </form>
                                                                    </td>
                                                                </tr>
                                                            <?php } ?>
                                                        </tbody>
                                                    </table>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            <!-- complete Task  -->
            <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">Complete All Task</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="text-center table table-bordered table-hover dataTable dtr-inline display" aria-describedby="example2_info">
                                                        <thead>
                                                            <tr>
                                                                <th>Date &amp; Time</th>
                                                                <th>Title</th>
                                                                <th>Employee Id</th>
                                                             
                                                                <th>Description</th>
                                                                <th>Message</th>
                                                                <th>Url</th>
                                                                <th>Status</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php

                                                            include('connection.php');

                                                            $sql = "SELECT * FROM member_update_task WHERE status='complete'";
                                                            $query = mysqli_query($conn, $sql);
                                                            while ($row = mysqli_fetch_assoc($query)) {

                                                            ?>
                                                                <tr>
                                                                    <td><?php echo $row['datetime'] ?></td>
                                                                    <td><?php echo $row['title'] ?></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['id']; ?>">
                                                                        <?php echo $row['member'] ?>
                                                                    </td>
                                                            
                                                                    <td><?php echo $row['description'] ?></td>
                                                                    <td><?php echo $row['msg'] ?></td>
                                                                    <td><?php echo $row['url'] ?></td>


                                                                    <td>
                                                                        <form method="POST" action="update_member_taskstatus_code.php">
                                                                            <input type="hidden" name="item_id" value="<?php echo $row['id']; ?>">
                                                                            <input type="hidden" name="current_status" value="<?php echo $row['status']; ?>">

                                                                            <?php if ($row['status'] == 'complete') { ?>
                                                                                <input type="submit" name="change_status" value="Pending" class="btn btn-danger" style="font-weight: 600; font-size: 12px; height: 30px;">
                                                                            <?php } else { ?>
                                                                                <input type="submit" name="change_status" value="Complete" class="btn btn-success" style="font-weight: 600; font-size: 12px; height: 30px;">
                                                                            <?php } ?>
                                                                        </form>
                                                                    </td>
                                                                </tr>
                                                            <?php } ?>
                                                        </tbody>
                                                    </table>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>


    </div>

    <?php
    $query = "SELECT * FROM member_update_task";
    $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-md">
                <div class="modal-content">
                    <div class="modal-header" style="background: #343a40; ">
                        <h4 class="modal-title text-white fw-bold text-uppercase">Member Id :
                            <?php echo $row['member'] ?></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 action="update_vendor_code.php" method="POST">
                            <div class="card-body">
                                <div class="row">
                                    <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
                                    <div class="col-lg-6 col-sm-12">
                                        <div class="form-group">
                                            <label for="exampleInputPerson">PDF</label>
                                            <input type="text" name="profile" class="form-control" placeholder="Profile" value="<?php echo $row['pdf']; ?>">
                                        </div>
                                    </div>
                                    <div class="col-lg-6 col-sm-12">
                                        <div class="form-group">
                                            <label for="exampleInputPerson">Video Name</label>
                                            <input type="text" name="contact_person" class="form-control" id="exampleInputPerson" placeholder="Contact Person" value="<?php echo $row['video']; ?>">
                                        </div>
                                    </div>

                                </div>
                                <div class="row">
                                    <div class="col-lg-6 col-sm-12">
                                        <div class="form-group">
                                            <label for="exampleInputDesignation">Audio Name</label>
                                            <input type="text" name="designation" class="form-control" id="exampleInputDesignation" placeholder="Designation" value="<?php echo $row['audio']; ?>">
                                        </div>
                                    </div>
                                    <div class="col-lg-6 col-sm-12">
                                        <div class="form-group">
                                            <label for="exampleInputDesignation">PDF Name</label>
                                            <input type="text" name="designation" class="form-control" id="exampleInputDesignation" placeholder="Designation" value="<?php echo $row['pdf']; ?>">
                                        </div>
                                    </div>
                                </div>

                            </div>
                    </div>
                    </form>
                </div>

            </div>

        </div>

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



    <!-- Page specific script -->
    <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 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>
    <script>
        // Use noConflict to avoid conflicts with other scripts
        var $j = jQuery.noConflict();
        $j(document).ready(function() {
            $j('#example2').DataTable();
        });
    </script>
</body>

</html>