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

<script>   
login_url_val = "<?php echo $login_url_val;?>";   
$(document).ready(function()
{  
if(login_url_val==1)
{ 
	$("#login").modal({
	show: 'true',
	backdrop: 'static',
	keyboard:true
	});  
}

	$('#select-all').click(function(event) {    
		if(this.checked) 
		{
			// Iterate each checkbox
			$(':checkbox').each(function() 
			{  
				this.checked = true;         
			});  
		}else
		{
			$(':checkbox').each(function() {
				this.checked = false;                        
			});
		}
	});  

	$('.selectDelete').click(function(event) 
	{      
		var idGranted= Array();     
		var cityidGranted= Array();     
		//$("input:checkbox").each(function(){
		  $(".chk").each(function(){
			var $this = $(this); 
			if($this.is(":checked"))
			{ 
				var res = $(this).attr("id").split("-");    
				//console.log(res[2]);
				if($.isNumeric(parseInt(res[1])))
				{
					idGranted.push(parseInt(res[1]));    
					cityidGranted.push(parseInt(res[2]));    
				}
			}
		});

				

		id_send = idGranted.join(',');	
		city_send = cityidGranted.join(',');	
		var r = confirm("Do you really want to delete selected ads !");
		if (r == true) 
		{  
		$.ajax({
			type: "POST",
			url: '../all-ajax/MyDetails.php', 
			data: {delete_all_ads:1,city_id:city_send,id:id_send},	  
			beforeSend: function(){
				//$("#search-box").css("background","#FFF url(LoaderIcon.gif) no-repeat 165px");
			},
			success: function(data)
			{   	  
				location.reload();	 
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) { 
	        alert('Error');
			}
		});  
		}	  
	});

    $('#inactive-select-all').click(function(event) {    
		if(this.checked) 
		{
			// Iterate each checkbox
			//$(':checkbox').each(function() 
			$(".inactive_chk").each(function()
			{  
				this.checked = true;         
			});  
		}else
		{
			//$(':checkbox').each(function() {
			$(".inactive_chk").each(function(){	
				this.checked = false;                        
			});
		}
	});  

	$('.inactive_selectDelete').click(function(event) 
	{      
		var idGranted= Array();     
		var cityidGranted= Array();     
		//$("input:checkbox").each(function(){
		  $(".inactive_chk").each(function(){
			var $this = $(this); 
			if($this.is(":checked"))
			{ 
				var res = $(this).attr("id").split("-");    
				//console.log(res[2]);
				if($.isNumeric(parseInt(res[1])))
				{
					idGranted.push(parseInt(res[1]));    
					cityidGranted.push(parseInt(res[2]));    
				}
			}
		});

				

		id_send = idGranted.join(',');	
		city_send = cityidGranted.join(',');	
		var r = confirm("Do you really want to delete selected ads !");
		if (r == true) 
		{  
		$.ajax({
			type: "POST",
			url: '../all-ajax/MyDetails.php', 
			data: {delete_all_ads:1,city_id:city_send,id:id_send},	  
			beforeSend: function(){
				//$("#search-box").css("background","#FFF url(LoaderIcon.gif) no-repeat 165px");
			},
			success: function(data)
			{   	  
				location.reload();	 
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) { 
	        alert('Error');
			}
		});  
		}	  
	});	
	
	//$("#active_details").show();
	$("#inactive_details").hide();
	$('#active_jobtab').click(function(event) 
	{
	   $('#active_jobtab').removeClass('btn-blk');
	   $('#active_jobtab').addClass('btn');	
	   $('#inactive_jobtab').addClass('btn-blk');	
	   $("#active_details").show();
	   $("#inactive_details").hide();
	});
	
	$('#inactive_jobtab').click(function(event) 
	{
	   $('#inactive_jobtab').removeClass('btn-blk');
	   $('#inactive_jobtab').addClass('btn');	
	   $('#active_jobtab').addClass('btn-blk');
	   $("#inactive_details").show();
	   $("#active_details").hide();
	});
	
});      

function edit_ads(city_id,id)
{
	$.ajax({
		type: "POST",
		url: '../all-ajax/MyDetails.php', 
		data: {edit_ads:1,city_id:city_id,id:id},	  
		beforeSend: function(){
			//$("#search-box").css("background","#FFF url(LoaderIcon.gif) no-repeat 165px");
		},
		success: function(data)
		{   	  
				$("#edit-ads-model").modal({
				show: 'true',
				backdrop: 'static',
				keyboard:true
				});   
				$("#placed_alertform").html(data);   
				$("#city_id").val(city_id);   
				$("#ads_id").val(id);    
		}
	});  
}

function del_ads(city_id,id)
{
	var r = confirm("Do you really want to delete ads !");
	if (r == true) 
	{  
	$.ajax({
		type: "POST",
		url: '../all-ajax/MyDetails.php', 
		data: {delete_ads:1,city_id:city_id,id:id},	  
		beforeSend: function(){
			//$("#search-box").css("background","#FFF url(LoaderIcon.gif) no-repeat 165px");
		},
		success: function(data)
		{   	  
			location.reload();	 
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) { 
        alert('Error');
		}
	});  
	}
}


function inactive_del_ads(city_id,id)
{
    var set=0;
	var r = confirm("Do you really want to delete ads !");
	if (r == true) 
	{  
	$.ajax({
		type: "POST",
		url: '../all-ajax/MyDetails.php', 
		data: {delete_ads:1,city_id:city_id,id:id},	  
		beforeSend: function(){
			//$("#search-box").css("background","#FFF url(LoaderIcon.gif) no-repeat 165px");
		},
		success: function(data)
		{   	  
		   location.reload();	 
		   set=1;
		   $('#inactive_jobtab').removeClass('btn-blk');
    	   $('#inactive_jobtab').addClass('btn');	
    	   $('#active_jobtab').addClass('btn-blk');
    	   $("#inactive_details").show();
    	   $("#active_details").hide();
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) { 
        alert('Error');
		}
	});  
	}
}

</script>
<div id="body" class="grey-bg">
<div class="wrapper">
	<div class="bradeCrubs">
	<a href="<?php echo ROOTPATH;?>">Home</a>
	<a href="<?php echo ROOTPATH;?>/MyDetails/">My Account</a>
	<a href="<?php echo ROOTPATH;?>/MyDetails/ads.php" class="current">My Ads</a>
	</div>   
		<?php include_once("side-menu.php");  ?> 
		
		<div class="col-md-10 newRigth">
        <div class="col-md-7">
    <div id="dataRight">
    <div class="leftHead">My Ads</div> 
	<!--<a href="javascript:void(0)" class="rightLink">Create New Alert</a>-->
	<ul class="resList">
	    
	<li class="border-box">
	<h3 class="postJobMin"><a class="btn" href="javascript:void(0)" id="active_jobtab">Active (<?php echo $active_rows; ?>)</a></h3>
	<h3 class="postJobMin"><a class="btn btn-blk" href="javascript:void(0)" id="inactive_jobtab">Inactive (<?php echo $inactive_rows; ?>)</a></h3>
		<div class="clearfix"></div>
	</li>
	
	
	

	<!--  active ads start -->
<li id="active_details" class="border-box">
	<!--<h3 class="postJobMin"><a class="btn" href="javascript:void(0)">Active All Ads</a></h3>
	<h3 class="postJobMin"><a class="btn btn-blk" href="javascript:void(0)">Matching ads</a></h3>-->	
	<?php 
	 if($active_rows > 0)	
     {
	?>
	<div class="alertOut">
	<div class="alertDiv1">
		<h3 class="alertHead">Ads Name</h3>
	 
	</div>
	<div class="alertDiv2">
		<h3 class="alertHead">Subscribed Date</h3>
 
	</div>
	<div class="alertDiv3">
		<h3 class="alertHead">Actions</h3> 
	</div>
	<div class="alertDiv4">
		<h3 class="alertHead">Status</h3> 
	</div>
	</div> 
	<p class="selectAll job-filter">
		<span><input type="checkbox" id="select-all"> &nbsp; Select All </span>
		<span class="selectDelete">Delete</span>
	</p>

    <?php   
	 foreach($all_ads_data as $dt)
	 {
	?> 	 
	<div class="alertOut">
	<div class="alertDiv1"> 
		<div class="ckeckOur">
		<div class="ckeckBox job-filter">
			<!--<input type="checkbox" id="chk_<?php echo $dt->id;?>">-->
			<input type="checkbox" class="chk" id="chk-<?php echo $dt->id;?>-<?php echo $dt->city_id;?>">
		</div>
			<img src="<?php echo ROOTPATH;?>/view/images/fevicon.png" class="addImg" />
			<div class="adDisc"><?php  echo $dt->heading;?></div>
		</div>
	</div>
	<div class="alertDiv2"><?php echo $dt->job_date; ?>
	</div>
	<div class="alertDiv3">		 
		<!--<a href="<?php echo ROOTPATH.'/jobs/'.$_COOKIE['search_city_name'].'/'.$dt->heading.'-'.$dt->cate_id;?>">Matching </a>-->
		<a href="<?php echo ROOTPATH?>/jobs/edit_ads.php?id=<?php echo $dt->id;?>&city_id=<?php echo $dt->city_id;?>&url=<?php echo $dt->url; ?>">Edit</a>|
		<a href="javascript:void(0)"  onclick="del_ads(<?php echo $dt->city_id;?>,<?php echo $dt->id;?>)">Delete </a>|
		<a href="<?php echo ROOTPATH?>/MyDetails/view_application.php?id=<?php echo $dt->id;?>&city_id=<?php echo $dt->city_id;?>&site_id=<?php echo $_COOKIE['site_custom_id']; ?>" target="_blank">View Applications (<?php echo $dt->job_applied_cnt; ?>)</a>
	</div>
	<div class="alertDiv4"><?php if($dt->job_status==0) echo 'Pending';else if($dt->job_status==1) echo 'Publish';else if($dt->job_status==3) echo 'Decline'; ?>
	</div>
	</div>
	<?php 
		} 
	 } 	
     else {	echo "No records found!!!"
	?> 	 
	<?php } ?>	
	<div class="clear"></div> 
</li> 
<!--  active ads end -->

<!--  inactive ads start -->

<li id="inactive_details" class="border-box">
	<!--<h3 class="postJobMin"><a class="btn" href="javascript:void(0)">Inactive All Ads</a></h3>
	<h3 class="postJobMin"><a class="btn btn-blk" href="javascript:void(0)">Matching ads</a></h3>-->	
	<?php 
	 if($inactive_rows!='')
	 {
	?>
	<div class="alertOut">
	<div class="alertDiv1">
		<h3 class="alertHead">Ads Name</h3>
	 
	</div>
	<div class="alertDiv2">
		<h3 class="alertHead">Subscribed Date</h3> 
	</div>	
	<div class="alertDiv3">
		<h3 class="alertHead">Actions</h3> 
	</div>
	<div class="alertDiv4">
		<h3 class="alertHead">Status</h3> 
	</div>
	</div> 
	<p class="inactive_selectAll">
		<span><input type="checkbox" id="inactive-select-all"> &nbsp; Select All </span>
		<!--<span class="selectCount">0</span>-->
		<span class="inactive_selectDelete" style="color:#d21358; cursor:pointer;">Delete</span>
	</p>

    <?php
	foreach($inactive_all_ads_data as $dt)
	{
	?> 	 
	<div class="alertOut">
	<div class="alertDiv1"> 
		<div class="ckeckOur">
		<div class="ckeckBox">
			<!--<input type="checkbox" id="chk_<?php echo $dt->id;?>">-->
			<input type="checkbox" class="inactive_chk" id="chk-<?php echo $dt->id;?>-<?php echo $dt->city_id;?>">
		</div>
			<img src="<?php echo ROOTPATH;?>/view/images/fevicon.png" class="addImg" />
			<div class="adDisc"><?php  echo $dt->heading;?></div>
		</div>
	</div>
	<div class="alertDiv2"><?php echo $dt->job_date; ?>
	</div>
	<div class="alertDiv3">		 
		<!--<a href="<?php echo ROOTPATH.'/jobs/'.$_COOKIE['search_city_name'].'/'.$dt->heading.'-'.$dt->cate_id;?>">Matching </a>
		<a href="<?php echo ROOTPATH?>/jobs/edit_ads.php?id=<?php echo $dt->id;?>&city_id=<?php echo $dt->city_id;?>">Edit</a>|-->
		<a href="javascript:void(0)"  onclick="inactive_del_ads(<?php echo $dt->city_id;?>,<?php echo $dt->id;?>)">Delete </a>
		<?php if($dt->job_status==1) { ?>|
		<a href="<?php echo ROOTPATH?>/MyDetails/view_application.php?id=<?php echo $dt->id;?>&city_id=<?php echo $dt->city_id;?>" target="_blank">View Applications (<?php echo $dt->job_applied_cnt; ?>)</a> <?php } ?>
	</div>
	<div class="alertDiv4"><?php if($dt->job_status==0) echo 'Pending';else if($dt->job_status==1) echo 'Publish';else if($dt->job_status==3) echo 'Decline'; ?>
	</div>
	</div>
	<?php 
		} 
	}
    else {	echo "No records found!!!"
	?> 	 
	<?php } ?>
	<div class="clear"></div> 
</li> 

<!--  inactive ads end -->

        </ul>
    </div>
    </div>
    
    <div class="col-md-3 plr">
    <div class="add-box">
			<img src="http://www.goldenglassqatar.com/view/images/a.jpg" width="100%">
			<img src="http://www.goldenglassqatar.com/view/images/b.jpg" width="100%">
			<img src="http://www.goldenglassqatar.com/view/images/c.jpg" width="100%">
	</div>
	</div>

    </div>
	
<div class="clear"></div>
</div>
<br>

</div>

	


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