<?php
require_once (PATH_TABLES . "hr/DepartmentInterPermissionTable.php") ;
require_once (PATH_TABLES . "hr/DepartmentTable.php") ;
require_once (PATH_MODELS . "base/MasterBase.php") ;

class DepartmentInterPermissionClass extends MasterBase {
	function __construct($db) {
		$this->db = $db ;
		$this->tbl = DepartmentInterPermissionTable::C_TABLE ;
		$this->fldid = DepartmentInterPermissionTable::C_ID ;
	}
	function __destruct() {
	}
    function getInterPermission($id){
        $sql = "SELECT DIP.*, D." . DepartmentTable::C_DESC . " " . 
                " FROM " . DepartmentInterPermissionTable::C_TABLE . " DIP " .
                " LEFT OUTER JOIN " . DepartmentTable::C_TABLE . " D ON (D." . DepartmentTable::C_ID . " = DIP." . DepartmentInterPermissionTable::C_INTER . ")" .
                " WHERE DIP." . DepartmentInterPermissionTable::C_ID . " = " . $id . " " .
                " ORDER BY D." . DepartmentTable::C_DESC . " ";
        
        $result = null;
        try{
            $result = $this->db->getTable($sql);
        } catch (Exception $e){
            Log::write("[DepartmentInterPermissionClass]" . $e->getMessage());
        }
        
        return $result;
    }
    function deleteInterPermission($id, $inter_id){
        $sql = "DELETE FROM " . DepartmentInterPermissionTable::C_TABLE . 
                " WHERE " . DepartmentInterPermissionTable::C_ID . " = " . $id. 
                " AND " . DepartmentInterPermissionTable::C_INTER . " = " . $inter_id;
        
        try{
            $this->db->executeSql($sql);
        } catch (Exception $e){
            Log::write("[DepartmentInterPermissionClass]" . $e->getMessage());
        }
    }
}
?>