<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{


?>
<!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 -->

    <!-- Left Panel -->

    <!-- Right Panel -->

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

        <!-- Header-->
        
        <!-- Header-->

        

        <div class="content mt-3">
            <div class="animated fadeIn">
                <div class="row">

                    <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 Status 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 > Model Name </th>";
echo "<th > Serial No </th>";

echo "<th >Complain Details </th>";
echo "<th > Complain Reply </th>";
echo "<th > Amount </th>";
echo "<th > Status </th>";
echo "<th >Assigned Engineer </th>";
echo "<th >Days </th>";
echo "<th > Close Date </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sql = "SELECT * FROM complain_details where  date between '$from_date' and '$to_date' and user_id='$userid' order by date desc";
$result=$conn->query($sql);
                                       while($rowcom = $result->fetch_assoc())
 
  {
  $inv_no = $rowcom['inv_no'];
   $date = $rowcom['date'];
   $cdate = $rowcom['cdate'];	
  $ts1 = strtotime($cdate);
$ts2 = strtotime($date);
$diff = ($ts1 - $ts2)/86400;
if ($diff < 1)
{
$diff = $diff + 1;
}
  echo "<tr>";
echo "<td>" .$rowcom['inv_no'] . "</td>";
echo "<td>" .$rowcom['date'] . "</td>";
echo "<td>" .$rowcom['cname'] . "</td>";
echo "<td>" .$rowcom['item_name'] . "</td>";
echo "<td>" .$rowcom['sno'] . "</td>";
echo "<td>" .$rowcom['complain'] . "</td>";
echo "<td>" .$rowcom['rply'] . "</td>";
echo "<td>" .$rowcom['amount'] . "</td>";
echo "<td>" .$rowcom['status'] . "</td>";
echo "<td>" .$rowcom['disc'] . "</td>";
echo "<td>" .$diff . "</td>";

echo "<td>" .$rowcom['cdate'] . "</td>";
echo"<th> <a href ='Print_Complain1.php?inv_no=$inv_no'>"?><button type="button" class="btn btn-primary"> Print</button><?php "</a>";

  echo "</tr>";

$trecord=$trecord + 1;

$tfeerec=$tfeerec + $rowcom['amount'];
  }
  
   echo "<tr>";
	echo "<td colspan=3 align=right><b>" ."Total ::". $trecord ."</b></td>";
		
	echo "<td><b>" .$tfeerec . "</b></td>";
		
		
	  echo "</tr>";
	   
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>


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

    <!-- Right Panel -->

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

</body>

</html>
<?php
}
?>