Examples

Inheritance

Estimated reading: 5 minutes

Custom filters can be added to a search in an inherited table. As the get_gresult() function is used for the search, all of its parameters can be used. These include [$gsr], [$filter], [$verkn] and [$extension].

The following example shows, how content from individual fields of existing data records from other tables is inherited, when data are entered.

This example is based on two existing tables:

  • ‘Car types’ Table with the fields
    • Model
    • Manufacturer
    • Fuel Consumption
    • Car Dealer´s Address
  • ‘Employee’ Table with the fields
    • Employee ID
    • First name
    • Last name
    • Street
    • Zip Code
    • City

All company cars should be entered in a table with the following fields:

  • License plate
  • Date of first registration
  • Model
  • Manufacturer
  • Fuel Consumption
  • Driver Last name
  • Driver First name

For the ‘Inheritance Function’ in LIMBAS the ‘inherited’ Field Type is used. The table fields ‘Model’, ‘Manufacturer’, ‘Fuel Consumption’, ‘Driver last name’, ‘Driver first name’ are of the ‘inherited’ type. The ‘Inherit from these fields’ of the ‘Sending Table’ are also specified. ‘Model’, ‘Manufacturer’ and ‘Consumption’ are assigned to a common ‘Inheritance Group’, ‘Driver last name’ and ‘Driver first name’ are assigned to a second common ‘Inheritance Group’. Furthermore, the ‘Search Option’ is set for ‘Model’ and ‘Driver.

Enter one or more characters in the ‘Model’ input field, in the Edit View of the ‘Company car’ table and a drop down list appears with all ‘Models’ of the ‘Car Types’ table containing these characters. Select with a click one of these values and it will be applied, including the value of the fields ‘Manufacturer’ and ‘Fuel Consumption’. Enter one or more characters in the input field ‘Driver last name’ and a drop down list appears, with all ‘Last names’ of the ‘Employee’ table, which contain the searched for characters. Select with a click one of these values and it is applied together with the associated ‘First name’.

Should only entries, which contain certain data values in one or more fields of the data record, appear in the pop-up list, a filter for ‘Inheritance’ must be used. The filter settings are defined with the “$gsr” (see functional description “get_gresult”).


Filter examples:

The following entry in the filter of the ‘Driver last name’ field takes into account only the employees from London:

$gsr[$tableIdMitarbeiter][$fieldIdOrt][$laufendeFilterNr]='London';
$gsr[$tableIdMitarbeiter][$fieldIdOrt]['txt'][$laufendeFilterNr]=1;

The following variables have to be replaced with the appropriate values:

  • $tableIdMitarbeiter: ID of the ‘Employees’ table
  • $fieldIdOrt: Field ID of the ‘City’ field from ‘Employees’ table
  • $laufendeFilterNr: Index (freely selectable), with multiple filters, starting with 0 and ascending.

The following entry in the filter of the ‘Driver last name’ field is only taken into account for employees, with a personnel number less than or equal to 200:

$gsr[$tableIdMitarbeiter][$fieldIdPersonalNr][$laufendeFilterNr+1]=200;
$gsr[$tableIdMitarbeiter][$fieldIdPersonalNr]['num'][$laufendeFilterNr+1]=4;

The following variables have to be replaced with the appropriate values:

  • $tableIdMitarbeiter: ID of the ‘Employees’ table
  • $fieldIdPersonalNr: Field ID of the ‘Employee ID’ field from the ‘Employees’ table
  • $laufendeFilterNr: Index (freely selectable), with multiple filters, starting with 0 and ascending.

The following entry in the filter of the ‘Driver last name’ field combines the first two examples in the following way. Only staff from London, with an ‘Employee ID’ less than or equal to 200 are taken into account:

$gsr[$tableIdMitarbeiter][$fieldIdOrt][$laufendeFilterNr]='London';
$gsr[$tableIdMitarbeiter][$fieldIdOrt]['txt'][$laufendeFilterNr]=1;
$gsr[$tableIdMitarbeiter][$fieldIdPersonalNr][$laufendeFilterNr+1]=200;
$gsr[$tableIdMitarbeiter][$fieldIdPersonalNr]['num'][$laufendeFilterNr+1]=4;
$gsr[$tableIdMitarbeiter]['andor'] = 1;

The following variables have to be replaced with the appropriate values:

  • $tableIdMitarbeiter: ID of the ‘Employees’ table
  • $fieldIdOrt/$fieldIdPersonalNr: Field ID of the ‘City’ field or ‘Employee ID’ from the ‘Employees’ table.
  • $laufendeFilterNr: Index (freely selectable), with multiple filters, starting with 0 and ascending.

The following entry in the filter of the field ‘Driver last name’ combines the first two examples in the following way. Staff from London and employees with an ‘Employee ID’ less than or equal to 200 are taken into account:

$gsr[$tableIdMitarbeiter][$fieldIdOrt][$laufendeFilterNr]='London';
$gsr[$tableIdMitarbeiter][$fieldIdOrt]['txt'][$laufendeFilterNr]=1;
$gsr[$tableIdMitarbeiter][$fieldIdPersonalNr][$laufendeFilterNr+1]=200;
$gsr[$tableIdMitarbeiter][$fieldIdPersonalNr]['num'][$laufendeFilterNr+1]=4;
$gsr[$tableIdMitarbeiter]['andor'] = 2;

The following variables have to be replaced with the appropriate values:

  • $tableIdMitarbeiter: ID of the ‘Employees’ table
  • $fieldIdOrt/$fieldIdPersonalNr: Field ID of the ‘City’ field or ‘Employee ID’ from the ‘Employees’ table.
  • $laufendeFilterNr: Index (freely selectable), with multiple filters, starting with 0 and ascending.

The following entry in the filter of the field ‘Driver last name’ determines the first letter of the existing ‘License plate’ and takes into account only employees who live in a city that begins with that letter.

$myOnlyField[$tableIdFirmenwagen] = array($fieldIdKennzeichen);
$myResult = get_gresult($tableIdFirmenwagen, 1, null, null, null, $myOnlyField, $ID, null, null);
$gsr[$tableIdMitarbeiter][$fieldIdOrt][$laufendeFilterNr]=$myResult[$tableIdFirmenwagen][$fieldIdKennzeichen][0][0];
$gsr[$tableIdMitarbeiter][$fieldIdOrt]['txt'][$laufendeFilterNr]=3;

The following variables have to be replaced with the appropriate values:

  • $tableIdMitarbeiter: ID of the ‘Employees’ table
  • $tableIdFirmenwagen: ID of the ‘Company car’ table
  • $fieldIdOrt: Field ID of the ‘City’ field from the ‘Employees’ table.
  • $fieldIdKennzeichen: Field ID of the ‘License plate’ field from the ‘Company car‘table
  • $laufendeFilterNr: Index (freely selectable), with multiple filters, starting with 0 and ascending.

The variable $ID is replaced by the script with the current record ID.

Share this Doc

Inheritance

Or copy link

CONTENTS