<?php include('common/header.php'); ?>
  <!-- Main Sidebar Container -->
<?php include('common/sidenav.php'); ?>


<?php
 include_once ('includes/config.php');
   
// Check connection
    if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
    } 

if(isset($_POST['submit']))
{
 
$sess= $_SESSION['sess_user'];


   
//insert.php
$name =$_POST['company'];
$address = $_POST['address'];
$vehiclemeasurement =$_POST['vehicle_measurement'];
$vendormeasurement =$_POST['vendor_measurement'];








 // Check connection
    if ($con->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    } 
  else

 

    
    $sql="INSERT INTO vendors(`company_name`,`company_address`,`vehicle_measurement`,`vendor_measurement`)Values('$name','$address','$vehiclemeasurement','$vendormeasurement')";
    
 
 
  


if ($con->multi_query($sql) === TRUE) 
{
     echo "Successfully Changed";

 

?>
  <script>
        alert('Record has Been Added Successfully.');
        window.location.href='vendor.php';
    </script>
<?php
}
else {
    echo "Error: " . $sql . "<br>" . $con->error;
  }

$con->close();
}
 ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
  

    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Payment Recoveries</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item">  <!--<a  href="#"  class="btn btn-danger"><i class="fa fa-plus">Add New</i></a>--></li>
             
            <!--  <li class="breadcrumb-item active"><a href="#">Dashboard</a></li>-->
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

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


            <div class="card">
              <div class="card-header">
   
                <h3 class="card-title">Lists</h3>
              </div>
        
              <!-- /.card-header -->
              <div class="card-body">
               <table id="example1" class="table table-striped">
                  <thead class="bg bg-danger">
                  <tr>
                    <th>S No</th>
                    <th>Company</th>
                    <th>Date</th>
                    <th>Paid Amount</th>
                    <th>Ch#</th>
                    <th>Action</th>
                  </tr>
                  </thead>
                  <tbody>

  <?php
    include('includes/config.php');
               
      $no=0;
      $result = mysqli_query($con, "SELECT * FROM `payment_generate` as p 
 ORDER BY pay_id ASC");
       while($row = mysqli_fetch_assoc($result)) {
       $no++; 
       $cheque_no = $row['cheque_no'];
          
  ?>
                  <tr>
                      <?php $id = $row['pay_id']; ?>
                    <td><?php echo $no; ?></td>
                    <td><?php echo $company = $row['vendor_id']; ?></td>
                   
                      <td><?php $prdate = $row['p_date']; echo date("d/m/Y", strtotime($prdate));?>
                      </td>
                     <td><?php echo $row['generate_amount']; ?></td>
                    
                   <td><?php  $paytype = $row['payment_type']; if($paytype =='Cheque'){ echo str_repeat('&nbsp;', 1).'Cheque No:'. str_repeat('&nbsp;', 1); ?>
                   
                   <?php echo $cheque_no; } else if($paytype == 'Transefer-Via-Account') { echo $paytype.'<br>'.$row['bank_name'];  } else { echo $paytype; } ?></td>
                   
                    <td>
                      <!--  <a href="paymentedit.php?id=<?php echo $row['pay_id']; ?>">
                  <i class="fas fa-edit"></i>
                          ||-->
                           <a onclick="window.open(this.href); return false;" href="billview.php?id=<?php echo $row['pay_id']; ?>">
                           <i class="fas fa-print"></i>
                          ||
                          
                        <a  onclick="return confirm('Are you sure <?php echo $company . $prdate; ?> ?')" href="paymentdelete.php?id=<?php echo $id; ?>"  ><i style="font-size:15px; color:red;"  class="fa fa-trash"></i></a>
                        
                    </td>
                    
                  </tr>

                    


    <?php
    }

  
  ?>
 
                  </tbody>
                </table>
                     
                
                
                
                
                
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->



<script>
  //show a confirmation and redirect to the delete profile script
  function deleteProfile() {
    if (confirm("Do you really want to delete your profile?")) {
        //location.href = '/deleteuser.php';
    }
}
</script>


  </div>
  <!-- /.content-wrapper -->


<?php include('common/footer.php'); ?>