<?php
include('../../adminlogin/include/session.php');
include('../admin/include/config.php');
date_default_timezone_set('Asia/Kolkata');// change according timezone
$currentTime = date( 'd-m-Y h:i:s A', time () );
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Admin | Reports</title>
	<link rel="stylesheet" href="https://vinayakamissions.com/vmcc-ticket/admin/bootstrap/css/bootstrap.min.css">
		<link rel="stylesheet" href="https://vinayakamissions.com/vmcc-ticket/admin/bootstrap/css/bootstrap-responsive.min.css">
	
	        <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" rel="stylesheet">
	<script language="javascript" type="text/javascript">
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
 if(popUpWin)
{
if(!popUpWin.closed) popUpWin.close();
}
popUpWin = open(URLStr,'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+500+',height='+600+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

</script>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
	<link type="text/css" href="../css/theme.css" rel="stylesheet">
	<link type="text/css" href="../images/icons/css/font-awesome.css" rel="stylesheet">
	<link type="text/css" href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' rel='stylesheet'>
		<link rel="stylesheet" href="https://vinayakamissions.com/vmcc-ticket/css/jquery-ui-datepicker.css">
  <script>
  $( function() {
    $( ".datepicker" ).datepicker({
		dateFormat: "dd/mm/yy",
		changeMonth: true,
        changeYear: true,
		showAnim: "slide"
	});
  });
  </script>
	<style>
		img{
			max-height: 100%;
			max-width: 100%;
		}
		ul,ol{
			list-style-type: none;
			padding: 0px;
		}
	table{
			  border-collapse: collapse;
  width: 100%;
		}
		.mystyle{
			  background-color: lightgrey;
  width: 97%;
  border: 15px solid maroon;
  padding: 20px;
  margin: 20px;
		}
		td,th{
			padding: 5px;
		}
		
/*Srcoll Bar*/

	/* Scroll width */
::-webkit-scrollbar {
  width: 5px;
}

/* Track */
::-webkit-scrollbar-track {
  background: #f1f1f1; 
}
 
/* Handle */
::-webkit-scrollbar-thumb {
  background: #002147; 
}

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
  background: #002147; 
}

	</style>
</head>
<body>
    
    <div class="navbar navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container-full">
				<a class="btn btn-navbar" data-toggle="collapse" data-target=".navbar-inverse-collapse">
					<i class="icon-reorder shaded"></i>
				</a>

			  	<a class="brand" href="#">
			  		<img src="https://vinayakamissions.com/vmcc-ticket/img/headerlogo.png" style="width: 250px;"> | REPORT
			  	</a>

				<div class="nav-collapse collapse navbar-inverse-collapse">
						<h5 align="right">Welcome: <?php echo $login_name; ?>
	                 	<a style="background-image: linear-gradient(to right, rgb(49, 26, 128) 0%, rgb(3, 62, 116) 100%); padding: 6px 10px 6px 10px; color: white; text-decoration: none; border-radius: 3px 9px 3px 9px;" href="https://vinayakamissions.com/vmcc-ticket/admin/logout.php">Logout</a>
	                 	</h5>
				</div><!-- /.nav-collapse -->
			</div>
		</div><!-- /navbar-inner -->
	</div>
    
    
    
    
    <div class="wrapper1">
		<div class="container-full">
			<div class="row">
    

	<div class="col-sm-3">
		<?php include("../include/sidebar.php");?>
	</div>
	
	
	<div class="span9">
					<div class="content">

	<div class="module">
	
	
	
	
	<div class="span3">
		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<div class="col-sm-12">

<div class="form-group">
<label class=""><strong>Complaint No&nbsp; :&nbsp;</strong></label>
<input class="form-control" name="cno" id="cno"  type="text" placeholder="Enter Complaint No"/>
</div>			

<div class="form-group">
<label><strong><span style="color: red;">(OR)</span></strong></label><br/>
<label><strong>Month&nbsp; :&nbsp;</strong></label>
	<select class="form-control" name="month">
	<option value="">Select Month</option>
	<option value="January">JANUARY</option>
	<option value="February">FEBRUARY</option>
	<option value="March">MARCH</option>
	<option value="April">APRIL</option>
	<option value="May">MAY</option>
	<option value="June">JUNE</option>
	<option value="July">JULY</option>
	<option value="August">AUGUST</option>
	<option value="September">SEPTEMBER</option>
	<option value="October">OCTOBER</option>
	<option value="November">NOVEMBER</option>
	<option value="December">DECEMBER</option>
	</select>

	</div>

<div class="form-group">
<label><strong>Year&nbsp; :&nbsp;</strong></label>
<select class="form-control" name="year">
<option value="">Select Year</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
	</select>
	</div>
	
<div class="form-group">
	<label><strong><span style="color: red;">(OR)</span></strong></label><br/>
<label><strong>Status&nbsp; :&nbsp;</strong></label>
<select name="category" id="category" class="form-control">
<option value="">Select Status</option>
<option value="Resolved">Resolved</option>
<option value="in process">In Process</option>
<option value="closed">Closed</option>
</select>
</div>


	<div class="col-sm-12">
	<center><input class="btn btn-success" name="export" id="export"  type="submit" value="Submit"><button style="margin-left:10px;" class="btn btn-danger" type="reset">Reset</button></center>

		</div>	

				</div>
								
									</form>
	</div>
	<div class="col-sm-7" height="300px" style="height: 500px !important; overflow: auto; ">
<script type='text/javascript'>
function printDiv() 
{

  var divToPrint=document.getElementById('DivIdToPrint');

  var newWin=window.open('','Print-Window');

  newWin.document.open();

  newWin.document.write('<html><body onload="window.print()">'+divToPrint.innerHTML+'</body></html>');

  newWin.document.close();

  setTimeout(function(){newWin.close();},10);

}
</script>
<?php
	include("../include/dbconnect.php");
if (isset($_POST['export']))
{
	if(! get_magic_quotes_gpc() )
		{
			$cno = addslashes($_POST['cno']);
			$month = $_POST['month'];
			$year = $_POST['year'];
			$category = addslashes($_POST['category']);
			$worker = addslashes($_POST['worker']);
		}
	else
	{
	$cno = ($_POST['cno']);
	$month = $_POST['month'];
	$year = $_POST['year'];
	$category = ($_POST['category']);
	$worker = ($_POST['worker']);
	}
	$dt = "$month"." $year";
					if($category=='1'){
			$cat1= "System and Networking";
		}
	if(isset($cno) && empty($month) && empty($year) && empty($category))
	{
		$query1="SELECT * FROM `tblcomplaints` WHERE complaintNumber='$cno'";
		$result1 = mysqli_query($conn,$query1) or die('Query failed: ' . mysqli_error());
    	$num_results1 = mysqli_num_rows($result1);  
		if(mysqli_num_rows($result1)>0)
	{
		echo "<div id='DivIdToPrint'><div class='col-sm-12'>
<center><img style='margin-top: 5px;' src='../avitlogo.png'/>
<hr/>
<h2 align='center'>TICKET RAISING SYSTEM</h2>
<p><strong>Details for the Complaint No: $cno</strong></p>
</center>
</div>
<center>
<table  border='1' cellpadding='3'>
		<thead>
		<tr style='color:#FF6801;'>
        <th>CNO</th>
		<th>LOCATION</th>
		<th>NOC</th>
        <th>COMPLAINT DETAILS</th>
		<th>PRIORITY</th>
		<th>STATUS</th>
		<th>DATE</th>
		</tr></thead>";	
		for($i = 1; $i <= $num_results1; $i++)
    	{
         	$row1 = mysqli_fetch_array($result1);
         	echo "<tr>
			<td align='center'>".$row1['complaintNumber']."</td>
			<td align='left'>".$row1['Location']."</td>
			<td align='left'>".$row1['noc']."</td>
			<td align='left'>".$row1['complaintDetails']."</td>
			<td align='center'>".$row1['priority']."</td>
			<td align='center'>".$row1['status']."</td>
			<td align='center'>".$row1['regDate']."</td>
			</tr>";
		}
		echo "</table><center>
		 <br/></div><center><input style='margin-bottom:50px;' type='button' id='btn' class='btn btn-warning' value='Print' onclick='printDiv();'></center>";
		//echo"<br/><a style='background-color:green; padding:15px;' href='report1.php?cno=$cno&from=$month&to=$year'>Export to Excel</a>";
	}
		else{
echo "<script language='javascript' type='text/javascript'>";
echo "alert('Invalid Details. Please Enter the Correct Complaint No.');";
echo "</script>";
		}
	}
	
	elseif(isset($month) && isset($year) && empty($cno) && empty($category))
	{
		// AND role='$login_role'
$query2="SELECT * FROM `tblcomplaints` WHERE Month='$dt' AND role='$login_role'";
$result2 = mysqli_query($conn, $query2) or die('Query failed: ' . mysqli_error());
    $num_results2 = mysqli_num_rows($result2);  
	if(mysqli_num_rows($result2)>0)
	{
			echo "<div id='DivIdToPrint'><div class='col-sm-12'>
<center><img style='margin-top: 5px;' src='../avitlogo.png'/>
<hr/>
<h2 align='center'>TICKET RAISING SYSTEM</h2>
<p><strong>Details for the Month: $month - $year</strong></p>
</center>
</div>
<center>
<table  border='1' cellpadding='3'>
		<thead>
		<tr style='color:#FF6801;'>
        <th>COMPLAINT NO</th>
		<th>LOCATION</th>
		<th>NOC</th>
        <th>COMPLAINT DETAILS</th>
		<th>PRIORITY</th>
		<th>STATUS</th>
		<th>DATE</th>
		</tr></thead>";
		//for($i = 1; $i <= $num_results2; $i++)
		while($row2 = mysqli_fetch_array($result2)) 
    	{
         	//$row2 = mysqli_fetch_array($result2);
			
			
         	echo "<tr>
			<td align='center'>".$row2['complaintNumber']."</td>
			<td align='left'>".$row2['Location']."</td>
			<td align='left'>".$row2['noc']."</td>
			<td align='left'>".$row2['complaintDetails']."</td>
			<td align='center'>".$row2['priority']."</td>
			<td align='center'>".$row2['status']."</td>
			<td align='center'>".$row2['regDate']."</td>
			</tr>";
		}
		echo "</table><center>
		 <br/></div><center><input style='margin-bottom:50px;' type='button' id='btn' class='btn btn-warning' value='Print' onclick='printDiv();'></center>";
	}
else{
echo "<script language='javascript' type='text/javascript'>";
echo "alert('No Record Found for given Month & Date');";
echo "</script>";
		}
	}
	
		elseif(isset($category) && empty($month) && empty($year) && empty($cno))
	{
$query3="SELECT * FROM `tblcomplaints` WHERE status='$category' AND role='$login_role'";
$result3 = mysqli_query($conn, $query3) or die('Query failed: ' . mysqli_error());
    $num_results3 = mysqli_num_rows($result3);  
	if(mysqli_num_rows($result3)>0)
	{
			echo "<div id='DivIdToPrint'><div id='scr' class='col-sm-12'>
<center><img style='margin-top: 5px;' src='../avitlogo.png'/>
<hr/>
<h2 align='center'>TICKET RAISING SYSTEM</h2>
<p><strong>Details for the Status: $category</strong></p>
</center>
</div>
<center>
<table style='overflow:scroll;' border='1' cellpadding='3'>
		<thead>
		<tr style='color:#FF6801;'>
		<th>S.NO</th>
        <th>CNO</th>
		<th>LOCATION</th>
		<th>NOC</th>
		<th>PRIORITY</th>
		<th>STATUS</th>
		<th>DATE</th>
		</tr></thead>";	
		for($i = 1; $i <= $num_results3; $i++)
    	{
         	$row3 = mysqli_fetch_array($result3);
         	echo "<tr>
			<td align='center'>".$i."</td>
			<td align='center'>".$row3['complaintNumber']."</td>
			<td align='left'>".$row3['Location']."</td>
			<td align='left'>".$row3['noc']."</td>
			<td align='center'>".$row3['priority']."</td>
			<td align='center'>".$row3['status']."</td>
			<td align='center'>".$row3['regDate']."</td>
			</tr>";
		}
		echo "</table><center>
		 <br/></div><center><input style='margin-bottom:50px;' type='button' id='btn' class='btn btn-warning' value='Print' onclick='printDiv();'></center>";
	}
else{
echo "<script language='javascript' type='text/javascript'>";
echo "alert('Invalid Details. Status not Available');";
echo "</script>";
		}
	}
	
	
	elseif(isset($month) && isset($year) && isset($cno))
	{
		echo "<script language='javascript' type='text/javascript'>";
echo "alert('Invalid Details. Input Complaint No. , Date or Status');";
echo "</script>";
	}
	else
	{
		echo "<script language='javascript' type='text/javascript'>";
echo "alert('Invalid Details. Input Complaint No. , Date or Status');";
echo "</script>";
	}
	
}
?>

<?php include('../include/footer.php');?>
	<script src="../scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
	<script src="../scripts/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
	<script src="../bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<script src="../scripts/flot/jquery.flot.js" type="text/javascript"></script>
	</div>
	</div>	</div>	</div>
</body>