<?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 invoice 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 invoice 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 invoice_st where date='$today' and user_id='$userid'";
$resultactive=$conn->query($sqlactive);
while($rowactive = $resultactive->fetch_assoc())
 
  {
  $tdaypurchase=$tdaypurchase + $rowactive['tnetamount'];
 
$trecordp=$trecordp + 1;
  }
  
   $sqlinactive = "SELECT * FROM invoice_st where  month_name='$my' and user_id='$userid'";
$resultinactive=$conn->query($sqlinactive);
while($rowinactive = $resultinactive->fetch_assoc())
 
  {
 $tmpurchase=$tmpurchase + $rowinactive['tnetamount'];
 
$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/sale_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: Invoice/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; ?>:Invoice/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 Sale Tax Invoice/Amount </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; ?>:Sale Tax Invoice/Amount </p>

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

                    </div>
                </div>
            </div>
           
            
             

            


          
					
					
					
					
					

          

           
			
			
			<div class="col-md-14">
                        <div class="card">
                            <div class="card-header" style="background-color:#66FF33">
							
                               <strong class="card-title">Sale Invoice  </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$username=$_SESSION["username"];
$sql5 = "SELECT * FROM invoice where user_id = '$userid' and month_name = '$my' order by id desc";
$result5=$conn->query($sql5);
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead bgcolor="#FFFF66">
									<?php
                                       echo "<tr>";
echo "<th > I.No </th>";
echo "<th > Name </th>";
echo "<th > Cell </th>";
echo "<th > Invoice Amount </th>";
echo "<th > W.H.Tax </th>";
echo "<th > W.H.Tax Amount </th>";
echo "<th > Receipt Amount </th>";
echo "<th > Status </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
                                       while($row = $result5->fetch_assoc())
 
  {
  $id = $row['id'];	
   echo "<tr>";
echo "<td>" .$row['id'] . "</td>";
echo "<td>" .$row['cname'] . "</td>";
echo "<td>" .$row['cell'] . "</td>";
echo "<td>" .$row['netamount'] . "</td>";
echo "<td>" .$row['st'] . "</td>";
echo "<td>" .$row['stamount'] . "</td>";
echo "<td>" .$row['cashrec'] . "</td>";
echo "<td>" .$row['status'] . "</td>";
		/*  echo"<th> <a href ='Add_Invoice_Item.php?id=$id'>"?><button type="button" class="btn btn-primary">  Add Items By Search Products</button><?php "</a>";*/
		
		 
		  echo"<th> <a href ='Open_Print_Invoice.php?id=$id'>"?><button type="button" class="btn btn-danger">  Print Invoice </button><?php "</a>";
		    echo"<th> <a href ='Print_Do.php?id=$id'>"?><button type="button" class="btn btn-danger">  Print DO </button><?php "</a>";
		  /* echo"<th> <a href ='Open_Cash_Received.php?id=$id'>"?><button type="button" class="btn btn-warning">  Cash Received </button><?php "</a>";*/
		 
		
	
  echo "</tr>";


  }
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					<div class="col-md-14">
                        <div class="card">
                            <div class="card-header" style="background-color:#66FF33">
							
                               <strong class="card-title">Sales Tax Invoice </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$username=$_SESSION["username"];
$sql12 = "SELECT * FROM invoice_st where user_id = '$userid' and month_name = '$my' order by id desc";
$result12=$conn->query($sql12);
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead bgcolor="#FFFF66">
									<?php
                                       echo "<tr>";
 echo "<th > Date </th>";
echo "<th > I.No </th>";
echo "<th > Name </th>";
echo "<th > Cell </th>";
echo "<th > Amount </th>";
echo "<th > Sale Tax </th>";
echo "<th > Sale Tax Amount </th>";
echo "<th > Net Amount </th>";
echo "<th > Cash Received </th>";
echo "<th > W.H.Tax Amount </th>";
echo "<th > Bal </th>";
echo "<th > Status </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
                                       while($row1 = $result12->fetch_assoc())
 
  {
  $id = $row1['id'];	
   echo "<tr>";
 echo "<td>" .$row1['date'] . "</td>";
echo "<td>" .$row1['id'] . "</td>";
echo "<td>" .$row1['cname'] . "</td>";
echo "<td>" .$row1['cell'] . "</td>";
echo "<td>" .$row1['netamount'] . "</td>";
echo "<td>" .$row1['st'] . "</td>";
echo "<td>" .$row1['stamount'] . "</td>";
echo "<td>" .$row1['tnetamount'] . "</td>";
echo "<td>" .$row1['cashrec'] . "</td>";
echo "<td>" .$row1['whamount'] . "</td>";
echo "<td>" .$row1['balret'] . "</td>";
echo "<td>" .$row1['status'] . "</td>";
		/*  echo"<th> <a href ='Add_Invoice_Item.php?id=$id'>"?><button type="button" class="btn btn-primary">  Add Items By Search Products</button><?php "</a>";*/
		  
		  
		  echo"<th> <a href ='Print_Invoice_st.php?id=$id'>"?><button type="button" class="btn btn-danger">  Print Invoice </button><?php "</a>";
		    echo"<th> <a href ='Print_Do_St.php?id=$id'>"?><button type="button" class="btn btn-danger">  Print DO </button><?php "</a>";
		  /* echo"<th> <a href ='Open_Cash_Received.php?id=$id'>"?><button type="button" class="btn btn-warning">  Cash Received </button><?php "</a>";*/
		 
		
	
  echo "</tr>";


  }
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					
					
					


					
					
					
					
					
					
					
					
					
					
					
					
					
					
        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

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

</body>

</html>
<?php
}
?>