<?php

function dashboard_view_transport_utility_expenses($vehicle_id, $from_date, $to_date, $expense_type_id=0) {
    
    global $expense_categories, $systypes_array;
    

        display_heading('Transport Utility Expenses');    br();
        
        $project_name = get_vehicle_formatted_name($vehicle_id);
        display_heading("Vehicle : ".$project_name);    br();
        
        if($expense_type_id > 0){
            $expense_type = get_list_value($expense_type_id);
            display_heading("Expense Type : ".$expense_type['value_name']);    br();
        }
        
        start_table(TABLESTYLE, "width=90%");

            $th = array("Date", "Type", "#", "Project", "Bill No", "Bill Reference", "Expense Type", "Description", "Amount"); 
            
                table_header($th);
                
                    $k = $total_amount = $count = 0;
                    $result = view_dashboard_transport_utility_expenses_details($vehicle_id, $from_date, $to_date,$expense_type_id);
                        while($row = db_fetch($result)) {
                            alt_table_row_color($k);
                                label_cell(sql2date($row['trans_date']),"align=center");
                                label_cell($systypes_array[$row['trans_type']]);
                                $link = get_journal_trans_view_str($row['trans_type'], $row['trans_no']);
                                label_cell($link, "align=center");
                                
                                $project_name = get_project_formatted_name($row['project_id']);
                                label_cell($project_name,"align=center");
                                label_cell($row["bill_no"]);
                                label_cell($row["bill_reference"]);
                                label_cell($row["expense_type_name"]);
                                label_cell($row["description"]);
                                
                                $total = $row['amount'];
                                amount_cell($total);
                                
                                
\
                            end_row();

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


?>