<?php
require_once (PATH_TABLES . "activity/salesquotation/SalesQuotationAdditionalAttachmentTable.php") ;
require_once (PATH_MODELS . "base/MasterBase.php") ;

class SalesQuotationAdditionalAttachmentClass extends MasterBase {
	function __construct($db) {
		$this->db 		= $db ;
		$this->tbl 		= SalesQuotationAdditionalAttachmentTable::C_TABLE ;
		$this->fldid 	= SalesQuotationAdditionalAttachmentTable::C_ID ;
		$this->flddesc 	= SalesQuotationAdditionalAttachmentTable::C_CAPTION ;
	}
	function __destruct() {
	}
    function deleteAllRecord(){
        $sql = "DELETE FROM ".SalesQuotationAdditionalAttachmentTable::C_TABLE;        
        $this->db->executeSql($sql);
    }
	function getAttachmentList($id) {     
        $sql = "SELECT A.*, S.".SalesQuotationAttachmentTable::C_DOC_NAME.", S.".SalesQuotationAttachmentTable::C_DESC.", S.".SalesQuotationAttachmentTable::C_ATTACH_ID.", S.".SalesQuotationAttachmentTable::C_ID.
		" FROM ".SalesQuotationAdditionalAttachmentTable::C_TABLE." A ".
		" LEFT OUTER JOIN ".SalesQuotationAttachmentTable::C_TABLE." S ".
		" ON S.".SalesQuotationAttachmentTable::C_ATTACH_ID." = A.".SalesQuotationAdditionalAttachmentTable::C_ID.
		" AND S.".SalesQuotationAttachmentTable::C_TYPE." = 1 ".
		" AND S.".SalesQuotationAttachmentTable::C_ID." = ".$id.
		" ORDER BY A.".SalesQuotationAdditionalAttachmentTable::C_ORDER;
		
        $rows = $this->db->getTable($sql) ;
        
        if(is_null($rows) || count($rows) == 0){
            return null;
        }else {
            return $rows;
        }
    }
}
?>