CUnits
class CUnits extends CommonDict (View source)
Class of dictionary type of thirdparty (used by imports)
Properties
| DoliDB | $db | from CommonDict | |
| $error | from CommonDict | ||
| string[] | $errors | from CommonDict | |
| int | $id | from CommonDict | |
| ?int | $entity | from CommonDict | |
| ?string | $code | from CommonDict | |
| ?string | $label | from CommonDict | |
| ?int<0, 1> | $active | from CommonDict | |
| CUnits[] | $records | ||
| $libelle | |||
| string | $sortorder | ||
| string | $short_label | ||
| string | $unit_type | ||
| ?int | $scale |
Methods
Constructor
Create object into database
Load object in memory from database
Load list of objects in memory from the database.
Update object into database
Get unit from code
Unit converter
Get scale of unit factor
Details
__construct($db)
Constructor
@param DoliDB $db Database handler
create($user, int<0, 1> $notrigger = 0)
Create object into database
@param User $user User that create
fetch($id, string $code = '', $short_label = '', $unit_type = '')
Load object in memory from database
@param int $id Id of CUnit object to fetch (rowid)
CUnits[]|int
fetchAll(string $sortorder = '', string $sortfield = '', int $limit = 0, int $offset = 0, string|array<string, mixed> $filter = '', string $filtermode = 'AND')
Load list of objects in memory from the database.
update($user = null, int<0, 1> $notrigger = 0)
Update object into database
@param User $user User that modify
delete(User $user, $notrigger = 0)
Delete object in database
int|string
getUnitFromCode(string $code, string $mode = 'code', string $unit_type = '')
Get unit from code
float
unitConverter(float $value, int $fk_unit, int $fk_new_unit = 0)
Unit converter
float|int
scaleOfUnitPow(int $id)
Get scale of unit factor