<?php
require_once (PATH_TABLES . "activity/ChecklistHeaderTable.php") ;
require_once (PATH_TABLES . "activity/ChecklistDetailTable.php") ;
require_once (PATH_TABLES . "activity/ChecklistActivityTable.php") ;
require_once (PATH_MODELS . "base/MasterBase.php") ;

class ChecklistActivityClass extends MasterBase {
	function __construct($db) {
		$this->db 		= $db ;
		$this->tbl 		= ChecklistActivityTable::C_TABLE ;
		$this->fldid 	= ChecklistActivityTable::C_ID ;
	}
	function __destruct() {
	}

	function deteleChecklist($activity_id){
		$sql = " DELETE FROM " . ChecklistActivityTable::C_TABLE . " " .
                " WHERE " . ChecklistActivityTable::C_ACTIVITY_ID . " = " .$activity_id."";
        
        $this->db->executeSql($sql);
	}

	function getChecklistActivity($activity_id,$assignment_id, $checklist_header_id,$checklist_detail_id,$line_no){
		$sql = "SELECT * ". 
                " FROM " . ChecklistActivityTable::C_TABLE . "  " .
				" WHERE " . ChecklistActivityTable::C_ACTIVITY_ID . " = " . $activity_id ." ".
				" AND ". ChecklistActivityTable::C_ASSIGNMENT_ID . " = " . $assignment_id ." ".
				" AND ". ChecklistActivityTable::C_ACTIVITY_LINE_NO . " = " . $line_no ." ".
				" AND ". ChecklistActivityTable::C_HEADER_ID . " = " . $checklist_header_id ." ".
				" AND ". ChecklistActivityTable::C_DETAIL_ID . " = " . $checklist_detail_id ." ";
        
        $result = null;
        try{
			$result = $this->db->getTable($sql);
			
        } catch (Exception $e){
            Log::write("[ChecklistDetailClass]" . $e->getMessage());
        }
        
        return $result;
        
	}
	
}
?>