<?php ob_start(); ?>
<?php  session_start();
require_once '../includes/conn.php';
require_once 'head_link.php'
?>

<!DOCTYPE html>
<html lang="en">
  
  <head> 
<title>Training Institute Manager</title>  
 <meta charset="utf-8">
    <link rel="stylesheet" href="php_action/invoice/style1.css" media="all" /> 
<link rel="icon" type="image/x-icon" href="../includes/dim.png"> 
</head>

  <body>
  
<?php 
$sql = $con->query("select * from stuff where userid ='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
$BizLogo =$row['photo'];
$SignImg =$row['sign_img'];
$BizNam =$row['business_name'];
$BizPhn =$row['business_phone']; 
$BizEml =$row['business_email'];
$BizAdr =$row['business_address'];
?>       
    <div class="container">
	
    <header class="clearfix center">
      <div id="logo"> 
	  <img src="../<?php if($BizLogo==""){echo "../img/user.jpg";}else{echo $BizLogo;} ?>"> 
         <h2 class="name"><b><?php echo $BizNam ; ?></b><br>
		 Daily Report Summary
		 </h2>
        <div>  
  <span style="font-size:15px;"> 
 Current Date :
<?php 
 date_default_timezone_set("Asia/Dhaka");
 $date=date("Y/m/d");
echo date("d-m-Y") ;
?>
 |  Current Time :  <?php date_default_timezone_set("Asia/Dhaka"); echo  date("h:i:sa");?>
 </span>
		</div>
       </div> 
    </header>
	
   <main>
	 
				
  <table border="0" cellspacing="0" cellpadding="0">
       
	   <thead>
          <tr>
		  <th class="no"><b>SL</b> </th> 
		  <th class="desc"><b> Description</b></th> 
		  <th class="desc"><b> Value</b></th> 
          </tr>
        </thead>
        
		 <tbody>	
 		  
          <tr>
            <td class="no">1</td>
            <td class="desc">Total Sale Qty</td>
            <td class="desc">
<?php  
$sql = $con->query("SELECT sum(order_item.order_quantity) as total FROM order_item
left join orders on orders.order_id=order_item.order_id
WHERE order_item.entry_date='$date' and orders.user_id ='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
$TSQ= $row['total'];
?><?php echo $TSQ ; ?>
			</td> 
          </tr>
		  
		  <tr>
		  <td class="no">2</td>
		  <td class="desc">Previous Due</td>
		  <td class="desc">
		  <?php 
$sql = $con->query("SELECT sum(`pre_due`) as `total` FROM `orders`
WHERE order_date='$date' and orders.user_id ='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
$TSP1= $row['total'];
?><?php echo $TSP1 ; ?>
		  </td>
		  </tr>
		  
		  <tr>
		  <td class="no"><b>3</b></td>
		  <td class="desc"><b>Today Sale Price</b></td>
		  <td class="desc">
		  <b><?php 
$sql = $con->query("SELECT sum(`today_total`) as `total` FROM `orders`
WHERE order_date='$date' and orders.user_id ='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
$TSP= $row['total'];
?><?php echo $TSP ; ?></b>
		  </td>
		  </tr>
		  
		  <tr>
		  <td class="no">4</td>
		  <td class="desc">Total Sale Price</td>
		  <td class="desc">
		  <?php 
$sql = $con->query("SELECT sum(`grand_total`) as `total` FROM `orders`
WHERE order_date='$date' and orders.user_id ='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
$TSP1= $row['total'];
?><?php echo $TSP1 ; ?>
		  </td>
		  </tr>
		  
		  <tr>
            <td class="no">5</td>
            <td class="desc">Total Buy Price</td>
            <td class="desc">
<?php  
$sql = $con->query("SELECT sum(order_item.buy_rate * order_item.order_quantity) as total FROM order_item
left join orders on orders.order_id=order_item.order_id
WHERE order_item.entry_date='$date' and orders.user_id ='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
$TBPS= $row['total'];
?><?php echo $TBPS ; ?>
			</td> 
          </tr>
		  
		  <tr>
            <td class="no"><b>6</b></td>
            <td class="desc"><b>Today's Profit</b></td>
            <td class="desc">
<b><?php
$TDP=$TSP-$TBPS ;
 echo $TDP ;
 ?></b>
			</td> 
          </tr>
		  
		  <tr>
		  <td class="no">7</td>
		  <td class="desc">Paid By Invoice</td>
		   <td class="desc">
		   <?php 
$sql = $con->query("SELECT sum(`paid`) as `total` FROM `orders`
 WHERE order_date='$date' and order_status='1' and orders.user_id ='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
$PBI= $row['total'];
?><?php echo $PBI ; ?>
		   </td>
		  </tr>
		  
		   <tr>
		  <td class="no">8</td> 
		   <td class="desc">Total Due Paid Without Sale</td>
		   <td class="desc">
		   <?php 
$sql = $con->query("SELECT sum(`paid`) as `total` FROM `orders_details` WHERE order_date='$date' and order_type=4 and orders_details.user_id ='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
$TDPWS= $row['total'];
?> <?php echo $TDPWS ; ?>
		   </td>
		  </tr>
		  
		   <tr>
		  <td class="no">9</td>
		  <td class="desc">Total Due</td>
		   <td class="desc">
		   <?php 
$sql = $con->query("SELECT sum(`due`) as `total` FROM `orders`
 WHERE order_date='$date' and order_status='1' and orders.user_id ='".$_SESSION['id']."' ");
$row = $sql->fetch_assoc();
$TDue= $row['total'];
?><?php echo $TDue ; ?>
		   </td>
		  </tr>
		    
		  
		   <tr>
		  <td class="no"><b>10</b></td>
		  <td class="desc"><b>Grand Total Collection</b></td>
		   <td class="desc">
		   <b><?php
$GTC=$PBI+$TDPWS ;
 echo $GTC ;
 ?></b>
		   </td>
		  </tr>

 <tr> <td><br></td> <td><br></td> <td><br></td> </tr>
		  
		   <tr>
		  <td class="no"><b>11</b></td>
		  <td class="desc"><b>Office Expense</b></td>
		   <td class="desc"><b>
		   <?php
$sql = $con->query("SELECT SUM(`expense_cost`) as `total2` FROM `expense` where entry_date='$date' and user_id='".$_SESSION['id']."'  ");
$row = $sql->fetch_assoc();
$OfExp=$row['total2'];
?> <?php echo $OfExp; ?></b>
		   </td>
		  </tr>


		  
		   <tr> <td><br></td> <td><br></td> <td><br></td> </tr>
		  
		 <tr>
		  <td class="no"><b>12</b></td>
		  <td class="desc"><b>Total Cash</b></td>
		   <td class="desc"><b>
		   <?php 
$Cash= $GTC-$OfExp;
echo $Cash ;
?></b>
		   </td>
		  </tr>
	
	 
		
      </table>
	  
	  
      <br>   <br>
	  
    </main>
	
 
	
  </body>
</html> 

</div>

