<?php
session_start();
ob_start();
  if(!isset($_SESSION['LOGIN_STATUS']))
  {
      header('location:../index.php');
  }
require "../model/configuration.php";
include("../model/words_class.php");
$invoice=$_GET['invo'];
$vendorid=$_GET['vendid'];
$invdate=$_GET['invodate'];
/* @var $sion type */

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php echo $_SESSION['title'];?></title>
<link rel='stylesheet' type='text/css' href='../css/fonts.googleapis.com/css_cd14c140.css' />
<!-- Bootstrap CSS -->
<link rel="stylesheet" type="text/css" href="../vendor/bootstrap/css/bootstrap.min.css" />
<!-- Theme CSS -->
<link rel="stylesheet" type="text/css" href="../css/vendor.css" />
<link rel="stylesheet" type="text/css" href="../css/theme.css" />
<link rel="stylesheet" type="text/css" href="../css/utility.css" />
<link rel="stylesheet" type="text/css" href="../css/custom.css" />
<link rel="stylesheet" type="text/css" href="../css/Quotation/quotstyle.css" />
<style>
.mar{ margin: 10px; margin-left: 20px;}
</style>
</head>

<body class="dashboard-page">
<script> var boxtest = localStorage.getItem('boxed'); if (boxtest === 'true') {document.body.className+=' boxed-layout';} </script> 
<!-- Start: Theme Preview Pane -->


<!-- Start: Header -->
<header class="navbar navbar-fixed-top">
  
   <?php include_once("../include/top_menu.php");?> 
</header>

<!-- Start: Main -->
<div id="main"> 
  
  <!-- Start: Sidebar -->
  <?php include_once("../include/left_menu.php");?>

  <!-- Start: Content -->
  <section id="content_wrapper">
    <div id="topbar">
      <div class="topbar-left">
        <ol class="breadcrumb">
          <li class="crumb-icon"><a href="#"><span class="glyphicon glyphicon-home"></span></a></li>
          <li class="crumb-link"><a href="#">Reports</a></li>
          <li class="crumb-trail">Reports</li>
        </ol>
      </div>
      
    </div>
    
    
    <div id="content">
      <div class="row">
        <div class="col-md-12">
          <div class="panel">
          
       
        
           <div class="panel-heading"> <span class="panel-title"> <span class="glyphicon glyphicon-pencil"></span> Purchase View</span> </div>
            <div class="panel-body pbn">

                    <div class="row">
          <div class="col-xs-6">
            <address>
            <strong>Vendor:</strong><br>
            <?php 
              $vquery=$db->execute("select * from vendor where client_id='".$vendorid."'");
              while($vrow=$vquery->fetch_assoc()){
               echo $vrow['vendor_name']."<br>";
               echo $vrow['vendoraddress']."<br>";
               echo $vrow['email']."<br>";
               echo $vrow['phone'];

              }
            ?>

             
            </address>
          </div>
          <div class="col-xs-6 text-right">
            <address>
              <strong>Invoice Date:</strong><br>
              <?php echo $invdate;?><br><br>
            </address>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-6">
            
          </div>
          <div class="col-xs-6 text-right">
            <address>
              <strong>Invoice Number:</strong><br>
              <?php echo $invoice;?><br><br>
            </address>
          </div>
        </div>
      




              <table class="table table-striped table-bordered table-hover" id="datatable">
                <thead>
            <tr>
              <th width="5%">Sl</th>                            
              <th width="15%">Item Code</th>
              <th width="20%">Item Name</th>
                            <th width="10%">Unitprice</th>
              <th width="10%">Quantity</th>
                            <th width="10%">Discount</th>
                            <th width="10%">Tax</th>
                            <th width="10%">Total</th>
                            <th width="10%">action</th>
            </tr>
          </thead>
                <tbody>
                  <?php
				  $c=0;
            
                  $sqry=$db->execute("select * from master_purchase where invoice_no = '".$invoice."' and delet='0'");
                  $gtotal=0;
				  while($row=$sqry->fetch_assoc())
				  {
					  $c++;

             $pprce=($row['price']/(100+$row['tax']))*100;
           $taxamount_unt=round($row['price']*$row['tax']/(100+$row['tax']),2);
            $uprice=round($pprce,2);
           // $total_unit=$uprice*
            //echo // $taxamount_unt + $uprice;
            $ntprce=$uprice*$row['quantity'];
            $netamount=$ntprce-$row['discount'];//($ntprce*$disc);//$disc/100
              $taxamount=$netamount*$row['tax']/100;
             $total_amt=round($netamount+($netamount*$row['tax']/100),0);
            $gtotal=$gtotal+$total_amt;


				  ?>
                  <tr>
                    <td><?php echo $c;?></td>
                    <td class="hidden-xs"><?php echo $row['product_code'];?></td>
                    <td class="hidden-xs">
                     <?php echo $row['product_name'];?>
                    </td>
                    <td class="hidden-xs ">
                    <?php 

                   echo $uprice;
                  ?>
                      
                    </td>
                     <td class="hidden-xs ">
                    <?php 
                        
                    echo $row['quantity'];
                  ?>
                      
                    </td>
                     <td class="hidden-xs ">
                    <?php 
                       
                    echo $row['discount'];
                  ?>
                      
                    </td>
                     <td class="hidden-xs ">
                    <?php 
                       echo $row['tax'];
                  ?>
                      
                    </td>
                     <td class="hidden-xs ">
                     
                         <?php  
                      echo $total_amt;
                      ?>
                  
                      
                    </td>
                     <td class="hidden-xs text-center">
                     &nbsp;&nbsp;<a href="../controler/delete_purchase_item.php?invo=<?php echo $row['invoice_no'];?>&&id=<?php echo $row['id'];?>&&vendid=<?php echo $row['vendr_id'];?>&&invodate=<?php echo $row['invoice_date'];?>&&paper=<?php echo $row['paper']; ?>" title="Delete"><i class="fa fa-trash-o"></i></a>
                    </td>
                  </tr>
                  <?php
				  }
				  ?>
                </tbody>
                 <tr><th colspan="7" style="text-align: right;"> Total </th><th id="test" colspan="2"><?php echo  $gtotal; ?> </th></tr> 
              </table>
            </div>
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          </div>
          </div>
          
         
          </div>
          
   </div> 
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    </div>
    
  </section>
  
  <!-- Start: Right Sidebar -->
  
</div>
<!-- End #Main --> 


<!-- jQuery --> 
<script type="text/javascript" src="../vendor/jquery/jquery-1.11.1.min.js"></script> 
<script type="text/javascript" src="../vendor/jquery/jquery_ui/jquery-ui.min.js"></script> <!-- Bootstrap --> 
<script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script> 

<!-- Page Plugins --> 
<script type="text/javascript" src="../vendor/plugins/validate/jquery.validate.js"></script>  
<script type="text/javascript" src="../vendor/plugins/morris/morris.js"></script> 
<script type="text/javascript" src="../vendor/plugins/datatables/js/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="../vendor/plugins/datatables/js/datatables.js"></script> 
<script type="text/javascript" src="../vendor/plugins/multiselect/bootstrap-multiselect.js"></script> 
<script type="text/javascript" src="../vendor/plugins/jvectormap/jquery-jvectormap.min.js"></script> 
<script type="text/javascript" src="../vendor/plugins/jvectormap/assets/jquery-jvectormap-us-lcc-en.js"></script> 
<script type="text/javascript" src="../vendor/plugins/clndr/clndr.js"></script> 
<script type="text/javascript" src="../vendor/plugins/clndr/moment.js"></script> 
<script type="text/javascript" src="../vendor/plugins/datepicker/bootstrap-datepicker.js"></script> 
<script type="text/javascript" src="../vendor/plugins/jquerymask/jquery.maskedinput.min.js"></script> 
<!-- Flot Plugins --> 
<script type="text/javascript" src="../vendor/plugins/jqueryflot/jquery.flot.min.js"></script> 

<!-- Theme Javascript --> 
<script type="text/javascript" src="../js/utility/spin.min.js"></script> 
<script type="text/javascript" src="../js/utility/underscore-min.js"></script> 
<script type="text/javascript" src="../js/main.js"></script> 
<script type="text/javascript" src="../js/ajax.js"></script> 
<script type="text/javascript" src="../js/custom.js"></script> 
<script type="text/javascript">
$(document).ready(function() {
    
    "use strict";

     // Init Theme Core 	  
     Core.init();

     // Enable Ajax Loading 	  
     Ajax.init();    
     
    $('.datepicker').datepicker()
    
    });
</script>
</body>
</html>