2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
13 //--------------------------------------------------------------------------------------
15 function get_sql_for_view_transactions($filtertype, $from, $to, &$trans_ref)
17 $db_info = get_systype_db_info($filtertype);
22 $table_name = $db_info[0];
23 $type_name = $db_info[1];
24 $trans_no_name = $db_info[2];
25 $trans_ref = $db_info[3];
27 $sql = "SELECT DISTINCT $trans_no_name as trans_no";
30 $sql .= " ,$trans_ref ";
32 $sql .= ", ".$filtertype." as type FROM $table_name
33 WHERE $trans_no_name >= ".db_escape($from). "
34 AND $trans_no_name <= ".db_escape($to);
36 if ($type_name != null)
37 $sql .= " AND `$type_name` = ".db_escape($filtertype);
39 $sql .= " ORDER BY $trans_no_name";