<?php
$msg = '';
include("include/settings.php");
include("checksession.php");

$salesmaster = $mysqli->prepare("select * from cdi_usermaster where user_type='sales_exec' order by user_creationdate desc");
$salesmaster->execute();
$salesresult = $salesmaster->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="">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

    <title>Call Scheduling - 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">Manage Call Scheduling</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">
				           <center><p class="errormessage" id="errormessage"><?php echo $msg ?></p></center>
				  <h3 class="box-title">Manage Call Scheduling</h3>
				</div>
			
					<div class="box-body">
						<div class="row">
						</div>
						<div class="row">
						  <div class="col-md-4">
							<div class="form-group">
							   <input placeholder='Start Date' type="date" 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="date" id="txtToDate" name="txtToDate" class="form-control" autocomplete='off' onchange="getLeads()"/>
                   
							</div>
						  </div>
						     <div class="col-md-4">
                        <select id="ddlUserId" name="ddlUserId" class="form-select" onchange="getLeads()">
                            <option value="0">All Executives</option>
                            <?php
                            while ($e_userrow = mysqli_fetch_object($salesresult)) {
                                ?>
                                <option value="<?php echo $e_userrow->user_id ?>"><?php echo $e_userrow->user_full_name ?></option>
                                <?php
                            }
                            ?>
                        </select>
                    </div>
						</div>
					</div>
			
			
				<!-- /.box-header -->

				<!-- /.box-body -->
			  </div>
			  <!-- /.box -->


			  <!-- /.box -->          
			</div>
			<!-- /.col -->
		  </div>
		  <!-- /.row -->
		</section>
		<!-- /.content -->
			<div class="col-md-2">
                        <img src="../img/small-loader.gif" style="display:none" id="loading"/>
                    </div>
				
		
			 <div id="ajaxcoursedata">

                </div>
	  
	  </div>
  </div>
  <!-- /.content-wrapper -->
 <script>
    var page_skip = 1;
    function getLeads(page_no=null) {

        if((page_no != undefined) && (page_no != '') && (page_no != 0)) {
            page_skip = page_no;
        }

        var txtFromDate = $('#txtFromDate').val();
        var txtToDate = $('#txtToDate').val();
        var ddlUserId = $('#ddlUserId').val();

        $('#loading').css('display', '');

        $.ajax({
            url: 'ajax_call_schedule.php',
            type: 'post',
            data: {
                page_skip:page_skip,
                ddlUserId: ddlUserId,
                txtFromDate: txtFromDate,
                txtToDate: txtToDate,
            },
            datatype: 'html',
            success: function (rsp) {
                $('#ajaxcoursedata').html(rsp);
                $('#loading').css('display', 'none');
            }
        });
    }
    getLeads(1);

    function getLeadsPagination(page_skip) {

        $('#loading').css('display', '');
        $.ajax({
            url: 'ajax_call_schedule.php',
            type: 'post',
            data: {"page_skip": page_skip},
            datatype: 'html',
            success: function (rsp) {
                $('#ajaxcoursedata').html(rsp);
                $('#loading').css('display', 'none');
            }
        });
    }

    $(document).ready(function () {
        $("#txtFromDate,#txtToDate").datepicker({
            dateFormat: 'yy-mm-dd',
            // minDate: 0, // 0 days offset = today
        });
    });
</script>
<?php include('./include/footer.php'); ?>