<?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['gamount'];
 
$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['gamount'];
 
$trecord2=$trecord2 + 1;
  }
  
  $sqlactive = "SELECT * FROM purchase where date='$today' and user_id='$userid'";
$resultactive=$conn->query($sqlactive);
while($rowactive = $resultactive->fetch_assoc())
 
  {
  $tdaypurchase=$tdaypurchase + $rowactive['netamount'];
 
$trecordp=$trecordp + 1;
  }
  
   $sqlinactive = "SELECT * FROM purchase where  month_name='$my' and user_id='$userid'";
$resultinactive=$conn->query($sqlinactive);
while($rowinactive = $resultinactive->fetch_assoc())
 
  {
 $tmpurchase=$tmpurchase + $rowinactive['netamount'];
 
$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 -->

    <?php include("includes/menu.php") ?><!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

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

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

             <?php include("includes/customer_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">

           


            
            <!--/.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 Sale Invoice 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 > Invoice No </th>";
echo "<th >  Date </th>";
echo "<th > Area Name </th>";
echo "<th > Customer Name </th>";
echo "<th > Amount </th>";
echo "<th > User Name </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sql = "SELECT * FROM invoice where  date = '$today' and user_id='$userid' order by cell";
$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['cell'] . "</td>";
echo "<td>" .$row['cname'] . "</td>";
echo "<td>" .$row['netamount'] . "</td>";
echo "<td>" .$row['username'] . "</td>";
echo"<th> <a href ='Print_Invoice.php?id=$id'>"?><button type="button" class="btn btn-primary"> Print Inoice</button><?php "</a>";


  echo "</tr>";

$trecord=$trecord + 1;
$tfeerec=$tfeerec + $row['netamount'];

  }
  
   echo "<tr>";
	echo "<td colspan=3 align=right><b>" ."Total Records::". $trecord ."</b></td>";
		echo "<td><b>" .$tfeerec . "</b></td>";
		
		
		
	  echo "</tr>";
	   
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					<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 Sale Tax Invoice 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 > Invoice No </th>";
echo "<th >  Date </th>";
echo "<th > Area Name </th>";
echo "<th > Customer Name </th>";
echo "<th > Amount </th>";
echo "<th > User Name </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sqlst = "SELECT * FROM invoice_st where  date = '$today' and user_id='$userid' order by cell";
$resultst=$conn->query($sqlst);
                                       while($rowst = $resultst->fetch_assoc())
 
  {
  $v_no = $rowst['v_no'];
 
  echo "<tr>";
echo "<td>" .$rowst['v_no'] . "</td>";
echo "<td>" .$rowst['date'] . "</td>";
echo "<td>" .$rowst['cell'] . "</td>";
echo "<td>" .$rowst['cname'] . "</td>";
echo "<td>" .$rowst['netamount'] . "</td>";
echo "<td>" .$rowst['username'] . "</td>";

echo"<th> <a href ='Print_Invoice_st.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Print Sale Tax</button><?php "</a>";

  echo "</tr>";

$trecordst=$trecordst + 1;
$tfeerecst=$tfeerecst + $rowst['netamount'];

  }
  
   echo "<tr>";
	echo "<td colspan=3 align=right><b>" ."Total Records::". $trecordst ."</b></td>";
		echo "<td><b>" .$tfeerecst . "</b></td>";
		
		
		
	  echo "</tr>";
	   
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					
					<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 Complain 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 > Complain No </th>";
echo "<th >  Date </th>";

echo "<th > Customer Name </th>";
echo "<th > Address </th>";
echo "<th > User Name </th>";
echo "<th > Status </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sqlcom = "SELECT * FROM complain where  status = 'Open' and user_id='$userid' order by id";
$resultcom=$conn->query($sqlcom);
                                       while($rowcom = $resultcom->fetch_assoc())
 
  {
  $v_no = $rowcom['v_no'];
 
  echo "<tr>";
echo "<td>" .$rowcom['v_no'] . "</td>";
echo "<td>" .$rowcom['date'] . "</td>";
echo "<td>" .$rowcom['cname'] . "</td>";
echo "<td>" .$rowcom['cell'] . "</td>";
echo "<td>" .$rowcom['disc'] . "</td>";
echo "<td>" .$rowcom['status'] . "</td>";
echo"<th> <a href ='Print_Complain.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Print</button><?php "</a>";
echo"<th> <a href ='Edit_Complain.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Reply</button><?php "</a>";
echo"<th> <a href ='Close_Complain.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Close</button><?php "</a>";
  echo "</tr>";
  

$trecordcom=$trecordcom + 1;
$tfeereccom=$tfeereccom + $rowcom['netamount'];

  }
  
   echo "<tr>";
	echo "<td colspan=3 align=right><b>" ."Total Records::". $trecordcom ."</b></td>";
		echo "<td><b>" .$tfeereccom . "</b></td>";
		
		
		
	  echo "</tr>";
	   
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					

<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 Sale Return 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 > Invoice No </th>";
echo "<th >  Date </th>";
echo "<th > Area Name </th>";
echo "<th > Customer Name </th>";
echo "<th > Amount </th>";
echo "<th > User Name </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sqlsr = "SELECT * FROM invoice_return where  date = '$today' and user_id='$userid' order by id";
$resultsr=$conn->query($sqlsr);
                                       while($rowsr = $resultsr->fetch_assoc())
 
  {
  $v_no = $rowsr['v_no'];
 
  echo "<tr>";
echo "<td>" .$rowsr['v_no'] . "</td>";
echo "<td>" .$rowsr['date'] . "</td>";
echo "<td>" .$rowsr['cell'] . "</td>";
echo "<td>" .$rowsr['cname'] . "</td>";
echo "<td>" .$rowsr['netamount'] . "</td>";
echo "<td>" .$rowsr['username'] . "</td>";
echo"<th> <a href ='Print_Invoice_Return.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Print</button><?php "</a>";
echo"<th> <a href ='Edit_Invoice_Return.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Edit</button><?php "</a>";
  echo "</tr>";

$trecordsr=$trecordsr + 1;
$tfeerecsr=$tfeerecsr + $rowsr['netamount'];

  }
  
   echo "<tr>";
	echo "<td colspan=3 align=right><b>" ."Total Records::". $trecordsr ."</b></td>";
		echo "<td><b>" .$tfeerecsr . "</b></td>";
		
		
		
	  echo "</tr>";
	   
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					
					
					
					
					
					<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 Purchase 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 > Invoice No </th>";
echo "<th >  Date </th>";
echo "<th > Area Name </th>";
echo "<th > Customer Name </th>";
echo "<th > Amount </th>";
echo "<th > User Name </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sqlp = "SELECT * FROM purchase where  date = '$today' and user_id='$userid' order by cell";
$resultp=$conn->query($sqlp);
                                       while($rowp = $resultp->fetch_assoc())
 
  {
  $v_no = $rowp['v_no'];
 
  echo "<tr>";
echo "<td>" .$rowp['v_no'] . "</td>";
echo "<td>" .$rowp['date'] . "</td>";
echo "<td>" .$rowp['cell'] . "</td>";
echo "<td>" .$rowp['cname'] . "</td>";
echo "<td>" .$rowp['netamount'] . "</td>";
echo "<td>" .$rowp['username'] . "</td>";
echo"<th> <a href ='Print_Invoice_Purchase.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Print</button><?php "</a>";
echo"<th> <a href ='Edit_Invoice_Purchase.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Edit</button><?php "</a>";
  echo "</tr>";

$trecordp=$trecordp + 1;
$tfeerecp=$tfeerecp + $rowp['netamount'];

  }
  
   echo "<tr>";
	echo "<td colspan=3 align=right><b>" ."Total Records::". $trecordp ."</b></td>";
		echo "<td><b>" .$tfeerecp . "</b></td>";
		
		
		
	  echo "</tr>";
	   
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					
					<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 Purchase Return 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 > Invoice No </th>";
echo "<th >  Date </th>";
echo "<th > Area Name </th>";
echo "<th > Customer Name </th>";
echo "<th > Amount </th>";
echo "<th > User Name </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sqlpr = "SELECT * FROM purchase_return where  date = '$today' and user_id='$userid' order by id";
$resultpr=$conn->query($sqlpr);
                                       while($rowpr = $resultpr->fetch_assoc())
 
  {
  $v_no = $rowpr['v_no'];
 
  echo "<tr>";
echo "<td>" .$rowpr['v_no'] . "</td>";
echo "<td>" .$rowpr['date'] . "</td>";
echo "<td>" .$rowpr['cell'] . "</td>";
echo "<td>" .$rowpr['cname'] . "</td>";
echo "<td>" .$rowpr['netamount'] . "</td>";
echo "<td>" .$rowpr['username'] . "</td>";
echo"<th> <a href ='Print_Invoice_pr.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Print</button><?php "</a>";
echo"<th> <a href ='Edit_Invoice_pr.php?v_no=$v_no'>"?><button type="button" class="btn btn-primary"> Edit</button><?php "</a>";
  echo "</tr>";

$trecordpr=$trecordpr + 1;
$tfeerecpr=$tfeerecpr + $rowpr['netamount'];

  }
  
   echo "<tr>";
	echo "<td colspan=3 align=right><b>" ."Total Records::". $trecordpr ."</b></td>";
		echo "<td><b>" .$tfeerecpr . "</b></td>";
		
		
		
	  echo "</tr>";
	   
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					
					
					
        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

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

</body>

</html>
<?php
}
?>