<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{
include 'dbc.php';
date_default_timezone_set("Asia/Karachi");
$today=date("Y-m-d");
$month = date("m",strtotime($today));
		$year = date("Y",strtotime($today));
		 $month_name = date("F", mktime(0, 0, 0, $month, 10));
		 $my=$month_name . " " . $year;
$userid=$_SESSION["userid"];
$sql = "SELECT * FROM cashpaid where date='$today' and user_id='$userid'";
$result=$conn->query($sql);
while($row = $result->fetch_assoc())
 
  {
 $tdaysale=$tdaysale + $row['netamount'];
 
$trecord=$trecord + 1;
  }
  
  $sql2 = "SELECT * FROM cashpaid where  month_name='$my' and user_id='$userid'";
$result2=$conn->query($sql2);
while($row2 = $result2->fetch_assoc())
 
  {
  $tmsale=$tmsale + $row2['netamount'];
 
$trecord2=$trecord2 + 1;
  }
  
  $sqlactive = "SELECT * FROM cashpaid where date='$today' and user_id='$userid'";
$resultactive=$conn->query($sqlactive);
while($rowactive = $resultactive->fetch_assoc())
 
  {
  $tdaypurchase=$tdaypurchase + $rowactive['whamount'];
 
$trecordp=$trecordp + 1;
  }
  
   $sqlinactive = "SELECT * FROM cashpaid where  month_name='$my' and user_id='$userid'";
$resultinactive=$conn->query($sqlinactive);
while($rowinactive = $resultinactive->fetch_assoc())
 
  {
 $tmpurchase=$tmpurchase + $rowinactive['whamount'];
 
$trecordpm=$trecordpm + 1;
  }
  

  
  
  
  
?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->

<head>
   <?php include("includes/header.php") ?>
</head>

<body>


    <!-- Left Panel -->


    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        <header id="header" class="header">

             <?php include("includes/paid_menu.php") ?>

        </header><!-- /header -->
        <!-- Header-->

        <div class="breadcrumbs">
            <div class="col-sm-6">
                <div class="page-header float-left">
                    <div class="page-title">
                        <h1><? echo "" . $_SESSION["userid"]; ?></h1>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="page-header float-right">
                    <div class="page-title">
                        <ol class="breadcrumb text-right">
                            <li class="active"><? echo "" . $_SESSION["username"]; ?></li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <div class="content mt-3">

           


            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-1">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
                            <span class="count"><?php echo $trecord; ?></span>
							/
							<span class="count"><?php echo $tdaysale; ?></span>
                        </h4>
                        <p class="text-light">Today: Payment Amount</p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart1"></canvas>
                        </div>

                    </div>

                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-2">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						 <span class="count"><?php echo $trecord2; ?></span>
							/
                            <span class="count"><?php echo $tmsale; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:Payment Amount </p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart2"></canvas>
                        </div>

                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-3">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordp; ?></span>
							/
                            <span class="count"><?php echo $tdaypurchase; ?></span>
							
                        </h4>
                        <p class="text-light">Today With Holding Tax </p>

                    </div>

                    <div class="chart-wrapper px-0" style="height:70px;" height="70">
                        <canvas id="widgetChart3"></canvas>
                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-4">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordpm; ?></span>
							/
                            <span class="count"><?php echo $tmpurchase; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:With Holding Tax </p>

                        <div class="chart-wrapper px-3" style="height:70px;" height="70">
                            <canvas id="widgetChart4"></canvas>
                        </div>

                    </div>
                </div>
            </div>
           
            
            
            <!--/.col-->

            
            <!--/.col-->

            
            <!--/.col-->

            
           
		   
		    <!--/.col-->

            
             

            


          
					
					
					
					
					

          

           
			
			
			<div class="col-md-14">
                        <div class="card">
						<div class="page-title">
                        <h2><center><? echo "" . $_SESSION["userid"]; ?></center></h2>
                    </div>
                            <div class="card-header">
							
                                <strong class="card-title"><center>Daily Cash Paid Details Report</center> </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$from_date=$_POST["from_date"];
$to_date=$_POST["to_date"];
$today=date("Y-m-d");
$username=$_SESSION["username"];


?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
                                       echo "<tr>";
									  
echo "<th > Receipt No </th>";
echo "<th >  Date </th>";

echo "<th > Vendor Name </th>";
echo "<th > Paid Amount </th>";
echo "<th > W.H.Tax % </th>";
echo "<th > W.H.Tax Amount </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sql = "SELECT * FROM cashpaid where  month_name = '$my' and user_id='$userid' order by date";
$result=$conn->query($sql);
                                       while($row = $result->fetch_assoc())
 
  {
  $id = $row['id'];
 
  echo "<tr>";
echo "<td>" .$row['id'] . "</td>";
echo "<td>" .$row['date'] . "</td>";
echo "<td>" .$row['ven_name'] . "</td>";
echo "<td>" .$row['netamount'] . "</td>";
echo "<td>" .$row['wh_tax'] . "</td>";
echo "<td>" .$row['whamount'] . "</td>";


  echo "</tr>";

$trecord1=$trecord1 + 1;
$tfeerec=$tfeerec + $row['netamount'];
$tst=$tst + $row['whamount'];
  }
  
   echo "<tr>";
	echo "<td colspan=3 align=right><b>" ."Total Records::". $trecord1 ."</b></td>";
		echo "<td><b>" .$tfeerec . "</b></td>";
		echo "<td></td>";
		echo "<td><b>" .$tst . "</b></td>";
		
		
		
	  echo "</tr>";
	   
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					
					
					
					
					
					
					
					
					
					
        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

   <?php include("includes/footermenu.php") ?>

</body>

</html>
<?php
}
?>