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"));
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"));
44 submit_center_last('CancelVoiding', _("Cancel"));
50 //----------------------------------------------------------------------------------------
52 function check_valid_entries()
54 if (!is_date($_POST['date_']))
56 display_error(_("The entered date is invalid."));
59 if (!is_date_in_fiscalyear($_POST['date_']))
61 display_error(_("The entered date is not in fiscal year."));
65 if (!is_numeric($_POST['trans_no']) OR $_POST['trans_no'] <= 0)
67 display_error(_("The transaction number is expected to be numeric and greater than zero."));
74 //----------------------------------------------------------------------------------------
76 function handle_void_transaction()
78 if (check_valid_entries()==true)
81 $void_entry = get_voided_entry($_POST['filterType'], $_POST['trans_no']);
82 if ($void_entry != null)
84 display_error(_("The selected transaction has already been voided."), true);
85 unset($_POST['trans_no']);
86 unset($_POST['memo_']);
87 unset($_POST['date_']);
91 $ret = void_transaction($_POST['filterType'], $_POST['trans_no'],
92 $_POST['date_'], $_POST['memo_']);
96 display_notification_centered(_("Selected transaction has been voided."));
97 unset($_POST['trans_no']);
98 unset($_POST['memo_']);
99 unset($_POST['date_']);
102 display_error(_("The entered transaction does not exist or cannot be voided."));
106 //----------------------------------------------------------------------------------------
108 if (!isset($_POST['date_']))
110 $_POST['date_'] = Today();
111 if (!is_date_in_fiscalyear($_POST['date_']))
112 $_POST['date_'] = end_fiscalyear();
115 if (isset($_POST['ProcessVoiding']))
117 if (!check_valid_entries())
118 unset($_POST['ProcessVoiding']);
121 if (isset($_POST['ConfirmVoiding']))
123 handle_void_transaction();
126 //----------------------------------------------------------------------------------------