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# HTML API
10#
11# $RCSfile: html_api.php,v $
12# $Revision: 1.21 $
13# ------------------------------------
14
15
16    //include( config_get( 'meta_include_file' ) );
17    # maybe include meta include when you find out what it does
18    /*
19    print"<meta http-equiv=Pragma content=no-cache />";
20    print"<meta http-equiv=Cache-Control content=no-cache />";
21    print"<meta http-equiv=Pragma-directive content=no-cache />";
22    print"<meta http-equiv=Cache-Directive content=no-cache />";
23    print"<meta http-equiv=Expires content=0 />";
24    */
25
26#--------------------------------------------------------------------------------------------------
27# This function and the two following functions have the wrong names
28# Maybe this should be html_window_title, the next html_page_title, and the last html_print_header.
29# Just a thought
30#--------------------------------------------------------------------------------------------------
31function html_window_title() {
32
33	print"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">". NEWLINE;
34	print"<html>". NEWLINE;
35	print"<head>". NEWLINE;
36	print"<meta http-equiv='Content-type' content='text/html;charset=utf-8'>". NEWLINE;
37	print"<title>". WINDOW_TITLE ."</title>". NEWLINE;
38	print"<link rel=stylesheet type='text/css' href='./css/default.php'>". NEWLINE;
39
40	# Include javascript file if USE_JAVASCRIPT constant is ON
41	if( USE_JAVASCRIPT ) {
42		html_head_javascript();
43	}
44	print"</head>". NEWLINE;
45}
46
47# ---------------------------------------------------------------------
48# Include javascript file
49# ---------------------------------------------------------------------
50function html_head_javascript() {
51
52		echo"<script type='text/JavaScript' src='api/javascript_api.js'></script>". NEWLINE;
53		echo"<script src='sortable.js'></script>".NEWLINE;
54}
55
56#-----------------------------------------
57# Prints main title on page
58#-----------------------------------------
59function html_page_title( $page_title ) {
60
61    if( trim($page_title) == '' ) {
62        $page_title = PAGE_TITLE;
63    }
64    print"<h2>$page_title</h2>". NEWLINE;
65}
66
67# ---------------------------------------------------------------------
68# This function will display the user name, date and time, and project listbox accross the top of the page
69# The project list box will only appear if the user has access to more than one project
70# ---------------------------------------------------------------------
71function html_page_header( $db, $current_proj ) {
72
73	$s_user_projects 	= session_get_user_projects();
74	$s_user_properties 	= session_get_user_properties();
75    $date               = date_get_long_dt();
76
77    $username			= $s_user_properties['username'];
78
79    print"<form method=post name=form_set_project action='login_switch_proj.php'>". NEWLINE;
80    print"<table class=hide100>". NEWLINE;
81    print"<tr>". NEWLINE;
82    print"<td class=header-l width='33%'>logged in as $username</td>". NEWLINE;
83    print"<td class=header-c width='33%'>$date</td>". NEWLINE;
84
85    if( $s_user_projects > 1 ) { # display the project list box
86
87        print"<td class=header-r width='33%'>". NEWLINE;
88
89		# Check for Javascript
90		print"<noscript>". NEWLINE;
91		print"<input type=hidden name=javascript_disabled value=true>". NEWLINE;
92		print"</noscript>". NEWLINE;
93
94		# login variables set, so there is no need to do if( isset($_GET[login][page]) )
95		# in login_switch_proj.php
96		print"<input type=hidden name='login[page]' value=''>". NEWLINE;
97		print"<input type=hidden name='login[get]' value=''>". NEWLINE;
98		print"<input type=hidden name='uname' value='$username'>". NEWLINE;
99
100		# Check for Javascript
101		print"<noscript>". NEWLINE;
102		print"<input type=hidden name=non_javascript_browser value=true>". NEWLINE;
103		print"</noscript>". NEWLINE;
104
105        if( session_use_javascript() ) {
106        	print lang_get('switch_project')."&nbsp;&nbsp;". NEWLINE;
107        } else {
108        	print"<input type=submit value='". lang_get('switch_project') ."'>". NEWLINE;
109        }
110
111        print"<select name='login[switch_project]' onchange='document.forms.form_set_project.submit();'>". NEWLINE;
112        html_print_list_box_from_array(	$s_user_projects, $current_proj );
113        print"</select>". NEWLINE;
114        print"</td>". NEWLINE;
115    } else { # don't display the project list box
116        print"<td class=header-r width=33%>&nbsp</td>". NEWLINE;
117    }
118
119
120    print"</tr>". NEWLINE;
121    print"</table>". NEWLINE;
122    print"</form>". NEWLINE;
123}
124
125# -----------------------------------------------------------------
126# This function will generate the main menu at the top of every page
127# The RTH_URL is defined in the properties_inc.php file
128# -----------------------------------------------------------------
129function html_print_menu() {
130
131    $home_url       = RTH_URL . "home_page.php";
132    $req_url        = RTH_URL . "requirement_page.php";
133    $test_url       = RTH_URL . "test_page.php";
134	$release_url    = RTH_URL . "release_page.php";
135    $results_url    = RTH_URL . "results_page.php";
136	$bug_url		= BUGTRACKER_URL;
137	$reports_url    = RTH_URL . "report_page.php";
138	$admin_url      = RTH_URL . "admin_page.php";
139    $user_url       = RTH_URL . "user_edit_my_account_page.php";
140    $help_url		= RTH_URL . "help_index.php";
141    $logout_url     = RTH_URL . "logout.php";
142
143	# set user url if user has admin rights
144    $s_user_properties 	= session_get_user_properties();
145	$user_id 			= $s_user_properties['user_id'];
146
147	$s_project_properties   = session_get_project_properties();
148	$project_name           = $s_project_properties['project_name'];
149	$project_id 			= $s_project_properties['project_id'];
150
151	if( user_has_rights($project_id, $user_id, ADMIN) ) {
152		$user_url       = RTH_URL . "user_manage_page.php";
153	}
154
155    # Get the session variables from the results page and append them on the query string if they are set
156    $s_results = session_get_display_options("results");
157
158    if( isset( $s_results['release_id'] ) ) {
159        $results_url = $results_url . "?release_id=" .$s_results['release_id'];
160    }
161    if( isset( $s_results['build_id'] ) ) {
162        $results_url = $results_url . "&build_id=" .$s_results['build_id'];
163    }
164    if( isset( $s_results['testset_id'] ) ) {
165        $results_url = $results_url . "&testset_id=" .$s_results['testset_id'];
166    }
167    if( isset( $s_results['test_id'] ) ) {
168		$results_url = "results_test_run_page.php?test_id=" .$s_results['test_id'] ."&testset_id=". $s_results['testset_id'];
169    }
170
171    print"<table class=width100 cellspacing=0>". NEWLINE;
172    print"<tr>". NEWLINE;
173	print"<td class=menu>". NEWLINE;
174	print"<a href='$home_url'>"		. lang_get( 'home_link' ) ."</a> | ". NEWLINE;
175	print"<a href='$req_url'>" 		. lang_get( 'req_link' ) ."</a> | ". NEWLINE;
176	print"<a href='$test_url'>"		. lang_get( 'test_link' ) . "</a> | ". NEWLINE;
177	print"<a href='$release_url'>"	. lang_get( 'release_link' ) . "</a> | ". NEWLINE;
178	print"<a href='$results_url'>"	. lang_get( 'results_link' ) . "</a> | ". NEWLINE;
179	print"<a href='$bug_url'";
180	if( BUGTRACKER != 'rth' ) {
181		print" target='new'";
182	}
183	print">"		. lang_get( 'bug_link' ) . "</a> | ". NEWLINE;
184	print"<a href='$reports_url'>"	. lang_get( 'reports_link' ) . "</a> | ". NEWLINE;
185	print"<a href='$admin_url'>"	. lang_get( 'admin_link' ) . "</a> | ". NEWLINE;
186	print"<a href='$user_url'>" 	. lang_get( 'user_link' ) . "</a> | ". NEWLINE;
187	print"<a href='$help_url' target=_blank>"		. lang_get( 'help_link' ) . "</a> | ". NEWLINE;
188	print"<a href='$logout_url'>"	. lang_get( 'logout_link' ) . "</a>". NEWLINE;
189	print"</td>". NEWLINE;
190    print"</tr>". NEWLINE;
191    print"</table>". NEWLINE;
192    print"<br>". NEWLINE;
193}
194
195# ----------------------------------------------------------------
196# Prints a menu of values seperated by "  |  "
197#
198# INPUT:
199#	current page
200#	array of menu items and their urls
201# OUTPUT:
202#	html menu
203# ----------------------------------------------------------------
204function html_print_sub_menu($page, $menu_items) {
205
206	$test_add_url       = RTH_URL . "main.php";
207	$test_workflow_url  = RTH_URL . "main.php";
208	$query_str			= "";
209
210	if( isset($_SERVER['QUERY_STRING']) ) {
211		$query_str = "?".$_SERVER['QUERY_STRING'];
212	}
213
214	print"<div align='center'>". NEWLINE;
215	print"<table class='sub-menu'>". NEWLINE;
216	print"<tr>". NEWLINE;
217	print"<td class='menu'>&nbsp;&nbsp;";
218
219	$i = 1;
220	$array_size = count($menu_items);
221
222	foreach($menu_items as $menu_page => $menu_url) {
223
224		$parsed_url = parse_url($menu_url);
225		$url_page = basename($parsed_url['path']);
226
227
228		if( $page == $menu_url || $page.$query_str == $menu_url ) {
229			print $menu_page;
230		} else {
231			print "<a href='$menu_url'>" . $menu_page ."</a>";
232		}
233
234		# if not the last element in the menu
235		if ($i != $array_size) {
236			print "&nbsp;&nbsp;|&nbsp;&nbsp;";
237		}
238
239		$i++;
240	}
241
242	print"&nbsp;&nbsp;</td>". NEWLINE;
243	print"</tr>". NEWLINE;
244	print"</table>". NEWLINE;
245	print"</div>". NEWLINE;
246}
247
248# -----------------------------------------------------------------------
249# Display the menu when drilling down to view a testset
250# The page, $table_display_properties and $filter parameters should allow
251# us to reuse this function on different pages
252# INPUT:
253#   db, page and project_id
254#   table_display_properties contains release, build and testset data
255#   filter
256# OUTPUT:
257#   Corresponding testset information
258# -----------------------------------------------------------------------
259function html_test_results_menu( $db, $page, $project_id, $table_display_properties=null, $filter=null ) {
260
261
262    $release_tbl        = RELEASE_TBL;
263    $f_release_id       = RELEASE_TBL .".". RELEASE_ID;
264    $f_project_id		= RELEASE_TBL .".". PROJECT_ID;
265    $f_release_name     = RELEASE_TBL .".". RELEASE_NAME;
266    $f_release_archive  = RELEASE_TBL .".". RELEASE_ARCHIVE;
267
268    $build_tbl          = BUILD_TBL;
269    $f_build_id         = BUILD_TBL .".". BUILD_ID;
270    $f_build_rel_id     = BUILD_TBL .".". BUILD_REL_ID;
271    $f_build_name       = BUILD_TBL .".". BUILD_NAME;
272    $f_build_archive    = BUILD_TBL .".". BUILD_ARCHIVE;
273
274    $testset_tbl        = TS_TBL;
275    $f_testset_id       = TS_TBL .".". TS_ID;
276    $f_testset_name     = TS_TBL .".". TS_NAME;
277
278    $test_tbl			= TEST_TBL;
279    $f_test_id			= TEST_ID;
280    $f_test_name		= TEST_NAME;
281
282    $test_run_page = "results_test_run_page.php";
283
284	$release_id		= $table_display_properties['release_id'];
285	$build_id		= $table_display_properties['build_id'];
286	$testset_id		= $table_display_properties['testset_id'];
287	$test_id		= $table_display_properties['test_id'];
288
289    if( empty( $filter['release_id'] ) ) {
290        $show_all = true;
291    } else {
292        $show_all = false;
293    }
294
295    //<!--Table for holding all other tables-->
296    print"<table class='hide100'>". NEWLINE;
297    print"<tr>". NEWLINE;
298    print"<td>". NEWLINE;
299
300	# Release Name
301    print"<table align='left'>". NEWLINE;
302    print"<tr>". NEWLINE;
303    print"<td class='sub_menu' nowrap><b><a href='$page?release_id=all'>". lang_get( 'release_name' ) ."</a></b></td>". NEWLINE;
304    print"</tr>". NEWLINE;
305
306    # if the user has not selected a release show all releases
307    if ( ( empty($release_id) || $release_id == 'all')  && $show_all == true ) {
308
309		$q 		= "SELECT DISTINCT $f_release_name, $f_release_id FROM $release_tbl WHERE $f_project_id = '$project_id' AND  $f_release_archive = 'N' ORDER BY $f_release_id";
310		$rs 	= db_query( $db, $q);
311		$rows	= db_fetch_array( $db, $rs );
312
313        if($rows) {
314
315        	foreach($rows as $row_release) {
316				$rel_id 	= $row_release[RELEASE_ID];
317				$rel_name 	= $row_release[RELEASE_NAME];
318				print"<tr>". NEWLINE;
319				print"<td class='sub_menu'><a href='$page?release_id=$rel_id'>$rel_name</a></td>". NEWLINE;
320				print"</tr>". NEWLINE;
321			}
322        } else  {
323
324			print"<tr>". NEWLINE;
325			print"<td class='error'>".lang_get('no_releases_in_project')."</td>". NEWLINE;
326			print"</tr>". NEWLINE;
327        }
328
329        print"</table>". NEWLINE;
330    } else { # Show the selected release and the build information
331
332        $q_rel_name = "SELECT $f_release_name FROM $release_tbl WHERE $f_release_id = '$table_display_properties[release_id]'";
333        $release_name = db_get_one( $db, $q_rel_name );
334
335        print"<tr>". NEWLINE;
336        print"<td class='sub_menu' nowrap>$release_name</td>". NEWLINE;
337        print"</tr>". NEWLINE;
338        print"</table>". NEWLINE;
339
340		print"<table align='left'>". NEWLINE;
341		print"<tr>". NEWLINE;
342		print"<td class='sub_menu'>&nbsp;</td>". NEWLINE;
343		print"</tr>". NEWLINE;
344		print"</table>". NEWLINE;
345
346        $q_build = "SELECT DISTINCT $f_build_name, $f_build_id FROM $build_tbl WHERE $f_build_archive = 'N' AND $f_build_rel_id = '$table_display_properties[release_id]' ORDER BY $f_build_name";
347        $rs_build = db_query( $db, $q_build );
348        $num_build = db_num_rows( $db, $rs_build );
349
350        print"<table align='left'>". NEWLINE;
351        print"<tr>". NEWLINE;
352        print"<td class='sub_menu' nowrap><b><a href='$page?release_id=$table_display_properties[release_id]&amp;build_id=all'>". lang_get('build_name') ."</a></b></td>". NEWLINE;
353        print"</tr>". NEWLINE;
354
355        # if the user has not selected a build, show all builds
356        if ( ( empty( $build_id ) || $build_id == 'all' ) && $show_all == true ) {
357            if($num_build == 0) { # if there are no builds display a message
358                print"<tr>". NEWLINE;
359                print"<td class='sub_menu'>". lang_get('builds_none') ."	</td>". NEWLINE;
360                print"</tr>". NEWLINE;
361                print"</table>". NEWLINE;
362            } else { # Show all builds associated to the selected release
363                while($row_build = db_fetch_row( $db, $rs_build ) ) {
364
365                    $b_name = $row_build[BUILD_NAME];
366                    $b_id	= $row_build[BUILD_ID];
367                    print"<tr>". NEWLINE;
368                    print"<td class='sub_menu'><a href='$page?release_id=$table_display_properties[release_id]&amp;build_id=$b_id'>$b_name</a></td>". NEWLINE;
369                    print"</tr>". NEWLINE;
370                }
371                print"</table>". NEWLINE;
372            }
373        } else { # show the selected build and testset information
374            $q_build_name = "SELECT $f_build_name FROM $build_tbl WHERE $f_build_id = '$table_display_properties[build_id]'";
375            $build_name = db_get_one( $db, $q_build_name );
376
377            print"<tr>". NEWLINE;
378            print"<td class='sub_menu'>$build_name</td>". NEWLINE;
379            print"</tr>". NEWLINE;
380            print"</table>";
381
382			print"<table align='left'>". NEWLINE;
383			print"<tr>". NEWLINE;
384			print"<td class='sub_menu'>&nbsp;</td>". NEWLINE;
385			print"</tr>". NEWLINE;
386			print"</table>". NEWLINE;
387
388            # MAY NEED TO CHANGE THE LOGIC TO EXCLUDE ALL
389            # WHEN A USER CLICKS ALL THE TABLE SHOULD APPEAR WITHOUT A SELECTED
390            # if the
391            if( isset( $table_display_properties['testset_id'] ) && $table_display_properties['testset_id'] != 'all' ) {
392                $q_testset_name = "SELECT $f_testset_name FROM $testset_tbl WHERE $f_testset_id = '$table_display_properties[testset_id]'";
393                $testset_name = db_get_one( $db, $q_testset_name );
394                print"<table align='left'>". NEWLINE;
395                print"<tr>". NEWLINE;
396                print"<td class='sub_menu' nowrap><b><a href='$page?release_id=$table_display_properties[release_id]&amp;build_id=$table_display_properties[build_id]&amp;testset_id=all'>" .lang_get('testset_name'). "</a></b></td>". NEWLINE;
397                print"</tr>". NEWLINE;
398                //print"<tr><td class='sub_menu'>$testset_name</td></tr>". NEWLINE;
399                print"<tr>". NEWLINE;
400				print"<td class='sub_menu'><a href='$page?release_id=$table_display_properties[release_id]&amp;build_id=$table_display_properties[build_id]&amp;testset_id=$table_display_properties[testset_id]&amp;test_id=none'>$testset_name</a></td>". NEWLINE;
401				print"</tr>". NEWLINE;
402                print"</table>". NEWLINE;
403            }
404
405            if( !empty($testset_id) && $testset_id != 'all' && !empty($test_id) && $test_id != 'none') {
406
407            	$q_testname = "SELECT $f_test_name FROM $test_tbl WHERE $f_test_id = '$table_display_properties[test_id]'";
408            	$test_name = db_get_one( $db, $q_testname );
409
410				# Only display the link if not on the test run page
411            	$current_page = basename($_SERVER["PHP_SELF"]);
412            	if( $test_run_page!=$current_page ) {
413
414            		$test_name = "<a href='$test_run_page?release_id=$table_display_properties[release_id]&amp;build_id=$table_display_properties[build_id]&amp;testset_id=$table_display_properties[testset_id]&amp;test_id=$table_display_properties[test_id]'>$test_name</a>";
415            	}
416
417            	print"<table>". NEWLINE;
418				print"<tr>". NEWLINE;
419				print"<td class='sub_menu' nowrap><b>" .lang_get('test_run'). "</b></td>". NEWLINE;
420				print"</tr>". NEWLINE;
421				print"<tr><td class='sub_menu'>$test_name</td></tr>". NEWLINE;
422                print"</table>". NEWLINE;
423            }
424        }
425    }
426
427    print"</td>". NEWLINE;
428    print"</tr>". NEWLINE;
429    print"</table>". NEWLINE;
430
431}
432
433# -----------------------------------------------------------------------
434# Display the menu when drilling down to view a testset
435# The page, $table_display_properties and $filter parameters should allow
436# us to reuse this function on different pages
437# INPUT:
438#   db, page and project_id
439#   table_display_properties contains release, build and testset data
440#   filter
441# OUTPUT:
442#   Corresponding testset information
443# -----------------------------------------------------------------------
444function html_testset_menu( $db, $page, $project_id, $table_display_properties=null ) {
445
446    $release_tbl        = RELEASE_TBL;
447    $f_release_id       = RELEASE_TBL .".". RELEASE_ID;
448    $f_project_id		= RELEASE_TBL .".". PROJECT_ID;
449    $f_release_name     = RELEASE_TBL .".". RELEASE_NAME;
450    $f_release_archive  = RELEASE_TBL .".". RELEASE_ARCHIVE;
451    $build_tbl          = BUILD_TBL;
452    $f_build_id         = BUILD_TBL .".". BUILD_ID;
453    $f_build_rel_id     = BUILD_TBL .".". BUILD_REL_ID;
454    $f_build_name       = BUILD_TBL .".". BUILD_NAME;
455    $f_build_archive    = BUILD_TBL .".". BUILD_ARCHIVE;
456    $testset_tbl        = TS_TBL;
457    $f_testset_id       = TS_TBL .".". TS_ID;
458    $f_testset_name     = TS_TBL .".". TS_NAME;
459    $test_tbl			= TEST_TBL;
460    $f_test_id			= TEST_ID;
461    $f_test_name		= TEST_NAME;
462
463    if( isset($_GET['testset_menu_release_id']) ) {
464		$release_id = $_GET['testset_menu_release_id'];
465	}
466
467	if( isset($_GET['testset_menu_build_id']) ) {
468		$build_id = $_GET['testset_menu_build_id'];
469	}
470
471	if( isset($_GET['testset_menu_testset_id']) ) {
472		$testset_id = $_GET['testset_menu_testset_id'];
473	}
474
475    if( empty( $filter['release_id'] ) ) {
476        $show_all = true;
477    } else {
478        $show_all = false;
479    }
480
481    $q = "	SELECT DISTINCT	$f_release_name,
482    						$f_release_id
483    		FROM $release_tbl
484    		WHERE $f_project_id = '$project_id'
485    			AND  $f_release_archive = 'N'
486    		ORDER BY $f_release_id";
487
488    $rs = db_query($db, $q);
489
490    //<!--Table for holding all other tables-->
491    print"<table class='hide100'>". NEWLINE;
492    print"<tr>". NEWLINE;
493    print"<td>". NEWLINE;
494
495	# Release Name
496    print"<table align='left'>". NEWLINE;
497    print"<tr>". NEWLINE;
498    print"<td class='sub_menu' nowrap><b><a href='$page?testset_menu_release_id=all'>". lang_get( 'release_name' ) ."</a></b></td>". NEWLINE;
499    print"</tr>". NEWLINE;
500
501    # if the user has not selected a release show all releases
502    if ( ( !isset( $release_id ) || $release_id == 'all') ) {
503
504        while( $row = db_fetch_row( $db, $rs ) ) {
505
506			$rel_id = $row[RELEASE_ID];
507			$rel_name = $row[RELEASE_NAME];
508            print"<tr>". NEWLINE;
509            print"<td class='sub_menu'><a href='$page?testset_menu_release_id=$rel_id'>$rel_name</a></td>". NEWLINE;
510            print"</tr>". NEWLINE;
511        }
512
513        print"</table>". NEWLINE;
514    } else { # Show the selected release and the build information
515
516        $q_rel_name = "	SELECT $f_release_name
517        				FROM $release_tbl
518        				WHERE $f_release_id = $release_id";
519
520        $release_name = db_get_one( $db, $q_rel_name );
521
522        print"<tr>". NEWLINE;
523        print"<td class='sub_menu' nowrap>$release_name</td>". NEWLINE;
524        print"</tr>". NEWLINE;
525        print"</table>". NEWLINE;
526
527		print"<table align='left'>". NEWLINE;
528		print"<tr>". NEWLINE;
529		print"<td class='sub_menu'>&nbsp;</td>". NEWLINE;
530		print"</tr>". NEWLINE;
531		print"</table>". NEWLINE;
532
533        $q_build = "SELECT DISTINCT $f_build_name,
534        							$f_build_id
535        			FROM $build_tbl
536        			WHERE $f_build_archive = 'N'
537        				AND $f_build_rel_id = $release_id
538        			ORDER BY $f_build_name";
539
540        $rs_build	= db_query($db, $q_build);
541        $num_build	= db_num_rows($db, $rs_build);
542
543		# Build Name
544        print"<table align='left'>". NEWLINE;
545        print"<tr>". NEWLINE;
546        print"<td class='sub_menu' nowrap><b><a href='$page?testset_menu_release_id=$release_id&amp;testset_menu_build_id=all'>". lang_get('build_name') ."</a></b></td>". NEWLINE;
547        print"</tr>". NEWLINE;
548
549        # if the user has not selected a build, show all builds
550        if ( ( !isset( $build_id ) || $build_id == 'all' ) && $show_all == true ) {
551            if($num_build == 0) { # if there are no builds display a message
552                print"<tr>". NEWLINE;
553                print"<td class='sub_menu'>". lang_get('builds_none') ."	</td>". NEWLINE;
554                print"</tr>". NEWLINE;
555                print"</table>". NEWLINE;
556            } else { # Show all builds associated to the selected release
557                while($row_build = db_fetch_row( $db, $rs_build ) ) {
558
559                    $b_name = $row_build[BUILD_NAME];
560                    $b_id	= $row_build[BUILD_ID];
561                    print"<tr>". NEWLINE;
562                    print"<td class='sub_menu'><a href='$page?testset_menu_release_id=$release_id&amp;testset_menu_build_id=$b_id'>$b_name</a></td>". NEWLINE;
563                    print"</tr>". NEWLINE;
564                }
565                print"</table>". NEWLINE;
566            }
567        } else { # show the selected build and testset information
568            $q_build_name = "	SELECT $f_build_name
569            					FROM $build_tbl
570            					WHERE $f_build_id = $build_id";
571
572            $build_name = db_get_one( $db, $q_build_name );
573
574            print"<tr>". NEWLINE;
575            print"<td class='sub_menu'>$build_name</td>". NEWLINE;
576            print"</tr>". NEWLINE;
577            print"</table>";
578
579			print"<table align='left'>". NEWLINE;
580			print"<tr>". NEWLINE;
581			print"<td class='sub_menu'>&nbsp;</td>". NEWLINE;
582			print"</tr>". NEWLINE;
583			print"</table>". NEWLINE;
584
585			# Testset Name
586			print"<table align='left'>". NEWLINE;
587			print"<tr>". NEWLINE;
588			print"<td class='sub_menu' nowrap><b><a href='$page?testset_menu_release_id=$release_id&amp;testset_menu_build_id=$build_id&amp;testset_menu_testset_id=all'>" .lang_get('testset_name'). "</a></b></td>". NEWLINE;
589			print"</tr>". NEWLINE;
590
591            if( isset( $testset_id ) && $testset_id != 'all' ) {
592
593
594				$q_testset_name = "	SELECT $f_testset_name
595									FROM $testset_tbl
596									WHERE $f_testset_id = $testset_id";
597
598				$testset_name = db_get_one( $db, $q_testset_name );
599
600                print"<tr>". NEWLINE;
601				print"<td class='sub_menu'>$testset_name</td>". NEWLINE;
602				print"</tr>". NEWLINE;
603                print"</table>". NEWLINE;
604
605            } else {
606
607				$testset_tbl                = TS_TBL;
608				$db_testset_id              = TS_TBL .".". TS_ID;
609				$db_testset_name            = TS_TBL .".". TS_NAME;
610				$db_testset_build_id        = TS_TBL .".". TS_BUILD_ID;
611
612				$q = "	SELECT 	$db_testset_name,
613								$db_testset_id
614						FROM $testset_tbl
615						WHERE $db_testset_build_id = $build_id
616						ORDER BY $db_testset_name ASC";
617
618				$rows 	= db_fetch_array($db, db_query($db, $q));
619
620				if( $rows ) {
621
622					foreach( $rows as $row ) {
623
624						$testset_name = $row[TS_NAME];
625						$testset_id = $row[TS_ID];
626
627						print"<tr>". NEWLINE;
628						print"<td class='sub_menu'><a href='$page?testset_menu_release_id=$release_id&amp;"
629								. "testset_menu_build_id=$build_id&amp;"
630								. "testset_menu_testset_id=$testset_id"
631								. "'>$testset_name</a></td>". NEWLINE;
632						print"</tr>". NEWLINE;
633					}
634					print"</table>". NEWLINE;
635
636				} else {
637					echo"<br>". NEWLINE;
638					echo"<p class='error'>". lang_get( 'no_testsets' ) ."</p>". NEWLINE;
639				}
640            }
641        }
642    }
643
644    print"</td>". NEWLINE;
645    print"</tr>". NEWLINE;
646    print"</table>". NEWLINE;
647}
648
649
650# -----------------------------------------------------------------------
651# Display the menu when drilling down to view a testset
652# The page, $table_display_properties and $filter parameters should allow
653# us to reuse this function on different pages
654# INPUT:
655#   db, page and project_id
656#   table_display_properties contains release, build and testset data
657#   filter
658# OUTPUT:
659#   Corresponding testset information
660# -----------------------------------------------------------------------
661function html_browse_release_menu( 	$db,
662									$page,
663									$project_id,
664									$display_property_group="",
665									$show_build=true,
666									$show_testset=true ) {
667
668    $release_tbl        = RELEASE_TBL;
669    $f_release_id       = RELEASE_TBL .".". RELEASE_ID;
670    $f_project_id		= RELEASE_TBL .".". PROJECT_ID;
671    $f_release_name     = RELEASE_TBL .".". RELEASE_NAME;
672    $f_release_archive  = RELEASE_TBL .".". RELEASE_ARCHIVE;
673    $f_release_date 	= RELEASE_TBL .".". RELEASE_DATE_RECEIVED;
674
675    $build_tbl          = BUILD_TBL;
676    $f_build_id         = BUILD_TBL .".". BUILD_ID;
677    $f_build_rel_id     = BUILD_TBL .".". BUILD_REL_ID;
678    $f_build_name       = BUILD_TBL .".". BUILD_NAME;
679    $f_build_archive    = BUILD_TBL .".". BUILD_ARCHIVE;
680    $f_build_date		= BUILD_TBL .".". BUILD_DATE_REC;
681
682    $testset_tbl        = TS_TBL;
683    $f_testset_id       = TS_TBL .".". TS_ID;
684    $f_testset_name     = TS_TBL .".". TS_NAME;
685    $f_testset_date     = TS_TBL .".". TS_DATE_CREATED;
686
687    $test_tbl			= TEST_TBL;
688    $f_test_id			= TEST_ID;
689    $f_test_name		= TEST_NAME;
690
691    if( isset($_GET["$display_property_group"."_release_id"]) ) {
692		$release_id = $_GET["$display_property_group"."_release_id"];
693	}
694
695	if( isset($_GET["$display_property_group"."_build_id"]) ) {
696		$build_id = $_GET["$display_property_group"."_build_id"];
697	}
698
699	if( isset($_GET["$display_property_group"."_testset_id"]) ) {
700		$testset_id = $_GET["$display_property_group"."_testset_id"];
701	}
702
703    if( empty( $filter["release_id"] ) ) {
704        $show_all = true;
705    } else {
706        $show_all = false;
707    }
708
709    //<!--Table for holding all other tables-->
710    print"<table class='hide100'>". NEWLINE;
711    print"<tr>". NEWLINE;
712    print"<td>". NEWLINE;
713
714	# Release Name
715    print"<table align='left'>". NEWLINE;
716    print"<tr>". NEWLINE;
717    print"<td class='sub_menu' nowrap><b><a href='$page?$display_property_group"."_release_id=all'>". lang_get( 'release_name' ) ."</a></b></td>". NEWLINE;
718    print"</tr>". NEWLINE;
719
720    # if the user has not selected a release show all releases
721    if ( ( !isset( $release_id ) || $release_id == 'all') ) {
722
723		$q 		= "SELECT DISTINCT $f_release_name, $f_release_id FROM $release_tbl WHERE $f_project_id = '$project_id' AND  $f_release_archive = 'N' ORDER BY $f_release_id";
724		$rs 	= db_query( $db, $q);
725		$rows	= db_fetch_array( $db, $rs );
726
727        if($rows) {
728
729        	foreach($rows as $row_release) {
730				$rel_id 	= $row_release[RELEASE_ID];
731				$rel_name 	= $row_release[RELEASE_NAME];
732				print"<tr>". NEWLINE;
733				print"<td class='sub_menu'><a href='$page?_release_id=$rel_id'>$rel_name</a></td>". NEWLINE;
734				print"</tr>". NEWLINE;
735			}
736        } else  {
737
738			print"<tr>". NEWLINE;
739			print"<td class='error'>".lang_get('no_releases_in_project')."</td>". NEWLINE;
740			print"</tr>". NEWLINE;
741        }
742
743        print"</table>". NEWLINE;
744    } else { # Show the selected release and the build information
745
746        $q_rel_name = "	SELECT $f_release_name
747        				FROM $release_tbl
748        				WHERE $f_release_id = $release_id";
749
750        $release_name = db_get_one( $db, $q_rel_name );
751
752        print"<tr>". NEWLINE;
753        print"<td class='sub_menu' nowrap>$release_name</td>". NEWLINE;
754        print"</tr>". NEWLINE;
755        print"</table>". NEWLINE;
756
757		print"<table align='left'>". NEWLINE;
758		print"<tr>". NEWLINE;
759		print"<td class='sub_menu'>&nbsp;</td>". NEWLINE;
760		print"</tr>". NEWLINE;
761		print"</table>". NEWLINE;
762
763		if( $show_build ) {
764
765
766			$q_build = "SELECT DISTINCT $f_build_name,
767										$f_build_id
768						FROM $build_tbl
769						WHERE $f_build_archive = 'N'
770							AND $f_build_rel_id = $release_id
771						ORDER BY $f_build_date ASC";
772
773			$rs_build	= db_query($db, $q_build);
774			$num_build	= db_num_rows($db, $rs_build);
775
776			# Build Name
777			print"<table align='left'>". NEWLINE;
778			print"<tr>". NEWLINE;
779			print"<td class='sub_menu' nowrap><b><a href='$page?$display_property_group"."_release_id=$release_id&amp;$display_property_group"."_build_id=all'>". lang_get('build_name') ."</a></b></td>". NEWLINE;
780			print"</tr>". NEWLINE;
781
782			# if the user has not selected a build, show all builds
783			if ( ( !isset( $build_id ) || $build_id == 'all' ) && $show_all == true ) {
784				if($num_build == 0) { # if there are no builds display a message
785					print"<tr>". NEWLINE;
786					print"<td class='sub_menu'>". lang_get('builds_none') ."	</td>". NEWLINE;
787					print"</tr>". NEWLINE;
788					print"</table>". NEWLINE;
789				} else { # Show all builds associated to the selected release
790					while($row_build = db_fetch_row( $db, $rs_build ) ) {
791
792						$b_name = $row_build[BUILD_NAME];
793						$b_id	= $row_build[BUILD_ID];
794						print"<tr>". NEWLINE;
795						print"<td class='sub_menu'><a href='$page?$display_property_group"."_release_id=$release_id&amp;$display_property_group"."_build_id=$b_id'>$b_name</a></td>". NEWLINE;
796						print"</tr>". NEWLINE;
797					}
798					print"</table>". NEWLINE;
799				}
800			} else { # show the selected build and testset information
801				$q_build_name = "	SELECT $f_build_name
802									FROM $build_tbl
803									WHERE $f_build_id = $build_id";
804
805				$build_name = db_get_one( $db, $q_build_name );
806
807				print"<tr>". NEWLINE;
808				print"<td class='sub_menu'>$build_name</td>". NEWLINE;
809				print"</tr>". NEWLINE;
810				print"</table>";
811
812				print"<table align='left'>". NEWLINE;
813				print"<tr>". NEWLINE;
814				print"<td class='sub_menu'>&nbsp;</td>". NEWLINE;
815				print"</tr>". NEWLINE;
816				print"</table>". NEWLINE;
817
818				if( $show_testset ) {
819
820					# Testset Name
821					print"<table align='left'>". NEWLINE;
822					print"<tr>". NEWLINE;
823					print"<td class='sub_menu' nowrap><b><a href='$page?$display_property_group"."_release_id=$release_id&amp;$display_property_group"."_build_id=$build_id&amp;$display_property_group"."_testset_id=all'>" .lang_get('testset_name'). "</a></b></td>". NEWLINE;
824					print"</tr>". NEWLINE;
825
826					if( isset( $testset_id ) && $testset_id != 'all' ) {
827
828
829						$q_testset_name = "	SELECT $f_testset_name
830											FROM $testset_tbl
831											WHERE $f_testset_id = $testset_id";
832
833						$testset_name = db_get_one( $db, $q_testset_name );
834
835						print"<tr>". NEWLINE;
836						print"<td class='sub_menu'>$testset_name</td>". NEWLINE;
837						print"</tr>". NEWLINE;
838						print"</table>". NEWLINE;
839
840					} else {
841
842						$testset_tbl                = TS_TBL;
843						$db_testset_id              = TS_TBL .".". TS_ID;
844						$db_testset_name            = TS_TBL .".". TS_NAME;
845						$db_testset_build_id        = TS_TBL .".". TS_BUILD_ID;
846
847						$q = "	SELECT 	$db_testset_name,
848										$db_testset_id
849								FROM $testset_tbl
850								WHERE $db_testset_build_id = $build_id
851								ORDER BY $f_testset_date ASC";
852
853						$rows 	= db_fetch_array($db, db_query($db, $q));
854
855						if( $rows ) {
856
857							foreach( $rows as $row ) {
858
859								$testset_name = $row[TS_NAME];
860								$testset_id = $row[TS_ID];
861
862								print"<tr>". NEWLINE;
863								print"<td class='sub_menu'><a href='$page?$display_property_group"."_release_id=$release_id&amp;"
864										. "$display_property_group"."_build_id=$build_id&amp;"
865										. "$display_property_group"."_testset_id=$testset_id"
866										. "'>$testset_name</a></td>". NEWLINE;
867								print"</tr>". NEWLINE;
868							}
869							print"</table>". NEWLINE;
870
871						} else {
872							print"<tr>". NEWLINE;
873							print"<td class='sub_menu'><br>";
874							echo"<p class='error'>". lang_get( 'no_testsets' ) ."</p>". NEWLINE;
875							print"</tr>". NEWLINE;
876							print"</table>". NEWLINE;
877						}
878					}
879				}
880			}
881		}
882    }
883
884    print"</td>". NEWLINE;
885    print"</tr>". NEWLINE;
886    print"</table>". NEWLINE;
887}
888
889
890function html_project_manage_menu() {
891
892	$selected_project_properties 	= session_get_properties("project_manage");
893	$selected_project_id 			= $selected_project_properties['project_id'];
894
895	$manage_pages = array(	'project_manage_page.php'				=> lang_get('edit_project')." (".project_get_name($selected_project_id).")",
896							'project_manage_reqareacovered_page.php'=> lang_get('reqs'),
897							'project_archive_results_page.php'=> lang_get('tests'),
898							'project_manage_bug_category_page.php' => lang_get('bug_link') );
899
900	print"<div align='center'>". NEWLINE;
901	print"<table class='sub-menu' rules=cols>". NEWLINE;
902	print"<tr><td class='menu'>";
903
904	$str = "";
905
906	foreach($manage_pages as $key => $value) {
907
908		if( stristr($_SERVER['PHP_SELF'], $key)===false ) {
909			$str .= "&nbsp;<a href='$key'>$value</a>&nbsp;|". NEWLINE;
910		} else {
911			$str .= "&nbsp;$value&nbsp;|". NEWLINE;
912		}
913	}
914
915	print substr($str, 0, -2);
916	print"</td></tr>";
917
918	print"</table>". NEWLINE;
919
920	print"</div>". NEWLINE;
921
922	print"<br>";
923}
924
925function html_project_manage_reqs_menu() {
926
927	$selected_project_properties 	= session_get_properties("project_manage");
928	$selected_project_id 			= $selected_project_properties['project_id'];
929
930	$manage_pages = array(	'project_manage_reqareacovered_page.php'	=> lang_get('req_area_covered'),
931							'project_manage_reqdoctype_page.php' 		=> lang_get('req_doc_type'),
932							'project_manage_reqfunctionality_page.php'	=> lang_get('req_functionality') );
933
934	print"<div align='center'>". NEWLINE;
935	print"<table class='sub-menu' rules=cols>". NEWLINE;
936	print"<tr><td class='menu'>";
937
938	$str = "";
939
940	foreach($manage_pages as $key => $value) {
941
942		if( stristr($_SERVER['PHP_SELF'], $key)===false ) {
943			$str .= "&nbsp;<a href='$key'>$value</a>&nbsp;|". NEWLINE;
944		} else {
945			$str .= "&nbsp;$value&nbsp;|". NEWLINE;
946		}
947	}
948
949	print substr($str, 0, -2);
950	print"</td></tr>";
951
952	print"</table>". NEWLINE;
953	print"</div>". NEWLINE;
954	print"<br>". NEWLINE;
955}
956
957function html_project_manage_tests_menu() {
958
959	$selected_project_properties 	= session_get_properties("project_manage");
960	$selected_project_id 			= $selected_project_properties['project_id'];
961
962	$manage_pages = array(
963							'project_archive_results_page.php' 			=> lang_get('archive_results'),
964							'project_archive_tests_page.php'	 		=> lang_get('archive_tests'),
965							'project_manage_testareatested_page.php'	=> lang_get('area_tested'),
966							'project_manage_testdoctype_page.php'		=> lang_get('test_doc_type'),
967							'project_manage_testenvironment_page.php' 	=> lang_get('environment'),
968							'project_manage_testmachines_page.php' 		=> lang_get('test_machine'),
969							'project_manage_testtype_page.php' 			=> lang_get('testtype') );
970
971	print"<div align='center'>". NEWLINE;
972	print"<table class='sub-menu' rules=cols>". NEWLINE;
973	print"<tr><td class='menu'>";
974
975	$str = "";
976
977	foreach($manage_pages as $key => $value) {
978
979		if( stristr($_SERVER['PHP_SELF'], $key)===false ) {
980			$str .= "&nbsp;<a href='$key'>$value</a>&nbsp;|". NEWLINE;
981		} else {
982			$str .= "&nbsp;$value&nbsp;|". NEWLINE;
983		}
984	}
985
986	print substr($str, 0, -2);
987	print"</td></tr>";
988
989	print"</table>". NEWLINE;
990
991	print"</div>". NEWLINE;
992	print"<br>". NEWLINE;
993}
994
995function html_project_manage_bugs_menu() {
996
997	$selected_project_properties 	= session_get_properties("project_manage");
998	$selected_project_id 			= $selected_project_properties['project_id'];
999
1000	$manage_pages = array(
1001		'project_manage_bug_category_page.php' => lang_get('bug_category_link'),
1002		'project_manage_bug_component_page.php' => lang_get('bug_component_link') );
1003
1004	print"<div align='center'>". NEWLINE;
1005	print"<table class='sub-menu' rules=cols>". NEWLINE;
1006	print"<tr><td class='menu'>";
1007
1008	$str = "";
1009
1010	foreach($manage_pages as $key => $value) {
1011
1012		if( stristr($_SERVER['PHP_SELF'], $key)===false ) {
1013			$str .= "&nbsp;<a href='$key'>$value</a>&nbsp;|". NEWLINE;
1014		} else {
1015			$str .= "&nbsp;$value&nbsp;|". NEWLINE;
1016		}
1017	}
1018
1019	print substr($str, 0, -2);
1020	print"</td></tr>";
1021
1022	print"</table>". NEWLINE;
1023	print"</div>". NEWLINE;
1024	print"<br>". NEWLINE;
1025}
1026
1027
1028#--------------------------------------------------------------------------------------------------
1029# This function will place focus on a form field if you pass in the form name and obj name
1030# Its best to pass in variables if your using a form.  I think this will work well on most browsers
1031#--------------------------------------------------------------------------------------------------
1032function html_print_body( $form_name=null, $obj_name=null ) {
1033
1034    if( empty($form_name) && empty($obj_name) ) {
1035        print"<body>". NEWLINE;
1036    }
1037    else {
1038        print"<body onload='document.$form_name.$obj_name.focus();'>". NEWLINE;
1039    }
1040}
1041/*
1042# -------------------------------------------------------
1043# This function is intended to make all table headers consistant.
1044# Pass in a page, field, order_by, and $order_dir and the header
1045# will be a hyperlink. Pass only the first parameter and the
1046# function will just list the table header without making it a link.
1047# If javascript param is included, then the javascript is included
1048# in the a tag.
1049# -------------------------------------------------------
1050function html_tbl_print_header(	$header,
1051								$page=null,
1052								$field=null,
1053								$order_by=null,
1054								$order_dir=null,
1055								$javascript=null ) {
1056
1057	if($javascript) {
1058		$javascript = "onClick=\"sortPage('$field');return false\"";
1059	}
1060
1061	switch( $order_dir ) {
1062		case( $field != $order_by ):
1063			$image="";
1064			break;
1065		case( $order_dir=="ASC" ):
1066			$image = "&nbsp;<img src='". IMG_SRC ."down.gif' border=0 alt='Ascending'>";
1067			break;
1068		case( $order_dir=="DESC" ):
1069			$image = "&nbsp;<img src='". IMG_SRC ."up.gif' border=0 alt='Descending'>";
1070			break;
1071		default:
1072			$image="";
1073	}
1074
1075	if( $field !== null ) {
1076
1077		print"<th nowrap><a $javascript href=\"$page?order_by=$field&amp;tbl_header=true\">$header$image</a></th>";
1078	} else {
1079
1080		print"<th nowrap>$header</th>";
1081	}
1082}
1083*/
1084function html_tbl_print_header_not_sortable( $header,
1085											 $field=null,
1086											 $order_by=null,
1087											 $order_dir=null,
1088											 $page=null ) {
1089	switch( $order_dir ) {
1090		case( $field != $order_by ):
1091			$image="";
1092			break;
1093		case( $order_dir=="ASC" ):
1094			$image = "&nbsp;<img src='images/down.gif' border=0 alt='Ascending'>";
1095			$new_order_dir = "DESC";
1096			break;
1097		case( $order_dir=="DESC" ):
1098			$image = "&nbsp;<img src='images/up.gif' border=0 alt='Descending'>";
1099			$new_order_dir = "ASC";
1100			break;
1101		default:
1102			$image="";
1103	}
1104
1105
1106	if( $field !== null ) {
1107
1108		print"<th class='unsortable' nowrap>". NEWLINE;
1109
1110		if( !is_null($page) ) {
1111			print"<form method=post action='$page'>". NEWLINE;
1112			print"<input type=hidden name='table_header' value='true'>". NEWLINE;
1113		}
1114		print"<input type=hidden name='order_dir' value='$order_dir'>". NEWLINE;
1115		print"<input type=hidden name='$header' value='$field'>". NEWLINE;
1116		print"<input type=submit name='change_order_by'  value='$header' class='sort-header'>$image". NEWLINE;
1117
1118		if( !is_null($page) ) {
1119			print"</form>". NEWLINE;
1120		}
1121		print"</th>". NEWLINE;
1122	} else {
1123
1124		print"<th class='unsortable' nowrap>$header</th>". NEWLINE;
1125	}
1126}
1127
1128function html_tbl_print_header(	$header,
1129								$field=null,
1130								$order_by=null,
1131								$order_dir=null,
1132								$page=null ) {
1133
1134	switch( $order_dir ) {
1135		case( $field != $order_by ):
1136			$image="";
1137			break;
1138		case( $order_dir=="ASC" ):
1139			$image = "&nbsp;<img src='images/down.gif' border=0 alt='Ascending'>";
1140			$new_order_dir = "DESC";
1141			break;
1142		case( $order_dir=="DESC" ):
1143			$image = "&nbsp;<img src='images/up.gif' border=0 alt='Descending'>";
1144			$new_order_dir = "ASC";
1145			break;
1146		default:
1147			$image="";
1148	}
1149
1150
1151	if( $field !== null ) {
1152
1153		print"<th nowrap>". NEWLINE;
1154
1155		if( !is_null($page) ) {
1156			print"<form method=post action='$page'>". NEWLINE;
1157			print"<input type=hidden name='table_header' value='true'>". NEWLINE;
1158		}
1159		print"<input type=hidden name='order_dir' value='$order_dir'>". NEWLINE;
1160		print"<input type=hidden name='$header' value='$field'>". NEWLINE;
1161		print"<input type=submit name='change_order_by'  value='$header' class='sort-header'>$image". NEWLINE;
1162
1163		if( !is_null($page) ) {
1164			print"</form>". NEWLINE;
1165		}
1166		print"</th>". NEWLINE;
1167	} else {
1168
1169		print"<th nowrap>$header</th>". NEWLINE;
1170	}
1171
1172}
1173function html_tbl_print_sortable_header($header,
1174								$tbl_column=null,
1175								$order_by=null,
1176								$order_dir=null,
1177								$page=null,
1178								$field=null ) {
1179
1180
1181	$new_order_dir="ASC";
1182	if( $tbl_column != $order_by ){
1183		$image= "&nbsp;<img src='images/arrow_none.gif' border=0 alt='no order'>";
1184	}
1185	else if( $order_dir=="ASC" ){
1186		$image = "&nbsp;<img src='images/arrow_up.gif' border=0 alt='Ascending'>";
1187		$new_order_dir = "DESC";
1188	}
1189	else if( $order_dir=="DESC" ){
1190		$image = "&nbsp;<img src='images/arrow_down.gif' border=0 alt='Descending'>";
1191		$new_order_dir = "ASC";
1192	}
1193	else {
1194		$image= "&nbsp;<img src='images/arrow_none.gif' border=0 alt='no order'>";
1195	}
1196
1197	if($tbl_column!==null){
1198		print'<th><a href="javascript:setFieldsAndSubmit(\''.$tbl_column.'\',\''.$new_order_dir.'\')">'.$header.'</a>'. $image.'</th>'. NEWLINE;
1199	} else{
1200		print"<th nowrap>$header</th>". NEWLINE;
1201	}
1202
1203
1204}
1205
1206
1207function html_tbl_change_order_dir( $direction ) {
1208
1209    if( $direction == 'ASC' ) {
1210        $direction = 'DESC';
1211    } elseif( $direction == 'DESC' ) {
1212        $direction = 'ASC';
1213    }
1214    print"direction in change_order_direction function = $direction<br>";
1215    return $direction;
1216}
1217
1218
1219# --------------------------------------------------------------------------
1220# Display alernating row colors for html tables.
1221# COMMENTS:
1222# This function will set the row style if it's not already set and then alternate the row style.
1223# The background colors are defined in properties_inc.php as constants
1224# USAGE:
1225#   $row_style = html_tbl_alternate_bgcolor( $row_style );
1226#   print"<tr class=$row_style>";
1227# ---------------------------------------------------------------------------
1228function html_tbl_alternate_bgcolor( $style ) {
1229
1230    if( empty( $style ) ) {
1231        $style = ROW2_STYLE;
1232    }
1233    else if( $style == ROW2_STYLE ) {
1234        $style = ROW1_STYLE;
1235    }
1236    else {
1237        $style = ROW2_STYLE;
1238    }
1239    return $style;
1240}
1241
1242# ------------------------------------------------------------------------------------
1243# DISPLAY THE PROPER ICON THAT IDENTIFIES A TEST AS MANUAL AUTOMATED OR BOTH
1244# ------------------------------------------------------------------------------------
1245function html_print_testtype_icon( $manual, $automated, $load_test="NO" ) {
1246
1247    //print"<td align=center valign=top nowrap>";
1248
1249		$return_str = "";
1250
1251        if( $load_test=="YES" ) {
1252
1253        	$return_str .= "<img src='".IMG_SRC."load_test.gif' title='". lang_get('test_performance') ."' alt=L>";
1254        }
1255
1256		if( $manual == 'YES' && $automated == 'YES' ) {
1257			 $return_str .= "<img src='".IMG_SRC."auto_man.gif' title='". lang_get('man_auto_test') ."' alt='M/A'>";
1258		}
1259        elseif( $manual == 'YES')  {
1260            $return_str .= "<img src='".IMG_SRC."manual.gif' title='". lang_get('manual_test') ."' alt=M>";
1261        }
1262        elseif ($automated == 'YES') {
1263            $return_str .= "<img src='".IMG_SRC."auto.gif' title='". lang_get('automated_test') ."' alt=A>";
1264        }
1265
1266    //print"</td>";
1267
1268    return $return_str;
1269}
1270
1271# ------------------------------------------------------------------------------------
1272# DISPLAY THE PROPER ICON THAT IDENTIFIES A TEST AS PASSED OR FAILED
1273# ------------------------------------------------------------------------------------
1274function html_teststatus_icon( $test_status ) {
1275
1276	if( $test_status == 'Passed' ) {
1277
1278		return"<img src='./images/pass.gif' title=Passed alt=Pass>";
1279	} elseif( $test_status == 'Failed')  {
1280
1281		return"<img src='./images/fail.gif' title=Failed alt=Fail>";
1282	}
1283}
1284
1285# ------------------------------------------------------------------------------------
1286# This function will display the html page footer
1287# COMMENTS:
1288# This will print out the time it takes to load an html page if you turn the DEBUG option
1289# in properties_inc.php = ON.
1290# ------------------------------------------------------------------------------------
1291function html_print_footer() {
1292    global $g_timer;
1293    $admin_email = ADMIN_EMAIL;
1294
1295    print"<br>". NEWLINE;
1296    print"<br>". NEWLINE;
1297    print"<br>". NEWLINE;
1298    print"<hr>". NEWLINE;
1299    print"<table>". NEWLINE;
1300    print"<tr>". NEWLINE;
1301    print"<td class=footer-l>" . WINDOW_TITLE ."</td>". NEWLINE;
1302    print"</tr>". NEWLINE;
1303	print"<tr>". NEWLINE;
1304    print"<td class=footer-l>" . RTH_VERSION ."</td>". NEWLINE;
1305    print"</tr>". NEWLINE;
1306    print"<tr>". NEWLINE;
1307    print"<td class=footer-l>". lang_get('copywrite') . "</td>". NEWLINE;
1308    print"</tr>". NEWLINE;
1309    print"<tr>". NEWLINE;
1310    print"<td class=footer-l>". lang_get('contact_admin') ." <a href='mailto:$admin_email'>". lang_get('rth_admin_email') ."</a></td>". NEWLINE;
1311    print"</tr>". NEWLINE;
1312    print"<tr>". NEWLINE;
1313    print"<td class=footer-l>". lang_get('help_sourceforge') ." <a href='http://sourceforge.net/projects/rth/' target='_blank'>sourceforge.net</a></td>". NEWLINE;
1314    print"</table>". NEWLINE;
1315
1316    if ( ON == DEBUG ) {
1317        $g_timer->print_times();
1318    }
1319
1320    print"</body>". NEWLINE;
1321    print"</html>". NEWLINE;
1322}
1323
1324# -------------------------------------------------------------------------------------
1325# Redirect the user
1326# INPUT:
1327#   The url inluding any query strings
1328#   The delay ( default = 1 second )
1329# -------------------------------------------------------------------------------------
1330function html_redirect($url, $delay=null) {
1331
1332    if( empty( $delay ) ) {
1333        $delay = '1';
1334    }
1335
1336   print"<meta http-equiv='Refresh' content='$delay; URL=$url'>";
1337
1338   exit;
1339}
1340
1341/*
1342# --------------------------------------------------------------------------------------
1343# Populate list box with Manual/Auto values
1344# INPUT
1345#   the selected value (not required)
1346# COMMENTS:
1347# Print the manual automated list box.  I think we should call this list box test type.
1348# Make this test type so that we can account for Load Tests, Unit Tests, etc (Richard's idea)
1349# I've set it up so we can add a value to the language file and add that value here to update
1350# the values in the list box.  Maybe it should be an array of the values in the language file?
1351# Don't know what we'd call the current TestType field
1352# --------------------------------------------------------------------------------------
1353function html_manauto_list_box( $selected=null ) {
1354
1355    $all        = lang_get('all');
1356    $manual     = lang_get('manual');
1357    $automated  = lang_get('automated');
1358    $man_auto   = lang_get('man_auto');
1359
1360    # Might need to make the value = the db name
1361
1362    if( $selected != '' ) {
1363        print"<option value=''></option>";
1364    }
1365    if( $selected != $manual ) {
1366        print"<option value='$manual'>$manual</option>";
1367    }
1368    if( $selected != $automated ) {
1369        print"<option value='$automated'>$automated</option>";
1370    }
1371    if( $selected != $man_auto ) {
1372        print"<option value='$man_auto'>$man_auto</option>";
1373    }
1374
1375    print"<option selected value='$selected'>$selected</option>";
1376}
1377*/
1378
1379/*
1380# ----------------------------------------------------------------------------
1381# Query a database and populate a list box with the query result
1382# INPUT:
1383#   database you want to query
1384#   table you want to query
1385#   field you want to query
1386#   the selected value of the html ( not required )
1387# COMMENTS:
1388# Same as html_print_list_box except that this function will not print out
1389# the value "all" in the list box
1390# -----------------------------------------------------------------------------
1391function html_list_box( $database, $table, $field, $selected=null ) {
1392
1393    $q = "SELECT DISTINCT $field FROM $table WHERE $field != ''";
1394
1395
1396    //print"$q<br>";
1397
1398    # ALTER WHERE CLAUSE TO ELIMINATE DUPLICATE ENTRIES IN THE LIST BOX
1399    if( $selected == '' ) {
1400        $q_clause =  " ORDER BY $field";
1401    }
1402    else {
1403        $q_clause =  " AND $field != '$selected' ORDER BY $field";
1404    }
1405
1406    # RUN QUERY
1407    $q = $q . $q_clause;
1408    $rs = db_query( $database, $q );
1409    $num = db_num_rows( $database, $rs );
1410    //$row = array();
1411
1412    if( $num > 0 ) {
1413
1414        $row = db_fetch_array( $database, $num, $rs );
1415
1416        for($i=0; $i < sizeof( $row ); $i++) {
1417
1418            extract( $row[$i], EXTR_PREFIX_ALL, 'v' );
1419
1420            $val = ${'v_' . $field};
1421
1422            if( $val != '' ) {
1423                print"<option value='$val'>$val</option>";
1424            }
1425        }
1426
1427        print"<option selected value='$selected'>$selected</option>";
1428
1429    }
1430    else {  # DISPLAY NOTHING IF THERE IS NOTHING IN THE DB
1431        print"<td class=center>&nbsp</td>";
1432    }
1433}
1434*/
1435
1436# ----------------------------------------------------------------------------
1437# Query a database and populate a list box with the query result (include "all" as a value)
1438# INPUT:
1439#   database you want to query
1440#   table you want to query
1441#   field you want to query
1442#   the selected value of the html ( not required )
1443# COMMENTS:
1444# The function will eliminate duplicate entries from the list box and ignore blanks
1445# We may want to add a second field input which is optional $field2=null so that
1446# we could query for an id and name field using id as the option value
1447# and name as the display option.  It is the function used to populate list boxes
1448# when filtering a table
1449# -----------------------------------------------------------------------------
1450function html_print_list_box( $database, $table, $field, $project_id, $selected=null ) {
1451
1452	$db_project_id = PROJECT_ID;
1453    $q = "SELECT DISTINCT $field FROM $table WHERE $db_project_id = '$project_id' AND $field != ''";
1454
1455    //print"$q<br>";
1456
1457    # ALTER WHERE CLAUSE TO ELIMINATE DUPLICATE ENTRIES IN THE LIST BOX
1458    if( $selected == '' || $selected == 'all' ) {
1459        $q_clause =  " ORDER BY $field";
1460    }
1461    else {
1462        $q_clause =  " AND $field != '$selected' ORDER BY $field";
1463    }
1464
1465    # RUN QUERY
1466    $q = $q . $q_clause;
1467    $rs = db_query( $database, $q );
1468	$num = db_num_rows( $database, $rs );
1469    //$row = array();
1470
1471    if( $num > 0 ) {
1472
1473        if( $selected != 'all' ) {
1474            print"<option value=all>". lang_get('all') ."</option>";
1475        }
1476
1477        $row = db_fetch_array( $database, $rs );
1478
1479        for($i=0; $i < sizeof( $row ); $i++) {
1480
1481            extract( $row[$i], EXTR_PREFIX_ALL, 'v' );
1482
1483            $val = ${'v_' . $field};
1484
1485            if( $val != '' ) {
1486                print"<option value='$val'>$val</option>";
1487            }
1488        }
1489
1490        print"<option selected value='$selected'>$selected</option>";
1491
1492    }
1493    else {  # DISPLAY NOTHING IF THERE ARE NO BA_OWNERS
1494        print"<td class=center>&nbsp</td>";
1495    }
1496}
1497
1498
1499/*
1500# ----------------------------------------------------------------------------
1501# This function will query a db, add a where clause to the query and print the result set in a list box
1502# INPUT:
1503#   database you want to query
1504#   table you want to query
1505#   field you want to query
1506#   the where condition ( a field name ) such as WHERE table_id = ''
1507#   where_value - the value after the = in the where clause
1508#   the selected value of the html ( not required )
1509# COMMENTS:
1510# The function will eliminate duplicate entries from the list box and ignore blanks
1511# We may want to add a second field input which is optional $field2=null so that
1512# we could query for an id and name field using id as the option value
1513# and name as the display option.
1514# -----------------------------------------------------------------------------
1515function html_print_list_box_with_where( $database, $table, $field, $where_condition, $where_value, $selected=null ) {
1516
1517    $q = "SELECT DISTINCT $field FROM $table WHERE $where_condition = $where_value AND $field != ''";
1518    print"$q<br>";
1519
1520    # ALTER WHERE CLAUSE TO ELIMINATE DUPLICATE ENTRIES IN THE LIST BOX
1521    if( $selected == '' || $selected == 'all' ) {
1522        $q_clause =  " ORDER BY $field";
1523    }
1524    else {
1525        $q_clause =  " AND $field != '$selected' ORDER BY $field";
1526    }
1527
1528    # RUN QUERY
1529    $q = $q . $q_clause;
1530    $rs = db_query( $database, $q );
1531    $num = db_num_rows( $database, $rs );
1532    //$row = array();
1533
1534    if( $num > 0 ) {
1535
1536        if( $selected != 'all' ) {
1537            print"<option value=all>". lang_get('all') ."</option>";
1538        }
1539
1540        $row = db_fetch_array( $database, $num, $rs );
1541
1542        for($i=0; $i < sizeof( $row ); $i++) {
1543
1544            extract( $row[$i], EXTR_PREFIX_ALL, 'v' );
1545
1546            $val = ${'v_' . $field};
1547
1548            if( $val != '' ) {
1549                print"<option value='$val'>$val</option>";
1550            }
1551        }
1552
1553        print"<option selected value='$selected'>$selected</option>";
1554
1555    }
1556    else {  # DISPLAY NOTHING IF THERE ARE NO BA_OWNERS
1557        print"<td class=center>&nbsp</td>";
1558    }
1559}
1560*/
1561/*
1562# ----------------------------------------------------------------------
1563# This function will query a db, join two tables and print the result set in a list box
1564# INPUT:
1565#   $db - database you want to query
1566#   $table1 - table you want to select from (combined with field to fetch the values)
1567#   $table2 - table you want to join
1568#   $field  - value you want to return in the list box
1569#   $join_field - field to join in the ON portion of the query ( this field is combined with table1 and table2 to create ON clause)
1570#   $where_table -
1571#   $where_field - These two values are joined to create the where condition
1572#   $selected - The selected value
1573#   $all - when set to true, all is added to list box
1574# -------------------------------------------------------------------------
1575function html_print_list_box_with_join( $database, $table1, $table2, $field, $join_field, $where_table, $where_field, $where_value, $project_id, $selected=null, $all=null ) {
1576
1577
1578	$db_project_id	= PROJECT_ID;
1579    $f1 = $table1 .".". $field;
1580    $join1 = $table1 .".". $join_field;
1581    $join2 = $table2 .".". $join_field;
1582    $where_field = $where_table .".". $where_field;
1583
1584    $q = "SELECT DISTINCT $f1 FROM $table1 INNER JOIN $table2 ON $join1 = $join2 WHERE $where_field = '$where_value' AND $f1 != ''";
1585    print"$q<br>";
1586
1587    # ALTER WHERE CLAUSE TO ELIMINATE DUPLICATE ENTRIES IN THE LIST BOX
1588    if( $selected == '' || $selected == 'all' ) {
1589        $q_clause =  " ORDER BY $field";
1590    }
1591    else {
1592        $q_clause =  " AND $field != '$selected' ORDER BY $field";
1593    }
1594
1595    # RUN QUERY
1596    $q = $q . $q_clause;
1597    $rs = db_query( $database, $q );
1598    $num = db_num_rows( $database, $rs );
1599    //$row = array();
1600    if( $num > 0 ) {
1601
1602        if( $selected != 'all' && $all=='all' ) {
1603            print"<option value=all>". lang_get('all') ."</option>";
1604        }
1605
1606        $row = db_fetch_array( $database, $num, $rs );
1607
1608        for($i=0; $i < sizeof( $row ); $i++) {
1609
1610            extract( $row[$i], EXTR_PREFIX_ALL, 'v' );
1611
1612            $val = ${'v_' . $field};
1613
1614            if( $val != '' ) {
1615                print"<option value='$val'>$val</option>";
1616            }
1617        }
1618
1619        print"<option selected value='$selected'>$selected</option>";
1620
1621    }
1622    else {  # DISPLAY NOTHING IF THERE ARE NO BA_OWNERS
1623        print"<td class=center>&nbsp</td>";
1624    }
1625}
1626*/
1627
1628# ----------------------------------------------------------------------
1629# Print option items using an indexed array.
1630# INPUT:
1631#   $array_options - The <option> items
1632#		e.g. array("Iggy Pop", "Taylor Holbrook")
1633#   $selected - The selected value(s)
1634# 		e.g. 1) 'Iggy Pop'
1635#		e.g. 2) array('Iggy Pop', 'Taylor Holbrook')
1636#
1637# OUTPUT:
1638#	e.g. 1)
1639#	<option value='Albert Einstein' selected>Albert Einstein</option>
1640#	<option value='Albert Einstein'>Taylor Holbrook</option>
1641#
1642# NOTE: If this function does not do what you want it to, look at
1643# html_print_list_box_from_key_array
1644# ----------------------------------------------------------------------
1645function html_print_list_box_from_array( $array_options, $selected='' ) {
1646
1647	foreach($array_options as $option) {
1648
1649		# if selected is an array of values
1650	    if( is_array($selected) ) {
1651			# find out if this option is a selected value
1652			if ( util_array_value_search($option, $selected) ) {
1653				$selected_html = "selected";
1654			} else {
1655				$selected_html = "";
1656			}
1657
1658		# if selected is a single value
1659	    } else {
1660	    	# find out if this option is a selected value
1661			if ($option == $selected) {
1662				$selected_html = "selected";
1663			} else {
1664				$selected_html = "";
1665			}
1666		}
1667
1668		print"<option value='$option' $selected_html>$option</option>". NEWLINE;
1669    }
1670}
1671
1672# ----------------------------------------------------------------------
1673# Print option items using an associative array.
1674# INPUT:
1675#   $array_options - The <option> items
1676#		e.g. array("aeinstein@liberty.com"=>"Albert Einstein", "tholbrook@liberty.com"=>"Taylor Holbrook")
1677#   $selected - The selected value(s)
1678# 		e.g. 1) 'aeinstein@liberty.com'
1679#		e.g. 2) array('aeinstein@liberty.com', 'tholbrook@liberty.com')
1680#
1681# OUTPUT:
1682#	e.g. 1)
1683#	<option value='aeinstein@liberty.com' selected>Albert Einstein</option>
1684#	<option value='tholbrook@liberty.com'>Taylor Holbrook</option>
1685#
1686# NOTE: If this function does not do what you want it to, look at
1687# html_print_list_box_from_array
1688# ----------------------------------------------------------------------
1689function html_print_list_box_from_key_array( $array_options, $selected=null ) {
1690
1691	foreach($array_options as $option_value => $option_text) {
1692
1693		# if selected is an array of values
1694		if( is_array($selected) ) {
1695
1696			# find out if this option is a selected value
1697			if ( util_array_value_search($option_value, $selected) ) {
1698				$selected_html = "selected";
1699			}
1700			else {
1701				$selected_html = "";
1702			}
1703
1704		# if selected is a single value
1705	    } else {
1706			# find out if this option is a selected value
1707			if( $option_value == $selected ) {
1708				$selected_html = "selected";
1709			} else {
1710				$selected_html = "";
1711			}
1712		}
1713
1714		print"<option value='$option_value' $selected_html>$option_text</option>". NEWLINE;
1715
1716    }
1717}
1718
1719# ----------------------------------------------------------------------------
1720# Prints the user rights options for a form select.
1721# ----------------------------------------------------------------------------
1722function html_print_user_rights_list_box( $selected="" ) {
1723
1724	$user_rights_list_box 		= array( 	USER=>lang_get('user'),
1725											DEVELOPER=>lang_get('developer'),
1726											MANAGER=>lang_get('manager') );
1727
1728	html_print_list_box_from_key_array(	$user_rights_list_box,
1729										$selected );
1730}
1731
1732# ----------------------------------------------------------------------------
1733# Prints the table offset details including "showing records x - y", csv_url
1734# and "first, prev, 1 2 ... next last"
1735# If use_javascript is set then, the function is added to the onClick event of
1736# the a tags.
1737# ----------------------------------------------------------------------------
1738function html_table_offset( $row_count, $per_page, $page_number, $order_by=null, $order_dir=null, $csv_url=null ) {
1739
1740	# First page number
1741	$page_one = 1;
1742
1743	# Make sure page count is at least 1
1744	$page_count = ceil($row_count / $per_page );
1745	if( $page_count < 1 ) {
1746		$page_count = 1;
1747	}
1748
1749	# Set page_num = 1 in case the user hasn't yet chosen a page number
1750	if( empty($page_number) ) {
1751		$page_number = 1;
1752	}
1753
1754	# Make sure page_number isn't past the last page.
1755	if( $page_number > $page_count ) {
1756		$page_number = $page_count;
1757	}
1758
1759	# offset = (page number - 1) * records per page
1760	# if page number = 1, offset = 0, returning record 0 through 25 (page)
1761	# if page number = 2, offset = 25
1762	# if page number = 3, offset = 50
1763	$offset = ( ($page_number - 1) * $per_page );
1764
1765	# Show the number of records displayed and the total number of records
1766	if( $row_count == '0' ) {
1767		return;
1768
1769	} else {
1770		$lower_count = $offset + 1;
1771	}
1772
1773	# upper count is the last record displayed on the page
1774	$upper_count = $offset + $per_page;
1775	$upper_count = ($upper_count > $row_count) ? $row_count : $upper_count;
1776
1777	$page_numbers_array			= array();
1778	$number_page_links_shown	= 10;
1779
1780	# Calculate first and last pages
1781	$first_page_link_shown	= max( $page_one, $page_number - $number_page_links_shown/2 );
1782	$first_page_link_shown	= min( $first_page_link_shown, $page_count - $number_page_links_shown );
1783	$first_page_link_shown	= max( $first_page_link_shown, $page_one );
1784	$last_page_link_shown	= $first_page_link_shown + $number_page_links_shown;
1785	$last_page_link_shown	= min( $last_page_link_shown, $page_count );
1786
1787	# Page numbers array
1788	for ( $i = $first_page_link_shown ; $i <= $last_page_link_shown ; $i++ ) {
1789		if ( $i == $page_number ) {
1790			array_push( $page_numbers_array, "<input type=submit name=page_number value=$i disabled class='page-numbers-disabled'>" );
1791		} else {
1792			array_push( $page_numbers_array, "<input type=submit name=page_number value=$i class='page-numbers'>" );
1793		}
1794	}
1795
1796	print"<input name='order_dir' id='order_dir' type=hidden value='$order_dir' >". NEWLINE;
1797	print"<input name='order_by' id='order_by' type=hidden value='$order_by' >". NEWLINE;
1798
1799	print"<input type=hidden name=first_page_number    value=1>". NEWLINE;
1800	print"<input type=hidden name=previous_page_number value=".($page_number-1).">". NEWLINE;
1801	print"<input type=hidden name=next_page_number     value=".($page_number+1).">". NEWLINE;
1802	print"<input type=hidden name=last_page_number     value=$page_count>". NEWLINE;
1803	print"<input type=hidden name=page_number          value=$page_number>". NEWLINE;
1804
1805	print"<table class=hide100>". NEWLINE;
1806	print"<tr>". NEWLINE;
1807
1808	# Showing x - y of z
1809	print"<td class='left'>". NEWLINE;
1810	print"Showing $lower_count - $upper_count of $row_count". NEWLINE;
1811	print"</td>". NEWLINE;
1812
1813	# CVS Export Link
1814	if( !is_null($csv_url) ) {
1815		echo"<td align='center'>". NEWLINE;
1816		echo"<a href='csv_export.php?table=$csv_url'>";
1817		if( IMPORT_EXPORT_TO_EXCEL ) {
1818			print lang_get('excel_export');
1819		}
1820		else {
1821			print lang_get('csv_export');
1822		}
1823		print"</a>". NEWLINE;
1824		echo"</td>". NEWLINE;
1825	}
1826
1827	print"<td class='right'>". NEWLINE;
1828	echo"[". NEWLINE;
1829
1830	# First and previous links
1831	if ( 1 < $page_number ) {
1832		$disabled = "class='page-numbers'";
1833	} else {
1834		$disabled = "disabled class='page-numbers-disabled'";
1835	}
1836	echo"<input type=submit name=page_number value='".lang_get('first')."' $disabled >". NEWLINE;
1837	echo"<input type=submit name=page_number value='".lang_get('previous')."' $disabled >". NEWLINE;
1838
1839	# ...
1840	if ( $first_page_link_shown > 1 ) {
1841		echo( " ... " );
1842	}
1843
1844	# Print page numbers
1845	echo "".implode( "\n", $page_numbers_array )."". NEWLINE;
1846
1847	# ...
1848	if ( $last_page_link_shown < $page_count ) {
1849		echo( " ... " );
1850	}
1851
1852	# Next and last links
1853	if ( $page_number < $page_count ) {
1854		$disabled = "class='page-numbers'";
1855	} else {
1856		$disabled = "disabled class='page-numbers-disabled'";
1857	}
1858	echo"<input type=submit name=page_number value='".lang_get('next')."' $disabled>". NEWLINE;
1859	echo"<input type=submit name=page_number value='".lang_get('last')."' $disabled>". NEWLINE;
1860
1861	echo"]". NEWLINE;
1862
1863	echo"</td>". NEWLINE;
1864	echo"</tr>". NEWLINE;
1865	echo"</table>". NEWLINE;
1866}
1867
1868# ------------------------------------------------------------------------------------
1869# Prints html for displaying file type icon
1870# ------------------------------------------------------------------------------------
1871function html_file_type( $file_name ) {
1872
1873    $file_type = util_get_filetype( $file_name );
1874
1875    switch($file_type)
1876    {
1877        case 'xls':
1878            return"<IMG SRC='". ICON_SRC . "/xls.jpg' alt='xls' title='microsoft excel document'>";
1879            break;
1880		case 'csv':
1881            return"<IMG SRC='". ICON_SRC . "/xls.jpg' alt='xls' title='microsoft excel document'>";
1882            break;
1883        case 'doc':
1884            return"<IMG SRC='". ICON_SRC . "/doc.jpg' alt='doc' title='microsoft word document'>";
1885            break;
1886        case 'txt':
1887            return"<IMG SRC='". ICON_SRC . "/file.gif' alt='txt' title='plain text file'>";
1888            break;
1889        case 'rtf':
1890            return"<IMG SRC='". ICON_SRC . "/doc.jpg' alt='rtf' title='rich text document'>";
1891            break;
1892        case 'pdf':
1893            return"<IMG SRC='". ICON_SRC . "/pdf.jpg' alt='pdf' title='pdf'>";
1894            break;
1895        case 'html':
1896            return"<IMG SRC='". ICON_SRC . "/html.jpg' alt='html' title='html document'>";
1897            break;
1898        case 'htm':
1899            return"<IMG SRC='". ICON_SRC . "/htm.jpg' alt='html' title='html document'>";
1900            break;
1901        case 'jpg':
1902            return"<IMG SRC='". ICON_SRC . "/jpg.jpg' alt='jpg' title='jpg image'>";
1903            break;
1904        case 'gif':
1905            return"<IMG SRC='". ICON_SRC . "/gif.jpg' alt='gif' title='gif image'>";
1906            break;
1907        default:
1908            return"&nbsp;";
1909    }
1910}
1911
1912# ------------------------------------------------------------------------------------
1913# Returns html for displaying info icon
1914# ------------------------------------------------------------------------------------
1915function html_info_icon( $text ) {
1916
1917	if( $text ) {
1918		return "<img src='images/info.gif' title=\"$text\" alt='Info'>";
1919	} else {
1920		return "&nbsp;". NEWLINE;
1921	}
1922}
1923
1924# ------------------------------------------------------------------------------------
1925# Prints the html for the no records found message
1926# ------------------------------------------------------------------------------------
1927function  html_no_records_found_message( $message ) {
1928
1929	print"<div class=center>". NEWLINE;
1930	print"<table class=hide100>". NEWLINE;
1931	print"<tr>". NEWLINE;
1932	print"<td>$message</td>". NEWLINE;
1933	print"</tr>". NEWLINE;
1934	print"</table>". NEWLINE;
1935	print"</div>". NEWLINE;
1936
1937}
1938
1939#------------------------------------------------------------------------------------------
1940# Prints all html including <html>, <head> and <body> tags, with an operation successful
1941# message in the body.
1942#
1943# INPUT:
1944# 	page title
1945#	redirect page
1946# OUTPUT:
1947# 	Entire html page with redirect
1948#------------------------------------------------------------------------------------------
1949function html_print_operation_successful( $page_title, $redirect_page ) {
1950
1951	global $db;
1952
1953
1954	$s_project_properties = session_get_project_properties();
1955	$project_name = $s_project_properties['project_name'];
1956
1957	html_window_title();
1958	html_print_body();
1959	html_page_title($project_name ." - ". lang_get($page_title) );
1960	html_page_header( $db, $project_name );
1961	html_print_menu();
1962	print"<div class=operation-successful>".lang_get('operation_successful')."</div>";
1963	html_print_footer();
1964	html_redirect($redirect_page);
1965	exit;
1966}
1967
1968#------------------------------------------------------------------------------------------
1969# Prints a road map of where the user is in relation to other release pages.
1970# The function will loop through an array, format and print out the keys in the same order.
1971#
1972# A case can be provided in the switch statement to custom format certain keys, i.e. adding
1973# a hyperlink to a key.
1974#
1975# INPUT:
1976# 	Array of keys
1977# OUTPUT:
1978#	Formatted html roadmap map of where the current pageis in relation to other pages.
1979#------------------------------------------------------------------------------------------
1980function html_release_map( $map ) {
1981	$release_properties = session_get_properties("release");
1982
1983	$html_top_row 		= "<tr>". NEWLINE;
1984	$html_bottom_row 	= "<tr>". NEWLINE;
1985
1986	foreach($map as $key) {
1987		switch($key) {
1988		case "release_link":
1989			$release_name = admin_get_release_name($release_properties['release_id']);
1990
1991			$html_top_row .= "<td class='sub_menu' nowrap>";
1992			$html_top_row .= "<b><a href=release_page.php>". lang_get( 'release_name' ) ."</a></b>";
1993			$html_top_row .= "</td>". NEWLINE;
1994
1995			$html_bottom_row .= "<td class='sub_menu' nowrap>";
1996			$html_bottom_row .= "$release_name";
1997			$html_bottom_row .= "</td>". NEWLINE;
1998			break;
1999		case "build_link":
2000			$build_name = admin_get_build_name($release_properties['build_id']);
2001
2002			$html_top_row .= "<td class='sub_menu' nowrap>";
2003			$html_top_row .= "<b><a href=build_page.php>". lang_get( 'build_name' ) ."</a></b>";
2004			$html_top_row .= "</td>". NEWLINE;
2005
2006			$html_bottom_row .= "<td class='sub_menu' nowrap>";
2007			$html_bottom_row .= "$build_name";
2008			$html_bottom_row .= "</td>". NEWLINE;
2009			break;
2010		case "testset_link":
2011			$testset_name = admin_get_testset_name($release_properties['testset_id']);
2012
2013			$html_top_row .= "<td class='sub_menu' nowrap>";
2014			$html_top_row .= "<b><a href=testset_page.php>". lang_get( 'testset_name' ) ."</a></b>";
2015			$html_top_row .= "</td>". NEWLINE;
2016
2017			$html_bottom_row .= "<td class='sub_menu' nowrap>";
2018			$html_bottom_row .= "$testset_name";
2019			$html_bottom_row .= "</td>". NEWLINE;
2020			break;
2021		case "copy_testset_link":
2022			$testset_name = admin_get_testset_name($release_properties['testset_id']);
2023
2024			$html_top_row .= "<td class='sub_menu' rowspan=2 nowrap>";
2025			$html_top_row .= "<b><a href=testset_page.php>". lang_get( 'copy_testset_to' ) ."</a></b>";
2026			$html_top_row .= "</td>". NEWLINE;
2027
2028			$html_bottom_row .= "<td></td>". NEWLINE;
2029
2030			break;
2031		default:
2032
2033			$html_top_row .= "<td class='sub_menu' nowrap><b>$key</b></td>". NEWLINE;
2034
2035			$html_bottom_row .= "<td></td>". NEWLINE;
2036
2037		}
2038
2039		$html_top_row .= "<td class='sub_menu' rowspan=2 nowrap>&nbsp;</td>". NEWLINE;
2040	}
2041
2042	$html_top_row 		.= "</tr>". NEWLINE;
2043	$html_bottom_row 	.= "</tr>". NEWLINE;
2044
2045	print"<table width=1 cellspacing=2>". NEWLINE;
2046	print$html_top_row;
2047	print$html_bottom_row;
2048	print"</table>". NEWLINE;
2049}
2050
2051/*
2052
2053function html_release_map( $map ) {
2054	$release_properties = session_get_properties("release");
2055
2056	$html = "<table>". NEWLINE;
2057	$html .= "<tr>". NEWLINE;
2058	$html .= "<td>". NEWLINE;
2059
2060	foreach($map as $key) {
2061		switch($key) {
2062		case "release_link":
2063			$release_name = admin_get_release_name($release_properties['release_id']);
2064
2065			$html .= "<table align=left>". NEWLINE;
2066			$html .= "<tr>". NEWLINE;
2067			$html .= "<td class='sub_menu' nowrap>". NEWLINE;
2068			$html .= "<b><a href=release_page.php>". lang_get( 'release_name' ) ."</a></b>". NEWLINE;
2069			$html .= "</td>". NEWLINE;
2070			$html .= "</tr>". NEWLINE;
2071			$html .= "<tr>". NEWLINE;
2072			$html .= "<td class='sub_menu' nowrap>". NEWLINE;
2073			$html .= "$release_name". NEWLINE;
2074			$html .= "</td>". NEWLINE;
2075			$html .= "</tr>". NEWLINE;
2076			$html .= "</table>". NEWLINE;
2077			break;
2078		case "build_link":
2079			$build_name = admin_get_build_name($release_properties['build_id']);
2080
2081			$html .= "<table align=left>". NEWLINE;
2082			$html .= "<tr>". NEWLINE;
2083			$html .= "<td class='sub_menu' nowrap>". NEWLINE;
2084			$html .= "<b><a href=build_page.php>". lang_get( 'build_name' ) ."</a></b>". NEWLINE;
2085			$html .= "</td>". NEWLINE;
2086			$html .= "</tr>". NEWLINE;
2087			$html .= "<tr>". NEWLINE;
2088			$html .= "<td class='sub_menu' nowrap>". NEWLINE;
2089			$html .= "$build_name". NEWLINE;
2090			$html .= "</td>". NEWLINE;
2091			$html .= "</tr>". NEWLINE;
2092			$html .= "</table>". NEWLINE;
2093			break;
2094		case "testset_link":
2095			$testset_name = admin_get_testset_name($release_properties['testset_id']);
2096
2097			$html .= "<table align=left>". NEWLINE;
2098			$html .= "<tr>". NEWLINE;
2099			$html .= "<td class='sub_menu' nowrap>". NEWLINE;
2100			$html .= "<b><a href=testset_page.php>". lang_get( 'testset_name' ) ."</a></b>". NEWLINE;
2101			$html .= "</td>". NEWLINE;
2102			$html .= "</tr>". NEWLINE;
2103			$html .= "<tr>". NEWLINE;
2104			$html .= "<td class='sub_menu' nowrap>". NEWLINE;
2105			$html .= "$testset_name". NEWLINE;
2106			$html .= "</td>". NEWLINE;
2107			$html .= "</tr>". NEWLINE;
2108			$html .= "</table>". NEWLINE;
2109			break;
2110		case "copy_testset_link":
2111			$testset_name = admin_get_testset_name($release_properties['testset_id']);
2112
2113			$html .= "<table align=left>". NEWLINE;
2114			$html .= "<tr>". NEWLINE;
2115			$html .= "<td class='sub_menu' rowspan=2 nowrap>". NEWLINE;
2116			$html .= "<b><a href=testset_page.php>". lang_get( 'copy_testset_to' ) ."</a></b>". NEWLINE;
2117			$html .= "</td>". NEWLINE;
2118			$html .= "</tr>". NEWLINE;
2119			$html .= "</table>". NEWLINE;
2120			break;
2121		default:
2122			$html .= "<table align=left>". NEWLINE;
2123			$html .= "<tr>". NEWLINE;
2124			$html .= "<td class='sub_menu' nowrap><b>$key</b></td>". NEWLINE;
2125			$html .= "</tr>". NEWLINE;
2126			$html .= "</table>". NEWLINE;
2127		}
2128	}
2129
2130	$html .= "</td>". NEWLINE;
2131	$html .= "</tr>". NEWLINE;
2132	$html .= "</table>". NEWLINE;
2133
2134	print $html;
2135
2136*/
2137
2138function html_project_manage_map( $map ) {
2139
2140	$release_properties = session_get_properties("project_manage");
2141	$project_manage = session_get_properties('project_manage');
2142
2143	$html = "<table>". NEWLINE;
2144	$html .= "<tr>". NEWLINE;
2145	$html .= "	<td>". NEWLINE;
2146
2147	foreach($map as $key) {
2148
2149		$hyperlink = "";
2150
2151		switch($key) {
2152		case"project_manage_link":
2153			$hyperlink 	= "project_manage_page.php";
2154			$text 		= project_get_name($project_manage['project_id']);
2155			break;
2156		case"area_tested_link":
2157			$hyperlink 	= "project_manage_areatested_page.php";
2158			$text 		= lang_get('area_tested');
2159			break;
2160		case"environment_link":
2161			$hyperlink 	= "project_manage_environment_page.php";
2162			$text 		= lang_get('environment');
2163			break;
2164		case"machine_link":
2165			$hyperlink 	= "project_manage_machines_page.php";
2166			$text 		= lang_get('machine');
2167			break;
2168		case"reqareacovered_link":
2169			$hyperlink 	= "project_manage_reqareacovered_page.php";
2170			$text 		= lang_get('req_area_covered');
2171			break;
2172		case"reqdoctype_link":
2173			$hyperlink 	= "project_manage_reqdoctype_page.php";
2174			$text 		= lang_get('req_doc_type');
2175			break;
2176		case"reqfunctionality_link":
2177			$hyperlink 	= "project_manage_reqfunctionality_page.php";
2178			$text 		= lang_get('req_functionality');
2179			break;
2180		case"testdoctype_link":
2181			$hyperlink 	= "project_manage_testdoctype_page.php";
2182			$text 		= lang_get('test_doc_type');
2183			break;
2184		case"testtype_link":
2185			$hyperlink 	= "project_manage_testtype_page.php";
2186			$text 		= lang_get('testtype');
2187			break;
2188		case"bug_category_link":
2189			$hyperlink 	= "project_manage_bug_category_page.php";
2190			$text 		= lang_get('bug_category');
2191			break;
2192		case"bug_component_link":
2193			$hyperlink 	= "project_manage_bug_component_page.php";
2194			$text 		= lang_get('bug_component');
2195			break;
2196		}
2197
2198		if($hyperlink) {
2199
2200			$html .= "<table align=left>". NEWLINE;
2201			$html .= "<tr>". NEWLINE;
2202			$html .= "<td class='sub_menu' nowrap><b><a href='$hyperlink'>$text</a></b></td>". NEWLINE;
2203			$html .= "</tr>". NEWLINE;
2204			$html .= "</table>". NEWLINE;
2205		} else {
2206
2207			$html .= "<table align=left>". NEWLINE;
2208			$html .= "<tr>". NEWLINE;
2209			$html .= "<td class='sub_menu' nowrap><b>$key</b></td>". NEWLINE;
2210			$html .= "</tr>". NEWLINE;
2211			$html .= "</table>". NEWLINE;
2212		}
2213	}
2214
2215	$html .= "	</td>". NEWLINE;
2216	$html .= "</tr>". NEWLINE;
2217	$html .= "</table>". NEWLINE;
2218
2219	print $html;
2220}
2221
2222function html_print_tabs($tabs, $selected_tab) {
2223
2224	$i = 1;
2225
2226/*
2227	print"<table class=hide100>". NEWLINE;
2228	print"<tr>". NEWLINE;
2229	foreach($tabs as $key => $value) {
2230		if($i!=$selected_tab) {
2231			print"<td><a href='$value'>$key</a></td>". NEWLINE;
2232		} else {
2233			print"<td>$key</td>". NEWLINE;
2234		}
2235		$i++;
2236	}
2237	print"</tr>". NEWLINE;
2238	print"</table>". NEWLINE;
2239*/
2240	foreach($tabs as $key => $value) {
2241		if($i!=$selected_tab) {
2242			print"<a href='$value'>$key</a>";
2243		} else {
2244			print"$key";
2245		}
2246
2247		if($i!=sizeof($tabs)) {
2248			print" | ";
2249		}
2250		$i++;
2251	}
2252}
2253
2254# display's a nice indented tree
2255# $highlighted will BOLD any node with that id
2256function html_tree( $tree_array, $highlighted=null, $column_map=array() ) {
2257
2258	global $db;
2259
2260	# images html
2261	$img_tree_T 		= "<img align='middle' src='".IMG_SRC."tree_dots_T.gif' alt=''>";
2262	$img_tree_L 		= "<img align='middle' src='".IMG_SRC."tree_dots_L.gif' alt=''>";
2263	$img_tree_column 	= "<img align='middle' src='".IMG_SRC."tree_dots_column.gif' alt=''>";
2264	$img_tree_plus 		= "<img align='middle' src='".IMG_SRC."tree_dots_plus.gif' alt=''>";
2265	$img_tree_plus_b 	= "<img align='middle' src='".IMG_SRC."tree_dots_plus_b.gif' alt=''>";
2266	$img_tree_minus 	= "<img align='middle' src='".IMG_SRC."tree_dots_minus.gif' alt=''>";
2267	$img_tree_minus_b 	= "<img align='middle' src='".IMG_SRC."tree_dots_minus_b.gif' alt=''>";
2268
2269	$img_spacer = "<img src='".IMG_SRC."1px_transparent.gif' width=15 height=1 alt=''>";
2270
2271	$column = $img_tree_column.$img_spacer;
2272
2273	# display each child
2274	for( $i=0; $i<sizeof($tree_array); $i++ ) {
2275
2276		//echo"<tr><td valign=bottom>";
2277		echo$img_spacer;
2278
2279		foreach($column_map as $column_type) {
2280
2281			if($column_type=="|") {
2282
2283				echo$column;
2284			} elseif($column_type==" ") {
2285
2286				echo$img_spacer;
2287			}
2288		}
2289
2290		# if the last child record print $table_L
2291		# else print $table_T
2292		if( $i == sizeof($tree_array)-1 ) {
2293
2294			echo $img_tree_L;
2295			$column_type = array(" ");
2296		} else {
2297
2298			echo $img_tree_T;
2299			$column_type = array("|");
2300		}
2301
2302		$style="";
2303
2304		if($tree_array[$i]['req_id']==$highlighted) {
2305
2306			$style="style='font-weight: bold; font-size: 120%;'";
2307		}
2308
2309		echo"<a $style href='requirement_detail_page.php?req_id=".$tree_array[$i]['req_id']."'>".$tree_array[$i]['req_name']."</a>";
2310
2311		echo"<br>". NEWLINE;
2312		//echo"</td></tr>". NEWLINE;
2313
2314		# display this node's children
2315		html_tree( $tree_array[$i]['children'], $highlighted, array_merge($column_map, $column_type) );
2316
2317	}
2318}
2319
2320# display's a dynamic tree with +/- boxes to expand/collapse the nodes
2321#
2322# $session_variable
2323#	name of the session variable used to store the expanded nodes
2324# $tree_array
2325#	the tree data structure
2326# $root_node
2327#	first node from which all others in $tree_array stem from
2328function html_dynamic_tree( $session_variable, $tree_array, $root_node, $highlighted=null, $column_map=array() ) {
2329
2330	# Get the expanded tree array from the session
2331	$s_display_options = session_get_display_options($session_variable);
2332	$expanded = $s_display_options["filter"]["tree"];
2333
2334	# Add expanded node (if there is one)
2335	if( isset($_GET['expand']) ) {
2336
2337		$expanded[] = $_GET['expand'];
2338	}
2339
2340	# Remove collapsed node (if there is one)
2341	if( isset($_GET['collapse']) ) {
2342
2343		$expanded = array_diff( $expanded, array($_GET['collapse']) );
2344	}
2345
2346	# Create variable to update the session
2347	$update_expanded = array("tree"=>$expanded);
2348
2349	# Update the tree variable in the session and get the returned value
2350	$s_display_options = session_set_display_options($session_variable, $update_expanded);
2351	$expanded = $s_display_options["filter"]["tree"];
2352
2353	global $db;
2354
2355	# images html
2356	$img_tree_T			= "<img align='absmiddle' border=0 src='".IMG_SRC."tree_dots_T.gif' alt=''>";
2357	$img_tree_L			= "<img align='absmiddle' border=0 src='".IMG_SRC."tree_dots_L.gif' alt=''>";
2358	$img_tree_column	= "<img align='absmiddle' border=0 src='".IMG_SRC."tree_dots_column.gif' alt=''>";
2359	$img_tree_plus		= "<img align='absmiddle' border=0 src='".IMG_SRC."tree_dots_plus.gif' alt=''>";
2360	$img_tree_plus_b	= "<img align='absmiddle' border=0 src='".IMG_SRC."tree_dots_plus_b.gif' alt=''>";
2361	$img_tree_minus		= "<img align='absmiddle' border=0 src='".IMG_SRC."tree_dots_minus.gif' alt=''>";
2362	$img_tree_minus_b 	= "<img align='absmiddle' border=0 src='".IMG_SRC."tree_dots_minus_b.gif' alt=''>";
2363	$img_tree_folder 	= "<img align='absmiddle' border=0 src='".IMG_SRC."tree_folder.gif' alt=''>";
2364	$img_tree_folder_b 	= "<img align='absmiddle' border=0 src='".IMG_SRC."tree_folder_b.gif' alt=''>";
2365
2366	$img_spacer 		= "<img align='absmiddle' border=0 src='".IMG_SRC."1px_transparent.gif' width=15 height=1 alt=''>";
2367
2368	$column 			= $img_tree_column.$img_spacer;
2369
2370	# display each child node
2371	for( $i=0; $i<sizeof($tree_array); $i++ ) {
2372
2373		$req_id = $tree_array[$i]['uid'];
2374		$req_version_id = requirement_get_latest_version($req_id);
2375
2376		echo$img_spacer;
2377
2378		foreach($column_map as $column_type) {
2379
2380			if($column_type=="|") {
2381
2382				echo$column;
2383			} elseif($column_type==" ") {
2384
2385				echo$img_spacer;
2386			}
2387		}
2388
2389		# if the last node
2390		if( $i == sizeof($tree_array)-1 ) {
2391
2392			# if the last node has no children
2393			if( empty($tree_array[$i]["children"]) ) {
2394
2395				echo $img_tree_L;
2396
2397			# if the last node has children
2398			} else {
2399
2400				# if last node has children and the node is in the expanded array
2401				if( util_array_value_search($req_id, $expanded) ) {
2402
2403					echo"<a href='?collapse=$req_id#$req_id'>".$img_tree_minus_b.$img_tree_folder_b."</a>";
2404
2405				# if last node has children and the node is not in the expanded array
2406				} else {
2407
2408					echo"<a href='?expand=$req_id#$req_id'>".$img_tree_plus_b.$img_tree_folder."</a>";
2409				}
2410			}
2411
2412			$column_type = array(" ");
2413
2414		# if not the last node
2415		} else {
2416
2417			# if not the last node and the node has no children
2418			if( empty($tree_array[$i]["children"]) ) {
2419
2420				echo $img_tree_T;
2421			} else {
2422
2423				# if not the last node and the node is in the expanded array
2424				if( util_array_value_search($req_id, $expanded) ) {
2425
2426					echo"<a href='?collapse=$req_id#$req_id'>".$img_tree_minus.$img_tree_folder_b."</a>";
2427
2428				# if not the last node and the node is not in the expanded array
2429				} else {
2430
2431					echo"<a href='?expand=$req_id#$req_id'>".$img_tree_plus.$img_tree_folder."</a>";
2432				}
2433			}
2434
2435			$column_type = array("|");
2436		}
2437
2438		# prints a closed folder if node has no children and $root_node is set to true
2439		if( empty($tree_array[$i]["children"]) && $root_node ) {
2440
2441			echo$img_tree_folder;
2442		}
2443
2444		# formatting for highlighted node
2445		$style="";
2446
2447		if($req_id==$highlighted) {
2448
2449			$style="style='font-weight: bold; font-size: 120%;'";
2450		}
2451
2452		# print the node name
2453		echo" <a $style name=$req_id href='requirement_detail_page.php?req_id=$req_id&req_version_id=$req_version_id'>".$tree_array[$i]['name']."</a>";
2454
2455		echo"<br>". NEWLINE;
2456
2457		# display this nodes children
2458		if( util_array_value_search($req_id, $expanded) ) {
2459
2460			html_dynamic_tree( $session_variable, $tree_array[$i]['children'], false, $highlighted, array_merge($column_map, $column_type) );
2461		}
2462	}
2463}
2464
2465#------------------------------------------------------------------------------------------
2466# Prints the filter at the top of the requirements page.
2467# INPUT:
2468# 	all the possible values that a user can filter on
2469# OUTPUT:
2470#	The requirements filter form
2471#------------------------------------------------------------------------------------------
2472function html_print_requirements_filter(	$project_id,
2473											$filter_doc_type,
2474											$filter_status,
2475											$filter_area_covered,
2476											$filter_functionality,
2477											$filter_assign_release,
2478											$filter_per_page=null,
2479											$filter_show_versions=null,
2480											$filter_search,
2481											$filter_priority ) {
2482	print"<table class=width100>". NEWLINE;
2483	print"<tr>". NEWLINE;
2484	print"<td>". NEWLINE;
2485		print"<table class=inner rules=none border=0>". NEWLINE;
2486
2487		# TITLES FOR FIRST ROW OF FORM
2488		print"<tr class=left>". NEWLINE;
2489		print"<td class=form-header-c>". lang_get('req_type') ."</td>". NEWLINE;
2490		print"<td class=form-header-c>". lang_get('status') ."</td>". NEWLINE;
2491		print"<td class=form-header-c>". lang_get('req_area') ."</td>". NEWLINE;
2492
2493		# if show versions or per page is displayed
2494		if( !is_null($filter_show_versions) || !is_null($filter_per_page) ) {
2495
2496			print"<td class=form-header-c>". lang_get('show') ."</td>". NEWLINE;
2497		}
2498		else {
2499			print"<td class='form-header-c'></td>". NEWLINE;
2500		}
2501
2502
2503		if( !is_null($filter_show_versions) ) {
2504				# SHOW VERSIONS
2505				print"<td class='left' rowspan=4>". NEWLINE;
2506				print"<input id=all_versions type='radio' name='show_versions' value='all' ".($filter_show_versions=="all"?"checked":"").">";
2507				print"<label for=all_versions>".lang_get("all_versions")."</label><br>". NEWLINE;
2508
2509				print"<input id=latest_version type='radio' name='show_versions' value='latest' ".($filter_show_versions=="latest"?"checked":"").">";
2510				print"<label for=latest_version>".lang_get("latest_version")."</label>". NEWLINE;
2511				print"</td>". NEWLINE;
2512
2513				//print"<td>&nbsp;</td>". NEWLINE;
2514
2515		}
2516
2517		print"<td align='center' rowspan=4><input type='submit' value='Filter'></td>". NEWLINE;
2518
2519		print"</tr>". NEWLINE;
2520
2521		# LIST BOXES FOR FIRST ROW
2522		print"<tr>". NEWLINE;
2523
2524		# DOC TYPE
2525		print"<td align='center'>". NEWLINE;
2526		print"<select name='doc_type'>". NEWLINE;
2527		html_print_list_box_from_key_array( requirement_get_types($project_id, $blank=true),
2528											$selected=$filter_doc_type );
2529		print"</select>". NEWLINE;
2530		print"</td>". NEWLINE;
2531
2532		# STATUS
2533		print"<td align='center'>". NEWLINE;
2534		print"<select name='status'>". NEWLINE;
2535		html_print_list_box_from_array( requirement_get_distinct_field($project_id, REQ_VERS_STATUS, $blank=true),
2536										$selected=$filter_status );
2537		print"</select>". NEWLINE;
2538		print"</td>". NEWLINE;
2539
2540		# AREA COVERED
2541		print"<td align='center'>". NEWLINE;
2542		print"<select name='area_covered'>". NEWLINE;
2543		html_print_list_box_from_key_array( requirement_get_areas($project_id, $blank=true),
2544											$selected=$filter_area_covered );
2545		print"</select>". NEWLINE;
2546		print"</td>". NEWLINE;
2547
2548		if( !is_null($filter_per_page) ) {
2549			# PER PAGE
2550			print"<td align='center'>". NEWLINE;
2551			print"<input type='text' size='3' maxlength='3' name='per_page' value='$filter_per_page'>". NEWLINE;
2552			print"</td>". NEWLINE;
2553		}
2554
2555		print"</tr>";
2556
2557		# TITLES FOR HEADER DIALOG - second row
2558		print"<tr>";
2559		print"<td class=form-header-c>". lang_get('functionality') ."</td>". NEWLINE;
2560		print"<td class=form-header-c>". lang_get('req_assign_release') ."</td>". NEWLINE;
2561		print"<td class=form-header-c>". lang_get('req_priority') ."</td>". NEWLINE;
2562		print"<td class=form-header-c>". lang_get('search') ."</td>". NEWLINE;
2563
2564		/*
2565		if( !is_null($filter_show_versions) ) {
2566				# SHOW VERSIONS
2567				print"<td class='left' rowspan=4>". NEWLINE;
2568				print"<input id=all_versions type='radio' name='show_versions' value='all' ".($filter_show_versions=="all"?"checked":"").">";
2569				print"<label for=all_versions>".lang_get("all_versions")."</label><br>". NEWLINE;
2570
2571				print"<input id=latest_version type='radio' name='show_versions' value='latest' ".($filter_show_versions=="latest"?"checked":"").">";
2572				print"<label for=latest_version>".lang_get("latest_version")."</label>". NEWLINE;
2573				print"</td>". NEWLINE;
2574
2575				//print"<td>&nbsp;</td>". NEWLINE;
2576
2577		}
2578		*/
2579		print"</tr>";
2580
2581		# FUNCTIONALITY
2582		print"<tr>";
2583		$functions = requirement_get_functionality($project_id);
2584		$functions[""] = "";
2585		print"<td align='center'>". NEWLINE;
2586		print"<select name='functionality'>". NEWLINE;
2587		html_print_list_box_from_key_array( $functions, $selected=$filter_functionality );
2588		print"</select>". NEWLINE;
2589		print"</td>". NEWLINE;
2590
2591		# ASSIGNED TO RELEASE
2592		print"<td align='center'>". NEWLINE;
2593		print"<select name='assign_release'>". NEWLINE;
2594		$rows_releases = requirement_get_all_assoc_releases($project_id, $blank=true);
2595		html_print_list_box_from_key_array( $rows_releases,$selected=$filter_assign_release );
2596		print"</select>". NEWLINE;
2597		print"</td>". NEWLINE;
2598
2599		# PRIORITY
2600		print"<td align='center'>". NEWLINE;
2601		print"<select name='priority'>". NEWLINE;
2602		$rows_priority = requirement_get_priority();
2603		html_print_list_box_from_array( $rows_priority, $selected=$filter_priority );
2604		print"</select>". NEWLINE;
2605		print"</td>". NEWLINE;
2606
2607		# SEARCH
2608		print"<td align='center'>". NEWLINE;
2609		print"<input type='text' size='15' maxlength='25' name='requirement_search' value='" . $filter_search . "'>". NEWLINE;
2610		print"</td>". NEWLINE;
2611
2612		print"</tr>";
2613		print"</table>". NEWLINE;
2614	print"</td>". NEWLINE;
2615	print"</tr>". NEWLINE;
2616	print"</table>". NEWLINE;
2617
2618}
2619
2620#------------------------------------------------------------------------------------------
2621# Prints the filter at the top of the test page.
2622# INPUT:
2623# 	all the possible values that a user can filter on
2624# OUTPUT:
2625#	The test filter form
2626#------------------------------------------------------------------------------------------
2627function html_print_tests_filter(	$project_id,
2628									$filter_manual_auto,
2629									$filter_test_type,
2630									$filter_ba_owner,
2631									$filter_qa_owner,
2632									$filter_tester,
2633									$filter_area_tested,
2634									$filter_test_status=null,
2635									$filter_priority,
2636									$filter_per_page,
2637									$filter_search) {
2638
2639
2640	print"<table class=width100>". NEWLINE;
2641	print"<tr>". NEWLINE;
2642	print"<td>". NEWLINE;
2643		print"<table class=inner rules=none border=0>". NEWLINE;
2644
2645		# TITLES FOR HEADER DIALOG
2646		print"<tr class=left>". NEWLINE;
2647		print"<td class=form-header-c>". lang_get('man_auto') ."</td>". NEWLINE;
2648		print"<td class=form-header-c>". lang_get('ba_owner') ."</td>". NEWLINE;
2649		print"<td class=form-header-c>". lang_get('qa_owner') ."</td>". NEWLINE;
2650		print"<td class=form-header-c>". lang_get('tester') ."</td>". NEWLINE;
2651		print"<td class=form-header-c>". lang_get('show') ."</td>". NEWLINE;
2652		print"<td>&nbsp;</td>". NEWLINE;
2653		print"</tr>". NEWLINE;
2654
2655		# MANUAL/AUTOMATED
2656		print"<tr>". NEWLINE;
2657		print"<td align='center'>". NEWLINE;
2658		print"<select name='manual_auto'>". NEWLINE;
2659		$man_auto = test_get_man_auto_values();
2660		html_print_list_box_from_array( $man_auto, $filter_manual_auto );
2661		print"</select>". NEWLINE;
2662		print"</td>". NEWLINE;
2663
2664		# BA OWNER
2665		print"<td align='center'>". NEWLINE;
2666		print"<select name='ba_owner'>". NEWLINE;
2667		$ba_owners = test_get_test_value($project_id, TEST_BA_OWNER, $blank=true);
2668		html_print_list_box_from_array( $ba_owners, $filter_ba_owner );
2669		print"</select>". NEWLINE;
2670		print"</td>". NEWLINE;
2671
2672		# QA OWNER
2673		print"<td align='center'>". NEWLINE;
2674		print"<select name='qa_owner'>". NEWLINE;
2675		$qa_owners = test_get_test_value($project_id, TEST_QA_OWNER, $blank=true);
2676		html_print_list_box_from_array( $qa_owners, $filter_qa_owner );
2677		print"</select>". NEWLINE;
2678		print"</td>". NEWLINE;
2679
2680		# TESTER
2681		print"<td align='center'>". NEWLINE;
2682		print"<select name='tester'>". NEWLINE;
2683		$testers = test_get_test_value($project_id, TEST_TESTER, $blank=true);
2684		html_print_list_box_from_array( $testers, $filter_tester );
2685		print"</select>". NEWLINE;
2686		print"</td>". NEWLINE;
2687
2688		# PER PAGE
2689				print"<td align='center'>". NEWLINE;
2690				print"<input type='text' size='3' maxlength='3' name='per_page' value='" . $filter_per_page . "'>". NEWLINE;
2691		print"</td>". NEWLINE;
2692		print"<td align='center'><input type='submit' value='Filter'></td>". NEWLINE;
2693		print"</tr>". NEWLINE;
2694
2695
2696		print"<tr>";
2697		print"<td class=form-header-c>". lang_get('testtype') ."</td>". NEWLINE;
2698		print"<td class=form-header-c>". lang_get('area_tested') ."</td>". NEWLINE;
2699		if( !is_null($filter_test_status) ) {
2700			print"<td class=form-header-c>". lang_get('test_status') ."</td>". NEWLINE;
2701		}
2702		print"<td class=form-header-c>". lang_get('priority') ."</td>". NEWLINE;
2703		print"<td class=form-header-c>". lang_get('search') ."</td>". NEWLINE;
2704
2705		print"</tr>";
2706
2707		print"<tr>";
2708
2709		# TEST TYPE
2710		print"<td align='center'>". NEWLINE;
2711		print"<select name='test_type'>". NEWLINE;
2712		$test_type = test_get_test_value($project_id, TEST_TESTTYPE, $blank=true);
2713		html_print_list_box_from_array( $test_type, $filter_test_type );
2714		print"</select>". NEWLINE;
2715		print"</td>". NEWLINE;
2716
2717		# AREA TESTED
2718		print"<td align='center'>". NEWLINE;
2719		print"<select name='area_tested'>". NEWLINE;
2720		$area_tested = test_get_test_value($project_id, TEST_AREA_TESTED, $blank=true);
2721		html_print_list_box_from_array( $area_tested, $filter_area_tested );
2722		print"</select>". NEWLINE;
2723		print"</td>". NEWLINE;
2724
2725		if( !is_null($filter_test_status) ) {
2726			# TEST STATUS
2727			print"<td align='center'>". NEWLINE;
2728			print"<select name='test_status'>". NEWLINE;
2729			$test_status = test_get_test_value($project_id, TEST_STATUS, $blank=true);
2730			html_print_list_box_from_array( $test_status, $filter_test_status );
2731			print"</select>". NEWLINE;
2732			print"</td>". NEWLINE;
2733		}
2734
2735		# PRIORITY
2736		print"<td align='center'>". NEWLINE;
2737		print"<select name='priority'>". NEWLINE;
2738		$priority = test_get_priorities();
2739		html_print_list_box_from_array( $priority, $filter_priority );
2740		print"</select>". NEWLINE;
2741		print"</td>". NEWLINE;
2742
2743
2744		# SEARCH
2745		print"<td align='center'>". NEWLINE;
2746		print"<input type='text' size='15' maxlength='25' name='test_search' value='" . $filter_search . "'>". NEWLINE;
2747		print"</td>". NEWLINE;
2748
2749
2750		print"</tr>". NEWLINE;
2751
2752		print"</table>";
2753		print"<input type=hidden name=test_form_filter_value value=true>". NEWLINE;
2754	print"</td>". NEWLINE;
2755	print"</tr>". NEWLINE;
2756	print"</table>". NEWLINE;
2757
2758}
2759
2760#------------------------------------------------------------------------------------------
2761# Prints the filter at the top of the test page.
2762# INPUT:
2763# 	all the possible values that a user can filter on
2764# OUTPUT:
2765#	The test filter form
2766#------------------------------------------------------------------------------------------
2767function html_print_testsets_filter($project_id, $filter_build_name, $filter_release_name, $filter_per_page) {
2768
2769
2770	print"<table class=width100>". NEWLINE;
2771	print"<tr>". NEWLINE;
2772	print"<td>". NEWLINE;
2773		print"<table class=inner rules=none border=0>". NEWLINE;
2774
2775		# TITLES FOR HEADER DIALOG
2776		print"<tr class=left>". NEWLINE;
2777		print"<td class=form-header-c>". lang_get('build_name') ."</td>". NEWLINE;
2778		print"<td class=form-header-c>". lang_get('release_name') ."</td>". NEWLINE;
2779		print"<td class=form-header-c>". lang_get('show') ."</td>". NEWLINE;
2780		print"<td>&nbsp;</td>". NEWLINE;
2781		print"</tr>". NEWLINE;
2782
2783		# BUILD NAME
2784		print"<tr>". NEWLINE;
2785		print"<td align='center'>". NEWLINE;
2786		print"<select name='build_name'>". NEWLINE;
2787		$build_names = build_get_buildnames($project_id);
2788		html_print_list_box_from_array( $build_names, $filter_build_name );
2789		print"</select>". NEWLINE;
2790		print"</td>". NEWLINE;
2791
2792		# RELEASE NAME
2793		print"<td align='center'>". NEWLINE;
2794		print"<select name='release_name'>". NEWLINE;
2795		$release_names = release_get_releasenames($project_id);
2796		html_print_list_box_from_array( $release_names, $filter_release_name );
2797		print"</select>". NEWLINE;
2798		print"</td>". NEWLINE;
2799
2800		# PER PAGE
2801				print"<td align='center'>". NEWLINE;
2802				print"<input type='text' size='3' maxlength='3' name='per_page' value='" . $filter_per_page . "'>". NEWLINE;
2803		print"</td>". NEWLINE;
2804
2805		print"<td align='center'><input type='submit' value='Filter'></td>". NEWLINE;
2806		print"</tr>". NEWLINE;
2807		print"<tr><td></td></tr>". NEWLINE;
2808	print"</table>". NEWLINE;
2809	print"</table>". NEWLINE;
2810
2811}
2812
2813#------------------------------------------------------------------------------------------
2814# Prints the filter at the top of the bug page.
2815# INPUT:
2816# 	all the possible values that a user can filter on
2817# OUTPUT:
2818#	The bug filter form
2819#------------------------------------------------------------------------------------------
2820function html_print_bug_filter(	$project_id, $filter_bug_status, $filter_bug_category,
2821								$filter_bug_component, $filter_reported_by, $filter_assigned_to, $filter_assigned_to_developer, $filter_found_in_rel, $filter_assigned_to_rel, $filter_per_page, $filter_view_closed, $filter_search, $filter_jump  ) {
2822
2823
2824	print"<table class=width100>". NEWLINE;
2825	print"<tr>". NEWLINE;
2826	print"<td>". NEWLINE;
2827		print"<table class=inner rules=none border=0>". NEWLINE;
2828
2829		# TITLES FOR HEADER DIALOG
2830		print"<tr class=left>". NEWLINE;
2831		print"<td class=form-header-c>". lang_get('reported_by') ."</td>". NEWLINE;
2832		print"<td class=form-header-c>". lang_get('assigned_to') ."</td>". NEWLINE;
2833		print"<td class=form-header-c>". lang_get('assigned_to_developer') ."</td>". NEWLINE;
2834		print"<td class=form-header-c>". lang_get('found_in_release') ."</td>". NEWLINE;
2835		print"<td class=form-header-c>". lang_get('assigned_to_release') ."</td>". NEWLINE;
2836		print"<td class=form-header-c>". lang_get('show') ."</td>". NEWLINE;
2837		print"<td>&nbsp;</td>". NEWLINE;
2838		print"</tr>". NEWLINE;
2839
2840		# REPORTED BY - all users
2841		print"<td align='center'>". NEWLINE;
2842		print"<select name='reported_by'>". NEWLINE;
2843		$reported_by = user_get_usernames_by_project($project_id, $blank=true);
2844		html_print_list_box_from_array( $reported_by, $filter_reported_by );
2845		print"</select>". NEWLINE;
2846		print"</td>". NEWLINE;
2847
2848		# ASSIGNED TO - all users?? or all users with bug_assign_status
2849		print"<td align='center'>". NEWLINE;
2850		print"<select name='assigned_to'>". NEWLINE;
2851		$assigned_to = user_get_usernames_by_project($project_id, $blank=true);
2852		html_print_list_box_from_array( $assigned_to, $filter_assigned_to );
2853		print"</select>". NEWLINE;
2854		print"</td>". NEWLINE;
2855
2856		# ASSIGNED TO DEVELOPER
2857		print"<td align='center'>". NEWLINE;
2858		print"<select name='assigned_to_developer'>". NEWLINE;
2859		$assigned_to_developer = user_get_usernames_by_project($project_id, $blank=true);
2860		html_print_list_box_from_array( $assigned_to_developer, $filter_assigned_to_developer );
2861		print"</select>". NEWLINE;
2862		print"</td>". NEWLINE;
2863
2864		# FOUND IN RELEASE
2865		print"<td align='center'>". NEWLINE;
2866		print"<select name='found_in_release'>". NEWLINE;
2867		$found_in_release = admin_get_all_release_names( $project_id, $blank=true );
2868		html_print_list_box_from_array( $found_in_release, $filter_found_in_rel );
2869		print"</select>". NEWLINE;
2870		print"</td>". NEWLINE;
2871
2872		# ASSIGNED TO RELEASE
2873		print"<td align='center'>". NEWLINE;
2874		print"<select name='assigned_to_release'>". NEWLINE;
2875		$assigned_to_release = admin_get_all_release_names( $project_id, $blank=true );
2876		html_print_list_box_from_array( $assigned_to_release, $filter_assigned_to_rel );
2877		print"</select>". NEWLINE;
2878		print"</td>". NEWLINE;
2879
2880		# PER PAGE
2881		print"<td align='center'>". NEWLINE;
2882		print"<input type='text' size='3' maxlength='3' name='per_page' value='" . $filter_per_page . "'>". NEWLINE;
2883		print"</td>". NEWLINE;
2884
2885		print"<td align='center' rowspan=4 valign=center><input type='submit' value='Filter'></td>". NEWLINE;
2886		print"</tr>". NEWLINE;
2887
2888
2889		# SECOND ROW OF FILTERS
2890		print"<tr class='left'>". NEWLINE;
2891		print"<td class=form-header-c>". lang_get('bug_status') ."</td>". NEWLINE;
2892		print"<td class=form-header-c>". lang_get('bug_category') ."</td>". NEWLINE;
2893		print"<td class=form-header-c>". lang_get('bug_component') ."</td>". NEWLINE;
2894		print"<td class=form-header-c>". lang_get('view_closed') ."</td>". NEWLINE;
2895		print"<td class=form-header-c>". lang_get('search') ."</td>". NEWLINE;
2896		print"<td class=form-header-c>". lang_get('jump') ."</td>". NEWLINE;
2897		print"<td>&nbsp;</td>". NEWLINE;
2898		print"</tr>". NEWLINE;
2899
2900		print"<tr>". NEWLINE;
2901
2902		# STATUS
2903		print"<td align='center'>". NEWLINE;
2904		print"<select name='status'>". NEWLINE;
2905		$bug_status = bug_get_status( true );
2906		html_print_list_box_from_array( $bug_status, $filter_bug_status );
2907		print"</select>". NEWLINE;
2908		print"</td>". NEWLINE;
2909
2910		# CATEGORY
2911		print"<td align='center'>". NEWLINE;
2912		print"<select name='category'>". NEWLINE;
2913		html_print_list_box_from_key_array( bug_get_categories( $project_id, $blank=true ), $selected=$filter_bug_category);
2914		print"</select>". NEWLINE;
2915		print"</td>". NEWLINE;
2916
2917		# COMPONENT
2918		print"<td align='center'>". NEWLINE;
2919		print"<select name='component'>". NEWLINE;
2920		html_print_list_box_from_key_array( bug_get_components( $project_id, $blank=true ), $selected=$filter_bug_component);
2921		print"</select>". NEWLINE;
2922		print"</td>". NEWLINE;
2923
2924		# VIEW CLOSED
2925		print"<td align='center'>". NEWLINE;
2926		print"<select name='view_closed'>". NEWLINE;
2927		$view_closed_options = array( lang_get('yes'), lang_get('no') );
2928		html_print_list_box_from_array( $view_closed_options, $filter_view_closed );
2929		print"</select>". NEWLINE;
2930		print"</td>". NEWLINE;
2931
2932		# SEARCH
2933		print"<td align='center'>". NEWLINE;
2934		print"<input type='text' size='15' maxlength='25' name='bug_search' value='" . $filter_search . "'>". NEWLINE;
2935		print"</td>". NEWLINE;
2936
2937		# JUMP
2938		print"<td align='center'>". NEWLINE;
2939		print"<input type='text' size='6' maxlength='6' name='filter_jump' value='" . $filter_jump . "'>". NEWLINE;
2940		print"</td>". NEWLINE;
2941
2942		print"</tr>". NEWLINE;
2943
2944		print"</table>". NEWLINE;
2945		print"<input type=hidden name=bug_form_filter_value value=true>". NEWLINE;
2946	print"</td>". NEWLINE;
2947	print"</tr>". NEWLINE;
2948	print"</table>". NEWLINE;
2949
2950}
2951
2952#------------------------------------------------------------------------------------------
2953# Prints the filter at the top of the test page.
2954# INPUT:
2955# 	all the possible values that a user can filter on
2956# OUTPUT:
2957#	The test filter form
2958#------------------------------------------------------------------------------------------
2959function html_print_field_filter( $filter_screen, $filter_search) {
2960
2961	$s_project_properties	= session_get_project_properties();
2962	$project_id				= $s_project_properties['project_id'];
2963
2964	print"<table class=width60>". NEWLINE;
2965	print"<tr>". NEWLINE;
2966	print"<td>". NEWLINE;
2967		print"<table class=inner rules=none border=0>". NEWLINE;
2968
2969		# TITLES FOR HEADER DIALOG
2970		print"<tr class=left>". NEWLINE;
2971		print"<td class=form-header-c>". lang_get('screen_name') ."</td>". NEWLINE;
2972		print"<td class=form-header-c>". lang_get('search') ."</td>". NEWLINE;
2973		print"<td>&nbsp;</td>". NEWLINE;
2974		print"</tr>". NEWLINE;
2975
2976		print"<tr>". NEWLINE;
2977
2978		# SCREEN_NAMES
2979		$screens = test_get_screens( $project_id, SCREEN_NAME, "ASC" );
2980		$screen_array = array();
2981		foreach( $screens as $screen ) {
2982			$screen_array[$screen[SCREEN_ID]] = $screen[SCREEN_NAME];
2983		}
2984		print"<td align=center>". NEWLINE;
2985		print"<select name='filter_screen'>". NEWLINE;
2986		print"<option value=''></option>". NEWLINE;
2987			html_print_list_box_from_key_array( $screen_array,  $filter_screen );
2988		print"</select>". NEWLINE;
2989		print"</td>". NEWLINE;
2990
2991		# SEARCH
2992		print"<td align='center'>". NEWLINE;
2993		print"<input type='text' size='15' maxlength='25' name='filter_search' value='" . $filter_search . "'>". NEWLINE;
2994		print"</td>". NEWLINE;
2995
2996		# FILTER BUTTON
2997		print"<td align='center' rowspan=4 valign=center><input type='submit' value='Filter'></td>". NEWLINE;
2998
2999		print"</tr>". NEWLINE;
3000
3001		print"</table>";
3002		print"<input type=hidden name=field_form_filter_value value=true>". NEWLINE;
3003	print"</td>". NEWLINE;
3004	print"</tr>". NEWLINE;
3005	print"</table>". NEWLINE;
3006
3007}
3008
3009#------------------------------------------------------------------------------------------
3010# Prints the FCKeditor code if session_use_FCKeditor() returns true,
3011# otherwise prints out a normal <textarea>.
3012# INPUT:
3013# 	name of field
3014#	width in pixels
3015#	height in pixels
3016#	default value of field
3017#------------------------------------------------------------------------------------------
3018function html_FCKeditor($name, $width, $height, $value="") {
3019
3020	# Set minimum height and width of the FCKeditor
3021	if( $width < 510 ) {
3022		$width = 510;
3023	}
3024	if( $height < 120 ) {
3025		$height = 120;
3026	}
3027
3028	# if using FCKeditor
3029	if( session_use_FCKeditor() ) {
3030
3031		$FCKeditor = new FCKeditor($name);
3032		$FCKeditor->BasePath			= FCK_EDITOR_BASEPATH;
3033		$FCKeditor->Config['SkinPath']	= $FCKeditor->BasePath.'editor/skins/office2003/';
3034		$FCKeditor->ToolbarSet			= "RTH";
3035		$FCKeditor->Width				= $width."px";
3036		$FCKeditor->Height				= $height."px";
3037		$FCKeditor->Value				= $value;
3038		$FCKeditor->Create();
3039
3040	# if not using FCKeditor
3041	} else {
3042
3043		# work out number of rols and cols for the text area.
3044		# this is ~ 8 pixels per character and 20 pixels per row
3045		$cols = round($width/8);
3046		$rows = round($height/20);
3047
3048		$value = util_strip_html_tags( $value );
3049
3050		print"<textarea rows=$rows cols=$cols name='$name'>$value</textarea>";
3051	}
3052}
3053
3054#------------------------------------------------------------------------------------------
3055# Prints one teststep row and parses the action, input and results column.
3056# If any of these columns includes an hyperlink according an fixed patter
3057# the link will made clickable
3058# INPUT:
3059# 	action of teststep
3060#	input of teststep
3061#	resutls of teststep
3062#------------------------------------------------------------------------------------------
3063function html_print_teststep_with_hyperlinks($info_step_class, $action, $input, $result)
3064{
3065	$step_action = replace_uri($action);
3066	$step_test_inputs = replace_uri($input);
3067	$step_expected = replace_uri($result);
3068	print"<td align=left><div $info_step_class>$step_action</div></td>". NEWLINE;
3069	print"<td align=left><div $info_step_class>$step_test_inputs</div></td>". NEWLINE;
3070	print"<td align=left><div $info_step_class>$step_expected</div></td>". NEWLINE;
3071}
3072
3073#------------------------------------------------------------------------------------------
3074# replace URIs with appropriate HTML code to be clickable.
3075#------------------------------------------------------------------------------------------
3076function replace_uri($str) {
3077  $pattern = '#(^|[^\"=]{1})(http://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm';
3078  return preg_replace($pattern,"\\1<a href=\"\\2\\3\" target=\"_blank\"><u>\\2\\3</u></a>\\4",$str);
3079}
3080
3081# ------------------------------------
3082# $Log: html_api.php,v $
3083# Revision 1.21  2008/08/04 06:55:01  peter_thal
3084# added sorting function to several tables
3085#
3086# Revision 1.20  2008/07/25 09:50:07  peter_thal
3087# added lock testset feature
3088# disabled detail column in test result, because functionality is not implemented yet
3089#
3090# Revision 1.19  2008/07/17 13:54:12  peter_thal
3091# added new feature: test sets status (overview)
3092# +fixed some bugs with project_id parameter in testdetail_page references
3093#
3094# Revision 1.18  2008/01/22 08:28:14  cryobean
3095# added function for not sortable headers
3096#
3097# Revision 1.17  2007/11/19 08:59:01  cryobean
3098# bugfixes
3099#
3100# Revision 1.16  2007/11/15 12:58:48  cryobean
3101# bugfixes
3102#
3103# Revision 1.15  2007/03/14 17:45:52  gth2
3104# removing code that passes varables by reference - gth
3105#
3106# Revision 1.14  2007/02/25 23:17:41  gth2
3107# fixing bugs for release 1.6.1 - gth
3108#
3109# Revision 1.13  2007/02/06 03:28:12  gth2
3110# correct email problem when updating test results - gth
3111#
3112# Revision 1.12  2007/02/03 11:58:37  gth2
3113# no message
3114#
3115# Revision 1.11  2007/02/03 10:25:04  gth2
3116# no message
3117#
3118# Revision 1.10  2007/02/02 04:26:27  gth2
3119# adding version information to the footer of each page - gth
3120#
3121# Revision 1.9  2006/10/05 02:42:18  gth2
3122# adding file upload to the bug page - gth
3123#
3124# Revision 1.8  2006/09/25 12:46:37  gth2
3125# Working on linking rth and other bugtrackers - gth
3126#
3127# Revision 1.7  2006/08/05 22:31:46  gth2
3128# adding NEWLINE constant to support mulitple OS - gth
3129#
3130# Revision 1.6  2006/05/08 15:38:10  gth2
3131# Changing formatting - gth
3132#
3133# Revision 1.5  2006/05/03 21:52:43  gth2
3134# adding screen and field to menu - gth
3135#
3136# Revision 1.4  2006/01/20 02:36:03  gth2
3137# enable export to excel functionaltiy - gth
3138#
3139# Revision 1.3  2006/01/16 13:27:48  gth2
3140# adding excel integration - gth
3141#
3142# Revision 1.2  2005/12/13 13:59:53  gth2
3143# Completed the addition of requirement priority - gth
3144#
3145# Revision 1.1.1.1  2005/11/30 23:01:12  gth2
3146# importing initial version - gth
3147#
3148# ------------------------------------
3149?>