 <?php
include 'header.php';
 ?>
  <!-- Content Wrapper. Contains page content -->

    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
    <div class="row">
          <div class="col-lg-3 col-6">
            <!-- small box -->
<?php
$query ="SELECT sum(price) as pending_amount from order_link where status = 'Pending'";
$result = mysqli_query($con,$query);
$row = mysqli_fetch_assoc($result);
?>
            <div class="small-box bg-info">
              <div class="inner">
                <h3>$<?php echo $row['pending_amount']?></h3>

                <p>Total Pending Amount</p>
              </div>
              <div class="icon">
                <i class="ion ion-bag"></i>
              </div>
              
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box --><?php
$query ="SELECT count(*) as pending_leads from order_link where status = 'Pending'";
$result = mysqli_query($con,$query);
$row = mysqli_fetch_assoc($result);
?>
            <div class="small-box bg-success">
              <div class="inner">
                <h3><?php echo $row['pending_leads']?></h3>

                <p>Total Pending Leads</p>
              </div>
              <div class="icon">
                <i class="ion ion-stats-bars"></i>
              </div>
              
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box --><?php
$query ="SELECT sum(price) as paid_amount from order_link where status = 'Paid'";
$result = mysqli_query($con,$query);
$row = mysqli_fetch_assoc($result);
?>
            <div class="small-box bg-warning">
              <div class="inner">
                <h3>$<?php echo $row['paid_amount']?></h3>

                <p>Total Paid Amount</p>
              </div>
              <div class="icon">
                <i class="ion ion-person-add"></i>
              </div>
             
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
                <!-- small box --><?php
$query ="SELECT count(*) as paid_leads from order_link where status = 'Paid'";
$result = mysqli_query($con,$query);
$row = mysqli_fetch_assoc($result);
?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['paid_leads']?></h3>

                <p>Total Paid Leads</p>
              </div>
              <div class="icon">
                <i class="ion ion-pie-graph"></i>
              </div>
              
            </div>
          </div>
          <!-- ./col -->
        </div>
        <!-- /.row -->
        <!-- Main row -->
        <div class="row">
          
         <div class="col-md-12">
            <!-- general form elements -->
            <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Domains Property</h3>
              </div>
           
              <!-- form start -->
                <div class="card-body">
                  <?php
                    $query = "SELECT * FROM order_link order by id desc ";
                    $result = mysqli_query($con,$query);
                ?>
                <div class="table-responsive">
              <table id="example2" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Email</th>
                  <th>Price</th>
                  <th>Website</th>
                  <th>Status</th>
                  <th>Created At</th>
                  <th>Action</th>
                </tr>
                </thead>
                <tbody>
                  <?php
                      while($row = mysqli_fetch_assoc($result)){
              
                  ?>              
                <tr role="row" class="odd">
                 
                  <td><?php echo $row['email']?></td>
                  <td><?php echo $row['price']?></td>
                  <td><?php echo $row['website'];?></td>
                  <td>
                    <?php echo $row['status'];?>
                    <select class="form-control status" data-value="<?php echo $row['id']?>">
                      <option>Select Payment Status</option>
                      <option>Paid</option>
                      <option>Decline</option>
                      <option>Pending</option>
                    </select>
                  </td>
                  <td><?php echo $row['created_at'];?></td>
                  
                  <td>
                      <a class="btn btn-info btn-sm profile"  href="add_marchant.php?id=<?php echo $row['id'];?>">update</a>
                      <a class="btn btn-danger btn-sm" id="userId" href="response.php?order_leadDl=<?php echo $row['id'];?>">Delete</a>
                  </td>
                </tr>
                <?php } ?>
                 </tbody>              
              </table>
              </div>
                </div>
                <!-- /.card-body -->

            </div>
            <!-- /.card -->
</div>
          </div>
        </div>
      
        <!-- /.row (main row) -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
 <?php
include 'footer.php';
 ?>
<script type="text/javascript">

  $(document).ready(function(){
   
     $(".status").change(function(){
      var status = $(this).val();
      var id = $(this).data("value");
      $.get("response.php",{order_linkStatus:status,linkorder_id:id},function(data){

              alert("status Upated..");
      });
     })
  });
</script>
 