 <?PHP
session_start();
$status = $_SESSION['status'];
$privilage = $_SESSION['privilage']; 


$background_color =$_SESSION['background_color'];
$text_color =$_SESSION['text_color'];

		$bottom_backgroundcolor = $_SESSION['bottom_backgroundcolor'] ;
		$bottom_textcolor = $_SESSION['bottom_textcolor'] ;


if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
	header ("Location: ../login.php");
}


if($status === "inactive"){
//echo "it works";
	
	header ("Location: payment_activate.php");
	
 }

 

?>


<?php


$app_name = $_SESSION['app_name'];
  $db_size = $_SESSION['db_size'];




$current_date = date("Y-m-d");
$activation_d = $_SESSION['activation_date'];
$expiration_d = $_SESSION['expiration_date'];
/*
$activation_d ="2013-03-15";
$expiration_d ="2013-03-30" ;

*/
//echo "<br>";




?>



<?php


$date1 = date_create("$current_date");

$date2 = date_create($expiration_d);

$date_diff = date_diff($date1,$date2);

  $date_diff->format("%a ")
	
	 ?>

<?php
	
	
if($date_diff->format("%R%a ") <0){
		
	header ("Location: dash_exp.php");
	}	
	  


if ($privilage == "suspend")
	
{
	echo $notification = "Suspended App";
	
	header ("Location: /login.php?txnfailed=$notification");
	//header ("Location: ../login.php?");
}



	
$notification = "";



if($date_diff->format("%a ") <=30){
		$notification = $date_diff->format("%a")."  "."days Remaining";
	}	
	
?>







	<script>
	

	
		
		
				
function showUser(str) {
	
  if (str == "") {
    document.getElementById("txtHint").innerHTML = "";
	   document.getElementById("cat").innerHTML = "";
	 
	  
	//    document.getElementById("txtHint").innerHTML = window.alert();
    return;
  } 
	
	
	else {
		
		
		
		
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) 
	  {
        document.getElementById("cat").innerHTML = this.responseText;
	
		 document.getElementById("txtHint").innerHTML = "";
	
			 document.getElementById("amount").value = "";
		   document.getElementById("actual").value = "";
		   document.getElementById("qty").value = "";
		   document.getElementById("bal").innerHTML = "Bal";
		  
      }
		
		
	
	
		
    };
		
    xmlhttp.open("GET","getuserlist.php?q="+str,true);
    xmlhttp.send();
  }
}

		
		
		
function showUse(str) {
  if (str == "") {
    document.getElementById("txtHint").innerHTML = "";
	 
	  
	//    document.getElementById("txtHint").innerHTML = window.alert();
    return;
  } 
	
	
	

	
	
	else {
		
		 
		
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange =  function() {
      if (this.readyState == 4 && this.status == 200) {
        document.getElementById("txtHint").innerHTML = this.responseText;
		//  var myobj =JSON.parse(this.responseText);
		  
		  var strArray = xmlhttp.responseText.split(":::");
 // window.alert();
		
	
			 document.getElementById("amount").value = "";
		   document.getElementById("actual").value = "";
		   document.getElementById("qty").value = "";
		   document.getElementById("bal").innerHTML = "Bal";
		  
		 
		   
      }
		
	
		
    };
		
		
		
	
			
			
			
		 xmlhttp.open("GET","get_details.php?q="+str,true);
    xmlhttp.send();	
		
	
   
	
		
	
  }
	
	  
	
}

		
	

	
	
	

function multiply(str) {
	var avail_q =  parseInt(document.getElementById("unit_q").value) ;
		var sales_q = parseInt (document.getElementById("qty").value);
 
 
	if(str == "")
		
		{
			document.getElementById("amount").value = "";
			document.getElementById("actual").value = "";
			 document.getElementById("bal").innerHTML = "Bal";
			return;
		}
	else if(sales_q> avail_q){
		//showdiv();
		view_ac();
			
			document.getElementById("amount").value = "";
		document.getElementById("txtHint").innerHTML = "";
		//document.getElementById("cont").innerHTML = "";
		var color = document.getElementById("credit_color");
		color.style.color="blue";
		color.style.backgroundColor="";
		
		var x = document.getElementById("cont");
		  x.style.display = "none";
		customAlert.alert('Error||Avail Qty Exceeded','LBS');
		
		
		
		
		
		
			}
		
else {   
		var qty =  parseInt(document.getElementById("qty").value) ;
		var total_amount = parseInt (document.getElementById("unit_p").value);
	
	document.getElementById("actual").value = "";
			 document.getElementById("bal").innerHTML = "Bal";
		
		
	var sum = qty*total_amount;
	document.getElementById("amount").value = sum;
		}   
		  
 
   
}
		
		
		
	
	//function for debt subtraction
		
function diff(str) {
	
	var total_sales =  parseInt(document.getElementById("amount").value) ;
		var actual_sales = parseInt (document.getElementById("actual").value);
 
	if(str == "")
		
		
		{
			
			
			//document.getElementById("balance").value === "";
			document.getElementById("bal").innerHTML = "Bal";
			return;
		}
	
	else if(actual_sales > total_sales){
		
		// CustomAlert.alert('');
		
		//window.alert('exceeded total sales')
		
		view_ac();
		showdiv();
		customAlert.alert('Error||Total Sales Exceeded','LBS');
		document.getElementById("bal").innerHTML = "Bal";
		document.getElementById("txtHint").innerHTML = "";
		
		return;
	}
	
		
else {   
	
	
	//window.alert();
		
		
		
	var bal = total_sales - actual_sales;
	document.getElementById("balance").value = bal;

	document.getElementById("bal").innerHTML = bal;
	
	//window.alert(bal);
	
}   
		  
 
   
}
	

		
</script>
	

<?php


$app_name = $_SESSION['app_name'];
  $db_size = $_SESSION['db_size'];




$current_date = date("Y-m-d");
$activation_d = $_SESSION['activation_date'];
$expiration_d = $_SESSION['expiration_date'];
/*
$activation_d ="2013-03-15";
$expiration_d ="2013-03-30" ;

*/
//echo "<br>";




?>





<?php
	
	
	
	
	
	
	
require 'config.php';

$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 = "SELECT  date FROM txn_table ORDER BY product_id ASC  ";
											
$result = mysqli_query($db_handle, $SQL);
   $txn_nbr = mysqli_num_rows($result);
$progress = (mysqli_num_rows($result)/$db_size*100);





?>

<?php




if(isset($_POST['A']))
{
	
 
	$paymethod = $_POST['payment']; 
	
	//exit();
	
    $product = $_POST['product'];
	$amount = $_POST['amount'] ;
	$s_qty = $_POST['s_qty'] ;
	
	$customers = $_POST['customer'];
	
	
	//script for credit sales
	 $balance = $_POST['balance'];
	$equalize = $amount;
	//exit();
	$actual = $_POST['actual'];
	  $debt = @ $_POST['debt']; 
	
	if ($debt ==""){
		 $debt ='cash';
		
	}
	
	
	
	if($progress <= $db_size)
	{
	
		
		//=====================================================
		//script for full payment without debt
		//======================================================
			if($debt =='cash') 
			{
				//echo $debt;
				
				//exit();
		{
	
if($product=="" or $amount=="" or $s_qty=="" or $pm = ""){
	 $notification = 'OPERATION FAILED|| amount or quantity or product field is blank';
}
	
		else if($s_qty ==0){
			
			
				 $notification = 'OPERATION FAILED|| Qauntity Field cant be zero(0)';
		}
	
else{	
	
		//to select unit cost of goods sold from product database
	
	$SQ = "SELECT product_name, unit_c, unit_q FROM product_table where product_name = '$product' ";
												$resul = mysqli_query($db_handle, $SQ);
											$db_foun = mysqli_fetch_assoc($resul);
											 $unit_qty_cost = $db_foun['unit_c'].'<br>';
	
	
	$qty = $db_foun['unit_q'];
	
	$totalcost = intval($unit_qty_cost) *$s_qty.'<br>';
	
  	 "grossprofit". $gross_profit = intval($amount) -intval($totalcost);
	 "avilableqnty". $avail_qnty = 	intval($qty) - $s_qty;		
	
	 $cost_of_goods_in_db = $amount - $gross_profit;
	
	
	
	
	
	
	
	
	if($avail_qnty < 0 ){
		
		 $notification = 'OPERATION FAILED|| '.$product." is out of stock || available Quantity ".($qty);
		}
	

	
	else{
		
	$notification = "";
	$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );
	
	$SQl_update = "UPDATE product_table SET unit_q = $avail_qnty WHERE product_name = '$product' ";
	
	mysqli_query($db_found,$SQl_update);
				
	 $date = date("Y-m-d");
	 $month = date("M");
	 $year = date("Y");
	 $time = date("h-i-s");
	
	//$time = date("h-m-d");
	
		//$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );

	
		$SQL = $db_found->prepare("INSERT INTO txn_table (product_name,payment,customers_name, amount,unit_c,s_qty,cog,user_id,month,year,time,date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
			$SQL->bind_param('ssssssssssss',$product,$paymethod,$customers,$amount,$gross_profit,$s_qty,$cost_of_goods_in_db, $_SESSION['user_id'],$month,$year,$time,$date );
			$SQL->execute();
			//header ("Location: dashboard.php");
		

	
	
	
		 $notification = "operation successfull";
	
		
		
	}
	
	
	
	
	
	
	}
	
		}
			
			}
		//=====================================================
		//script for full payment without debt
		//======================================================
		
			//=====================================================
		//script for credit sales
		//======================================================
			else if($debt =='debtor') 
			{
		{
	//echo $debt;
			//exit();
			 $amount = $actual;
			
			if($amount ==""){
				
				$amount = 0;
				$balance = $equalize;
			}
		//	exit();
			
if($product=="" or $amount=="" or $s_qty=="" or $pm = ""){
	 $notification = 'OPERATION FAILED|| amount or quantity or product field is blank';
}
	
		else if($s_qty ==0){
			
			
				 $notification = 'OPERATION FAILED|| Qauntity Field cant be zero(0)';
		}
	
else{	
	
		//to select unit cost of goods sold from product database
	
	$SQ = "SELECT product_name, unit_c, unit_q FROM product_table where product_name = '$product' ";
												$resul = mysqli_query($db_handle, $SQ);
											$db_foun = mysqli_fetch_assoc($resul);
											 $unit_qty_cost = $db_foun['unit_c'].'<br>';
	
	
	$qty = $db_foun['unit_q'];
	
	$totalcost = intval($unit_qty_cost) *$s_qty.'<br>';
	
  	 "grossprofit". $gross_profit = intval($amount) -intval($totalcost);
	 "avilableqnty". $avail_qnty = 	intval($qty) - $s_qty;		
 $cost_of_goods_in_db = $amount - $gross_profit;
	
	
	
	
	
	
	if($avail_qnty < 0 ){
		
		 $notification = 'OPERATION FAILED|| '.$product." is out of stock || available Quantity ".($qty);
		}
	

	
	else{
		
	$notification = "";
	$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );
	
	$SQl_update = "UPDATE product_table SET unit_q = $avail_qnty WHERE product_name = '$product' ";
	
	mysqli_query($db_found,$SQl_update);
				
	 $date = date("Y-m-d");
	 $month = date("M");
	 $year = date("Y");
	 $time = date("h-i-s");
		
		
	
	//$time = date("h-m-d");
	
		//$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );

	
		$SQL = $db_found->prepare("INSERT INTO txn_table (product_name,payment,customers_name,amount,balance,unit_c,s_qty,cog,user_id,month,year,time,date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
			$SQL->bind_param('sssssssssssss',$product,$paymethod,$customers,$amount,$balance,$gross_profit,$s_qty,$cost_of_goods_in_db, $_SESSION['user_id'],$month,$year,$time,$date );
			$SQL->execute();
			//header ("Location: dashboard.php");
		

	
	
	
		 $notification = "operation successfull";
	
		
		
	}
	
	
	
	
	
	
	}
	
		}
			
			}
		//=====================================================
		//script for credit sales
		//======================================================
		
		else{
			
			
		}
		
	}
	
	
	
	else 
	{
		
		$notification = "OPERATION FAILD||database is filled";
	
	}
	
}



elseif(isset($_POST['B']))
{
	
 
	$paymethod = $_POST['payment']; 
	
	$expense = $_POST['expense']; 
	
	//exit();
	
    $product = $_POST['product'];
	$amount = $_POST['amount'] ;
	$s_qty = $_POST['s_qty'] ;
	
	$customers = $_POST['customer'];
	 
	
	
	if($progress <= $db_size) 
	{
	
	
	
	
if($product=="" or $amount==""  or $pm = ""){
	 $notification = 'OPERATION FAILED|| amount or quantity or product field is blank';
}
	
		
else{	
	
		//to select unit cost of goods sold from product database
	
		
	$notification = "";
	$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );
	
	/*$SQl_update = "UPDATE product_table SET unit_q = $avail_qnty WHERE product_name = '$product' ";
	
	mysqli_query($db_found,$SQl_update);
	*/			
	 $date = date("Y-m-d");
	 $month = date("M");
	 $year = date("Y");
	 $time = date("h-i-s");
	
	//$time = date("h-m-d");
	
		//$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );

	
		$SQLL = $db_found->prepare("INSERT INTO txn_table (product_name,type,payment,customers_name,amount,s_qty,user_id,month,year,time,date) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
			$SQLL->bind_param('sssssssssss',$product,$expense,$paymethod,$customers,$amount,$s_qty, $_SESSION['user_id'],$month,$year,$time,$date );
			$SQLL->execute();

			//header ("Location: dashboard.php");
		

	
	
	
		 $notification = "operation successfull";
	
		
		
	
	
	
	
	
	
	
	}
	

	
		}
	
	
	
	
	else {
		
		$notification = "OPERATION FAILD||database is filled";
	
	     }
	
}








else{
	
}



?>


<!DOCTYPE html>
<html lang="en">
<head>
	<title>Lawped</title>
	<meta charset="UTF-8">
	
	<meta http-equiv ="refresh" content="1500s">
	
	<meta name="viewport" content="width=device-width, initial-scale=1">
	 <link rel="apple-touch-icon" sizes="76x76" href="./assets/img/apple-icon.png">
  <link rel="icon" type="image/png" href="assets/img/favicon.png">
	
	
	  <!--manifest file for pwa ap-->
	 <link href="manifest.json"  rel = "manifest">
	   <!--manifest file for pwa ap-->
	  
	  <!--ios support-->
	   <link href="img/icons/icon-96.png"  rel = "apple-touch-icon">
	  <meta name="apple-mobile-web-app-status-bar" content="#00695c">
	  <meta name="theme-color" content="#00695c">
	  <!--ios suppoer-->
	
	  <script src="app.js"></script>
	
	
<!--===============================================================================================-->	
		
	
 <script src="https://kit.fontawesome.com/42d5adcbca.js" crossorigin="anonymous"></script>
  <!-- Material Icons -->
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Round" rel="stylesheet">
  <!-- CSS Files -->
  <link id="pagestyle" href="assets/css/material-dashboard.css" rel="stylesheet" />
	
	 <link href="css/bootstrap-4.4.1.css" rel="stylesheet">
	
	 <link href="css/popup.css" rel="stylesheet">
	
	
	<!-- import the webpage's javascript file -->
    <script src="script.js" defer></script>
	
	
	 <link rel="stylesheet" href="style.css" />
	
	
	
	
<!--===============================================================================================-->
	
</head>
	
	 <script src="js/main.js"></script>

	<!-- styel for toggle button-->
	<style>
		
		

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}
	
	
	
	
	</style>
	
	
	
	
	
	
	
	<style>
		
		.loader {
  border: 16px solid #f3f3f3;
  border-radius: 50%;
  border-top: 16px solid blue;
  border-right: 16px solid green;
  border-ottom: 16px solid red;
  border-left: 16px solid pink;
  width: 120px;
  height: 120px;
  -webkit-animation: spin 1s 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: <?php echo $bottom_backgroundcolor;  ?>;
		
}

		
	
            div.scroll {
                //margin:4px, 4px;
                padding:4px;
               // background-color: #494747;
                width: 100%;
                height: 210px;
               // overflow-x: hidden;
               // overflow-y: auto;
				overflow: auto;
                text-align:justify;
            }
		
		div.scroll_history {
                //margin:4px, 4px;
               // padding:4px;
                background-color: #494747;
                width: 100%;
                height: 300px;
                //overflow-x: hidden;
                //overflow-y: auto;
				overflow: auto;
                text-align:justify;
            }
		
		
		div.scroll_body {
                margin:4px, 4px;
               // padding:4px;
                //background-color: green;
                width: 100%;
                height: 400px;
                overflow-x: hidden;
                overflow-y: auto;
				//overflow: auto;
                text-align:justify;
            }
		
		

	</style>

	
	
	
<body onLoad= "<?php echo "customAlert.alert('$notification','$_SESSION[biz_name]<BR>$_SESSION[app_code]')"; ?>,unit_ac(),bulk_ac(),crude_ac(),view_ac(), showdiv(),spinner()">

	


	<!--newheader-->
	
	
	
	
	<!--new headeer-->
	
	
		<div class="jumbotron-fluid" style="background-color: #757672; color: #F0ECEC">
	
				
<?php 
		
	echo $_SESSION['name'].'   '.' (IDN '. $_SESSION['user_id'].' ) '.$date_diff->format("%a ")."days Left";
			
			

		?>
			<div class="" style="float: right; color: #ED0307;"><a HREF = "logout.php" onClick="spinner()"><span style="color: #F9F833">Log out</span></a></div>
			<!--<button onclick="myFunction()">Click Me</button>-->
			

			
		</div>
	
	<?php 
	
	//this script is to change the app picture of the app
	
	//echo $_SESSION['biz_nature'];
	
	if( $_SESSION['biz_nature'] =="phamarcy")
	{
		
		$img = "pharmacy.png"  ;
	}
	
	else if( $_SESSION['biz_nature'] =="printing press")
	{
		$img = "print.png" ;
	}
	
	else if( $_SESSION['biz_nature'] =="bookshop")
	{
		$img = "book3.png" ;
	}
	
	else if( $_SESSION['biz_nature'] =="drinks")
	{
		$img = "drink.png" ;
	}
	
	else if( $_SESSION['biz_nature'] =="retailshop")
	{
		$img = "retailshop.png" ;
	}
	
	else if( $_SESSION['biz_nature'] =="gas")
	{
		$img = "gas2.jpg" ;
	}
	else if( $_SESSION['biz_nature'] =="electronics")
	{
		$img = "electronics.jpg" ;
	}
	
	else if( $_SESSION['biz_nature'] =="cement")
	{
		$img = "cement.jpg" ;
		//$img = "drinkss.jpg" ;
	}
	
	else if( $_SESSION['biz_nature'] =="drinks")
	{
		//$img = "cement.jpg" ;
		$img = "drinkss.jpg" ;
	}
	
	else if( $_SESSION['biz_nature'] =="coldroom")
	{
		//$img = "cement.jpg" ;
		$img = "coldroom.jpg" ;
	}
	
	
	else if( $_SESSION['biz_nature'] =="supermark")
	{
		//$img = "cement.jpg" ;
		$img = "retailshop.png" ;
		
	}
	
	
	
	//	$img = "pharmacy3.jpg" ;
	
	
	
	?>
			
<div class="jumbotron " id="credit_colo" style="background-image:url(<?php echo $img ; ?>);background-color:<?php echo $background_color; ?>;   height: auto;  " >
	
		<!--<div class="jumbotron " style="background-color: #EAFC2F;  height: auto">-->
	
	



	
	
			
		
			<div style="color: #FDFDF9; "><h4><b><marquee behavior="alternate"><span style="color: <?php echo $text_color; ?>;background-color:<?php $background_color; ?>;"    ><?php echo $_SESSION['biz_name']; ?></span></marquee></b></h4>

	
	</div>
	
	
	
	
			
			
			<div class="row" >
		
				<div class="col-md-12" >
			
					<table style="margin: auto; width: auto" >
		
	
						<tbody >
						
						<tr >
				
							<td>
					
					
								<input type="submit" value='INCOME' onClick="view_ac()" class="btn btn-dark" style= "width: inherit; height: 70px;color:"  name = "A"  >
					
					
			
							</td>
	
							<td>
		
								<a href="report_wizard.php"><input type="button" onClick="spinner()" value="Report" class="btn btn-info" style= "width: ; height: 70px"  name = "A" ></a>
				
							</td>
	
							<td>
		
								<a href="app_info.php"><input type="submit" value="APP info" class="btn btn-info" style= "width: inherit; height: 70px" name = "A" onClick="spinner()" ></a>
			
							</td>
	
	
	
				
						</tr>
		
						</tbody>
					</table>
		
				</div>
	
    
			</div>
			
			
			
			<div class="row">
			
				<table style="margin: auto;width: auto" >
		
	
					<tr>
				
						<td>
					
					 
							<input type="submit" onClick="unit_ac()" value="EXPENSES" class="btn btn-dark" style= "width: inherit; height: 50px" name = "A" >
					
					
				
						</td>
	
						<td>
		
							<a href="inventory_ac.php"> <input type="submit" value="Inventory" onClick="spinner()" class="btn btn-info" style= "width: inherit; height: 50px" name = 
															   "A" ></a>
				
						</td>
	
						<td>
		 
							<a href="add_user.php"> <input type="submit" value="Add users" onClick="spinner()" class="btn btn-info" style= "width: inherit; height: 50px" name = "A"  ></a>
				
						</td>
	
	
	
					</tr>
			
			
				</table>
		
		
			
			</div>
				
	
			<div class="row">
			
				<table style="margin: auto; width: auto"  >
		
	
					<tr>
				
						<td>
					
					 
							<a href="dashboard.php"><input type="button" value="Refresh" class="btn btn-info" onClick=" spinner()" style= "width: inherit; height: 50px"  ></a>
					
					
				
						</td>
	
						<td>
		 
							<input type="button" value="Saved Receipts" class="btn btn-info" style= "width: inherit; height: 50px" name = "A" onClick="window.alert('inactive, www.lawped.com.ng)')" >
				
						</td>
	
						<td>
		 
							<a href="setup_ac.php"><input type="submit" value="Setup" class="btn btn-info" style= "width:inherit; height: 50px" name = "A" onClick= "spinner()" ></a>
				
						</td>
	
	
	
			
		
				</table>
	
			
		
				</tr>
			
	</div>
	
	<div class="row">
			
				<table style="margin: auto; width: auto"  >
		
	
					<tr>
				
						<td>
					
					 
							<a href="debtors.php"><input type="button" value="DEBT MGT" class="btn btn-info" onClick="spinner()" style= "width: inherit; height: 30px"  ></a>
					
					
				
						</td>

						<td>
		 
						<a href="database.php">	<input type="button" value="database" class="btn btn-info" style= "width: inherit; height: 30px" name = "A" onClick="spinner()"  > </a>
				
						</td>
	
						<td>
		 
							<a href="customers.php"><input type="submit" value="CUSTOMERS" class="btn btn-info" style= "width:inherit; height: 30px" name = "A" onClick="spinner()" ></a>
				
						</td>
	
	
	
			
		
				</table>
	
			
				</tr>
			
	</div>
	
	

			
	<div style="align-content: center; text-align: center; color:<?php echo $text_color; ?>">
		
		<?php echo $notification?> 
		
	
		
	</div>

	
	
	
	</div>
	

	
	<!--script to show recent inserted record-->
	
	
	
	<?php
			  //==================================================================================
			 //script to show recent inserted record
			//==================================================================================
	
	
	
	$SQL_recent = "SELECT * FROM txn_table ORDER BY product_id DESC LIMIT 1 ";
	
	$recent_record = mysqli_query($db_handle, $SQL_recent);
	
	$db_found_recent = mysqli_fetch_array($recent_record) ;
	// echo $db_found_recent['amount'];
	
	  //===================================================================================
	  		?>
	
	<div style="text-align:  center;background-color:#050404; font-size: 2px ">
		<h6> <marquee behavior="scroll" style="color: #F7E81B"> <?php echo "welcome to"."  ".$_SESSION['biz_name']." ||  ".'this App'."  ".$_SESSION['app_code']."  ".'will be inactive on the'."  ". $expiration_d." || "."we are into:".$_SESSION['biz_nature']."   || Company Role: $privilage" ?>
		</marquee></h6>
</div>
	<!--script to show recent inserted record-->
	<div style="text-align:  center;background-color:<?php echo $bottom_backgroundcolor;  ?>; width: inherit;  ">
		<h6 style="color:<?php echo $bottom_textcolor;  ?>">  <?php  echo $db_found_recent['product_name']." of 
	".$db_found_recent['amount'].'naira as @ '.$db_found_recent['time']." ". ' ('.$db_found_recent['date'].')'; ?>
		</h6>
		
		
		
</div>	


<div class="container-fluid" style="background-color:" >
	
<div class = "loader" id="spin" style="margin: auto; background-color: ">

</div>
	
	
	
		<div class="container-fluid" style="background-color:;padding-left: 0;padding-right: 0;" >
		

		
			<?php
		
		
		
		
	
		//	echo $dat = date("h:i") ;
		
		
			  $date = date("Y-m-d");
			  //==================================================================================
			 //this junk of code is to sum up daily transaction
			//==================================================================================
	  //$SQL_sum = "SELECT SUM(amount) FROM txn_table where date =current_date";
		// $SQL_sum = "SELECT SUM(amount) FROM txn_table where date = current_date";
		
		
			$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table  where date = '$date' and type = 'expense'";
	  
			$sum = mysqli_query($db_handle, $SQL_sum);
	  
			$db_found_exp = mysqli_fetch_assoc($sum) ;
	  //===================================================================================
		
			//===================================================
			//this code is used for the break even analyzise
			//====================================================
			
			
		
				
				
				
			//this set of codes are used to manipulate the daily account
			
				
			
			
		//	$gross_profit = $db_found_sum['SUM(unit_c)'];
			
			/*$net_profit = $gross_profit - $daily_bep;
			$adjusted_netprf = "";
			$remark = "";
			
			if($net_profit >0){
				
				$adjusted_netprf= $net_profit;
			}
			
				if($net_profit >0){
				
				$remark= "congratulations";
			}
			*/
			?>
		
		
		
			<div class="jumbotron-fluid" >
		
	
			
				<div class="row">
				
				
					<div class="col-md-12" style="padding-top: 8px; color:  <?php echo $bottom_textcolor;  ?>" id="unit_ac">
									
					
						<div class="row">
							<div class="col-md-4"> 
							
									
					
								
								
						<div style="border: 1px solid grey; box-shadow: 5px 5px 5px">
											
						
						<!--space for old pay in script-->
						
							
							
					
						<div id="">
											
						
							<form METHOD ="POST" ACTION = "dashboard.php" style="width: 100%">
							
								<input type="button" style="width: 100%" value="EXPENDITURE ACCOUNT AS @ <?php echo date("Y-m-d"); ?> "> 
								
								<table width="100%">
				
									<tr>
				
					
					
					
										<td>  <select class="custom-select"  style="width:"  id="inputGroupSelect03" name="product">
										
											<option selected>Select Expenses</option>
		
											<?php
											
											$SQL = "SELECT * FROM fixed_cost ORDER BY name ASC ";
											
											$result = mysqli_query($db_handle, $SQL);
											
											$i =1;

											
											while ( $db_found = mysqli_fetch_assoc($result) ) {
											
												echo'<option value="'. $db_found['name'].'">'. $db_found['name'].'</option>'; 
																									  }
		
											?>
											
											</select> 
					
										</td>
					
						 
							
										<td>
											
											
											
						 			<select class="custom-select"  style="width:100%"  id="inputGroupSelect03" name="customer">
										
											<option selected>Anonymous</option>
		
											<?php
											
											$SQL_customer = "SELECT * FROM customers_table where type ='supplier' ORDER BY name ASC ";
											
											$result = mysqli_query($db_handle, $SQL_customer);
											
											$i =1;

											
											while ( $db_found = mysqli_fetch_assoc($result) ) {
											
												echo'<option value="'. $db_found['name'].'">'. $db_found['name'].'</option>'; 
																									  }
		
											?>
											
											</select> 												
						 					
										</td>
										
										



  <p style=" color:<?php echo $bottom_textcolor; ?>">Payment Method<br>
  <input type="radio" id="html" name="payment" value="Cash" checked>
  <label for="html" style=" color:<?php echo $bottom_textcolor; ?>">Cash</label>
  <!--<input type="radio" id="css" name="fav_language" value="CSS">
  <label for="css">POS</label>-->
  <input type="radio" id="javascript" name="payment" value="transfer">
  <label for="javascript" style=" color:<?php echo $bottom_textcolor; ?>">Bank Transfer</label>

 


										
											<td>
						 	  <input type= "number" style="width:100%" placeholder="0.00" class="form-control" aria-label="Amount (to the nearest dollar)" name="amount">
												
												<input type= "hidden"  value="expense" style="width:100%" placeholder="0.00" class="form-control" aria-label="Amount (to the nearest dollar)" name="expense">
												
						 	  
											
						 											
						 					
										</td>
									</tr>
			
								</table>
							
								<tr>
								
										<td>  
									
				<!--	<input type= "text" cols="40" rows = "5" style="width:100%" placeholder="description" class="form-control" aria-label="Amount (to the nearest dollar)" name="s_qty">-->
											
											<textarea cols="50" rows = "3" style="width:100%" placeholder="Description" class="form-control" aria-label="Amount (to the nearest dollar)" name="s_qty"></textarea>
										</td>
					
						 
								<td>
									
									<p></p>
							
									<input type="submit" value="Pay Out (OutFlow)" onClick="spinner(), unit_ac()" class="btn-dark" style= "width: 100%" name = "B" >
								</td>
								
								
								</tr>
										
								
							</form>
							
							
							
						</div>	
											
						
						
							
						
							
						</div>	
							
							<p></p>
							</div>
							
							<div class="col-md-8 ">
								
										<table width="100%" style="color:<?php echo $bottom_textcolor;?>">
							
  <tbody>
	  
   
	 
    <tr>
      <td>Total Expenditure  </td>
      <td>	<span class= "badge-dark">    <input type="button" value=" <?php     echo  $db_found_exp['SUM(amount)'];   ?>"> </span> </td>
    </tr>
  
  </tbody>
</table>
								
								
								<div class="scroll">
	
							<table class="table  table-hover" style="font-size:12; width:100%  " >
  
								<tbody>
    
									<tr  style="background-color: red; text-align: center; color: ghostwhite">
      
										<th scope="col"><input type="button" value="s/n"></th>
	
										<th scope="col"><input type="button" value="Txn id"> </th>
										
										<th scope="col"><input type="button" value="IDN"></th>
      
										<th scope="col"><input type="button" value="Expenditure"></th>
										<th scope="col"><input type="button" value="Payment"></th>
										
										<th scope="col"><input type="button" value="Supplier"></th>
		 
		<!-- <th scope="col">DESCRIPTION</th>-->
	
		   
										<th scope="col"><input type="button" value="Amount"></th>
										<!--<th scope="col">Gross Profit</th>-->
										<!--<th scope="col">QTY</th>-->
		
										
		 
										<th scope="col"><input type="button" value="TIME"></th>
										
		
     
    
									</tr>
 			
		



									<?PHP

//if ($db_found) {

//$SQL = "SELECT * FROM product_table ORDER BY product_id ASC ";

	  
	  
//$SQL = "SELECT * FROM txn_table where date= current_date ORDER BY product_id DESC   ";

									
								//	$SQL = "SELECT *FROM expens_tb   where date= '$date' and type = 'expense' ORDER BY product_id DESC";

										$SQL = "SELECT *FROM txn_table   where date= '$date' and type = 'expense' ORDER BY product_id DESC";

	  
									
									$result = mysqli_query($db_handle, $SQL);

									$i =1;
	  		
									while ( $db_found = mysqli_fetch_assoc($result) ) {
	   
	
										echo'<tr style="text-align: center; color:white; background-color:black" >';

	
	
										echo '<td>'.$i++.'</td>';
		
										?>
									
									<td><a href="transaction.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="<?php echo $db_found["product_id"]?>" onClick="spinner(), view_ac()"></a></td>
									
									
									<td><a href="user_id.php?txnId=<?php echo $db_found["user_id"]?>">
   
										<input type="button" value="<?php echo $db_found["user_id"]?>" onClick="spinner(), view_ac()"></a></td>
									<?php
										
										
										//	echo '<td>'.$db_found['product_id'].'</td>';
										//echo '<td>'.$db_found['user_id'].'</td>';
		 
										echo '<td>'.$db_found['product_name'].'</td>';
										
										echo '<td>'.$db_found['payment'].'</td>';
										
										echo '<td>'.$db_found['customers_name'].'</td>';
		
										echo '<td>'.$db_found['amount'].'</td>';
									
		
										
										
	
										echo '<td>'.$db_found['time'].'</td>';
										
										
					
	 
	
									?>
									<?php
	
										echo '</tr>';

	
	

									}

	  
			
									?>
	

								</tbody>

							</table>
						
								
								</div>
								
								
								
								
							</div>
						
						
						</row>
						
						
						
					</div>
										
					
					
					
					<div class="col-md-1" style="padding-top: 8px" id="bulk_ac">

						<form METHOD ="POST" ACTION = "dashboard.php" style="width: 100%">
						
							<table width="100%">
				
								<tr>
				
					
					
					
									<td>  
					
										<input type="text" class="form-control" name="product" placeholder="Job Description" aria-label="Amount" aria-describedby="basic-addon2">
					
									</td>
					
									<td>
					
										<input type="text" class="form-control" name="amount" placeholder="Amount" aria-label="Recipient's username" aria-describedby="basic-addon2">
				
					
										
									</td>
						 
												
						 												
						 
							
								</tr>
			
							</table>
			 
							<input type="submit" value="SAVE" class="btn-info" style= "width: 100%" name = "A" >
											
							
						</form>
						
					</div>
					
										
								
				
					<div class="col-md-4" style="padding-top: 8px; background-color:" id="crude_ac"  >
					
 
						<form METHOD ="POST" ACTION = "dashboard.php" style="width: 100%">
						
							<table width="100%">
				
								<tr>
				
					
					
					
									<td>  
					
										<input type="text" class="form-control" name="amount" placeholder="Amount" aria-label="Recipient's username" aria-describedby="basic-addon2">
					
									</td>
					
									<td>
					
				
					 
										<input type="submit" value="SAVE" class="btn-dark" style= "width: 100%" name = "A" >
										
									</td>
						 
												
						 												
						 
							
								</tr>
			
							</table>
			
											
							
						</form>
				
					</div>


				
				</div>
		
		
		</div>
		
		
		
		
		
			<?php
		
		
		
		
	
		//	echo $dat = date("h:i") ;
		
		
			  $date = date("Y-m-d");
			  //==================================================================================
			 //this junk of code is to sum up daily transaction
			//==================================================================================
	  //$SQL_sum = "SELECT SUM(amount) FROM txn_table where date =current_date";
		// $SQL_sum = "SELECT SUM(amount) FROM txn_table where date = current_date";
		
		
			$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c),SUM(cog) FROM txn_table  where date = '$date' and type = ''";
	  
			$sum = mysqli_query($db_handle, $SQL_sum);
	  
			$db_found_sum = mysqli_fetch_assoc($sum) ;
	  //===================================================================================
		
			//===================================================
			//this code is used for the break even analyzise
			//====================================================
			$SQL_break_even = "SELECT SUM(amount/30) FROM fixed_cost  ORDER BY name ASC   ";
			 $result_break_even = mysqli_query($db_handle, $SQL_break_even);
			$db_found_even = mysqli_fetch_assoc($result_break_even)
				
		
			
		
	  		?>
		
	  <?php     
				
				
				
			//this set of codes are used to manipulate the daily account
			
				
				$daily_bep =round( $db_found_even['SUM(amount/30)']);  
			//$daily_bep = round($daily_bep_ped);
			
			$gross_profit = $db_found_sum['SUM(unit_c)'];
			
		 $cost_of_goods = $db_found_sum['SUM(cog)'];;
			
			$net_profit = $gross_profit - $daily_bep;
			$adjusted_netprf = "";
			$remark = "";
			
			if($net_profit >0){
				
				
				$adjusted_netprf= $net_profit;
			}
			
				if($net_profit >0){
				
				$remark= "congratulations";
			}
			
			?>
		
		
			<div class="jumbotron-fluid" style="background-color: " id="view_ac">
		
			
				<div class="row " style="margin-top: 1px; background-color:;">
		
			
					
					<!--to pay in script-->
				
					
					
					
					<div class = "col-md-3 " style="color: <?php echo $bottom_textcolor;  ?>" id="">
				
					
								
						<div style="border: 1px solid grey; padding:; box-shadow: 6px 6px 6px ; " id="credit_color">
					<input type="button" style="width: 100%" value="INCOME ACCOUNT AS @ <?php echo date("Y-m-d"); ?> "> 
						
							<form METHOD ="POST" ACTION = "dashboard.php" style="width: 100%">
							
								<table width="100%">
									
									
									
				
							<tr>
									
															
<span style = "color:;  float:inherent" id="credit_color">Credit Sales </span>	 
						<br>				<!-- toggle botton-->
											 			  
<label class="switch" style="float: inherit">
  <input type="checkbox"  id="debt" name="debt" value="debtor" onClick=" showdiv()">
  <span class="slider round" ></span>
</label>
					
										 <br>

					
								
									<span  id="credit_color" style = "color:">Payment Method <br>
										
  <input type="radio" id="html" name="payment" value="Cash" checked>
										 
  <span style=" color:"  id="credit_color">Cash</span>
  <!--<input type="radio" id="css" name="fav_language" value="CSS">
  <label for="css">POS</label>-->
  <input type="radio" id="" name="payment" value="Transfer">
  <span for="" style=" color:" id="credit_color">Bank Transfer</label>

 	
	 </span> 
	  

										<div id ="txtHint" style="color: " id="line_color"> 
											
											

											
											<!--please select product-->
	
											</div>
										
								
										
									
									</tr>			
									
									
									
									
										<tr>
				
					
										
										<td>
										
										<select class="custom-select"  style="width:100%;background-color: #AFB5F8"   name="customer" id="sss"  >
										
											<option value="Anonymous" selected>Customers</option>
		
											<?php
											
											$SQL = "SELECT  DISTINCT name FROM customers_table 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['name'].'">'. $db_found['name'].'</option>'; 
																									  }
		
											?>
											
											</select> 
										</td>
					
					
										<td>  
											<select class="custom-select"  style="background-color:yellow"   name="" id="product" onchange="showUser(this.value) " >
										
											<option value="" selected>Product Category</option>
		
											<?php
											
											$SQL = "SELECT  DISTINCT cat_name FROM product_cat ORDER BY product_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['cat_name'].'">'. $db_found['cat_name'].'</option>'; 
																									  }
		
											?>
											
											</select> 
					
										</td>
					
						 
										
										
										<td  id="cat">
										
											
											
										</td>
										
										

										
									</tr>
									
									
									
								</table>
									
									
											<table>
								<tr>
								
										<td>  
											 		<input type= "number" style="width:100%;background-color: #EBE7E7" placeholder="QTY" class="form-control" aria-label="Amount (to the nearest dollar)" name="s_qty" onkeyup="multiply(this.value)"  id="qty">
						 													
					
										</td>
						<td>
						 	  
	
												
												
												
											<input type= "number" style="width:100%;background-color: #0512A0; color:white" placeholder="0.00" class="form-control" aria-label="Amount (to the nearest dollar)" name="amount" id="amount">
						 													
						 					
										</td>
						 
								
								
								
								</tr>
										
								</table>
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									<!--old scripts-->
							
								<td>
									
									
										<div    id="cont" >
									
										<table>
										
								<tr>
									<br>
								<span  style="" >Part Payment Amount</span> 
								
									<td>
											
											 		<input type= "number" style="width:70%;background-color: #0512A0; color:white" placeholder="Part Payment" class="form-control" aria-label="Amount (to the nearest dollar)" name="actual" onkeyup="diff(this.value)"  id="actual">
						 													
					
								
								</td>
									
										<td >
											<input type= "hidden" style="width:70%" placeholder="Part Payment" class="form-control" aria-label="Amount (to the nearest dollar)" name="balance"  value="" id="balance">
									<span id="bal" style="color: red; font-size:  45px" >Bal:</span> 
									</td>
								
								</tr>
										
								</table>
											
											</div>
									
									
							<br>
							<span id="credit_color"><input type="submit"   value="PAY IN(Inflow)" onClick="spinner(),view_ac()" class="btn-dark" style= "width: 100%;" name = "A" ></span>	
									
								</td>
								
							</form>
						
						</div>
					
					</div>	
					
					
					
					
					
					
					
					
					
					<div class = "col-md-4 " style="background-color:;padding: 10px">
				 
						<strong ><span style="color:<?php echo $bottom_textcolor;  ?>";>
							
					
									 
						
								 
						<table width="100%" style="color:<?php echo $bottom_textcolor;?>;font-size:20px">
							
  <tbody>
	   <tr>
      <td>Total Vol/Qty</td>
      <td> <span class= "badge-dark">  <?php     echo $db_found_sum['SUM(s_qty)'];   ?>   </span> </td>
    </tr>  
   
    <tr>
      <td>Total Sales </td>
      <td>	<span class= "badge-dark">   <?php     echo "  ".$db_found_sum['SUM(amount)']."  ";   ?>    </span></td>
    </tr>
	    <tr>
      <td>Cost of Goods  </td>
      <td>	<span class= "badge-dark">   <?php     echo $cost_of_goods;   ?>    </span></td>
    </tr>
	  
	  <tr>
      <td>Total Expenses</td>
      <td> <span class= "badge-dark">   <?php    echo $db_found_exp['SUM(amount)'];  ?>   </span> </td>
    </tr>
	  <?php
	   
	 $net = $db_found_sum['SUM(amount)'] -$db_found_sum['SUM(cog)'] -$db_found_exp['SUM(amount)'] ;
		 // $net = $db_found_sum['SUM(amount)'] -$gross_profit -$db_found_exp['SUM(amount)'] ;
		  
	   $net_pb = $db_found_sum['SUM(amount)'] -$db_found_sum['SUM(cog)'] -$db_found_exp['SUM(amount)'] ;
	  if($net >0){
		  $net = $net;
		   $remak = "congratulations";
	  }
	  
	  else{
		  $net = "";
		  $remak = "loss";
		  $net_pb = 0;
	  }
	  
	  ?>
	   <tr >
      <td>Net Profit</td>
      <td> <span class= "badge-dark" >   <?php    echo $net;  ?>   </span> </td>
    </tr>
	  
	 
	 
	  
	  
	  
	  <tr>
      <td>Remark</td>
      <td> <span class= "badge-dark">   <?php    echo $remak;  ?>   </span> </td>
    </tr>
	  
	 
	  
    <tr>
      <td>Daily Break Even </td>
      <td> <span class= "badge-dark">   <?php     echo $daily_bep;  ?>    </span> </td>
    </tr>
	  
	    <tr>
			<?php
			$pab = $net_pb - $daily_bep;
				
				if ($pab<0)
				{
					$pab= "";
				}
			?>
			
			
      <td>Profit After B.E.P</td>
      <td> <span class= "badge-dark">   <?php echo $pab;   ?>    </span> </td>
    </tr>
	  
	  
	
  </tbody>
</table>

							
							
			
							
							
							
							
							
							
							
							
						
				   </span></strong>
			
			  
						<div class="jumbotron-fluid scroll" >
				  
	  
							<table class="table table-dange table-hover" style="font-size:16; width:100% ;color: <?php echo $bottom_textcolor  ?>" >
  
								<tbody style="color:;bottom_textcolor">
    
									<tr  style="background-color: ; text-align: center; color: ">
      
										<th scope="col"><input type="button" value="S/N"></th>
		
										<!--<th scope="col">TRN ID</th>-->
      
										<th scope="col"><input type="button" value="Description"></th>
		
										<!-- <th scope="col">DESCRIPTION</th>-->
	
		   
										<th scope="col"><input type="button" value="Total Sales"></th>
										<!--<th scope="col"><input type="button" value="Gross Profit"></th>-->
										<th scope="col"><input type="button" value="QTY"></th>
										
		
     
    
									</tr>
 			
		



									<?PHP

	  
	  
//$SQL = "SELECT * FROM txn_table where date= current_date ORDER BY product_id DESC   ";
//$SQL = "SELECT  product_name,product_id,  SUM(amount) FROM txn_table   where date= current_date GROUP BY product_name  ORDER BY product_id DESC";

	  
									$SQL = "SELECT  product_name,product_id,SUM(amount),SUM(unit_c),SUM(s_qty) FROM txn_table   where date= '$date' and type = '' GROUP BY product_name  ORDER BY product_id DESC";

	  
									$result = mysqli_query($db_handle, $SQL);

									$i =1;
	  


									while ( $db_found = mysqli_fetch_assoc($result) ) {
	   
	
										echo'<tr style="text-align: center;background-color:; color: echo $text_color " >';
     // echo '<td>'.$db_found['user_id'].'</td>';
	
	
	
										echo '<td>'.$i++.'</td>';
	// echo '<td>'.$db_found['product_id'].'</td>';
	 
										echo '<td>'.$db_found['product_name'].'</td>';
	
	
	// echo '<td>'.'<a href="www.lawped.com.ng?id=$db_found['product_id']">details</a>'.'</td>';
	
	// $db_found_sum['SUM(amount)'];
	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</td>';
										//echo '<td>'.$db_found['SUM(amount-s_qty*unit_c)'].'</td>';
										//echo '<td>'.$db_found['SUM(unit_c)'].'</td>';
										echo '<td>'.$db_found['SUM(s_qty)'].'</td>';
										
										
	
	//echo $db_found_sum['SUM(amount)']; 
	 
  
   
   
										echo '</tr>';

	
	
}

//}
//else {

//print "Database NOT Found ";

//}
//mysqli_close($db_handle);
	  
			
									?>
	
	
	
	
	
  
								</tbody>

							</table>
						
	
	
	
						</div>

					
					</div>
						
			
					<div class = "col-md-5 " style="background-color: #494747">
				  	
						<strong ><span style="color:#FAF7FF;padding: 4px"><br>Transaction History<input type="button" value="<?php echo $txn_nbr?>mb">
					    <p>
							</span> </strong>
				
						 
						<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  <!--<strong ><span style="color:#260B4D;background-color: #FBFBFC;padding: 4px">TRANSACTION HISTORY
					     </span></strong>-->
				  
	  
							<table class="table  table-hover" style="font-size:13; width:100%  " >
  
								<tbody>
    
									<tr  style="background-color: #A22E2E; text-align: center; color: white">
      
										<th scope="col"><input type="button" value="s/n"></th>
	
										<th scope="col"></th>
										
										<th scope="col"></th>
										
										<th scope="col"></th>
      
										<th scope="col"><input type="button" value="Description"></th>
										<th scope="col"><input type="button" value="Payment"></th>
										
										<th scope="col"><input type="button" value="Customer"></th>
		 
		<!-- <th scope="col">DESCRIPTION</th>-->
	
		   
										<th scope="col"><input type="button" value="Sales"></th>
										<th scope="col"><input type="button" value="Balance"></th>
									<!--	<th scope="col"><input type="button" value="Gross Profit:"></th>-->
										<th scope="col"><input type="button" value="QTY"></th>
		
										
		 
										<th scope="col"><input type="button" value="TIME"></th>
										
		
     
    
									</tr>
 			
		



									<?PHP

//if ($db_found) {

//$SQL = "SELECT * FROM product_table ORDER BY product_id ASC ";

	  
	  
//$SQL = "SELECT * FROM txn_table where date= current_date ORDER BY product_id DESC   ";

									
									$SQL = "SELECT *FROM txn_table   where date= '$date' and type = '' ORDER BY product_id DESC";

	  
									
									$result = mysqli_query($db_handle, $SQL);

									$i =1;
	  		
									while ( $db_found = mysqli_fetch_assoc($result) ) {
	   
	
										echo'<tr style="text-align: center; color:white; background-color:black" >';

	
	
										echo '<td>'.$i++.'</td>';
		
										//echo '<td>'.$db_found['product_id'].'</td>';
										
										
										
										
										//echo '<td>  <button>'.$db_found['product_id'].'</botton></td>';
										
										?>
										<td><a href="transaction.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Reverse" onClick="spinner(), view_ac()"></a></td>
									
									
									<td><a href="user_id.php?txnId=<?php echo $db_found["user_id"]?>">
   
										<input type="button" value="Staff" onClick="spinner(), view_ac()"></a></td>
									
									
									
									<td><a href="invoice.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Issue Reciept" onClick="spinner(), view_ac()"></a></td>
									
									
									
									
								
									<?php
									//echo '<td>'.$db_found['user_id'].'</td>';
										
										
										
										
		 
										echo '<td>'.$db_found['product_name'].'</td>';
										
										echo '<td>'.$db_found['payment'].'</td>';
										
										echo '<td>'.$db_found['customers_name'].'</td>';
		
										echo '<td>'.$db_found['amount'].'</td>';
										echo '<td>'.$db_found['balance'].'</td>';
									
		
	
									//	echo '<td>'.$db_found['unit_c'].'</td>';
	
	 
										echo '<td>'.$db_found['s_qty'].'</td>';
										
										
	
										echo '<td>'.$db_found['time'].'</td>';
										
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
<!--	  
  <td><a href="construction.php?txnId=Receipt">
    <input type="button" value="Issue Receipt"></a></td>
	  
	  <td><a href="construction.php?txnId=Modify Account">
    <input type="button" value="Modify"></a></td>-->
	  
	  <!--
									<td>
    
										<input type="button" value="Issue Receipt"onClick= "window.alert('The page  you requsted is still under Development. Contact us (Alaye David 09055158742, head of iCT LAWPED GROUP,www.lawped.com.ng')"></td>
	  
	  
									<td>
    
										<input type="button" value="Modify"onClick= "window.alert('The page  you requsted is still under Development. Contact us (Alaye David 09055158742, head of iCT LAWPED GROUP,www.lawped.com.ng')" ></td>
	  
	   
									
   
										<input type="button" value="Delete" onClick="spinner(), view_ac()"></a></td>
	
	  -->
									<?php
	
										echo '</tr>';

	
	

									}

									mysqli_close($db_handle);
	  
			
									?>
	

								</tbody>

							</table>
						
	
	
						</div>
			
					</div>
			
		
				</div>
		
		
			</div>
		

		</div>
	
	

</div>

		</body>

</html>




	<script>
		
		

		function spinner() {
  
			var x = document.getElementById("spin");
	
	
	
  if (x.style.display === "none") {
    x.style.display = "block ";
	  
	  
  }
	else {
    x.style.display = "none";
  }
	
	
}
		
		
	
		
		
		
		
		
		
		
		
		
		
		function view_ac() {
  
			var x = document.getElementById("view_ac");
	
	 var unit_ac = document.getElementById("unit_ac");
	 var bulk_ac = document.getElementById("bulk_ac");
	 var crude_ac = document.getElementById("crude_ac");
	
  if (x.style.display === "none") {
    x.style.display = "block";
	  
	   
	  unit_ac.style.display="none";
	  crude_ac.style.display="none";
	  bulk_ac.style.display="none";
	  
  }
	else {
    x.style.display = "none";
  }
	
	
}
		
		
	
function unit_ac() {
	var x = document.getElementById("unit_ac");
	 var unit_ac = document.getElementById("bulk_ac");
	 var crude_ac = document.getElementById("crude_ac");
	var view_ac = document.getElementById("view_ac");
	
  if (x.style.display === "none") {
   
	   x.style.display = "block";
	  
	  unit_ac.style.display="none";
	  crude_ac.style.display="none";
	  view_ac.style.display="none";
	  
	  
  } 
	else {
    x.style.display = "none";
		
		
		
  }
	
	
}		
		
		
function bulk_ac() {
  var x = document.getElementById("bulk_ac");
	
	 var unit_ac = document.getElementById("unit_ac");
	 var crude_ac = document.getElementById("crude_ac");
	var view_ac = document.getElementById("view_ac");
	
  if (x.style.display === "none") {
    x.style.display = "block";
	  
	   unit_ac.style.display="none";
	  crude_ac.style.display="none";
	   view_ac.style.display="none";
  } 
	else {
    x.style.display = "none";
  }
}		
		
			
function crude_ac() {
  var x = document.getElementById("crude_ac");
	
	var unit_ac = document.getElementById("unit_ac");
	 var bulk_ac = document.getElementById("bulk_ac");
	var view_ac = document.getElementById("view_ac");
	
  if (x.style.display === "none") {
    x.style.display = "block";
	  unit_ac.style.display="none";
	  bulk_ac.style.display="none";
	  view_ac.style.display="none";
  } 
	else {
    x.style.display = "none";
  }
}		
		
			
		

		


</script>			
			




 <!--   Core JS Files   -->
  <script src="assets/js/core/popper.min.js"></script>
  <script src="assets/js/core/bootstrap.min.js"></script>
 
  <script>
    var win = navigator.platform.indexOf('Win') > -1;
    if (win && document.querySelector('#sidenav-scrollbar')) {
      var options = {
        damping: '0.5'
      }
      Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
    }
  </script>
  <!-- Github buttons -->
  <script async defer src="https://buttons.github.io/buttons.js"></script>
  <!-- Control Center for Material Dashboard: parallax effects, scripts for the example pages etc -->
 



<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 for toggle
function showdiv() {
	
	var x = document.getElementById("cont");
	
	//credit_color
	
  if (x.style.display == "none") {
    
	   x.style.display = "block";
	 
	
	  var color = document.getElementById("credit_color");
	
	  color.style.backgroundColor=" #353434";
	
	  color.style.color="red";
	  
	  
	   var colo = document.getElementById("credit_colo");
	
	  colo.style.backgroundColor="red";
	
	  colo.style.color="white";
		
	  
	 // alert();
	 
	
	  // unit_ac.style.display="none";
	 // crude_ac.style.display="none";
	 //  view_ac.style.display="none";
	 
  } 
	else {
		
		 x.style.display = "none";
		
		var color = document.getElementById("credit_color");
		
		var col = document.getElementById("cont");
		col.style.color="";
		
		color.style.backgroundColor="";
		color.style.color="";
   
		
		var colo = document.getElementById("credit_colo");
	
	  colo.style.backgroundColor="<?php echo $background_color; ?>";
	
	  colo.style.color="";
		 
	    
  }
	
	

	
}

	
	
	setTimeout(function(){
   window.location.reload(1);
}, 1440000);
	
	</script>

