<?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';

$username=$_SESSION["username"];

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"];

?>
<!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 id="header" class="header">

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

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

        <div class="breadcrumbs" style="background-color:#00CCFF">
            <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" style="background-color:#00CCFF">
                <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="animated fadeIn">
                <div class="row">

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

include 'dbc.php';


$userid=$_SESSION["userid"];
$username=$_SESSION["username"];
$sql = "SELECT * FROM complain where user_id = '$userid' and username = '$username' and status = 'Open' order by id desc";
$result=$conn->query($sql);
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead bgcolor="#FFFF66">
									<?php
                                       echo "<tr>";
									   echo "<th > Date </th>";
echo "<th > C.No </th>";
echo "<th > Name </th>";
echo "<th > Address </th>";

echo "<th > Cash Received </th>";
echo "<th > Status </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
                                       while($row = $result->fetch_assoc())
 
  {
  $v_no = $row['v_no'];	
   echo "<tr>";
   echo "<td>" .$row['date'] . "</td>";
echo "<td>" .$row['v_no'] . "</td>";
echo "<td>" .$row['cname'] . "</td>";
echo "<td>" .$row['cell'] . "</td>";
echo "<td>" .$row['cashrec'] . "</td>";
echo "<td>" .$row['status'] . "</td>";
		
		  
		  echo"<th> <a href ='Print_Complain.php?id=$v_no'>"?><button type="button" class="btn btn-danger">  Print Complain </button><?php "</a>";
		   echo"<th> <a href ='Edit_Complain.php?id=$v_no'>"?><button type="button" class="btn btn-warning">  Complain Update </button><?php "</a>";
		   echo"<th> <a href ='Open_Cash_Received_Complain.php?id=$v_no'>"?><button type="button" class="btn btn-warning">  Cash Received </button><?php "</a>";
		  echo"<th> <a href ='Complain_Close.php?id=$v_no'>"?><button type="button" class="btn btn-success">  Complain Close </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:#FF99CC">
                                <strong class="card-title">Complains Details  </strong>
								
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$username=$_SESSION["username"];
$sql = "SELECT * FROM complain_details where user_id = '$userid' and status = 'Pending' order by id desc";
$result=$conn->query($sql);
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead bgcolor="#3399FF">
									<?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
                                       while($rowcom = $result->fetch_assoc())
 
  {
  $id = $rowcom['id'];
  $date = $rowcom['date'];	
  $ts1 = strtotime($today);
$ts2 = strtotime($date);
$diff = ($ts1 - $ts2)/86400;
   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 "</tr>";

 $cnt=$cnt + 1;
	$tfeerec=$tfeerec + $row['netamount'];
	$tfeerec1=$tfeerec1 + $row['discount'];
	$tfeerec2=$tfeerec2 + $row['gamount'];
	$tfeerec3=$tfeerec3 + $row['cashrec'];
	$tfeerec4=$tfeerec4 + $row['balret'];
		 
  }
   echo "<tr>";
	echo "<td colspan=3 align=right><b>" ."Total Records::". $trecord ."</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
}

?>