<?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__);
$s_project_properties	= session_get_project_properties();
$project_id				= $s_project_properties['project_id'];
$project_name			= $s_project_properties['project_name'];
$test_id				= $_GET['test_id'];
$display_test_id		= util_pad_id( $test_id );
$test_name				= test_get_name( $test_id );

if( isset( $_POST['manual_test_id'] ) && $_POST['manual_test_id'] != "" ) {
	$manual_test_id = $_POST['manual_test_id'];
}
else {
	$manual_test_id	= $_GET['manual_test_id'];
}

$row_style = '';

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

#### Change to api submenu function for this page type ####
test_menu_print ($page);

print"<br><br>\n";

$row = test_get_uploaded_document_detail( $manual_test_id );

$manual_test_id		= $row[MAN_TD_VER_MANUAL_TEST_ID];
$file_name			= $row[MAN_TD_DISPLAY_NAME];
$doc_type			= $row[MAN_TEST_DOCS_VERS_MANUAL_DOC_TYPE_NAME];


# Display test information and link back to test detail
print"<div align=center>\n";
print"<table class=width95>\n";
print"<tr class='tbl_header'>\n";
	print"<td width='50%'>". lang_get('test_id') ."</td>\n";
	print"<td width='50%'>". lang_get('test_name') ."</td>\n";
	#print"<td width='33%'>". lang_get('test_version') ."</td>\n";
print"</tr>\n";
print"<tr>\n";
	print"<td class=grid-data-c><a href='test_detail_page.php?test_id=$test_id&tab=2'>$display_test_id</a></td>\n";
	print"<td class=grid-data-c>$test_name</td>\n";
	#print"<td class=grid-data-c>$version_no</td>\n";
print"</tr>\n";
print"</table>\n";


print"<br><br>\n";

error_report_check( $_GET );

# Display file upload form
print"<br>\n";
print"<span class='required'>*</span> <span class='print'>" . lang_get('must_complete_field') . "</span>\n";
print"<table class=width95>\n";
print"<tr>\n";
print"<td>\n";

	print"<form enctype=multipart/form-data name=upload action='test_add_doc_version_action.php' method=post>\n";
	print"<table class=inner>\n";

	print"<tr class=left>\n";
		print"<td class=form-header-l colspan=2>" . lang_get('upload_new_file_version') . " $file_name</td>\n";
	print"</tr>\n";
	print"<tr>\n";
		print"<td class=form-lbl-r>" . lang_get('file_name') . "<span class='required'>*</span></td>\n";
		print"<td class=form-data-l><input type='file' name='uploadfile_required' size='60'></td>\n";
	print"</tr>\n";
	print"<tr>\n";
		print"<td class=form-lbl-r>" . lang_get('comments') . "</td>\n";
		print"<td class=form-data-l><textarea rows='2' cols='45' name='comments'>".  session_validate_form_get_field ('comments') ."</textarea></td>\n";
	print"</tr>\n";
	print"<tr>\n";
		print"<td class=form-lbl-r>" .  lang_get('file_type') . "</td>\n";
		print"<td class=form-data-l>\n";
		print"<select name=doc_type>\n";
			$test_types = test_get_test_type( $project_id, $blank=true );
			html_print_list_box_from_array( $test_types, $doc_type );
		print"</select></td>\n";
	print"</tr>\n";

	print"<input type='hidden' name='manual_test_id' value='$manual_test_id'>\n";
	print"<input type='hidden' name='MAX_FILE_SIZE' value='25000000'>\n"; 

	print"<tr>\n";
		print"<td class=center colspan=2><input type='submit' value='Upload'></td>\n";
	print"</tr>\n";
	print"</table>\n";
	print"</form>\n";

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

print"</div>\n";

html_print_footer();
?>