6 include_once($path_to_root . "/includes/session.inc");
8 include_once($path_to_root . "/includes/date_functions.inc");
9 include_once($path_to_root . "/includes/ui.inc");
10 include_once($path_to_root . "/includes/data_checks.inc");
12 include_once($path_to_root . "/reporting/includes/reporting.inc");
14 if ($use_popup_windows)
15 $js .= get_js_open_window(800, 500);
16 page(_("View or Print Transactions"), false, false, "", $js);
18 //----------------------------------------------------------------------------------------
20 function viewing_controls()
22 display_note(_("Only documents can be printed."));
23 start_form(false, true);
25 start_table("class='tablestyle_noborder'");
28 systypes_list_cells(_("Type:"), 'filterType', null, true);
30 if (!isset($_POST['FromTransNo']))
31 $_POST['FromTransNo'] = "1";
32 if (!isset($_POST['ToTransNo']))
33 $_POST['ToTransNo'] = "999999";
35 ref_cells(_("from #:"), 'FromTransNo');
37 ref_cells(_("to #:"), 'ToTransNo');
39 submit_cells('ProcessSearch', _("Search"));
47 //----------------------------------------------------------------------------------------
49 function check_valid_entries()
51 if (!is_numeric($_POST['FromTransNo']) OR $_POST['FromTransNo'] <= 0)
53 display_note(_("The starting transaction number is expected to be numeric and greater than zero."));
57 if (!is_numeric($_POST['ToTransNo']) OR $_POST['ToTransNo'] <= 0)
59 echo _("The ending transaction number is expected to be numeric and greater than zero.");
62 if (!isset($_POST['filterType']) || $_POST['filterType'] == "")
68 //----------------------------------------------------------------------------------------
70 function handle_search()
73 if (check_valid_entries()==true)
75 $db_info = get_systype_db_info($_POST['filterType']);
80 $table_name = $db_info[0];
81 $type_name = $db_info[1];
82 $trans_no_name = $db_info[2];
83 $trans_ref = $db_info[3];
85 $sql = "SELECT DISTINCT $trans_no_name ";
88 $sql .= " ,$trans_ref ";
90 $sql .= " FROM $table_name
91 WHERE $trans_no_name >= " . $_POST['FromTransNo']. "
92 AND $trans_no_name <= " . $_POST['ToTransNo'];
94 if ($type_name != null)
95 $sql .= " AND $type_name = " . $_POST['filterType'];
97 $sql .= " ORDER BY $trans_no_name";
99 $result = db_query($sql, "could not query transactions on $table_name");
101 if (db_num_rows($result) == 0)
103 echo _("There are no transactions for the given parameters.");
106 $print_type = $_POST['filterType'];
107 $print_out = ($print_type == 10 || $print_type == 11 || $print_type == systypes::cust_dispatch() ||
108 $print_type == systypes::po() || $print_type == systypes::sales_order());
111 print_hidden_script($print_type);
113 $th = array(_("#"), _("Reference"), _("View"), _("Print"), _("GL"));
115 $th = array(_("#"), _("View"), _("Print"), _("GL"));
120 $th = array(_("#"), _("Reference"), _("View"), _("GL"));
122 $th = array(_("#"), _("View"), _("GL"));
124 start_table($table_style);
127 while ($line = db_fetch($result))
130 alt_table_row_color($k);
132 label_cell($line[$trans_no_name]);
134 label_cell($line[$trans_ref]);
135 label_cell(get_trans_view_str($_POST['filterType'],$line[$trans_no_name], _("View")));
137 label_cell(print_document_link($line[$trans_no_name], _("Print"), true, $print_type));
138 label_cell(get_gl_view_str($_POST['filterType'], $line[$trans_no_name], _("View GL")));
148 //----------------------------------------------------------------------------------------
150 if (isset($_POST['ProcessSearch']))
152 if (!check_valid_entries())
153 unset($_POST['ProcessSearch']);
156 //----------------------------------------------------------------------------------------