<?php
require_once (PATH_TABLES . "admin/BusinessNatureTable.php") ;
require_once (PATH_MODELS . "base/MasterBase.php") ;

class BusinessNatureClass extends MasterBase {
	
	function __construct($db) {
		$this->db 			= $db ;
		$this->tbl 			= BusinessNatureTable::C_TABLE ;
		$this->fldid 		= BusinessNatureTable::C_ID ;
		$this->flddesc 		= BusinessNatureTable::C_DESC ;
	}
	function __destruct() {
	}

	function isNameFound($name) {
		$filter = $this->db->fieldParam($this->flddesc);
		$params = array() ;
		$params[] = $this->db->valueParam($this->flddesc,$name) ;
		if ($this->db->getRowsCount($this->tbl,$filter,$params) > 0 )
			return true ;
		else
			return false ;
	}

	function deleteSettingRecord($ids){
		$sql = "delete from ". $this->tbl ." where ". $this->fldid ." in ( ".$ids.") ";
		$this->db->executeSql($sql);
	}

	function getBusinessIDByDesc($desc){
		$sql = "SELECT * FROM " . $this->tbl . " WHERE " . BusinessNatureTable::C_DESC . " = '" . $desc . "'";
		
		$rows = $this->db->getTable($sql);

		if(!is_null($rows) && count($rows) > 0){
			return $rows[0][BusinessNatureTable::C_ID];
		}
		return null;
	}
}
?>