<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_VIEW_PROJECT_WIP_COSTS';
$path_to_root = "../..";

include_once($path_to_root . "/includes/session.inc");

include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/inventory.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/projects/includes/db/project_wip_db.inc");
include_once($path_to_root . "/projects/includes/db/projects_db.inc");
include_once($path_to_root . "/includes/ui/ui_input.inc");                


$js = "";
if ($SysPrefs->use_popup_windows)
	$js .= get_js_open_window(800, 500);
page(_($help_context = "I Owe You Advances Batch"), true, false, "", $js);

//-------------------------------------------------------------------------------------------------
$woid = 0;
if ($_GET['project_id'] != "")
{
	$project_id = $_GET['project_id'];
}

global $approval_statuses;



function display_project_wip_cost_details($project_id)
{

    div_start('price_table');
    
    start_table(TABLESTYLE2, "width=30%");

    $th = array(_("Type"), _("Amount"));
    
    table_header($th);
    
    $q = view_project_wip_entries($project_id);
    
    $total = $float_total = $previous_float_id = 0;

    
    while ($wip = db_fetch($q))
    {     

        start_row();    

        label_cell($wip['wip_type_name']);          
        amount_decimal_cell($wip['value']);
 
        $total += $wip['value'];
    }

    start_row();    
        label_cell("Total:", "align=right");
        amount_cell($total, true); 
    end_row();

    end_table(1);  
    
    div_end();   
}

        $project = get_project_record($project_id);

        $project_id = $project['project_id'];
        $user_id = $_SESSION['wa_current_user']->user;
        $cap = can_access_project($project_id, $user_id);
        if($cap['success'] !== true) 
        {
            display_error($cap["message"]);
            set_focus('project_id');
            display_footer_exit();
            exit;
        } 
        



display_heading("WIP Costs of Project " .$project['description']);

br(1);
display_project_wip_cost_details($project_id);

end_page(true, false, false, ST_WORKORDER, $woid);

?>
