<?php 
error_reporting(0);
session_start();
if(!isset($_SESSION['admin']) || ($_SESSION['admin'] == "") )
{
	?>
<script language="javascript">window.location.href="index.php";</script>
<?php 
}
include "config.php";
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Product Manage</title>
<meta name="author" content="pixelcave">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="shortcut icon" href="img/favicon.ico">
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="57x57" href="img/apple-touch-icon-57x57-precomposed.png">
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon" sizes="114x114" href="img/apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-precomposed.png">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,400italic,700,700italic">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/plugins.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/themes.css">
<script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>

<script type="text/javascript" src="js/jsapi.js"></script>

      <script type="text/javascript">
        // Load the Google Transliteration API
        google.load("elements", "1", {
          packages: "transliteration"
        });

        function onLoad() {
          var options = {
            sourceLanguage: 'en',
            destinationLanguage: ['gu'],
            shortcutKey: 'ctrl+m',
            transliterationEnabled: true
          }

          // Create an instance on TransliterationControl with the required options.
          var control = new google.elements.transliteration.TransliterationControl(options);

          // Enable transliteration in the textfields with the given ids.
          var ids = ["language"];
          control.makeTransliteratable(ids);
 
    var ids = ["language2"];
          control.makeTransliteratable(ids);
          // Show the transliteration control which can be used to toggle between English and Hindi and also choose other destination language.
          control.showControl('translControl');
        }

        google.setOnLoadCallback(onLoad);
      </script>  
</head>
<body>
<div id="page-container">
  <?php include 'header.php' ?>
  <div id="inner-container">
    <?php include 'left_menu.php' ?>
    <div id="page-content">
      <ul id="nav-info" class="clearfix">
        <li><a href="#"><i class="icon-home"></i></a></li>
        <li class="active"><a href=""> Product Manage</a></li>
      </ul>
      <?php 
if ($_POST['add']) 
{
	$productname=$_REQUEST['productname']; 
	$description=$_REQUEST['description'];
	$unitprice=$_REQUEST['unitprice'];
	$perunit=$_REQUEST['perunit'];
	
	$status=$_REQUEST['status'];
 
	
  $sql=mysql_query("INSERT 
		INTO 
		tbl_product_master
		(productname,description,unitprice,perunit,status) 
		VALUES 
       ('$productname','$description','$unitprice','$perunit','$status')");
 	?>
      <?php
//	}
} 
?>
      <?php 


  $id = $_GET['reg'];
						
 if(isset($_REQUEST['up'])) 
  {  		 
  	$productname=$_REQUEST['productname'];
	$description=$_REQUEST['description'];
	$unitprice=$_REQUEST['unitprice'];
  	$perunit=$_REQUEST['perunit'];
  	$status=$_REQUEST['status'];
	
	$uupQry="UPDATE tbl_product_master SET productname='$productname',description='$description',unitprice='$unitprice',perunit='$perunit',status='$status' WHERE prd_id='$id'";
	$uuresult=mysql_query($uupQry);
	?>
      <script language="javascript">window.location.href="product_list.php";</script>
      <?php 
  
  }
  
   ?>
      <?php 						
		$ure=mysql_query("select * from tbl_product_master where prd_id='$id'");
		$urow=mysql_fetch_array($ure); ?>
      <form id="form-validation"  method="post" name="form" class="form-horizontal form-box remove-margin">
        <div class="form-box-content">
          
          
		  
		  
		  <!--<div class="control-group">
            <label class="control-label" for="val_skill">Select Product *</label>
            <div class="controls">
              <select id="val_skill" name="catid">
                <option value="">Please Select</option>
				
				<?php 
		//	   $sel1="select * from tbl_subcategory_master where subcatid='$id'";
  		//		$res1=mysql_query($sel1);
  		//		$row1=mysql_fetch_array($res1);
			  ?>
				
				 <option value="<?php //echo $urow['catid']; ?>" <?php //if($urow['catname'] == $row1['catname'] ) echo 'selected="selected"';?>><?php //echo $urow['catname']; ?></option>
				
				<?php
	//	$ure1=mysql_query("SELECT * FROM  categorymaster order by catid ASC");		
	//	while($urow1=mysql_fetch_array($ure1)) 
	//	{
		?>  
                <option value="<?php //echo $urow1[0]; ?>"><?php //echo $urow1['catname']; ?></option>
               
			   
			   <?php// } ?>
              </select>
            </div>
          </div>-->
		  
 
       
          <div class="control-group">
            <label class="control-label" for="val_username">પ્રોડક્ટ નામ * &nbsp;</label>
            <div class="controls">
              <div class="input-prepend"> <span class="add-on"><i class="icon-user"></i></span>
                <input type="text" id="language" name="productname" value="<?php echo $urow['productname']; ?>">
              </div>
            </div>
          </div>
          
          
      <!--    <div class="control-group">
            <label class="control-label" for="val_username">Description *</label>
            <div class="controls">
              <div class="input-prepend"> <span class="add-on"><i class="icon-user"></i></span>
                <input type="text" id="val_username" name="description" value="<?php //echo $urow['description']; ?>">
              </div>
            </div>
          </div>-->
          
         <!-- <div class="control-group">
            <label class="control-label" for="val_username">Unit Price *&nbsp;</label>
            <div class="controls">
              <div class="input-prepend"> <span class="add-on"><i class="icon-user"></i></span>
                <input type="text" id="val_username" name="unitprice" value="<?php //echo $urow['unitprice']; ?>">
              </div>
            </div>
          </div>
          
          <div class="control-group">
            <label class="control-label" for="val_username">Per Unit *&nbsp;</label>
            <div class="controls">
              <div class="input-prepend"> <span class="add-on"><i class="icon-user"></i></span>
                <input type="text" id="val_username" name="perunit" value="<?php //echo $urow['perunit']; ?>">
              </div>
            </div>
          </div>-->
          
		  <?php /*?><div class="control-group">
            <label class="control-label" for="val_skill">Select Member *</label>
            <div class="controls">
              <select id="val_skill" name="memid">
			  
			  	<?php 
			   $sel1="select * from tbl_subcategory_master where subcatid='$id'";
  				$res1=mysql_query($sel1);
  				$row2=mysql_fetch_array($res1);
			  ?>
			  
			  
                <option value="">Member Select</option>
				
				
				 <option value="<?php echo $urow['member_id']; ?>" <?php if($urow['membername'] == $row2['membername'] ) echo 'selected="selected"';?>><?php echo $urow['membername']; ?></option>
				
				
				<?php
		$ure1=mysql_query("SELECT * FROM  tbl_member_register");		
		while($urow1=mysql_fetch_array($ure1)) 
		{
		?>  
        <option value="<?php echo $urow1[0]; ?>"><?php echo $urow1['cname']; ?></option>
        <?php } ?>
              </select>
            </div>
          </div><?php */?>
		  
		  
		  <div class="control-group">
            <label class="control-label" for="val_skill">Status *&nbsp;</label>
            <div class="controls">
              <select id="val_skill" name="status">
                <option value="1" <?php if($urow['status'] == "1") echo 'selected="selected"';?>>Enable</option>
                <option value="0" <?php if($urow['status'] == "0") echo 'selected="selected"';?>>Disable </option>
              </select>
            </div>
          </div>
		  
		  
          <div class="form-actions">
            <?php
					 
                        if($id)
						{
						?>
            <input type="submit" name="up" value="Update Product" class="btn btn-success">
            <?php 
}
else 
{

?>
            <input type="submit" name="add" value="Add Product" class="btn btn-success">
            <?php } ?>
            <button type="reset" class="btn btn-danger"><i class="icon-repeat"></i> Reset</button>
          </div>
        </div>
      </form>
    </div>
    <?php include 'footer.php' ?>
  </div>
</div>
<?php include 'profile_popup.php' ?>
<!--[if lte IE 8]><script src="js/helpers/excanvas.min.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/vendor/jquery-1.9.1.min.js"%3E%3C/script%3E'));</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<script>$(function(){$("#form-validation").validate({errorClass:"help-block text-error",errorElement:"span",errorPlacement:function(t,e){e.parents(".controls").append(t)},highlight:function(t){$(t).closest(".control-group").removeClass("success error").addClass("error")},success:function(t){t.addClass("valid").closest(".control-group").removeClass("success error").addClass("success"),t.closest(".help-inline").remove(),t.closest(".help-block").remove()},rules:{val_username:{required:!0,minlength:2},val_password:{required:!0,minlength:5},val_confirm_password:{required:!0,minlength:5,equalTo:"#val_password"},val_email:{required:!0,email:!0},val_website:{required:!0,url:!0},val_date:{required:!0,date:!0},val_range:{required:!0,range:[1,100]},val_number:{required:!0,number:!0},val_digits:{required:!0,digits:!0},val_skill:{required:!0},val_credit_card:{required:!0,creditcard:!0},val_terms:{required:!0}},messages:{val_username:{required:"Please enter a username",minlength:"Your username must consist of at least 2 characters"},val_password:{required:"Please provide a password",minlength:"Your password must be at least 5 characters long"},val_confirm_password:{required:"Please provide a password",minlength:"Your password must be at least 5 characters long",equalTo:"Please enter the same password as above"},val_email:"Please enter a valid email address",val_website:"Please enter your website!",val_date:"Please select a date!",val_range:"Please enter a number between 1 and 100!",val_number:"Please enter a number!",val_digits:"Please enter digits!",val_credit_card:"Please enter a valid credit card!",val_skill:"Please select a skill!",val_terms:"You must agree to the terms!"}})});</script>
</body>
</html>
