<?php
	include "../db_connection/db_connection.php";
	include "../config/config.php";
	
	
if($_GET['ajax_id']==1)
{
	$vals = $_GET['vals'];
	
	
	$SLCT = "SELECT * FROM master_cad_cat WHERE cad_cat_name = '$vals' AND statu_s='active'";
	$QURY = mysqli_query($connect,$SLCT);
	if(mysqli_num_rows($QURY)> 0)
	{
		echo "yes";
	}
	else
	{
		echo "no";
	}
}
else if($_GET['ajax_id']==2)
{
		$design_id = $_GET['design_id'];
		$ids = $_GET['ids'];
		
		if($_GET['statu_s']==1)
		{
			$UPDATE = "UPDATE master_cad_cat SET statu_s = 'inactive',update_dt = '$cur_time' WHERE master_cad_cat_id = '$design_id'";
			//echo $UPDATE;
			$QRY    = mysqli_query($connect,$UPDATE); 
			$statu_s = 2;
			$stss = 'Inactive';
		}
		else if($_GET['statu_s']==2)
		{
			$UPDATE = "UPDATE master_cad_cat SET statu_s = 'Active',update_dt = '$cur_time' WHERE master_cad_cat_id = '$design_id'";
			$QRY    = mysqli_query($connect,$UPDATE); 
			$statu_s = 1;
			$stss = 'Active';
		}
	
	
		echo "<a href='javascript:0;' id='inactlink$ids' onclick='des_act_ina($design_id,$statu_s,$ids)'>".$stss."</a>";
}
else if($_GET['ajax_id']==3)
{
	$vals = $_GET['vals'];
	$ids = $_GET['ids'];
	
	$SLCT = "SELECT cad_cat_name FROM master_cad_cat WHERE master_cad_cat_id = '$vals'";
	$QURY = mysqli_query($connect,$SLCT);
	$FTCH = mysqli_fetch_object($QURY);
	
	$SLCT2 = "SELECT master_cad_cat_id FROM master_cad_cat WHERE cad_cat_name = '$FTCH->cad_cat_name' AND statu_s='Active'";
	$QURY2 = mysqli_query($connect,$SLCT2);	
	if(mysqli_num_rows($QURY2)> 0)
	{
		echo "yes$*$";
		$statu_s = 1;
		$stss = 'Inactive';
		echo "<a href='javascript:0;' id='inactlink$ids' onclick='des_act_ina($vals,$statu_s,$ids)'>".$stss."</a>";
	}
	else
	{
		$UPDATE = "UPDATE master_cad_cat SET statu_s = 'Active',update_dt = '$cur_time' WHERE master_cad_cat_id = '$vals'";
		$QRY    = mysqli_query($connect,$UPDATE); 
		$statu_s = 1;
		$stss = 'Active';
		echo "no$*$";
		echo "<a href='javascript:0;' id='inactlink$ids' onclick='des_act_ina($vals,$statu_s,$ids)'>".$stss."</a>";
	}
}
?>
		
     
 	
	
	