6 include_once($path_to_root . "/includes/session.inc");
8 page(_("View or Print Transactions"));
10 include_once($path_to_root . "/includes/date_functions.inc");
11 include_once($path_to_root . "/includes/ui.inc");
12 include_once($path_to_root . "/includes/data_checks.inc");
14 include_once($path_to_root . "/reporting/includes/reporting.inc");
16 //----------------------------------------------------------------------------------------
18 function viewing_controls()
20 start_form(false, true);
22 start_table("class='tablestyle_noborder'");
25 systypes_list_cells(_("Type:"), 'filterType', null, true);
27 ref_cells(_("from #:"), 'FromTransNo');
29 ref_cells(_("to #:"), 'ToTransNo');
31 submit_cells('ProcessSearch', _("Search"));
39 //----------------------------------------------------------------------------------------
41 function check_valid_entries()
43 if (!is_numeric($_POST['FromTransNo']) OR $_POST['FromTransNo'] <= 0)
45 display_note(_("The starting transaction number is expected to be numeric and greater than zero."));
49 if (!is_numeric($_POST['ToTransNo']) OR $_POST['ToTransNo'] <= 0)
51 echo _("The ending transaction number is expected to be numeric and greater than zero.");
58 //----------------------------------------------------------------------------------------
60 function handle_search()
63 if (check_valid_entries()==true)
65 $db_info = get_systype_db_info($_POST['filterType']);
67 $table_name = $db_info[0];
68 $type_name = $db_info[1];
69 $trans_no_name = $db_info[2];
70 $trans_ref = $db_info[3];
72 $sql = "SELECT DISTINCT $trans_no_name ";
75 $sql .= " ,$trans_ref ";
77 $sql .= " FROM $table_name
78 WHERE $trans_no_name >= " . $_POST['FromTransNo']. "
79 AND $trans_no_name <= " . $_POST['ToTransNo'];
81 if ($type_name != null)
82 $sql .= " AND $type_name = " . $_POST['filterType'];
84 $sql .= " ORDER BY $trans_no_name";
86 $result = db_query($sql, "could not query transactions on $table_name");
88 if (db_num_rows($result) == 0)
90 echo _("There are no transactions for the given parameters.");
94 start_table($table_style);
96 $th = array(_("#"), _("Reference"), _("View"), _("Print"));
98 $th = array(_("#"), _("View"), _("Print"));
101 while ($line = db_fetch($result))
104 alt_table_row_color($k);
106 label_cell($line[$trans_no_name]);
108 label_cell($line[$trans_ref]);
109 label_cell(get_trans_view_str($_POST['filterType'],$line[$trans_no_name], _("View")));
110 label_cell(get_gl_view_str_cell($_POST['filterType'], $line[$trans_no_name], _("View GL")));
112 $forms = get_form_entries($_POST['filterType'], $line[$trans_no_name]);
113 while ($form_item = db_fetch($forms))
116 $param1 = $form_item['param1'];
117 $param2 = $form_item['param2'];
119 if ($_POST['filterType'] == systypes::bank_payment()
120 || $_POST['filterType'] == systypes::bank_deposit()
121 || $_POST['filterType'] == systypes::cust_payment()
122 || $_POST['filterType'] == systypes::supp_payment())
124 $param1 = payment_person_types::type_name($form_item['param1']);
125 $param2 = payment_person_types::person_name($form_item['param1'], $form_item['param2'], false);
128 //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));
138 //----------------------------------------------------------------------------------------
140 if (isset($_POST['ProcessSearch']))
142 if (!check_valid_entries())
143 unset($_POST['ProcessSearch']);
146 //----------------------------------------------------------------------------------------
150 //echo getHiddenFieldScript();