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

include_once($path_to_root . "/includes/db_pager.inc");
include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/ui/ui_lists_custom.inc");
include_once($path_to_root . "/sales/includes/sales_ui.inc");
include_once($path_to_root . "/reporting/includes/reporting.inc");
include_once($path_to_root . "/projects/includes/db/task_revisions_inquiry_db.inc");



if (!@$_GET['popup'])
{
	$js = "";
	if ($SysPrefs->use_popup_windows)
		$js .= get_js_open_window(900, 600);
	if (user_use_date_picker())
		$js .= get_js_date_picker();
	page("Budget Revisions Inquiry", false, false, "", $js);
}

if (isset($_GET['project_id']))
{
	$_POST['project_id'] = $_GET['project_id'];
}
if (isset($_GET['from_date']))
{
	$_POST['from_date'] = $_GET['from_date'];
}
if (isset($_GET['to_date']))
{
	$_POST['to_date'] = $_GET['to_date'];
}

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


start_form();

start_table(TABLESTYLE_NOBORDER);
start_row();
project_list_cells(_("Project:"), 'project_id', null, _('Select a project'), true);
tasks_list_cells("Budget", 'task_id', $_POST['project_id'], null, '', true);

date_cells(_("From:"), 'from_date', '', null, -30);
date_cells(_("To:"), 'to_date', '', null, +1);

submit_cells('SearchOrders', _("Search"),'',_('Search'), 'default');

end_row();
end_table();

$sql = get_sql_for_task_revisions_inq(@$_POST['from_date'],  @$_POST['to_date'], @$_POST['project_id'], @$_POST['task_id']);


	$cols = array(
                _("BOQ Group"), 
                _("Budget Id")=> array('align'=>'center'), 
                _("Budget"), 
                _("Old Budget")=> array('type'=>'amount'), 
                _("Budget Allocated")=> array('type'=>'amount'), 
                _("Budget Used")=> array('type'=>'amount'), 
                _("New Budget")=> array('type'=>'amount'), 
                _("Approved By"),
                _("Approved On")=> array('align'=>'center'));
//        ,
//            
//                _("Budget Id") => array('fun'=>'view_budget_transactions', 'align' => 'center'),
//		
//		_("Tran Type") => array('fun'=>'get_tran_type_name'), 
//		_("Tran No") => array('fun'=>'view_link', 'align' => 'center'),
//		_("Date") => array('fun'=>'convert_date', 'align' => 'center'),
//		_("Amount") => array('align' => 'right'),
//                _("Total Cost") => array('align' => 'right'));

//	array_append($cols, array(
//		array('insert'=>true, 'fun'=>'dispatch_link'),
//		array('insert'=>true, 'fun'=>'edit_link')));


$table =& new_db_pager('orders_tbl', $sql, $cols);
//$table->set_marker('check_overdue', _("Marked items are overdue."));

$table->width = "90%";

display_db_pager($table);
//submit_center('Update', _("Update"), true, '', null);


end_form();
end_page();

?>
