<?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
#----------------------------------------------------------------------
define('NO_FOLDER_VIEW',true);

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

$page					= basename(__FILE__);
$form_name				= 'add_release';
$action_page			= 'project_manage_release_add_action.php';
$release_edit_page		= 'project_manage_release_edit_page.php';
$release_signoff_page	= 'release_signoff_page.php';
$build_page				= 'build_page.php';
$delete_page			= 'delete_page.php';
$s_project_properties	= session_get_project_properties();
$project_name			= $s_project_properties['project_name'];
$project_id				= $s_project_properties['project_id'];
$row_style				= '';

session_set_properties("project_manage", $_GET);
$selected_project_properties 	= session_get_properties("project_manage");
$selected_project_id 			= $selected_project_properties['project_id'];

session_set_properties( "release", $_GET );

$display_options	= session_set_display_options( "release", $_POST );
$order_by			= $display_options['order_by'];
$order_dir			= $display_options['order_dir'];

html_window_title();
html_print_body( $form_name, 'rel_name_required');
html_page_title(project_get_name($selected_project_id) ." - ". lang_get('add_release') );
html_page_header( $db, $project_name );
html_print_menu();
html_project_manage_menu();

error_report_check( $_GET );

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

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

print"<form method=post name=$form_name action=$action_page>\n";
print"<table class=inner>\n";

# RELEASE NAME
print"<tr>\n";
print"<td class='form-lbl-r'>". lang_get('release_name') ." <span class='required'>*</span></td>\n";
print"<td class='form-data-l'><input type='text' maxlength='20' name='rel_name_required' value='".
	session_validate_form_get_field("rel_name_required"). "'></td>\n";
print"</tr>\n";

# DESCRIPTION
print"<tr>\n";
print"<td class='form-lbl-r'>". lang_get('description') ."</td>\n";
print"<td class='form-data-l'>";
print"<textarea name='rel_description' rows=5 cols=30 >".
	session_validate_form_get_field("rel_description"). "</textarea>";
print"</td>\n";
print"</tr>\n";

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

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

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

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

$release_details = admin_get_all_release_details_by_project( $selected_project_id, null, $order_by, $order_dir );

if( !empty( $release_details ) ) {
	print"<table class=width100 rules=cols>\n";
	print"<tr class=tbl_header>\n";

	html_tbl_print_header( lang_get('release_name'), 	 RELEASE_NAME, 			$order_by, $order_dir, $page );
	html_tbl_print_header( lang_get('rel_date_received'),RELEASE_DATE_RECEIVED, $order_by, $order_dir, $page );
	html_tbl_print_header( lang_get('rel_description') );
	//html_tbl_print_header( lang_get('rel_ba_signoff') );
	//html_tbl_print_header( lang_get('rel_ba_signoff_by') );
	//html_tbl_print_header( lang_get('rel_ba_signoff_date') );
	//html_tbl_print_header( lang_get('rel_ba_signoff_note') );
	html_tbl_print_header( lang_get('rel_qa_signoff') );
	html_tbl_print_header( lang_get('rel_qa_signoff_by') );
	html_tbl_print_header( lang_get('rel_qa_signoff_date') );
	html_tbl_print_header( lang_get('rel_qa_signoff_note') );
	html_tbl_print_header( lang_get('sign_off') );
	html_tbl_print_header( lang_get('edit') );
	html_tbl_print_header( lang_get('delete') );

	print"</tr>\n";

	foreach( $release_details as $release_detail ) {


	//for( $i=0; $i < sizeof( $release_details ); $i++ ) {

	

		//extract( $release_details[$i], EXTR_PREFIX_ALL, 'v' );

		$release_id				= $release_detail[RELEASE_ID];
		$release_name			= $release_detail[RELEASE_NAME];
		$release_date_received	= date_trim_time( $release_detail[RELEASE_DATE_RECEIVED] );
		$release_description	= $release_detail[RELEASE_DESCRIPTION];
		$qa_signoff_by			= $release_detail[RELEASE_QA_SIGNOFF_BY];
		$qa_signoff_date		= date_trim_time( $release_detail[RELEASE_QA_SIGNOFF_DATE] );
		$qa_signoff_status		= $release_detail[RELEASE_QA_SIGNOFF];
		$qa_signoff_comment		= $release_detail[RELEASE_QA_SIGNOFF_COMMENTS];
		$ba_signoff_by			= $release_detail[RELEASE_BA_SIGNOFF_BY];
		$ba_signoff_date		= date_trim_time( $release_detail[RELEASE_BA_SIGNOFF_DATE] );
		$ba_signoff_status		= $release_detail[RELEASE_BA_SIGNOFF];
		$ba_signoff_comment		= $release_detail[RELEASE_BA_SIGNOFF_COMMENTS];


		$row_style = html_tbl_alternate_bgcolor( $row_style );
		print"<tr class='$row_style'>\n";
		print"<td class='tbl-l'><a href='$build_page?release_id=$release_id'>$release_name</a></td>\n";
		print"<td class='tbl-c'>$release_date_received</td>\n";
		print"<td class='tbl-c'>$release_description</td>\n";
		//print"<td class='tbl-c'>$ba_signoff_status</td>\n";
		//print"<td class='tbl-c'>$ba_signoff_by</td>\n";
		//print"<td class='tbl-c'>$ba_signoff_date</td>\n";
		//print"<td class='tbl-c'>$ba_signoff_comment</td>\n";
		print"<td class='tbl-c'>$qa_signoff_status</td>\n";
		print"<td class='tbl-c'>$qa_signoff_by</td>\n";
		print"<td class='tbl-c'>$qa_signoff_date</td>\n";
		print"<td class='tbl-c'>$qa_signoff_comment</td>\n";
		print"<td class='tbl-c'><a href='$release_signoff_page?release_id=$release_id'>". lang_get('sign_off') ."</a></td>\n";
		print"<td class='tbl-c'><a href='$release_edit_page?release_id=$release_id'>". lang_get('edit') ."</a></td>\n";
		print"<td class='tbl-c'>";
			print"<form method=post action='$delete_page'>\n";
			print"<input type='submit' name='delete' value='". lang_get( 'delete' ) ."' class='page-numbers'>";
			print"<input type='hidden' name='r_page' value=$page>\n";
			print"<input type='hidden' name='f' value='delete_release'>\n";
			print"<input type='hidden' name='id' value=$release_id>\n";
			print"<input type='hidden' name='msg' value='20'>\n";
			print"</form>";
		print"</td>\n";
		print"</tr>\n";
	}

	print"</table>\n";
	#print"</form>\n";
} else {
	html_no_records_found_message( lang_get('no_releases') );
}

print"</div>";

html_print_footer();

session_validate_form_reset();
?>