<?php 
error_reporting(0);
$usertype = $_GET['user'];
$saletype = $_GET['saletype'];

if($usertype == 'admin')
{
	include_once('session.php');
	$user_id=$_SESSION['id'];
	$user_name=$_SESSION['fname'];
	date_default_timezone_set('Africa/Nairobi');

}
elseif($usertype == 'user')
{
	include_once('usersession.php');
	$user_name=$_SESSION['fname'];
	date_default_timezone_set('Africa/Nairobi');
}
else
{
	echo 'Cant determine the user type pleas contact the deveoper';
}

?>

<!DOCTYPE html>
<html>
<?php include_once('includes/head.php');
?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <link rel="stylesheet" type="text/css" media="screen" href="css/layout.css">
<style type="text/css">


#print{  	background:blue; padding:10px;width:100px; height:50px;) ;

}
.hidden{
display:none;
}
   
    </style>
    
  <header class="main-header">
    <!-- Logo -->
    <a href="dashboard.php" class="logo">
      
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b>POS</b></span>
    </a>
      
      <?php include_once('include/links.php');
 include('header1.php'); 
 include('PS_Pagination.php');
	 
include('include/connect.php');


?>
      <link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript" src="tcal.js"></script>
<script type="text/javascript" src="jquery.js"></script>	

<script type="text/javascript" language="Javascript">
function submitForm(){
    document.frmOne.submit();
    document.frmOne.method='post';
}
var util = { };

document.addEventListener('keydown', function(e){

    var key = util.key[e.which];
    if( key ){
        e.preventDefault();
    }

    if( key === 'F3' ){        
      $("#country").focus();
    }
	 if( key === 'F4' ){        
      $("#cash").focus();
    }
	 if( key === 'F5' ){        
     $("#submit").submit();
	 //document.getElementById('submit').submit();
	      //window.location.href = "../user/preview.php";
		    submitForm();
    }
	 if( key === 'enter' ){        
return true;
    }

})


  
util.key = { 
  9: "tab",
  //13: "enter",
  16: "shift",
  18: "alt",
  27: "esc",
  33: "rePag",
  34: "avPag",
  35: "end",
  36: "home",
  37: "left",
  38: "up",
  39: "right",
  40: "down",
  112: "F1",
  113: "F2",
  114: "F3",
  115: "F4",
  116: "F5",
  117: "F6",
  118: "F7",
  119: "F8",
  120: "F9",
  121: "F10",
  122: "F11",
  123: "F12"
}
	var sum=0;
	price = document.frmOne.total.value;
	document.frmOne.change.value = price;
    function OnChange(value)
    {
		
		payable = document.frmOne.total.value;
		cash = document.frmOne.cash.value;
        sum = cash - payable;
		
		document.frmOne.change.value = sum;
    }
    
    var sum=0;
	price = document.frmOne.change.value;
	document.frmOne.changeM.value = price;
    function OnCalc(value){
		
		payable = document.frmOne.change.value;
		mpesaAmnt = document.frmOne.mpesaAmnt.value;
        sum = mpesaAmnt + payable;
		
		document.frmOne.change.value = sum;
    }
</script>
<script>
window.onload = function() {
  document.getElementById("country").focus();
  document.getElementById("mpesapay").style.display="none";
  document.getElementById("creditdue").style.display="none";
};
</script>
      
<script>
//*********************************************PRODUCT SUGGESTION***********************************************
function suggest(inputString){
		if(inputString.length == 0) {
			$('#suggestions');
		} else {
		$('#country').addClass('load');
			$.post("autosuggest.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions').fadeIn();
					$('#suggestionsList').html(data);
					$('#country').removeClass('load');
				}
			});
		}
	}
//*********************************************PRODUCT SUGGESTION***********************************************

//*********************************************CUSTOMER SUGGESTION***********************************************
function suggestcust(inputString){
		if(inputString.length == 0) {
			$('#suggestions2');
		} else {
		$('#customname').addClass('load');
			$.post("autosuggestcust.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions2').fadeIn();
					$('#suggestionsList2').html(data);
					$('#customname').removeClass('load');
				}
			});
		}
	}
//*********************************************CUSTOMER SUGGESTION***********************************************
	
	function fill(thisValue) {
		$('#country').val(thisValue);
		setTimeout("$('#suggestions').fadeOut();", 600);
	}
	
	function fill2(thisValue) {
		$('#customname').val(thisValue);
		setTimeout("$('#suggestions2').fadeOut();", 600);
	}

</script>
      
<script>
//******************************************************NEW MPESA FUNCTIONS**************************************
	function paympesa()
	{
		document.getElementById("mpesapay").style.display="block";
		var currentChange = document.getElementById("lform").value;
		document.getElementById("lform2").value = currentChange;

		
	}
	
	function calcMmoney()
	{
		var balance = parseInt(document.getElementById("lform2").value,10);
		var mpesaamt = parseInt(document.getElementById("mmoneyz").value,10);
		
		var change = balance + mpesaamt;
		
		document.getElementById("lform").value = change;
		
	}
//******************************************************NEW MPESA FUNCTIONS**************************************

//******************************************************CUSTOMER DETAILS MANAGEMENT**************************************
	
	
	function customerValidate()
	{
		var existcust = document.getElementById("customname").value;
		var newcust = document.getElementById("newcust").value;
		var address = document.getElementById("address").value;
		var lform = document.getElementById("lform").value;
		var duedate = document.getElementById("duedate").value;

		
		if(existcust != "" && newcust != "")
		{
			alert ('Pleas only enter a new customer or an existing customer only, you cant enter both');
			return false;
		}
		/*else if (existcust == "" && newcust == "")
		{
			alert ('Pleas enter the details of an existing or new customer to proceed');
			return false;
		}*/
		else if (newcust != "" && address == "")
		{
			alert ('Pleas enter the National ID or Phone Number of The New Customer');
			return false;
		}
		else if (lform < 0 && duedate == "")
		{
			alert ('Pleas enter the Credit Due Date to proceed');
			return false;
		}
		else
		{
			return true;
		}
		
	}
	
	
	
	/*function disableField()
	{
		
		var existcust = document.getElementById("customname").value;
		var newcust = document.getElementById("newcust").value;
		
		
		if(existcust != "")
		{
			document.getElementById("newcust").disabled = true;
			document.getElementById("address").disabled = true;
		}
		else if (newcust != "")
		{
			document.getElementById("customname").disabled = true;
		}
		else
		{
			document.getElementById("newcust").disabled = false;
			document.getElementById("customname").disabled = false;
			document.getElementById("address").disabled = false;

		}
	}
	
	function verivydisfields()
	{
		var existcust = document.getElementById("customname").value;
		var newcust = document.getElementById("newcust").value;
		if(existcust == "" && newcust == "")
		{
			document.getElementById("newcust").disabled = false;
			document.getElementById("customname").disabled = false;
			document.getElementById("address").disabled = false;
		}


	}*/
	
	/*function refreshData()
	{
	    x = 5;  // 5 Seconds
	
	   alert('Hello World');
	    setTimeout(refreshData, x * 1000);
	}
	
	
	 refreshData()// execute function*/
	
//******************************************************CUSTOMER DETAILS MANAGEMENT**************************************

//******************************************************CREDIT DUE DATE CALENDAR**************************************
	function displaydate()
	{
		var changez = Number(document.getElementById("lform").value);
		
		if(changez < 0)
		{
			document.getElementById("creditdue").style.display="block";
		}
		else
		{
			document.getElementById("creditdue").style.display="none";
		}
		/*creditdue
		cash
		lform*/	
	}
//******************************************************CREDIT DUE DATE CALENDAR**************************************
    function dynInput(rb) 
    {
    if (document.getElementById('raadio').checked == true) {
        var input = document.createElement("input");
        input.type = "text";
        input.onkeyup='OnCalc(this.value)';
        //input.value = "mpesaAmnt";
        input.placeholder = "MPESA AMOUNT";
        input.name = "mpesaAmnt";
        //input.required = "true";
        var div = document.createElement("div");
        div.id = rb.name.id;
        //div.innerHTML = "REGNR " + rb.name.id;
        div.appendChild(input);
        document.getElementById("insertinputs").appendChild(div);
        
        var input = document.createElement("input");
        input.type = "text";
        //input.value = "transactionID";
        input.placeholder = "TRANSACTION ID";
        input.name = "transac";
        //input.required = "true";
        var div = document.createElement("div");
        div.id = rb.name.id;
        //div.innerHTML = "REGNR " + rb.name.id;
        div.appendChild(input);
        document.getElementById("insertinputs").appendChild(div);
    }
    if (document.getElementById('raadio').checked == false) {
        document.getElementById(rb.name.id).remove();
    }
    
}
          
      </script>
      <style>
#result {
	height:20px;
	font-size:16px;
	font-family:Arial, Helvetica, sans-serif;
	color:#333;
	padding:5px;
	margin-bottom:10px;
	background-color:#FFFF99;
}

.suggestionsBox2 {
	position: absolute;
	left: 10px;
	margin: 0;
	width: 268px;
	top: 10px;
	padding:0px;
	background-color: #000;
	color: #fff;
}
.suggestionList2 {
	margin: 0px;
	padding: 0px;
}
.suggestionList2 ul li {
	list-style:none;
	margin: 0px;
	padding: 6px;
	border-bottom:1px dotted #666;
	cursor: pointer;
}
.suggestionList2 ul li:hover {
	background-color: #FC3;
	color:#000;
}
.suggestionsBox
 {
	position: absolute;
	left: 10px;
	margin: 0;
	width: 268px;
	top: 10px;
	padding:0px;
	background-color: #000;
	color: #fff;
}
.suggestionList {
	margin: 0px;
	padding: 0px;
}
.suggestionList ul li {
	list-style:none;
	margin: 0px;
	padding: 6px;
	border-bottom:1px dotted #666;
	cursor: pointer;
}
.suggestionList ul li:hover {
	background-color: #FC3;
	color:#000;
}
ul {
	font-family:Arial, Helvetica, sans-serif;
	color:#FFF;
	padding:0;
	margin:0;
}

.load{
background-image:url(loader.gif);
background-position:right;
background-repeat:no-repeat;
}

#suggest {
	position:relative;
}
.combopopup{
	padding:3px;
	width:268px;
	border:1px #CCC solid;
}

</style>
      
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
        <span class="sr-only">Collapse</span>
      </a>

      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">
          <li class="dropdown user user-menu">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
              <img src="dist/img/user.png" class="user-image" alt="User Image">
              <span class="hidden-xs">Welcome <?php echo "$session_user";?></span>
            </a>
            <ul class="dropdown-menu">
              
              <!-- Menu Footer-->
              <li class="user-footer">
                <div class="pull-left">
                  <a href="#" class="btn btn-default btn-flat">Profile</a>
                </div>
                <div class="pull-right">
                  <a href="logout.php" class="btn btn-default btn-flat">Sign out</a>
                </div>
              </li>
            </ul>
          </li>
          <!-- Control Sidebar Toggle Button -->
          <li>
            <a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
          </li>
        </ul>
      </div>
    </nav>
  </header>
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
      <!-- Sidebar user panel -->
      <div class="user-panel">
        <div class="pull-left image">
          <img src="dist/img/slider_pos.png" class="img-circle" alt="POS Image">
        </div>
        
      </div>
      <!-- sidebar menu: : style can be found in sidebar.less -->
      <?php 
			if($usertype == 'admin')
			{
				include_once('includes/menu.php');				 
			}
			elseif($usertype == 'user')
			{
				include_once('includes/usermenu.php');
			}
			else
			{
				echo 'Cant determine the user type pleas contact the deveoper';
			}
      	
      ?>
    </section>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
      
      <!-- Content Header (Page header) -->
    <section class="content-header">
        
      
    </section>
    
      
      
      <!-- Main content -->
    <section class="content">  
        <table width="100%">
<tr>
<td id="column">
<div class="leftpanel">


<div class="content">
<div style="margin-left:30%">
<?php

if($saletype == 'retail')
{
	?>
		<b style ="font-size:23px; font-weight:bolder">Retail Sale</b>
	<?php
}
elseif($saletype == 'whole')
{
	?>
		<b style ="font-size:23px; font-weight:bolder">Wholesale</b>
	<?php
}
else
{
	echo ('Error cant establish sale type');
}

?>
</div>

<table style="min-width:96%; max-width:100%;">
<tr>
<td id="column" >
<div class="rightpanel" style="min-width:96%; max-width:100%;">
<?php 
include('include/connect.php');


?>
<center>
<?php
 function clean($str) {
		$str = @trim($str);
		if(get_magic_quotes_gpc()) {
			$str = stripslashes($str);
		}
		return ($str);
	}
if(isset($_POST['save'])){
include('../connect.php');
include('include/connect.php');
$date = date("Y-m-d");


$a = clean($_POST['invoice']);

$b = clean($_POST['product']);
$c = clean($_POST['qty']);
$w = clean($_POST['pt']);
$type = clean($_POST['pt']);
$discount = clean($_POST['discount']);
$result = $db->prepare("SELECT * FROM products WHERE product_code= :userid");
$result->bindParam(':userid', $b);
$result->execute();

 $data=mysql_query("select * FROM products WHERE product_code = '$b'")or die(mysql_error());
$count=mysql_num_rows($data);

if(($count) >0) {

while($row=mysql_fetch_array($data)){
		$qty = $row['qty'];							
if ($qty<$c) {
          

?>
 <div id="alertdanger"><img src="images/warning.png" alt="warning" />The remaining quantity  is = <?php  echo $qty; ?> ...You can not sell items  more than the remaining quantity...Please add new stock.</div>	
		
<?php
}else{

for($i=0; $row = $result->fetch(); $i++){
$asasa=$row['price'];
$name=$row['product_name'];
$product_code=$row['product_code'];
$description=$row['description'];
$bprice=$row['cost'];

$salestype="retail";
}
$balance=$qty -$c;
$sql = "UPDATE products 
        SET qty=qty-?
		WHERE product_code=?";
$q = $db->prepare($sql);
$q->execute(array($c,$b));
$fffffff=$asasa-$discount;
$d=$fffffff*$c;

// query
$sql = "INSERT INTO sales_order (invoice,product,qty,amount,name,price,discount,date,user,description,bprice, type,address,balance,id_number,bonus) VALUES (:a,:b,:c,:d,:e,:f,:g,:date,:user_name,:description,:bprice,:type,:salestype,:balance,:id_number,:bonus)";
$q = $db->prepare($sql);
$q->execute(array(':a'=>$a,':b'=>$b,':c'=>$c,':d'=>$d,':e'=>$name,':f'=>$asasa,':g'=>$discount,':date'=>$date,':user_name'=>$user_name,':description'=>$description,':bprice'=>$bprice,':type'=>$type,':salestype'=>$salestype,':balance'=>$balance,':id_number'=>id_number,':bonus'=>bonus));
//header("location: viewsale.php?id=$w&invoice=$a");

}
}
}else{
?>
 <div id="alertdanger"><img src="images/warning.png" alt="warning" />That code or item name is not available in the system...Try again..or add it..</div>	
		
<?php
//header("location: viewsale.php?id=$w&invoice=$a");
//echo"No Available Stock"; 

}

}
?>

<form action="" method="post" >
<table width="100%"><b>
<tr style="color:white;">
<td >Select Item To Add</td><td> Quantity</td><td>Discount</td></tr>
</tr>
</b>
<tr>
<td>
<input type="hidden" name="pt" value="<?php echo $_GET['id']; ?>" />
<input type="hidden" name="invoice" value="<?php echo $_GET['invoice']; ?>" />

<input type="text" name="product" value=""style="width: 420px;" id="country" onKeyUp="suggest(this.value);" onBlur="fill();" class="" autocomplete="off" placeholder="Enter Item or Barcode Here" tabindex="1" />
	

</td><td>
<input type="text" name="qty" value="1" placeholder="Qty" autocomplete="off" style="width: 68px; padding-top: 6px; padding-bottom: 6px; margin-right: 4px;" />
</td><td>
<input type="text" name="discount" value="0" autocomplete="off" style="width: 68px; padding-top: 6px; padding-bottom: 6px; margin-right: 4px;" />
</td><td><input type="submit" name="save" value="Add item" id="addqnew"style="margin-left:1px; margin:0px;" /></td>
</tr>
<tr><td colspan="2">
<div class="suggestionsBox" id="suggestions" style="display: none;margin-top:50px">
		<div class="suggestionList" id="suggestionsList"> &nbsp; </div>
</div>

</td>
<td colspan="2">


</td>

</tr>


</table>
</form>

<table id="example"  width="100%" border="1">
	<thead>
		<tr>
			<th> Product Code </th>
			<th> Product Name </th>
			<th> Qty </th>
			<th> R Qty </th>
			<th> Price </th>
			<th> Disct </th>
			<th> Amt </th>
			<th>  </th>
		</tr>
	</thead>
	<tbody bgcolor="white">
		
			<?php
				$id=$_GET['invoice'];
				include('../connect.php');
				$result = $db->prepare("SELECT * FROM sales_order WHERE invoice= :userid order  by transaction_id desc");
				$result->bindParam(':userid', $id);
				$result->execute();
				for($i=0; $row = $result->fetch(); $i++){
				
			?>
			<tr class="record">
			<td><?php echo $row['product']; ?></td>
			<td><?php echo $row['name']; ?></td>
			<td><?php echo $row['qty']; ?></td>
			<td><?php echo $row['balance']; ?></td>
			<td>
			<?php
			$ppp=$row['price'];
			echo formatMoney($ppp, true);
			?>
			</td>
			<td>
			<?php
			$ddd=$row['discount'];
			echo formatMoney($ddd, true);
			?>
			</td>
			<td>
			<?php
			$dfdf=$row['amount'];
			echo formatMoney($dfdf, true);
			?>
			</td>
			<td><a href="delete.php?id=<?php echo $row['transaction_id']; ?>&invoice=<?php echo $_GET['invoice']; ?>&dle=<?php echo $_GET['id']; ?>&qty=<?php echo $row['qty'];?>&code=<?php echo $row['product'];?>&user=<?php echo $usertype;?>&saletype=<?php echo $saletype;?>">  <img src="images/error.png" alt="delete" width="20" height="20" /> </a></td>
			</tr>
			<?php
				}
			?>
			<tr>
				<td colspan="5"><strong style="font-size: 12px; color: #222222;">Total:</strong></td>
				<td colspan="3"><strong style="font-size: 12px; color: #222222;">
				<?php
				function formatMoney($number, $fractional=false) {
					if ($fractional) {
						$number = sprintf('%.2f', $number);
					}
					while (true) {
						$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
						if ($replaced != $number) {
							$number = $replaced;
						} else {
							break;
						}
					}
					return $number;
				}
				$sdsd=$_GET['invoice'];
				$resultas = $db->prepare("SELECT sum(amount) FROM sales_order WHERE invoice= :a");
				$resultas->bindParam(':a', $sdsd);
				$resultas->execute();
				for($i=0; $rowas = $resultas->fetch(); $i++){
				$fgfg=$rowas['sum(amount)'];
				echo formatMoney($fgfg, true);
				}
				?>
				</strong></td>
			</tr>
		
	</tbody>
</table><br>
<div class="clearfix"></div>
</div>
</center>
</td>

<td id="column">
<div class="rightpanel"  style="width:15em">
					
					<form NAME = "frmOne" id="frmOne"action="preview.php?viewname=viewsale.php&currentuser=<?php echo $usertype; ?>&saletype=<?php echo $saletype; ?>" method="post" onSubmit="return customerValidate()">
										<input type="hidden" name="invoice" id="invoice" value="<?php echo $_GET['invoice']?>" />
										<input type="hidden" name="pt" id="pt" value="<?php echo $_GET['id']?>" />
										<input type="hidden" name="cashier" id="cashier" value="<?php echo $user_name;?>" />

					
					<div id="total">
					<?php
					if( isset($_SESSION['CASH']) && is_array($_SESSION['CASH']) && count($_SESSION['CASH']) >0 ) {
						foreach($_SESSION['CASH'] as $msg) {
							echo '<span style="color:red;">',$msg,'</span>'; 
						}
						unset($_SESSION['CASH']);
					}
					?>
						<div id="customer">
							Customer Details
						</div>
												<?php
$asas=$_GET['id'];
if($asas=='credit') {
?>

                        
   		<input type="text" name="customer" id="customname" style="width: 150px;" value="" onkeyup="suggestcust(this.value);" onblur="fill2();" class="" autocomplete="off" placeholder="Enter customer name"placeholder="Customer Name"  required="required"/><br>
			<div class="suggestionsBox2" id="suggestions2" style="display: none;margin-top:50px">
			<div class="suggestionList2" id="suggestionsList2"> &nbsp; </div>
			</div>

		
		<input type="text" name="due" placeholder="Due Date"  class="tcal" style="width: 150px; margin-bottom: 15px;" /><br>
		
		                <div id="customer">
							Bonga Points
						</div>                        
                        <input type="text" name="bonus" id="lform4" style="width: 150px;" placeholder="Loyalty Points" value="<?php
						$sds=$fgfg;
                        $bon=$sds*.001;
						echo formatMoney($bon, true);
						?>"  required="required"/><br>

<?php
}
if($asas=='cash') {
?>
 
		<label><b><u>Existing Customer</u></b></label>
   		<input type="text" name="excustomer" id="customname" style="width: 150px;"  onkeyup="suggestcust(this.value); disableField();" onblur="fill2();" class="" autocomplete="off" placeholder="Enter customer name"placeholder="Customer Name" /><br>
			<div class="suggestionsBox2" id="suggestions2" style="display: none;margin-top:80px">
			<div class="suggestionList2" id="suggestionsList2"> &nbsp; </div>
			</div>




                  
<!--<?php
mysql_connect("localhost", "root","") or die(mysql_error());
mysql_select_db("sales") or die(mysql_error());

$query = "SELECT * FROM customer ORDER BY customer_id DESC";
$result = mysql_query($query) or die(mysql_error()."[".$query."]");
?>

<select name="customer" style="width: 170px;">
    <option value="">Select ID Number</option>
<?php 
while ($row = mysql_fetch_array($result))
{
    echo "<option value=".$row['customer_name'].">".$row['customer_name']."</option>";
}
?>        
</select>-->
                             
            <label><b><u>New Customer</u></b></label>           
			<input type="text" name="newcustomer" id="newcust" style="width: 150px;"  placeholder="Enter customer ID No." onKeyUp="disableField()" />
                        <br>
			<label><b><u>ID/MOBILE No</u></b></label> 
			<input type="text" name="idno" id="address" style="width: 150px;" placeholder="ID/Mobile" /><br>
			
			<div id="creditdue">
			<label><b><u>Credit Due Date</u></b></label>
			<input type="text" name="due" id="duedate" placeholder="Due Date"  class="tcal" style="width: 150px; margin-bottom: 15px;"/>
			</div>
                        
                        <div id="customer">
							Bonga Points
						</div>                        
                        <input type="text" name="bonus" id="lform4" style="width: 150px;" placeholder="Loyalty Points" value="<?php $sds=$fgfg; $bon=                                $sds*.001; echo formatMoney($bon, true);?>"  required="required"/><br>
<?php
}
?>						
					</div>
					
					<div id="total">
						<div id="customer">
							Sales Details
						</div>
						<div style="padding-top: 5px; padding-bottom: 5px;"><span style="float: left; font-size: 14px; font-weight: bold;">16 % VAT :</span><span style="float: right; font-size: 14px; font-weight: bold;">ksh:
						<?php
						$as=$fgfg;
						$vat=$as*.16;
						echo formatMoney($vat, true);
						?>
						</span><div class="clearfix"></div></div>
						<div style="padding-top: 5px; padding-bottom: 5px;"><span style="float: left; font-size: 14px; font-weight: bold;">Vatable :</span><span style="float: right; font-size: 14px; font-weight: bold;">ksh:
						<?php
						$as=$fgfg;
						$vt=$as-$vat;
						echo formatMoney($vt, true);
						?>
						</span><div class="clearfix"></div></div>
						<div style="padding-top: 5px; padding-bottom: 5px;"><span style="float: left; font-size: 14px; font-weight: bold;">Total :</span><span style="float: right; font-size: 14px; font-weight: bold;">ksh:
						<?php
						$sds=$fgfg;
						echo formatMoney($sds, true);
						?>
						</span><div class="clearfix"></div></div>
					</div>
					
					<div id="total">
						<div id="customer">
							Payment Details
						</div>
						<input type="hidden" name="total" id="lform6" style="width: 150px;" placeholder="Cash" value="<?php echo $fgfg ?>" />
						<input type="text" name="cash" value="<?php //echo $sds ?>" id="cash" style="width: 150px;" placeholder="Cash" onkeyup='OnChange(this.value); displaydate()' onKeyPress="return isNumberKey(event)" autocomplete="off"  required="required"/><br>
						<input type="text" name="change" id="lform" style="width: 150px;" placeholder="Change" readonly/ onchange="displaydate()"><br>
						<input type="hidden" name="change2" id="lform2" style="width: 150px;" placeholder="Change" /><br>

									<!--- <li><a  id="print" rel="facebox" href="preview2.php?invoice=<?php  echo $_GET['invoice']; ?>&cashier=<?php echo $user_name ?>&pt=<?php echo $_GET['id'];?>&total=<?php echo $fgfg ?>&customer=<?php   echo $_POST['customer']; ?>&cash=<?php   echo $_POST['cash']; ?>&change=<?php   echo $_POST['change']; ?>" accesskey="p"> Print</a></li>
-->
                        
    <label for="Radios">
        <input type="radio" name="rb" id="raadio" onChange="paympesa();" />Lipa na MPESA
        <div class="hidden" id="mpesapay" name ="mpesapay">
	        
	        <input type="text" id ="mmoneyz" name="mpesaAmnt" placeholder="MPESA AMOUNT" style="width: 150px;" onkeyup='calcMmoney()'>
	        <input type="text" name="transac" placeholder="TRANSACTION ID" style="width: 150px;">
        </div>

        <br/>
    
<p id="insertinputs"></p>
 <input id="submit" type="submit"name="Print" accesskey="n"value="Confirm Receipt" id="btn" /><br><br>
						<br><br>
					</div>
					</form>
				</div>

</td>
</tr>

</table>

        </section>
    <!-- /.content -->
  </div>
    
  <!-- /.content-wrapper -->
  <?php include_once('includes/footer.php');?>
  
  
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- jQuery 2.2.0 -->
<script src="plugins/jQuery/jQuery-2.2.0.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.6 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- Morris.js charts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="plugins/morris/morris.min.js"></script>
<!-- Sparkline -->
<script src="plugins/sparkline/jquery.sparkline.min.js"></script>
<!-- jvectormap -->
<script src="plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- jQuery Knob Chart -->
<script src="plugins/knob/jquery.knob.js"></script>
<!-- daterangepicker -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
<script src="plugins/daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
</body>
</html>
