Documentation

Kpi
in package

Class Kpi

This class provides methods to manage KPIs, including retrieving, adding, and creating KPIs.

Table of Contents

Properties

$mySql  : MySql

Methods

__construct()  : mixed
add()  : void
Add a new KPI to a Datapoint
createByAdmin()  : void
Create KPI (admin).
getAll()  : array<int, array<string, mixed>>
Get all KPIs filtered by status.
getAllforDatapoint()  : array<string|int, mixed>
Get all KPIs for a datapoint.
getByCode()  : array<string|int, mixed>
Get KPI by code.
updateByCode()  : void
Update KPI by code (admin).

Properties

Methods

__construct()

public __construct(MySql $mySql) : mixed
Parameters
$mySql : MySql

add()

Add a new KPI to a Datapoint

public add(type $data) : void
Parameters
$data : type
Tags
throws
RuntimeException
throws
Throwable

createByAdmin()

Create KPI (admin).

public createByAdmin(array<string, mixed> $data) : void

Expects in $data:

  • kpi_code (string, required)
  • kpi_name (string, required)
  • kpi_name_search (string|null)
  • reference_code (string|null)
  • datapoint_code (string|null)
  • kpi_category_code (string|null)
  • sort_order (int|null)
  • status (int, required)
  • createdby (string, required)
  • modifiedby (string, required)
Parameters
$data : array<string, mixed>

getAll()

Get all KPIs filtered by status.

public getAll(array<string|int, int> $statuses) : array<int, array<string, mixed>>
Parameters
$statuses : array<string|int, int>
Return values
array<int, array<string, mixed>>

getAllforDatapoint()

Get all KPIs for a datapoint.

public getAllforDatapoint(string $datapointCode) : array<string|int, mixed>
Parameters
$datapointCode : string
Return values
array<string|int, mixed>

getByCode()

Get KPI by code.

public getByCode(string $kpiCode) : array<string|int, mixed>
Parameters
$kpiCode : string
Return values
array<string|int, mixed>

updateByCode()

Update KPI by code (admin).

public updateByCode(array<string, mixed> $data) : void

Behaviour for FKs:

  • If *_code key is not present in $data → keep existing id+code.
  • If present but empty string → set id+code to NULL.
  • If present with non-empty value → resolve id by code and update both.

Expects in $data:

  • kpi_code (string, required)
  • kpi_name (string|null)
  • kpi_name_search (string|null)
  • reference_code (string|null, presence matters)
  • datapoint_code (string|null, presence matters)
  • kpi_category_code (string|null, presence matters)
  • sort_order (int|null)
  • status (int|null)
  • modifiedby (string, required)
Parameters
$data : array<string, mixed>

        
On this page

Search results