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

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin : View Resume</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">
    <div class="wrapper">

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

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

        <div class="content-wrapper">

            <section class="content-header">
                <div class="container-fluid">
                    <div class="row mb-2">
                        <div class="col-sm-6">
                            <h1 class=" text-bold text-uppercase">PLATFORM</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"><a href="#">Task</a></li>
                                <li class="breadcrumb-item active">View All</li>
                            </ol>
                        </div>
                    </div>

                </div>

            </section>

            <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; ">
                                    <div class="row">
                                        <div class="col-10">
                                            <h3 class="card-title text-white text-bold text-uppercase pt-1">All Platform
                                            </h3>
                                        </div>
                                        <div class="col-2 text-end">
                                            <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#modal-success">
                                                <i class="fa fa-plus-circle" aria-hidden="true"></i>
                                            </button>
                                        </div>
                                    </div>
                                </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>
                                        <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 text-center" aria-describedby="example2_info">
                                                        <thead>
                                                            <tr>
                                                                <th>Sr No.</th>
                                                                <th>Date</th>
                                                                <th>Platform</th>
                                                                <th>Action</th>

                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php

                                                            include('connection.php');

                                                            $sql = "SELECT * FROM add_platform ";
                                                            $query = mysqli_query($conn, $sql);
                                                            while ($row = mysqli_fetch_assoc($query)) {

                                                            ?>
                                                                <tr>
                                                                    <td><?php echo $row['id'] ?></td>
                                                                    <td> <?php echo $row['date'] ?></td>
                                                                    <td><?php echo $row['name'] ?></td>
                                                                    <td>
                                                                        <div class="d-flex">
                                                                            <form action="delete_platform.php" method="POST">
                                                                                <input type="hidden" name="platform_id" value="<?php echo $row['id']; ?>">
                                                                                <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                                                                            </form>&emsp;

                                                                            <!-- <button class="btn btn-success btn-sm">Edit</button> -->
                                                                            <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#detailsModal<?php echo $row['id']; ?>">
                                                                                Edit
                                                                            </button>
                                                                        </div>
                                                                    </td>
                                                                    <!-- edit platform model -->
                                                                    <div class="modal fade" id="detailsModal<?php echo $row['id']; ?>">
                                                                        <div class="modal-dialog">
                                                                            <div class="modal-content bg-white">
                                                                                <div class="modal-header bg-dark text-white">
                                                                                    <h4 class="modal-title fw-bold">Update
                                                                                        Platform</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_platform_code.php" method="POST">
                                                                                        <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
                                                                                        <label for="">Enter New
                                                                                            Platform</label>
                                                                                        <input type="text" name="newPlatform" value="<?php echo $row['name']; ?>" class="form-control">
                                                                                        <hr>
                                                                                        <button class="btn btn-dark text-white" type="submit">Update</button>
                                                                                    </form>
                                                                                </div>

                                                                            </div>
                                                                            <!-- /.modal-content -->
                                                                        </div>
                                                                        <!-- /.modal-dialog -->
                                                                    </div>

                                                                </tr>

                                                            <?php } ?>
                                                        </tbody>

                                                    </table>
                                                </table>

                                            </div>
                                        </div>

                                    </div>
                                </div>

                            </div>

                        </div>

                    </div>

                </div>

            </section>
        </div>

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

    </div>
    <!-- add plate form code model -->
    <div class="modal fade" id="modal-success">
        <div class="modal-dialog">
            <div class="modal-content bg-white">
                <div class="modal-header bg-dark text-white">
                    <h4 class="modal-title fw-bold">Add Platform</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="platform_code.php" method="POST">
                        <label for="">Enter New Platform</label>
                        <input type="text" name="newPlatform" id="" class="form-control">
                        <hr>
                        <button class="btn btn-dark text-white" type="submit">Submit</button>
                    </form>
                </div>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>




    <?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>
        $(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>