<?php
/**********************************************************************
***********************************************************************/
//-------------------------------------------------------------------------------------------------------------

function get_sql_for_manufacturing_transaction_inquiry($location, $from_date, $to_date, $type)
{

    $sql = "SELECT vmt.type, vmt.row_id, vmt.reference, vmt.tran_date, l.location_name 
            FROM 0_vw_manufacturing_transactions vmt,
                    0_locations l 
            WHERE vmt.location = l.loc_code AND 
                    vmt.tran_date >= ".db_escape(date2sql($from_date))." AND 
                    vmt.tran_date <= ".db_escape(date2sql($to_date))."   ";


   	if ($location != null) {
   		$sql .= " AND vmt.location = ".db_escape($location);
	}
	if ($type != null) 
	{
		$sql .= " AND vmt.type = ".db_escape($type);
	} 
	
        $sql .= " ORDER BY vmt.tran_date";
        
   	return $sql;
}
?>