<?php

function dashboard_view_transport_item_consumptions($vehicle_id, $from_date, $to_date, $item_code='') {
    
    global $systypes_array;
    

        display_heading('Transport Item Cconsumption');    br();
        
        $vehicle_name = get_vehicle_formatted_name($vehicle_id);
        display_heading("Vehicle : ".$vehicle_name);    br();
        
        if(strlen($item_code) > 0){
            $item_name = get_stock_item_formatted_name($item_code);
            display_heading("Item : ".$item_name);    br();
        }
        
        start_table(TABLESTYLE, "width=80%");

            $th = array("Date", "Type", "Trans. No", "Reference", "Movement Type", "Project", "Amount"); 
            
                table_header($th);
                
                    $k = $total_amount = $count = 0;
                    $result = view_dashboard_transport_item_consumption_details($from_date, $to_date, $vehicle_id, $item_code);
                        while($row = db_fetch($result)) {
                            alt_table_row_color($k);
                                label_cell(sql2date($row['tran_date']),"align=center");
                                label_cell($systypes_array[$row["trans_type"]]);
                                $link = get_trans_view_str($row['trans_type'], $row['trans_no']);
                                label_cell($link, "align=center");
                                label_cell($row["reference"]);
                                label_cell($row["movement_type_name"]);
                                $project_id_name = get_project_formatted_name($row['project_id']);
                                label_cell($project_id_name);
                               
                                
                                $total = $row['cost'];
                                amount_cell($total);
                                
                                

                            end_row();

                            $total_amount += $total;
                            $count++;
                        }
                        
                        start_row();
                            label_cell(text_bold("Total"),"align=right colspan=5");
                            label_cell(text_bold(number_format($total_amount, 2)),"align=right"); 
                        end_row();
                
        end_table(2);
}


?>