<?php
/**********************************************************************
***********************************************************************/

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

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


include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/gl/includes/gl_db.inc");
include_once($path_to_root . "/petty_cash/includes/db/project_advance_batches_inquiry_db.inc");


$js = "";
if ($SysPrefs->use_popup_windows)
	$js .= get_js_open_window(800, 500);
page(_($help_context = "View Project Advances Batch"), true, false, "", $js);

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

$pab_header = view_project_advance_batch_header($trans_no);

display_heading('Project Advance Batch ' . " #$trans_no");

echo "<br>";
start_table(TABLESTYLE2, "width=40%");

start_row();

label_cells(_("Reference"), $pab_header['reference'], "class='tableheader2'");
end_row();
label_cells(_("Float"), $pab_header['float_name'], "class='tableheader2'");
end_row();
label_cells(_("Date"), sql2date($pab_header['tran_date']), "class='tableheader2'");
end_row();
label_cells(_("Total"), $pab_header['total'], "class='tableheader2'");
end_row();

if($pab_header['paid'] == 1){
    $paid = "Yes";
}else{
    $paid = "No";
}
label_cells(_("Paid"), $paid, "class='tableheader2'");
end_row();
label_cells(_("Comment"), $pab_header['comment'], "class='tableheader2'");
end_row();


//label_cells(_("Sales Person"), $pab_header['salesman_name'], "class='tableheader2'");
//end_row();


end_table(2);

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

start_table(TABLESTYLE, "width=80%");

$th = array(_('Project'),_('Description'),
            _('Period From'), _('Period To'), 
             _('Amount'), "Reimb. Id");                    

display_heading('Batch Details');
table_header($th);

$pab_lines = view_project_advance_batches_details($trans_no);
$k = $total = 0;

while ($lines = db_fetch($pab_lines))
{
    alt_table_row_color($k);
    
    label_cell($lines['project_desctiption']);
    label_cell($lines['description']);
    
    label_cell(sql2date($lines['period_from']), "align=center");
    label_cell(sql2date($lines['period_to']), "align=center");
    label_cell(number_format($lines['amount'], 2), "align=right");
    
    $link = get_petty_cash_trans_view_str(ST_PETTY_CASH_FLOAT_REIMBUR, $lines['float_reimbursement_id']);
    label_cell($link);

    
//    if($lines['paid'] == 1){
//        $paid = "Yes";
//    }else{
//        $paid = "No";
//    }
//    label_cell($paid, "align=center");
    
    end_row();
    
    $total += $lines['amount'];
    
	
}

start_row();    
        label_cell("Total advances:", "colspan=4 align=right");
        amount_cell($total, true); 
    end_row();
//
//is_voided_display(ST_LOCTRANSFER, $trans_no, _("This transfer has been voided."));

end_page(true, false, false, ST_MATERIAL_REQ, $trans_no);




?>