<? include("header.php");


//session_start();
//error_reporting(0);

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'");
//.................

//ADD Coding Start

	if(isset($_REQUEST['submit']))

	{
	    $cat_name = $_REQUEST['cat_name'];
		$subcat = $_REQUEST['subcat'];
		$tamil_subcat = $_REQUEST['subcat_tamil'];

         $query_select="select `subcat` from ".$SUBCAT." where `subcat`='$subcat' and cat_name='$cat_name'  ";

		   $run_query=mysql_query($query_select);

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

                 }else{

                         $ins_qur = "insert into ".$SUBCAT." (`cat_name`,`subcat`) values('$cat_name','$subcat')";

			            mysql_query($ins_qur,$link);
						
						?>
                        <script>
						window.location='add.php?add=success';
						</script>
                        <?		

		                    //header("location:add.php?add=success");

}

}

//ADD Coding END
?>		 

<!----------------------Tamil---------------------------------------->
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
   google.load("elements", "1", {
            packages: "transliteration"          });
      function onLoad() {
        var options = {
          sourceLanguage: 'en',
          destinationLanguage: ['ta'], 
          shortcutKey: 'ctrl+g',
          transliterationEnabled: true        };
             var control =
            new google.elements.transliteration.TransliterationControl(options);
        var ids = ["cat_tamil"];
        control.makeTransliteratable(ids);
        control.showControl('translControl');      }
      google.setOnLoadCallback(onLoad);
	  
</script>
<!----------------------------------Tamil End----------------------------------------------------------->

<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_name" id="cat_name" 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;">Fabric Range  <font color="#FF0000"><b> *</b></font> </div>

                <div class="maintextbox"><input type="text" name="subcat" size="36" class="required"></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"); ?>