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 start_form(false, true);
24 start_table("class='tablestyle_noborder'");
27 systypes_list_cells(_("Type:"), 'filterType', null, true);
29 ref_cells(_("from #:"), 'FromTransNo');
31 ref_cells(_("to #:"), 'ToTransNo');
33 submit_cells('ProcessSearch', _("Search"));
41 //----------------------------------------------------------------------------------------
43 function check_valid_entries()
45 if (!is_numeric($_POST['FromTransNo']) OR $_POST['FromTransNo'] <= 0)
47 display_note(_("The starting transaction number is expected to be numeric and greater than zero."));
51 if (!is_numeric($_POST['ToTransNo']) OR $_POST['ToTransNo'] <= 0)
53 echo _("The ending transaction number is expected to be numeric and greater than zero.");
60 //----------------------------------------------------------------------------------------
62 function handle_search()
65 if (check_valid_entries()==true)
67 $db_info = get_systype_db_info($_POST['filterType']);
69 $table_name = $db_info[0];
70 $type_name = $db_info[1];
71 $trans_no_name = $db_info[2];
72 $trans_ref = $db_info[3];
74 $sql = "SELECT DISTINCT $trans_no_name ";
77 $sql .= " ,$trans_ref ";
79 $sql .= " FROM $table_name
80 WHERE $trans_no_name >= " . $_POST['FromTransNo']. "
81 AND $trans_no_name <= " . $_POST['ToTransNo'];
83 if ($type_name != null)
84 $sql .= " AND $type_name = " . $_POST['filterType'];
86 $sql .= " ORDER BY $trans_no_name";
88 $result = db_query($sql, "could not query transactions on $table_name");
90 if (db_num_rows($result) == 0)
92 echo _("There are no transactions for the given parameters.");
96 start_table($table_style);
98 $th = array(_("#"), _("Reference"), _("View"), _("Print"));
100 $th = array(_("#"), _("View"), _("Print"));
103 while ($line = db_fetch($result))
106 alt_table_row_color($k);
108 label_cell($line[$trans_no_name]);
110 label_cell($line[$trans_ref]);
111 label_cell(get_trans_view_str($_POST['filterType'],$line[$trans_no_name], _("View")));
112 label_cell(get_gl_view_str_cell($_POST['filterType'], $line[$trans_no_name], _("View GL")));
114 $forms = get_form_entries($_POST['filterType'], $line[$trans_no_name]);
115 while ($form_item = db_fetch($forms))
118 $param1 = $form_item['param1'];
119 $param2 = $form_item['param2'];
121 if ($_POST['filterType'] == systypes::bank_payment()
122 || $_POST['filterType'] == systypes::bank_deposit()
123 || $_POST['filterType'] == systypes::cust_payment()
124 || $_POST['filterType'] == systypes::supp_payment())
126 $param1 = payment_person_types::type_name($form_item['param1']);
127 $param2 = payment_person_types::person_name($form_item['param1'], $form_item['param2'], false);
130 //label_cell(printTransaction(_("Print") . " " . getFormTypeName($form_item["form_type"]), $form_item['form_id'], $form_item['form_type'], $_POST['filterType'], $line[$trans_no_name], $line[$trans_ref], $param1, $param2));
140 //----------------------------------------------------------------------------------------
142 if (isset($_POST['ProcessSearch']))
144 if (!check_valid_entries())
145 unset($_POST['ProcessSearch']);
148 //----------------------------------------------------------------------------------------
152 //echo getHiddenFieldScript();