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

$rows = array();

# if submit from requirements_page.php
if( isset($_POST['submit_update']) ) {

	foreach($_POST as $key => $value) {

		$exploded_key = explode("_", $key);
		//print"$exploded_key<br>";

		if( $exploded_key[0]=="row" ) {
			$rows[] = $exploded_key[1];
		}
	}

	if( empty($rows) ) {
		error_report_show("requirement_page.php", NO_REQ_SELECTED);
	}
}

# if submit from this page
if( isset($_POST['submit_status']) ) {

	foreach(explode(":", $_POST['req_ids']) as $value) {

		requirement_version_table_set_field($value, REQ_VERS_STATUS, $_POST['req_status']);
	}

	html_print_operation_successful( 'build_page', "requirement_page.php" );
}

$req_ids = implode(":", $rows);

$page                   = basename(__FILE__);
$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('req_update_status_page'));
html_page_header( $db, $project_name );
html_print_menu();
requirement_menu_print($page);

print"<br>\n";

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

print"<form method=post action=requirement_change_status_page.php>\n";
print"<input type='hidden' name=req_ids value='$req_ids'>";

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>". lang_get('update_status') ."</h4></td>\n";
print"</tr>\n";

# STATUS
print"<tr>\n";
print"<td class='form-data-c'>";

print"<select name=req_status size=1>\n";
	$list_box = requirement_get_statuses();

	html_print_list_box_from_array(	$list_box );
print"</select>\n";

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

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