<? 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'];
		$oldcat=$_POST['oldcat'];
		$oldsub=$_POST['oldsub'];

		$cat_name=$_POST['cat_name'];
		$sub_cat=$_POST['subcat'];
		//..........................
		
		
		  
		$upd_qur2="UPDATE sub_sub_category SET cat='$cat_name',sub_cat='$sub_cat' WHERE cat='$oldcat' and sub_cat='$oldsub'"; 
		$exe_pag2=mysql_query($upd_qur2);   
		
		$upd_qur33="UPDATE products SET category='$cat_name',sub_category='$sub_cat' WHERE category='$oldcat' and sub_category='$oldsub'"; 
		$exe_pag33=mysql_query($upd_qur33); 
		
		$update=mysql_query("update ".$SUBCAT." set `cat_name`='$cat_name',subcat='$sub_cat' where `id`='$cat_id'");    
		  
	//............................................
		
		?>
        <script>
		window.location='view.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">
        
 
  <?php

$query = mysql_query("SELECT * FROM ".$SUBCAT." 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" value="<?php echo $array['cat_name'];?>" name="oldcat" />
 <input  type="hidden" value="<?php echo $array['subcat'];?>" name="oldsub" />            
            
            
            <div class="mainrow" style="margin-left:100px;">
                <div class="maintext" style="width:130px;">Category Name<font color="#FF0000"><b> *</b></font> </div>
                <div class="maintextbox">
                <select name="cat_name" style="width:200px;">
                <option value="<?php echo $array['cat_name'];?>"><?php echo $array['cat_name'];?></option>
                <?php
				$set=mysql_query("select * from ".$CAT." where code='1'");
				while($eft=mysql_fetch_array($set))
				{
				?>
                <option><?php echo $eft['category_name']; ?></option>
                <?php } ?>
                </select>
                
                </div>
            </div>
            
            <br />
            
             <div class="mainrow" style="margin-left:100px;">
                <div class="maintext" style="width:130px;">Sub-Category<font color="#FF0000"><b> *</b></font> </div>
                <div class="maintextbox"><input  type="text" value="<?php echo $array['subcat'];?>" name="subcat" size="36"></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"); ?>