<?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 .= 'disposition = "' . $_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();



$salesmaster = $mysqli->prepare("select * from cdi_usermaster where user_type='sales_exec' order by user_creationdate desc");
$salesmaster->execute();
$salesresult = $salesmaster->get_result();

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

?>
<!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://code.jquery.com/jquery-3.6.0.min.js"></script>



	<title>Manage Rishta Leads - Rishta Depot</title>

	
		<!-- Vendors Style-->
	<link rel="stylesheet" href="../src/css/vendors_css.css">
	  
	<!-- Style-->  
	<link rel="stylesheet" href="../src/css/style.css">
	<link rel="stylesheet" href="../src/css/skin_color.css">
	
<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>
							<li>		 <button id="toggleButton" style="margin-left:10px;" class="btn btn-primary float-end">
                        Show/Hide Filters
                    </button></li>
                    	<li>
                    	<button type="submit" style="margin-left:10px;" class="btn btn-warning me-1"><a href="touched-leads.php">Multi Touched Filter</a></button>		
			</li>
			<li>
		<button type="submit" style="margin-left:10px;" class="btn btn-warning me-1"><a href="lead-created.php">Multi Lead Created</a></button>		
			</li>
				<li>
		<button type="submit" style="margin-left:10px;" class="btn btn-warning me-1"><a href="set-filter.php">Multi Set Filter</a></button>		
			</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" id="filterContent">
						<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">Leads Created</label>
										    <select class="form-select" name="touched" id="touched" onchange="getLeads()">
                                            <option value="all">All</option>
                                            <option value="today">Today</option>
                                            <option value="yesterday">Yesterday</option>
                                            <option value="this_week">This week</option>
                                            <option value="this_month">Month</option>
                                        </select>
										</div>
											</div>

									</div>
									
								<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-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         									    
									<?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-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
                   <option value="0" <?php echo $_GET['eid'] == 0 ?  : ''; ?>>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 id="countryId" name="txtcountry[]" class="countries form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         		
                            <option value="">All Country</option>
                        </select>
										</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">State</label>
										        <select id="stateId" name="txtstate[]" class="states form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         		
                            <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 id="cityId" name="txtcity[]" class="cities form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         						
                            <option value="">All City</option>
                        </select>
										</div>
									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="form-label">Gender</label>
									     
							  <select id="searchGender" name="searchGender[]" class="form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         						        
                                            <option value="">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 id="searchMemberStatus" name="searchMemberStatus[]" class="form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         						    							
									  
                                        <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">Lead Source</label>
              <select id="source" name="source[]" class="form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select " style="width: 100%;" tabindex="-1" aria-hidden="true">
         		 			
                                    <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 class="row">
									<div class="col-md-6">
										     <div class="form-group">
                                <label class="form-label">All Residency Status</label>
                                  <select id="searchResidencyStatus" name="searchResidencyStatus[]" class="form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         		    
                                   <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 id="searchCurrency" name="searchCurrency[]" class="form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         		    					       
                            <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 id="searchMinAge" name="searchMinAge[]" class="form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         		    				      
                            <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 id="searchMaxAge" name="searchMaxAge[]" class="form-control select2 select2-hidden-accessible" onchange="getLeads()" multiple data-placeholder="Select" style="width: 100%;" tabindex="-1" aria-hidden="true">
         		 		        
                            <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>
							<!-- /.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"  id="mainContent">
					<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="date" id="txtFromDate" value="<?php echo $receivedData; ?>" 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="date"  id="txtToDate" value="dd------yy" name="txtToDate" class="form-control" autocomplete='off' onchange="getLeads()"/>
								 <!--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="lead-created.php">Reset Filter</a></button>
								</div>
							</div>
						</form>
						

<ul class="box-controls pull-right d-md-flex d-none">
    <li class="dropdown" id="dropdownMenu">
        <button class="btn btn-primary dropdown-toggle px-10" data-bs-toggle="dropdown" id="dropdownButton">Show/hide</button>
        <div class="dropdown-menu dropdown-menu-end" id="dropdownMenuContent">
            <div class="new-class">
         Sr.No  
            <button type="button" class="btn btn-xs btn-toggle active" onclick="toggleColumn(0)" data-bs-toggle="button" aria-pressed="false">
                 	<span class="handle"></span>
            </button>
            </div>
            <div class="new-class">
              Allocated To
            <button type="button" class="btn btn-xs btn-toggle active" onclick="toggleColumn(1)" data-bs-toggle="button" aria-pressed="false">
               <span class="handle"></span>
            </button>
            </div>
              <div class="new-class"> 
          Name 
            <button type="button" class="btn btn-xs btn-toggle active" onclick="toggleColumn(2)" data-bs-toggle="button" aria-pressed="false">
                <span class="handle"></span>
               
            </button>
             </div>
               <div class="new-class">
            Phone
            <button type="button" class="btn btn-xs btn-toggle active" onclick="toggleColumn(3)" data-bs-toggle="button" aria-pressed="false">
                <span class="handle"></span>
                
            </button>
            </div>
               <div class="new-class">
            Lead Status
            <button type="button" class="btn btn-xs btn-toggle active" onclick="toggleColumn(4)" data-bs-toggle="button" aria-pressed="false">
              <span class="handle"></span>
                
            </button>
            </div>
               <div class="new-class">
             Email
            <button type="button" class="btn btn-xs btn-toggle active" onclick="toggleColumn(5)" data-bs-toggle="button" aria-pressed="false">
               <span class="handle"></span>
               
            </button>
            </div>
               <div class="new-class">
             City
            <button type="button" class="btn btn-xs btn-toggle active" onclick="toggleColumn(6)" data-bs-toggle="button" aria-pressed="false">
               <span class="handle"></span>
               
            </button>
            </div>
               <div class="new-class">
             State
            <button type="button" class="btn btn-xs btn-toggle  active" onclick="toggleColumn(7)" data-bs-toggle="button" aria-pressed="false">
               <span class="handle"></span>
               
            </button>
            </div>
               <div class="new-class">
             Country
            
            <button type="button" class="btn btn-xs btn-toggle active" onclick="toggleColumn(8)" data-bs-toggle="button" aria-pressed="false">
              <span class="handle"></span>
               
            </button>
             </div>
               <div class="new-class">
             Created On
            
            <button type="button" class="btn btn-xs btn-toggle active" onclick="toggleColumn(9)" data-bs-toggle="button" aria-pressed="false">
              <span class="handle"></span>
               
            </button>
             </div>
               <div class="new-class">
            </div>
              
        </div>
    </li>
</ul>

						<!-- /.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>Allocated To</th>
											<th>Name</th>
											<th>Phone Number</th>
											<th>Lead Status</th>
											<th>Email Address</th>
											<th>City</th>
											<th>State</th>
											<th>Country</th>
											<th>Created On</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 $userrow->lead_id; ?></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"><!--?php echo $userrow->disposition ?></td>
                                            <!--td>
                                                <select name="" class="form-control-custom" 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><a style="color:blue;" href="edit-leads.php?leadid=<?php echo $userrow->lead_id ?>"><?php echo $userrow->contact_name ?></a></td>
                                            <td><?php echo $userrow->contact_no ?></td>
                                            <td><?php echo $userrow->disposition ?></td>
                                            <td><?php echo $userrow->email_id ?></td>
                                            <td><?php echo $userrow->city ?></td>
                                            <td><?php echo $userrow->state ?></td>
                                            <td><?php echo $userrow->country ?></td>
                                            <td><?php echo date("m/d/Y", strtotime($userrow->lead_created_on)) ?></td>
                                             
                                        </tr>
                                        <?php
                                    }
                                    ?>
                                    </tbody>
                                    </table>
                  
								
							</div>
                                    <nav>
                                   		<ul class="pagination">
														<?php
															$total=ceil($total_records/100);
															for($i=1;$i<=$total;$i++)
															{
															?>
																<li><a 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>
    function getLeads() {

        var txtFromDate = $('#txtFromDate').val();
        var txtToDate = $('#txtToDate').val();
        var txtSearch = $('#txtSearch').val();
        var ddlLeadType = $('#ddlLeadType').val();
        var ddlUserId = $('#ddlUserId').val();
        
        var touched = $('#touched').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/leads-created.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,
                touched: touched
            },
            datatype: 'html',
            success: function (rsp) {
                $('#ajaxcoursedata').html(rsp);
                $('#loading').css('display', 'none');
            }
        });
    }

    function changeLeadAllocation(executive_id, lead_id) {
        $('#loading').css('display', '');
        $.ajax({
            url: 'https://rishtasite.in/lead-crm/crm/allocate_lead.php',
            type: 'post',
            data: {"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 touched = $('#touched').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/leads-created.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,
                touched:touched,
                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>



<script>
$(document).ready(function(){
    $("#toggleButton").click(function(){
        $("#filterContent").toggle(); // Toggle visibility of the filter content
        $("#mainContent").toggleClass("col-lg-8 col-lg-12"); // Change class of main content
    });
});
</script>

<script src="../../../lead-crm/src/js/vendors.min.js"></script>

	<script src="../../../lead-crm/src/js/pages/chat-popup.js"></script>

    <script src="../../../lead-crm/assets/icons/feather-icons/feather.min.js"></script>

	<script src="../../../lead-crm/assets/vendor_components/echarts/dist/echarts-en.min.js"></script>

	<script src="../../../lead-crm/assets/vendor_components/apexcharts-bundle/dist/apexcharts.js"></script>






	<script src="../../../lead-crm/assets/vendor_components/datatable/datatables.min.js"></script>
	

    <script src="../../../lead-crm/assets/vendor_components/Flot/jquery.flot.js"></script>
	<script src="../../../lead-crm/assets/vendor_components/Flot/jquery.flot.resize.js"></script>
	<script src="../../../lead-crm/assets/vendor_components/Flot/jquery.flot.pie.js"></script>
	<script src="../../../lead-crm/assets/vendor_components/Flot/jquery.flot.categories.js"></script>

	<script src="../../../lead-crm/assets/vendor_components/Flot/jquery.flot.js"></script> 
	<script src="../../../lead-crm/src/js/pages/sampledata1.js"></script>
	<script src="../../../lead-crm/src/js/pages/sampledata2.js"></script>    
	<script src="../../../lead-crm/assets/vendor_components/apexcharts-bundle/irregular-data-series.js"></script>
	<script src="../../../lead-crm/assets/vendor_components/jquery.peity/jquery.peity.js"></script>
	
	<!-- CRMi App -->
	<script src="../../../lead-crm/src/js/pages/reports.js"></script>
	<script src="../../../lead-crm/src/js/template.js"></script> 
 
	<!-- CRMi App -->
	<script src="../../../lead-crm/src/js/pages/analysis.js"></script>
	
	<!-- CRMi App -->
	<!--script src="../../../lead-crm/src/js/pages/dashboard.js"></script-->

	<script src="../../../lead-crm/src/js/pages/data-table.js"></script> 

	
	<!-- CRMi App -->
	
	<script src="../../../lead-crm/src/js/pages/widget1-flot-charts.js"></script>
	<script src="../../../lead-crm/src/js/pages/flot-chart.js"></script>
	<script src="../../../lead-crm/src/js/pages/flot-chart1.js"></script>

	
		<!-- Vendor JS -->
    <script src="../../../lead-crm/assets/vendor_components/raphael/raphael.min.js"></script>
	<script src="../../../lead-crm/assets/vendor_components/morris.js/morris.min.js"></script>

	<!-- CRMi App -->
	
	<script src="../../../lead-crm/src/js/pages/widget-morris-charts.js"></script>
	<script src="../../../lead-crm/assets/vendor_components/chartist-js-develop/chartist.js"></script>
	
	<!-- CRMi App -->

	<script src="../../../lead-crm/src/js/pages/widget-chartist1.js"></script>
	<script src="../../../lead-crm/assets/vendor_components/echarts/dist/echarts-en.min.js"></script>
	
	<!-- CRMi App -->
	<script src="../../../lead-crm/src/js/pages/echart-bar.js"></script>  
	<script src="../../../lead-crm/assets/vendor_components/Flot/jquery.flot.pie.js"></script>

 
	<script src="../../../assets/vendor_components/select2/dist/js/select2.full.js"></script>
<!-- Vendor JS -->

	<!-- CRMi App -->
	<script src="../src/js/template.js"></script>
	
	<script src="../src/js/pages/advanced-form-element.js"></script>
	
	
	 <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>



<script>
    // Function to toggle column visibility
    function toggleColumn(index) {
        $("table tr").each(function () {
            $(this).find("td:eq(" + index + "), th:eq(" + index + ")").toggle();
        });
    }
    
    // Close dropdown only when clicking outside of box-controls area
    document.addEventListener('click', function (event) {
        var isClickInsideDropdown = document.getElementById('dropdownMenu').contains(event.target);
        var isClickOnDropdownButton = event.target.id === 'dropdownButton';
        if (!isClickInsideDropdown && !isClickOnDropdownButton) {
            document.getElementById('dropdownMenuContent').classList.remove('show');
        }
    });
    
    // Prevent dropdown from closing when clicking on the dropdown toggle button
    document.getElementById('dropdownButton').addEventListener('click', function (event) {
        event.stopPropagation();
        document.getElementById('dropdownMenuContent').classList.toggle('show');
    });
</script>
<style>
        .hidden {
            display: none;
        }
        .new-class{
            padding-left:20px;
             padding-bottom:5px;
        }
        .box-controls{
            padding-right:40px;
            padding-bottom:10px;
        }
        
    </style>
    
    	  <footer class="main-footer text-center">
    <!--div class="pull-right d-none d-sm-inline-block">
        <ul class="nav nav-primary nav-dotted nav-dot-separated justify-content-center justify-content-md-end">
		  <li class="nav-item">
			<a class="nav-link" href="https://themeforest.net/item/crmi-bootstrap-admin-dashboard-template/33405709" target="_blank">Purchase Now</a>
		  </li>
		</ul>
    </div-->
	  &copy; <script>document.write(new Date().getFullYear())</script> Rishta. All Rights Reserved.
  </footer>
  </body>
</html>	
	
	