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

include_once($path_to_root . "/includes/session.inc");

include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/inventory.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/petty_cash/includes/db/petty_cash_float_reimbursement_inquiry_db.inc");
//include_once($path_to_root . "/petty_cash/includes/db/i_owe_you_advances_inquiry_db.inc");
//include_once($path_to_root . "/petty_cash/includes/ui/petty_cash_ui.inc");
//
//include_once($path_to_root . "/includes/common_functions.inc");
//include_once($path_to_root . "/includes/db/group_companies_db.inc");
//include_once($path_to_root . "/includes/ui/ui_input.inc");                


$js = "";
if ($SysPrefs->use_popup_windows){
	$js .= get_js_open_window(800, 500);
}

page(_($help_context = "View Reimbursement Details"), true, false, "", $js);

//-------------------------------------------------------------------------------------------------

$type_id = $trans_no = 0;

if ($_GET['trans_no'] != "")
{
	$trans_no = $_GET['trans_no'];
}

if ($_GET['type'] != "")
{
	$type_id = $_GET['type'];
}

global $approval_statuses;

function display_float_total_row($float_name, $float_total)
{
    label_cell("Total advances for $float_name:", "colspan=7 align=right");
    amount_cell($float_total, true); 
}

function display_petty_cash_float_reimbursement_details($type_id, $trans_no)
{
    global $systypes_array;

    div_start('price_table');
    
    start_table(TABLESTYLE2, "width=50%");

    $th = array("Rec Id", _("Reimb. No"), _("Tran. Type"), _("Tran. #"), _("Amount"));
    table_header($th);
    
    $q = view_petty_cash_float_reimbursement_details($type_id, $trans_no);
    
    $total = 0;
    
    while ($iou = db_fetch($q))
    {     
        
        start_row();    
        label_cell($iou["id"],"align=center");
        $iou_link = get_petty_cash_trans_view_str(ST_PETTY_CASH_FLOAT_REIMBUR, $iou['reimbursement_id']);
        label_cell($iou_link,"align=center","align=center");       
        label_cell($systypes_array[$iou["tran_type"]],"align=center");
        label_cell($iou["type_no"],"align=center");
        label_cell(number_format2($iou["amount"],2),"align=right");

        end_row();

        $total += $iou["amount"];
    }
   
    start_row();    
        label_cell("Total Reimbursed Amount:", "colspan=4 align=right");
        amount_cell($total, true); 
    end_row();

    end_table(1);  
    
    div_end();   
}

function display_petty_cash_float_reimbursement_header($type_id, $trans_no)
{    
    global $systypes_array;
    
    display_heading("Reimbusement Details for ".$systypes_array[$type_id]." #".$trans_no);

}


br(1);
display_petty_cash_float_reimbursement_header($type_id, $trans_no);
br(2);
display_petty_cash_float_reimbursement_details($type_id, $trans_no);

end_page(true, false, false);

?>
