<?PHP


session_start();
$status = $_SESSION['status'];

						

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

//echo 'WELCOME'.'    '.$_SESSION['name'].'   '.'<A HREF = logout.php>Log out</A>';

?>

<?php

$privilage = $_SESSION['privilage']; 

 

$app_name = $_SESSION['app_name'];
//echo "<br>";


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


?>






<?php
require 'config.php';

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

$database = "lawpedc3_lbs_users";

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


?>

<?php

	
$notification = "";

if(isset($_POST['A'])){
	
	echo $date = $_POST['date'];
	 
    $product = $_POST['product'];
	$amount = $_POST['amount'] ;
	$s_qty = $_POST['s_qty'] ;
	
		$customers = $_POST['customer'];
	
if($product=="Select Product" or $amount=="" or $s_qty==""){
	 $notification = 'OPERATION FAILED|| amount or quantity or product field is blank';
}
	
	
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'].'<br>';
	
	$totalcost = intval($unit_qty_cost) *$s_qty.'<br>';
	
  	 "grossprofit". $gross_profit = intval($amount) -intval($totalcost);
	 "avilableqnty". $avail_qnty = 	intval($qty) - $s_qty;		
	
	
	
	
	
	
	
	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,customers_name, amount,unit_c,s_qty, user_id,month,year,time,date) VALUES (?,?,?,?,?,?,?,?,?,?)");
			$SQL->bind_param('ssssssssss', $product,$customers, $amount,$gross_profit,$s_qty, $_SESSION['user_id'],$month,$year,$time, $date );
			$SQL->execute();
			//header ("Location: dashboard.php");
		

	
	
	
		 $notification = "operation successfull";
	
		
		
	}
	
	
	
	
	
	
	}
	
	
	
	

}






else{
	
}
?>


<!DOCTYPE html>
<html lang="en">
<head>
	<title>Lawped</title>
	<meta charset="UTF-8">
	<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">
<!--===============================================================================================-->
	
</head>
	
	 <script src="js/main.js"></script>
	
	
	
	<style>
		
		.loader {
  border: 16px solid #f3f3f3;
  border-radius: 50%;
  border-top: 16px solid blue;
  border-right: 16px solid green;
  border-bottom: 16px solid red;
  border-left: 16px solid pink;
  width: 120px;
  height: 120px;
  -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: #E1E1DB;
}

	
		
	
            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= "spinner()">


	
	
	<!--newheader-->
	
	
	
	
	<!--new headeer-->
	
	
		<div class="jumbotron-fluid" style="background-color: #D5F51C">
	

		
	
			

	
	
		<div class="jumbotron" style="background-color: #F9FAFB; height: auto">
			
			
		
	
			
			
			<div class="row">
		
				<div class="col-md-12" id="">
			
					<table style="margin: auto; width: auto; " >
		
	
						<tr>
				
							<td>
					
					
								<!--<input type="submit" value='Record' onClick="unit_ac()" class="btn btn-info" style= "width: inherit; height: 70px" name = "A"  >-->
					
					
			
							</td>
	
							<td>
		
									<a href="dashboard.php"><input type="button" value="HOME" class="btn btn-danger" onClick=" spinner()" style= "width: inherit; height: "  ></a>
				
							</td>
	
					<!--		<td>
		
							<input type="submit" value="Account" class="btn btn-info" style= "width: inherit; height: 70px" name = "A" onClick="spinner()" >
			
							</td>-->
	
	
	
				
						</tr>
		
					</table>
		
				</div>
	
    
			</div>
			
	
	
	
	

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

			<div class="row">
				
					<div style="color: #0508A8;  "><h4><b><span style="color: #1004A7">Employee Details</span></b></h4></div>
				
				
	
									<?PHP

									$amount =  $_GET['txnId']; ;
									
								

	  $SQL = "SELECT  * FROM login   where ID = $amount ";

									
									$result = mysqli_query($db_handle, $SQL);
								
								 $db_found = mysqli_fetch_assoc($result);
							
	  
							
									?>
				
				
				
	<div class="col-md-12">
	
						<table width="100%" style="font-size: 14px; margin: auto;color:#0508A8;"  >
		
								 <tr>
      <td>company role</td>
      <td> <?php    echo $db_found['privilage'];  ?> </td>
    </tr>
 
	   <tr>
      <td>Name</td>
      <td>   <?php     echo $db_found['name'];   ?>    </td>
    </tr>  
   
    <tr>
      <td>Country</td>
      <td><?php echo $db_found['nation'];?></td>
    </tr>
	  
	  
	  <tr>
      <td>City</td>
      <td>  <?php echo $db_found['city'];?>    </td>
    </tr>
	
	   <tr >
      <td >Phone-No: </td>
      <td>  <?php    echo $db_found['fone'];  ?>   </td>
    </tr>
	  
	 
	 
	  
	  
	  
	  <tr>
      <td>Email</td>
      <td> <?php    echo $db_found['email'];  ?> </td>
    </tr>
							
						
	  
	   <tr>
      <td>Profile Code</td>
      <td> <?php    echo $db_found['ID'];  ?> </td>
    </tr>
	
	 
	  
	  
	

</table>
	
	

		</div>
	


		</div>
	
	
			</div>



		</body>

</html>




	<script>
		
s		

		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 -->