<? include("header.php");


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

include "checksession.php";

include ("include/db-connect.php");

if(isset($_REQUEST['submit']))
 {
	
	  $product_id=$_REQUEST['product_id'];
	  $percentage=$_REQUEST['percentage'];
	  $percen=$percentage/100;
	  
	  $set=mysql_query("select * from products where product_id='$product_id'");
	  $st=mysql_fetch_array($set);
	  $tax_percen=$st['tax_percen'];//Tax Percen
	  
	  $in_price=$st['in_price'];// Sale Price
	 
	  $pur_price=$st['pur_price'];// Purcase Price
	  $price=$in_price-$pur_price;
	  
	  $pp=$price*$percen;//Offer
	  
	  $amt=$in_price-$pp;// Minus Offer
	
	  $ttx=$amt*$tax_percen;//Tax Tot
	 
	  $amttt=$amt+$ttx; // Final
	  
	  
	  $offer=mysql_query("update products set offer='offer',price='$amttt',offper='$percentage' where product_id='$product_id'");
	  
	  ?>
      <script>
	  window.location='view_offer.php?add=success';
	  </script>
      <?
		                   
     // header("location:view_offer.php?add=success"); 
} 
?>
<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 Offer</h1>
    </div>
    <div class="content">
      <div class="overview" style="width:50%; margin-left:300px;">
        <div class="dashboard-heading"> Offer</div>
        <div class="dashboard-content">
        
 
   <?php 
 $sel="select * from ".$MAIL_CON." where id=1";
 $run=mysql_query($sel);
 $array=mysql_fetch_array($run);
 $name=$array['image_name'];
  
 ?>
 
 <?php if($_REQUEST['ed']=='su'){ echo "<div class='alert_succes'>Contact Edited Successfully</div>"; } else { echo "";}?>

 <form action="" method="post" enctype="multipart/form-data" id="question" >
 <!-- <script type="text/javascript" src="../prototype.js"></script>
  <script type="text/javascript" src="../validation.js"></script>   
  <script src="../ckeditor.js"></script>-->
  
      
		<div class="add_row" style="margin-top:20px"><div id="wrapper">
		<div class="wrap_box">
        
        
        
                
                <div style="float:left; width:200px;">PRODUCT ID&nbsp;<font color="#FF0000">*</font>	</div> 
    			
                       <div class="wrap_box" style="margin-left:200px;">
              			<select name="product_id" class="required">
						<option value="">Select ID</option>
						<?php
						$sep=mysql_query("select product_id from products");
						while($rowCountry=mysql_fetch_array($sep))
						{
						?>
						<option value="<?php echo $rowCountry['product_id']?>"><?php echo $rowCountry['product_id']?></option>
						<?php	}	?>
						</select>
						</div>
                        <div class="spacer"></div> <br />
                        
                        <div style="float:left;width:200px;">Offer Percentage&nbsp;<font color="#FF0000">*</font>	</div> 
							<div id="txtHintstate" style="margin-left:200px;">
                            <input  type="text"  name="percentage" size="19" class="required">%
                            </div><div class="spacer"></div>
     
                    <br />
                                          
                                                        

                       <div class="add_row" style="margin-left:195px; margin-top:20px;">
                      <p><span class="maintextbox"> <input type="submit" name="submit" id="button" value="Submit" > </span></p>
                      </div></div><!-- End option--></div><!-- End add_row-->
                      </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>
<div id="footer">Copyright &copy; 2014 | Powered by <a href="http://linikantech.com/" target="_blank">Linikantech</a><!--<a href="http://www.opencart.com">OpenCart</a> &copy; 2009-2016 All Rights Reserved.<br />Version 1.5.6.4--></div>
</body></html>