 <input type="submit" value='Back' onClick="spinner(),document.location='receiptwiz.php'" class="" style= "width: inherit; height: " name = "A"  >


<?php
session_start();
$error = "";

require 'config.php';


$branch_key = $_SESSION['branch_key'];

$db_handle = mysqli_connect(DB_SERVER, DB_USER, DB_PASS);
$database = $_SESSION['database'];
//$database = "lawped_app";

$db_found = mysqli_select_db($db_handle, $database);


		//$SQL = "DELETE FROM product_table WHERE product_id=$txnid";
   //$query_del = mysqli_query($db_handle, $SQL);



  

if(isset($_POST['A']))
{

	
	
	
	//customers details
	
	$_SESSION['c_phone'] =  $_POST['phone'] ; 
	
	

	
$_SESSION['c_address'] =  $_POST['address'] ; 
	
	

	 $_SESSION['c_email'] =   $_POST['email'] ; 
	
	 $_SESSION['customer'] =   $_POST['name'] ; 
	
	
	
	
	
	//product details
	
	

	
	
	//
	
	echo  $_SESSION['s_qty'] =   $_POST['qty'] ; 
	
	$_SESSION['unit_p'] =   $_POST['u_amount'] ; 
	
	
	
	 $_SESSION['amount'] =   $_POST['a_p'] ; 
	 $_SESSION['balance']  =   $_POST['bal'] ; 
	 $_SESSION['payement_method'] =   $_POST['p_m'] ; 
	$_SESSION['product_name'] =   $_POST['title'] ; 
	$_SESSION['p_description'] =   $_POST['desc'] ; 
	
	
	
	
		
	
	//=============================================================================
	
	
	
	
	
	//transaction details
	
 $_SESSION['payement_method'] = $_POST['p_m'] ; 
	
	$_SESSION['customer'] =$_POST['name'] ; 
	
	
	$_SESSION['product_name'] = $_POST['title'] ; 
	
	// $_SESSION['received_name'] = $db_found['name'];
	
	$_SESSION['s_qty'] = $_POST['qty'] ; 
	
	
	echo 	$_SESSION['unit_c']  =   $_POST['u_amount'] ; 
	
	$_SESSION['amount'] = $_POST['a_p'] ; 
	
	$_SESSION['p_description'] = $_POST['desc'] ; 
	
	
	$_SESSION['total'] =  $_POST['a_p'] ; 
	
	
	
	if($_POST['a_p'] == ''){
		
		
	
		$_POST['a_p'] = 0;
		
	}
	
	
	if ($_SESSION['balance'] =='')
		
	{
		
		
		
		$_SESSION['balance'] = 0;
		
		
			$_SESSION['total'] =   $_POST['a_p']   +  $_SESSION['balance'] ; 
	}
	
	

	
		$_SESSION['balance'] = $_POST['bal'] ; 
	
		$_SESSION['user_id'] = $_SESSION['user_id'];
	
	$_SESSION['date'] =   date("Y-m-d");
	
	$_SESSION['time'] =  date("h-i-s");
	
	
		$_SESSION['p_description'] =   $_POST['desc'] ; 
	
	
	
	
	
	
	
	echo $product_name = $_SESSION['product_name']; 
	
	
	
				
				//product table
				
			
		
	echo 'br';
	
							
echo	$_SESSION['unit_p'] =  $_POST['u_amount'] ; 
	
	
	echo 'br';
	
	
	if($_POST['u_amount']==''){
		
		
		$_POST['u_amount'] = 0;
		
		$_SESSION['s_qty'] = 0;
	}
	
	echo $_SESSION['total_q_p'] =  $_POST['u_amount']  * $_SESSION['s_qty'];
	
	
	
	
	
	
		//customer table
	
	
					echo $customer = $_POST['name'] ; 
	
	
	
		
	echo 'br';
	
							
echo	$_SESSION['c_phone'] =  $_POST['phone'] ; 
	
	
	echo 'br';
	
	echo $_SESSION['c_address'] =  $_POST['address'] ;
	
	
	echo 'br';
	
	echo $_SESSION['c_email'] =  $_POST['email'] ; 
	
	
	
	
	if($_SESSION['balance'] == "")
		
		
	{
		
			
echo	$_SESSION['word'] = 'The sum of '.$_SESSION['total'].'.00 naira only  was received from '.$_SESSION['customer'].' for payment of '.$_SESSION['product_name'].'('.$_SESSION['p_description'].')';
	

		
	}
	
	else{
		
		
echo $_SESSION['word'] = 'Part payment of '.$_SESSION['total'].'.00 naira only  was received from '.$_SESSION['customer'].' for payment of '.$_SESSION['product_name'].'('.$_SESSION['p_description'].')'.' with a bal of'.$_SESSION['balance'];
	
	}

	

	
	//==============================================================================
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	header ("Location:receipt/receipt.php");
		
			
			
		
			 
			
				
		
		
	
		
	
	
	
	
}
	 
	 
	  

	
 


?>



<script> 

	
		//show product
				
function showUser(str) {
	
  if (str == "") {
    document.getElementById("txtHint").innerHTML = "";
	 document.getElementById("cat").innerHTML = "";
	 
	  
	//    document.getElementById("txtHint").innerHTML = window.alert();
    return;
  } 
	
	
	else {
		
		
		//window.alert();
		
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) 
	  {
		  
		
		
		
		  
        document.getElementById("cat").innerHTML = this.responseText;
	 
		//  window.alert();
		// document.getElementById("txtHint").innerHTML = "";
	
		  
		/*  
			 document.getElementById("amount").value = "";
		   document.getElementById("actual").value = "";
		   document.getElementById("qty").value = "";
		   document.getElementById("bal").innerHTML = "Bal";
		
		  
		  */
		
		//scrollTo(0,0);
		  

		  
		  
		    //loader();
		 // customAlert.alert('Select product','LBS');  
//		 window.alert('kindly select product');
      }
		
		
	
	
		
    };
		
 //loader();
		xmlhttp.open("GET","rcpt_wzexternal.php?q="+str,true);
    xmlhttp.send();
  }
}

		


</script>


	<html>
		
			<title>Business Manager</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->	
		 <link href="css/bootstrap-4.4.1.css" rel="stylesheet">
		 <link href="css/popup.css" rel="stylesheet">
		
		
		
	<head>



	</head>
		
	
		<style>
			.loader {
  border: 16px solid #f3f3f3;
  border-radius: 30%;
  border-top: 5px solid blue;
  border-right: 5px solid green;
  border-bottom: 5px solid red;
  border-left: 5px solid yellow;
  width: 40px;
  height: 40px;
  -webkit-animation: spin 2s linear infinite;
  animation: spin 1s linear infinite;
}

		
		
@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

			
			
			
		
		body, html {
background-color: #E1E1DF;
		//	background: image();
			}
		</style>
	
		<body onLoad="<?php echo "customAlert.alert('$error','BM App Builder')"; ?>, show_cat(), spinner()">


			

	
			<div class="jumbotron" style="text-align: center">
		
		
		
		
		<div class="row">
			
			
			
		
					<div class="col-md-4">
			</div>
			
			
			
			<div class="col-md-4">
				
				
					
				
	
				
			
				
		 			<span style="background-color: black; color: white;">  <?php echo $error; ?></span>
			<h3><b><span style="color: #8996C9">Reciept <span style="color: red">WIZARD</span> </b></h3>
				
					<form METHOD ="POST" ACTION = "rcpt_wz.php" >
				
						
						<input type="hidden" value="LBS" name="app_name">
						<input type="hidden" value="admin" name="privilage">
						<input type="hidden" value="active125" name="status">
						<input type="hidden" value="1000" name="db_size">
						
							<input type="hidden" value="Product Key" name="product_key">
						
						
										
										
										
										
										
										<div class="input-group mb-3" style="margin-top: 40px">
  					
		<select class=""  style="background-color:#EEF88D;"   name="" id="product" onchange="showUser(this.value);show_ca() " >
										
											<option value="" selected>Select Customer</option>
		
											<?php
											
											///$SQL = "SELECT  DISTINCT cat_name FROM product_cat where address = '$address' ORDER BY product_id ASC ";
											$SQL = "SELECT  DISTINCT *FROM customers_table where branch_key='$branch_key' ORDER BY id ASC ";
											$result = mysqli_query($db_handle, $SQL);
											
											//$i =1;

											
											while ( $db_found = mysqli_fetch_assoc($result) ) {
											
												/*echo'<option value="'. $db_found['product_name'].'">'. $db_found['product_name'].'(Qty'. $db_found['unit_q'].', Amt '. $db_found['unit_p'].')</option>'; */
												
												echo'<option value="'. $db_found['id'].'">'. $db_found['name'].'</option>'; 
																									  }
		
											?>
											
												<option value="1"> undefine</option> ; 
			
											</select> 
					
											
											
											
											

											
											
											
										</div>
										
										
										
										
										
										
										
			
				<div id="cat"> </div>

								
										
										
										
										
										
									
										
								
										
										
										
										
										
										
	
			
										
			
									
										
							
				<div>
					
					
					
					
					
							<div class="input-group mb-3">
											
									
											
												<input type="submit" value="                   Generate                 "  name = "A" style= "width:100%; height: 40px" class="btn btn-info" onClick="spinner()" id="sub" > 
										
										
												
												
												
												
										
												
				
										</div>
					
					
					
					
					
					
					
							
							<div class="loader" id="load" style="margin: auto"></div>
							
							
					
											
							
					</form>
		
		        
					
					
				
				
				
				
			</div>
			
			
			
				
				
				<div class="col-md-4">
			</div>
			
			
	
		</div>
			
			
			
			
			
			
			</div>
			

			
			
		</body>
	
		</html>
<script>


		function spinner() {
  
			var x = document.getElementById("load");
	
	
	
  if (x.style.display === "none") {
    x.style.display = "block ";
	  
	  
  }
	else {
    x.style.display = "none";
  }
	
	
}
	
		
		
		


</script>



<script>
	
	//pop scripts
	
	
function CustomAlert(){
  this.alert = function(message,title){
    document.body.innerHTML = document.body.innerHTML + '<div id="dialogoverlay"></div><div id="dialogbox" class="slit-in-vertical"><div><div id="dialogboxhead"></div><div id="dialogboxbody"></div><div id="dialogboxfoot"></div></div></div>';

    let dialogoverlay = document.getElementById('dialogoverlay');
    let dialogbox = document.getElementById('dialogbox');
    
    let winH = window.innerHeight;
    dialogoverlay.style.height = winH+"px";
    
    dialogbox.style.top = "100px";

    dialogoverlay.style.display = "block";
    dialogbox.style.display = "block";
    
    document.getElementById('dialogboxhead').style.display = 'block';

    if(typeof title === 'undefined') {
      document.getElementById('dialogboxhead').style.display = 'none';
    } else {
      document.getElementById('dialogboxhead').innerHTML = '<i class="fa fa-exclamation-circle" aria-hidden="true"></i> '+ title;
    }
    document.getElementById('dialogboxbody').innerHTML = message;
    document.getElementById('dialogboxfoot').innerHTML = '<button class="pure-material-button-contained active" onclick="customAlert.ok()">OK</button>';
  }
  
  this.ok = function(){
    document.getElementById('dialogbox').style.display = "none";
    document.getElementById('dialogoverlay').style.display = "none";
  }
}

let customAlert = new CustomAlert();
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
				
function show_cat() {
  var y = document.getElementById("sub");
	
	
	   y.style.display = "none";
	 

	

	
	
}		
	
	
	
				
function show_ca() {
  var y = document.getElementById("sub");
	
	
	   y.style.display = "block";
	 

	

	
	
}		
		
	
	
	
	
	
	</script>