<?php
require("header.php")
?>
<style>
    .btn-group>.btn:not(:last-child):not(.dropdown-toggle) {
        background: black;
    }

    .btn-group>.btn-group:not(:first-child)>.btn {
        background: black;
    }

    .page-item.active .page-link {
        background: black;
    }

    .dt-button-collection .dropdown-menu .buttons-columnVisibility {
        background-color: black;
    }
</style>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <!-- <h1>Add Vender</h1> -->
                </div>
                <div class="col-sm-6">

                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <!-- /.card -->

                    <div class="card  card-secondary">
                        <div class="card-header" style="background-color: black;">
                            <h3 class="card-title"> Add Vendors</h3>
                            <ol class="breadcrumb float-sm-right" style="background-color: black;">
                                <li class="breadcrumb-item"><a href="dashboad.php">Home</a></li>
                                <li class="breadcrumb-item active">Add Vendors</li>
                            </ol>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">

                            <form action="add_vender_code.php" method="post">
                                <div class="row">
                                    <br>


                                    <div class="col-sm-10">

                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Vendor name <span style="color:red; font-size:25px;">*<span></label>
                                            <input type="text" name="vendor_name" class="form-control" id="exampleInputEmail1" placeholder="Enter Vendor Name" required>

                                        </div>
                                    </div>
                                    <div class="col-sm-2">

                                        <button style="margin-top: 45px; width:95%; margin-left:5%; background:black;" type="submit" name="add" class="btn btn-dark">Create</button>

                                    </div>

                                </div>

                            </form>

                            <table id="example1" class="table table-bordered table-striped">
                                <thead>
                                    <tr>
                                        <th>Sr.no</th>
                                        <th>Date</th>

                                        <th>Vender Name</th>

                                        <th>Status</th>

                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    include('connection.php');
                                    $i = 0;
                                    $sql = "SELECT * FROM vendor ORDER BY date_time";
                                    $res = mysqli_query($conn, $sql);
                                    while ($row = mysqli_fetch_assoc($res)) {
                                        $i++;

                                    ?>

                                        <tr>
                                            <td><?php echo $i; ?></td>
                                            <td><?php echo $row['date_time'];  ?></td>

                                            <td><?php echo $row['vendor_name'];  ?></td>
                                            <td>

                                                <form method="POST" action="add_vender_code.php">

                                                    <input type="hidden" name="item_id" value="<?php echo $row['id']; ?>">
                                                    <?php if ($row['status'] == 1) { ?>
                                                        <input type="submit" name="block" value="Block" class="btn btn-danger" style="font-weight: 600;font-size: 12px;height: 30px;">
                                                    <?php } else { ?>
                                                        <input type="submit" name="activate" value="Activate" class="btn btn-success" style="font-weight: 600;font-size: 12px;height: 30px;">
                                                    <?php } ?>
                                                    <!-- <?php echo ($row['status'] == 1) ? "<div class='test rounded-circle'></div>" : "<div class='test2 rounded-circle'></div>"; ?> -->
                                                </form>

                                            </td>
                                            <!-- <td><button type="submit" id="approve_button" class="btn btn-success">Active</button></td> -->
                                        </tr>
                                    <?php
                                    }
                                    ?>

                                </tbody>

                            </table>
                        </div>
                        <!-- /.card-body -->

                    </div>

                </div>

                <!-- /.card -->
            </div>

            <!-- /.col -->
        </div>
        <!-- /.row -->

        <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
</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).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>

<!-- pagination -->

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