class CustomObject extends CrudObject (View source)

CustomObject class

Properties

string $element from CrudObject
string $table_element from CrudObject
array $fetch_fields from CrudObject
array $date_fields from CrudObject
string $pk_name from CrudObject
string $ref_field_name from CrudObject
array $rows from CrudObject
string $triggers_prefix from CrudObject
string $picto
array $tooltip_details
string $doc_title
array $doc_lines
string $card_url
protected string $modulepart

Methods

__construct()

Constructor

$this
setTableName($table_name)

Set table name

int
create(array $data, int $notrigger)

Create object into database

int
fetch(int $id, string $ref = '')

Load object in memory from database

int
fetchWhere(string $where)

Load object in memory from database (wrapper for fetchAll function)

int
fetchAll(string $where = '')

Load all object entries in memory from database

int
update(array $data, int $notrigger)

Update object into database

int
updateWhere(array $data, string $where, int $notrigger = 1)

Update row(s) into database (wrapper for updateAll function)

int
updateAll(array $data, string $where = '', int $notrigger = 1)

Update all object rows into database

int
delete(int $notrigger)

Delete object in database

int
deleteWhere(string $where, int $notrigger = 1)

Delete row(s) in database (wrapper for deleteAll function)

int
deleteAll(string $where = '', int $notrigger = 1)

Delete all object rows in database

int
deleteAllObjectLinked()

Delete all links between an object $this

string
escape($value)

Escape field value

int
run_triggers($action_suffix)

Run Dolibarr triggers (from other modules)

$this
clone($obj)

Clone an object

array
getExtraFields()

Returns object extrafields as a ['label' => 'value'] array

string
getNextNumRef(string $const_name_prefix = '', string $model_name = '', Societe $soc = '')

Returns the reference to the following non used object depending on the active numbering model defined into MODULE_RIGHTS_CLASS_ADDON

string
getNomUrl(int $withpicto, string $title = '')

Return clicable name (with picto eventually)

string
getLibStatut(int $mode)

Return label of status of object (draft, validated, .

string
getImage($default_image)

Get object image(s)

int
generateDocument(string $model)

Create a document onto disk according to template module.

int
deleteDocument()

Delete document from disk.

Details

__construct()

Constructor

$this setTableName($table_name)

Set table name

Parameters

$table_name table name

Return Value

$this

int create(array $data, int $notrigger)

Create object into database

Parameters

array $data array, e.: array('my_field_name' => 'my_field_value', 'second_field_name' => 'second_field_value')
int $notrigger 0=launch triggers after, 1=disable triggers

Return Value

int <0 if KO, Id of created object if OK

int fetch(int $id, string $ref = '')

Load object in memory from database

Parameters

int $id object Id
string $ref object ref

Return Value

int <0 if KO, >0 if OK

int fetchWhere(string $where)

Load object in memory from database (wrapper for fetchAll function)

Parameters

string $where where clause (without 'WHERE')

Return Value

int <0 if KO, >0 if OK

int fetchAll(string $where = '')

Load all object entries in memory from database

Parameters

string $where where clause (without 'WHERE')

Return Value

int <0 if KO, >0 if OK

int update(array $data, int $notrigger)

Update object into database

Parameters

array $data array, e.: array('my_field_name' => 'my_field_value', 'second_field_name' => 'second_field_value')
int $notrigger 0=launch triggers after, 1=disable triggers

Return Value

int <0 if KO, >0 if OK

int updateWhere(array $data, string $where, int $notrigger = 1)

Update row(s) into database (wrapper for updateAll function)

Parameters

array $data array, e.: array('my_field_name' => 'my_field_value', 'second_field_name' => 'second_field_value')
string $where where clause (without 'WHERE')
int $notrigger 0=launch triggers after, 1=disable triggers

Return Value

int <0 if KO, >0 if OK

int updateAll(array $data, string $where = '', int $notrigger = 1)

Update all object rows into database

Parameters

array $data array, e.: array('my_field_name' => 'my_field_value', 'second_field_name' => 'second_field_value')
string $where where clause (without 'WHERE')
int $notrigger 0=launch triggers after, 1=disable triggers

Return Value

int <0 if KO, >0 if OK

int delete(int $notrigger)

Delete object in database

Parameters

int $notrigger 0=launch triggers after, 1=disable triggers

Return Value

int <0 if KO, >0 if OK

int deleteWhere(string $where, int $notrigger = 1)

Delete row(s) in database (wrapper for deleteAll function)

Parameters

string $where where clause (without 'WHERE')
int $notrigger 0=launch triggers after, 1=disable triggers

Return Value

int <0 if KO, >0 if OK

int deleteAll(string $where = '', int $notrigger = 1)

Delete all object rows in database

Parameters

string $where where clause (without 'WHERE')
int $notrigger 0=launch triggers after, 1=disable triggers

Return Value

int <0 if KO, >0 if OK

protected int deleteAllObjectLinked()

Delete all links between an object $this

Return Value

int <0 if KO, >0 if OK

protected string escape($value)

Escape field value

Parameters

$value field value

Return Value

string escaped value

protected int run_triggers($action_suffix)

Run Dolibarr triggers (from other modules)

Parameters

$action_suffix action suffix

Return Value

int errors number

$this clone($obj)

Clone an object

Parameters

$obj object to clone from

Return Value

$this

array getExtraFields()

Returns object extrafields as a ['label' => 'value'] array

Return Value

array Extrafields array

string getNextNumRef(string $const_name_prefix = '', string $model_name = '', Societe $soc = '')

Returns the reference to the following non used object depending on the active numbering model defined into MODULE_RIGHTS_CLASS_ADDON

Parameters

string $const_name_prefix Constant name prefix
string $model_name Numbering model name
Societe $soc Object thirdparty

Return Value

string Reference

string getNomUrl(int $withpicto, string $title = '')

Return clicable name (with picto eventually)

Parameters

int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
string $title Tooltip title

Return Value

string Chain with URL

string getLibStatut(int $mode)

Return label of status of object (draft, validated, .

..)

Parameters

int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto

Return Value

string Label

string getImage($default_image)

Get object image(s)

Parameters

$default_image Default image to show if no image is available

Return Value

string Object image(s) HTML output

int generateDocument(string $model)

Create a document onto disk according to template module.

Parameters

string $model Force template to use ('' to not force)

Return Value

int 0 if KO, 1 if OK

int deleteDocument()

Delete document from disk.

Return Value

int 0 if KO, 1 if OK