<?php    include_once('../config/db.php');  include_once('../config/homecheck.php'); include_once('../functions/sale/sale.php');

 //  $mycurrentpage ='sellreceipt';
 $receiptno =           $_GET['receipt'];

    $rdata = $conn->query("SELECT memo,invnumber,date,enddate from acctransactions  where id='$receiptno'  ")->fetch(); 


    $items = $conn->prepare(" SELECT a.* ,b.name pname,c.code ccode FROM acctransactionsdetails a 
                              JOIN item b ON a.item = b.id 
                              LEFT JOIN adtaxrate c ON a.itemtaxrate=c.id
                                                     where transid='$receiptno' ");
     $items->execute();
  
     $t3 = $conn->query(" SELECT  itemtotal total FROM acctransactionsdetails a WHERE a.transmove=3 and transid='$receiptno'  ")->fetch();
     $t4 = $conn->query(" SELECT  total FROM acctransactionsdetails a WHERE a.transmove=4 and transid='$receiptno'  ")->fetch();
     $t5 = $conn->query(" SELECT  total FROM acctransactionsdetails a WHERE a.transmove=5 and transid='$receiptno'  ")->fetch();
                          

 if (filter_has_var(INPUT_POST, "submit")) 
  try{  
      
        
 
        header("location:sellreceipt.php?receipt="."$lastid"); 
   } catch(Exception $e) { echo 'Message: ' .$e->getMessage();}
       
       
?>

<!DOCTYPE html>
<html>
<head>
<?php include_once('../inc/slink.php');   ?>  
</head>
<body   class="hold-transition skin-black sidebar-collapse sidebar-mini"  >
<div class="wrapper">

  <!-- Main Header -->
    <header class="main-header">

    <!-- Logo -->
       <?php include_once('../inc/sbrand.php');   ?>

    <!-- Header Navbar -->
    <?php include_once('../inc/snavbar.php');   ?>

  </header>
 
  <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">

    <!-- sidebar: style can be found in sidebar.less -->
     <?php  // include_once('../inc/menu.php');   ?>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
   

          <!-- Main content -->
           <div class="row">
           <div class="col-xs-2"></div>
    <div class="col-xs-8">
    <section class="invoice">
      <!-- title row -->
      <div class="row">
        <div class="col-xs-12">
          <h2 class="page-header">
            <i class="fa fa-print"></i> Receipt
            <!-- <small class="pull-right">Date: 2/10/2014</small> -->
          </h2>
        </div>
        <!-- /.col -->
      </div>
      <!-- info row -->
      <div class="row invoice-info ">
        <div class="col-sm-6 invoice-col with-border ">
       
            <address>
            <strong>Nunguni Chemist LTD.</strong><br>
            P.O BOX 325-90400 MWINGI<br>
            BRANCH: KITUI|MWINGI<br>
            Phone: (254) 0700-100100<br>
            PIN NO #P100000<br>
            </address>
        </div>
            
        <!-- /.col -->
        <div class="col-sm-4 invoice-col">
        Receipt No #<?php  echo $rdata["invnumber"]; ?></br>
            Order ID:</b> <?php  echo $rdata["invnumber"]; ?><br>
            Date:</b> <?php  echo $rdata["date"]; ?><br>
            Memo:</b> <?php  echo $rdata["memo"]; ?><br>
        </div>
        <!-- /.col -->
         <div class="col-sm-2"></div>
      </div>
      <hr>
      <!-- /.row -->

      <!-- Table row -->
      <div class="row">
        <div class="col-xs-10 table-responsive">
          <table class="table table-striped">
            <thead>

            
            <tr>
              
              <th>Product</th>
              <th>Qty</th>
              <th>Price #</th>
              <th>Tax</th>
              <th>Total</th>
            </tr>
            </thead>
            <tbody>
                <?php foreach($items as $item) 
                       { ?>
                          <tr>
                            
                            <td> <?php echo $item['pname'];  ?> </td>
                            <td> <?php echo $item['itemunit'];  ?> </td>
                            <td> <?php echo $item['itemprice'];  ?>  </td>
                            <td> <?php echo $item['ccode'];  ?>  </td>
                            <td> <?php echo $item['itemtotal'];  ?>  </td>
                          </tr>
                <?php } ?>
            
            
            </tbody>
          </table>
        </div>
         <div class="col-xs-2"></div>
        <!-- /.col -->
      </div>
      <!-- /.row -->

      <div class="row">
        <div class="col-xs-12">
          <!-- <p class="lead">TOTALS </p> -->

          <div class="table-responsive">
            <table class="table ">
              <tr>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>Subtotal:</td>
                <td> <?php  echo $t3["total"]; ?> </td>
              </tr>
              <tr>
                <td></td>
                <td></td>
                <td></td>
                <td>Tax </td>
                <td> <?php  echo $t4["total"]; ?> </td>
              </tr>
              <tr>
                 <td></td>
                <td></td>
                <td></td>
                <td>Total:</td>
                <td > <?php  echo $t5["total"]; ?> </td>
              </tr>
            </table>

            <p class="text-muted well well-sm no-shadow" style="margin-top: 10px;">
              Thank You for your business.
            </p>

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

      <!-- this row will not appear when printing -->
      <div class="row no-print">
        <div class="col-xs-12">
          <a href="#" target="_blank" class="btn btn-default"><i class="fa fa-print"></i> Print</a>
    
          <a href="sales"  class="btn btn-default"><i class="fa fa-print"></i> Make another Sale </a>
          <a href="sell"  class="btn btn-default"><i class="fa fa-print"></i> Make another Sale </a>
      
        </div>
      </div>
    </section>
    </div>
    <div class="col-xs-2"></div>
    </div>
    <!-- /.content -->

  <!-- Main content -->
  
</div>
  <!-- /.content-wrapper -->
  
  <!-- Main Footer -->
  <footer class="main-footer">
    <?php  include_once('../inc/sfooter.php'); ?>
  </footer>
  
</div>
                         
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->
<?php include_once('../inc/slinkjs.php') ?>

</body>
</html>
