<?php include("auth.php") ?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title>Partner Accounts List</title>
  <meta content="" name="description">
  <meta content="" name="keywords">
  <?php include("templates/inc.php"); ?>
  <script src="scripts/vendor.js" type="text/javascript" language="javascript"></script>
</head>

<body>

  <!-- ======= Header ======= -->
  <?php
  include("templates/header.php");
  ?>

  <!-- End Header -->

  <!-- ======= Sidebar ======= -->
  <?php
  include("templates/sidebar.php");

  ?>
  <!-- End Sidebar-->

  <main id="main" class="main">

    <div class="pagetitle">
      <h1>Partner Accounts List</h1>
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
          <li class="breadcrumb-item">Partner Accounts List</li>

        </ol>
      </nav>
      <hr>
    </div><!-- End Page Title -->


      <section class="section">
        <div class="row">
          <div class="col-lg-12">

            <div class="card" style="overflow:scroll;">
              <div class="card-body" id="records">
                <h5 class="card-title">Partner Accounts List</h5>
                <table class="table datatable">
                  <thead>
                    <tr>
                      <th scope="col">Id</th>

                      <!--<th scope="col">Photo</th>-->
                      <th scope="col">Partner</th>
                      <!--<th scope="col">Dealer</th>-->
                      <th scope="col">Name</th>
                      <th scope="col">Role</th>
                      <th scope="col">Desig.</th>
                      <th scope="col">Email</th>
                      <th scope="col">Mobile No</th>
                      <th scope="col">Status</th>
                      <th scope="col">Edit</th>
                      <th scope="col">Delete</th>
                    </tr>
                  </thead>

                  <tbody>
                    <?php
                    require "conn.php";
                    $sl = 1;
                    $sql = "select * from tbl_vendor where deleted_at is NULL order by id desc";

                    $rs = mysqli_query($conn, $sql);
                    while ($row = mysqli_fetch_assoc($rs)) {
                      echo "<tr>";
                      echo '<td>' . $sl . '</td>';

                    //   echo '<td><img src="' . $row['photo_url'] . '" height="50" width="50" class="img-thumbnail" /></td>';



                      if ($row['v_code'] == ($row['role'] == 'Dealer')) {

                        echo '<td><span class="badge bg-info btn-lg me-2">' . $row['v_code'] . '</span></td>';

                      } else {

                        echo '<td><span class="badge bg-success btn-lg me-2">' . $row['v_code'] . '</span></td>';

                      }


                   
                      echo '<td>' . $row['name'] . '</td>';



                        echo '<td><span class="badge bg-info btn-lg me-2">' . $row['role'] . '</span></td>';

                        echo '<td><span class="badge bg-danger btn-lg me-2"> ' . $row['designation'] . '</span></td>';

              
                      echo '<td>' . $row['email'] . '</td>';
                      echo '<td>' . $row['mobile'] . '</td>';

                      if ($row['status'] == 'Active') {
                        echo '<td><button id=' . $row['id'] . ' class="btn btn-success btn-sm deactivate"><i class="bi bi-check-lg"></i>Deactivate</button></td>';

                      } else {
                        echo '<td> <button id=' . $row['id'] . ' class="btn btn-danger btn-sm activate">Activate</button></td>';
                      }
                      
                      echo '<td><a class="btn btn-primary" href="edit-user.php?id='.$row['id'].'">Edit</a></td>';

                       echo '<td><a class="btn btn-danger" href="delete.php?id='.$row['id'].'">Delete</a></td>';
                    
                      echo "</tr>";
                      $sl++;
                    }
                    ?>

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

      </section>

  </main><!-- End #main -->

  <!-- ======= Footer ======= -->
  <?php
  include("templates/footer.php");
  ?>
  <!-- End Footer -->


  <?php include("templates/vendors.php"); ?>

</body>

</html>