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

$page_security = 'SA_EST_PROJECT_STATUS_VIEW';
$path_to_root = "../..";
include($path_to_root . "/includes/session.inc");
include_once ($path_to_root . "/trace.php");
$js = "";
if ($SysPrefs->use_popup_windows)
	$js .= get_js_open_window(900, 500);
if (user_use_date_picker())
	$js .= get_js_date_picker();
	
page(_($help_context = "Project Status View"), @$_REQUEST['popup'], false, "", $js);

include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/includes/ui/ui_lists_estimation.inc");

include_once($path_to_root . "/estimation/includes/db/est_projects_db.inc");
include_once($path_to_root . "/estimation/includes/db/est_approve_project_db.inc");

include_once($path_to_root . "/estimation/includes/db/est_project_boq_item_groups_db.inc");
include_once($path_to_root . "/estimation/includes/ui/est_project_boq_item_groups_ui.inc");
include_once($path_to_root . "/projects/includes/db/project_task_detail_types_db.inc");
include_once($path_to_root . "/estimation/includes/ui/est_project_status_view_ui.inc");
include_once($path_to_root . "/estimation/includes/ui/est_approve_project_ui.inc");
include_once($path_to_root . "/includes/approval_functions.inc");
include_once($path_to_root . "/estimation/includes/db/est_project_boq_items_db.inc");
include_once($path_to_root . "/estimation/includes/db/est_project_competitors_db.inc");
include_once($path_to_root . "/includes/db/group_companies_db.inc");



if(isset($_POST['Recalculate_BOQ_Item_Groups'])){
    
    recalculate_est_boq_item_groups(get_post('est_project_id'));
    display_note("Estimation BOQ Item Groups have been recalculated.");    
}


//-------------------------------------------------------------------------------------------- 

if (!isset($_POST['est_project_id'])){
//	$_POST['est_project_id'] = get_global_project_id();
}
else{
    $project_id = $_POST['est_project_id'];
}

start_form(true);

start_table();

    start_row();
        est_project_list_cells(_("Project:"), 'est_project_id', null, _('Select a project'), true);
        submit_cells('SearchOrders', _("Display"),'',_('Search'), '');
    end_row();
 
   
end_table(1);

//set_global_project_id($_POST['est_project_id']);

global $Ajax;

$Ajax->activate('proj_status_tbl');

//$from_date = INFINITE_START_DATE;
//$to_date = INFINITE_END_DATE;
        
div_start('proj_status_tbl');
if(isset($_POST['est_project_id']) && $_POST['est_project_id'] > 0){
    $boq_approved_all_components_total = display_est_project_details($_POST['est_project_id']); 
    br(1);

    submit_center_first('Recalculate_Est_BOQ_Item_Groups', _("Recalculate BOQ Item Group Summaries"), '', 'default');
    echo(get_estimation_trans_view_str(ST_EST_PROJECT_BOQ_ITEM_GROUPS_SUMMARY, $_POST['est_project_id'], "<b>View BOQ Item Group Details</b>"));

    br(2);
    
    display_est_component_category_summary($_POST['est_project_id'], $boq_approved_all_components_total);
    
    br(2);
    
    display_heading2("Competitors");
    br(1);
    display_competitors_inquiry($_POST['est_project_id']);
            
}

br(1);


div_end();


hidden('popup', @$_REQUEST['popup']);

end_form();

//------------------------------------------------------------------------------------

end_page(@$_REQUEST['popup']);



?>
