<?php
$msg = '';

include("include/settings.php");
include("checksession.php");

$and = 'and';
$condition = '';


$memberdetailmaster = $mysqli->prepare("select * from cdi_usermaster where user_id=?");
$memberdetailmaster->bind_param("i", $_GET['userid']);
$memberdetailmaster->execute();
$memberdetailmaster = $memberdetailmaster->get_result();
$userrow = mysqli_fetch_object($memberdetailmaster);

$extension = $userrow->extension3;	

$userresulttotaldata = $mysqli->prepare("select count(*) from rishta_3cx_calls where agentextension='$extension' order by id desc");
$userresulttotaldata->execute();
$userresulttotaldata->bind_result($total_records);
$userresulttotaldata->fetch();
$userresulttotaldata->close();


$usermaster = $mysqli->prepare("select count(*) from cdi_usermaster where user_id=?");
$usermaster->bind_param("i", $_GET['userid']);
$usermaster->execute();
$usermaster->bind_result($membercount);
$usermaster->fetch();
$usermaster->close();

if ($membercount == 0) {
    header("location:home.php");
}




//$usermaster = $mysqli->prepare("select * from rishta_new_api where (destination = '$extension') OR (source = '$extension') OR (dst_channel LIKE '%$extension%') ");

$usermaster = $mysqli->prepare("select * from  rishta_3cx_calls where (agentextension ='$extension') order by id desc limit 100");
$usermaster->execute();
$userresult = $usermaster->get_result();





?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>3CX Report - Rishta Depot</title>
  
	
<?php include('./include/meta.php'); ?>

</head>

	
<?php include('./include/header.php'); ?>
  
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
	  <div class="container-full">
		<!-- Content Header (Page header) -->
		<div class="content-header">
			<div class="d-flex align-items-center">
				<div class="me-auto">
					<h4 class="page-title">Reports</h4>
					<div class="d-inline-block align-items-center">
						<nav>
							<ol class="breadcrumb">
								<li class="breadcrumb-item"><a href="#"><i class="mdi mdi-home-outline"></i></a></li>
								<li class="breadcrumb-item" aria-current="page">Sales Target Dialer Report</li>
								<li class="breadcrumb-item active" aria-current="page">Reports</li>
							</ol>
						</nav>
					</div>
				</div>
				
			</div>
		</div>

		<!-- Main content -->
		<section class="content">
		  <div class="row">
			<div class="col-12">

			 <div class="box">
				<div class="box-header with-border">
				  <h3 class="box-title">Target 3CX Report</h3>
				</div>
				<form class="form">
					<div class="box-body">
						<div class="row">
						  <div class="col-md-12">
							<div class="form-group">
								<label class="form-label">Email Id</label>
							        <input type="text" id="txtEmailId" name="txtEmailId" class="form-control" value="<?php echo $userrow->user_email_id ?>"/>
                            <input type="hidden" id="txtHfEmailId" name="txtHfEmailId" class="form-control-custom" value="<?php echo $userrow->user_email_id ?>"/>
                           
							 <input type="hidden" id="ddlUserIds" name="ddlUserIds" class="form-control-custom" value="<?php echo $extension ?>"/>
							 
							</div>
						  </div>
						</div>
						<div class="row">
						  <div class="col-md-4">
							<div class="form-group">
					  <input placeholder='Start Date' type="text" id="txtFromDate" name="txtFromDate" class="form-control" autocomplete='off' onchange="getLeads()"/>
                    
							</div>
						  </div>
						  <div class="col-md-4">
							<div class="form-group">
				<input placeholder='End Date' type="text" id="txtToDate" name="txtToDate" class="form-control" autocomplete='off' onchange="getLeads()"/>
                    
							</div>
						  </div>
						  <div class="col-md-4">
							<div class="form-group">
							<input type="text" id="txtSearch" name="txtSearch" class="form-control" placeholder="Phone Number" onchange="getLeads()"/>
							</div>
						  </div>
						</div>
						<div class="box-footer">
							<!--button type="button" class="btn btn-warning me-1">Fresh</button-->
						    <button type="submit" class="btn btn-primary">Inbound Call</button>
							<button type="button" class="btn btn-primary">Outbound Call</button>
							<button type="button" class="btn btn-primary">7 Min</button>
						</div>
					</div>
				</form>
				<!-- /.box-header -->
				<div class="box-body" id="ajaxcoursedata">
					<div class="table-responsive">
					    	    	<?php
										if(mysqli_num_rows($userresult)>0)
										{
											?>
					  <table id="example1" class="table table-bordered table-striped">
						<thead>
							<tr>
								<th>Sr.No</th>
								<th>Agent Name</th>
								<th>Inbound</th>
								<th>Outbound</th>
								<th>Fresh</th>
								<th>7+</th>
							</tr>
						</thead>
						<tbody>
		        <?php
													$i=0;
													while($userrow=mysqli_fetch_object($userresult))
													{
														$i++;
														?>
													
															<tr class="text-center">
																<td><?php echo $i; ?></td>
															
																	    <td><a href="dialers_report.php?userid=<?php echo $userrow->user_id ?>"><?php echo $userrow->	user_full_name ?></a></td>
												
																<td class="text-left"><?php echo $userrow-> incount ?></td>
																<td class="text-left"><?php echo  $userrow-> outcount ?></td>
																	<td class="text-left"><?php echo  $userrow-> freash ?></td>
																		<td class="text-left"><?php echo  $userrow-> more ?></td>
																
																
																
															</tr>
																<?php
														}
													?>
						</tbody>
						
					  </table>
					  	  		<?php
										}
										else
										{
											?>
												<div class="alert alert-danger">
													<strong>Warning!</strong> You have no leads.
												</div>
											<?php
										}
									?>
					</div>
				</div>
				<!-- /.box-body -->
				<!-- /.box-body -->
			  </div>
			  <!-- /.box -->


			  <!-- /.box -->          
			</div>
			<!-- /.col -->
		  </div>
		  <!-- /.row -->
		</section>
		<!-- /.content -->
	  
	  </div>
  </div>
  <!-- /.content-wrapper -->
	
<?php include('./include/footer.php'); ?>