1<?php 2# --------------------------------------------------------------------- 3# truc is a tool for requirement and use case tracking 4# Copyright (C) 2006 ASDIS - http://sf.net/projects/truc 5# 6# (rth) Initial truc version based on rth 7# Copyright (C) 2005 George Holbrook - rth@lists.sourceforge.net 8# 9# This program is distributed under the terms and conditions of the GPL 10# See the README and LICENSE files for details 11#---------------------------------------------------------------------- 12 13 14function filter_results_page( $page, $manauto, $baowner, $qaowner,$tester, $testtype, $test_area, $test_status, $per_page, $orderby, 15 $order_dir, $page_number, $release_id, $build_id, $testset_id ) { 16 17 global $db; 18 $test_tbl = TEST_TBL; 19 $test_id = TEST_TBL. "." .TEST_ID; 20 $test_name = TEST_TBL. "." .TEST_NAME; 21 $manual_tests = TEST_TBL. "." .TEST_MANUAL; 22 $automated_tests = TEST_TBL. "." .TEST_AUTOMATED; 23 $ba_owner = TEST_TBL. "." .TEST_BA_OWNER; 24 $qa_owner = TEST_TBL. "." .TEST_QA_OWNER; 25 $test_tester = TEST_TBL. "." .TEST_TESTER; 26 $test_load = TEST_TBL. "." .TEST_LR; 27 $test_type = TEST_TBL. "." .TEST_TESTTYPE; 28 $area_tested = TEST_TBL. "." .TEST_AREA_TESTED; 29 $deleted = TEST_TBL. "." .TEST_DELETED; 30 $archived = TEST_TBL. "." .TEST_ARCHIVED; 31 $test_priority = TEST_TBL. "." .TEST_PRIORITY; 32 $auto_pass = TEST_TBL. "." .TEST_AUTO_PASS; 33 34 $ts_assoc_tbl = TEST_TS_ASSOC_TBL; 35 $ts_assoc_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_ID; 36 $ts_assoc_ts_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TS_ID; 37 $ts_assoc_test_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TEST_ID; 38 $ts_assoc_finished = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_FINISHED; 39 $ts_assoc_timestamp = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TIMESTAMP; 40 $ts_assoc_test_status = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_STATUS; 41 $ts_assoc_assigned_to = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_ASSIGNED_TO; 42 $ts_assoc_comments = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_COMMENTS; 43 44 $limit_clause = ''; 45 46 //$q = "SELECT * FROM $test_tbl WHERE $deleted = 'N' AND $archived = 'N'"; 47 $q = "SELECT $test_name, $test_id, $ts_assoc_id, $ts_assoc_test_status, $ts_assoc_comments, $ts_assoc_assigned_to, $manual_tests, $automated_tests, $qa_owner, $test_load, $ba_owner, $test_priority, $area_tested, $auto_pass, $test_type FROM $ts_assoc_tbl INNER JOIN $test_tbl ON $ts_assoc_test_id = $test_id WHERE $ts_assoc_ts_id = '$testset_id' AND $deleted = 'N'"; 48 49 $where_clause = ''; 50 51 # MANUAL AUTOMATED 52 if ( !empty($manauto) && $manauto != 'all') { 53 if( $manauto == 'Manual' ) { 54 $where_clause = $where_clause. " AND $manual_tests = 'YES' AND $automated_tests = ''"; 55 } 56 elseif( $manauto == 'Automated' ) { 57 $where_clause = $where_clause. " AND $manual_tests = '' AND $automated_tests = 'YES'"; 58 } 59 else { 60 $where_clause = $where_clause. " AND $manual_tests = 'YES' AND $automated_tests = 'YES'"; 61 } 62 } 63 # BA OWNER 64 if ( !empty($baowner) && $baowner != 'all') { 65 66 $where_clause = $where_clause." AND $ba_owner = '$baowner'"; 67 } 68 # QA OWNER 69 if ( !empty($qaowner) && $qaowner != 'all') { 70 71 $where_clause = $where_clause." AND $qa_owner = '$qaowner'"; 72 } 73 # TESTER 74 if ( !empty($tester) && $tester != 'all') { 75 76 $where_clause = $where_clause." AND $test_tester = '$tester'"; 77 } 78 # TEST TYPE 79 if ( !empty( $testtype ) && $testtype != 'all') { 80 81 $where_clause = $where_clause." AND $test_type = '$testtype'"; 82 } 83 # AREA TESTED 84 if ( !empty($test_area ) && $test_area != 'all') { 85 86 $where_clause = $where_clause." AND $area_tested = '$test_area'"; 87 } 88 # TEST STATUS 89 if ( !empty($test_status ) && $test_status != 'all') { 90 91 $where_clause = $where_clause." AND $ts_assoc_test_status = '$test_status'"; 92 } 93 94 $where_clause = $where_clause." GROUP BY $test_name"; 95 $order_clause = " ORDER BY $orderby $order_dir"; 96 $q = $q.$where_clause.$order_clause; 97 //print"$q<br>"; 98 $rs_count = db_query( $db, $q ); //$db->Execute( $q ); 99 $q_count = db_num_rows( $db, $rs_count ); //$rs_count->NumRows(); 100 101 # add a table header that includes the pages showing, export to csv, and links to other result pages 102 $page_count = ceil($q_count / $per_page ); 103 104 if( $page_number > $page_count ) { 105 $page_number = $page_count; 106 } 107 108 # Add the limit clause to the query so that we only show n number of records per page 109 $offset = ( ( $page_number - 1 ) * $per_page ); 110 $limit_clause .= " LIMIT $offset, $per_page"; 111 112 $q = $q . $limit_clause; 113 114 $rs = db_query($db, $q); 115 116 $rows = db_fetch_array($db, $rs); 117 118 print"<table class=hide100 rules='all' border='1'>"; // rules=all 119 print"<tr>"; 120 html_print_records($q_count, $per_page, $page_number, $page_count); 121 print"<td class='tbl-c' width='33%'><a href='csv_export.php?rs=$row'>"; 122 if( IMPORT_EXPORT_TO_EXCEL ) { 123 print lang_get('excel_export'); 124 } 125 else { 126 print lang_get('csv_export'); 127 } 128 print"</a></td>"; 129 html_page_links( $page, 1, $page_count, $page_number ); 130 print"</tr>"; 131 print"</table>"; 132 133 return $rows; 134} 135?>