<!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">Vendors</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">Vendors</li>
                                <li class="breadcrumb-item active">View All</li>
                            </ol>
                        </div><!-- /.col -->
                    </div><!-- /.row -->
                </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">All Vendors</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="table table-bordered table-hover dataTable dtr-inline display"
                                                        aria-describedby="example2_info">
                                                        <thead>
                                                            <tr>
                                                                <th>Date &amp; Time</th>
                                                                <th>Profile</th>
                                                                <th>Company</th>
                                                                <th>Person</th>
                                                                <th>Number</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php
            
                                                                include('connection.php');

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

                                                                ?>
                                                            <tr>
                                                                <td><?php echo $row['datetime']?></td>
                                                                <td><?php echo $row['profile']?></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['company_name']?>
                                                                </td>
                                                                <td><?php echo $row['contact_person']?></td>
                                                                <td><?php echo $row['contact_number1']?></td>
                                                            </tr>
                                                            <?php }?>

                                                        </tbody>

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

                                    </div>
                                </div>

                            </div>

                        </div>

                    </div>

                </div>

            </section>

        </div>


    </div>

    <?php 
    $query = "SELECT * FROM add_vendor"; 
    $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-xl">
            <div class="modal-content">
                <div class="modal-header" style="background: #343a40; ">
                    <h4 class="modal-title text-white fw-bold text-uppercase">Profile : <?php echo $row['profile']?></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-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputPerson">Profile</label>
                                        <input type="text" name="profile" class="form-control" id="exampleInputPerson"
                                            placeholder="Profile" value="<?php echo $row['profile']; ?>">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputPerson">Contact Person</label>
                                        <input type="text" name="contact_person" class="form-control"
                                            id="exampleInputPerson" placeholder="Contact Person"
                                            value="<?php echo $row['contact_person']; ?>">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputDesignation">Designation</label>
                                        <input type="text" name="designation" class="form-control"
                                            id="exampleInputDesignation" placeholder="Designation"
                                            value="<?php echo $row['designation']; ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputNumber">Contact Number</label>
                                        <!-- <input type="number" name="contact_number1" class="form-control"
                                            id="exampleInputNumber" placeholder="Contact Number"
                                            value="<?php echo $row['contact_number1']; ?>"> -->
                                        <input type="text" class="form-control"
                                            value="<?php echo $row['contact_number1']; ?>" id="exampleInputName"
                                            placeholder="Contact Number" name="contact_number1"
                                            oninput="this.value = this.value.replace(/[^0-9]/g, '');">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputEmail">Contact Email</label>
                                        <input type="email" name="contact_email1" class="form-control"
                                            id="exampleInputEmail" placeholder="Contact Email"
                                            value="<?php echo $row['email1']; ?>">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputWebsite">Company Website</label>
                                        <input type="text" name="company_website1" class="form-control"
                                            id="exampleInputWebsite" placeholder="Company Website"
                                            value="<?php echo $row['website1']; ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="row">

                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputNumber">Contact Number 2</label>
                                        <!-- <input type="number" name="contact_number2" class="form-control"
                                            id="exampleInputNumber" placeholder="Contact Number"
                                            value="<?php echo $row['contact_number2']; ?>"> -->

                                        <input type="text" class="form-control"
                                            value="<?php echo $row['contact_number2']; ?>" id="exampleInputName"
                                            placeholder="Contact Number" name="contact_number2"
                                            oninput="this.value = this.value.replace(/[^0-9]/g, '');">
                                    </div>
                                </div>

                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputEmail">Contact Email 2</label>
                                        <input type="email" name="contact_email2" class="form-control"
                                            id="exampleInputEmail" placeholder="Contact Email"
                                            value="<?php echo $row['email2']; ?>">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputWebsite">Company Website 2</label>
                                        <input type="text" name="company_website2" class="form-control"
                                            id="exampleInputWebsite" placeholder="Company Website"
                                            value="<?php echo $row['website2']; ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputCompany">Company Name</label>
                                        <input type="text" name="company_name" class="form-control"
                                            id="exampleInputCompany" placeholder="Company Name"
                                            value="<?php echo $row['company_name']; ?>">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputDesignation">Linkedin Page</label>
                                        <div class="input-group mb-3">
                                            <div class="input-group-prepend">
                                                <a href="<?php echo $row['linkedin_page']; ?>" target="_blank"
                                                    class="input-group-text">
                                                    <i class="fab fa-linkedin"></i>
                                                </a>
                                            </div>
                                            <input type="text" name="linkedin_page"
                                                value="<?php echo $row['linkedin_page']; ?>" class="form-control"
                                                placeholder="Linkedin Page">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputDesignation">GMB Page</label>
                                        <div class="input-group mb-3">
                                            <div class="input-group-prepend">
                                                <a href="<?php echo $row['gmb_page']; ?>" target="_blank"
                                                    class="input-group-text">
                                                    <i class="fab fa-google"></i>
                                                </a>
                                            </div>
                                            <input type="text" name="gmb_page_username"
                                                value="<?php echo $row['gmb_page']; ?>" class="form-control"
                                                placeholder="GMB Page">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <label for="exampleInputEmail1">Socail Handels</label>
                            <div class="row">

                                <div class="col-lg-3 col-sm-12">
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <a href="<?php echo $row['fb']; ?>" target="_blank"
                                                class="input-group-text">
                                                <i class="fab fa-facebook"></i>
                                            </a>
                                        </div>
                                        <input type="text" name="facebook_username" value="<?php echo $row['fb']; ?>"
                                            class="form-control" placeholder="Facebook">
                                    </div>
                                </div>
                                <div class="col-lg-3 col-sm-12">
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <a href="<?php echo $row['twitt']; ?>" target="_blank"
                                                class="input-group-text">
                                                <i class="fab fa-twitter"></i>
                                            </a>
                                        </div>
                                        <input type="text" name="twitter_username" value="<?php echo $row['twitt']; ?>"
                                            class="form-control" placeholder="Twitter">
                                    </div>
                                </div>
                                <div class="col-lg-3 col-sm-12">
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <a href="<?php echo $row['insta']; ?>" target="_blank"
                                                class="input-group-text">
                                                <i class="fab fa-instagram  fw-bold"></i>
                                            </a>
                                        </div>
                                        <input type="text" name="instagram_username"
                                            value="<?php echo $row['insta']; ?>" class="form-control"
                                            placeholder="Instagram">
                                    </div>
                                </div>
                                <div class="col-lg-3 col-sm-12">
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <a href="<?php echo $row['youtube']; ?>" target="_blank"
                                                class="input-group-text">
                                                <i class="fab fa-youtube"></i>
                                            </a>
                                        </div>
                                        <input type="text" name="youtube_username"
                                            value="<?php echo $row['youtube']; ?>" class="form-control"
                                            placeholder="Youtube">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-3 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputCompany">GSTIN</label>
                                        <input type="text" name="gstin" value="<?php echo $row['gstin']; ?>"
                                            class="form-control" id="exampleInputCompany"
                                            placeholder="027AWWFV0388BH1EN">
                                    </div>
                                </div>
                                <div class="col-lg-3 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputNumber">Street Address</label>
                                        <input type="text" name="address" value="<?php echo $row['address']; ?>"
                                            class="form-control" id="exampleInputNumber" placeholder="Street Address">
                                    </div>
                                </div>
                                <div class="col-lg-2 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputEmail">City</label>
                                        <input type="text" name="city" value="<?php echo $row['city']; ?>"
                                            class="form-control" id="exampleInputEmail" placeholder="City">
                                    </div>
                                </div>
                                <div class="col-lg-2 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputWebsite">State</label>
                                        <input type="text" name="state" value="<?php echo $row['state']; ?>"
                                            class="form-control" id="exampleInputWebsite" placeholder="State">
                                    </div>
                                </div>
                                <div class="col-lg-2 col-sm-12">
                                    <div class="form-group">
                                        <label for="exampleInputWebsite">Zip Code</label>
                                        <!-- <input type="number" value="<?php echo $row['zipcode']; ?>" name="zipcode"
                                            class="form-control" id="exampleInputWebsite" placeholder="Zip Code"> -->
                                        <input type="text" class="form-control" value="<?php echo $row['zipcode']; ?>"
                                            id="exampleInputName" placeholder="Contact Number" name="zipcode"
                                            oninput="this.value = this.value.replace(/[^0-9]/g, '');">
                                    </div>
                                </div>
                            </div>


                        </div>

                        <div class="card-footer">
                            <button type="submit" class="btn text-white fw-bold"
                                style="background: #343a40; ">Update</button>
                        </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>