<?php 
	
	include_once("../view/header-footer/header.php");    
	//include_once("../all-ajax/inner-header.php");    
	
?>   

<script src="<?php echo ROOTPATH;?>/view/js/tab/search_candidate.js"></script>      
<script>
var last; 
$(document).ready(function(){      

	site_id = '<?php echo $_REQUEST['site_id']; ?>';
	job_city_id = '<?php echo $job_city_id; ?>';
	job_id = '<?php echo $job_id; ?>';
	
	//alert(apply_city_id);
	$(".comboText").click(function(){
		$(this).next().slideDown();
	});
	
	//hide sub categories span...
	/*for(i=0;i<=<?php echo $affected_rows_job_category;?>;i++)
		$("#job-sub-category-span"+i).hide();   */  
		
	
	
/*	var hidden_role_key_val=null;
	if(($("#hidden_role_key_val").val())!="undefined")
	hidden_role_key_val = $("#hidden_role_key_val").val();
	else hidden_role_key_val = 0;

	
	//show collape for role...
	var container = $('#role-collapse'),
	scrollTo = $("#searchcandidate-category"+hidden_role_key_val);  
	
	
	container.animate({	scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() 	});*/

	$("#clear_searchcandidate_locality").click(function(){ 
	
		$.ajax({	
		type: "POST",
		url: URL+"/all-ajax/search_candidate.php", 
		data: {clear_searchcandidate_locality:1},
		beforeSend: function(){ 
		},
		success: function(data)
		{   
			/*$("#MyIframeDivs").load("searchcandidateLoad.php");  
			$("#locality_placed").html('');  
			location.reload();*/
			
			$("#MyIframeDivs").load("searchcandidateLoad.php?site_id="+site_id+"&job_city_id="+job_city_id+"&job_id="+job_id);
			$("#locality_placed").html('');  
			location.reload();
		}
		}); 
	});	
	
	$("#clear_all_job_filers").click(function(){ 
	
		$.ajax({	
		type: "POST",
		url: URL+"/all-ajax/search_candidate.php", 
		data: {clear_all_job_filers:1},
		beforeSend: function(){ 
		},
		success: function(data)
		{   
			////$("#MyIframeDivs").load("searchcandidateLoad.php"); 
			$("#MyIframeDivs").load("searchcandidateLoad.php?site_id="+site_id+"&job_city_id="+job_city_id+"&job_id="+job_id);
			location.reload();
		}
		}); 
	});	
	
	$("#clear_gender_filter").click(function(){ 
	
		$.ajax({	
		type: "POST",
		url: URL+"/all-ajax/search_candidate.php", 
		data: {clear_gender_filter:1},
		beforeSend: function(){ 
		},
		success: function(data)
		{   
			//$("#MyIframeDivs").load("searchcandidateLoad.php");
			$("#MyIframeDivs").load("searchcandidateLoad.php?site_id="+site_id+"&job_city_id="+job_city_id+"&job_id="+job_id);
			location.reload();
		}
		}); 
	});
	
	$("#clear_profile_search").click(function(){ 
	
		$.ajax({	
		type: "POST",
		url: URL+"/all-ajax/search_candidate.php", 
		data: {clear_profile_searchcandidate:1},
		beforeSend: function(){ 
		},
		success: function(data)
		{   
			//$("#MyIframeDivs").load("searchcandidateLoad.php");
			$("#MyIframeDivs").load("searchcandidateLoad.php?site_id="+site_id+"&job_city_id="+job_city_id+"&job_id="+job_id);
			location.reload();
		}
		}); 
	});
	
	$("body").click(function(e) 
	{    
		
		if ( e.target.id == "job-locality" || $(e.target).parents("#suggesstion_comboText").size() ) 
		{ 
             //alert("Inside div");   
        } else 
		{   
			 
			 
			$("#job-locality").val('');
			$("#suggesstion_comboText").slideUp(500);
        }   
    });	
    
    $("#search_roles_").keyup(function() 
	{
		$.ajax({	
			type: "POST",
			url: URL+"/all-ajax/search_candidate.php", 
			data: {select_searchcandidate_category:1,keyword:$(this).val()},
			beforeSend: function(){ 
			},
			success: function(data)
			{  
				var obj = jQuery.parseJSON(data);  
				if(obj==null || obj=='null')
				{  
					 
					$("#suggesstion_search_roles_").hide();
				}else
				{  	
					source_first_name = obj[0].name; 
					source_list = '<ul class="sug-box">'; 
					
					for(i=0;i<obj.length;i++)			  
					source_list +='<li id=searchcandidate-category><input type=radio name=searchcandidate-category onclick=searchcandidate_by_category("'+i+'","'+encodeURIComponent(obj[i].name)+'","'+obj[i].id+'")>'+obj[i].name+'</li>'
					
					
					source_list +='</ul>';   
					$("#suggesstion_search_roles_").show();
					$("#suggesstion_search_roles_").html(source_list); 
				}   
				
			}
		}); 
	});
	
	$("#job-locality").keyup(function() 
	{  
		city_id = '<?php echo $_REQUEST['city_id']; ?>';   
		$.ajax({	
			type: "POST",
			url: URL+"/all-ajax/search_candidate.php", 
			data: {search_locality:1,keyword:$(this).val(),city_id:city_id},
			beforeSend: function(){ 
			},
			success: function(data)
			{  
				$("#job-locality-ul").hide();
				var obj = jQuery.parseJSON(data);  
				if(obj==null || obj=='null')
				{  
					$("#suggesstion_comboText").hide();
					//$("#job-locality-ul").show();
					//$("#job-locality").val("entire city");
					$("#job-locality-ul").hide();
					
				}else
				{  	
					source_first_name = obj[0].location_name; 
					source_list = '<ul>'; 
					
					for(i=0;i<obj.length;i++)			
						source_list +='<li><span class="locList"><a onClick=searchcandidate_by_locality("'+obj[i].id+'","'+encodeURIComponent(obj[i].location_name)+'") href="javascript:void(0)">'+obj[i].location_name+'</a></span></li>';   
					
					source_list +='</ul>';   
					$("#suggesstion_comboText").show();
					$("#suggesstion_comboText").html(source_list);    
				}    
			
			}
		}); 
	});
});      

function searchcandidate_by_category(val,name,id)
{ 
    //alert(id);
	var new_name = name.split(' ');	 
	new_name1 =   new_name[0].replace(new RegExp("%20", "g"), '_');        
	//new_name1 =   new_name1.replace(new RegExp("%2F", "g"), '_'); 
	new_name1 =   new_name1.replace(new RegExp("%2F", "g"), '_');    
	$.ajax({	
	type: "POST",
	url: URL+"/all-ajax/search_candidate.php", 
	data: {set_searchcandidate_filter:1,val:id,type:1},
	beforeSend: function(){ 
	},
	success: function(data)
	{  
    	$("#MyIframeDivs").load("searchcandidateLoad.php?site_id="+site_id+"&job_city_id="+job_city_id+"&job_id="+job_id);
	}
	});
	
}   


function searchcandidate_by_profile(val)
{
    $("#ProfileSelect").addClass("DullColor");
	$("#ProfileSelectGreen").addClass("selectElemNew");
    $.ajax({	
	type: "POST",
	url: URL+"/all-ajax/search_candidate.php", 
	data: {searchcandidate_by_profile:1,val:val,remove:$('#profile_search'+val).is(':checked')},
	beforeSend: function(){ 
	},
	success: function(data)
	{  
	    if(data=='1')
		{
		    $("#ProfileSelect").addClass("DullColor");
		    $("#ProfileSelectGreen").addClass("selectElemNew"); 
		}
		else 
		{
		    $("#ProfileSelect").removeClass("DullColor")
		    $("#ProfileSelectGreen").removeClass("selectElemNew");
		} 
		$("#MyIframeDivs").load("searchcandidateLoad.php?site_id="+site_id+"&job_city_id="+job_city_id+"&job_id="+job_id); 
	}
	});
	
}


function searchcandidate_by_gender(val)
{ 	 
    $("#GenderSelect").addClass("DullColor");
	$("#GenderSelectGreen").addClass("selectElemNew");
	$.ajax({	
	type: "POST",
	url: URL+"/all-ajax/search_candidate.php", 
	data: {searchcandidate_by_gender:1,val:val,remove:$('#gender'+val).is(':checked')},
	beforeSend: function(){ 
	},
	success: function(data)
	{  
		$("#MyIframeDivs").load("searchcandidateLoad.php?site_id="+site_id+"&job_city_id="+job_city_id+"&job_id="+job_id); 
	}
	});	
}   

function searchcandidate_by_locality(val,name)
{
    //$(".loading-div").show();
	$("#LocationSelect").addClass("DullColor");
	$("#LocationSelectGreen").addClass("selectElemNew");
	new_name =   name.replace(new RegExp("%20", "g"), ' ');  
	$.ajax({	
		type: "POST",
		url: URL+"/all-ajax/search_candidate.php", 
		data: {searchcandidate_by_locality:1,val:val,name:new_name},
		beforeSend: function(){ 
		},
		success: function(data)
		{
            if(data=='false')
            {
               $("#job-locality").val(''); 
               alert("Location already added!"); 
               $("#job-locality-ul").hide();
            }
			else 
			{
    			$("#job-locality").val(''); 
    		    $("#suggesstion_comboText").hide();
    			$("#job-locality-ul").hide();
    			$("#locality_placed").html(data);  
    			
    			$("#MyIframeDivs").load("searchcandidateLoad.php?site_id="+site_id+"&job_city_id="+job_city_id+"&job_id="+job_id); 
			}
		}
	}); 
}

	
function searchcandidate_remove_locality(loc)
{ 
	new_name = loc.replace(new RegExp("%20", "g"), ' ');   
	$.ajax({	
		type: "POST",
		url: URL+"/all-ajax/search_candidate.php", 
		data: {searchcandidate_remove_locality:1,name:new_name},
		beforeSend: function(){ 
		},
		success: function(data)
		{     
		    if(data=='')
			{
			    $("#LocationSelect").removeClass("DullColor"); 
			    $("#LocationSelectGreen").removeClass("selectElemNew"); 
			}
			$("#locality_placed").html(data);  
			$("#MyIframeDivs").load("searchcandidateLoad.php?site_id="+site_id+"&job_city_id="+job_city_id+"&job_id="+job_id); 
		}
	});  
	 
}



    





</script> 

<script type="text/javascript">
$(document).ready(function() { 
	$("#results" ).load( "searchcandidateLoad.php?job_city_id="+job_city_id+"&job_id="+job_id+"&site_id="+site_id+" "); //load initial records    
	//executes code below when user click on pagination links
	$("#results").on( "click", ".pagination a", function (e){
		e.preventDefault();
		$(".loading-div").show(); //show loading element
	
		var page = $(this).attr("data-page"); //get page number from link  
		$("#results").load("searchcandidateLoad.php?job_city_id="+job_city_id+"&job_id="+job_id+"&site_id="+site_id+" ",{"page":page}, function()
		{ //get content from PHP page
			$(".loading-div").hide(); //once done, hide loading element
		});
		
	});
});
</script>
<?php include_once("../all-ajax/inner-header.php");  ?> 
<div id="body" class="grey-bg">
<div class="wrapper">
<div class="bradeCrubs">
<a href="<?php echo ROOTPATH;?>">Home</a>
<a href="javascript:void(0);">Hire Candidates</a>
<!--<a href="javascript:void(0);" class="current"><b><?php //echo $jobs_result->heading ?> in <?php //echo $city_name_result->name;?></b></a>-->
<!---a href="javascript:void(0);" class="current"><b title="<?php echo $jobs_result->heading; ?>"><?php echo substr($jobs_result->heading,0,16).'..';?> in <?php echo $city_name_result->name;?></b></a-->
<!--a href="javascript:void(0);"><i class="fa fa-long-arrow-left pull-right" onclick="goBack()"></i></a-->

</div>
<a class="clearAll pull-right" href="javascript:void(0)" id="clear_all_job_filers"><b>Clear All</b></a>
<div class="welcome-menu">
<div class="col-md-2 plr bottom newLeft" id="stickytypeheader">
	<div id="dataLeft" class="job-filter bottom">
    <div class="filterHead">Filter jobs 
    <!--a class="clearAll" href="javascript:void(0)" id="clear_all_job_filers">Clear All</a-->
    </div>
    <div class="panel-group" id="accordion">
    
	
    <div class="panel panel-default" id="locality">
      <div class="panel-heading">
        <h4 data-toggle="collapse" data-parent="#accordion" href="#collapse2" class="panel-title expand">
            <div class="right-arrow pull-right">+</div>
            <!--a href="javascript:void(0);"><i class="fa fa-user"></i> <b>Locality</b></a-->
            <?php if($_SESSION['searchcandidate_by_locality_val']) { ?>   
            <a href="javascript:void(0);" class="big-head">
              <b id="LocationSelect"><span class="nameLeft DullColor">Locality</span> 
                  <span id="LocationSelectGreen" class="selectElemNew"></span>
                  <div class="clear"></div>
              </b>   
            </a> 
            <?php }else { ?>   
            <a href="javascript:void(0);" class="big-head">
              <b id="LocationSelect"><span class="nameLeft">Locality</span> 
                  <span id="LocationSelectGreen"></span>
                  <div class="clear"></div>
              </b>   
            </a>   
            <div class="clear"></div> 
            <?php } ?>
	    </h4>
      
      <div id="collapse2" class="panel-collapse collapse">   
        <div class="panel-body">  
			 <!-- combo-box  -->
			 <a href="javascript:void(0)" class="cleFilter" id="clear_searchcandidate_locality">Clear Filter</a> 
			<div class="">
				<input type="text" class="location-name local-input" placeholder="E.q. Shalimar" id="job-locality" > 
				<ul id="job-locality-ul">
				<?php 
				$stmt =  $conn->prepare("select id,location_name from city_lacations  where city_id=:city_id");	  
				$stmt->bindValue(':city_id', $applycityid , PDO::PARAM_INT);
				$stmt->execute();   
				$city_locations = $stmt->fetchAll(PDO::FETCH_OBJ); 
				foreach($city_locations as $dt) 
				{
				?> 
					<li><a href="javascript:void(0)" onClick="searchcandidate_by_locality(<?php echo $dt->id;?>,'<?php echo $dt->location_name;?>')"><?php echo $dt->location_name;?></a></li> 
				<?php } ?>
				</ul>
				
			</div>
			<div class="col-md-8">
				<span id="locality_placed" class="local-tabs-2">
						<?php 
						$test_array = explode(",",$_SESSION['searchcandidate_by_locality_name']);
						array_pop($test_array); 
						foreach($test_array as $dt) 
							$val .= '<span class="locList">'.$dt.'<a href=javascript:void(0) onclick=searchcandidate_remove_locality("'.str_replace(" ","%20",$dt).'")> X</a> </span>';
							
						echo $val;
						?> 
					</span>	
			</div>
			
			<div  id="suggesstion_comboText" class="locality-list"></div>
				<?php 				
				$stmt=$conn->prepare("select id,city_id,location_name from city_lacations where city_id=:city_id order by  id asc");  
				$stmt->bindValue(':city_id', $applycityid , PDO::PARAM_INT);	
				$stmt->execute();   
				$city_locations_res = $stmt->fetchAll(PDO::FETCH_OBJ);	
				?>
        </div>
      </div>
    </div>
    </div>
	
	 <div class="panel panel-default">
      <div class="panel-heading">
        <h4 data-toggle="collapse" data-parent="#accordion" href="#collapse5" class="panel-title expand">
            <div class="right-arrow pull-right">+</div>
            <!--a href="javascript:void(0);"><i class="fa fa-user"></i> <b>Gender</b></a-->
            <?php if($_SESSION['searchcandidate_by_gender']) { ?>   
            <a href="javascript:void(0);" class="big-head">
              <b id="GenderSelect"><span class="nameLeft DullColor">Gender</span> 
                  <span id="GenderSelectGreen" class="selectElemNew"></span>
                  <div class="clear"></div>
              </b>   
            </a> 
            <?php }else { ?>   
            <a href="javascript:void(0);" class="big-head">
              <b id="GenderSelect"><span class="nameLeft">Gender</span> 
                  <span id="GenderSelectGreen"></span>
                  <div class="clear"></div>
              </b>   
            </a>   
            <div class="clear"></div> 
            <?php } ?>
        </h4>
      
      <div id="collapse5" class="panel-collapse collapse">
        <div class="panel-body pad">
			<a href="javascript:void(0)"class="cleFilter" id="clear_gender_filter">Clear Filter</a> 
        	<ul class="innUl job-filter list-gender">   
				<li><input type="radio" name="gender" id="gender1" onclick="searchcandidate_by_gender(1)" <?php if($_SESSION['searchcandidate_by_gender']==1) echo 'checked=checked'; ?> /> &nbsp;Male </li>
				
				<li> <input type="radio" name="gender" id="gender2" onclick="searchcandidate_by_gender(2)" <?php if($_SESSION['searchcandidate_by_gender']==2) echo 'checked=checked'; ?>  /> &nbsp;Female </li>
				
				<li><input type="radio" name="gender" id="gender3" onclick="searchcandidate_by_gender(3)" <?php if($_SESSION['searchcandidate_by_gender']==3) echo 'checked=checked'; ?>  /> &nbsp;Transgender </li>
            </ul>
        </div>
      </div>
    </div>
    </div>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h4 data-toggle="collapse" data-parent="#accordion" href="#collapse6" class="panel-title expand">
            <div class="right-arrow pull-right">+</div>
            <!--a href="javascript:void(0);"><i class="fa fa-user"></i> <b>Profile</b></a-->
            <?php if($_SESSION['searchcandidate_by_profile_val']) { ?>   
            <a href="javascript:void(0);" class="big-head">
              <b id="ProfileSelect"><span class="nameLeft DullColor">Profile</span> 
                  <span id="ProfileSelectGreen" class="selectElemNew"></span>
                  <div class="clear"></div>
              </b>   
            </a> 
            <?php }else { ?>   
            <a href="javascript:void(0);" class="big-head">
              <b id="ProfileSelect"><span class="nameLeft">Profile</span> 
                  <span id="ProfileSelectGreen"></span>
                  <div class="clear"></div>
              </b>   
            </a>   
            <div class="clear"></div> 
            <?php } ?>
        </h4>
      
      <div id="collapse6" class="panel-collapse collapse">
        <div class="panel-body pad">
			<a href="javascript:void(0)"class="cleFilter" id="clear_profile_search">Clear Filter</a>
			<?php
			$profile_val_array = explode(",",$_SESSION['searchcandidate_by_profile_val']); 
		    array_pop($profile_val_array);
			?>
        	<ul class="innUl job-filter list-gender">   
				<li><input type="checkbox" name="profile_search" id="profile_search1" onclick="searchcandidate_by_profile(1)" <?php if(in_array(1,$profile_val_array)) echo 'checked=checked'; ?> /> &nbsp;<span title="With mobile verified only">With mobile verified only</span> </li> 
				<li><input type="checkbox" name="profile_search" id="profile_search2" onclick="searchcandidate_by_profile(2)" <?php if(in_array(2,$profile_val_array)) echo 'checked=checked'; ?>  /> &nbsp;<span title="With email verified only">With email verified only</span> </li>
				<!--li><input type="checkbox" name="profile_search" id="profile_search3" onclick="searchcandidate_by_profile(3)" <?php if(in_array(3,$profile_val_array)) echo 'checked=checked'; ?>  /> &nbsp;<span title="With resume only">With resume only</span> </li-->
            </ul>
        </div>
      </div>
    </div>  
	</div>
	
	
   
  </div> 
    
    </div>
    </div> 
    
    </div>








    
   <div id="MyIframeDivs" class="col-md-10 newRigthView viewAppNew">
        <div class="col-md-12 p0">
            <div class="loading-div"><img src="<?php echo ROOTPATH;?>/view/images/ajax-loader.gif" ></div>
            <div id="results"><!-- content will be loaded here --></div>    
        </div>
	    <div class="col-md-3 plr">
            <div class="add-box">
        		<?php 
                  /*  foreach($RightImagesResult as $images)
                    {  
                         if($images->url!='')
                         {
                ?>  
                    <a href="<?php echo $images->url; ?>" target="_blank"><img src="<?php echo ROOTPATH.'/uploads/advertise/service/full-screen/'.$images->name;?>" width="100%" alt="Netbuttrfly Images"> </a>
                <?php } else { ?>
                <img src="<?php echo ROOTPATH.'/uploads/advertise/service/full-screen/'.$images->name;?>" width="100%" alt="Netbuttrfly Images">
                <?php } }*/?>  
        	</div>
    	</div>
   </div>   
   
<div class="clear"></div>
</div>
<br>

    
 <input type="hidden" value="<?php echo  $_REQUEST['city_id'];?>" id="search_city_id_hidden" name="search_city_id_hidden" />

</div>



<?php include_once("../view/header-footer/footer.php");  