Indicators
With the help of indicator rules, single or multiple data records of a table can be visually highlighted in the Record List. There are three options, which can be applied individually or in combination to a data record or a table row:
- Color: Highlighting a data record using a different background color in the Record List
- Title: Show a hint text when hovering with the mouse over the data record in the Record List
- Object: Insert a graphic or a text as a prefix in the row of the Record List.
Indicators for a table are created in the Table Settings or for specific groups in the Table Rights. An existing group setting overrides the global settings of the table. The indicator rule is found at the traffic light.
Indicator rules must be defined in a PHP function in the extension file ./dependent/EXTENSIONS/ext_gtab.inc or a global extension file. If assigned to a table, the PHP function will be run once for each record.
Indicator rules can also be applied to the calendar. Therefore, appointments can be created with different background colors or individual symbols can be added.
PHP Function for the Definition of Indicator Rules
- Any function name
- The following parameters are needed to define an indicator:
- Table ID (in the example function: $gtabid)
- Record ID of the table (in the example function: $i)
- Array containing all data records of the table (in the example function: $gresult)
- A return value ‘false’ hides the data record in the Record List of the table. It is still included in the number of found records. It will also be displayed in the Record View (view or edit mode), when scrolling forwards or backwards.
- Use Row background color by setting an RGB value in the following indexed data record array (variable names according to the example function):
$gresult[$gtabid][“indicator”][“color”][$i][1] = $RGB; - CSS-Klasse für die Ergebnis-Zeile:
$gresult[$gtabid][“indicator”][“class”][$i] = “my-css-class-to-indicate-something”; - Use the note text by placing a text in the following indexed record array (variable names according to the example function):
$gresult[$gtabid][“indicator”][“title”][$i][1] = $text1;
$gresult[$gtabid][“indicator”][“title”][$i][2] = $text2;
…
If several texts are displayed together, the order of the texts is set according to their order in the function. - Add a graphic object or text to be displayed at the beginning of a table row, by placing a text or a graphic in the following indexed record array (variable names according to the example function):
$gresult[$gtabid][“indicator”][“object”][$i][2] = $grafik;
…
Example: Funktion:
/**
* use your own function here
*
* @param integer $gtabid
* @param integer $i
* @param array $gresult
* @return boolean
*/
function extIndicatorSample($gtabid,$i,&$gresult){
global $filter;
$field1 = $gresult[$gtabid][13][$i]; # Typ
$field2 = $gresult[$gtabid][8][$i]; # bezahlt
$field3 = $gresult[$gtabid][6][$i]; # Rechnungsdatum
# 1 first indicator with background color
# 2 second indicator with image or Text
if($filter["indicator_set"][$gtabid]) {
$indicator_set = explode("_",$filter["indicator_set"][$gtabid]);
$hide = 1;
}
if($field1 == 'Rechnung'){
if(!$field2 AND (local_stamp(1) - get_stamp($field3) > 1814400) AND (local_stamp(1) - get_stamp($field3) < 3024000)){
$gresult[$gtabid]["indicator"]["color"][$i][1] = "FFDDDD"; # background color
$gresult[$gtabid]["indicator"]["title"][$i][1] = "21 days"; # row title
$gresult[$gtabid]["indicator"]["object"][$i][2] = "<IMG SRC=\"pic/ampel/amp_4_2.gif\" OnClick=\"document.form1.filter_indicator.value ='2_1';send_form(1);\" style=\"cursor:pointer;\" BORDER=\"0\" TITLE=\"".$gdesc."\" ALT=\"".$gdesc."\"> "; # image or text
if($indicator_set[1] != 2){$hide = 0;}
}elseif(!$field2 AND (local_stamp(1) - get_stamp($field3) > 3024000)){
$gresult[$gtabid]["indicator"]["color"][$i][1] = "FFAAAA";
$gresult[$gtabid]["indicator"]["title"][$i][1] = "35 days";
$gresult[$gtabid]["indicator"]["object"][$i][2] = "<IMG SRC=\"pic/ampel/amp_4_3.gif\" OnClick=\"document.form1.filter_indicator.value ='2_2';send_form(1);\" style=\"cursor:pointer;\" BORDER=\"0\" TITLE=\"".$gdesc."\" ALT=\"".$gdesc."\"> ";
if($indicator_set[1] != 1){$hide = 0;}
}else{
$gresult[$gtabid]["indicator"]["object"][$i][2] = " ";
$hide = 0;
}
}
$filter["indicator"][$gtabid] = 1; #numbers of indicators without rowcolor
# if return false dataset will hidden
if($hide){return false;}
return true;
}
The indicator could be initialized on the group table rights. You can define a function for each table on the form field “indicator rule”.
return extIndicatorSample($gtabid,$i,$gresult);