<?php
# ---------------------------------------------------------------------
# rth is a requirement, test, and bugtracking system
# Copyright (C) 2005 George Holbrook - rth@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
#----------------------------------------------------------------------
# ---------------------------------------------------------------------
# Test Page
#
# $RCSfile: test_page.php,v $  $Revision: 1.2 $
# ---------------------------------------------------------------------

if( isset($_POST['mass_update_btn']) ) {

	require_once("test_group_action_page.php");
	exit;
}

include"./api/include_api.php";
auth_authenticate_user();

$page                   = basename(__FILE__);
$action_page            = 'test_action.php';
$detail_page			= 'test_detail_page.php';
$test_update_url		= 'test_detail_update_page.php';
$num                    = 0;
$bg_color               = '';
$project_properties     = session_get_project_properties();
$project_name           = $project_properties['project_name'];
$project_id				= $project_properties['project_id'];


$s_display_options 		= session_set_display_options("test", $_POST);
$order_by				= $s_display_options['order_by'];
$order_dir				= $s_display_options['order_dir'];
$page_number			= $s_display_options['page_number'];

$filter_per_page		= $s_display_options['filter']['per_page'];
$filter_manual_auto		= $s_display_options['filter']['manual_auto'];
$filter_test_type		= $s_display_options['filter']['test_type'];
$filter_ba_owner		= $s_display_options['filter']['ba_owner'];
$filter_qa_owner		= $s_display_options['filter']['qa_owner'];
$filter_tester			= $s_display_options['filter']['tester'];
$filter_area_tested		= $s_display_options['filter']['area_tested'];
$filter_test_status		= $s_display_options['filter']['test_status'];
$filter_search			= $s_display_options['filter']['test_search'];

html_window_title();
html_print_body();
html_page_title($project_name ." - ". lang_get('test_page') );
html_page_header( $db, $project_name );
html_print_menu();
test_menu_print ($page);

error_report_check( $_GET );

print"<br>";

print"<form method='post' action='$page' name='tests_form'>\n";

print"<div align=center>\n";

html_print_tests_filter(	$project_id,
							$filter_manual_auto,
							$filter_test_type,
							$filter_ba_owner,
							$filter_qa_owner,
							$filter_tester,
							$filter_area_tested,
							$filter_test_status,
							$filter_per_page, 
							$filter_search);

print"<br>\n";

$g_timer->mark_time( "Load rows to display on page from db into memory" );

$row = test_filter_rows(	$project_id,
							$filter_manual_auto,
							$filter_ba_owner,
							$filter_qa_owner,
							$filter_tester,
							$filter_test_type,
							$filter_area_tested,
							$filter_test_status,
							$filter_per_page,
							$filter_search,
							$order_by,
							$order_dir,
							$page_number,
							$csv_name="tests");

print"</div>\n";

$g_timer->mark_time( "Finished load rows to display on page from db into memory" );
if( $row ) {
	print"<div align=center>\n";

	print"<table class=width100 rules=cols>\n";

	print"<tr class=tbl_header>\n";
	print"<th></th>\n";
	print"<th></th>\n";
	html_tbl_print_header( lang_get('test_id'),		TEST_ID,			$order_by, $order_dir );
	html_tbl_print_header( lang_get('man_auto') );
	html_tbl_print_header( lang_get('file_type') );
	html_tbl_print_header( lang_get('autopass'),	TEST_AUTO_PASS,		$order_by, $order_dir );
	html_tbl_print_header( lang_get('test_name'),	TEST_NAME,			$order_by, $order_dir );
	html_tbl_print_header( lang_get('ba_owner'), 	TEST_BA_OWNER,		$order_by, $order_dir );
	html_tbl_print_header( lang_get('qa_owner'), 	TEST_QA_OWNER,		$order_by, $order_dir );
	html_tbl_print_header( lang_get('tester'),		TEST_TESTER,		$order_by, $order_dir );
	html_tbl_print_header( lang_get('testtype'), 	TEST_TESTTYPE,		$order_by, $order_dir );
	html_tbl_print_header( lang_get('area_tested'), TEST_AREA_TESTED,	$order_by, $order_dir );
	html_tbl_print_header( lang_get('test_status'), TEST_STATUS,		$order_by, $order_dir );
	print"</tr>\n";

	$g_timer->mark_time( "Outputting main html table to browser" );

	$row_style = '';

	foreach( $row as $row_test_detail ) {

		$test_id         = $row_test_detail[TEST_ID];
		//$test_version_id = $row_test_detail[TEST_VERS_ID];
		$test_name       = $row_test_detail[TEST_NAME];
		$ba_owner        = $row_test_detail[TEST_BA_OWNER];
		$qa_owner        = $row_test_detail[TEST_QA_OWNER];
		$tester			 = $row_test_detail[TEST_TESTER];
		$test_type       = $row_test_detail[TEST_TESTTYPE];
		$manual          = $row_test_detail[TEST_MANUAL];
		$automated       = $row_test_detail[TEST_AUTOMATED];
		$area_tested     = $row_test_detail[TEST_AREA_TESTED];
		$autopass        = $row_test_detail[TEST_AUTO_PASS];
		$test_status     = $row_test_detail[TEST_STATUS];

		$display_test_id = util_pad_id($test_id);

		if($row_test_detail[TEST_AUTO_PASS]=="Y") {

			$autopass = "Yes";
		} else {

			$autopass = "No";
		}

		$filename = test_get_filename($test_id);

		$row_style = html_tbl_alternate_bgcolor($row_style);
		print"<tr class='$row_style'>\n";
		print"<td><input type='checkbox' name='row_test_arr[{$test_id}]'></td>\n";
		print"<td class='tbl-c'><a href='$test_update_url?test_id=$test_id'><img src='".IMG_SRC."update.gif' title='". lang_get('update_test') ."' border=0></a></td>\n";

		//$detail_url = $detail_page ."?test_id=". $test_id ."&test_version_id=". $test_version_id;
		$detail_url = $detail_page ."?test_id=". $test_id;

		print"<td class='tbl-c'><a href='$detail_url' title='". lang_get('test_view_detail') ."'>$display_test_id</a></td>\n";
		print"<td class='tbl-c'>".html_print_testtype_icon( $manual, $automated )."</td>\n";
		print"<td class='tbl-c'>".html_file_type( $filename )."</td>\n";
		print"<td class='tbl-l'>$autopass</td>\n";
		print"<td class='tbl-l'>$test_name</td>\n";
		print"<td class='tbl-l'>$ba_owner</td>\n";
		print"<td class='tbl-l'>$qa_owner</td>\n";
		print"<td class='tbl-l'>$tester</td>\n";
		print"<td class='tbl-l'>$test_type</td>\n";
		print"<td class='tbl-l'>$area_tested</td>\n";
		print"<td class='tbl-l'>$test_status</td>\n";
		print"</tr>\n";
	}

	$g_timer->mark_time( "Finished outputting main html table to browser" );

	print"</table>\n";
	print"</div>\n";


	if( session_use_javascript() ) {
		//print"<input type=checkbox name=all_tests value=all onClick=checkall('tests_form', this.form.all_tests.checked)\">Select All&nbsp;&nbsp;";
		print"<input id=select_all type=checkbox onClick='checkAll( this )'>\n";
		print"<label for=select_all>".lang_get("select_all")."</label>\n";
	}
	print"<select name=action>";
	print"<option value=man_auto>". lang_get('man_auto') ."</option>";
	print"<option value=ba_owner>". lang_get('ba_owner') ."</option>";
	print"<option value=qa_owner>". lang_get('qa_owner') ."</option>";
	print"<option value=tester>". lang_get('tester') ."</option>";
	print"<option value=test_status>". lang_get('test_status') ."</option>";
	print"<option value=test_priority>". lang_get('priority') ."</option>";
	print"<option value=auto_pass>". lang_get('autopass') ."</option>";
	print"<option value=test_type>". lang_get('testtype') ."</option>";
	print"<option value=area_tested>". lang_get('area_tested') ."</option>";
	print"</select>";
	print"&nbsp;";
	print"<input type=submit name=mass_update_btn value='".lang_get("update")."'>";

} else {

	html_no_records_found_message( lang_get('no_tests') );
}

print"</form>\n";

html_print_footer();

# ---------------------------------------------------------------------
# $Log: test_page.php,v $
# Revision 1.2  2006/02/24 11:36:04  gth2
# update to div - class=div-c not working in firefox - gth
#
# Revision 1.1.1.1  2005/11/30 23:00:58  gth2
# importing initial version - gth
#
# ---------------------------------------------------------------------

?>