dolibarr  13.0.2
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')
 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

CUnits::__construct (   $db)

Constructor.

Parameters
DoliDb$dbDatabase handler

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

References db.

Member Function Documentation

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.

References $resql, code, db, and dol_syslog().

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

References $resql, db, and dol_syslog().

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

References $resql, code, and db.

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

References $resql, db, and dol_syslog().

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

Get unit from code.

Parameters
string$codecode of unit
string$mode0= id , short_label=Use short label as value, code=use code
Returns
int <0 if KO, Id of code if OK

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

References db, and dol_getIdFromCode().

CUnits::scaleOfUnitPow (   $id)

get scale of unit factor

Parameters
int$idid of unit in dictionary
Returns
float|int

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

References db.

Referenced by 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 404 of file cunits.class.php.

References price2num(), and scaleOfUnitPow().

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

References $resql, code, db, and dol_syslog().


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