Mos
class Mos extends DolibarrApi (View source)
API class for MO
Properties
| protected DoliDB | $db | from DolibarrApi | |
| Restler | $r | from DolibarrApi | |
| Mo | $mo |
Methods
Constructor
Check and convert a string depending on its type/name.
Filter properties that will be returned on object
Clean sensible object datas
Check access by user to a given resource
Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules
Function to forge a SQL criteria from a Generic filter string.
Get properties of a MO object
List Mos
Create MO object
Update MO
Delete MO
Produce and consume all
Produce and consume
Details
__construct()
Constructor
protected string|array<string, mixed>
_checkValForAPI(string $field, string|string[] $value, object $object)
Check and convert a string depending on its type/name.
protected object
_filterObjectProperties(object $object, string $properties)
Filter properties that will be returned on object
protected object
_cleanObjectDatas(object $object)
Clean sensible object datas
static protected bool
_checkAccessToResource(string $resource, int $resource_id = 0, string $dbtablename = '', string $feature2 = '', string $dbt_keyfield = 'fk_soc', string $dbt_select = 'rowid')
Check access by user to a given resource
protected bool|string
_checkFilters(string $sqlfilters, string $error = '')
Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules
static protected string
_forge_criteria_callback(string[] $matches)
Function to forge a SQL criteria from a Generic filter string.
Function no more used. Kept for backward compatibility with old APIs of modules
object
get(int $id)
Get properties of a MO object
Return an array with MO information
array
index(string $sortfield = "t.rowid", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $sqlfilters = '', string $properties = '')
List Mos
Get a list of MOs
int
post(array $request_data = null)
Create MO object
object
put(int $id, array $request_data = null)
Update MO
array
delete(int $id)
Delete MO
int
produceAndConsumeAll(int $id, array $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" ] }
int
produceAndConsume(int $id, array $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 } ] }