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

Protected Member Functions

 _cleanObjectDatas ($object)
 Clean sensible object datas. More...
 
- Protected Member Functions inherited from DolibarrApi
 _cleanObjectDatas ($object)
 Executed method when API is called without parameter. More...
 
 _checkFilters ($sqlfilters)
 Return if a $sqlfilters parameter is valid. More...
 

Private Member Functions

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

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 user access to a resource. More...
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria. More...
 

Detailed Description

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

Member Function Documentation

Orders::_cleanObjectDatas (   $object)
protected

Clean sensible object datas.

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

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

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

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

Get properties of an order object.

Return an array with order informations

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
array|mixed data without useless information
Exceptions
RestException

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

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

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

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

Referenced by post().

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

Close an order (Classify it as "Delivered")

Parameters
int$idOrder ID
int$notriggerDisabled triggers

POST {id}/close

Returns
int

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

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

Orders::createOrderFromProposal (   $proposalid)

Create an order using an existing proposal.

Parameters
int$proposalidId of the proposal

POST /createfromproposal/{proposalid}

Returns
int
Exceptions
RestException400
RestException401
RestException404
RestException405

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

References _cleanObjectDatas(), and db.

Orders::delete (   $id)

Delete order.

Parameters
int$idOrder ID
Returns
array

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

References DolibarrApi\_checkAccessToResource().

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).

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

Returns
int
Exceptions
RestException401
RestException404
RestException500

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

References DolibarrApi\_checkAccessToResource().

Orders::deleteLine (   $id,
  $lineid 
)

Delete a line to given order.

Parameters
int$idId of order to update
int$lineidId of line to delete

DELETE {id}/lines/{lineid}

Returns
int
Exceptions
RestException401
RestException404

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

References DolibarrApi\_checkAccessToResource().

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

Get properties of an order object by id.

Return an array with order informations

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

References _fetch().

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

Get properties of an order object by ref.

Return an array with order informations

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

GET ref/{ref}

Exceptions
RestException

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

References _fetch().

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

Get properties of an order object by ref_ext.

Return an array with order informations

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

GET ref_ext/{ref_ext}

Exceptions
RestException

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

References _fetch().

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

Get contacts of given order.

Return an array with contact informations

Parameters
int$idID of order
string$typeType of the contact (BILLING, SHIPPING, CUSTOMER)

GET {id}/contacts

Returns
array data without useless information
Exceptions
RestException

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

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

Orders::getLines (   $id)

Get lines of an order.

Parameters
int$idId of order

GET {id}/lines

Returns
int

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

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

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

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') { /^[0-9,]*$/i}
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
Returns
array Array of order objects
Exceptions
RestException404 Not found
RestException503 Error

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

References DolibarrApi\_checkFilters(), _cleanObjectDatas(), db, and dol_syslog().

Orders::post (   $request_data = null)

Create a sale order.

Exemple: { "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 243 of file api_orders.class.php.

References _validate().

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)

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

Returns
int
Exceptions
RestException401
RestException404

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

References DolibarrApi\_checkAccessToResource().

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

Add a line to given order.

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

POST {id}/lines

Returns
int

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

References DolibarrApi\_checkAccessToResource().

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
int

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

References DolibarrApi\_checkAccessToResource().

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

PUT {id}/lines/{lineid}

Returns
array|bool

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

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

Orders::reopen (   $id)

Tag the order as validated (opened)

Function used when order is reopend after being closed.

Parameters
int$idId of the order

POST {id}/reopen

Returns
int
Exceptions
RestException304
RestException400
RestException401
RestException404
RestException405

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

Orders::setinvoiced (   $id)

Classify the order as invoiced.

Could be also called setbilled

Parameters
int$idId of the order

POST {id}/setinvoiced

Returns
int
Exceptions
RestException400
RestException401
RestException404
RestException405

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

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

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)

POST {id}/settodraft

Returns
array

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

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

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

POST {id}/validate

Exceptions
RestException304
RestException401
RestException404
RestException500
Returns
array

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

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


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