<?php ob_start(); ?>
<!DOCTYPE html>
<html lang="en"> 

<head>
<?php   require_once 'head_link.php'; ?>

</head>

<body>
 
<?php   require_once 'header1.php'; ?> 

<?php  require_once 'sidebar.php'; ?>


  <main id="main" class="main">
  
  <div class="pagetitle bg-light rounded p-2">
      <h1>  <i class="bi bi-wallet-fill"></i>  Daily Cash Report     
	   <i class="bi bi-calendar"></i> Date :
<?php 
 date_default_timezone_set("Asia/Dhaka");
 $date=date("Y/m/d");
echo date("d-M-Y") ;
?>
      <i class="bi bi-clock"></i> Time :  <?php date_default_timezone_set("Asia/Dhaka"); echo  date("h:i:sa");?>
	  </h1> 
    </div> 
	
	<section class="section">
      <div class="row">
	  
        <div class="col-lg-12  mt-2">

          <div class="container">
          <div class="card">
            <div class="card-body">
			
	  <table class="table table-hover">
       
	   <thead class="bg-light">
          <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>
	  
	  <center><h1 class="h2"> <a target="_blank" class="btn btn-info" href="daily-cash-report-print.php"> <span class="bi bi-printer"></span> &nbsp; <b>Print</b>  </a></h1></center>
      
 </div>
          </div>

        </div>
        </div>
      </div>
    </section>
	
   </main>
  
  <?php  require_once 'footer1.php'; ?>