<?php



function display_view_item_transaction_summary_details($stock_id, $from_date, $to_date, $type, $loc_code='') {
    global $systypes_array;
    
    $item_formatted_name = get_stock_item_formatted_name($stock_id);
    display_heading("Item : ".$item_formatted_name);    br();
    
    $dec = get_qty_dec($stock_id);
    
    start_table(TABLESTYLE, "width=70%");

        $th = array(_("Tran Date"), _("Trans Type"), _("Trans #"), _("Reference"), _("Location"), 
                    _("Tran Unit"), _("Tran Unit Qty"), _("Base Unit"), _("Base Unit Qty"));
        table_header($th);

            $result = get_view_item_transaction_summary_type_details($stock_id, $from_date, $to_date, $type, $loc_code);
                $k = $total_qty = 0;
                while ($row = db_fetch($result)) {
                    alt_table_row_color($k);
                        label_cell(sql2date($row['tran_date']), 'align=center');
                        label_cell($systypes_array[$row['type']]);
                        label_cell(get_trans_view_str($row['type'], $row['trans_no']), 'align=center');
                        label_cell($row['reference']);
                        label_cell($row['location_name']);
                        label_cell($row['tran_unit_name']);
                        qty_cell($row['tran_qty'], false, $dec);
                        label_cell($row['base_unit_name']);
                        qty_cell($row['qty'], false, $dec);
                    end_row();
                    
                    $total_qty += $row['qty'];
                }
                
                start_row();
                    label_cell(text_bold('Total'), 'align=right colspan=8');
                    qty_cell($total_qty, true, $dec);
                end_row();
                
    end_table(3);
}

