<?php

 //echo $product_name = $_POST['product'];



session_start();

//$privilage = $_SESSION['privilage']; 


 $data_base = $_SESSION['database'];


$status = $_SESSION['status'];





$app_name = $_SESSION['app_name'];
$app_code = $_SESSION['app_code'];
  $db_size = $_SESSION['db_size'];
$biz_name = $_SESSION['biz_name'];
$biz_nature = $_SESSION['biz_nature'];
$privilage = $_SESSION['privilage'];




$current_date = date("Y-m-d");
$activation_d = $_SESSION['activation_date'];
$expiration_d = $_SESSION['expiration_date'];


if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {

	header ("Location: login.php");

}
		
else if($privilage == "Priviledge" or $privilage == "Sales Rep" or $privilage == "Sales Rep" or $privilage == "Receptionist" or $privilage == "Iventory Manager" or $privilage == "Secetary"or $privilage == "Manager")
{
	
	header ("Location: not_authorized.php");
	
}




?>


<?php

$error = "";

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);
			
		//$SQL = "DELETE FROM product_table WHERE product_id=$txnid";
   //$query_del = mysqli_query($db_handle, $SQL);



  if($db_found){
	 

if(isset($_POST['A']))
{
	 
   
		
	    $biz_name = $_POST['biz_name'];
		$biz_nature = $_POST['biz_nature'] ;
		$admin_name = $_POST['admin_name'] ;
	
		$nation = $_POST['nation'] ;
		$city = $_POST['city'] ;
		$fone = $_POST['fone'] ;
		$email = $_POST['email'] ;
	
		$user_name=$_POST['pass'];
    	$pass=$_POST['pass'];
		$re_pass=$_POST['re_pass'];
		
		 $d_b=  $_POST['d_base'];
	$db_size=  $_POST['db_size'];
	
	
	
		 $app_code = $_POST['app_code'];
	 $app_name =$_POST['app_name'];
	
	 $privilage =$_POST['privilage'];
	 $status =$_POST['status'];
	
	 $date = date("Y-m-d");
	
	

	if($pass==$re_pass)
	
	{
		
		
		//if( $biz_name or $biz_nature or $admin_name or $nation or $city or $fone =="")
			if( $biz_name =="" or $biz_nature==""  or $admin_name=="" or $nation=="" or $city==""or $fone =="" or $pass =="" or $re_pass=="")
		
		{
		
				
			$error = " one of the fields is blank";
		}

		else{
			
			$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );
	
		$SQL = $db_found->prepare("INSERT INTO login (biz_name,biz_nature,name,nation,city,fone,email,L1,L2,d_b,db_size,app_code,app_name,privilage,status,date,activation_date,expiration_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
			$SQL->bind_param('ssssssssssssssssss',$biz_name,$biz_nature, $admin_name,$nation,$city,$fone,$email,$user_name,$pass,$d_b,$db_size,$app_code,$app_name,$privilage, $status,$date,$activation_d,$expiration_d);
			
		
			$SQL->execute();
			
			header ("Location: add_user.php");
			
			//$error = "no blank";
		}
		
		
		
		
		
		
	}
	
	else{
		$error = "passwords mis-matched";
	
	}


	
	
	
	
	
	
	
}
	  
	  
	// header ("Location: inventory_ac.php");

	 
	  
  
  }
	  
  
else{
	
	$error =  "database not found";

	}

 

?>






	<html>
		
			<title>Delete_script</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">
		
		
		
	<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); }
}

			
			
			div.scroll_history {
                //margin:4px, 4px;
               // padding:4px;
                background-color: #494747;
                width: 100%;
                height: 80%;
                //overflow-x: hidden;
                //overflow-y: auto;
				overflow: auto;
                text-align:justify;
            }
		
			
			
		
		body, html {
background-color: #BC0306;
			}
		</style>
		
		
		
	<body onLoad="spinner()">


			

		<div class="jumbotron" style="text-align: center">
		
		
		
		
		<div class="row" style="height: ">
			
			
					<div class="col-md-6">
			
			
				<table style="margin: auto;width:;background-color: " >
				
		
					<tr>
				<td>
				
		 			<span style="background-color: black; color: white;">  <?php echo $error; ?></span>
			<h3><b><span style="color: #8996C9">LBS <span style="color: red">LBS</span> </b></h3>
				
					<form METHOD ="POST" ACTION = "lbs_dashbard.php" style="width: 100%">
				
						<input type="hidden" value="<?php echo $data_base ?>" name="d_base">
						<input type="hidden" value="<?php echo $db_size ?>" name="db_size">
						<input type="hidden" value="<?php echo $app_code ?>" name="app_code">
						
						
						<input type="hidden" value="LBS" name="app_name">
						<!--<input type="hidden" value="admin" name="privilage">-->
						<input type="hidden" value="active" name="status">
						
						
							<!--<select class="custom-select"  style="width:100%"  id="inputGroupSelect03" name="privilage">
										
												<option selected>Priviledge</option>
																		
												<option value="admin">admin</option> 
												<option value="Sales Rep">Sales Rep</option> 
												<option value="Receptionist">Receptionist</option>
												<option value="Manager">Manager</option>
												<option value="Inventory Manager">Inventory Manager</option>
												<option value="Employee">Secetary</option>
																									  }
		
											
											
											</select> -->
					
						
						
						<table width="">
				
							<tr>
									<td>  
	
										<div class="input-group mb-3">
											
											
											<input type="hidden" class="form-control" placeholder="eg.Lawped Limited" aria-label="Username" aria-describedby="basic-addon1" value="<?php echo $biz_name ?>" name="biz_name">
				
										</div>
										
										<div class="input-group mb-3">
											
										
										
											<input type="hidden" class="form-control" placeholder="eg.Provision Store,Supermarket,Gas station etc" aria-label="Username" aria-describedby="basic-addon1" value="<?php echo $biz_nature ?>" name="biz_nature">
				
										</div>
										
										
										
										
					
										<div class="input-group mb-3">
  					
											<div class="input-group-prepend">
    
												<span class="input-group-text" id="basic-addon1">APP CODE</span>
  
												</div>
  
											<input type="text" class="form-control" placeholder="eg. Alaye David " aria-label="Username" aria-describedby="basic-addon1" name="app_code" value="">

											
										</div>
										
										
							
					</td>
					
	
						</tr>
							
					</table>
						<table>
						<td>
			<input type="submit" value="                  QUERY            "  name = "B" style= "width:auto; height: 70px" class="btn btn-info" onClick="spinner()" > 
						</td>
							
							<td>
							
							<div class="loader" id="load" style="margin: auto"></div>
							</td>
							
							
				<td>		
						<a href = "logout.php"><input type="button" value=" Logout "  name = "" style= "width:auto; height: 70px" class="btn btn-danger" onClick="spinner()"> </a>
				</td>
											
								</table>
					</form>
		
		        
					
					
				
		</td>
					
			
	
				</tr>

			
			
			</table>
				
				
				
				
				
				</div>

			
			
			
			
					<div class = "col-md-6 " style="background-color: #494747;height: 500px">
				  	
						<strong ><span style="color:#FAF7FF;padding: 4px"><br>MASTER ACCOUNT
					    
							</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:12; width:100%  " >
  
								<tbody>
    
									<tr  style="background-color: #A22E2E; text-align: center; color: white">
      
										<th scope="col">S/N</th>
	
										<th scope="col">IDN </th>
										
										<th scope="col">NAME</th>
      
										<th scope="col">PASSWORD</th>
										
										<th scope="col">CITY</th>
		 
		<!-- <th scope="col">DESCRIPTION</th>-->
	
		   
										<th scope="col">PHONE</th>
										<th scope="col">EMAIL</th>
										<th scope="col">PRIVILAGE</th>
		
										
		 
										<th scope="col">STATUS</th>
										<th scope="col">APP CODE</th>
										<th scope="col">DATABASE</th>
										
										<th scope="col">DATE</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   ";

						
									
								if(isset($_POST['B']))
{
	 
					$app_code = $_POST['app_code'];
								
									$SQL = "SELECT   *FROM login  where app_code = '$app_code'   ORDER BY 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['ID'].'</td>';
										
										echo '<td>'.$db_found['name'].'</td>';
		 
										echo '<td>'.$db_found['L1'].'</td>';
										
										echo '<td>'.$db_found['city'].'</td>';
		
										echo '<td>'.$db_found['fone'].'</td>';
									
		
	
										echo '<td>'.$db_found['email'].'</td>';
	
	 
										echo '<td>'.$db_found['privilage'].'</td>';
										
										
	
										echo '<td>'.$db_found['status'].'</td>';
										echo '<td>'.$db_found['app_code'].'</td>';
										echo '<td>'.$db_found['d_b'].'</td>';
										
										echo '<td>'.$db_found['date'].'</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><a href="modify_priviledge.php?txnId=<?php echo $db_found["ID"]?>">
   
										<input type="button" value="Modify Account" onClick="spinner(), view_ac()"></a>
									</td>
	
	
	   
									<td><a href="admin_dashboard_delete.php?txnId=<?php echo $db_found["ID"]?>">
   
										<input type="button" value="Delete Account" onClick="spinner(), view_ac()"></a>
									</td>
	
	  
									<?php
	
										echo '</tr>';

	
	

									}

							//		mysqli_close($db_handle);
	  
								}
									?>
	

								</tbody>

							</table>
						
	
	
						</div>
			
					</div>
			
			
		</div>
			
	
			
			</div>
	
		
		
		
		
		
		
		
		<div class="jumbotron">
		
		
			<div class="row" style="height: 30%">
			
				<div class="col-md-6">
				
						<strong ><span style="color:#FAF7FF;padding: 4px"><br>ACTIVE ACCOUNT
					    
							</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:12; width:100%  " >
  
								<tbody>
    
									<tr  style="background-color: #A22E2E; text-align: center; color: white">
      
										<th scope="col">S/N</th>
	
										<th scope="col">IDN </th>
										
										<th scope="col">NAME</th>
      
										<th scope="col">PASSWORD</th>
										
										<th scope="col">CITY</th>
		 
		<!-- <th scope="col">DESCRIPTION</th>-->
	
		   
										<th scope="col">PHONE</th>
										<th scope="col">EMAIL</th>
										<th scope="col">PRIVILAGE</th>
		
										
		 
										<th scope="col">STATUS</th>
										<th scope="col">APP-CODE</th>
										
										<th scope="col">DATE</th>
										
		
     
    
									</tr>
 			
		



									<?PHP
			
								
					
								
									$SQL = "SELECT  *FROM login   where status = 'active'  ORDER BY 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['ID'].'</td>';
										
										echo '<td>'.$db_found['name'].'</td>';
		 
										echo '<td>'.$db_found['L1'].'</td>';
										
										echo '<td>'.$db_found['city'].'</td>';
		
										echo '<td>'.$db_found['fone'].'</td>';
									
		
	
										echo '<td>'.$db_found['email'].'</td>';
	
	 
										echo '<td>'.$db_found['privilage'].'</td>';
										
										
	
										echo '<td>'.$db_found['status'].'</td>';
										
										echo '<td>'.$db_found['app_code'].'</td>';
										
										echo '<td>'.$db_found['date'].'</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><a href="modify_priviledge.php?txnId=<?php echo $db_found["ID"]?>">
   
										<input type="button" value="Modify Account" onClick="spinner(), view_ac()"></a>
									</td>
	
	
	   
									<td><a href="add_user_delete.php?txnId=<?php echo $db_found["ID"]?>">
   
										<input type="button" value="Delete" onClick="spinner(), view_ac()"></a>
									</td>
	
	  
									<?php
	
										echo '</tr>';

	
	

									}

									//mysqli_close($db_handle);
	  
							
									?>
	

								</tbody>

							</table>
						
	
	
						</div>
			
					
				</div>
				
			
				<div class="col-md-6">
				
						<strong ><span style="color:#FAF7FF;padding: 4px"><br>INACTIVE ACCOUNT
					    
							</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:12; width:100%  " >
  
								<tbody>
    
									<tr  style="background-color: #A22E2E; text-align: center; color: white">
      
										<th scope="col">S/N</th>
	
										<th scope="col">IDN </th>
										
										<th scope="col">NAME</th>
      
										<th scope="col">PASSWORD</th>
										
										<th scope="col">CITY</th>
		 
		<!-- <th scope="col">DESCRIPTION</th>-->
	
		   
										<th scope="col">PHONE</th>
										<th scope="col">EMAIL</th>
										<th scope="col">PRIVILAGE</th>
		
										
		 
										<th scope="col">STATUS</th>
											<th scope="col">APP-CODE</th>
										
										<th scope="col">DATE</th>
										
		
     
    
									</tr>
 			
		



									<?PHP
			
								
					
								
									$SQL = "SELECT  *FROM login   where status = 'inactive'  ORDER BY 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['ID'].'</td>';
										
										echo '<td>'.$db_found['name'].'</td>';
		 
										echo '<td>'.$db_found['L1'].'</td>';
										
										echo '<td>'.$db_found['city'].'</td>';
		
										echo '<td>'.$db_found['fone'].'</td>';
									
		
	
										echo '<td>'.$db_found['email'].'</td>';
	
	 
										echo '<td>'.$db_found['privilage'].'</td>';
										
										
	
										echo '<td>'.$db_found['status'].'</td>';
										
										echo '<td>'.$db_found['app_code'].'</td>';
										
										
										
										echo '<td>'.$db_found['date'].'</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><a href="modify_priviledge.php?txnId=<?php echo $db_found["ID"]?>">
   
										<input type="button" value="Modify Account" onClick="spinner(), view_ac()"></a>
									</td>
	
	
	   
									<td><a href="add_user_delete.php?txnId=<?php echo $db_found["ID"]?>">
   
										<input type="button" value="Delete" onClick="spinner(), view_ac()"></a>
									</td>
	
	  
									<?php
	
										echo '</tr>';

	
	

									}

									mysqli_close($db_handle);
	  
							
									?>
	

								</tbody>

							</table>
						
	
	
						</div>
			
					
				</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>