<?php
require("header.php");
include("connection.php");

// ... Your existing HTML and PHP code ...

// Display SweetAlert2 success message
if (isset($_GET['success'])) {
  echo "<script>
    Swal.fire({
        title: 'Success',
        text: '{$_GET['success']}',
        icon: 'success',
        confirmButtonText: 'OK'
    });
    </script>";
}

// Display SweetAlert2 error message
if (isset($_GET['error'])) {
  echo "<script>
    Swal.fire({
        title: 'Error',
        text: '{$_GET['error']}',
        icon: 'error',
        confirmButtonText: 'OK'
    });
    </script>";
}
?>

<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 Quantity</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 Quantity</h3>
              <ol class="breadcrumb float-sm-right" style="background-color: black;">
                <li class="breadcrumb-item"><a href="#">Home</a></li>
                <li class="breadcrumb-item ">Inventory</li>
                <li class="breadcrumb-item active">Add Quantity</li>
              </ol>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
              <form action="add_quantity_code.php" method="post">
                <div class="row">
                  <br>
                  <!--<?php if (isset($_GET['error'])) { ?>-->
                  <!--  <div class="alert alert-denger  col-12">-->
                  <!--          <p class="error"><?php echo $_GET['error']; ?></p>-->
                  <!--    </div>-->



                  <!--  <?php } ?>-->
                  <!--  <?php if (isset($_GET['success'])) { ?>-->
                  <!--    <div class="alert alert-success  col-12">-->
                  <!--        <p class="success"><?php echo $_GET['success']; ?></p>-->
                  <!--        </div>-->


                  <!--  <?php } ?>-->

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

                    <div class="form-group">
                      <label for="exampleInputEmail1">Quantity<span style="color:red; font-size:25px;">*<span></label>
                      <input type="text" name="quantity" class="form-control" id="exampleInputEmail1" placeholder="Enter Quantity" 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>Quantity</th>

                    <th>Status</th>

                  </tr>
                </thead>
                <tbody>
                  <?php
                  include('connection.php');
                  $i = 0;

                  $sql = "SELECT * FROM quantity 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['quantity'];  ?></td>
                      <td>

                        <form method="POST" action="add_quantity_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" style="font-weight: 600;font-size: 12px;height: 30px;" class="btn btn-danger">
                          <?php } else { ?>
                            <input type="submit" name="activate" value="Activate" style="font-weight: 600;font-size: 12px;height: 30px;" class="btn btn-success">
                          <?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>
          </div>
          <!-- /.card-body -->

        </div>

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

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

    <!-- /.container-fluid -->
  </section>
  <!-- /.content -->
</div>
<!-- for searching -->

<!-- searching end -->

<!-- pagination -->

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