<?php
include("config.inc.php");
include("function.inc.php");

session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}
	$pmcode  = $_POST['pmcode'];
    $pmdesc  = $_POST['pmdesc'];
	$actionmode = $_GET['actionmode'];
	$paymentmode_code = $_POST['paymentmode_code'];
	$paymentmode_cod = $_GET['paymentmode_cod'];
	//echo $actionmode;exit;
	 if ($actionmode =='save'){ 
	   $query = "insert into payment_mode (paymentmode_code, paymentmode_desc)".
					" values (".GetSQLValueString($pmcode,'text').", ".GetSQLValueString($pmdesc,'text').");";
					
		$result=mysql_query($query,$connection);
	  	//echo $query;exit;
		header("Location: ./Form_Paymentmode.php");
		exit;

	  }
	  
	  if ($actionmode =='delete'){
	   $queryd = "delete from payment_mode where paymentmode_code='$paymentmode_cod'";
		$resultd=mysql_query($queryd,$connection);
	  	//echo $query;exit;
		header("Location: ./Form_Paymentmode.php");
		exit;

	  }

	   if ($actionmode =='edit'){		  
	     	$queryedt="update payment_mode
   							set  	paymentmode_code=".GetSQLValueString($pmcode,'text').", 
   									paymentmode_desc=".GetSQLValueString($pmdesc,'text')."
   							where 	paymentmode_code='$paymentmode_code'";
   	$resultedt=mysql_query($queryedt,$connection);
//echo $queryedt;exit;	
   	header("Location: ./Form_Paymentmode.php");
exit;
   }
?>