<? include("header.php");

include "checksession.php";

include "include/db-connect.php";

//....Tamil font......
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
//.................

	if(isset($_REQUEST['submit']))
	{
	    $cat = $_REQUEST['cat'];
		$sub_cat = $_REQUEST['sub_cat'];
		$sub_sub_cat = $_REQUEST['sub_sub_cat'];
		
		if(is_numeric($sub_cat))
		{
		$set=mysql_query("select * from sub_category where id='$sub_cat'");
		$fet=mysql_fetch_array($set);
		$cat = $fet['cat_name'];
		$sub_cat = $fet['subcat'];
		}
		else
		{
		$cat = $_REQUEST['cat'];
		$sub_cat = $_REQUEST['sub_cat'];	
		}
		

         $query_select="select `subcat` from sub_sub_category where cat='$cat' and sub_cat='$sub_cat' and sub_sub_cat='$sub_sub_cat'";

		   $run_query=mysql_query($query_select);

		      if(mysql_num_rows($run_query) > 0){ header("location:view.php?add=fail");

                 }else{

				  $ins_qur = "insert into sub_sub_category(`cat`,`sub_cat`,`sub_sub_cat`) values('$cat','$sub_cat','$sub_sub_cat')";
			      mysql_query($ins_qur,$link);
				  ?>
				  <script>
				  window.location='add_sub_sub.php?add=success';
				  </script>
				  <?		
				  //header("location:add.php?add=success");

}

}

//ADD Coding END
?>		 

<script type="text/javascript">
function showstate(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHintstate").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","loadData.php?q="+str,true);
xmlhttp.send();
}
function showcity(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHintcity").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","city_ajax.php?q="+str,true);
xmlhttp.send();
}
</script>
<div id="content">
  <div class="breadcrumb">
       <!-- <a href="http://amarasudhan.com/admin/index.php?route=common/home&amp;token=b735cc089ec2d51abb9a8e1901f501fb">Home</a>-->
      </div>
              <div class="box">
    <div class="heading">
      <h1><img src="view/image/home.png" alt="" />Add Fabric Range </h1>
    </div>
    <div class="content">
      <div class="overview" style="width:50%; margin-left:300px;">
        <div class="dashboard-heading"> Product Fabric Range </div>
        <div class="dashboard-content">
        
 <?php
if($_REQUEST['add'] == 'success') {echo $result= '<h4 class="alert_success">Sub Category Added Success </h4>';}elseif($_REQUEST['add'] == 'fail'){echo $result= '<h4 class="alert_error">Sub Category Already Exit</h4>';}
?>
 <form action="" method="post"  id="client" class="mdsform"  >
 <!-- <script type="text/javascript" src="../prototype.js"></script> 
  <script type="text/javascript" src="../validation.js"></script>
  -->

            <div class="mainrow" style="margin-left:100px;">

                <div class="maintext" style="width:150px;">Category Name <font color="#FF0000"><b> *</b></font> </div>

                <div class="maintextbox">
                <select name="cat" onChange="showstate(this.value)" style="width:150px;">

          <option value="0">Select Category</option>

          <?PHP $selectcat=mysql_query("select  * from ".$CAT." where code='1'");

		  while($viewcat=mysql_fetch_array($selectcat))
		  {?>

          <option value="<?=$viewcat['category_name']; ?>"><?=$viewcat['category_name']; ?></option>

          <?PHP }?>

        

        </select> </div>

            </div>
  <br />
             <div class="mainrow" style="margin-left:100px;">

                <div class="maintext" style="width:150px;">Sub-Category <font color="#FF0000"><b> *</b></font> </div>

                <div id="txtHintstate" style="margin-left:0px;">
                            <select  name="sub_cat"  onChange="showcity(this.value)" style="width:150px;" class="required">
                            <option hidden="">Select Sub-Category </option>
                            </select>
                            </div>

            </div>
  <br />
  
  
  <div class="mainrow" style="margin-left:100px;">

                <div class="maintext" style="width:150px;">Sub-Sub-Category <font color="#FF0000"><b> *</b></font> </div>

                <div style="margin-left:0px;">
                           <input type="text" name="sub_sub_cat" />
                            </div>

            </div>
 <br />

            <div class="mainrow" style="margin-left:100px;">
            <div class="maintext" style="width:150px;"> </div>
            <div class="maintextbox"><input  id="Submit" type="submit" value="Submit" name="submit" /></div>
            </div>			        

   </form>
        </div>
      </div>
      
      
    </div>
  </div>
</div>
<!--[if IE]>
<script type="text/javascript" src="view/javascript/jquery/flot/excanvas.js"></script>
<![endif]--> 
<script type="text/javascript" src="view/javascript/jquery/flot/jquery.flot.js"></script> 
<script type="text/javascript"><!--
function getSalesChart(range) {
	$.ajax({
		type: 'get',
		url: 'index.php?route=common/home/chart&token=b735cc089ec2d51abb9a8e1901f501fb&range=' + range,
		dataType: 'json',
		async: false,
		success: function(json) {
			var option = {	
				shadowSize: 0,
				lines: { 
					show: true,
					fill: true,
					lineWidth: 1
				},
				grid: {
					backgroundColor: '#FFFFFF'
				},	
				xaxis: {
            		ticks: json.xaxis
				}
			}

			$.plot($('#report'), [json.order, json.customer], option);
		}
	});
}

getSalesChart($('#range').val());
//--></script> 
</div>
<?  include("footer.php"); ?>