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

$page_security = 'SA_PRINT_CHEQUES';
$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/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");

include_once($path_to_root . "/projects/includes/db/approval_path_db.inc");


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

page(_($help_context = "Approval Path Details Inquiry"), false, false, "", $js);


//-----------------------------------------------------------------------------------
// Ajax updates
//

global $Ajax;
	$Ajax->activate('trans_tbl');

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


start_form();

br(1);

start_table(TABLESTYLE_NOBORDER);
start_row();

approval_path_list_cells(_("Select Approval Path:"), 'approval_path_id', null,_(''), true);
approval_group_list_cells(_("Approval group:"), 'approval_group_id', null, '', true);
user_list_cells(_("User:"), 'user_id', null, '', true);
submit_cells('SearchOrders', _("Search"),'',_('Search'), 'default');
end_row();
end_table();


end_form();

br(2);
//------------------------------------------------------------------------------------------------

//if (!isset($_POST['bank_account']))
//	$_POST['bank_account'] = "";

$approval_path_id = $approval_group_id = $user_id = 0;

if(isset_numeric_post('approval_path_id')) $approval_path_id = $_POST['approval_path_id'];
if(isset_numeric_post('approval_group_id')) $approval_group_id = $_POST['approval_group_id'];
if(isset_numeric_post('user_id')) $user_id = $_POST['user_id'];


$result = get_approval_paths_groups_and_approver_details($approval_path_id, $approval_group_id, $user_id);	

div_start('trans_tbl');
//$act = get_bank_account($_POST["bank_account"]);
//display_heading($act['bank_account_name']." - ".$act['bank_curr_code']);

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


$th = array(_("Approval path"),_("Seq. No"),_("Position Description"), _("Approval Group"),  
            _("User"), _("Inactive"), _("Approval Limit"), _("Over Budget Limit"), _("Over Budget Percentage"));
table_header($th);


end_row();

$j = 1;
$k = 0; //row colour counter

$ap_id = $ag_id = 0;

while ($myrow = db_fetch($result))
{
    if($ap_id != $myrow["approval_path_id"]){
        if($ap_id > 0){
            start_row();
            label_cell("-", 'colspan=8');
            end_row();
        }
        start_row();
        label_cell(text_bold("Approval path : ".$myrow["approval_path_name"]), 'colspan=8');
        end_row();
    }
    elseif($ag_id > 0  && $ag_id != $myrow["approval_group_id"]){
        start_row();
        label_cell("-", 'colspan=8');
        end_row();
    }
	alt_table_row_color($k);

	label_cell($myrow["approval_path_name"]);
	label_cell($myrow["position_seq_no"]);
	label_cell($myrow["position_description"]);
//	label_cell($myrow["approval_group_code"]);
	label_cell($myrow["approval_group_description"]);
	label_cell($myrow["real_name"]);
	label_cell(get_yes_no_name($myrow["user_inactive"]),'align=center');
	amount_cell($myrow["approval_limit"]);
	amount_cell($myrow["over_budget_limit"]);
	amount_cell($myrow["over_budget_percentage"]);
        
        end_row();

        $ap_id = $myrow["approval_path_id"];
        $ag_id = $myrow["approval_group_id"];

}
//end of while loop

end_table(2);
div_end();

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

end_page();



?>
