Documentation

TalerErrorLog extends CommonObject
in package

Class TalerErrorLog

Stores synchronization / integration errors for the TalerBarr module. Extends Dolibarr's CommonObject for standard CRUD behavior.

Table of Contents

Properties

$context  : mixed
$datec  : mixed
$direction_is_push  : mixed
$element  : string
$entity  : mixed
$error_code  : mixed
$error_message  : mixed
$external_ref  : mixed
$fields  : mixed
$fk_product  : mixed
$fk_product_link  : mixed
$http_status  : mixed
$isextrafieldmanaged  : int
$ismultientitymanaged  : int|string
$module  : string
$operation  : mixed
$payload_json  : mixed
$picto  : string
$rowid  : mixed
$table_element  : string
$taler_instance  : mixed
$taler_product_id  : mixed
$tms  : mixed

Methods

__construct()  : mixed
Constructor.
create()  : int
Create record.
delete()  : int
Delete record.
fetch()  : int
Fetch a record by id/ref.
fetchRecent()  : array<int, self>|int
Fetch last N logs, optionally filtered.
getLabelForList()  : string
Human-friendly label for list rows.
getNomUrl()  : string
Build object link for lists and cards.
purgeOlderThan()  : int
Purge logs older than a given timestamp.
record()  : int
Quick factory to record an error log (transaction-less).
recordArray()  : int
Convenience wrapper that accepts an associative array.
update()  : int
Update record.

Properties

$fields

public mixed $fields = array('rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'visible' => 0, 'notnull' => 1, 'index' => 1, 'position' => 1), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'visible' => 0, 'notnull' => 1, 'default' => 1, 'index' => 1, 'position' => 5), 'context' => array('type' => 'varchar(32)', 'label' => 'Context', 'visible' => 1, 'notnull' => 1, 'index' => 1, 'position' => 10, 'arrayofkeyval' => array('product' => 'Product', 'category' => 'Category', 'order' => 'Order', 'tax' => 'Tax', 'image' => 'Image', 'auth' => 'Auth', 'other' => 'Other')), 'operation' => array('type' => 'varchar(64)', 'label' => 'Operation', 'visible' => 1, 'notnull' => 0, 'position' => 11, 'arrayofkeyval' => array('create' => 'Create', 'update' => 'Update', 'delete' => 'Delete', 'relink' => 'Relink', 'sync' => 'Sync', 'fetch' => 'Fetch')), 'direction_is_push' => array('type' => 'integer', 'label' => 'DirectionPush', 'visible' => 1, 'notnull' => 0, 'position' => 12, 'arrayofkeyval' => array('1' => 'PullTalerToDoli', '0' => 'PushDoliToTaler')), 'fk_product_link' => array('type' => 'integer', 'label' => 'FkProductLink', 'visible' => 1, 'notnull' => 0, 'index' => 1, 'position' => 20), 'fk_product' => array('type' => 'integer:Product:product/class/product.class.php', 'label' => 'Product', 'visible' => 1, 'notnull' => 0, 'index' => 1, 'position' => 21, 'picto' => 'product'), 'taler_instance' => array('type' => 'varchar(64)', 'label' => 'TalerInstance', 'visible' => 1, 'notnull' => 0, 'index' => 1, 'position' => 22), 'taler_product_id' => array('type' => 'varchar(128)', 'label' => 'TalerProductId', 'visible' => 1, 'notnull' => 0, 'index' => 1, 'position' => 23), 'external_ref' => array('type' => 'varchar(128)', 'label' => 'ExternalRef', 'visible' => 1, 'notnull' => 0, 'position' => 24), 'http_status' => array('type' => 'integer', 'label' => 'HttpStatus', 'visible' => 1, 'notnull' => 0, 'position' => 30), 'error_code' => array('type' => 'varchar(64)', 'label' => 'ErrorCode', 'visible' => 1, 'notnull' => 0, 'position' => 31), 'error_message' => array('type' => 'text', 'label' => 'ErrorMessage', 'visible' => 1, 'notnull' => 1, 'position' => 32), 'payload_json' => array('type' => 'text', 'label' => 'PayloadJSON', 'visible' => 0, 'notnull' => 0, 'position' => 33), 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'visible' => -2, 'notnull' => 0, 'position' => 500), 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'visible' => -2, 'notnull' => 1, 'position' => 501))

Methods

__construct()

Constructor.

public __construct(DoliDB $db) : mixed
Parameters
$db : DoliDB

Database handler.

create()

Create record.

public create(User $user[, int $notrigger = 1 ]) : int
Parameters
$user : User

User performing the creation (used by triggers/audit).

$notrigger : int = 1

Set to 1 to disable triggers.

Return values
int

0 on success, <0 on error.

delete()

Delete record.

public delete(User $user[, int $notrigger = 1 ]) : int
Parameters
$user : User

User performing the deletion.

$notrigger : int = 1

Set to 1 to disable triggers.

Return values
int

0 on success, <0 on error.

fetch()

Fetch a record by id/ref.

public fetch(int|string $id[, string|null $ref = null ][, int $noextrafields = 1 ][, int $nolines = 1 ]) : int
Parameters
$id : int|string

Row ID (preferred) or technical ref.

$ref : string|null = null

Optional ref if you need to fetch by ref.

$noextrafields : int = 1

1 to skip extrafields fetch for performance.

$nolines : int = 1

Unused here (compat with CommonObject).

Return values
int

0 if OK, <0 on error, 0 if not found.

fetchRecent()

Fetch last N logs, optionally filtered.

public fetchRecent([int $limit = 50 ][, string|null $context = null ][, int|null $fkProductLink = null ][, int|null $fkProduct = null ][, string|null $talerInstance = null ]) : array<int, self>|int
Parameters
$limit : int = 50

Number of rows to return (default 50).

$context : string|null = null

Filter by context or null for all.

$fkProductLink : int|null = null

Filter by product link FK or null.

$fkProduct : int|null = null

Filter by product FK or null.

$talerInstance : string|null = null

Filter by Taler instance or null.

Return values
array<int, self>|int

Array of TalerErrorLog indexed by id, or <0 on SQL error.

getLabelForList()

Human-friendly label for list rows.

public getLabelForList() : string
Return values
string

Readable label including id, context/operation and error metadata.

getNomUrl()

Build object link for lists and cards.

public getNomUrl([int $withpicto = 0 ][, string $option = '' ][, int $notooltip = 0 ][, string $morecss = '' ][, int $save_lastsearch_value = -1 ]) : string
Parameters
$withpicto : int = 0

0 = no picto, 1 = picto + label, 2 = picto only.

$option : string = ''

'nolink' to disable anchor; anything else enables link.

$notooltip : int = 0

1 to disable tooltip (kept for API compatibility).

$morecss : string = ''

Extra CSS classes to add to the link.

$save_lastsearch_value : int = -1

Keep -1 to use default behavior.

Return values
string

HTML for object link.

purgeOlderThan()

Purge logs older than a given timestamp.

public purgeOlderThan(int $olderThanTs) : int
Parameters
$olderThanTs : int

UNIX timestamp; delete rows with datec older than this.

Return values
int

=0 number of deleted rows, <0 on error.

record()

Quick factory to record an error log (transaction-less).

public static record(DoliDB $db[, User|null $user = null ], string $context, string|null $operation, bool|null $directionIsPush, int|null $fkProductLink, int|null $fkProduct, string|null $talerInstance, string|null $talerProductId, string|null $externalRef, int|null $httpStatus, string|null $errorCode, string $errorMessage[, string|null $payloadJson = null ]) : int

Provide only what you have; nulls are accepted for optional fields.

Parameters
$db : DoliDB

Database handler.

$user : User|null = null

User performing the action (or null for system).

$context : string

Logical context: product, category, order, tax, image, auth, other.

$operation : string|null

Operation name: create, update, delete, relink, sync, fetch.

$directionIsPush : bool|null

True if push Doli→Taler, false if pull Taler→Doli, null if n/a.

$fkProductLink : int|null

FK to talerproductlink row if known.

$fkProduct : int|null

FK to Dolibarr product if known.

$talerInstance : string|null

Taler instance identifier (string key).

$talerProductId : string|null

Taler-side product ID.

$externalRef : string|null

Any other external reference.

$httpStatus : int|null

HTTP status code if from an HTTP call.

$errorCode : string|null

Optional module/provider error code.

$errorMessage : string

Human-readable error message (required).

$payloadJson : string|null = null

Raw JSON payload that caused/illustrates error.

Return values
int

0 row id on success, <0 on error.

recordArray()

Convenience wrapper that accepts an associative array.

public static recordArray(DoliDB $db, array<string|int, mixed> $data[, User|null $user = null ]) : int

Keys: context, operation, direction_is_push(bool|null), fk_product_link, fk_product, taler_instance, taler_product_id, external_ref, http_status, error_code, error_message, payload_json

Parameters
$db : DoliDB

Database handler.

$data : array<string|int, mixed>

Input data (see keys above).

$user : User|null = null

User performing the action (or null for system).

Return values
int

0 row id on success, <0 on error.

update()

Update record.

public update(User $user[, int $notrigger = 1 ]) : int
Parameters
$user : User

User performing the update.

$notrigger : int = 1

Set to 1 to disable triggers.

Return values
int

0 on success, <0 on error, 0 if no change.


        
On this page

Search results