 <?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");
}

else if($privilage == "Priviledge" or $privilage == "Sales Rep" or $privilage == "Sales Rep" or $privilage == "Receptionist" or $privilage == "Inventory Manager" or $privilage == "Secetary"/*or $privilage == "Manager"*/)
{
	
	header ("Location: not_authorized.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 = "lawped_app";

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


?>

<?php



											/*$SQ = "SELECT product_name, unit_c FROM product_table where product_name = 'laptop' ";
											
											$resul = mysqli_query($db_handle, $SQ);
											$db_foun = mysqli_fetch_assoc($resul);
											echo $unit_qty_cost = $db_foun['unit_c'].'<br>';
*/

											


?>



<!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>
	
	
	
	
	<style>
		
		
		
		.btn {
 // background-color: DodgerBlue;
			
			 background-color: <?php echo  $bottom_backgroundcolor ?>;
  border: none;
  //color: white;
			
		color:<?php echo  $bottom_textcolor ?>;
  padding: 12px 16px;
  font-size: 16px;
  cursor: pointer;
}

/* Darker background on mouse-over */
.btn:hover {
 background-color: RoyalBlue;
	
	
}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
					.loader {
  border: 5px solid #f3f3f3;
  border-radius: 50%;
  border-top: 5px solid blue;
  border-right: 5px solid green;
  border-ottom: 5px solid red;
  border-left: 5px solid pink;
  width: 120px;
  height: 120px;
  -webkit-animation: spin 1s linear infinite;
  animation: spin 0.8s 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:;
}

	
		
	
            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(),unit_ac(),bulk_ac(),crude_ac(),view_a()">


	
	
	<!--newheader-->
	
	
	
	
	<!--new headeer-->
	
	
<div class="jumbotron-fluid" style="background-color: #757672; color: #F0ECEC">
	
				<i class='fas fa-user-circle'>  <?php echo $_SESSION['name'].'   '.' (IDN '. $_SESSION['user_id'].' ) ' ?></i> Detailed Report 
			
			

			<div class="" style="float: right; color: #ED0307;"><a HREF = "logout.php" onClick="spinner()"><span style="color: #F9F833"><i class='fas fa-power-off'>logout</i></span></a></div>
			<!--<button onclick="myFunction()">Click Me</button>-->
			

			
		</div>


	
	
	
	<div class="jumbotron" style="background-color:  <?php echo $background_color; ?>; height: auto">
			
			
<div class="loader" id="spin" style="margin: auto"></div>		
			
			
			
	
	
		
	
			
			
		<div class="row">
			
				<table style="margin: auto;width: auto" >
		
	
					<tr>
				
						<td>
					
					 <button class="btn" style= "width:10px inherit; height: "  onClick="window.print()"><i class="material-icons">cloud_download_print</i>  </button> 
							
							<!--<input type="submit" onClick= "window.print()" value="Print" class="btn btn-danger" style= "width: inherit; height: 30px" name = "A" >-->
					
				
				
						</td>
	
						<td>
		
							
				
						</td>
	
						<td>
		 
							<button class="btn" style= "width: inherit; height: "  onClick="spinner(),history.back()"><i class="material-icons">arrow_back</i>  </button> 
							
						<!--<a href="dashboard.php">	<input type="submit"  onClick="spinner()"  value="Home" class="btn btn-danger" style= "width: inherit; height: 30px" name = "A"  ></a>-->
				
						</td>
	
	
	
					</tr>
			
			
				</table>
		
		
			
			</div>
	
		
			
	
	</div>
	
	
	<!--cscript to accounts and transaction history-->
	
	

	
	
	
		

	<div class="" style="background-color:" >
		
		
		<div class="container">
		
<div class="jumbotron-fluid" style="background-color: ">
		
		
			
				<div class="row">
				
				
					<div class="col-md-4" style="padding-top: 8px" id="unit_ac">
					
						<div id="">
											
						
						<!--	<form METHOD ="POST" ACTION = "report_wizard.php" style="width: 100%">
							
								<table width="100%" style="margin-bottom:10px;">
				
										<tr>
				
					
					
				
											<td style="background-color: black">  <select class="custom-select"  style="width:"  id="inputGroupSelect03" name="product">
										
											<option selected><?php  echo 'Select Days';   ?></option>
		
											<?php
											
											$SQL = "SELECT DISTINCT date FROM txn_table ORDER BY date DESC  ";
											
											$result = mysqli_query($db_handle, $SQL);
											
											$i =1;

											
											while ( $db_found = mysqli_fetch_assoc($result) ) {
											
												echo'<option value="'. $db_found['date'].'">'. $db_found['date'].'</option>'; 
																									  }
		
											?>
											
											</select> 
					
										</td>
											
											
					
									<td>
					
				
					 
										<input type="submit" value="GENERATE" class="btn-dark" style= "width: 100%" name = "A" onClick="spinner()" >
										
									</td>
						 
												
						 												
						 
							
								</tr>
			
								</table>
			 
							
								
							</form>-->
							
						</div>	
											
						
							<div id="">
											
						
							<form METHOD ="POST" ACTION = "report_wizard.php" style="width: 100%">
							
								<table width="100%">
				
										<tr>
				
					
					
				
											<td>  <select class="custom-select"  style="width:"  id="inputGroupSelect03" name="product">
										
											<option selected><?php  echo 'Upper Date';   ?></option>
		
											<?php
											
											$SQL = "SELECT DISTINCT date FROM txn_table ORDER BY date DESC  ";
											
											$result = mysqli_query($db_handle, $SQL);
											
											$i =1;

											
											while ( $db_found = mysqli_fetch_assoc($result) ) {
											
												echo'<option value="'. $db_found['date'].'">'. $db_found['date'].'</option>'; 
																									  }
		
											?>
											
											</select> 
					
										</td>
											
												<td>  <select class="custom-select"  style="width:"  id="inputGroupSelect03" name="lower_date">
										
											<option selected><?php  echo 'Lower Date';   ?></option>
		
											<?php
											
											$SQL = "SELECT DISTINCT date FROM txn_table ORDER BY date DESC  ";
											
											$result = mysqli_query($db_handle, $SQL);
											
											$i =1;

											
											while ( $db_found = mysqli_fetch_assoc($result) ) {
											
												echo'<option value="'. $db_found['date'].'">'. $db_found['date'].'</option>'; 
																									  }
		
											?>
											
											</select> 
					
										</td>
					
									<td>
					
				
					 
										<input type="submit" value="GENERATE" class="btn-dark" style= "width: 100%" name = "period" onClick="spinner()" >
										
									</td>
						 
												
						 												
						 
							
								</tr>
			
								</table>
			 
							
								
							</form>
							
						</div>	
						
					</div>
										
					
					
					<div class="col-md-4" style="padding-top: 8px" id="bulk_ac">
 
						<form METHOD ="POST" ACTION = "report_wizard.php" style="width: 100%">
						
							<table width="100%">
				
								<tr>
				
					
					
					
									<td> 
										<select class="custom-select"  style="width:"  id="inputGroupSelect03" name = "man">
										
											<option selected >Select Year</option>
		
											<?php
											
											$SQL_year = "SELECT  DISTINCT year FROM txn_table ORDER BY product_id ASC ";
											
											$result = mysqli_query($db_handle, $SQL_year);
											
											$i =1;

											
											while ( $db_found = mysqli_fetch_assoc($result) ) {
											
												echo'<option value="'. $db_found['year'].'">'. $db_found['year'].'</option>'; 
																									  }
		
											?>
											
									  </select> 
					
								  </td>
					
									<td>  <select class="custom-select"  style="width:"  id="inputGroupSelect03" name="month">
										
											<option selected>Select Month</option>
		
											<?php
											
											$SQL = "SELECT DISTINCT month FROM txn_table ORDER BY product_id DESC ";
											
											$result = mysqli_query($db_handle, $SQL);
											
											$i =1;

											
											while ( $db_found = mysqli_fetch_assoc($result) ) {
											
												echo'<option value="'. $db_found['month'].'">'. $db_found['month'].'</option>'; 
																									  }
		
											?>
											
											</select> 
					
								  </td>
						 
												
						 												
						 
							
								</tr>
			
							</table>
			 
							<input type="submit" value="GENERATE" class="btn-info" style= "width: 100%" name = "crude" onClick="spinner()" >
											
							
						</form>
						
					</div>
					
										
								
				
					<div class="col-md-4" style="padding-top: 8px; background-color:" id="crude_ac"  >
					
 
						<form METHOD ="POST" ACTION = "report_wizard.php" style="width: 100%">
						
							<table width="100%">
				
								<tr>
				
					
					
					<td>  <select class="custom-select"  style="width:"  id="inputGroupSelect03" name="yea">
										
											<option selected>Select Business Year</option>
		
											<?php
											
											$SQL = "SELECT DISTINCT year FROM txn_table ORDER BY product_id DESC ";
											
											$result = mysqli_query($db_handle, $SQL);
											
											$i =1;

											
											while ( $db_found = mysqli_fetch_assoc($result) ) {
											
												echo'<option value="'. $db_found['year'].'">'. $db_found['year'].'</option>'; 
																									  }
		
											?>
											
											</select> 
					
								  </td>
					
									<td>
					
				
					 
										<input type="submit" value="GENERATE" class="btn-dark" style= "width: 100%" name = "year" onClick="spinner()" >
										
									</td>
						 
												
						 												
						 
							
								</tr>
			
							</table>
			
											
							
						</form>
				
					</div>


				
				</div>
		
		
		</div>
		
		</div>
		
		<!--open-->
		
			<?php
		

		
			  $date = date("Y-m-d");
	
		
			$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where date = '$date'";
	  
			$sum = mysqli_query($db_handle, $SQL_sum);
	  
			$db_found_sum = mysqli_fetch_assoc($sum) ;
	
			
			
			
		
		
	  		?>
		
	
			<?PHP
		
		//	echo '<div class="jumbotron-fluid" style="background-color: " id="view_ac">';
		
				?>
			
		
				 <div class="jumbotron-fluid" style="background-color:" id="view_ac">
					 
		
			  
			<?php
 			
 		
 $year = @ $_GET['year'];
 $month =  @ $_GET['month'];
 $lower_date =  @ $_GET['lowerdate'];
$upper_date =@ $_GET['upperdate'];
 $product_cutomer_name =@ $_GET['txnname'];

 $key =@  $_GET['key'];


	
//this script is for per day report search only
	  
	  				
					
	  			//	else if(isset($_POST['period']))
					 
					 //
					 
					  if($key == "01")
					// for days people
					{
						echo "it works perfectly";
						// income Account
						{
							
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#C3C2F9 ">';
							
						
					
						 			
		   // $product = $_POST['product'];
							
							
							 $product =$upper_date;
			$lower_date = $lower_date;					
										
			
							
			//$SQL_count = "SELECT date  FROM txn_table where date  BETWEEN '$lower_date' AND '$product' and type = '' ORDER BY name ASC   ";				
							
			
							$SQL = "SELECT  DISTINCT date FROM txn_table where date  BETWEEN '$lower_date' AND '$product' and type = '' and product_name = '$product_cutomer_name' ORDER BY product_id ASC  ";
											

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

							echo  $txn_nbr = mysqli_num_rows($result).' working days  ';

							
											
			
										
			
										
										
										
										
										
									
								
						?>
		
		
		<div class="row" style="color:#260B4D; text-align: center; ">
						<strong> <span style=" text-align: center; color:#2C12D0;">Customers who did <?php echo $product_cutomer_name ?> from <?php echo $product ?> To <?php echo $lower_date ?> </span></strong><p></p>
						
		</div>
		
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#C3C2F9"> <br>INCOME HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#C3C2F9;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
									echo '<th scope="col">s/n</th>';
	
							
							echo '<th scope="col">IDN</th>';
										//echo '<th scope="col">Txn id </th>';
										
										
								echo '<th scope="col">Names</th>';
							
							
							echo '<th scope="col">Payment Method</th>';
      
										 '<th scope="col">Description</th>';
										
									
		 
		
	
		   
										echo '<th scope="col">Sale</th>';
							echo '<th scope="col">Balance</th>';
										echo '<th scope="col">Gross Profit</th>';
										echo '<th scope="col">Qty/Vol</th>';
		
										
		 
										echo '<th scope="col">Time</th>';
							echo '<th scope="col">Date</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment, balance FROM txn_table   where date  BETWEEN '$lower_date' AND '$product' and type = '' and product_name = '$product_cutomer_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; color:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										//echo '<td>'.$db_found['product_id'].'</td>';
										
										echo '<td>'.$db_found['user_id'].'</td>';
										
										echo '<td>'.$db_found['customers_name'].'</td>';
										echo '<td>'.$db_found['payment'].'</td>';
		 
										 '<td>'.$db_found['product_name'].'</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['date'].'</td>';
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									
										<td><a href="transaction.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Edit" 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 '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			
				
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
				
						
						echo '</div>';
							
						}
						
						
				
						//expenses Account
						
						
				
		
					}
					 
					 
					  else if($key == "02")
					// for days product
					{
						echo "it works perfectly";
						// income Account
						{
							
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#C3C2F9 ">';
							
						
					
						 			
		   // $product = $_POST['product'];
							
							
							 $product =$upper_date;
			$lower_date = $lower_date;					
										
			
							
			//$SQL_count = "SELECT date  FROM txn_table where date  BETWEEN '$lower_date' AND '$product' and type = '' ORDER BY name ASC   ";				
							
			
							$SQL = "SELECT  DISTINCT date FROM txn_table where date  BETWEEN '$lower_date' AND '$product' and type = '' and customers_name = '$product_cutomer_name' ORDER BY product_id ASC  ";
											

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

							echo  $txn_nbr = mysqli_num_rows($result).'working days';

							
											
			
										
			
										
										
										
										
										
									
								
						?>
		
		
		<div class="row" style="color:#260B4D; text-align: center; ">
						<strong> <span style=" text-align: center; color:#2C12D0;">Product or Services Purchased by <?php echo $product_cutomer_name ?> from <?php echo $product ?> To <?php echo $lower_date ?> </span></strong><p></p>
						
		</div>
		
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#C3C2F9"> <br>INCOME HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#C3C2F9;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
									echo '<th scope="col">s/n</th>';
	
							
							echo '<th scope="col">IDN</th>';
										//echo '<th scope="col">Txn id </th>';
										
										
								echo '<th scope="col">Name</th>';
							
							
							echo '<th scope="col">Payment Method</th>';
      
										 '<th scope="col">Description</th>';
										
									
		 
		
	
		   
										echo '<th scope="col">Sale</th>';
							echo '<th scope="col">Balance</th>';
										echo '<th scope="col">Gross Profit</th>';
										echo '<th scope="col">Qty/Vol</th>';
		
										
		 
										echo '<th scope="col">Time</th>';
							echo '<th scope="col">Date</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment, balance FROM txn_table   where date  BETWEEN '$lower_date' AND '$product' and type = '' and customers_name = '$product_cutomer_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; color:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										//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>';
		 
										 '<td>'.$db_found['product_name'].'</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['date'].'</td>';
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									
										<td><a href="transaction.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Edit" 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 '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			
				
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
				
						
						echo '</div>';
							
						}
						
						
				
						//expenses Account
						
						
				
		
					}
									
					 
					 
					   else if($key == "03")
					// for month people
					{
						echo "it works perfectly";
						// income Account
						{
							
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#C3C2F9 ">';
							
						
					
			
							$SQL = "SELECT  DISTINCT date FROM txn_table  where year = '$year' && month ='$month' and type = '' and product_name = '$product_cutomer_name'  ORDER BY product_id ASC  ";
											
										
	  
							$result = mysqli_query($db_handle, $SQL);

							echo  $txn_nbr = mysqli_num_rows($result).'working days';

							
											
			
										
			
										
										
										
										
										
									
								
						?>
		
		
		<div class="row" style="color:#260B4D; text-align: center; ">
						<strong> <span style=" text-align: center; color:#2C12D0;"> Customers who did <?php echo $product_cutomer_name ?> in the month of <?php echo $month ?>, <?php echo $year ?> </span></strong><p></p>
						
		</div>
		
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#C3C2F9"> <br>INCOME HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#C3C2F9;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
									echo '<th scope="col">s/n</th>';
	
							
							echo '<th scope="col">IDN</th>';
										//echo '<th scope="col">Txn id </th>';
										
										
								echo '<th scope="col">Name</th>';
							
							
							echo '<th scope="col">Payment Method</th>';
      
										 '<th scope="col">Description</th>';
										
									
		 
		
	
		   
										echo '<th scope="col">Sale</th>';
							echo '<th scope="col">Balance</th>';
										echo '<th scope="col">Gross Profit</th>';
										echo '<th scope="col">Qty/Vol</th>';
		
										
		 
										echo '<th scope="col">Time</th>';
							echo '<th scope="col">Date</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment,balance FROM txn_table   where year = '$year' && month ='$month' and type = '' and product_name = '$product_cutomer_name' ORDER BY product_id DESC";
							
							
							

									
									//$SQL = "SELECT  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment, balance FROM txn_table   where date  BETWEEN '$lower_date' AND '$product' and type = '' and customers_name = '$product_cutomer_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; color:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										//echo '<td>'.$db_found['product_id'].'</td>';
										
										echo '<td>'.$db_found['user_id'].'</td>';
										
										echo '<td>'.$db_found['customers_name'].'</td>';
										echo '<td>'.$db_found['payment'].'</td>';
		 
										 '<td>'.$db_found['product_name'].'</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['date'].'</td>';
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									
										<td><a href="transaction.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Edit" 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 '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			
				
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
				
						
						echo '</div>';
							
						}
						
						
				
						//expenses Account
						
						
				
		
					}
					 
					 
					  else if($key == "04")
					// for month product
					{
						echo "it works perfectly";
						// income Account
						{
							
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#C3C2F9 ">';
							
						
					
			
							$SQL = "SELECT  DISTINCT date FROM txn_table  where year = '$year' && month ='$month' and type = '' and customers_name = '$product_cutomer_name'  ORDER BY product_id ASC  ";
											
										
	  
							$result = mysqli_query($db_handle, $SQL);

							echo  $txn_nbr = mysqli_num_rows($result).'working days';

							
											
			
										
			
										
										
										
										
										
									
								
						?>
		
		
		<div class="row" style="color:#260B4D; text-align: center; ">
						<strong> <span style=" text-align: center; color:#2C12D0;"> Product or Services done by <?php echo $product_cutomer_name ?> in the month of <?php echo $month ?>, <?php echo $year ?> </span></strong><p></p>
						
		</div>
		
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#C3C2F9"> <br>INCOME HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#C3C2F9;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
									echo '<th scope="col">s/n</th>';
	
							
							echo '<th scope="col">IDN</th>';
										//echo '<th scope="col">Txn id </th>';
										
										
								echo '<th scope="col">Name</th>';
							
							
							echo '<th scope="col">Payment Method</th>';
      
										 '<th scope="col">Description</th>';
										
									
		 
		
	
		   
										echo '<th scope="col">Sale</th>';
							echo '<th scope="col">Balance</th>';
										echo '<th scope="col">Gross Profit</th>';
										echo '<th scope="col">Qty/Vol</th>';
		
										
		 
										echo '<th scope="col">Time</th>';
							echo '<th scope="col">Date</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment,balance FROM txn_table   where year = '$year' && month ='$month' and type = '' and customers_name = '$product_cutomer_name' ORDER BY product_id DESC";
							
							
							

									
									//$SQL = "SELECT  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment, balance FROM txn_table   where date  BETWEEN '$lower_date' AND '$product' and type = '' and customers_name = '$product_cutomer_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; color:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										//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>';
		 
										 '<td>'.$db_found['product_name'].'</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['date'].'</td>';
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									
										<td><a href="transaction.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Edit" 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 '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			
				
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
				
						
						echo '</div>';
							
						}
						
						
				
						//expenses Account
						
						
				
		
					}
					 
					 
					 
					   else if($key == "05")
					// for year product
					{
						//echo "it works perfectly";
						// income Account
						{
							
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#C3C2F9 ">';
							
						$product = $year;
						
					
			
						//	$SQL = "SELECT  DISTINCT date FROM txn_table  where year = '$year' && month ='$month' and type = '' and customers_name = '$product_cutomer_name'  ORDER BY product_id ASC  ";
											
										
							$SQL = "SELECT  DISTINCT date FROM txn_table where  year = '$product' and type = '' and product_name = '$product_cutomer_name' ORDER BY product_id ASC  ";
							
	  
							$result = mysqli_query($db_handle, $SQL);

							echo  $txn_nbr = mysqli_num_rows($result).'working days';

							
											
			
										
			
										
										
										
										
										
									
								
						?>
		
		
		<div class="row" style="color:#260B4D; text-align: center; ">
						<strong> <span style=" text-align: center; color:#2C12D0;"> Customers who did  <?php echo $product_cutomer_name ?> in  <?php echo $year ?> </span></strong><p></p>
						
		</div>
		
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#C3C2F9"> <br>INCOME HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#C3C2F9;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
									echo '<th scope="col">s/n</th>';
	
							
							echo '<th scope="col">IDN</th>';
										//echo '<th scope="col">Txn id </th>';
										
										
								echo '<th scope="col">Name</th>';
							
							
							echo '<th scope="col">Payment Method</th>';
      
										 '<th scope="col">Description</th>';
										
									
		 
		
	
		   
										echo '<th scope="col">Sale</th>';
							echo '<th scope="col">Balance</th>';
										echo '<th scope="col">Gross Profit</th>';
										echo '<th scope="col">Qty/Vol</th>';
		
										
		 
										echo '<th scope="col">Time</th>';
							echo '<th scope="col">Date</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment,balance FROM txn_table  where year = '$product' and type = '' and product_name = '$product_cutomer_name' ORDER BY product_id DESC";
							
								
									//$SQL = "SELECT  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment,balance FROM txn_table   where year = '$year' && month ='$month' and type = '' and customers_name = '$product_cutomer_name' ORDER BY product_id DESC";
							
							
							

									
									//$SQL = "SELECT  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment, balance FROM txn_table   where date  BETWEEN '$lower_date' AND '$product' and type = '' and customers_name = '$product_cutomer_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; color:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										//echo '<td>'.$db_found['product_id'].'</td>';
										
										echo '<td>'.$db_found['user_id'].'</td>';
										
										echo '<td>'.$db_found['customers_name'].'</td>';
										echo '<td>'.$db_found['payment'].'</td>';
		 
										 '<td>'.$db_found['product_name'].'</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['date'].'</td>';
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									
										<td><a href="transaction.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Edit" 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 '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			
				
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
				
						
						echo '</div>';
							
						}
						
						
				
						//expenses Account
						
						
				
		
					}
					 
					 
					  else if($key == "06")
					// for year people
					{
						//echo "it works perfectly";
						// income Account
						{
							
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#C3C2F9 ">';
							
						$product = $year;
						
					
			
						//	$SQL = "SELECT  DISTINCT date FROM txn_table  where year = '$year' && month ='$month' and type = '' and customers_name = '$product_cutomer_name'  ORDER BY product_id ASC  ";
											
										
							$SQL = "SELECT  DISTINCT date FROM txn_table where  year = '$product' and type = '' and customers_name = '$product_cutomer_name' ORDER BY product_id ASC  ";
							
	  
							$result = mysqli_query($db_handle, $SQL);

							echo  $txn_nbr = mysqli_num_rows($result).'working days';

							
											
			
										
			
										
										
										
										
										
									
								
						?>
		
		
		<div class="row" style="color:#260B4D; text-align: center; ">
						<strong> <span style=" text-align: center; color:#2C12D0;"> Product or Services done by  <?php echo $product_cutomer_name ?> in  <?php echo $year ?> </span></strong><p></p>
						
		</div>
		
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#C3C2F9"> <br>INCOME HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#C3C2F9;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
									echo '<th scope="col">s/n</th>';
	
							
							echo '<th scope="col">IDN</th>';
										//echo '<th scope="col">Txn id </th>';
										
										
								echo '<th scope="col">Name</th>';
							
							
							echo '<th scope="col">Payment Method</th>';
      
										 '<th scope="col">Description</th>';
										
									
		 
		
	
		   
										echo '<th scope="col">Sale</th>';
							echo '<th scope="col">Balance</th>';
										echo '<th scope="col">Gross Profit</th>';
										echo '<th scope="col">Qty/Vol</th>';
		
										
		 
										echo '<th scope="col">Time</th>';
							echo '<th scope="col">Date</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment,balance FROM txn_table  where year = '$product' and type = '' and customers_name = '$product_cutomer_name' ORDER BY product_id DESC";
							
								
									//$SQL = "SELECT  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment,balance FROM txn_table   where year = '$year' && month ='$month' and type = '' and customers_name = '$product_cutomer_name' ORDER BY product_id DESC";
							
							
							

									
									//$SQL = "SELECT  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment, balance FROM txn_table   where date  BETWEEN '$lower_date' AND '$product' and type = '' and customers_name = '$product_cutomer_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; color:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										//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>';
		 
										 '<td>'.$db_found['product_name'].'</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['date'].'</td>';
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									
										<td><a href="transaction.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Edit" 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 '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			
				
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
				
						
						echo '</div>';
							
						}
						
						
				
						//expenses Account
						
						
				
		
					}
					 
				
					else if(isset($_POST['year']))
					{
						
						// income Account
						{
							
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#C3C2F9 ">';
							
						
					
						 			
		   // $product = $_POST['product'];
							
							 $product = $_POST['yea'];
							 				
										
			$Ist_date = '2022-07-25';
			$second_date = '2022-07-28';
							
			//$SQL_count = "SELECT date  FROM txn_table where date  BETWEEN '$lower_date' AND '$product' and type = '' ORDER BY name ASC   ";				
							
			
							$SQL = "SELECT  DISTINCT date FROM txn_table where  year = '$product' and type = '' ORDER BY product_id ASC  ";
											

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

							echo  'Number of days  '.$txn_nbr = mysqli_num_rows($result);

							
											
			
										
			$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c),SUM(balance) FROM txn_table where year = '$product' and type = ''";													
	  
			$sum = mysqli_query($db_handle, $SQL_sum);
	  
			$db_found_sum = mysqli_fetch_assoc($sum) ;
							
	
										
										//this set of codes are used to manipulate the daily account
			$SQL_break_even = "SELECT SUM(amount) 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);
										
			$daily_bep = round($db_found_even['SUM(amount)'])*12;  
			
			
			$gross_profit = $db_found_sum['SUM(unit_c)'];
			
			$net_profit = $gross_profit - $daily_bep;
			//$adjusted_netprf = $ne;
							
			
			$remark = "fail";
			
	/*		if($net_profit >0){
				
				$adjusted_netprf= $net_profit;
			}
			
			*/							
							if($net_profit >0){
				
				$remark= "congratulations";
			}
										
										
										
										
										
									
								
						?>
		
		
		<div class="row" style="color:#260B4D; text-align: center; ">
						<strong> <span style=" text-align: center; color:#2C12D0;">INCOME ACCOUNT for <?php echo $product ?>  </span></strong><p></p>
						
		</div>
						
		<div class="row" style="margin-top: 1px; background-color:#C3C2F9">
							
								<div class="row" style="margin: auto;" >
								
								<div class = "col-md-6 " style="margin: auto; background-color: #D9D3D3">
									<b><table width="100%" style="color:">
							
  <tbody>
	  
   
    <tr>
      <td>Total Sales  </td>
      <td>	<span class = "">   <?php     echo "  ".$db_found_sum['SUM(amount)']."  ";   ?>    </span></td>
    </tr>
	  
	    <tr>
      <td>Credit Sales  </td>
      <td>	<span class = "">   <?php     echo "  ".$db_found_sum['SUM(balance)']."  ";   ?>    </span></td>
    </tr>
   
  </tbody>
</table> </b>	
								</div>
								</div>
	
								<p></p>	
								
								<div class = "col-md-6 " style="background-color:;">
						
					
										<b>Money Recieved from Product:</b> 

							
						                <div class="jumbotron-fluid scroll" style="font-size:12; background-color: ">
				  	
					
  
							
								
					
					
					
					
		
										
										
											
						<?php
										
										
	
										
									

		
				$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where year = '$product' and type = '' ";
	  
			$sum = mysqli_query($db_handle, $SQL_sum);
	  
			$db_found_sum = mysqli_fetch_assoc($sum) ;
	
			
		
			
						
																
										echo 	'<table class="table  table-hover" style="font-size:12; width:100%  " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Description </th>';
										
									 
										echo 	'<th scope="col">Sales</th>';
      
									
										echo 	'<th scope="col">Gross Profit</th>';
										
										echo 	'<th scope="col">Qty/Vol</th>';
		 


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

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

									$i =1;
	  
//echo "<p></p>";
//echo "<b>PRODUCT/SERVICE BASED RETURNS</b>";
									while ( $db_found = mysqli_fetch_assoc($result) ) {
	   
	
										echo'<tr style="text-align: center;background-color:; color:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['product_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</td>';
									echo '<td>'.$db_found['SUM(unit_c)'].'</td>';
										echo '<td>'.$db_found['SUM(s_qty)'].'</td>';
										
										
	
	//echo $db_found_sum['SUM(amount)']; 
	 ?>
										
										
					<td><a href="detail_report.php?txnname=<?php echo $db_found["product_name"]?>&year=<?php echo $product?>"><button onClick="spinner()">view</button>  </a></td>
										
											<?php
											
  
   
   
										echo '</tr>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
								//===========================================================================
									
	
	
	
	
	
  
	
	
					//echo	'</div>';

					?>
		
		</div>
						</div>
				
								
								<div class="col-md-6">
<B>Money Recieved from Customers:</B>
				<div class=" scroll" >
					
					
			<?php
									
										
					echo 	'<table class="table  table-hover" style="font-size:12; width:100%  " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Customers </th>';
										
									 
										echo 	'<th scope="col">Sales</th>';
      
									
										echo	'<th scope="col">Gross Profit</th>';
										
										echo 	'<th scope="col">Qty/Vol</th>';
		 

										
										
										
										
										
	  
									$SQL = "SELECT  customers_name,product_id,SUM(amount),SUM(unit_c),SUM(s_qty) FROM txn_table  where year = '$product' and type = '' GROUP BY customers_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:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['customers_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</td>';
										echo '<td>'.$db_found['SUM(unit_c)'].'</td>';
										echo '<td>'.$db_found['SUM(s_qty)'].'</td>';
										
										
	
	//echo $db_found_sum['SUM(amount)']; 
	 
										 ?>
										
										
					<td><a href="detail_report.php?txnname=<?php echo $db_found["customers_name"]?>&year=<?php echo $product?>"><button onClick="spinner()">view</button>  </a></td>
										
											<?php
  
   
   
										echo '</tr>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
							//===========================================================================
							// end of returns based on clients		
	
		?>
					
				</div>
				</div>
					
				
</div>
			
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#C3C2F9"> <br>INCOME HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#C3C2F9;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
										echo '<th scope="col">s/n</th>';
	
										echo '<th scope="col">Txn id </th>';
										
										//echo '<th scope="col">IDN</th>';
							echo '<th scope="col">Payment</th>';
      
										echo '<th scope="col">Job Description</th>';
										
										echo '<th scope="col">Customers</th>';
		 
		
	
		   
										echo '<th scope="col">Sales</th>';
										echo '<th scope="col">Balance</th>';
							
							echo '<th scope="col">Gross Profit</th>';
										echo '<th scope="col">Qty/vol</th>';
		
										
		 
										echo '<th scope="col">Time</th>';
							echo '<th scope="col">Date</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment,balance FROM txn_table  where year = '$product' 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:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										?>
										
						
										<?php
										
										
										echo '<td>'.$db_found['product_id'].'</td>';
										
										//echo '<td>'.$db_found['user_id'].'</td>';
										echo '<td>'.$db_found['payment'].'</td>';
		 
										echo '<td>'.$db_found['product_name'].'</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['date'].'</td>';
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									
													<td><a href="modify_record.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Edit" 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 '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			
				
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
				
						
						echo '</div>';
							
						}
						
						
				
						//expenses Account
						
						
				
						{
						
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#E0E71E; ">';
						
						
		
			
										
			$SQL_exp = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where year = '$product' and type = 'expense'";		
			
				//$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where date  BETWEEN '$lower_date' AND '$product'";							
	  
			$exp = mysqli_query($db_handle, $SQL_exp);
	  
			$db_found_exp = mysqli_fetch_assoc($exp) ;
	
										
										//this set of codes are used to manipulate the daily account
							/*
			$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);
										
			$daily_bep = $db_found_even['SUM(amount/30)'];  
			
			
			$gross_profit = $db_found_sum['SUM(unit_c)'];
			
			$net_profit = $gross_profit - $daily_bep;
			$adjusted_netprf = "";
							
			
			$remark = "fail";
			
			if($net_profit >0){
				
				$adjusted_netprf= $net_profit;
			}
			
										
							if($net_profit >0){
				
				$remark= "congratulations";
			}
										
										
										
										
										
							*/		
								
						?>
		
		
<div class="row" style="color:#260B4D; text-align: center;  ">
						<strong> <span style="color:#0E0CC1; text-align: center">EXPENSES ACCOUNT for <?php echo $product ?> </span></strong><p></p>
						
</div>
						
<div class="row" style="margin-top: ; background-color:#E0E71E; ">
							
								<div class="row" style="margin: auto;" >
								
								<div class = "col-md-6 " style="margin: auto; background-color:#D9D3D3">
									<b><table width="100%" style="color:">
							
  <tbody>
	  
   
    <tr style="">
      <td>Total Expenses </td>
      <td>	<span class = "">   <?php     echo "  ".$db_found_exp['SUM(amount)']."  ";   ?>    </span></td>
    </tr>
  
	  
  </tbody>
</table> </b>	
								</div>
								</div>
	
								<p></p>	
								
								<div class = "col-md-6 " style="background-color:;">
						
					
										<b>Money spent on:</b> 

							
						                <div class="jumbotron-fluid scroll" style="font-size:12; background-color: ">
				  	
					
  
							
								
					
					
					
					
		
										
										
											
						<?php
										
										
	
										
									

		
			$SQL_exp = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where year = '$product' and type = 'expense' ";
	  
			$exp = mysqli_query($db_handle, $SQL_exp);
	  
			$db_found_exp = mysqli_fetch_assoc($exp) ;
	
			
		
			
						
																
										echo 	'<table class="table  table-hover" style="font-size:12; width:100%; " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Description </th>';
										
									 
										echo 	'<th scope="col">Amount</th>';
      
									
										//echo 	'<th scope="col">Gross Profit</th>';
										
										//echo 	'<th scope="col">Qty/Vol</th>';
		 

										
										
										
										
										
	  
									$SQL = "SELECT  product_name,product_id,SUM(amount),SUM(unit_c),SUM(s_qty) FROM txn_table  where year = '$product' and type = 'expense' GROUP BY product_name  ORDER BY product_id DESC";
	  
									$result = mysqli_query($db_handle, $SQL);

									$i =1;
	  
//echo "<p></p>";
//echo "<b>PRODUCT/SERVICE BASED RETURNS</b>";
									while ( $db_found = mysqli_fetch_assoc($result) ) {
	   
	
										echo'<tr style="text-align: center;background-color:; color:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['product_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</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>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
								//===========================================================================
									
	
	
	
	
	
  
	
	
					//echo	'</div>';

					?>
		
		</div>
						</div>
				
								
								<div class="col-md-6">
<!--<B>Client Base Expenses</B>-->
									
			<!--	<div class=" scroll" >
					
					
			<?php
									
										
					echo 	'<table class="table  table-hover" style="font-size:12; width:100%  " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Name of Client </th>';
										
									 
										echo 	'<th scope="col">Total Sales</th>';
      
									
										//echo 	'<th scope="col">Gross Profit</th>';
										
										//echo 	'<th scope="col">Qty/Vol</th>';
		 

										
										
										
										
										
	  
									$SQL = "SELECT  customers_name,product_id,SUM(amount),SUM(unit_c),SUM(s_qty) FROM txn_table  where year = '$product' and type = 'expense' GROUP BY customers_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:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['customers_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</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>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
							//===========================================================================
							// end of returns based on clients		
	
		?>
					
				</div>-->
									
				</div>
					
				
</div>
			
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#E0E71E;"> <br>EXPENDITURE HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#E0E71E;;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
										echo '<th scope="col">s/n</th>';
	
										echo '<th scope="col">Invoice No </th>';
										
										echo '<th scope="col">IDN</th>';
      
										echo '<th scope="col">Description</th>';
										
										echo '<th scope="col">Customers</th>';
		 
		
	
		   
										echo '<th scope="col">Amount</th>';
										//echo '<th scope="col">Gross Profit</th>';
										//echo '<th scope="col">QTY/VOL</th>';
		
										
		 
										echo '<th scope="col">TIME</th>';
							echo '<th scope="col">DATE</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name FROM txn_table   where date= '$product' and type ='expense'  ORDER BY product_id DESC";

	  $SQL = "SELECT  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date FROM txn_table  where year = '$product' 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:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										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['customers_name'].'</td>';
		
										echo '<td>'.$db_found['amount'].'</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['date'].'</td>';
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									<?php
	
										echo '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			</div>
	
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
						
						
						
						
						
						
						
						
						}
							
						
						//profit and loss account
						
						{
						
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:; ">';
						
						
		
			
										
		//	$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where date  BETWEEN '$lower_date' AND '$product' and type = 'expense'";		
			
				//$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where date  BETWEEN '$lower_date' AND '$product'";							
	  
			$sum = mysqli_query($db_handle, $SQL_sum);
	  
			$db_found_sum = mysqli_fetch_assoc($sum) ;
	
		/*								
										//this set of codes are used to manipulate the daily account
			$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);
										
			$daily_bep = $db_found_even['SUM(amount/30)'];  
			
			
			$gross_profit = $db_found_sum['SUM(unit_c)'];
			
			$net_profit = $gross_profit - $daily_bep;
			$adjusted_netprf = "";
							
			
			$remark = "fail";
			
			if($net_profit >0){
				
				$adjusted_netprf= $net_profit;
			}
			
										
							if($net_profit >0){
				
				$remark= "congratulations";
			}
										
										
										*/
										
										
									
								
						?>
		
		
<div class="row" style="color:#260B4D; text-align: center;  ">
						<strong> <span style="color:black; text-align: center">Profit & loss ACCOUNT for <?php echo $product ?> </span></strong><p></p>
						
</div>
						
<div class="row" style="margin-top: ; background-color:; ">
							
								<div class="row" style="margin: auto;" >
								
								<div class = "col-md-6 " style="margin: auto; background-color:#D9D3D3">
									<b><table width="100%" style="color:">
							
  <tbody>
	  
  
	  
  </tbody>
</table> </b>	
								</div>
								</div>
	
								<p></p>	
								
								<div class = "col-md-6 " style="background-color:;">
						
					
										

															
							
						                <div class="jumbotron-fluid scroll" style="font-size:12; background-color: ">
				  	
					
  <b><table width="100%" style="color:">
							
  <tbody>
	  
   
    <tr>
      <td>Total Sales </td>
      <td>	<span class = "">   <?php     echo "   ".$db_found_sum['SUM(amount)']."  ";   ?>    </span></td>
    </tr>
	  
	  <?php $cos = $db_found_sum['SUM(amount)'] - $gross_profit;  ?>
	  <tr>
      <td>Cost of Goods sold</td>
      <td> <span class= ""> (<?php     echo $cos;   ?>)  </span> </td>
    </tr>
	  <tr>
      <td>Gross Profit</td>
      <td> <span class= "">   <?php     echo $gross_profit;   ?>   </span> </td>
    </tr>

	  
    <tr>
      <td>Total Expenses</td>
      <td> <span class= ""> (<?php     echo $db_found_exp['SUM(amount)'];   ?>)   </span> </td>
    </tr>
  
	  
	    <tr>
			
			<?php $net = $db_found_sum['SUM(amount)'] - $cos - $db_found_exp['SUM(amount)']; 
							
							$pab = $net - $daily_bep;
		    if($pab <0)
			{$pab = "";}
		
			
							if($net>0){
							$summary = "congratulations";	
								$loss ="";
								
							}
							else{
								$summary = "loss";
								$color = "red";
								$loss = $net;
								$net = "";
								//$loss = $net;
							}
			
			?>
      <td>Net Profit</td>
      <td> <span style= "background-color: <?php echo $color?>">   <?php    echo $net  ?>    </span> </td>
    </tr>
	  
	  
	  <tr>
      <td>Account Summery</td>
      <td> <span class= "">   <?php    echo  $summary?>   <span style="background-color: red"> <?php echo $loss;  ?></span> </span> </td>
    </tr>
	  
	   <tr>
      <td>Break Even Point</td>
      <td> <span class= ""> (<?php     echo $daily_bep;  ?>)    </span> </td>
    </tr>
	  
	    <tr>
      <td>Profit After B.E.P</td>
      <td> <span class= "">   <?php echo $pab  ?>    </span> </td>
    </tr>
	 
  </tbody>
</table> </b>	
									
										
										
											
					
		
		</div>
						</div>
				
								
								<div class="col-md-6">
<!--<B>Client Base Expenses</B>-->
									
			<!--	<div class=" scroll" >
					
					
			<?php
									
										
					echo 	'<table class="table  table-hover" style="font-size:12; width:100%  " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Name of Client </th>';
										
									 
										echo 	'<th scope="col">Total Sales</th>';
      
									
										//echo 	'<th scope="col">Gross Profit</th>';
										
										//echo 	'<th scope="col">Qty/Vol</th>';
		 

										
										
										
										
										
	  
									$SQL = "SELECT  customers_name,product_id,SUM(amount),SUM(unit_c),SUM(s_qty) FROM txn_table   where date= '$product' and type = 'expense' GROUP BY customers_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:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['customers_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</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>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
							//===========================================================================
							// end of returns based on clients		
	
		?>
					
				</div>-->
									
				</div>
					
				
</div>
			
			
			<!--this is the transaction table of the code-->
	
		
						
			</div>
	
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
						
						
						
						
						
						
						
						
						}
		
					}
					
					
					
					else if(isset($_POST['crude']))
				
					{
						
						// income Account
						{
							
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#C3C2F9 ">';
							
						
					
						 			
		   // $product = $_POST['product'];
							
							$year = $_POST['man'];
							$month = $_POST['month'];
							
							
							
							// $product = $year;
							// $lower_date = $month;		
							
										
			$Ist_date = '2022-07-25';
			$second_date = '2022-07-28';
							
			//$SQL_count = "SELECT date  FROM txn_table where date  BETWEEN '$lower_date' AND '$product' and type = '' ORDER BY name ASC   ";				
							
			
							$SQL = "SELECT  DISTINCT date FROM txn_table  where year = '$year' && month ='$month' and type = '' ORDER BY product_id ASC  ";
											
						//	$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where year = '$year' && month ='$month' and type = ''  ";					
	  
							$result = mysqli_query($db_handle, $SQL);

							echo  'work  days  '.$txn_nbr = mysqli_num_rows($result);

							
											
			
										
			$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c), SUM(balance) FROM txn_table where year = '$year' && month ='$month' and type = ''";													
	  
			$sum = mysqli_query($db_handle, $SQL_sum);
	  
			$db_found_sum = mysqli_fetch_assoc($sum) ;
							
	
										
										//this set of codes are used to manipulate the daily account
			$SQL_break_even = "SELECT SUM(amount) 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);
										
			//$daily_bep = round($db_found_even['SUM(amount/30)'])*$txn_nbr;  
							$daily_bep = round($db_found_even['SUM(amount)']);  
			
			
			$gross_profit = $db_found_sum['SUM(unit_c)'];
			
			$net_profit = $gross_profit - $daily_bep;
			//$adjusted_netprf = $ne;
							
			
			$remark = "fail";
			
	/*		if($net_profit >0){
				
				$adjusted_netprf= $net_profit;
			}
			
			*/							
							if($net_profit >0){
				
				$remark= "congratulations";
			}
										
										
										
										
										
									
								
						?>
		
		
		<div class="row" style="color:#260B4D; text-align: center; ">
						<strong> <span style=" text-align: center; color:#2C12D0;">INCOME ACCOUNT for  <?php echo $month ?>  <?php echo $year ?> </span></strong><p></p>
						
		</div>
						
		<div class="row" style="margin-top: 1px; background-color:#C3C2F9">
							
								<div class="row" style="margin: auto;" >
								
								<div class = "col-md-6 " style="margin: auto; background-color: #D9D3D3">
									<b><table width="100%" style="color:">
							
  <tbody>
	  
   
    <tr>
      <td>Total Sales </td>
      <td>	<span class = "">   <?php     echo "  ".$db_found_sum['SUM(amount)']."  ";   ?>    </span></td>
    </tr>
	  
	      <tr>
      <td>Credit Sales  </td>
      <td>	<span class = "">   <?php     echo "  ".$db_found_sum['SUM(balance)']."  ";   ?>    </span></td>
    </tr>
    <!--<tr>
      <td>Gross Profit</td>
      <td> <span class= "">   <?php     echo $gross_profit;   ?>   </span> </td>
    </tr>
    <tr>
      <td>Break Even Point</td>
      <td> <span class= "">   <?php     echo $daily_bep;  ?>    </span> </td>
    </tr>
	  
	    <tr>
      <td>Profit After B.E.P</td>
      <td> <span class= "">   <?php    echo $adjusted_netprf;  ?>    </span> </td>
    </tr>
	  
	  
	  <tr>
      <td>Remark</td>
      <td> <span class= "">   <?php    echo  $remark;  ?>    </span> </td>
    </tr>
	  
	  <tr>
      <td>Total Vol/Qty</td>
      <td> <span class= "">  <?php     echo $db_found_sum['SUM(s_qty)'];   ?>   </span> </td>
    </tr>
	  -->
  </tbody>
</table> </b>	
								</div>
								</div>
	
								<p></p>	
								
								<div class = "col-md-6 " style="background-color:;">
						
					
										<b>Money Recieved from Services:</b> 

							
						                <div class="jumbotron-fluid scroll" style="font-size:12; background-color: ">
				  	
					
  
							
								
					
					
					
					
		
										
										
											
						<?php
										
										
	
										
									

		
				$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where year = '$year' && month ='$month' and type = '' ";
	  
			$sum = mysqli_query($db_handle, $SQL_sum);
	  
			$db_found_sum = mysqli_fetch_assoc($sum) ;
	
			
		
			
						
																
										echo 	'<table class="table  table-hover" style="font-size:12; width:100%  " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Description </th>';
										
									 
										echo 	'<th scope="col">Total Sales</th>';
      
									
										echo 	'<th scope="col">Gross Profit</th>';
										
										echo 	'<th scope="col">Qty/Vol</th>';
		 


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

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

									$i =1;
	  
//echo "<p></p>";
//echo "<b>PRODUCT/SERVICE BASED RETURNS</b>";
									while ( $db_found = mysqli_fetch_assoc($result) ) {
	   
	
										echo'<tr style="text-align: center;background-color:; color:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['product_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</td>';
										echo '<td>'.$db_found['SUM(unit_c)'].'</td>';
										echo '<td>'.$db_found['SUM(s_qty)'].'</td>';
										
										
	
										
										
										
										
	//echo $db_found_sum['SUM(amount)']; 
										
										?>
										
										
					<td><a href="detail_report.php?txnname=<?php echo $db_found["product_name"]?>&month=<?php echo $month?>&year=<?php echo $year?>"><button onClick="spinner()">view</button>  </a></td>
										
											<?php
											
										
	 
  
   
   
										echo '</tr>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
								//===========================================================================
									
	
	
	
	
	
  
	
	
					//echo	'</div>';

					?>
		
		</div>
						</div>
				
								
								<div class="col-md-6">
<B>Money Recieved from customers:</B>
				<div class=" scroll" >
					
					
			<?php
									
										
					echo 	'<table class="table  table-hover" style="font-size:12; width:100%  " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Customers </th>';
										
									 
										echo 	'<th scope="col">Total Sales</th>';
      
									
										echo 	'<th scope="col">Gross Profit</th>';
										
										echo 	'<th scope="col">Qty/Vol</th>';
		 

										
										
										
										
										
	  
									$SQL = "SELECT  customers_name,product_id,SUM(amount),SUM(unit_c),SUM(s_qty) FROM txn_table where year = '$year' && month ='$month'  and type = '' GROUP BY customers_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:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['customers_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</td>';
										echo '<td>'.$db_found['SUM(unit_c)'].'</td>';
										echo '<td>'.$db_found['SUM(s_qty)'].'</td>';
										
										
	
	//echo $db_found_sum['SUM(amount)']; 
	 
  	?>
										
										
					<td><a href="detail_report.php?txnname=<?php echo $db_found["customers_name"]?>&month=<?php echo $month?>&year=<?php echo $year?>"><button onClick="spinner()">view</button>  </a></td>
										
											<?php
   
   
										echo '</tr>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
							//===========================================================================
							// end of returns based on clients		
	
		?>
					
				</div>
				</div>
					
				
</div>
			
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#C3C2F9"> <br>INCOME HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#C3C2F9;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
										echo '<th scope="col">s/n</th>';
	
										echo '<th scope="col">Txn  Id </th>';
										
										//echo '<th scope="col">IDN</th>';
							echo '<th scope="col">Payment</th>';
      
										echo '<th scope="col">Description</th>';
										
										echo '<th scope="col">Customers</th>';
		 
		
	
		   
										echo '<th scope="col"> Sales</th>';
										echo '<th scope="col">Gross Profit</th>';
							echo '<th scope="col">Balance</th>';
										echo '<th scope="col">Qty/Vol</th>';
		
										
		 
										echo '<th scope="col">Time</th>';
							echo '<th scope="col">Date</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date,payment,balance FROM txn_table   where year = '$year' && month ='$month' 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:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										echo '<td>'.$db_found['product_id'].'</td>';
										
									//	echo '<td>'.$db_found['user_id'].'</td>';
										echo '<td>'.$db_found['payment'].'</td>';
		 
										echo '<td>'.$db_found['product_name'].'</td>';
										echo '<td>'.$db_found['customers_name'].'</td>';
		
										echo '<td>'.$db_found['amount'].'</td>';
									
		
	
										echo '<td>'.$db_found['unit_c'].'</td>';
	
	 
										echo '<td>'.$db_found['balance'].'</td>';
										echo '<td>'.$db_found['s_qty'].'</td>';
										
										
	
										echo '<td>'.$db_found['time'].'</td>';
										echo '<td>'.$db_found['date'].'</td>';
										
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									
									<td><a href="modify_record.php?txnId=<?php echo $db_found["product_id"]?>">
   
										<input type="button" value="Edit" 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 '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			
				
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
				
						
						echo '</div>';
							
						}
						
						
				
						//expenses Account
						
						
				
						{
						
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:#E0E71E; ">';
						
						
		
			
										
			$SQL_exp = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where year = '$year' && month ='$month' and type = 'expense'";		
			
				//$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where date  BETWEEN '$lower_date' AND '$product'";							
	  
			$exp = mysqli_query($db_handle, $SQL_exp);
	  
			$db_found_exp = mysqli_fetch_assoc($exp) ;
	
										
										//this set of codes are used to manipulate the daily account
							/*
			$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);
										
			$daily_bep = $db_found_even['SUM(amount/30)'];  
			
			
			$gross_profit = $db_found_sum['SUM(unit_c)'];
			
			$net_profit = $gross_profit - $daily_bep;
			$adjusted_netprf = "";
							
			
			$remark = "fail";
			
			if($net_profit >0){
				
				$adjusted_netprf= $net_profit;
			}
			
										
							if($net_profit >0){
				
				$remark= "congratulations";
			}
										
										
										
										
										
							*/		
								
						?>
		
		
<div class="row" style="color:#260B4D; text-align: center;  ">
						<strong> <span style="color:#0E0CC1; text-align: center">EXPENSES ACCOUNT for <?php echo $month ?>  <?php echo $year; ?></span></strong><p></p>
						
</div>
						
<div class="row" style="margin-top: ; background-color:#E0E71E; ">
							
								<div class="row" style="margin: auto;" >
								
								<div class = "col-md-6 " style="margin: auto; background-color:#D9D3D3">
									<b><table width="100%" style="color:">
							
  <tbody>
	  
   
    <tr style="">
      <td>Total Expenses </td>
      <td>	<span class = "">   <?php     echo "  ".$db_found_exp['SUM(amount)']."  ";   ?>    </span></td>
    </tr>
  
	  
  </tbody>
</table> </b>	
								</div>
								</div>
	
								<p></p>	
								
								<div class = "col-md-6 " style="background-color:;">
						
					
										<b>Money spent on:</b> 

							
						                <div class="jumbotron-fluid scroll" style="font-size:12; background-color: ">
				  	
					
  
							
								
					
					
					
					
		
										
										
											
						<?php
										
										
	
										
									

		
			$SQL_exp = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where year = '$year' && month ='$month' and type = 'expense' ";
	  
			$exp = mysqli_query($db_handle, $SQL_exp);
	  
			$db_found_exp = mysqli_fetch_assoc($exp) ;
	
			
		
			
						
																
										echo 	'<table class="table  table-hover" style="font-size:12; width:100%; " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Description </th>';
										
									 
										echo 	'<th scope="col">Amount</th>';
      
									
										//echo 	'<th scope="col">Gross Profit</th>';
										
										//echo 	'<th scope="col">Qty/Vol</th>';
		 

										
										
										
										
										
	  
									$SQL = "SELECT  product_name,product_id,SUM(amount),SUM(unit_c),SUM(s_qty) FROM txn_table  where year = '$year' && month ='$month' and type = 'expense' GROUP BY product_name  ORDER BY product_id DESC";
	  
									$result = mysqli_query($db_handle, $SQL);

									$i =1;
	  
//echo "<p></p>";
//echo "<b>PRODUCT/SERVICE BASED RETURNS</b>";
									while ( $db_found = mysqli_fetch_assoc($result) ) {
	   
	
										echo'<tr style="text-align: center;background-color:; color:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['product_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</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>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
								//===========================================================================
									
	
	
	
	
	
  
	
	
					//echo	'</div>';

					?>
		
		</div>
						</div>
				
								
								<div class="col-md-6">
<!--<B>Client Base Expenses</B>-->
									
			<!--	<div class=" scroll" >
					
					
			<?php
									
										
					echo 	'<table class="table  table-hover" style="font-size:12; width:100%  " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Name of Client </th>';
										
									 
										echo 	'<th scope="col">Total Sales</th>';
      
									
										//echo 	'<th scope="col">Gross Profit</th>';
										
										//echo 	'<th scope="col">Qty/Vol</th>';
		 

										
										
										
										
										
	  
									$SQL = "SELECT  customers_name,product_id,SUM(amount),SUM(unit_c),SUM(s_qty) FROM txn_table  where year = '$year' && month ='$month' and type = 'expense' GROUP BY customers_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:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['customers_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</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>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
							//===========================================================================
							// end of returns based on clients		
	
		?>
					
				</div>-->
									
				</div>
					
				
</div>
			
			
			<!--this is the transaction table of the code-->
			<div class="row">
			
					<div class = "col-md-12 " style="background-color: #494747">
			
				  	
						<strong > <span style="color:; padding: 4px; background-color:#E0E71E;"> <br>EXPENDITURE HISTORY
					    
						</span> </strong>
				
					
					<div class="jumbotron-fluid scroll_history" style="font-size:12; ">
				  
				  
				 
	  
						<table class="table  table-hover" style="font-size:12; width:100%; background-color:#E0E71E;;" >
  
								<tbody>
    
								<tr  style="background-color: ; text-align: center; color: #000000">
									
									
      
										<?php
										
										echo '<th scope="col">s/n</th>';
	
										echo '<th scope="col">Invoice No </th>';
										
										echo '<th scope="col">IDN</th>';
      
										echo '<th scope="col">Description</th>';
										
										echo '<th scope="col">Customers</th>';
		 
		
	
		   
										echo '<th scope="col">Amount</th>';
										//echo '<th scope="col">Gross Profit</th>';
										//echo '<th scope="col">QTY/VOL</th>';
		
										
		 
										echo '<th scope="col">TIME</th>';
							echo '<th scope="col">DATE</th>';
										
			
     
    
									echo '</tr>';
 			
		



//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  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name FROM txn_table   where date= '$product' and type ='expense'  ORDER BY product_id DESC";

	  $SQL = "SELECT  product_name,product_id,user_id, amount,time,s_qty,unit_c,customers_name,date FROM txn_table   where year = '$year' && month ='$month' 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:black; background-color: " >';

	
	
										echo '<td>'.$i++.'</td>';
		
										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['customers_name'].'</td>';
		
										echo '<td>'.$db_found['amount'].'</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['date'].'</td>';
										
										
										
	//echo '<td>'.$db_found['SUM(amount)'].'</td>';
	
	//echo $db_found_sum['SUM(amount)']; 
	 
	 
	
									?>
									<?php
	
										echo '</tr>';

	
	

									}

										
									
								echo '</tbody>';

							echo '</table>';
						
									//mysqli_close($db_handle);
	  	?>
	
					</div>
			
			</div>
			
		
				</div>
		
		
						
			</div>
	
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
						
						
						
						
						
						
						
						
						}
							
						
						//profit and loss account
						
						{
						
					echo '<div class="jumbotron" style="border: #121111; border: solid 1px; margin-top: 70px; background-color:; ">';
						
						
		
			
										
		//	$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where date  BETWEEN '$lower_date' AND '$product' and type = 'expense'";		
			
				//$SQL_sum = "SELECT SUM(amount), SUM(s_qty), SUM(unit_c) FROM txn_table where date  BETWEEN '$lower_date' AND '$product'";							
	  
			$sum = mysqli_query($db_handle, $SQL_sum);
	  
			$db_found_sum = mysqli_fetch_assoc($sum) ;
	
		/*								
										//this set of codes are used to manipulate the daily account
			$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);
										
			$daily_bep = $db_found_even['SUM(amount/30)'];  
			
			
			$gross_profit = $db_found_sum['SUM(unit_c)'];
			
			$net_profit = $gross_profit - $daily_bep;
			$adjusted_netprf = "";
							
			
			$remark = "fail";
			
			if($net_profit >0){
				
				$adjusted_netprf= $net_profit;
			}
			
										
							if($net_profit >0){
				
				$remark= "congratulations";
			}
										
										
										*/
										
										
									
								
						?>
		
		
<div class="row" style="color:#260B4D; text-align: center;  ">
						<strong> <span style="color:black; text-align: center">Profit & loss ACCOUNT for <?php echo $month ?>  To <?php echo $year; ?></span></strong><p></p>
						
</div>
						
<div class="row" style="margin-top: ; background-color:; ">
							
								<div class="row" style="margin: auto;" >
								
								<div class = "col-md-6 " style="margin: auto; background-color:#D9D3D3">
									<b><table width="100%" style="color:">
							
  <tbody>
	  
  
	  
  </tbody>
</table> </b>	
								</div>
								</div>
	
								<p></p>	
								
								<div class = "col-md-6 " style="background-color:;">
						
					
										

															
							
						                <div class="jumbotron-fluid scroll" style="font-size:12; background-color: ">
				  	
					
  <b><table width="100%" style="color:">
							
  <tbody>
	  
   
    <tr>
      <td>Total Sales </td>
      <td>	<span class = "">   <?php     echo "  ".$db_found_sum['SUM(amount)']."  ";   ?>    </span></td>
    </tr>
	  
	  <?php $cos = $db_found_sum['SUM(amount)'] - $gross_profit;  ?>
	  <tr>
      <td>Cost of Goods sold</td>
      <td> <span class= ""> (<?php     echo $cos;   ?>)  </span> </td>
    </tr>
	  <tr>
      <td>Gross Profit</td>
      <td> <span class= "">   <?php     echo $gross_profit;   ?>   </span> </td>
    </tr>

	  
    <tr>
      <td>Total Expenses</td>
      <td> <span class= ""> (<?php     echo $db_found_exp['SUM(amount)'];   ?>)   </span> </td>
    </tr>
  
	  
	    <tr>
			
			<?php $net = $db_found_sum['SUM(amount)'] - $cos - $db_found_exp['SUM(amount)']; 
							
							$pab = $net - $daily_bep;
		    if($pab <0)
			{$pab = "";}
		
			
							if($net>0){
							$summary = "congratulations";	
								$loss ="";
								
							}
							else{
								$summary = "loss";
								$color = "red";
								$loss = $net;
								$net = "";
								//$loss = $net;
							}
			
			?>
      <td>Net Profit</td>
      <td> <span style= "background-color: <?php echo $color?>">   <?php    echo $net  ?>    </span> </td>
    </tr>
	  
	  
	  <tr>
      <td>Account Summery</td>
      <td> <span class= "">   <?php    echo  $summary?>   <span style="background-color: red"> <?php echo $loss;  ?></span> </span> </td>
    </tr>
	  
	   <tr>
      <td>Break Even Point</td>
      <td> <span class= ""> (<?php     echo $daily_bep;  ?>)   </span> </td>
    </tr>
	  
	    <tr>
      <td>Profit After B.E.P</td>
      <td> <span class= "">   <?php echo $pab  ?>    </span> </td>
    </tr>
	 
  </tbody>
</table> </b>	
									
										
										
											
					
		
		</div>
						</div>
				
								
								<div class="col-md-6">
<!--<B>Client Base Expenses</B>-->
									
			<!--	<div class=" scroll" >
					
					
			<?php
									
										
					echo 	'<table class="table  table-hover" style="font-size:12; width:100%  " >';
  									
										echo '<tr  style="background-color: ; text-align: center; color: black">';
      
									
										echo 	'<th scope="col">s/n</th>';
	
									
										echo 	'<th scope="col">Name of Client </th>';
										
									 
										echo 	'<th scope="col">Total Sales</th>';
      
									
										//echo 	'<th scope="col">Gross Profit</th>';
										
										//echo 	'<th scope="col">Qty/Vol</th>';
		 

										
										
										
										
										
	  
									$SQL = "SELECT  customers_name,product_id,SUM(amount),SUM(unit_c),SUM(s_qty) FROM txn_table   where date= '$product' and type = 'expense' GROUP BY customers_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:black" >';
   
	
	
										echo '<td>'.$i++.'</td>';
	
	 
										echo '<td>'.$db_found['customers_name'].'</td>';
	
	
	

	
	//echo '<td>'.$db_found['amount'].'</td>';
	
										echo '<td>'.$db_found['SUM(amount)'].'</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>';

	
			
									}

							echo '</tbody>';

							echo '</table>';
						
										
										
							//===========================================================================
							// end of returns based on clients		
	
		?>
					
				</div>-->
									
				</div>
					
				
</div>
			
			
			<!--this is the transaction table of the code-->
	
		
						
			</div>
	
										
		
		<!--open-->
			
		
	
	
	
	
	<!--second report works-->
	

	
<?php
										
				
						
						
					
					
							
						
						
						
						
						
						
						
						
						}
		
					}
					
					
					else {
						
					}
					
					 
					// echo  '</div>';		
		echo $date = date("Y-m-d");
		
?>


</div>
	
	
</body>

</html>




	<script>
		
		

		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";
  }
}		
		
			
		
function spinner() {
  
			var x = document.getElementById("spin");
	var history = document.getElementById("view_ac");
	
	
	
  if (x.style.display === "none") {
	  history.style.display ="none";
    x.style.display = "block ";
	  
	  
  }
	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 -->