TalerCategoryMap
extends CommonObject
in package
Class TalerCategoryMap
Maps Taler (Merchant Backend) category ids/names to Dolibarr categories. Provides CRUD helpers and idempotent upsert by either side of the mapping.
Table of Contents
Properties
- $datec : mixed
- $element : string
- $entity : mixed
- $fields : mixed
- $fk_categorie : mixed
- $isextrafieldmanaged : int
- $ismultientitymanaged : int|string
- $module : string
- $note : mixed
- $picto : string
- $rowid : mixed
- $table_element : string
- $taler_category_id : mixed
- $taler_category_name : mixed
- $taler_instance : mixed
- $tms : mixed
Methods
- __construct() : mixed
- Constructor.
- create() : int
- Create record in database.
- delete() : int
- Delete record from database.
- fetch() : int
- Fetch object from database.
- fetchByCategorie() : int
- Fetch a mapping by Dolibarr category id (unique per entity).
- fetchByInstanceCatId() : int
- Fetch a mapping by (taler_instance, taler_category_id) (unique per entity).
- getLabelForList() : string
- Build a concise label for list contexts.
- getNomUrl() : string
- Build HTML link to the card page.
- update() : int
- Update record in database.
- upsert() : int
- Idempotent upsert helper respecting unique keys.
Properties
$datec
public
mixed
$datec
$element
public
string
$element
= 'talercategorymap'
$entity
public
mixed
$entity
$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), 'taler_instance' => array('type' => 'varchar(64)', 'label' => 'TalerInstance', 'visible' => 1, 'notnull' => 1, 'index' => 1, 'position' => 10, 'enabled' => '1'), 'taler_category_id' => array('type' => 'integer', 'label' => 'TalerCategoryId', 'visible' => 1, 'notnull' => 1, 'index' => 1, 'position' => 11, 'enabled' => '1'), 'taler_category_name' => array('type' => 'varchar(255)', 'label' => 'TalerCategoryName', 'visible' => 1, 'notnull' => 0, 'position' => 12, 'enabled' => '1'), 'fk_categorie' => array('type' => 'integer', 'label' => 'DolibarrCategory', 'visible' => 1, 'notnull' => 1, 'index' => 1, 'position' => 20, 'picto' => 'category', 'enabled' => '1'), 'note' => array('type' => 'varchar(255)', 'label' => 'Note', 'visible' => 1, 'notnull' => 0, 'position' => 30, 'enabled' => '1'), 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'visible' => -2, 'notnull' => 0, 'position' => 500), 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'visible' => -2, 'notnull' => 1, 'position' => 501))
$fk_categorie
public
mixed
$fk_categorie
$isextrafieldmanaged
public
int
$isextrafieldmanaged
= 0
$ismultientitymanaged
public
int|string
$ismultientitymanaged
= 1
$module
public
string
$module
= 'talerbarr'
$note
public
mixed
$note
$picto
public
string
$picto
= 'category'
$rowid
public
mixed
$rowid
$table_element
public
string
$table_element
= 'talerbarr_category_map'
$taler_category_id
public
mixed
$taler_category_id
$taler_category_name
public
mixed
$taler_category_name
$taler_instance
public
mixed
$taler_instance
$tms
public
mixed
$tms
Methods
__construct()
Constructor.
public
__construct(DoliDB $db) : mixed
Parameters
- $db : DoliDB
-
Database handler
create()
Create record in database.
public
create(User $user[, int $notrigger = 0 ]) : int
Parameters
- $user : User
-
User performing the action
- $notrigger : int = 0
-
1 = do not call triggers
Return values
int —0 if OK, <0 on error
delete()
Delete record from database.
public
delete(User $user[, int $notrigger = 0 ]) : int
Parameters
- $user : User
-
User performing the action
- $notrigger : int = 0
-
1 = do not call triggers
Return values
int —0 if OK, <0 on error
fetch()
Fetch object from database.
public
fetch(int $id[, string|null $ref = null ][, int $noextrafields = 1 ][, int $nolines = 1 ]) : int
Parameters
- $id : int
-
Rowid
- $ref : string|null = null
-
Optional reference
- $noextrafields : int = 1
-
1 = do not load extrafields
- $nolines : int = 1
-
1 = do not load lines
Return values
int —0 if OK, 0 if not found, <0 on error
fetchByCategorie()
Fetch a mapping by Dolibarr category id (unique per entity).
public
fetchByCategorie(int $fk_categorie) : int
Parameters
- $fk_categorie : int
-
Dolibarr category rowid
Return values
int —0 if loaded, 0 if not found, <0 on SQL error
fetchByInstanceCatId()
Fetch a mapping by (taler_instance, taler_category_id) (unique per entity).
public
fetchByInstanceCatId(string $instance, int $talerCategoryId) : int
Parameters
- $instance : string
-
Taler instance (username/tenant)
- $talerCategoryId : int
-
Taler category id
Return values
int —0 if loaded, 0 if not found, <0 on SQL error
getLabelForList()
Build a concise label for list contexts.
public
getLabelForList() : string
Return values
string —Label like "instance/id (name) → #fk_categorie"
getNomUrl()
Build HTML link to the card page.
public
getNomUrl([int $withpicto = 0 ][, string $option = '' ][, int $notooltip = 0 ][, string $morecss = '' ][, int|string $save_lastsearch_value = -1 ]) : string
Parameters
- $withpicto : int = 0
-
0=No picto, 1=Include picto+label, 2=Picto only
- $option : string = ''
-
'nolink' to return a span instead of a link
- $notooltip : int = 0
-
1=Disable tooltip
- $morecss : string = ''
-
Additional CSS classes on the or
- $save_lastsearch_value : int|string = -1
-
Pass-through for Dolibarr helpers
Return values
string —HTML
update()
Update record in database.
public
update(User $user[, int $notrigger = 0 ]) : int
Parameters
- $user : User
-
User performing the action
- $notrigger : int = 0
-
1 = do not call triggers
Return values
int —0 if OK, <0 on error
upsert()
Idempotent upsert helper respecting unique keys.
public
upsert(User $user, string $instance, int $talerCatId, int $fkCategorie[, string|null $talerCatName = null ][, string|null $note = null ]) : int
- If (entity, fk_categorie) exists, updates Taler fields.
- Else if (entity, instance, taler_category_id) exists, updates Dolibarr fields.
- Else inserts a new row.
Parameters
- $user : User
-
User performing the action
- $instance : string
-
Taler instance
- $talerCatId : int
-
Taler category id
- $fkCategorie : int
-
Dolibarr category rowid
- $talerCatName : string|null = null
-
Optional Taler category name
- $note : string|null = null
-
Optional free-form note
Return values
int —0 row id on success, <0 on error