<?php


include('conn.php');
$page='Inventory Receipt Details';
include('common/head.php');




if (isset($_GET['re'])) {

    $id=$_GET['re'];
    $location=$_GET['l'];


    $sql7 = "SELECT * FROM `inventory` WHERE receipt_id='$id'";
    $result7 = mysqli_query($conn,$sql7)or die( mysqli_error($conn));
    $row7=mysqli_fetch_array($result7) ;
    $receipt_id=$row7['receipt_id'];
    $item_name=$row7['item_name'];
          $item_price=$row7['price'];
          $unit=$row7['unit'];
          $value=$row7['unit_value'];
          $quantity=$row7['quantity'];
          $date=$row7['datein'];
          $by=$row7['by'];
          $text='';
   

  
 $sql="select * from receipt where receipt_id='$id'";
 $result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
$row=mysqli_fetch_array($result);
$supply=$row['company'];
$total=$row['total'];
$contact=$row['company_contact'];
$by=$row['by'];



 }
 
 
 

 
$sql1="SELECT * FROM currency ";
$result1 = mysqli_query($conn,$sql1)or die( mysqli_error($conn));
$row1=mysqli_fetch_array($result1) ;
$currency=$row1['curency'];


?>

   <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@500&display=swap" rel="stylesheet">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.1/css/all.min.css" integrity="sha256-2XFplPlrFClt0bIdPgpz8H7ojnk10H69xRqd9+uTShA=" crossorigin="anonymous" />
<style>
    body{margin-top:20px;
background-color:#eee;
color:black !important;
height: 100%;
font-family: 'Roboto', sans-serif ! important;
}

.card {
    box-shadow: 0 20px 27px 0 rgb(0 0 0 / 5%);
}
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-clip: border-box;
    border: 0 solid rgba(0,0,0,.125);
    border-radius: 1rem;}



        
        table, th, td {

  border-collapse: collapse;
  font-size:14px;
  color:black !important;
    }

 
</style>
<div class="container">
<div class="row">
        <form action="submit.php" method="post">

        <div class="col-lg-12">
            <div class="card ">
                <div class="card-body">
                <div style="font-size: 12px;" class="invoice-title text-center">
                        <div class="mb-1">
                           <h4  class="mb-1 "><?php echo $supply?></h4>
                        </div>
                        <div class="">
                            <p><i class="uil uil-phone me-1"></i><?php echo $contact?></p>
                        </div>
                    </div>
                    <hr class="my-2">

                    <div class="row">

                        <!-- end col -->
                        <div class="col-sm-12">
                            <div class=" text-sm-end">
                                <div class="mt-2">
                                    <h5 style="font-size: 15px;" class=" mb-1">Invoice Date: <?php echo $date?></h5>
                                   
       
                                </div>
                                <div class="mt-4">
                                    <h5 style="font-size: 12px;" class=" mb-1">Receipt Id:</h5>
                                    <p>#<?php echo $receipt_id?></p>
                                </div>
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    
                    <div class="py-2">
                        <h5 style="font-size: 12px;" class="">Items Summary</h5>
                        <div class="table-responsive">
                            <table   class="table align-middle table-nowrap table-centered mb-0">
                                <thead>
                                    <tr >
                                        <th >Item </th>
                                        <th>Qty</th>
                                        <th>Price</th>
                                        <th>Total</th>
                                    </tr>
                                </thead><!-- end thead -->
                                <tbody>
                                <?php


$sql8 = "SELECT * FROM `inventory` where receipt_id='$receipt_id' ";
$result8 = mysqli_query($conn,$sql8)or die( mysqli_error($conn));
while($row8=mysqli_fetch_array($result8)){ ;
$receipt_id=$row8['receipt_id'];
$item_name=$row8['item_name'];
      $price=$row8['price'];
      $unit=$row8['unit'];
      $value=$row8['unit_value'];
      $quantity=$row8['quantity'];
      $date=$row8['datein'];
      $by=$row8['by'];
      $text='';
$item_total=$price*$value;



?>    
                                    <tr >
                                        <td ><?php echo $item_name ?></td>
                                        <td><?php echo $value." ". $unit ?></td>
                                        <td><?php echo $currency ?><?php echo number_format($price,2)?></td>
                                        <td><?php echo $currency ?><?php echo number_format($item_total,2)?></td>
                                    </tr>

                                    
                                    <?php }?>
                               
                                    <!-- end tr -->
                                 
                                    <!-- end tr -->
                                   
                                        <th scope="row" colspan="3" class="border-0 ">Total</th>
                                        <td class="border-0 "><b class="m-0 fw-semibold"><?php echo $currency ?><?php echo number_format($total,2)?></b>
                                    </td>
                                    </tr>
                                    <!-- end tr -->
                                </tbody><!-- end tbody -->
                            </table><!-- end table -->
                        </div><!-- end table responsive -->
                        <div class="d-print-none mt-4">
                        <div class="pament-button text-center">
              
          
                            <div class="float-end">
                                
                            <a href="javascript:window.print()" class="btn btn-success me-1"><i class="fa fa-print"></i></a>
                                <a href="<?php echo $location ?>" class="btn btn-primary btn-sm">Back Home</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            </form>
        </div><!-- end col -->
     
    </div>
</div>
<script>
function myFunction() {
  var x = document.getElementById("mySelect").value;
  document.getElementById("demo").innerHTML = "Bill to: " + x;
}
</script> 
    