<?php
require_once (PATH_TABLES . "activity/invoice/InvoiceHeaderTable.php") ;
require_once (PATH_MODELS . "base/MasterBase.php") ;

class InvoiceHeaderClass extends MasterBase {
	function __construct($db) {
		$this->db = $db ;
		$this->tbl = InvoiceHeaderTable::C_TABLE ;
		$this->fldid = InvoiceHeaderTable::C_ID ;
		$this->flddesc = InvoiceHeaderTable::C_INVOICE_NUMBER ;
	}
	function __destruct() {
	}
	

    function getExportInvoiceList($fromDate, $toDate) {
        $sql = "SELECT I.*, ".
				" S.".SalesQuotationTable::C_CUSTOMER_NUMBER.", S.".SalesQuotationTable::C_CUSTOMER_ID.", S.".SalesQuotationTable::C_PROSPECT.", S.".SalesQuotationTable::C_PROSPECT_NAME.", S.".SalesQuotationTable::C_CURRENCY.", S.".SalesQuotationTable::C_BU.
                " FROM " .InvoiceHeaderTable::C_TABLE." I ".
                " LEFT OUTER JOIN " .SalesQuotationTable::C_TABLE." S ON S.".SalesQuotationTable::C_ID." = I.".InvoiceHeaderTable::C_ID.
                " WHERE I.".InvoiceHeaderTable::C_CREATE_DATE." BETWEEN '".$fromDate." 00:00' AND '".$toDate." 23:59' AND I.".InvoiceHeaderTable::C_CREATE_DATE." <> '".NULL_DATE."' ";
        $orderby = " ORDER BY " .InvoiceHeaderTable::C_CREATE_DATE. " DESC";
        $rows = $this->db->getTable($sql . $orderby);

        if(!is_null($rows) && count($rows) > 0){
            return $rows;
        } else {
            return null;
        }
    }
}
?>