<?php
include("db_connection.php");
$Mainclass=new DB_Controller();

$rate_of_24k=$_REQUEST['rate_of_24k'];
$Date=date('Y-m-d H:i:s');


	$fetch_per_22 = $Mainclass->Fetch_individual_data("gold_rate_percentage_master","Customer_Price,Dealer_Price","Karat='22'");

	$cus_percentage_22 = $fetch_per_22['Customer_Price'];

	$dealer_percentage_22 = $fetch_per_22['Dealer_Price'];

	$Selling_Rate_22 = round($rate_of_24k*$cus_percentage_22,2);

	$Buying_Rate_22 = $Selling_Rate_22-100;

	$Dealer_Rate_22 = round($rate_of_24k*$dealer_percentage_22,2);

	$Fields="`Karat`,`Buying_Rate`,`Selling_Rate`,`Entry_Date`,`Created_By`,`Creation_IP`,`Dealer_Rate`";
	$Values="'22K','".$Buying_Rate_22."','".$Selling_Rate_22."','".$Date."','".$_COOKIE['User_Name']."','".$_SERVER['REMOTE_ADDR']."','".$Dealer_Rate_22."'";
	$Ins=$Mainclass->Insert_Data('gold_rate_master',$Fields,$Values);



	$fetch_per_18 = $Mainclass->Fetch_individual_data("gold_rate_percentage_master","Customer_Price,Dealer_Price","Karat='18'");

	$cus_percentage_18 = $fetch_per_18['Customer_Price'];

	$dealer_percentage_18 = $fetch_per_18['Dealer_Price'];

	$Selling_Rate_18 = round($rate_of_24k*$cus_percentage_18,2);

	$Buying_Rate_18 = $Selling_Rate_18-100;

	$Dealer_Rate_18 = round($rate_of_24k*$dealer_percentage_18,2);

	$Fields="`Karat`,`Buying_Rate`,`Selling_Rate`,`Entry_Date`,`Created_By`,`Creation_IP`,`Dealer_Rate`";
	$Values="'18K','".$Buying_Rate_18."','".$Selling_Rate_18."','".$Date."','".$_COOKIE['User_Name']."','".$_SERVER['REMOTE_ADDR']."','".$Dealer_Rate_18."'";
	$Ins=$Mainclass->Insert_Data('gold_rate_master',$Fields,$Values);



	$fetch_per_14 = $Mainclass->Fetch_individual_data("gold_rate_percentage_master","Customer_Price,Dealer_Price","Karat='14'");

	$cus_percentage_14 = $fetch_per_14['Customer_Price'];

	$dealer_percentage_14 = $fetch_per_14['Dealer_Price'];

	$Selling_Rate_14 = round($rate_of_24k*$cus_percentage_14,2);

	$Buying_Rate_14 = $Selling_Rate_14-100;

	$Dealer_Rate_14 = round($rate_of_24k*$dealer_percentage_14,2);

	$Fields="`Karat`,`Buying_Rate`,`Selling_Rate`,`Entry_Date`,`Created_By`,`Creation_IP`,`Dealer_Rate`";
	$Values="'14K','".$Buying_Rate_14."','".$Selling_Rate_14."','".$Date."','".$_COOKIE['User_Name']."','".$_SERVER['REMOTE_ADDR']."','".$Dealer_Rate_14."'";
	$Ins=$Mainclass->Insert_Data('gold_rate_master',$Fields,$Values);


$Entry_Date=date('Y-m-d');
$Entry_Time=date('H:i:s');

$Mainclass->Insert_Data("gold_rate_log_master","Rate,Entry_Date,Entry_Time,Created_By,Creation_IP","'".$rate_of_24k."','".$Entry_Date."','".$Entry_Time."','".$_COOKIE['User_Name']."','".$_SERVER['REMOTE_ADDR']."' ");


$msg=0;

echo $msg;
?>