Missing Popup window
[fa-stable.git] / admin / view_print_transaction.php
1 <?php
2
3 $path_to_root="..";
4 $page_security = 5;
5
6 include_once($path_to_root . "/includes/session.inc");
7
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");
11
12 include_once($path_to_root . "/reporting/includes/reporting.inc");
13 $js = "";
14 if ($use_popup_windows)
15         $js .= get_js_open_window(800, 500);
16 page(_("View or Print Transactions"), false, false, "", $js);
17
18 //----------------------------------------------------------------------------------------
19
20 function viewing_controls()
21 {
22     start_form(false, true);
23
24     start_table("class='tablestyle_noborder'");
25         start_row();
26
27         systypes_list_cells(_("Type:"), 'filterType', null, true);
28
29     ref_cells(_("from #:"), 'FromTransNo');
30
31     ref_cells(_("to #:"), 'ToTransNo');
32
33     submit_cells('ProcessSearch', _("Search"));
34
35         end_row();
36     end_table(1);
37
38         end_form();
39 }
40
41 //----------------------------------------------------------------------------------------
42
43 function check_valid_entries()
44 {
45         if (!is_numeric($_POST['FromTransNo']) OR $_POST['FromTransNo'] <= 0)
46         {
47                 display_note(_("The starting transaction number is expected to be numeric and greater than zero."));
48                 return false;
49         }
50
51         if (!is_numeric($_POST['ToTransNo']) OR $_POST['ToTransNo'] <= 0)
52         {
53                 echo _("The ending transaction number is expected to be numeric and greater than zero.");
54                 return false;
55         }
56
57         return true;
58 }
59
60 //----------------------------------------------------------------------------------------
61
62 function handle_search()
63 {
64         global $table_style;
65         if (check_valid_entries()==true)
66         {
67                 $db_info = get_systype_db_info($_POST['filterType']);
68
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];
73
74                 $sql = "SELECT DISTINCT $trans_no_name ";
75
76                 if ($trans_ref)
77                         $sql .= " ,$trans_ref ";
78
79                 $sql .= " FROM $table_name
80                         WHERE $trans_no_name >= " . $_POST['FromTransNo']. "
81                         AND  $trans_no_name <= " . $_POST['ToTransNo'];
82
83                 if ($type_name != null)
84                         $sql .= " AND $type_name = " . $_POST['filterType'];
85
86                 $sql .= " ORDER BY $trans_no_name";
87
88                 $result = db_query($sql, "could not query transactions on $table_name");
89
90                 if (db_num_rows($result) == 0) 
91                 {
92                         echo _("There are no transactions for the given parameters.");
93                         return;
94                 }
95
96                 start_table($table_style);
97                 if ($trans_ref)
98                         $th = array(_("#"), _("Reference"), _("View"), _("Print"));
99                 else    
100                         $th = array(_("#"), _("View"), _("Print"));
101                 table_header($th);      
102                 $k = 0;
103                 while ($line = db_fetch($result)) 
104                 {
105
106                         alt_table_row_color($k);
107
108                         label_cell($line[$trans_no_name]);
109                         if ($trans_ref)
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")));
113
114                 $forms = get_form_entries($_POST['filterType'], $line[$trans_no_name]);
115                 while ($form_item = db_fetch($forms)) 
116                 {
117
118                         $param1 = $form_item['param1'];
119                         $param2 = $form_item['param2'];
120
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()) 
125                         {
126                                 $param1 = payment_person_types::type_name($form_item['param1']);
127                                 $param2 = payment_person_types::person_name($form_item['param1'], $form_item['param2'], false);
128                         }
129
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));
131                 }
132                 end_row();
133
134                 }
135
136                 end_table();
137         }
138 }
139
140 //----------------------------------------------------------------------------------------
141
142 if (isset($_POST['ProcessSearch']))
143 {
144         if (!check_valid_entries())
145                 unset($_POST['ProcessSearch']);
146 }
147
148 //----------------------------------------------------------------------------------------
149
150 viewing_controls();
151
152 //echo getHiddenFieldScript();
153
154 handle_search();
155
156 br(2);
157
158 end_page();
159
160 ?>