<?PHP
ini_set('max_execution_time', '1200'); //300 seconds = 5 minutes
ob_start();
session_start();
include 'connect.php';
if(isset($_SESSION['adminemail']))
{
$user=$_SESSION['adminemail'];

$gtp=mysql_query("select * from admin 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">Executive 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>
								Executive 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['submit']))
{
$executive=$_GET['executive'];

$exed=mysql_query("select * from employee where ID='$executive'");
$exed1=mysql_fetch_array($exed);

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

<tr><td style='width:20%;'></td><td><table style='margin:auto; line-height:23px;'>

<tr><td>Executive</td><td style='padding:0 11px;'>:</td><td>".$exed1['name']."</td></tr>

<tr><td>Address</td><td style='padding:0 11px;'>:</td><td>".$exed1['permanentaddress']."</td></tr>

<tr><td>Contact</td><td style='padding:0 11px;'>:</td><td>".$exed1['contactno']."</td></tr>

</table></td><td style='width:20%; text-align:right;'>

<a href='customersexcel1.php?executive=".$executive."' target='_blank'><button type='submit' class='btn btn-minier btn-info'>Customers List Excel</button></a>

</td></tr>

</table><br />";

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

<tr><td>

<table id='example' class='table table-bordered table-condensed'>

<thead><tr><th style='width:15%;'>Customer</th>
<th style='width:15%;'>District</th>
<th style='width:15%;'>Crop</th>
<th style='width:15%;'>Contact No.</th>
<th style='width:12%;'>Last Follow Up</th>
<th style='width:10%;'>History</th>
<th style='width:10%;'>History</th>
<th style='width:10%;'>History</th>
<th style='width:10%;'>History</th>
<th style='width:10%;'>History</th></tr></thead>";

echo"</table>

</td></tr>

</table><br />

<center><a href='javascript:history.back(1);'>Back</a></center>";

$exct=$executive;

}

else
{


$desig=mysql_query("select * from employee_designation where designation='Executive'");
$desig1=mysql_fetch_array($desig);

$design=mysql_query("select * from employee_designation where designation='Team Leader'");
$design1=mysql_fetch_array($design);


$sel=mysql_query("select * from admin where username='$user'");
$nmrw=mysql_num_rows($sel);
$sel1=mysql_fetch_array($sel);

?>



<center>




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

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

<tr><td>Executive <span class="red">*</span></td><td>:</td>
<td><select name="executive" class="chosen" id="required" title="*" style="width:220px;"><option value="">-- Select --</option>

<?php

if($nmrw>0)
{
$exec=mysql_query("select employee.ID as ID, employee.name as name from employee left join department on employee.department=department.ID where department.crm='1' order by employee.ID asc");
}
else
{

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

$usr=$empd1['ID'];

$exec=mysql_query("select employee.ID as ID, employee.name as name from employee left join department on employee.department=department.ID where department.crm='1' and employee.ID='$usr' order by employee.ID asc");
}

while($exec1=mysql_fetch_array($exec))
{
	echo"<option value='".$exec1['ID']."'>".$exec1['name']."</option>";
}

?>

</select></td></tr>

</table><br />

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

</form>



</center>



<?php



}



?>

							<br>
<br>


<script type="text/javascript" language="javascript" class="init">

		var nmrw=<?php echo $nmrw; ?>;
		var exct=<?php echo $exct; ?>;
		
		//alert(nmrw);

		$(document).ready(function() {			
			$('#example').dataTable( {
				"processing": true,
				"serverSide": true,
				"ajax": "followupreportserver.php?exct="+ exct,
				"language": {
                    "processing": '<i class="fa fa-spinner fa-spin" style="font-size:24px;color:rgb(75, 183, 245);"></i>'
                 }
			} );
		} );

</script>


								<!-- 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();


?>