2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU Affero General Public License,
5 AGPL, as published by the Free Software Foundation, either version
6 3 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/agpl-3.0.html>.
11 ***********************************************************************/
15 include_once($path_to_root . "/includes/session.inc");
17 include_once($path_to_root . "/includes/date_functions.inc");
18 include_once($path_to_root . "/includes/ui.inc");
19 include_once($path_to_root . "/includes/data_checks.inc");
21 include_once($path_to_root . "/reporting/includes/reporting.inc");
23 if ($use_popup_windows)
24 $js .= get_js_open_window(800, 500);
25 page(_("View or Print Transactions"), false, false, "", $js);
27 //----------------------------------------------------------------------------------------
29 function viewing_controls()
31 display_note(_("Only documents can be printed."));
32 start_form(false, true);
34 start_table("class='tablestyle_noborder'");
37 systypes_list_cells(_("Type:"), 'filterType', null, true);
39 if (!isset($_POST['FromTransNo']))
40 $_POST['FromTransNo'] = "1";
41 if (!isset($_POST['ToTransNo']))
42 $_POST['ToTransNo'] = "999999";
44 ref_cells(_("from #:"), 'FromTransNo');
46 ref_cells(_("to #:"), 'ToTransNo');
48 submit_cells('ProcessSearch', _("Search"), '', '', true);
56 //----------------------------------------------------------------------------------------
58 function check_valid_entries()
60 if (!is_numeric($_POST['FromTransNo']) OR $_POST['FromTransNo'] <= 0)
62 display_error(_("The starting transaction number is expected to be numeric and greater than zero."));
66 if (!is_numeric($_POST['ToTransNo']) OR $_POST['ToTransNo'] <= 0)
68 display_error(_("The ending transaction number is expected to be numeric and greater than zero."));
71 if (!isset($_POST['filterType']) || $_POST['filterType'] == "")
77 //----------------------------------------------------------------------------------------
79 function handle_search()
82 if (check_valid_entries()==true)
84 $db_info = get_systype_db_info($_POST['filterType']);
89 $table_name = $db_info[0];
90 $type_name = $db_info[1];
91 $trans_no_name = $db_info[2];
92 $trans_ref = $db_info[3];
94 $sql = "SELECT DISTINCT $trans_no_name ";
97 $sql .= " ,$trans_ref ";
99 $sql .= " FROM $table_name
100 WHERE $trans_no_name >= " . $_POST['FromTransNo']. "
101 AND $trans_no_name <= " . $_POST['ToTransNo'];
103 if ($type_name != null)
104 $sql .= " AND $type_name = " . $_POST['filterType'];
106 $sql .= " ORDER BY $trans_no_name";
108 $result = db_query($sql, "could not query transactions on $table_name");
110 if (db_num_rows($result) == 0)
112 display_notification(_("There are no transactions for the given parameters."));
115 $print_type = $_POST['filterType'];
116 $print_out = ($print_type == 10 || $print_type == 11 || $print_type == systypes::cust_dispatch() ||
117 $print_type == systypes::po() || $print_type == systypes::sales_order());
121 $th = array(_("#"), _("Reference"), _("View"), _("Print"), _("GL"));
123 $th = array(_("#"), _("View"), _("Print"), _("GL"));
128 $th = array(_("#"), _("Reference"), _("View"), _("GL"));
130 $th = array(_("#"), _("View"), _("GL"));
132 div_start('transactions');
133 start_table($table_style);
136 while ($line = db_fetch($result))
139 alt_table_row_color($k);
141 label_cell($line[$trans_no_name]);
143 label_cell($line[$trans_ref]);
144 label_cell(get_trans_view_str($_POST['filterType'],$line[$trans_no_name], _("View"), ICON_VIEW));
146 label_cell(print_document_link($line[$trans_no_name], _("Print"), true, $print_type, ICON_PRINT));
147 label_cell(get_gl_view_str($_POST['filterType'], $line[$trans_no_name]));
158 //----------------------------------------------------------------------------------------
160 if (isset($_POST['ProcessSearch']))
162 if (!check_valid_entries())
163 unset($_POST['ProcessSearch']);
164 $Ajax->activate('transactions');
167 //----------------------------------------------------------------------------------------