<?php
# ---------------------------------------------------------------------
# truc is a tool for requirement and use case tracking
# Copyright (C) 2006 ASDIS - http://sf.net/projects/truc
#
# (rth) Initial truc version based on rth
#       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
#----------------------------------------------------------------------

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

$page                   = basename(__FILE__);
$action_page			= 'test_group_action.php';
$project_properties     = session_get_project_properties();
$project_name           = $project_properties['project_name'];
$project_id				= $project_properties['project_id'];

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

$ids = "";

# if submit from test_page.php
if( isset($_POST['mass_update_btn']) && isset($_POST['row_test_arr']) ) {
	
	$field = $_POST['action'];
	
	foreach( $_POST['row_test_arr'] as $key => $value) {
		$ids .= $key .":";
	}
}
else {
	error_report_show("test_page.php", NO_TESTS_SELECTED);
}

switch( $field ) {

	case 'man_auto':
		$form_title = lang_get( 'performed_by' );
		$possible_values = test_get_man_auto_values();
		break;
	case 'ba_owner':
		$form_title = lang_get( 'update_ba_owner' );
		$possible_values = user_get_baowners_by_project($project_id, $blank=true);
		break;
	case 'qa_owner':
		$form_title = lang_get( 'update_qa_owner' );
		$possible_values = user_get_qaowners_by_project($project_id, $blank=true);
		break;
	case 'test_status':
		$form_title = lang_get( 'update_test_status' );
		$possible_values = test_get_status( $blank=true );
		break;
	case 'test_priority':
		$form_title = lang_get( 'update_priority' );
		$possible_values = test_get_priorities();
		break;
	case 'auto_pass':
		$form_title = lang_get( 'update_autopass' );
		$possible_values = test_get_autopass_values();
		break;
	case 'test_type':
		$form_title = lang_get( 'update_testtype' );
		$possible_values = test_get_test_type( $project_id  );
		break;
	case 'area_tested':
		$form_title = lang_get( 'update_area_tested' );
		$possible_values = test_get_test_value($project_id, TEST_AREA_TESTED, $blank=true);
		break;

}


print"<br>\n";

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

print"<form method=post action=$action_page>\n";

print"<table class=width50>\n";
print"<tr>\n";
print"<td>\n";

print"<table class=inner>\n";

# FORM TITLE
print"<tr>\n";
print"<td class='form-data-l'><h4>$form_title</h4></td>\n";
print"</tr>\n";

# VALUE
print"<tr>\n";
print"<td class='form-data-c'>";
print"<select name=field_value size=1>\n";
	html_print_list_box_from_array(	$possible_values );
print"</select>\n";
print"</td>\n";
print"</tr>\n";

print"<input type='hidden' name=test_ids value='$ids'>";
print"<input type='hidden' name=field value='$field'>";

util_add_spacer();

# SUBMIT BUTTON
print"<tr>\n";
print"<td class='form-data-c'><input type='submit' name=submit_status value='". lang_get('update') ."'></td>\n";
print"</tr>\n";

print"</table>\n";

print"</td>\n";
print"</tr>\n";
print"</table>\n";

print"</form>\n";

print"</div>\n";

html_print_footer();
?>