<?php

function add_payment_modes($name, $banks)
{
	$sql = "INSERT INTO ".TB_PREF."payment_modes (name,
            banks,inactive)
            VALUES (" .
            db_escape($name) . ", " . db_escape($banks) . ", 0)";
	
   	db_query($sql,"The payment Mode could not be added");
}

function update_payment_modes($id,$name,$banks)
{
    $sql = "UPDATE ".TB_PREF."payment_modes SET name=" . db_escape($name) . ",
            banks=" . db_escape($banks) . "
            WHERE id=" .db_escape($id);
   	db_query($sql,"The payment mode could not be updated");
}

function delete_payment_modes($selected_id)
{
	$sql="DELETE FROM ".TB_PREF."payment_modes WHERE id=".db_escape($selected_id);
	db_query($sql,"could not delete a payment modes");
}

function get_payment_modes($selected_id)
{
	$sql = "SELECT * 
	 FROM ".TB_PREF."payment_modes t WHERE id=".db_escape($selected_id);

	$result = db_query($sql,"could not get payment mode");

	return db_fetch($result);
}

function get_payment_modes_all($show_inactive)
{
	$sql = "SELECT * FROM ".TB_PREF."payment_modes";
	if (!$show_inactive) $sql .= " WHERE !inactive";
	return db_query($sql,"could not get payment modes");
}