<?php

function get_boq_item_group_budget_details_with_boq_item_component_details($project_id, $boq_group_id) {
    $sql = "SELECT ptg.id task_group_id,
                ptg.code,
                ptg.description,
                ptg.long_description,
                ptg.boq_group_id,
                ptg.type_id,
                ptg.start_date,
                ptg.end_date,
                pt.*,
                boq_i.id boq_item_id, 
                cmp.boq_item_id cmp_boq_item_id, 
                cmp.id boq_item_componet_id
            FROM ".TB_PREF."project_task_groups ptg 
                JOIN ".TB_PREF."project_tasks pt 
                    ON pt.task_group_id = ptg.id 
                        AND pt.project_id = ptg.project_id 
                LEFT JOIN ".TB_PREF."project_boq_items boq_i   
                    ON ptg.id = boq_i.id 
                LEFT JOIN ".TB_PREF."project_boq_item_components cmp  
                    ON pt.task_id = cmp.id 
            WHERE ptg.project_id = ". db_escape($project_id)."  
                AND ptg.boq_group_id = ".db_escape($boq_group_id)." 
            ORDER BY ptg.code ";
        
	return db_query($sql, "get_boq_item_group_budget_details_with_boq_item_component_details");
}

?>