<?php
defined('BASEPATH') OR exit('No direct script access allowed');?>
<!DOCTYPE html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- bootstrap-css -->
<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/bootstrap.min.css" />
<!-- //bootstrap-css -->
<!-- Custom CSS -->
<link href="<?php echo base_url();?>/assets/css/style.css" rel='stylesheet' type='text/css' />
<link href="<?php echo base_url();?>/assets/css/style-responsive.css" rel="stylesheet"/>
<!-- font CSS -->
<link href='//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
<!-- font-awesome icons -->
<link rel="stylesheet" href="<?php echo base_url();?>/assets/css/font.css" type="text/css"/>
<link href="<?php echo base_url();?>/assets/css/font-awesome.css" rel="stylesheet"/> 
<link href="<?php echo base_url();?>/assets/css/datetimepicker.min.css" rel="stylesheet"/>
<!-- //font-awesome icons -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
	<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
	<script src="https://www.reviewadda.co.in/assets/crm/js/jquery-ui.js"></script>
</head>
<body>
<section id="container">
<!--header start-->
<header class="header fixed-top clearfix">
<!--logo start-->
<div class="brand">
    <a href="<?php echo base_url();?>home/dashboard" class="logo">
        <img src="" style="  display: block;  margin-left: auto;  margin-right: auto;  width: 80%;margin-top: -22px;"/>
    </a>
    <div class="sidebar-toggle-box">
        <div class="fa fa-bars"></div>
    </div>
</div>
<!--logo end-->
<?php include_once 'common/notification_bar.php';?>
<?php include_once 'common/aside.php';?>

<section id="main-content">
	<section class="wrapper">
		<div class="table-agile-info">
  <div class="panel panel-default">
  <div id="studentInfo" style="border:0px solid;z-index:999999"></div>
    <div class="panel-heading">
  Report
    </div>
    <div class="row w3-res-tb">
	<form method="post" action="<?php echo base_url();?>home/report">
      <div class="col-sm-12 m-b-xs">
	  <input type="text" name="name" style="margin:5px;" placeholder="By Name" class="col-sm-4 input-sm form-control w-sm inline v-middle" value="<?php if($filter_data['name']!=''){echo $filter_data['name'];}?>"/>
	  <input type="email" name="email" style="margin:5px;" placeholder="By Email" class="col-sm-4 input-sm form-control w-sm inline v-middle" value="<?php if($filter_data['email']!=''){echo $filter_data['email'];}?>"/>
	  <input type="text" name="phone" maxlength="10" pattern="[0-9]+" onkeypress="return numbersonly(this, event)" style="margin:5px;" placeholder="By Phone" class="col-sm-4 input-sm form-control w-sm inline v-middle" value="<?php if($filter_data['phone']!=''){echo $filter_data['phone'];}?>"/>
	   <input type="date" name="added_on" style="margin:5px;" placeholder="by created date" class="col-sm-4 input-sm form-control datepicker1 w-sm inline v-middle" value="<?php if($filter_data['added_on']!=''){echo $filter_data['added_on'];}?>"/>
	  <input type="text" name="followup_date" style="margin:5px;" placeholder="By Follow Up" class="col-sm-4 input-sm form-control datepicker1 w-sm inline v-middle" value="<?php if($filter_data['followup_date']!=''){echo $filter_data['followup_date'];}?>"/>
        <select class="col-sm-4 input-sm form-control w-sm inline v-middle" name="city" style="margin:5px;">
         <option value="">Select City</option>
		<?php foreach(getCity() as $get){?>
		<option <?php if($filter_data['city']==$get->id){echo "selected";}?> value="<?php echo $get->id;?>"><?php echo $get->city_name;?></option>
		<?php } ?>
		</select>
		<select name="lead_status" class="col-sm-4 input-sm form-control w-sm inline v-middle" style="margin:5px;">
         <option  value="">Select Lead Status</option>
											<?php foreach(getStatus() as $get){?>
											<option <?php if($filter_data['lead_status']==$get->id){echo "selected";}?> value="<?php echo $get->id;?>"><?php echo $get->status;?></option>
											<?php } ?>
											</select>
		<select name="source_id" class="col-sm-4 input-sm form-control w-sm inline v-middle" style="margin:5px;">
          <option value="">Select Source</option>
											<?php foreach(getSource() as $get){?>
											<option <?php if($filter_data['source_id']==$get->id){echo "selected";}?> value="<?php echo $get->id;?>"><?php echo $get->source;?></option>
											<?php } ?>
											</select>
      
		<?php if($user_data[0]['user_type']!=3){?>
		<select name="caller_id" class="col-sm-4 input-sm form-control w-sm inline v-middle" style="margin:5px;">
         <option value="">Select Caller</option>
											<?php $userid=$this->session->userdata('user_login');
											foreach(getCaller($userid[0]['id'],$userid[0]['user_type']) as $get){?>
											<option <?php if($filter_data['caller_id']==$get->id){echo "selected";}?> value="<?php echo $get->id;?>"><?php echo $get->username;?></option>
											<?php } ?>
											</select>
											<?php } ?>
	<select name="site_visit_verify" class="col-sm-4 input-sm form-control w-sm inline v-middle" style="margin:5px;">
         <option value="">Site visit verify</option>
		<option <?php if($filter_data['site_visit_verify']=='Y'){echo "selected";}?> value="Y">Y</option>
		<option <?php if($filter_data['site_visit_verify']=='N'){echo "selected";}?> value="N">N</option>
		</select>
		 <input type="date" name="from_date" style="margin:5px;" placeholder="by created date" class="col-sm-4 input-sm form-control w-sm inline v-middle" value="<?php if($filter_data['from_date']!=''){echo $filter_data['from_date'];}?>"/>
		 
		  <input type="date" name="to_date" style="margin:5px;" placeholder="by created date" class="col-sm-4 input-sm form-control w-sm inline v-middle" value="<?php if($filter_data['to_date']!=''){echo $filter_data['to_date'];}?>"/>
		<div class="clearfix"></div>
        <button class="btn btn-sm btn-primary" name="submit" >Apply</button>                
        <a href="<?php echo base_url();?>home/reset" class="btn btn-sm btn-default">Reset</a>                
      </div>
      </form>
    </div>
	<div class="row w3-res-tb">
	<h2>Leads : <?php if($counts!=''){echo $counts;}?></h2>
	<?php if($counts!=''){?><?php if(($user_data[0]['user_type']==1)){?>
	<a href="<?php echo base_url()?>home/report/csv" class="btn btn-primary">Download</a>
	<?php } ?>
	<div class='clearfix'></div>
	<div class="col-md-12">

	<div class="table-responsive">
      <table class="table table-striped b-t b-light">
        <thead>
          <tr>
            <th style="font-weight: normal;">ID</th>
            <th style="font-weight: normal;">Name</th>
           
            <th style="font-weight: normal;">Phone</th>
            <th style="font-weight: normal;">Looking For</th>
            <th style="font-weight: normal;">Lead Status</th>
            <th style="font-weight: normal;">Source</th>
            <th style="font-weight: normal;">Remark</th>
     
            <th style="font-weight: normal;">Follow Up</th>
            <th style="font-weight: normal;">Interested In</th>
            <th style="font-weight: normal;">Caller</th>
            <th style="font-weight: normal;">Site Visit Date</th>
            <th style="font-weight: normal;">SITE VISIT VERIFY</th>
            <th style="font-weight: normal;">Team Leader</th>
			       <th style="font-weight: normal;">Added_on</th>
          </tr>
        </thead>
        <tbody>
		<?php $i=0;foreach($_SESSION['leadsdata'] as $lead){
			$leadstatus=getStatus($lead->lead_status);
		$project=getProjects($lead->interested_in);
		$tl=getTL($lead->caller_id);
		?>
		<tr>
		<th><?php echo $i+1;?></th>
            <th style="font-weight: normal;"><?php echo $lead->name;?></th>
        
            <th style="font-weight: normal;"><?php echo $lead->phone;?></th>
            <th style="font-weight: normal;"><?php echo $lead->looking_for;?></th>
            <th style="font-weight: normal;"><?php echo $leadstatus[0]->status;?></th>
            <th style="font-weight: normal;"><?php echo $lead->source;?></th>
            <th style="font-weight: normal;"><div style="overflow-y:scroll; width:100%;height:35px;"><?php echo $lead->feedback;?></div></th>
           
            <th style="font-weight: normal;"><?php echo $lead->follow_up;?></th>
            <th style="font-weight: normal;"><?php echo $project[0]->property_name;?></th>
            <th style="font-weight: normal;"><?php echo $lead->username;?></th>
            <th style="font-weight: normal;"><?php echo $lead->site_visit_date;?></th>
            <th style="font-weight: normal;"><?php echo $lead->site_visit_verify;?></th>
            <th style="font-weight: normal;"><?php echo $tl[0]->username;?></th>
			 <th style="font-weight: normal;"><?php echo $lead->added_on;?></th>
		</tr>
	<?php $i++;} ?>
		</tbody>
		</table>
		</div>
	</div>
	<div class='clearfix'></div>
	<div class="col-sm-6">
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
	<?php $arr='';
	foreach($leads as $lead){
		$arr .=$lead->lead_status.',';
	}
	$arr=rtrim($arr,',');
	$arr1=explode(',',$arr);
	$aa=(array_count_values($arr1));
	$cht='';
	foreach($aa as $key => $chart){
	$leadstatus=getStatus($key);
	$cht .="['".$leadstatus[0]->status."-".$chart."',".$chart."],";	
	}
	$cht = rtrim($cht,',');
	?>
    <script type="text/javascript">
      google.charts.load("current", {packages:["corechart"]});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Task', 'leads Status'],
          <?php echo $cht;?>
        ]);

        var options = {
          title: 'Leads Report According to Status',
          is3D: true,
        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
        chart.draw(data, options);
      }
    </script>
  
    <div id="piechart_3d" style="min-width:400px; height:350px; margin: 0 auto"></div>
 
</div>
<div class="col-sm-6">
	
	<?php $arrss='';
	foreach($leads as $lead){
		$arrss .=$lead->caller_id.',';
	}
    $arrss=rtrim($arrss,',');
	$arrss1=explode(',',$arrss);
	$aass=(array_count_values($arrss1));
	$chttt='';
	foreach($aass as $keys1 => $charts1){
	$leadss=GetCounsellorName($keys1);
	$chttt .="['".$leadss."-".$charts1."',".$charts1."],";	
	}
	$chttt = rtrim($chttt,',');
	?>
    <script type="text/javascript">
      google.charts.load("current", {packages:["corechart"]});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Task', 'Callers'],
          <?php echo $chttt;?>
        ]);

        var options = {
          title: 'Leads Report According to Callers',
          is3D: true,
        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart_3ddd'));
        chart.draw(data, options);
      }
    </script>
 
    <div id="piechart_3ddd" style="min-width:400px; height:350px; margin: 0 auto"></div>
 
  </div>
<div class="col-sm-6">
	
	<?php $arrs='';
	foreach($leads as $lead){
		$arrs .=$lead->source_id.',';
	}
    $arrs=rtrim($arrs,',');
	$arrs1=explode(',',$arrs);
	$aas=(array_count_values($arrs1));
	$chtt='';
	foreach($aas as $keys => $charts){
	$leads=getSource($keys);
	$chtt .="['".$leads[0]->source."-".$charts."',".$charts."],";	
	}
	$chtt = rtrim($chtt,',');
	?>
    <script type="text/javascript">
      google.charts.load("current", {packages:["corechart"]});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Task', 'lead Source'],
          <?php echo $chtt;?>
        ]);

        var options = {
          title: 'Leads Report According to Source',
          is3D: true,
        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart_3dd'));
        chart.draw(data, options);
      }
    </script>
 
    <div id="piechart_3dd" style="min-width:400px; height:350px; margin: 0 auto"></div>
 
  </div>
	

	<?php }?>
	</div>
  </div>
</div>
</section>
<style>
.footnav{display:none;}
@media(max-width:750px){
.footnav{display:block;}	
}
</style>

<div style="width:100%;padding:16px;background:#1a20c3;color:#fff;position:fixed;bottom:0px;border-top:3px solid #d01525" class="footnav">
<?php if($userid[0]['user_type']==1){?>
<a href="<?php echo base_url();?>home/dashboard" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-dashboard" > Dashboard</i></a>
<a href="<?php echo base_url();?>home/lead_info" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-list-alt" > Leads</i></a>
<a href="<?php echo base_url();?>home/report" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-bar-chart" > Report</i></a>
<a href="<?php echo base_url();?>home/logout" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-sign-out" > logout</i></a>
<?php } ?>
<?php if($userid[0]['user_type']==2){?>
<a href="<?php echo base_url();?>home/dashboard" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-dashboard" > Dashboard</i></a>
<a href="<?php echo base_url();?>home/lead_info" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-list-alt" > Leads</i></a>
<a href="<?php echo base_url();?>home/my_team" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-list" > My Team</i></a>
<a href="<?php echo base_url();?>home/logout" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-sign-out" > logout</i></a>
<?php } ?>
<?php if($userid[0]['user_type']==3){?>
<a href="<?php echo base_url();?>home/dashboard" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-dashboard" > Dashboard</i></a>
<a href="<?php echo base_url();?>home/lead_info" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-list-alt" > Leads</i></a>
<a href="<?php echo base_url();?>home/logout" style="color:#fff;margin:0 15px 0 15px;"><i class="fa fa-sign-out" > logout</i></a>
<?php } ?>
</div>
 <!-- footer -->
		  <div class="footer">
			<div class="wthree-copyright">
			 	<p >Develped by <a href="https://www.tenacioushub.com/" target="_blank"><img src="<?php echo base_url;?>/assets/images/logo.png" style="height:25px;"/></a></p>
			</div>
		  </div>
  <!-- / footer -->
</section>
<style>
.btnh{border: 1px solid #ccc;
padding: 5px;
border-radius: 100%;}
</style>
<!--main content end-->
</section>

<script src="<?php echo base_url();?>/assets/js/bootstrap.js"></script>
<script src="<?php echo base_url();?>/assets/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="<?php echo base_url();?>/assets/js/scripts.js"></script>
<script src="<?php echo base_url();?>/assets/js/jquery.slimscroll.js"></script>
<script src="<?php echo base_url();?>/assets/js/jquery.nicescroll.js"></script>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="js/flot-chart/excanvas.min.js"></script><![endif]-->
<script src="<?php echo base_url();?>/assets/js/jquery.scrollTo.js"></script>
</body>
</html>
