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

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin : View Task</title>
    <?php include("headerlink.php")?>
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css">
</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">Project</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">Project</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">View All project</h3>
                                </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 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 table-bordered text-center table-hover dataTable dtr-inline display"
                                                        aria-describedby="example2_info">
                                                        <thead>
                                                            <tr>
                                                                <th>Date &amp; time</th>
                                                                <th>Task Tile</th>
                                                                <th>Platfrom</th>
                                                                <th>Total Assign</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php
                                                            include('connection.php');
                                                            $sql = "SELECT * FROM add_project ";
                                                            $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><?php echo $row['platform']?></td>

                                                                <!-- <td>
                                                                    <p class="btn btn-link view-details-button fw-bold text-danger text-uppercase"
                                                                        style="text-decoration: none; "
                                                                        data-toggle="modal"
                                                                        data-target="#detailsModal<?php echo $row['id'];?>">
                                                                        6/10
                                                                    </p>
                                                                </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'];?>">
                                                                    4/10
                                                                </td>
                                                            </tr>
                                                            <?php }?>
                                                        </tbody>

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

                                    </div>
                                </div>

                            </div>

                        </div>

                    </div>

                </div>

            </section>

        </div>

    </div>
    <?php

    $sql = "SELECT * FROM add_project ";
    $query = mysqli_query($conn, $sql);
    while ($row = mysqli_fetch_assoc($query)) {
    ?>
    <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 fw-bold text-white text-uppercase">Large Modal</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-projectcode.php" enctype="multipart/form-data">
                        <div class="card-body">
                            <input type="hidden" id="id" name="id" value="<?php echo $row['id']?>">
                            <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"
                                            value="<?php echo $row['title']?>" name="title">
                                    </div>
                                </div>
                                <div class="col-4">
                                    <div class="form-group">
                                        <label for="exampleInputName">Platform</label>
                                        <select class="form-control" name="platform">
                                            <option value="GMB Review"
                                                <?php if ($row['platform'] == 'GMB Review') echo 'selected'; ?>>GMB
                                                Review</option>
                                            <option value="JD Review"
                                                <?php if ($row['platform'] == 'JD Review') echo 'selected'; ?>>JD Review
                                            </option>
                                            <option value="Amazon Order"
                                                <?php if ($row['platform'] == 'Amazon Order') echo 'selected'; ?>>Amazon
                                                Order</option>
                                            <option value="Flipkart Order"
                                                <?php if ($row['platform'] == 'Flipkart Order') echo 'selected'; ?>>
                                                Flipkart Order</option>
                                            <option value="Youtube Like"
                                                <?php if ($row['platform'] == 'Youtube Like') echo 'selected'; ?>>
                                                Youtube Like</option>
                                        </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" value="<?php echo $row['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"
                                            name="discription"><?php echo $row['task_discription']; ?></textarea>
                                    </div>
                                </div>
                            </div>


                            <div class="row">
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputFile">Video Upload</label>
                                        <div class="custom-file">
                                            <input type="file" class="custom-file-input" id="video_file"
                                                name="video_file" onchange="displayFileName()">
                                            <label class="custom-file-label"
                                                for="video_file"><?php echo $row['video']; ?></label>
                                        </div>
                                    </div>

                                </div>
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="exampleInputFile">Image Upload</label>

                                        <div class="custom-file">
                                            <input type="file" class="custom-file-input" id="image_file"
                                                name="image_file" onchange="displayFileName()">
                                            <label class="custom-file-label"
                                                for="image_file"><?php echo $row['image']; ?></label>
                                        </div>
                                    </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 class="custom-file">
                                            <input type="file" class="custom-file-input" id="audio_file"
                                                name="audio_file" onchange="displayFileName()">
                                            <label class="custom-file-label"
                                                for="audio_file"><?php echo $row['audio']; ?></label>
                                        </div>
                                    </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 class="custom-file">
                                            <input type="file" class="custom-file-input" id="pdf_file" name="pdf_file"
                                                onchange="displayFileName()">
                                            <label class="custom-file-label"
                                                for="pdf_file"><?php echo $row['pdf']; ?></label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-12">
                                    <div class="form-group">
                                        <label for="exampleInputName">Assign Task</label>
                                        <input type="text" class="form-control" id="exampleInputName"
                                            placeholder="Add Users" name="assign_task"
                                            value="<?php echo $row['assign_task']?>">
                                    </div>
                                </div>


                            </div>
                        </div>

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

            </div>

        </div>

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



    <script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="../../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
    <script src="../../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
    <script src="../../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
    <script src="../../plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
    <script src="../../plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
    <script src="../../plugins/jszip/jszip.min.js"></script>
    <script src="../../plugins/pdfmake/pdfmake.min.js"></script>
    <script src="../../plugins/pdfmake/vfs_fonts.js"></script>
    <script src="../../plugins/datatables-buttons/js/buttons.html5.min.js"></script>
    <script src="../../plugins/datatables-buttons/js/buttons.print.min.js"></script>
    <script src="../../plugins/datatables-buttons/js/buttons.colVis.min.js"></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>
    // Use noConflict to avoid conflicts with other scripts
    var $j = jQuery.noConflict();
    $j(document).ready(function() {
        $j('#example2').DataTable();
    });

    function displayFileName() {
        var input = document.getElementById('video_file');
        var fileName = input.files[0] ? input.files[0].name : '';
        var label = input.nextElementSibling; // Get the label element
        label.innerText = fileName;
    }


    function displayFileName() {
        var input = document.getElementById('image_file');
        var fileName = input.files[0] ? input.files[0].name : '';
        var label = input.nextElementSibling; // Get the label element
        label.innerText = fileName;
    }

    function displayFileName() {
        var input = document.getElementById('audio_file');
        var fileName = input.files[0] ? input.files[0].name : '';
        var label = input.nextElementSibling; // Get the label element
        label.innerText = fileName;
    }

    function displayFileName() {
        var input = document.getElementById('pdf_file');
        var fileName = input.files[0] ? input.files[0].name : '';
        var label = input.nextElementSibling; // Get the label element
        label.innerText = fileName;
    }
    </script>
</body>

</html>