<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_SALESORDER';
$path_to_root = "../..";

include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/payroll/includes/ui/salary_advance_payments_ui.inc"); 
include_once($path_to_root . "/payroll/includes/db/salary_advances_db.inc"); 
include_once($path_to_root . "/petty_cash/includes/db/petty_cash_float_adjustments_db.inc"); 
include_once($path_to_root . "/payroll/includes/db/employees_db.inc"); 
include_once($path_to_root . "/admin/db/list_values_db.inc"); 

$js = "";
$js .= get_js_open_window(800, 500);

page(_($help_context = "View Salary Advance"), true, false, "", $js);

if ($_GET['trans_no'] > 0) {
    $tran_no = $_GET['trans_no'];
}

function view_salary_advance_details($tran_no) {
    global $payroll_approval_statuses;
    
    $row = get_salary_advance_details($tran_no);
        start_outer_table(TABLESTYLE2, "width=60%");

            table_section(1, "50%");
                label_row(_("Employee:"), get_employee_formatted_long_name($row['employee_code']), "class='tableheader2'");
                label_row(_("Type:"), get_listvalue_name_by_id($row['type_id']), "class='tableheader2'");
                label_row(_("Due Date:"), sql2date($row['due_date']), "class='tableheader2'");

            table_section(2, "50%");
                label_row(_("Salary Advance:"), number_format($row['salary_advance'], 2), "class='tableheader2'");
                label_row(_("Approval Status:"), $payroll_approval_statuses[$row['status_code']], "class='tableheader2'");
                label_row(_("Comment:"), nl2br($row['comments']), "class='tableheader2'");

        end_outer_table(2);
}

    display_heading("Salary Advance #$tran_no");    br();

    view_salary_advance_details($tran_no);

    display_heading("Salary Advance Payments");    br();
    
    view_salary_advance_payment(ST_SALARY_ADVANCE, $tran_no);

end_page(true, false, false, ST_POINTSUPDATE, $tran_no);

?>
