<?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 Add Page
#
# $RCSfile: test_add_page.php,v $  $Revision: 1.3 $
# ---------------------------------------------------------------------

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

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

$s_show_options = session_get_show_options();
$show_priority = $s_show_options['show_priority'];

$s_project_properties = session_get_project_properties();
$project_id = $s_project_properties['project_id'];

if (isset($_GET['failed'])) {
    $is_validation_failure = $_GET['failed'];
} else {
    $is_validation_failure = false;
}

global $db;

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

error_report_check( $_GET );

print"<br>\n";

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

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

# requirement this new test is associated to
if( !empty($_GET["assoc_req"]) ) {

	print"<input type=hidden name=assoc_req value=".$_GET["assoc_req"].">\n";
}

print"<span class='required'>*</span><span class='print'>" . lang_get('must_complete_field') . "</span><br>\n";

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

    print"<table class=inner rules=none border=0>\n";

    print"<tr>\n";
    print"<td class=form-header-l colspan=2>".lang_get('add_test')."</td>\n";
    print"</tr>\n";

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('test_name') ."<span class='required'>*</span></td>\n";
    print"<td class=form-data-l>\n";
        print"<input type=text size=67 name=testname_required value='" . session_validate_form_get_field( 'testname_required' );
        print"'>\n";
    print"</td>\n";

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('test_purpose') ."</td>\n";
    print"<td class=form-data-l>\n";
            print"<textarea rows='4' cols='50' name='testpurpose'>" .
            session_validate_form_get_field( 'testpurpose' );
            print"</textarea>\n";
    print"</td>\n";
    print"</tr>\n";

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('test_comments') ."</td>\n";
    print"<td class=form-data-l>\n";
        print"<textarea rows='2' cols='50' name='testcomments'>" .
               session_validate_form_get_field( 'testcomments' );
        print"</textarea>\n";
    print"</td>\n";
    print"</tr>\n";

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('test_status') ."</td>\n";
    print"<td class=form-data-l>\n";
        $selected_value = session_validate_form_get_field( 'teststatus', 'New' );
		$statuses = test_get_status( $blank=true );
        print"<select name='teststatus' size=1>\n";
        #html_print_list_box( $db, TEST_STATUS_TBL, TEST_STATUS_STATUS, $project_id, $selected_value);
		html_print_list_box_from_array( $statuses, $selected_value);
        print"</select>\n";
    print"</td>\n";
    print"</tr>\n";

	if ($show_priority == 'Y') {
        print"<tr>\n";
        print"<td class=form-lbl-r>". lang_get('priority') ."</td>\n";
        print"<td class=form-data-l>\n";
            $priorities = test_get_priorities();
            $selected_value = session_validate_form_get_field( 'testpriority' );
            print"<select name='testpriority' size=1>\n";
            html_print_list_box_from_array( $priorities, $selected_value);
            print"</select>\n";
        print"</td>\n";
        print"</tr>\n";
    }

	# AREA TESTED
    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('area_tested') ."</td>\n";
    print"<td class=form-data-l>\n";
		$areas_tested = test_get_areas_tested( $project_id, true );
        $selected_value = session_validate_form_get_field( 'testareatested' );
        print"<select name='testareatested' size=1>\n";
        html_print_list_box_from_array( $areas_tested, $selected_value);
        print"</select>\n";
    print"</td>\n";
    print"</tr>\n";

	# TEST TYPE
    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('testtype') ."</td>\n";
    print"<td class=form-data-l>\n";
        $selected_value = session_validate_form_get_field( 'testtype' );
        print"<select name='testtype' size=1>\n";
		$test_types = test_get_test_type( $project_id, $blank=true);
        html_print_list_box_from_array( $test_types, $selected_value);
        print"</select>\n";
    print"</td>\n";
    print"</tr>\n";

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('ba_owner') ."</td>\n";
    print"<td class=form-data-l>\n";
        $selected_value = session_validate_form_get_field( 'ba_owner' );
        print"<select name='ba_owner' size=1>\n";
        $ba_owner = user_get_baowners_by_project($project_id, $blank=true);
        html_print_list_box_from_array( $ba_owner, $selected_value);
        print"</select>\n";
    print"</td>\n";
    print"</tr>\n";


    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('qa_owner') ."</td>\n";
    print"<td class=form-data-l>\n";
        $selected_value = session_validate_form_get_field( 'qa_owner');
        print"<select name='qa_owner' size=1>\n";
        $qa_owner = user_get_qaowners_by_project($project_id, $blank=true);
        html_print_list_box_from_array( $qa_owner, $selected_value );
        print"</select>\n";
    print"</td>\n";
    print"</tr>\n";
    
    
      print"<tr>\n";
	    print"<td class=form-lbl-r>". lang_get('test_tester') ."</td>\n";
	    print"<td class=form-data-l>\n";
	        $selected_value = session_validate_form_get_field( 'tester' );
	        print"<select name='tester' size=1>\n";
	        $assign_to_users = user_get_usernames_by_project($project_id, $blank=true);
	        html_print_list_box_from_array( $assign_to_users, $selected_value);
	        //html_print_list_box_with_join( $db, USER_TBL, PROJECT_USER_ASSOC_TBL, USER_UNAME, USER_ID, PROJECT_USER_ASSOC_TBL, PROJ_ID, $project_id, $selected_value);
	        print"</select>\n";
	    print"</td>\n";
    print"</tr>" ;

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('test_assigned_to') ."</td>\n";
    print"<td class=form-data-l>\n";
        $selected_value = session_validate_form_get_field( 'assigned_to' );
        print"<select name='assigned_to' size=1>\n";
        $assign_to_users = user_get_usernames_by_project($project_id, $blank=true);
        html_print_list_box_from_array( $assign_to_users, $selected_value);
        //html_print_list_box_with_join( $db, USER_TBL, PROJECT_USER_ASSOC_TBL, USER_UNAME, USER_ID, PROJECT_USER_ASSOC_TBL, PROJ_ID, $project_id, $selected_value);
        print"</select>\n";
    print"</td>\n";
    print"</tr>" ;

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('test_assigned_by') ."</td>\n";
    print"<td class=form-data-l>\n";
        $selected_value = session_validate_form_get_field( 'assigned_by' );
        print"<select name='assigned_by' size=1>\n";
        $assign_by_users = user_get_usernames_by_project($project_id, $blank=true);
        html_print_list_box_from_array( $assign_by_users, $selected_value);
        print"</select>\n";
    print"</td>\n";
    print"</tr>" ;

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('date_assigned') . "</td>\n";
    print"<td class=form-data-l>\n";
        print"<input type=text size=10 maxlength=10 name='dateassigned' value=" .
              session_validate_form_get_field( 'dateassigned' );
        print">\n";
        print"&nbsp;&nbsp;" . lang_get('correct_date_format');
    print"</td>\n";
    print"</tr>" ;

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('date_expected') ."</td>\n";
    print"<td class=form-data-l>\n";
        print"<input type=text size=10 maxlength=10 name='dateexpcomplete' value=" .
              session_validate_form_get_field( 'dateexpcomplete' );
        print">\n";
        print"&nbsp;&nbsp;" . lang_get('correct_date_format');
    print"</td>\n";
    print"</tr>" ;

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('date_complete') ."</td>\n";
    print"<td class=form-data-l>\n";
        print"<input type=text size=10 maxlength=10 name='dateactcomplete' value=" .
              session_validate_form_get_field( 'dateactcomplete' );
        print">\n";
        print"&nbsp;&nbsp;" . lang_get('correct_date_format');
    print"</td>\n";
    print"</tr>" ;

    print"<tr>\n";
    print"<td class='form-lbl-r'>". lang_get('ba_signoff_date') ."</td>\n";
    print"<td class='form-data-l'>\n";
        print"<input type=text size=10 maxlength=10 name='datebasignoff' value=" .
              session_validate_form_get_field( 'datebasignoff' );
        print">\n";
        print"&nbsp;&nbsp;" . lang_get('correct_date_format');
    print"</td>\n";
    print"</tr>" ;

	# Duration
	print"<tr>\n";
	 print"<td class='form-lbl-r'>". lang_get('duration') ."</td>\n";
    print"<td class='form-data-l'><input type='text' size='3' name='test_duration' value=" .
		session_validate_form_get_field( 'test_duration' );
        print">\n";
		print"&nbsp;&nbsp;". lang_get('in_minutes') ."</td>\n";
	print"</tr>\n";

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('autopass') ."</td>\n";
    print"<td class=form-data-l>\n";
        print"<input type=checkbox name='chk_autopass' value='Y'\n";
        if (session_validate_form_get_field('chk_autopass')) print ' checked';
        print">\n";
    print"</td>\n";
    print"</tr>" ;

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('manual') ."</td>\n";
    print"<td class=form-data-l>\n";
        print"<input type=checkbox name='chk_steps' value='YES'\n";
        if (session_validate_form_get_field('chk_steps')) print ' checked';
        print">\n";
    print"</td>\n";
    print"</tr>" ;

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('automated') ."</td>\n";
    print"<td class=form-data-l>\n";
        print"<input type=checkbox name='chk_auto' value='YES'\n";
        if (session_validate_form_get_field('chk_auto')) print ' checked';
        print">\n";
    print"</td>\n";
    print"</tr>" ;

    print"<tr>\n";
    print"<td class=form-lbl-r>". lang_get('test_performance') ."</td>\n";
    print"<td class=form-data-l>\n";
        print"<input type=checkbox name='chk_performance' value='YES'\n";
        if (session_validate_form_get_field('chk_performance')) print ' checked';
        print">\n";
    print"</td>\n";
    print"</tr>" ;

    print"<tr><td class=center colspan=2><input type=submit name='save' value='Save'><br><br></td>\n";

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

print"</form>\n";

print"</div>\n";


html_print_footer();

# ---------------------------------------------------------------------
# $Log: test_add_page.php,v $
# Revision 1.3  2006/06/25 16:44:53  gth2
# removing "all" from test area list box - gth
#
# 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
#
# ---------------------------------------------------------------------

?>
