<?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_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=width100>\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>";
		print"<td class=form-lbl-r>". lang_get('usecase_pre') ."</td>";
		print"<td class=left>";
				print"<textarea rows='4' cols='50' name='testpre'>" .
				session_validate_form_get_field('testpre') ;
				print"</textarea>";
		print"</td>";
		print"</tr>";

		print"<tr>";
		print"<td class=form-lbl-r>". lang_get('usecase_post') ."</td>";
		print"<td class=left>";
				print"<textarea rows='4' cols='50' name='testpost'>" .
				session_validate_form_get_field('testpost') ;
				print"</textarea>";
		print"</td>";
		print"</tr>";
    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";

    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();
?>