dolibarr 21.0.0-alpha
CUnits Class Reference

Class of dictionary type of thirdparty (used by imports) More...

Inheritance diagram for CUnits:
Collaboration diagram for CUnits:

Public Member Functions

 __construct ($db)
 Constructor.
 
 create ($user, $notrigger=0)
 Create object into database.
 
 fetch ($id, $code='', $short_label='', $unit_type='')
 Load object in memory from database.
 
 fetchAll ($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
 Load list of objects in memory from the database.
 
 update ($user=null, $notrigger=0)
 Update object into database.
 
 delete ($user, $notrigger=0)
 Delete object in database.
 
 getUnitFromCode ($code, $mode='code', $unit_type='')
 Get unit from code.
 
 unitConverter ($value, $fk_unit, $fk_new_unit=0)
 Unit converter.
 
 scaleOfUnitPow ($id)
 Get scale of unit factor.
 

Detailed Description

Class of dictionary type of thirdparty (used by imports)

Definition at line 32 of file cunits.class.php.

Constructor & Destructor Documentation

◆ __construct()

CUnits::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 72 of file cunits.class.php.

Member Function Documentation

◆ create()

CUnits::create ( $user,
$notrigger = 0 )

Create object into database.

Parameters
User$userUser that create
int<0,1>$notrigger 0=launch triggers after, 1=disable triggers
Returns
int Return integer <0 if KO, Id of created object if OK

Definition at line 85 of file cunits.class.php.

References dol_syslog().

◆ delete()

CUnits::delete ( $user,
$notrigger = 0 )

Delete object in database.

Parameters
User$userUser that delete
int<0,1>$notrigger 0=launch triggers after, 1=disable triggers
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 400 of file cunits.class.php.

References dol_syslog().

◆ fetch()

CUnits::fetch ( $id,
$code = '',
$short_label = '',
$unit_type = '' )

Load object in memory from database.

Parameters
int$idId of CUnit object to fetch (rowid)
string$codeCode
string$short_labelShort Label ('g', 'kg', ...)
string$unit_typeUnit type ('size', 'surface', 'volume', 'weight', ...)
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 170 of file cunits.class.php.

◆ fetchAll()

CUnits::fetchAll ( $sortorder = '',
$sortfield = '',
$limit = 0,
$offset = 0,
$filter = '',
$filtermode = 'AND' )

Load list of objects in memory from the database.

Parameters
string$sortorderSort Order
string$sortfieldSort field
int$limitLimit
int$offsetOffset
string|array<string,mixed>$filter Filter USF
string$filtermodeFilter mode (AND or OR)
Returns
CUnits[]|int int <0 if KO, array of pages if OK

Definition at line 234 of file cunits.class.php.

References dol_syslog(), and forgeSQLFromUniversalSearchCriteria().

◆ getUnitFromCode()

CUnits::getUnitFromCode ( $code,
$mode = 'code',
$unit_type = '' )

Get unit from code.

Parameters
string$codecode of unit
string$mode0= id , short_label=Use short label as value, code=use code
string$unit_typeweight,size,surface,volume,qty,time...
Returns
int|string Return integer <0 if KO, Id of code if OK (or $code if $mode is different from '', 'short_label' or 'code')

Definition at line 438 of file cunits.class.php.

References dol_getIdFromCode().

◆ scaleOfUnitPow()

CUnits::scaleOfUnitPow ( $id)

Get scale of unit factor.

Parameters
int$idId of unit in dictionary
Returns
float|int Scale of unit

Definition at line 480 of file cunits.class.php.

Referenced by unitConverter().

◆ unitConverter()

CUnits::unitConverter ( $value,
$fk_unit,
$fk_new_unit = 0 )

Unit converter.

Parameters
float$valuevalue to convert
int$fk_unitcurrent unit id of value
int$fk_new_unitthe id of unit to convert in
Returns
float

Definition at line 453 of file cunits.class.php.

References price2num(), and scaleOfUnitPow().

◆ update()

CUnits::update ( $user = null,
$notrigger = 0 )

Update object into database.

Parameters
User$userUser that modify
int<0,1>$notrigger 0=launch triggers after, 1=disable triggers
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 328 of file cunits.class.php.

References dol_syslog().


The documentation for this class was generated from the following file: