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

$gtp=mysqli_query($conn,"select * from admin where username='$user'");
$gtp1=mysqli_fetch_assoc($gtp);

include 'top.php';
?>


<div id="page-wrapper" >
          <div>
<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=mysqli_query($conn,"select * from financial where user='$user' order by ID desc");
$aca1=mysqli_fetch_assoc($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;">
                            
                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>
                            
                            </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['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>';
		 }
		
	}

echo"<center><b>Today's Follow Up - ".date('d-m-Y')."</b></center><br />";

$date=date('Y-m-d');

echo"<table style='width:90%; margin:auto;'>

<tr><td><table id='dynamic-table' class='table table-bordered table-condensed' style='font-size:11px;'>

<thead><tr><th>Customer</th>
<th>District</th>
<th>Crop</th>
<th>Mobile</th><th>Time</th><th style='width:15%;'>Last Remarks</th><th style='width:15%;'>Remarks</th><th>Executive</th><th>Status</th></tr></thead>";

$sel=mysqli_query($conn,"select * from admin where username='$user'");
$nmrw=mysqli_num_rows($sel);
$sel1=mysqli_fetch_assoc($sel);

if($nmrw>0)
{
$getr=mysqli_query($conn,"select * from followup where date='$date'");
}
else
{
	
	$empd=mysqli_query($conn,"select * from employee where username='$user'");
	$empd1=mysqli_fetch_assoc($empd);

	$usr=$empd1['ID'];
	
$getr=mysqli_query($conn,"select * from followup where date='$date' and executive='$usr'");
}

while($getr1=mysqli_fetch_assoc($getr))
{
	
	$cust=mysqli_query($conn,"select * from crm_customer where ID='$getr1[customer]'");
	$cust1=mysqli_fetch_assoc($cust);
	
	$exec=mysqli_query($conn,"select * from employee where ID='$getr1[executive]'");
	$exec1=mysqli_fetch_assoc($exec);
	
	$dist=mysqli_query($conn,"select * from districts where ID='$cust1[district]'");
	$dist1=mysqli_fetch_assoc($dist);	$lfr=mysqli_query($conn,"select * from followup where customer='$getr1[customer]' and ID<'$getr1[ID]' order by ID desc limit 1");	$lfr1=mysqli_fetch_assoc($lfr);
	
	echo"<tr><td>".$cust1['name']."</td>		<td>".$dist1['district']."</td>		<td>".$cust1['cultivatingcrop']."</td>
	<td>".$cust1['mobile']."</td>
	<td>".$getr1['time']."</td>		<td>".$lfr1['remarks']."</td>			<td>".$getr1['remarks']."</td>	
	<td>".$exec1['name']."</td><td>";
	
	if($getr1['status']!='')
	{
		echo"".$getr1['status']."";
	}
	else
	{
		echo"<a href='status1.php?id=".$getr1['ID']."'>Update</a> &nbsp; <a href='salesorder1.php?id=".$getr1['ID']."'>Order</a> &nbsp; <a href='close1.php?id=".$getr1['ID']."'>Close</a>";
	}
	
	echo"</td></tr>";
	
}

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





?>                             
                               
							<br>
<br>
	

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

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


<?php

include 'bottom.php';

}
else
{

 header("location:login.php");
 
}

ob_flush();

?>