dolibarr 20.0.0
Orders Class Reference
Inheritance diagram for Orders:
Collaboration diagram for Orders:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id, $contact_list=1)
 Get properties of an order object by id.
 
 getByRef ($ref, $contact_list=1)
 Get properties of an order object by ref.
 
 getByRefExt ($ref_ext, $contact_list=1)
 Get properties of an order object by ref_ext.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $thirdparty_ids='', $sqlfilters='', $sqlfilterlines='', $properties='')
 List orders.
 
 post ($request_data=null)
 Create a sale order.
 
 getLines ($id)
 Get lines of an order.
 
 postLine ($id, $request_data=null)
 Add a line to given order.
 
 putLine ($id, $lineid, $request_data=null)
 Update a line to given order.
 
 deleteLine ($id, $lineid)
 Delete a line of a given order.
 
 getContacts ($id, $type='')
 Get contacts of given order.
 
 postContact ($id, $contactid, $type)
 Add a contact type of given order.
 
 deleteContact ($id, $contactid, $type)
 Unlink a contact type of given order.
 
 put ($id, $request_data=null)
 Update order general fields (won't touch lines of order)
 
 delete ($id)
 Delete order.
 
 validate ($id, $idwarehouse=0, $notrigger=0)
 Validate an order.
 
 reopen ($id)
 Tag the order as validated (opened)
 
 setinvoiced ($id)
 Classify the order as invoiced.
 
 close ($id, $notrigger=0)
 Close an order (Classify it as "Delivered")
 
 settodraft ($id, $idwarehouse=-1)
 Set an order to draft.
 
 createOrderFromProposal ($proposalid)
 Create an order using an existing proposal.
 
 getOrderShipments ($id)
 Get the shipments of an order.
 
 createOrderShipment ($id, $warehouse_id)
 Create the shipment of an order.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanObjectDatas ($object)
 Clean sensible object datas.
 
- 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

 _fetch ($id, $ref='', $ref_ext='', $contact_list=1)
 Get properties of an order object.
 
 _validate ($data)
 Validate fields before create or update object.
 

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 29 of file api_orders.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Orders::_cleanObjectDatas ( $object)
protected

Clean sensible object datas.

Parameters
Object$objectObject to clean
Returns
Object Object with cleaned properties

Reimplemented from DolibarrApi.

Definition at line 1090 of file api_orders.class.php.

References $object.

Referenced by _fetch(), close(), createOrderFromProposal(), getContacts(), getLines(), getOrderShipments(), index(), putLine(), setinvoiced(), settodraft(), and validate().

◆ _fetch()

Orders::_fetch ( $id,
$ref = '',
$ref_ext = '',
$contact_list = 1 )
private

Get properties of an order object.

Return an array with order information

Parameters
int$idID of order
string$refRef of object
string$ref_extExternal reference of object
int$contact_list0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
Returns
Object Object with cleaned properties
Exceptions
RestException

Definition at line 119 of file api_orders.class.php.

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

Referenced by get(), getByRef(), and getByRefExt().

◆ _validate()

Orders::_validate ( $data)
private

Validate fields before create or update object.

Parameters
array$dataArray with data to verify
Returns
array
Exceptions
RestException

Definition at line 1112 of file api_orders.class.php.

Referenced by post().

◆ close()

Orders::close ( $id,
$notrigger = 0 )

Close an order (Classify it as "Delivered")

Parameters
int$idOrder ID
int$notriggerDisabled triggers
Returns
Object Object with cleaned properties

@url POST {id}/close

Definition at line 861 of file api_orders.class.php.

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

◆ createOrderFromProposal()

Orders::createOrderFromProposal ( $proposalid)

Create an order using an existing proposal.

Parameters
int$proposalidId of the proposal
Returns
Object Object with cleaned properties

@url POST /createfromproposal/{proposalid}

Exceptions
RestException400
RestException401
RestException404
RestException405

Definition at line 956 of file api_orders.class.php.

References _cleanObjectDatas().

◆ createOrderShipment()

Orders::createOrderShipment ( $id,
$warehouse_id )

Create the shipment of an order.

Parameters
int$idId of the order
int$warehouse_idId of a warehouse

@url POST {id}/shipment/{warehouse_id}

Returns
int
Exceptions
RestException401
RestException404
RestException500 System error

Definition at line 1054 of file api_orders.class.php.

◆ delete()

Orders::delete ( $id)

Delete order.

Parameters
int$idOrder ID
Returns
array

Definition at line 685 of file api_orders.class.php.

References DolibarrApi\_checkAccessToResource().

◆ deleteContact()

Orders::deleteContact ( $id,
$contactid,
$type )

Unlink a contact type of given order.

Parameters
int$idId of order to update
int$contactidId of contact
string$typeType of the contact (BILLING, SHIPPING, CUSTOMER).

@url DELETE {id}/contact/{contactid}/{type}

Returns
array
Exceptions
RestException401
RestException404
RestException500 System error

Definition at line 590 of file api_orders.class.php.

References DolibarrApi\_checkAccessToResource().

◆ deleteLine()

Orders::deleteLine ( $id,
$lineid )

Delete a line of a given order.

Parameters
int$idId of order to update
int$lineidId of line to delete
Returns
Object Object with cleaned properties

@url DELETE {id}/lines/{lineid}

Exceptions
RestException401
RestException404

Definition at line 473 of file api_orders.class.php.

References DolibarrApi\_checkAccessToResource().

◆ get()

Orders::get ( $id,
$contact_list = 1 )

Get properties of an order object by id.

Return an array with order information

Parameters
int$idID of order
int$contact_list0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
Returns
array|mixed data without useless information
Exceptions
RestException

Definition at line 65 of file api_orders.class.php.

References _fetch().

◆ getByRef()

Orders::getByRef ( $ref,
$contact_list = 1 )

Get properties of an order object by ref.

Return an array with order information

Parameters
string$refRef of object
int$contact_list0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
Returns
array|mixed data without useless information

@url GET ref/{ref}

Exceptions
RestException

Definition at line 83 of file api_orders.class.php.

References _fetch().

◆ getByRefExt()

Orders::getByRefExt ( $ref_ext,
$contact_list = 1 )

Get properties of an order object by ref_ext.

Return an array with order information

Parameters
string$ref_extExternal reference of object
int$contact_list0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
Returns
array|mixed data without useless information

@url GET ref_ext/{ref_ext}

Exceptions
RestException

Definition at line 101 of file api_orders.class.php.

References _fetch().

◆ getContacts()

Orders::getContacts ( $id,
$type = '' )

Get contacts of given order.

Return an array with contact information

Parameters
int$idID of order
string$typeType of the contact (BILLING, SHIPPING, CUSTOMER)
Returns
Object Object with cleaned properties

@url GET {id}/contacts

Exceptions
RestException

Definition at line 509 of file api_orders.class.php.

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

◆ getLines()

Orders::getLines ( $id)

Get lines of an order.

Parameters
int$idId of order

@url GET {id}/lines

Returns
array

Definition at line 306 of file api_orders.class.php.

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

◆ getOrderShipments()

Orders::getOrderShipments ( $id)

Get the shipments of an order.

Parameters
int$idId of the order

@url GET {id}/shipment

Returns
array
Exceptions
RestException401
RestException404
RestException500 System error

Definition at line 998 of file api_orders.class.php.

References _cleanObjectDatas(), and dol_syslog().

◆ index()

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

List orders.

Get a list of orders

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$thirdparty_idsThirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
string$sqlfilterlinesOther criteria to filter answers separated by a comma. Syntax example "(tl.fk_product:=:'17') and (tl.price:<:'250')"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
Returns
array Array of order objects
Exceptions
RestException404 Not found
RestException503 Error

Definition at line 166 of file api_orders.class.php.

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

◆ post()

Orders::post ( $request_data = null)

Create a sale order.

Example: { "socid": 2, "date": 1595196000, "type": 0, "lines": [{ "fk_product": 2, "qty": 1 }] }

Parameters
array$request_dataRequest data
Returns
int ID of order

Definition at line 265 of file api_orders.class.php.

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

◆ postContact()

Orders::postContact ( $id,
$contactid,
$type )

Add a contact type of given order.

Parameters
int$idId of order to update
int$contactidId of contact to add
string$typeType of the contact (BILLING, SHIPPING, CUSTOMER)
Returns
array

@url POST {id}/contact/{contactid}/{type}

Exceptions
RestException401
RestException404

Definition at line 542 of file api_orders.class.php.

References DolibarrApi\_checkAccessToResource().

◆ postLine()

Orders::postLine ( $id,
$request_data = null )

Add a line to given order.

Parameters
int$idId of order to update
array$request_dataOrderLine data

@url POST {id}/lines

Returns
int

Definition at line 338 of file api_orders.class.php.

References DolibarrApi\_checkAccessToResource(), and sanitizeVal().

◆ put()

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

Update order general fields (won't touch lines of order)

Parameters
int$idId of order to update
array$request_dataDatas
Returns
Object Object with cleaned properties

Definition at line 632 of file api_orders.class.php.

References DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValForAPI(), and sanitizeVal().

◆ putLine()

Orders::putLine ( $id,
$lineid,
$request_data = null )

Update a line to given order.

Parameters
int$idId of order to update
int$lineidId of line to update
array$request_dataOrderLine data
Returns
Object|false Object with cleaned properties

@url PUT {id}/lines/{lineid}

Definition at line 405 of file api_orders.class.php.

References DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), and sanitizeVal().

◆ reopen()

Orders::reopen ( $id)

Tag the order as validated (opened)

Function used when order is reopend after being closed.

Parameters
int$idId of the order

@url POST {id}/reopen

Returns
int
Exceptions
RestException304
RestException400
RestException401
RestException404
RestException405

Definition at line 784 of file api_orders.class.php.

◆ setinvoiced()

Orders::setinvoiced ( $id)

Classify the order as invoiced.

Could be also called setbilled

Parameters
int$idId of the order
Returns
Object Object with cleaned properties

@url POST {id}/setinvoiced

Exceptions
RestException400
RestException401
RestException404
RestException405

Definition at line 820 of file api_orders.class.php.

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

◆ settodraft()

Orders::settodraft ( $id,
$idwarehouse = -1 )

Set an order to draft.

Parameters
int$idOrder ID
int$idwarehouseWarehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on)
Returns
Object Object with cleaned properties

@url POST {id}/settodraft

Definition at line 906 of file api_orders.class.php.

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

◆ validate()

Orders::validate ( $id,
$idwarehouse = 0,
$notrigger = 0 )

Validate an order.

If you get a bad value for param notrigger check, provide this in body { "idwarehouse": 0, "notrigger": 0 }

Parameters
int$idOrder ID
int$idwarehouseWarehouse ID
int$notrigger1=Does not execute triggers, 0= execute triggers
Returns
Object Object with cleaned properties

@url POST {id}/validate

Exceptions
RestException304
RestException401
RestException404
RestException500 System error

Definition at line 733 of file api_orders.class.php.

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


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