<? include("header.php");

//session_start(0);
include "checksession.php";
include "include/db-connect.php";
$cat_id=$_REQUEST['id'];
//Edit Coding Start

	if(isset($_POST['submit']))
	{
		$cat_id=$_REQUEST['id'];

		$cat = $_REQUEST['cat'];
		
		$sub_cat = $_REQUEST['sub_cat'];
		$sub_sub_cat = $_REQUEST['sub_sub_cat'];
		
		$oldcat = $_REQUEST['oldcat'];
		$oldsub_cat = $_REQUEST['oldsub_cat'];
		$oldsub_sub_cat = $_REQUEST['oldsub_sub_cat'];

		//..........................
		
		if(is_numeric($sub_cat))
		{
			$sqlzdfsdf="SELECT * FROM sub_category WHERE id = '$sub_cat'"; 
	   		$resultasdasd = mysql_query($sqlzdfsdf);
	   		$rowffff = mysql_fetch_array($resultasdasd);
	   
	   		 $cat=$rowffff['cat_name'];
	   		$sub_cat=$rowffff['subcat'];
		} 
		else 
		{
			$cat = $_REQUEST['cat'];
			$sub_cat = $_REQUEST['sub_cat'];
		}
		
		
		  
		$upd_qur2="UPDATE products SET  category='$cat',sub_category='$sub_cat',sub_sub_cat='$sub_sub_cat' WHERE category='$oldcat' and sub_category='$oldsub_cat' and sub_sub_cat='$oldsub_sub_cat'"; 
		//$exe_pag2=mysql_query($upd_qur2);    
		  
//............................................

$update="update sub_sub_category set `cat`='$cat',sub_cat='$sub_cat',sub_sub_cat='$sub_sub_cat' where `id`='$cat_id'";  

mysql_query($update);
		
		?>
        <script>
		window.location='view_sub_sub.php?edit=sucess&&ca=$cat_name&&su=$sub_cat';
		</script>
        <?
		 //header("location:view2.php?edit=sucess&&ca=$cat_name&&su=$sub_cat");
	}
?>	

<!-------------------------------------------------------------------------------------------->

<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="" />Edit Sub-Category</h1>
    </div>
    <div class="content">
      <div class="overview" style="width:50%; margin-left:300px;">
        <div class="dashboard-heading">Sub-Category</div>
        <div class="dashboard-content">
<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>        
 
  <?php

$query = mysql_query("SELECT * FROM sub_sub_category WHERE id = '".$cat_id."' ");
$array=mysql_fetch_array($query);

?>		

 <?php if($_REQUEST['ed']=='su'){ echo "<div class='alert_succes'>Contact Edited Successfully</div>"; } else { echo "";}?>

 <form action="" method="post"  id="chgpass" class="mdsform"  >
            
 <input type="hidden" name="oldcat" value="<?php echo $array['cat']; ?>" />
 <input type="hidden" name="oldsub_cat" value="<?php echo $array['sub_cat']; ?>" />
 <input type="hidden" name="oldsub_sub_cat" value="<?php echo $array['sub_sub_cat']; ?>" />           
            
            
           <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="<?php echo $array['cat']; ?>"><?php echo $array['cat']; ?></option>
          		<option value="0">Select Category</option>
          		<?PHP $selectcat=mysql_query("select * from ".$CAT." where code='1'");
		  		while($viewcat=mysql_fetch_array($selectcat))
		  		{?>
          		<option value="<?php echo $viewcat['category_name']; ?>"><?php echo $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 value="<?php echo $array['sub_cat']; ?>"><?php echo $array['sub_cat']; ?></option>
                            <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" value="<?php echo $array['sub_sub_cat']; ?>" />
                            </div>

            </div>
 <br />
            <div class="mainrow" style="margin-left:100px;">
             <div class="maintext" style="width:130px;"> </div>
              <div class="maintextbox"><input  id="Submit" type="submit" value="Submit" name="submit" />
              
              <div style="margin-bottom:10px; margin-top:10px; margin-left:100px;">
             <a href="javascript: history.go(-1)"><img src="images/bac.jpg"></a></div></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"); ?>