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

$page_security = 'SA_REOPEN_PROJECTS';
$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 = "Reopen Estimation Project"), @$_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");



if(isset($_POST['Reopen_Est_Project'])){
    
    $project = get_est_project_record($_POST['project_id']);
    $rp_msg = reopen_est_project($project);   
    if($rp_msg['success'] !== true){
        display_error($rp_msg['message']);
    }
    else{
        display_notification($rp_msg['message']);
    }
}


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

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

start_form(true);

start_table();

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

//set_global_project_id($_POST['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['project_id']) && $_POST['project_id'] > 0){
    $boq_approved_all_components_total = display_est_project_details($_POST['project_id']); 
    br(1);

    submit_center_first('Reopen_Est_Project', _("Reopen Project"), '', 'default');
    
            
}

br(2);


div_end();


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

end_form();

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

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



?>
