<?php

// Fetch records

$conn=new MySQLi("localhost","karan_live","Sailor@123!","karan_live");  //Live Rishta DB

$sql = "SELECT * FROM caste";
$caste_result = mysqli_query($conn, $sql);

$sql = "SELECT * FROM sub_caste";
$sub_result = mysqli_query($conn, $sql);

$sql = "SELECT * FROM status";
$status_result = mysqli_query($conn, $sql);

$sql = "SELECT * FROM source";
$source_result = mysqli_query($conn, $sql);

$sql = "SELECT * FROM res_status";
$res_result = mysqli_query($conn, $sql);


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

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

if (isset($_GET['eid']) && trim($_GET['eid']) != null) {
    $condition = 'lead_allocated_to = ' . $_GET['eid'];
} else {
    $_GET['eid'] = '0';
}

if (isset($_GET['type']) && trim($_GET['type']) != null) {
    if (trim($condition) != null) {
        $condition = $condition . ' and ';
    }
    $condition .= 'lead_status = "' . $_GET['type'] . '"';
} else {
    $_GET['type'] = '0';
}

if (trim($condition) != null) {
    $condition = $and . ' ' . $condition;
}

$userresulttotaldata = $mysqli->prepare("select count(*) from rishta_leadmaster where lead_type='rishta_lead' " . $condition . " order by lead_created desc");
$userresulttotaldata->execute();
$userresulttotaldata->bind_result($total_records);
$userresulttotaldata->fetch();
$userresulttotaldata->close();

$usermaster = $mysqli->prepare("select *,(select count(*) from cdi_followups where lead_id = rishta_leadmaster.lead_id) as followcount  from rishta_leadmaster where lead_type='rishta_lead' " . $condition . " order by lead_created desc limit 100");
$usermaster->execute();
$userresult = $usermaster->get_result();

$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="">


	<title>Manage Bulk Leads - Rishta Depot</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

    <script src="js/countrystatecity.js"></script>

	<?php include('./include/meta.php'); ?>
		<?php include('./include/sidebar.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">Leads</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 Rishta Leads</li>
								<li class="breadcrumb-item active" aria-current="page">Leads</li>
							</ol>
						</nav>

					</div>
					

				</div>

			</div>

		</div>

		<!-- Main content -->
		<section class="content">
			<div class="row">
				<div class="col-lg-4 col-12">
					<div class="box">
						<div class="box-header with-border">
							<h3 class="box-title">Filters</h3>
						</div>
						<!-- /.box-header -->
							<div class="box-body">
						
								<div class="row">
									<div class="col-md-6">
											<div class="form-group">
								<label class="form-label">Lead Status</label>
								<select id="ddlLeadType" name="ddlLeadType" class="form-select" onchange="getLeads()">
									<?php if (mysqli_num_rows($status_result) > 0): ?>
										<?php while ($row = mysqli_fetch_assoc($status_result)): ?>
											<option value="<?php echo $row['id']; ?>" <?php echo $_GET['type'] == $row['name'] ? 'selected' : ''; ?>>
												<?php echo $row['name']; ?>
											</option>
										<?php endwhile; ?>
									<?php else: ?>
										<option value="">No status options found</option>
									<?php endif; ?>
								</select>
							</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Executives</label>
						       <select id="ddlUserId" name="ddlUserId" class="form-select" onchange="getLeads()">
                            <option value="0" <?php echo $_GET['eid'] == 0 ? 'selected' : ''; ?>>All Executives</option>
                            <?php
                            while ($e_userrow = mysqli_fetch_object($salesresult)) {
                                ?>
                                <option value="<?php echo $e_userrow->user_id ?>" <?php echo $_GET['eid'] == $e_userrow->user_id ? 'selected' : ''; ?>><?php echo $e_userrow->user_full_name ?></option>
                                <?php
                            }
                            ?>
                        </select>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">Country</label>
											 <select name="txtcountry" class="countries form-select" id="countryId" onchange="getLeads()">
                            <option value="">All Country</option>
                        </select>
										</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">State</label>
										  <select name="txtstate" class="states form-select" id="stateId" onchange="getLeads()">
                            <option value="">All State</option>
                        </select>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">City</label>
									  <select name="txtcity" class="cities form-select" id="cityId" onchange="getLeads()">
                            <option value="">All City</option>
                        </select>
										</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Gender</label>
										    <select class="form-select" name="searchGender" id="searchGender" onchange="getLeads()">
                                            <option value="">All Gender</option>
                                            <option value="Male">Male</option>
                                            <option value="Female">Female</option>
                                        </select>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Member Status</label>
									     <select class="form-select" name="searchMemberStatus" id="searchMemberStatus" onchange="getLeads()">
                                        <option value="">All Member Status</option>
                                        <option value="#2">#2</option>
                                        <option value="#3">#3</option>
                                        <option value="#4">#4</option>
                                    </select>
										</div>
									</div>
									<div class="col-md-6">
                              <div class="form-group">
                                <label class="form-label">All Caste</label>
                                <select class="form-select" name="searchCaste" id="searchCaste" onchange="getLeads()">
                                    <option value="">All Caste</option>
                                    <?php if (mysqli_num_rows($caste_result) > 0): ?>
                                        <?php while ($row = mysqli_fetch_assoc($caste_result)): ?>
                                            <option value="<?php echo $row['name']; ?>">
                                                <?php echo $row['name']; ?>
                                            </option>
                                        <?php endwhile; ?>
                                    <?php else: ?>
                                        <option value="">No caste options found</option>
                                    <?php endif; ?>
                                </select>
                            </div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6">
										     <div class="form-group">
                                <label class="form-label">All Residency Status</label>
                               								    <select class="form-select" name="searchResidencyStatus" id="searchResidencyStatus" onchange="getLeads()">
                                   <option value="">All Residency Status</option>
                                    <?php if (mysqli_num_rows($res_result) > 0): ?>
                                        <?php while ($row = mysqli_fetch_assoc($res_result)): ?>
                                            <option value="<?php echo $row['name']; ?>">
                                                <?php echo $row['name']; ?>
                                            </option>
                                        <?php endwhile; ?>
                                    <?php else: ?>
                                        <option value="">No Residency options found</option>
                                    <?php endif; ?>
                                </select>
                            </div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Currency</label>
									   <select class="form-select" name="searchCurrency" id="searchCurrency" onchange="getLeads()">
                            <option value="">All Currency</option>
                            <option value="INR">INR</option>
                            <option value="US Dollar">US Dollar</option>
                            <option value="Canadian Dollar">Canadian Dollar</option>
                            <option value="Pound">Pound</option>
                            <option value="USD">USD</option>
                            <option value="CAD">CAD</option>
                            <option value="GBP">GBP</option>
                            <option value="AUD">AUD</option>
                        </select>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Min Age</label>
						  <select class="form-select" name="searchMinAge" id="searchMinAge" onchange="getLeads()">
                            <option value="">All Min Age</option>
                            <?php for ($i = 18; $i <= 75; $i++) { ?>
                                <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                            <?php } ?>
                        </select>
										</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Max Age</label>
					    <select class="form-select" name="searchMaxAge" id="searchMaxAge" onchange="getLeads()">
                            <option value="">All Max Age</option>
                            <?php for ($i = 18; $i <= 75; $i++) { ?>
                                <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                            <?php } ?>
                        </select>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Min Foot Height</label>
									      <select class="form-select" name="searchMinFootHeight" id="searchMinFootHeight" onchange="getLeads()">
                                    <option value="">All Min Foot Height</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                    <option value="7">7</option>
                                </select>
										</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Min Inches Height</label>
									 <select class="form-select" name="searchMinInchHeight" id="searchMinInchHeight" onchange="getLeads()">
                                    <option value="">All Min Inches Height</option>
                                    <?php for ($i = 0; $i < 12; $i++) { ?>
                                        <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                                    <?php } ?>
                                </select>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Max Foot Height</label>
										    <select class="form-select" name="searchMaxFootHeight" id="searchMaxFootHeight" onchange="getLeads()">
                                    <option value="">All Max Foot Height</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                    <option value="7">7</option>
                                </select>
										</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">All Max Inches Height</label>
								    <select class="form-select" name="searchMaxInchHeight" id="searchMaxInchHeight" onchange="getLeads()">
                                    <option value="">All Max Inches Height</option>
                                    <?php for ($i = 0; $i < 12; $i++) { ?>
                                        <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                                    <?php } ?>
                                </select>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6">
										   <div class="form-group">
                           			<label class="form-label">Religion</label>
									       <select class="form-select" name="religion" id="religion" onchange="getLeads()">
                                    <option value="">All Caste</option>
                                    <?php if (mysqli_num_rows($sub_result) > 0): ?>
                                        <?php while ($row = mysqli_fetch_assoc($sub_result)): ?>
                                            <option value="<?php echo $row['name']; ?>">
                                                <?php echo $row['name']; ?>
                                            </option>
                                        <?php endwhile; ?>
                                    <?php else: ?>
                                        <option value="">No Religion options found</option>
                                    <?php endif; ?>
                                </select>
                            </div>
									</div>
									<div class="col-md-6">
       <div class="form-group">
                                <label class="form-label">Lead Source</label>
                                <select class="form-select" name="source" id="source" onchange="getLeads()">
                                    <option value="">Source</option>
                                    <?php 
                                    if (mysqli_num_rows($source_result) > 0) {
                                        while($row = mysqli_fetch_assoc($source_result)) { ?>
                                            <option value="<?php echo $row['name']; ?>">
                                               <?php echo $row['name']; ?> 
                                            </option> 
                                        <?php }
                                    } ?>
                                </select>
                            </div>
									</div>
								</div>
							</div>
							<!-- /.box-body -->
							<div class="box-footer">
								<button type="button" class="btn btn-warning me-1">Cancel
								</button>
								<button type="submit" class="btn btn-primary">Apply Filter
								</button>
							</div>
					
					</div>
					<!-- /.box -->
				</div>

				<div class="col-lg-8 col-12">
					<div class="box">
						<div class="box-header with-border">
							<h3 class="box-title">Total Leads</h3>
						</div>
						<form class="form">
							<div class="box-body">
								<div class="row">
									<div class="col-md-4">
										<div class="form-group">
											<label class="form-label">Start Date</label>
										<input placeholder='Start Date' type="datetime-local" id="txtFromDate" value="dd------yy" name="txtFromDate" class="form-control" autocomplete='off' onchange="getLeads()"/>
										</div>
									</div>
									<div class="col-md-4">
										<div class="form-group">
											<label class="form-label">End Date</label>
									 <input placeholder='End Date' type="datetime-local"  id="txtToDate" value="dd------yy" name="txtToDate" class="form-control" autocomplete='off' onchange="getLeads()"/>
										</div>
									</div>
									<div class="col-md-4">
										<div class="form-group">
											<label class="form-label">Email/Phone/Name</label>
										<input type="text" id="txtSearch" name="txtSearch" class="form-control" placeholder="Email/Phone/Name" onchange="getLeads()"/>
										</div>
									</div>
								</div>
								<div class="box-footer">
									<button type="submit" style="margin-left:-20px;" class="btn btn-warning me-1"><a href="add-new.php">Add New Leads</a></button>
							<button type="submit" style="margin-left:20px;" class="btn btn-warning me-1"><a href="filter-manage-bulk-leads.php">Reset Filter</a></button>
								</div>
							</div>
						</form>
						
						          <div class="row">
                    <div class="col-md-4">
                        <label style="display: inline-block;width: 50%; margin-left:10px;" class="form-control">Allocate to</label>
                        <select id="ddlLeadAllocated" name="ddlLeadAllocated" class="form-select" style="display: inline-block;width: 78%; margin:20px;">
                            <option value="">select allocate</option>
                            <?php
                            mysqli_data_seek($salesresult, 0);
                            while ($a_userrow = mysqli_fetch_object($salesresult)) {
                                ?>
                                <option value="<?php echo $a_userrow->user_id ?>"><?php echo $a_userrow->user_full_name ?></option>
                                <?php
                            }
                            ?>
                        </select>
                    </div>
                    <div class="col-md-2">
                        <button type="button" class="btn btn-primary" id="btn_update_allocate">Update</button>
                    </div>
                 
                </div>
						
						
						 <div class="col-md-6" style="margin-bottom:5px;">
                            <h4 class="form-control">No. of Leads to Transfer: <?php echo mysqli_num_rows($userresult) ?></h4>
                        </div>
						<!-- /.box-header -->
						<div class="box-body" style="margin-top: -30px;" id="ajaxcoursedata">
							<div class="table-responsive">
							     <?php
                            if (mysqli_num_rows($userresult) > 0) {
                                ?>
								<table  class="table table-bordered table-striped">
									<thead>
										<tr>
										  <th>Sr.No</th>
                                        <th><input type='checkbox' id='checkAll'> Check</th>
                                        <th>Disposition</th>
                                        <th>Allocated To</th>
                                        <th>Profile Name</th>
                                        <th>Profile E-mail Id</th>
										</tr>
									</thead>
				         <tbody>
                                    <?php
                                    $i = 0;
                                    while ($userrow = mysqli_fetch_object($userresult)) {
                                        switch ($userrow->disposition) {
                                            case 'fresh':
                                                $the_alert_class = 'alert-info';
                                                break;
                                            case 'processing':
                                                $the_alert_class = 'alert-warning';
                                                break;
                                            case 'deal':
                                                $the_alert_class = 'alert-success';
                                                break;
                                            case 'lost':
                                                $the_alert_class = 'alert-danger';
                                                break;
                                            default:
                                                $the_alert_class = '';
                                        }
                                        $i++;
                                        ?>
                                        <tr class="text-center alert <?php echo $the_alert_class ?>">
                                            <td><?php echo $i; ?></td>
                                            <td><input type="checkbox" class="chk_lead_allocated" id="chk_lead_allocated_<?php echo $userrow->lead_id ?>" name="lead_allocated[]" value="<?php echo $userrow->lead_id ?>"></td>
                                            <td class="text-left"><?php echo $userrow->disposition ?></td>
                                            <td>
                                                <select name="" class="form-select" onchange="changeLeadAllocation(this.value,<?php echo $userrow->lead_id ?>)">
                                                    <?php
                                                    mysqli_data_seek($salesresult, 0);
                                                    while ($a_userrow = mysqli_fetch_object($salesresult)) {
                                                        ?>
                                                        <option value="<?php echo $a_userrow->user_id ?>" <?php echo $userrow->lead_allocated_to == $a_userrow->user_id ? 'selected' : ''; ?>><?php echo $a_userrow->user_full_name ?></option>
                                                        <?php
                                                    }
                                                    ?>
                                                </select>
                                            </td>
                                            <td class="text-left"><a style="color:blue;" href="edit-leads.php?leadid=<?php echo $userrow->lead_id ?>"><?php echo $userrow->profile_name ?></a></td>
                                            <td><?php echo $userrow->email_id ?></td>
                                            <!--td><?php //echo $userrow->contact_no ?></td>
                                            <td><?php //echo $userrow->source ?></td>
                                            <td><?php //echo date("m/d/Y", strtotime($userrow->lead_created_on)) ?></td>
                                            <?php
                                          //  if ($userrow->lead_type == 'rishta_lead') {
                                                ?>
                                                <td><a href="followlead.php?leadid=<?php //echo $userrow->lead_id ?>&is_p=0"><?php //echo $userrow->followcount ?> Follow Ups</a></td>
                                                <td><a href="edit-rishta-lead.php?leadid=<?php //echo $userrow->lead_id ?>">Edit/View</a></td>
                                                <?php
                                          //  } else {
                                                ?>
                                                <td><a href="followlead.php?leadid=<?php //echo $userrow->lead_id ?>&is_p=1"><?php //echo $userrow->followcount ?> Follow Ups</a></td>
                                                <td><a href="edit-rishta-lead.php?leadid=<?php //echo $userrow->lead_id ?>">Edit/View</a></td-->
                                                <?php
                                         //   }
                                            ?>
                                        </tr>
                                        <?php
                                    }
                                    ?>
                                    </tbody>
                                    </table>
                  
								
							</div>
						
                                    <nav>
                                        <ul class="pagination">
                                            <?php
                                            $total = ceil($total_records / 50);
                                            for ($i = 1; $i <= $total; $i++) {
                                                ?>
                                                <li><a  style="background-color:yellow;" onclick='getLeadsPagination(<?php echo $i ?>)' href="javascript:void(0)" class="pagelink <?php if ($i == 1) {
                                                        echo "active";
                                                    } ?>"><?php echo $i ?></a></li>
                                                <?php
                                            }
                                            ?>
                                        </ul>
                                    </nav>
                              
                                <?php
                            } else {
                                ?>
                                <div class="alert alert-danger">
                                    <strong>Warning!</strong> You have no leads.
                                </div>
                                <?php
                            }
                            ?>
                           
						</div>
					</div>
					<!-- /.box -->
				</div>



			</div>


	</div>

	<!-- /.box-footer -->
	</form>
	
</div>

<!-- /.box-header -->

<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!--/.col (right) -->
</div>
<!-- /.row -->

</section>
<!-- /.content -->
</div>
</div>
<!-- /.content-wrapper -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<script src="https://rishtasite.in/sales_admin/js/jquery.js" type="text/javascript"></script>
<script src="https://rishtasite.in/sales_admin//js/jquery-ui.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.1.62/jquery.inputmask.bundle.js"></script>


<script type="text/javascript">

    var ajaxLeadData = null;
    var getSelectedLeadId = null;

    $(document).ready(function () {

        ajaxLeadData = function () {

            // Check/Uncheck ALl
            $('#checkAll').change(function () {

                if ($(this).is(':checked')) {

                    $('input[name="lead_allocated[]"]').prop('checked', true);

                } else {

                    $('input[name="lead_allocated[]"]').each(function () {
                        $(this).prop('checked', false);
                    });
                }
            });

            // Checkbox click
            $('input[name="lead_allocated[]"]').click(function () {

                var total_checkboxes = $('input[name="lead_allocated[]"]').length;
                var total_checkboxes_checked = $('input[name="lead_allocated[]"]:checked').length;

                if (total_checkboxes_checked == total_checkboxes) {

                    $('#checkAll').prop('checked', true);

                } else {

                    $('#checkAll').prop('checked', false);
                }
            });
        };
        ajaxLeadData();


        getSelectedLeadId = function () {

            var ar_leadID = [];

            $('div#ajaxcoursedata table tbody tr td input[name="lead_allocated[]"]').each(function () {

                var $this = $(this);
                if ($this.prop("checked") == true) {

                    ar_leadID.push($this.val());
                }
            });

            return ar_leadID;
        };

        $('#btn_update_allocate').click(function () {


            var executive_id = $('#ddlLeadAllocated').val();

            var ar_leadID = [];
            ar_leadID = getSelectedLeadId();

            if (ddlLeadAllocated != '') {

                if (ar_leadID.length > 0) {

                    $('#loading').css('display', '');
                    $.ajax({
                        url: 'allocate_new.php',
                        type: 'post',
                        data: {
                            action_for: 'lead_allocate',
                            action_type: 'multiple',
                            executive_id: executive_id,
                            lead_id: ar_leadID
                        },
                        datatype: 'html',
                        success: function (rsp) {

                            window.location.reload();
                            $('#loading').css('display', 'none');
                        }
                    });

                } else {

                    alert("Please select any leads.");
                }
            } else {
                alert("Please select any allocate.");
            }
        });
    });
</script>
<script>
    function getLeads() {

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

        var countryId = $('#countryId').val();
        var stateId = $('#stateId').val();
        var cityId = $('#cityId').val();
        var searchGender = $('#searchGender').val();
        var searchMemberStatus = $('#searchMemberStatus').val();
        var searchCaste = $('#searchCaste').val();
        var searchResidencyStatus = $('#searchResidencyStatus').val();

        var searchCurrency = $('#searchCurrency').val();

        var searchMinAge = $('#searchMinAge').val();
        var searchMaxAge = $('#searchMaxAge').val();

        var searchMinFootHeight = $('#searchMinFootHeight').val();
        var searchMinInchHeight = $('#searchMinInchHeight').val();

        var searchMaxFootHeight = $('#searchMaxFootHeight').val();
        var searchMaxInchHeight = $('#searchMaxInchHeight').val();

        $('#loading').css('display', '');
        $.ajax({
            url: 'ajaxgetassign.php',
            type: 'post',
            data: {
                ddlUserId: ddlUserId,
                ddlLeadMasterType: 'rishta_lead',
                ddlLeadType: ddlLeadType,
                txtFromDate: txtFromDate,
                txtToDate: txtToDate,
                txtSearch: txtSearch,
                countryId: countryId,
                stateId: stateId,
                cityId: cityId,
                searchGender: searchGender,
                searchMemberStatus: searchMemberStatus,
                searchCaste: searchCaste,
                searchResidencyStatus: searchResidencyStatus,
                searchCurrency: searchCurrency,
                searchMinAge: searchMinAge,
                searchMaxAge: searchMaxAge,
                searchMinFootHeight: searchMinFootHeight,
                searchMinInchHeight: searchMinInchHeight,
                searchMaxFootHeight: searchMaxFootHeight,
                searchMaxInchHeight: searchMaxInchHeight,
            },
            datatype: 'html',
            success: function (rsp) {

                $('#ajaxcoursedata').html(rsp);
                $('#loading').css('display', 'none');

                ajaxLeadData();
                getSelectedLeadId();
            }
        });
    }

    function changeLeadAllocation(executive_id, lead_id) {
        $('#loading').css('display', '');
        $.ajax({
            url: 'allocate_new.php',
            type: 'post',
            data: {
                action_for: 'lead_allocate',
                action_type: 'single',
                executive_id: executive_id,
                lead_id: lead_id
            },
            datatype: 'html',
            success: function (rsp) {
                $('#loading').css('display', 'none');
            }
        });
    }

  function getLeadsPagination(page_skip) {

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

        var countryId = $('#countryId').val();
        var stateId = $('#stateId').val();
        var cityId = $('#cityId').val();
        var searchGender = $('#searchGender').val();
        var searchMemberStatus = $('#searchMemberStatus').val();
        var searchCaste = $('#searchCaste').val();
        var searchResidencyStatus = $('#searchResidencyStatus').val();

        var searchCurrency = $('#searchCurrency').val();
        var searchDisposition = $('#searchDisposition').val();

        var searchMinAge = $('#searchMinAge').val();
        var searchMaxAge = $('#searchMaxAge').val();

        var searchMinFootHeight = $('#searchMinFootHeight').val();
        var searchMinInchHeight = $('#searchMinInchHeight').val();

        var searchMaxFootHeight = $('#searchMaxFootHeight').val();
        var searchMaxInchHeight = $('#searchMaxInchHeight').val();

         var religion = $('#religion').val();
         
          var source = $('#source').val();

        $('#loading').css('display', '');
        $.ajax({
            url: 'https://rishtasite.in/lead-crm/crm/ajaxgetrishtaleads.php',
            type: 'post',
            data: {
                ddlUserId: ddlUserId,
                ddlLeadMasterType: 'rishta_lead',
                ddlLeadType: ddlLeadType,
                txtFromDate: txtFromDate,
                txtToDate: txtToDate,
                txtSearch: txtSearch,
                countryId: countryId,
                stateId: stateId,
                cityId: cityId,
                searchGender: searchGender,
                searchMemberStatus: searchMemberStatus,
                searchCaste: searchCaste,
                searchResidencyStatus: searchResidencyStatus,
                searchCurrency: searchCurrency,
                searchMinAge: searchMinAge,
                searchMaxAge: searchMaxAge,
                searchMinFootHeight: searchMinFootHeight,
                searchMinInchHeight: searchMinInchHeight,
                searchMaxFootHeight: searchMaxFootHeight,
                searchMaxInchHeight: searchMaxInchHeight,
                religion: religion,
                source: source,
                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>
<style>
 .pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.42857143;color:#337ab7;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-top-left-radius:4px;border-bottom-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}.pagination>li>a:focus,.pagination>li>a:hover,.pagination>li>span:focus,.pagination>li>span:hover{z-index:2;color:#23527c;background-color:#eee;border-color:#ddd}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{z-index:3;color:#fff;cursor:default;background-color:#337ab7;border-color:#337ab7}.pagination>.disabled>a,.pagination>.disabled>a:focus,.pagination>.disabled>a:hover,.pagination>.disabled>span,.pagination>.disabled>span:focus,.pagination>.disabled>span:hover{color:#777;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px;line-height:1.3333333}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-top-left-radius:6px;border-bottom-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px;line-height:1.5}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-top-left-radius:3px;border-bottom-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px}.pager{padding-left:0;margin:20px 0;text-align:center;list-style:none}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;border-radius:15px}.pager li>a:focus,.pager li>a:hover{text-decoration:none;background-color:#eee}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:focus,.pager .disabled>a:hover,.pager .disabled>span{color:#777;cursor:not-allowed;background-color:#fff}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}a.label:focus,a.label:hover{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.btn .label{position:relative;top:-1px}.label-default{background-color:#777}.label-default[href]:focus,.label-default[href]:hover{background-color:#5e5e5e}   
</style>
<?php include('./include/footer.php'); ?>