Tuesday, July 10, 2012

testlink: Removing columns from Query Metrics report

We wanted to remove 2 columns from the excel version only of the Query Metrics report, the Build and the Time.

I did play with the php code for some while for the file resultsMoreBuilds.php located in lib\results, then I discovered that I can only hide the values.

To hide the whole column, I need to look into the template.

I opened the template file \testlink\gui\templates\results\resultsMoreBuilds.tpl

located the lines for these 2 columns, 6 lines, 2 for the header,



and the same header lines for suit summaries

then another 2 lines for the data

<td style="text-align:center;">{$gui->builds_html[$inst.build_id]|escape}</td>

<td style="text-align:center;">{$inst.execution_ts|strip_tags|escape} </td>

In order to hide these columns from the excel only, which has the value of 3, I added if condition before these lines,

{if ($gui->report_type <> 3)}

In order to pass the report type with the gui object, I have modified \testlink\lib\results\resultsMoreBuilds.php, added a line just after this line $gui = initializeGui($db,$args,$date_format_cfg);

I added $gui->report_type = $args->report_type;

For example the first line will be like this

{if ($gui->report_type <> 3)}<th>{$tlImages.sort_hint}{$labels.th_build}</th> {/if}

Applying the same for the rest of the 6 lines, the 2 columns, Build and Time where not displayed in the extracted excel file

If someone wants to hide these columns from all report types, then simply instead of the if condition, just add an comment, like will look like

<!--<th>{$tlImages.sort_hint}{$labels.th_build}</th> {/if}-->