1<?php
2# ---------------------------------------------------------------------
3# rth is a requirement, test, and bugtracking system
4# Copyright (C) 2005 George Holbrook - rth@lists.sourceforge.net
5# This program is distributed under the terms and conditions of the GPL
6# See the README and LICENSE files for details
7#----------------------------------------------------------------------
8# ------------------------------------
9# Home Page 2
10#
11# $RCSfile: home_page2.php,v $
12# $Revision: 1.5 $
13# ------------------------------------
14
15include_once"./api/include_api.php";
16auth_authenticate_user();
17
18if( isset($_POST['submit_btn']) ) {
19
20	if( $_POST['submit_btn']==lang_get('edit') ) {
21
22		require_once("news_edit_page.php");
23		exit;
24	}
25
26	if( $_POST['submit_btn']==lang_get('delete') ) {
27
28		require_once("delete_page.php");
29		exit;
30	}
31
32	if( $_POST['submit_btn']==lang_get("new_post") ) {
33
34		require_once("news_add_page.php");
35		exit;
36	}
37}
38
39session_validate_form_reset();
40
41$project_name 		= session_get_project_name();
42$page				= basename(__FILE__);
43$row_style			= '';
44
45$project_properties     = session_get_project_properties();
46$project_name           = $project_properties['project_name'];
47$project_id				= $project_properties['project_id'];
48
49$test_detail_page		= 'test_detail_page.php';
50$req_detail_page		= 'requirement_detail_page.php';
51$results_page			= 'results_page.php';
52
53html_window_title();
54html_print_body();
55html_page_title($project_name ." - HOME");
56html_page_header( $db, $project_name );
57html_print_menu();
58//html_print_sub_menu( $page, array() );
59
60error_report_check( $_GET );
61
62
63//print"<h3>".lang_get("news")."</h3>". NEWLINE;
64
65
66print"<div align=center>". NEWLINE;
67
68print"<table width=80% border=0>". NEWLINE;
69print"<tr>". NEWLINE;
70print"<td align=left><font size=3><b>". lang_get('news') ."</b></font></td>". NEWLINE;
71print"</tr>". NEWLINE;
72print"</table>". NEWLINE;
73
74
75print"<table class=width80 rules=cols>". NEWLINE;
76
77$rows_news = news_get($project_id);
78
79if($rows_news) {
80
81	//print"<div align=center>". NEWLINE;
82
83	foreach($rows_news as $row_news) {
84
85		$news_id		= $row_news[NEWS_ID];
86		$subject 		= $row_news[NEWS_SUBJECT];
87		$body			= $row_news[NEWS_BODY];
88		$poster			= $row_news[NEWS_POSTER];
89		$news_modified	= $row_news[NEWS_MODIFIED];
90
91		//print"<table class=width80 rules=cols>". NEWLINE;
92
93		# NEWS TITLE
94		print"<tr class='tbl-header-l'>". NEWLINE;
95		print"<td><b>$subject - $news_modified - ".user_get_display_name($project_id, $poster)."</b></td>". NEWLINE;
96		print"</tr>". NEWLINE;
97
98		# NEWS
99		print"<tr>". NEWLINE;
100		print"<td align=left class=news-body>".util_html_encode_string($body)."</td>". NEWLINE;
101		print"</tr>". NEWLINE;
102/*
103		# EDIT, DELETE LINKS
104		print"<tr>". NEWLINE;
105			print"<td align=left>". NEWLINE;
106			print"<form action='$page' method=post>". NEWLINE;
107			print"<input type=hidden name=news_id value=$news_id>". NEWLINE;
108			print"[<input type=submit name=submit_btn value='".lang_get("edit")."' class=page-numbers>]". NEWLINE;
109			print"[<input type=submit name=submit_btn value='".lang_get("delete")."' class=page-numbers>]". NEWLINE;
110			print"<input type='hidden' name='r_page' value='$page'>". NEWLINE;
111			print"<input type='hidden' name='f' value='delete_news_post'>". NEWLINE;
112			print"<input type='hidden' name='id' value='$news_id'>". NEWLINE;
113			print"<input type='hidden' name='project_id' value='$project_id'>". NEWLINE;
114			print"<input type='hidden' name='msg' value='". DEL_NEWS ."'>". NEWLINE;
115			print"[<input type=submit name=submit_btn value='".lang_get("new_post")."' class=page-numbers>]". NEWLINE;
116			print"</form>". NEWLINE;
117			print"</td>". NEWLINE;
118		print"</tr>". NEWLINE;
119*/
120		//print"</table>". NEWLINE;
121
122		//print"<br>". NEWLINE;
123
124	}
125
126} else { # The default news if there isn't any
127
128		# DEFAULT NEWS
129		print"<tr class='tbl-header-l'>". NEWLINE;
130		print"<td><b>". lang_get('home_welcome') ."</b></td>". NEWLINE;
131		print"</tr>". NEWLINE;
132
133		# NEWS
134		print"<tr>". NEWLINE;
135		print"<td align=left class=news-body>".lang_get('home_notes')."</td>". NEWLINE;
136		print"</tr>". NEWLINE;
137
138}
139
140print"</table>". NEWLINE;
141print"</div>";
142print"<br>". NEWLINE;
143
144
145# LATEST TEST RESULTS
146print"<div align=center>". NEWLINE;
147
148print"<table width=80% border=0>". NEWLINE;
149print"<tr>". NEWLINE;
150print"<td align=left><font size=3><b>". lang_get('latest_test_results') ."</b></font></td>". NEWLINE;
151print"</tr>". NEWLINE;
152print"</table>". NEWLINE;
153#print"<h3>".lang_get("latest_test_results")."</h3>". NEWLINE;
154
155$release_id = admin_get_max_release_id_from_build_tbl( $project_id );
156$build_id = admin_get_max_build_id( $release_id );
157$testset_id = admin_get_max_testset( $build_id );
158
159if( empty($release_id) ) { # There are no tests associated to the testset or no test sets.
160
161	print lang_get('no_releases_in_project');
162} elseif( empty($build_id) ) {
163
164	print lang_get('no_builds_in_release');
165} elseif( empty($testset_id) ) {
166
167	print lang_get('no_testsets_in_build');
168} else {  # There are tests associated to the test set so we can display the test status.
169
170		$release_name	= admin_get_release_name( $release_id );
171		$build_info		= admin_get_build($project_id, $build_id);
172		$build_name		= $build_info[BUILD_NAME];
173		$build_date		= $build_info[BUILD_DATE_REC];
174
175	print"<table rules=cols class=width80>". NEWLINE;
176		print"<tr>". NEWLINE;
177		html_tbl_print_header( lang_get('release_name') );
178		html_tbl_print_header( lang_get('build_name') );
179		html_tbl_print_header( lang_get('build_date_received') );
180		print"</tr>". NEWLINE;
181
182		print"<tr>". NEWLINE;
183		print"<td class='tbl-data-c'>$release_name</td>". NEWLINE;
184		print"<td class='tbl-data-c'>$build_name</td>". NEWLINE;
185		print"<td class='tbl-data-c'>$build_date</td>". NEWLINE;
186		print"</tr>". NEWLINE;
187	print"</table>". NEWLINE;
188
189	print"<br>". NEWLINE;
190
191	$statuses = results_get_teststatus_by_project( $project_id );
192	$results_url = $results_page ."?release_id=$release_id&amp;build_id=$build_id&amp;testset_id=$testset_id";
193
194	print"<table rules=cols class=width80>". NEWLINE;
195		print"<tr>". NEWLINE;
196		html_tbl_print_header( lang_get('testset_name') );
197		# Display table headers based on the statuses of the project
198		foreach( $statuses as $status ) {
199			html_tbl_print_header( $status );
200		}
201		print"</tr>". NEWLINE;
202
203		// testset_get_last_5: function that returns an array with last 5 testsets created
204		$rows_testsets = &testset_get_last_5($project_id);
205
206
207		if($rows_testsets) {
208
209			foreach($rows_testsets as $row_testset) {
210
211				$testset_id	= $row_testset['TestSetID'];
212				$num_tests = admin_count_tests_in_testset( $testset_id );
213				$testset_name = admin_get_testset_name( $testset_id );
214				$row_style = html_tbl_alternate_bgcolor($row_style);
215				print"<tr class=$row_style>". NEWLINE;
216				$results_url = $results_page ."?release_id=$release_id&amp;build_id=$build_id&amp;testset_id=$testset_id";
217				print"<td class='tbl-data-c'><a href='$results_url'>$testset_name</a></td>";
218				# Display table data based on the statuses of the project as well
219				foreach( $statuses as $status ) {
220					$num = results_get_num_tests_by_status( $testset_id, $status );
221					print"<td class='tbl-data-c'>$num</td>". NEWLINE;
222				} print"</tr>";
223			}
224		}
225
226		print"</table>". NEWLINE;
227}
228
229print"</div>". NEWLINE;
230print"<br>";
231
232# DISPLAY SOMETHING LIKE PROD.  SOME STATS, A GRAPH, AND A LINK TO THE LATEST TEST RESULTS
233# MAKE SURE THERE ARE TESTS ADDED TO THE TEST SET WHEN GIVING THE LATEST TEST RESULTS LINK
234
235# LATEST CHANGES TO TESTS
236print"<div align=center>";
237
238print"<table width=80% border=0>". NEWLINE;
239print"<tr>". NEWLINE;
240print"<td align=left><font size=3><b>". lang_get('latest_tests') ."</b></font></td>". NEWLINE;
241print"</tr>". NEWLINE;
242print"</table>". NEWLINE;
243#print"<h3>".lang_get("latest_tests")."</h3>". NEWLINE;
244
245$rows_tests = test_get_last_modified($project_id);
246
247if($rows_tests) {
248
249	print"<table rules=cols class=width80>". NEWLINE;
250	print"<tr>";
251	html_tbl_print_header( lang_get('test_id') );
252	html_tbl_print_header( lang_get('test_name') );
253	html_tbl_print_header( lang_get('last_updated_by') );
254	html_tbl_print_header( lang_get('last_updated') );
255	print"</tr>";
256
257	foreach($rows_tests as $row_test) {
258
259		$test_id				= $row_test[TEST_ID];
260		$test_name 				= $row_test[TEST_NAME];
261		$test_last_updated		= $row_test[TEST_LAST_UPDATED];
262		$test_last_updated_by	= $row_test[TEST_LAST_UPDATED_BY];
263
264		$display_test_id = util_pad_id( $test_id );
265
266		$row_style = html_tbl_alternate_bgcolor($row_style);
267
268		print"<tr class=$row_style>". NEWLINE;
269		print"<td><a href='$test_detail_page?test_id=$test_id&project_id=$project_id'>$display_test_id</a></td>". NEWLINE;
270		print"<td>$test_name</td>". NEWLINE;
271		print"<td>$test_last_updated_by</td>". NEWLINE;
272		print"<td>$test_last_updated</td>". NEWLINE;
273		print"</tr>". NEWLINE;
274	}
275	print"</table>". NEWLINE;
276
277} else {
278
279	print lang_get('no_tests_in_project');
280}
281
282print"</div>". NEWLINE;
283print"<br>". NEWLINE;
284
285# LATEST CHANGES TO REQUIREMENTS
286print"<div align=center>". NEWLINE;
287
288print"<table width=80% border=0>". NEWLINE;
289print"<tr>". NEWLINE;
290print"<td align=left><font size=3><b>". lang_get('latest_requirements') ."</b></font></td>". NEWLINE;
291print"</tr>". NEWLINE;
292print"</table>". NEWLINE;
293#print"<h3>".lang_get("latest_requirements")."</h3>". NEWLINE;
294
295$rows_reqs = requirement_get_last_updated($project_id);
296
297if($rows_reqs) {
298
299	print"<table rules=cols class=width80>". NEWLINE;
300	print"<tr>";
301	html_tbl_print_header( lang_get('req_id') );
302	html_tbl_print_header( lang_get('req_version') );
303	html_tbl_print_header( lang_get('req_name') );
304	html_tbl_print_header( lang_get('last_updated_by') );
305	html_tbl_print_header( lang_get('last_updated') );
306	print"</tr>";
307
308	foreach($rows_reqs as $rows_req) {
309
310		$req_id					= $rows_req[REQ_ID];
311		$req_version_id			= $rows_req[REQ_VERS_UNIQUE_ID];
312		$req_name 				= $rows_req[REQ_FILENAME];
313		$req_last_updated		= $rows_req[REQ_VERS_LAST_UPDATED];
314		$req_last_updated_by	= $rows_req[REQ_VERS_LAST_UPDATED_BY];
315		$req_version			= $rows_req[REQ_VERS_VERSION];
316
317		$display_req_id = util_pad_id( $req_id );
318
319		$row_style = html_tbl_alternate_bgcolor($row_style);
320
321		print"<tr class=$row_style>". NEWLINE;
322		print"<td><a href='$req_detail_page?req_id=$req_id&amp;req_version_id=$req_version_id'>$display_req_id</a></td>". NEWLINE;
323		print"<td>$req_version</td>". NEWLINE;
324		print"<td>$req_name</td>". NEWLINE;
325		print"<td>$req_last_updated_by</td>". NEWLINE;
326		print"<td>$req_last_updated</td>". NEWLINE;
327		print"</tr>". NEWLINE;
328	}
329	print"</table>". NEWLINE;
330
331} else {
332
333	print lang_get('no_requirements_in_project');
334}
335
336print"</div>";
337
338html_print_footer();
339
340#------------------------------------
341# $Log: home_page2.php,v $
342# Revision 1.5  2008/07/21 07:42:34  peter_thal
343# small bug fixes for test_detail_page linking parameter
344#
345#
346# ------------------------------------
347
348?>
349