<?php

    
function dashboard_get_transport_all_costs_item_consumption_items_value($from_date, $to_date, $vehicle_id) {
    
    $sql = dashboard_get_sql_for_inventory_item_consuption_items($from_date, $to_date, -1, '', IMLF_VEHICLE, $vehicle_id);
    
    $sql = "SELECT item_code, SUM(qty * unit_cost) grand_total,
                    sm.description item_description 
            FROM ($sql) tmp  
                JOIN ".TB_PREF."stock_master sm  
                    ON sm.stock_id = tmp.item_code   
            GROUP BY item_code   
            ORDER BY grand_total DESC";
    
    return db_query($sql); 
                
}


function dashboard_get_period_transport_all_costs_item_consumption_total($item_code, $from_date, $to_date, $vehicle_id) {
    
    $sql = dashboard_get_sql_for_inventory_item_consuption_items($from_date, $to_date, -1, $item_code, IMLF_VEHICLE, $vehicle_id);
    
    $sql = "SELECT SUM(qty * unit_cost) total_cost  FROM ($sql) tmp_table ";

    $result = db_query($sql, "dashboard_get_period_project_item_consuption_total"); 
    
    return db_result_value($result, "total_cost");
    
}

