<?php
/**********************************************************************
***********************************************************************/



function display_all_task_recalculations($project_id)
{

    display_heading2("Budgets");
    
    $th = array(("Id"),_("BOQ Item Group"), _("Tran No"),
            _("Date"),"Calculation", "Update");
    
    start_table(TABLESTYLE2, "width=98%");

    table_header($th);
    
    start_row();

    $result = get_project_boq_item_group_records($project_id);
    while ($myrow = db_fetch($result)) {
        start_row();
        $boq_group_name = "<b>".$myrow['code']." - ".$myrow['description']."(".$myrow['id'].")"."</>";
        label_cell(spaces(($myrow['depth']-1)*10).$boq_group_name, "colspan=6");
        
        display_boq_group_task_recalculations($project_id, $myrow['id']);
    }
    start_row();
    label_cell("<b>No BOQ Item Group</b>", "colspan=6");
    display_boq_group_task_recalculations($project_id, 0);
    end_row();
    
    end_table();
}


function display_boq_group_task_recalculations($project_id, $boq_group_id)
{
    $result = get_boq_group_task_recalculations($project_id, $boq_group_id);
    while ($myrow = db_fetch($result)) {
        start_row();
        label_cell(spaces(20));
        label_cell($myrow['task_group_description']);
        label_cell($myrow['task_id'], "align=center");
        label_cell($myrow['task_code']." - ".$myrow['task_description']);
        
        if($myrow['updated_by'] > 0){
            label_cell("Updated", "align=center");
            label_cell($myrow['updated_on'], "align=center");
        }
        elseif($myrow['created_by'] > 0){
            if($myrow['row_state'] == $myrow['task_row_state']){
                if($myrow['updated_by'] == 0){
                    label_cell($myrow['created_on'], "align=center");
                    check_cells(null, "recalculated_".$myrow['task_id']);
                }
                else{
                    label_cell($myrow['created_on'], "align=center");
                    label_cell($myrow['updated_on']);
                }
            }
            else{            
                label_cell("Outdated");
                label_cell("");
            }
        }
        else{
            label_cell(spaces(3));
            label_cell(spaces(3));
        }

        end_row();
    }

}


?>
