<?php

$page_security = 'SA_CHANGE_DOC_APP_GROUP';
$path_to_root = "../..";

include($path_to_root . "/includes/session.inc");
include_once ($path_to_root . "/trace.php");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/gl/includes/ui/change_approved_transaction_ui.inc"); 
include_once($path_to_root . "/gl/includes/db/change_approved_transaction_db.inc"); 
include_once($path_to_root . "/admin/db/list_values_db.inc"); 
            
$js = "";
$js .= get_js_open_window(900, 500);
$js .= get_js_date_picker();

page(_($help_context = "Change Approved Transaction"), @$_REQUEST['popup'], false, "", $js);

if (isset($_POST['Update_CAT'])) {
    $msg = change_approved_transaction();
        if ($msg['success'] === false) {
            if (isset($msg['set_focus'])) {
                set_focus($msg['set_focus']);
            }
            display_error($msg['message']);
        } else {
            display_notification($msg['message']);
        }
}

if (isset($_POST['Refresh'])) {
    unset($_POST['due_date']);
}

start_form(true);

    global $Ajax;

    $Ajax->activate('change_approved_transaction');
    div_start('change_approved_transaction');

        display_change_approved_transaction_selection_parameters(); 
        
        if ($_POST['tran_type'] > 0 && $_POST['document_no'] > 0) {
            $show_button = display_change_approved_transaction_details($_POST['tran_type'], $_POST['document_no']); 
                if ($show_button === true) {
                    submit_center_first('Update_CAT', 'Update', false, false, ICON_SUBMIT);                    br(2);
                }
        } else {
            display_note("Please select a transaction type and enter valid transaction number.", 1, 2, "style=color:red");
        }

    div_end();

end_form();

end_page(@$_REQUEST['popup']);

?>