<?php
/**********************************************************************
	Copyright (C) Evolve Techniologies
	Author : Danushka Widanage
	Email : dwidanage@gmail.com
	Company : Evolve Technologies(pvt)Ltd
***********************************************************************/
function add_main_category($description)
{
	$sql = "INSERT INTO ".TB_PREF."main_category (main_cat_name)
		VALUES (".db_escape($description).")";

	db_query($sql,"main category could not be added");
}

function update_main_category($id, $description)

{
	$sql = "UPDATE ".TB_PREF."main_category SET main_cat_name = ".db_escape($description)." WHERE main_category_id = ".db_escape($id);

	db_query($sql,"an item category could not be updated");
}

function delete_main_category($id)
{
	$sql="DELETE FROM ".TB_PREF."main_category WHERE main_category_id=".db_escape($id);

	db_query($sql,"main category could not be deleted");
}

function get_main_categories($show_inactive)
{
	$sql = "SELECT mc.* FROM ".TB_PREF."main_category AS mc ";
	if (!$show_inactive) $sql .= " WHERE !mc.inactive";

	return db_query($sql, "could not get main categories");
}

function get_main_category($id)
{
	$sql="SELECT * FROM ".TB_PREF."main_category WHERE main_category_id=".db_escape($id);

	$result = db_query($sql,"main category could not be retrieved");

	return db_fetch($result);
}

function get_main_category_name($id)
{
	$sql = "SELECT main_cat_name FROM ".TB_PREF."main_category WHERE main_category_id=".db_escape($id);

	$result = db_query($sql, "could not get sales type");

	$row = db_fetch_row($result);
	return $row[0];
}

?>