dolibarr 23.0.3
Mos Class Reference
Inheritance diagram for Mos:
Collaboration diagram for Mos:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id)
 Get properties of a MO object.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $sqlfilters='', $properties='')
 List Mos.
 
 post ($request_data=null)
 Create MO object.
 
 put ($id, $request_data=null)
 Update MO.
 
 delete ($id)
 Delete MO.
 
 produceAndConsumeAll ($id, $request_data=null)
 Produce and consume all.
 
 produceAndConsume ($id, $request_data=null)
 Produce and consume.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanObjectDatas ($object)
 Clean sensible object datas @phpstan-template T.
 
- Protected Member Functions inherited from DolibarrApi
 _checkValForAPI ($field, $value, $object)
 Check and convert a string depending on its type/name.
 
 _filterObjectProperties ($object, $properties)
 Filter properties that will be returned on object.
 
 _checkFilters ($sqlfilters, &$error='')
 Return if a $sqlfilters parameter is valid Function no more used.
 

Private Member Functions

 _validate ($data)
 Validate fields before creating or updating an object.
 
 checkRefNumbering ()
 Validate the ref field and get the next Number if it's necessary.
 

Additional Inherited Members

- Static Protected Member Functions inherited from DolibarrApi
static _checkAccessToResource ($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
 Check access by user to a given resource.
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria from a Generic filter string.
 

Detailed Description

Definition at line 38 of file api_mos.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Mos::_cleanObjectDatas ( $object)
protected

Clean sensible object datas @phpstan-template T.

Parameters
Object$objectObject to clean
Returns
Object Object with cleaned properties @phpstan-param T $object @phpstan-return T

Reimplemented from DolibarrApi.

Definition at line 930 of file api_mos.class.php.

References $object, and _cleanObjectDatas().

Referenced by _cleanObjectDatas(), get(), and index().

◆ _validate()

Mos::_validate ( $data)
private

Validate fields before creating or updating an object.

Parameters
?array<null|int|float|string>$data Data to validate
Returns
array<string,null|int|float|string>
Exceptions
RestException

Definition at line 993 of file api_mos.class.php.

Referenced by post().

◆ checkRefNumbering()

Mos::checkRefNumbering ( )
private

Validate the ref field and get the next Number if it's necessary.

Returns
void

Definition at line 1013 of file api_mos.class.php.

Referenced by post(), and put().

◆ delete()

Mos::delete ( $id)

Delete MO.

Parameters
int$idMO ID
Returns
array @phan-return array<string,array{code:int,message:string}> @phpstan-return array<string,array{code:int,message:string}>

Definition at line 277 of file api_mos.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ get()

Mos::get ( $id)

Get properties of a MO object.

Return an array with MO information

Parameters
int$idID of MO
Returns
Object Object with cleaned properties

@url GET {id}

Exceptions
RestException

Definition at line 66 of file api_mos.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

◆ index()

Mos::index ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$sqlfilters = '',
$properties = '' )

List Mos.

Get a list of MOs

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
Returns
array Array of order objects @phan-return Mo[] @phpstan-return Mo[]
Exceptions
RestException

Definition at line 102 of file api_mos.class.php.

References _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), and forgeSQLFromUniversalSearchCriteria().

◆ post()

Mos::post ( $request_data = null)

Create MO object.

Parameters
array$request_dataRequest datas @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
int ID of MO
Exceptions
RestException

Definition at line 187 of file api_mos.class.php.

References DolibarrApi\_checkValForAPI(), _validate(), checkRefNumbering(), and sanitizeVal().

◆ produceAndConsume()

Mos::produceAndConsume ( $id,
$request_data = null )

Produce and consume.

Example: { "inventorylabel": "Produce and consume using API", "inventorycode": "PRODUCEAPI-YY-MM-DD", "autoclose": 1, "arraytoconsume": [ { "objectid": "123", – rowid of MoLine "qty": "2", "fk_warehouse": "789" – "0" or empty, if stock change is disabled. } ], "arraytoproduce": [ { "objectid": "456", – rowid of MoLine "qty": "1", "fk_warehouse": "789", "pricetoproduce": "12.3" – optional } ] }

Parameters
int$idID of state
array$request_dataRequest datas @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url POST {id}/produceandconsume

Returns
int ID of MO

Definition at line 714 of file api_mos.class.php.

References $id, dol_now(), and dol_syslog().

◆ produceAndConsumeAll()

Mos::produceAndConsumeAll ( $id,
$request_data = null )

Produce and consume all.

  • If arraytoconsume and arraytoproduce are both filled, this fill an empty MO with the lines to consume and produce and record the consumption and production.
  • If arraytoconsume and arraytoproduce are not provided, it consumes and produces all existing lines.

Example: { "inventorylabel": "Produce and consume using API", "inventorycode": "PRODUCEAPI-YY-MM-DD", "autoclose": 1, "arraytoconsume": [ "objectid": 123, – ID_of_product "qty": "2", "fk_warehouse": "789" ], "arraytoproduce": [ "objectid": 456, – ID_of_product "qty": "1", "fk_warehouse": "789" ] }

Parameters
int$idID of state
array$request_dataRequest datas @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url POST {id}/produceandconsumeall

Returns
int ID of MO

Definition at line 336 of file api_mos.class.php.

References $id, dol_now(), dol_syslog(), and sanitizeVal().

◆ put()

Mos::put ( $id,
$request_data = null )

Update MO.

Parameters
int$idId of MO to update
array$request_dataDatas @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
Object Updated object

Definition at line 225 of file api_mos.class.php.

References $id, DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValForAPI(), checkRefNumbering(), and sanitizeVal().


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