<?php


function display_view_reconciled_account_difference($rec_id) {
    global $path_to_root, $systypes_array;

    
        $text = "";
        display_heading($text);
        
        br(1);
        
        $rec_header = get_bank_reconciliation_header_by_id($rec_id); 
        
        $bank_act = $rec_header['account_id'];
        $unreconciled_ids = $rec_header['unreconciled_ids'];
        
	start_table(TABLESTYLE);

        $th = array(_("Type"), _("#"), _("Date"), _("Debit"), _("Credit"), _("Balance"), _("Statement"));

        table_header($th);
 
        $result = view_reconciled_account_difference($bank_act, $rec_header['reconciliation_date']); 	

        $n= $debits = $credits = $balance = 0;
        while ($myrow = db_fetch($result)) {

            alt_table_row_color($k);

                $type_id = $myrow["type"];
                label_cell($systypes_array[$type_id]);
                $link = get_trans_view_str($type_id, $myrow["trans_no"]);
                label_cell($link, "align=center");
                label_cell(sql2date($myrow["trans_date"]), "align=center");
                
                if($myrow["amount"] > 0){
                    amount_cell($myrow["amount"]);
                    label_cell("");
                    $debits += $myrow["amount"];
                }else{
                    label_cell("");
                    amount_cell($myrow["amount"]);                    
                    $credits += $myrow["amount"];
                }
                
                $balance += $myrow["amount"];
                amount_cell($balance);       
                label_cell($myrow["reconciled"]);   
                
                $n++;

            end_row();
        }
        
        start_row();
        label_cell(text_bold("Total"), "colspan=3 align=right"); 
        amount_cell($debits, true);
        amount_cell($credits, true); 
        amount_cell($debits + $credits, true); 
        label_cell("");
        end_row(); 
        end_table();
        
         br(2);

}
