dolibarr 18.0.6
CUnits Class Reference

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

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, array $filter=array(), $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 28 of file cunits.class.php.

Constructor & Destructor Documentation

◆ __construct()

CUnits::__construct ( $db)

Constructor.

Parameters
DoliDb$dbDatabase handler

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

Member Function Documentation

◆ create()

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

Create object into database.

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

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

References dol_syslog().

◆ delete()

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

Delete object in database.

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

Definition at line 389 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 <0 if KO, >0 if OK

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

◆ fetchAll()

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

Load list of objects in memory from the database.

Parameters
string$sortorderSort Order
string$sortfieldSort field
int$limitlimit
int$offsetOffset
array$filterFilter array. Example array('field'=>'valueforlike', 'customurl'=>...)
string$filtermodeFilter mode (AND or OR)
Returns
array|int int <0 if KO, array of pages if OK

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

References dol_syslog().

◆ 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 <0 if KO, Id of code if OK

Definition at line 428 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 474 of file cunits.class.php.

Referenced by unitConverter().

◆ unitConverter()

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

Unit converter.

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

Definition at line 447 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$notrigger0=launch triggers after, 1=disable triggers
Returns
int <0 if KO, >0 if OK

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

References dol_syslog().


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