<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_PROJECT_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 . "/includes/db/approval_functions_db.inc");

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

if (user_use_date_picker()) {
	$js .= get_js_date_picker();
}

page(_($help_context = "View Approval History"), true, false, "", $js);


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

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

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

function display_document_summary_view_links($source_type_id, $trans_no)
{

    start_table(TABLESTYLE_NOBORDER, "width=40%");

//$th = array(_("Approval Status"), _("Approver"), _("Approved On"), _("Display Status"),_("Comment"),_('Next Approval Group'));
    $s = get_project_trans_view_str(ST_DOCUMENT_BUDGET_STATUS,$trans_no."&source_type_id=".$source_type_id, "View Document Budget Summary");
    label_cell("<b>".$s."</b>", "align = center");
    
    end_table(1);
    
}

display_document_summary_view_links($source_type_id, $trans_no);


global $approval_statuses;

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

$th = array(_("Approval Status"), _("Approver"), _("Approved On"), _("Display Status"),_("Comment"),_('Next Approval Group'));

display_heading('Approval Log of Document' . " #$trans_no");
table_header($th);
$approval_log = get_approval_logs($source_type_id, $trans_no);
$k = 0;
while ($item = db_fetch($approval_log))
{
    label_cell($approval_statuses[$item['approval_status']]);
    label_cell($item['approved_by']);
    label_cell($item['approved_on'], "align = center");   
    
    label_cell($item['display_status']);
    label_cell($item['comment']);
    
    if($item['next_approval_group_id'] > 0)
    {
        $s = get_project_trans_view_str(ST_APPROVAL_GROUP,$item['next_approval_group_id'],$item['approval_group_description']);
    }
    else {
        $s = '';
    }
    label_cell($s, "align = left");
    
    end_row();
	
}

end_table(1);
//
//is_voided_display(ST_LOCTRANSFER, $trans_no, _("This transfer has been voided."));

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