5 include_once($path_to_root . "/includes/session.inc");
7 include_once($path_to_root . "/includes/date_functions.inc");
8 include_once($path_to_root . "/includes/ui.inc");
9 include_once($path_to_root . "/includes/data_checks.inc");
11 include_once($path_to_root . "/admin/db/voiding_db.inc");
14 $js .= get_js_date_picker();
15 page(_("Void a Transaction"), false, false, "", $js);
17 //----------------------------------------------------------------------------------------
19 function voiding_controls()
23 start_form(false, true);
25 start_table($table_style2);
27 systypes_list_row(_("Transaction Type:"), "filterType", null, true);
29 text_row(_("Transaction #:"), 'trans_no', null, 12, 12);
31 date_row(_("Voiding Date:"), 'date_');
33 textarea_row(_("Memo:"), 'memo_', null, 30, 4);
37 if (!isset($_POST['ProcessVoiding']))
38 submit_center('ProcessVoiding', _("Void Transaction"), true, '', true);
42 display_note(_("Are you sure you want to void this transaction ? This action cannot be undone."), 0, 1);
43 submit_center_first('ConfirmVoiding', _("Proceed"), '', true);
44 submit_center_last('CancelVoiding', _("Cancel"), '', true);
50 //----------------------------------------------------------------------------------------
52 function check_valid_entries()
54 if (!is_date($_POST['date_']))
56 display_error(_("The entered date is invalid."));
60 if (!is_date_in_fiscalyear($_POST['date_']))
62 display_error(_("The entered date is not in fiscal year."));
67 if (!is_numeric($_POST['trans_no']) OR $_POST['trans_no'] <= 0)
69 display_error(_("The transaction number is expected to be numeric and greater than zero."));
70 set_focus('trans_no');
77 //----------------------------------------------------------------------------------------
79 function handle_void_transaction()
81 if (check_valid_entries()==true)
84 $void_entry = get_voided_entry($_POST['filterType'], $_POST['trans_no']);
85 if ($void_entry != null)
87 display_error(_("The selected transaction has already been voided."), true);
88 unset($_POST['trans_no']);
89 unset($_POST['memo_']);
90 unset($_POST['date_']);
91 set_focus('trans_no');
95 $ret = void_transaction($_POST['filterType'], $_POST['trans_no'],
96 $_POST['date_'], $_POST['memo_']);
100 display_notification_centered(_("Selected transaction has been voided."));
101 unset($_POST['trans_no']);
102 unset($_POST['memo_']);
103 unset($_POST['date_']);
106 display_error(_("The entered transaction does not exist or cannot be voided."));
107 set_focus('trans_no');
113 //----------------------------------------------------------------------------------------
115 if (!isset($_POST['date_']))
117 $_POST['date_'] = Today();
118 if (!is_date_in_fiscalyear($_POST['date_']))
119 $_POST['date_'] = end_fiscalyear();
122 if (isset($_POST['ProcessVoiding']))
124 if (!check_valid_entries())
125 unset($_POST['ProcessVoiding']);
126 $Ajax->activate('_page_body');
129 if (isset($_POST['ConfirmVoiding']))
131 handle_void_transaction();
132 $Ajax->activate('_page_body');
135 if (isset($_POST['CancelVoiding']))
137 $Ajax->activate('_page_body');
140 //----------------------------------------------------------------------------------------