<?PHP
ob_start();
session_start();
include 'connect.php';
if(isset($_SESSION['adminemail']))
{
$user=$_SESSION['adminemail'];

$gtp=mysql_query("select * from employee where username='$user'");
$gtp1=mysql_fetch_array($gtp);

include 'top.php';
?>



<div class="main-content">
				<div class="main-content-inner">
					<div class="breadcrumbs ace-save-state" id="breadcrumbs">
						<ul class="breadcrumb">
							<li>
								<i class="ace-icon fa fa-home home-icon"></i>
								<a href="#">Home</a>
							</li>
							<li class="active">Follow Up Report</li>
						</ul><!-- /.breadcrumb -->
					</div>

					<div class="page-content">
			

						<div class="page-header">
                        
<?php

$aca=mysql_query("select * from financial where user='$user' order by ID desc");
$aca1=mysql_fetch_array($aca);

$financial=$aca1['financial'];

?>                        
                        
							<table style="width:100%;">
                        
                        <tr><td style="width:50%;">
                        
							<h1>
								Follow Up Report
							</h1>
                            
                            </td>
                            
                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">
                            
                            Executive : <?php echo $gtp1['name']; ?>
                            
                            </td></tr></table>
                            
						</div><!-- /.page-header -->
<br />

						<div class="row">
							<div class="col-xs-12">
                            
								<!-- PAGE CONTENT BEGINS -->
                                
<script src="assets/js/jquery.js"></script>
<script>
	
jQuery(function($){
		   
	// simple jQuery validation script
	$('#work').submit(function(){
		
		var valid = true;
		var errormsg = 'This field is required!';
		var errorcn = 'error';
		
		$('.' + errorcn, this).remove();			
		
		$('#required', this).each(function(){
			var parent = $(this).parent();
			if( $(this).val() == '' ){
				var msg = $(this).attr('title');
				msg = (msg != '') ? msg : errormsg;
				$('<span style="font-size:13px;color:#FF0000; padding-left:3px;" class="'+ errorcn +'">'+ msg +'</span>')
					.appendTo(parent)
					.fadeIn('fast')
					.click(function(){ $(this).remove(); });
				valid = false;
			};
		});
		
		return valid;
	});
	
});	

</script>
								
<?php 



if(isset($_GET['submit']))
{
$fromdate=$_GET['fromdate'];
$todate=$_GET['todate'];

echo"<center><b>Follow Up Report Between - ".$fromdate." - ".$todate."</b></center><br />";

$fromdate=date('Y-m-d',strtotime($fromdate));
$todate=date('Y-m-d',strtotime($todate));

echo"<table style='width:90%; margin:auto;'><tr><td><table id='dynamic-table' class='table table-bordered table-condensed'>

<thead><tr><th style='width:13%;'>Date</th><th>Customer</th><th>Time</th><th style='width:25%;'>Remarks</th><th>Status</th></tr></thead>";

$getr=mysql_query("select * from followup where date between '$fromdate' and '$todate' and executive='$gtp1[ID]'");
while($getr1=mysql_fetch_array($getr))
{
	
	$cust=mysql_query("select * from customer where ID='$getr1[customer]'");
	$cust1=mysql_fetch_array($cust);
		
	echo"<tr><td>".date('d-m-Y',strtotime($getr1['date']))."</td><td>".$cust1['name']."</td><td>".$getr1['time']."</td><td>".$getr1['remarks']."</td><td>";
	
	if($getr1['status']!='')
	{
		echo"".$getr1['status']."";
	}
	else
	{
		echo"<a href='status.php?id=".$getr1['ID']."'>Update</a> &nbsp; <a href='salesorder1.php?id=".$getr1['ID']."'>Order</a>";	
	}
	
	echo"</td></tr>";
}

echo"</table></td></tr></table><br />


<center><a href='followupreport.php'>Back</a></center>";


}

else

{
	
	
	if (isset($_GET['s'])) 
	{
	 $status=$_GET['s'];
		 if($status=='1')
		 {
		 echo '<div class="alert alert-success">
				<a class="close" data-dismiss="alert">x</a>
					Values Updated Successfully !
			  </div>';
		}
		elseif($status=='2')
		 {
		 echo '<div class="alert alert-danger">
				<a class="close" data-dismiss="alert">x</a>
					Values not edited. please try again.
			  </div>';
		}
	}
	

?>



<center>



<form action="followupreport.php" method="get" id="work">



<table width="50%" style="line-height:35px;">

<tr><td>From Date <span class="red">*</span></td><td>:</td>
<td> <input type="text" name="fromdate" id="required" title="*" class="datepicker" autocomplete="off" /></td></tr>

<tr><td>To Date <span class="red">*</span></td><td>:</td>
<td> <input type="text" name="todate" id="required" title="*" class="popupdatepicker" autocomplete="off" /></td></tr>

</table><br />



<button type="submit" name="submit" class="btn btn-sm btn-primary" value="submit">Go</button>



</form>



</center>



<?php



}



?>                             
                               
							<br>
<br>
	

								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					

</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->


<?php
include 'bottom.php';
}
else
{

 header("location:login.php");
}
ob_flush();
?>