dolibarr  16.0.5
Public Member Functions | List of all members
CUnits Class Reference

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

Public Member Functions

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

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 69 of file cunits.class.php.

References db.

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 82 of file cunits.class.php.

◆ 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 387 of file cunits.class.php.

◆ 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 168 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 234 of file cunits.class.php.

◆ 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 426 of file cunits.class.php.

◆ 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 472 of file cunits.class.php.

◆ 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 445 of file cunits.class.php.

◆ 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 314 of file cunits.class.php.


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