5 include_once($path_to_root . "/includes/session.inc");
7 page(_("Void a Transaction"));
9 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/includes/ui.inc");
11 include_once($path_to_root . "/includes/data_checks.inc");
13 include_once($path_to_root . "/admin/db/voiding_db.inc");
15 //----------------------------------------------------------------------------------------
17 function voiding_controls()
21 start_form(false, true);
23 start_table($table_style2);
25 systypes_list_row(_("Transaction Type:"), "filterType", null, true);
27 text_row(_("Transaction #:"), 'trans_no', null, 12, 12);
29 date_row(_("Voiding Date:"), 'date_');
31 textarea_row(_("Memo:"), 'memo_', null, 30, 4);
35 if (!isset($_POST['ProcessVoiding']))
36 submit_center('ProcessVoiding', _("Void Transaction"));
40 display_note(_("Are you sure you want to void this transaction ? This action cannot be undone."), 0, 1);
41 submit_center_first('ConfirmVoiding', _("Proceed"));
42 submit_center_last('CancelVoiding', _("Cancel"));
48 //----------------------------------------------------------------------------------------
50 function check_valid_entries()
52 if (!is_date($_POST['date_']))
54 display_error(_("The entered date is invalid."));
57 if (!is_date_in_fiscalyear($_POST['date_']))
59 display_error(_("The entered date is not in fiscal year."));
63 if (!is_numeric($_POST['trans_no']) OR $_POST['trans_no'] <= 0)
65 display_error(_("The transaction number is expected to be numeric and greater than zero."));
72 //----------------------------------------------------------------------------------------
74 function handle_void_transaction()
76 if (check_valid_entries()==true)
79 $void_entry = get_voided_entry($_POST['filterType'], $_POST['trans_no']);
80 if ($void_entry != null)
82 display_error(_("The selected transaction has already been voided."), true);
83 unset($_POST['trans_no']);
84 unset($_POST['memo_']);
85 unset($_POST['date_']);
89 $ret = void_transaction($_POST['filterType'], $_POST['trans_no'],
90 $_POST['date_'], $_POST['memo_']);
94 display_notification_centered(_("Selected transaction has been voided."));
95 unset($_POST['trans_no']);
96 unset($_POST['memo_']);
97 unset($_POST['date_']);
100 display_error(_("The entered transaction does not exist or cannot be voided."));
104 //----------------------------------------------------------------------------------------
106 if (!isset($_POST['date_']))
108 $_POST['date_'] = Today();
109 if (!is_date_in_fiscalyear($_POST['date_']))
110 $_POST['date_'] = end_fiscalyear();
113 if (isset($_POST['ProcessVoiding']))
115 if (!check_valid_entries())
116 unset($_POST['ProcessVoiding']);
119 if (isset($_POST['ConfirmVoiding']))
121 handle_void_transaction();
124 //----------------------------------------------------------------------------------------