|
dolibarr 25.0.0-alpha
|


Public Member Functions | |
| __construct () | |
| Constructor. | |
| get ($id) | |
| Get properties of a supplier order object. | |
| index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $thirdparty_ids='', $product_ids='', $status='', $sqlfilters='', $sqlfilterlines='', $properties='', $pagination_data=false) | |
| List orders. | |
| post ($request_data=null) | |
| Create supplier order object. | |
| put ($id, $request_data=null) | |
| Update supplier order. | |
| postLine ($id, $request_data=null) | |
| Add a line to a given supplier order. | |
| getLine ($id, $lineid) | |
| Get one supplier order line after checking access to its parent. | |
| putLine ($id, $lineid, $request_data=null) | |
| Update selected fields of a draft supplier order line. | |
| deleteLine ($id, $lineid) | |
| Deletes a line of a given draft supplier order. | |
| getContacts ($id, $source, $type='') | |
| Get contacts of given supplier order. | |
| postContact ($id, $contactid, $type, $source) | |
| Add a contact type of given supplier order. | |
| deleteContact ($id, $contactid, $type, $source) | |
| Unlink a contact type of given supplier order. | |
| delete ($id) | |
| Delete supplier order. | |
| validate ($id, $idwarehouse=0, $notrigger=0) | |
| Validate an order. | |
| settodraft ($id) | |
| Set a validated or approved order back to draft. | |
| approve ($id, $idwarehouse=0, $secondlevel=0) | |
| Approve an order. | |
| refuse ($id, $comment='') | |
| Refuse a validated order that is waiting for approval. | |
| makeOrder ($id, $date, $method, $comment='') | |
| Sends an order to the vendor. | |
| cancel ($id, $comment='') | |
| Cancel an approved order that has not been sent to the vendor yet. | |
| receiveOrder ($id, $closeopenorder, $comment, $lines) | |
| Receives the order, dispatches products. | |
Public Member Functions inherited from DolibarrApi | |
| __construct ($db, $cachedir='', $refreshCache=false) | |
| Constructor. | |
Protected Member Functions | |
| prepareLineUpdate ($line, $request_data) | |
| Prepare a partial update without changing the original line or writing data. | |
| loadOrderForOperation ($id) | |
| Load an authorised order without sanitising its live database handle. | |
| loadLineForOperation ($id, $lineid) | |
| Load the complete line after checking its parent and ownership. | |
| _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. | |
| _checkValExtrafieldsForAPI ($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 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', $parenttableforentity='') |
| Check access by user to a given resource. | |
| static | _forge_criteria_callback ($matches) |
| Function to forge a SQL criteria from a Generic filter string. | |
Definition at line 35 of file api_supplier_orders.class.php.
|
protected |
Clean sensible object datas @phpstan-template T.
| Object | $object | Object to clean |
Reimplemented from DolibarrApi.
Definition at line 1292 of file api_supplier_orders.class.php.
References $object.
|
private |
Validate fields before create or update object.
| ?array<string,string> | $data Data to validate |
| RestException |
Definition at line 1314 of file api_supplier_orders.class.php.
Referenced by post().
| SupplierOrders::approve | ( | $id, | |
| $idwarehouse = 0, | |||
| $secondlevel = 0 ) |
Approve an order.
| int | $id | Order ID |
| int | $idwarehouse | Warehouse ID |
| int | $secondlevel | 1=Does not execute triggers, 0= execute triggers |
@url POST {id}/approve
FIXME An error 403 is returned if the request has an empty body. Error message: "Forbidden: Content type `text/plain` is not supported." Workaround: send this in the body { "idwarehouse": 0, "secondlevel": 0 }
Definition at line 979 of file api_supplier_orders.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
| SupplierOrders::cancel | ( | $id, | |
| $comment = '' ) |
Cancel an approved order that has not been sent to the vendor yet.
| int | $id | Order ID |
| string | $comment | Reason of the cancellation, added to the agenda event {@required false} |
@url POST {id}/cancel
| RestException | 403 Not allowed |
| RestException | 404 Not found |
| RestException | 405 Order is not approved |
| RestException | 500 Error |
FIXME An error 403 is returned if the request has an empty body. Error message: "Forbidden: Content type `text/plain` is not supported." Workaround: send this in the body { "comment": "" }
Definition at line 1153 of file api_supplier_orders.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and CommandeFournisseur\STATUS_ACCEPTED.
| SupplierOrders::delete | ( | $id | ) |
Delete supplier order.
| int | $id | Supplier order ID |
Definition at line 811 of file api_supplier_orders.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
| SupplierOrders::deleteContact | ( | $id, | |
| $contactid, | |||
| $type, | |||
| $source ) |
Unlink a contact type of given supplier order.
| int | $id | Id of supplier order to update |
| int | $contactid | Id of contact/user to add |
| string | $type | Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...). |
| string | $source | Source of the contact (internal, external). |
@url DELETE {id}/contact/{contactid}/{type}/{source}
| RestException | 401 |
| RestException | 404 |
| RestException | 500 System error |
Definition at line 758 of file api_supplier_orders.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
| SupplierOrders::deleteLine | ( | $id, | |
| $lineid ) |
Deletes a line of a given draft supplier order.
A line that has already been received cannot be deleted.
| int | $id | Id of supplier order |
| int | $lineid | Id of the line to delete |
@url DELETE {id}/lines/{lineid}
| RestException | 400 Bad parameters |
| RestException | 403 Not allowed |
| RestException | 404 Not found |
| RestException | 405 Error |
Definition at line 521 of file api_supplier_orders.class.php.
References $id, loadLineForOperation(), and CommandeFournisseur\STATUS_DRAFT.
| SupplierOrders::get | ( | $id | ) |
Get properties of a supplier order object.
Return an array with supplier order information
| int | $id | ID of supplier order |
| RestException |
Definition at line 71 of file api_supplier_orders.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().
| SupplierOrders::getContacts | ( | $id, | |
| $source, | |||
| $type = '' ) |
Get contacts of given supplier order.
Return an array with contact information
| int | $id | ID of supplier order |
| string | $source | Source of the contact (internal, external, all). |
| string | $type | Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...) |
@url GET {id}/contacts
| RestException |
Definition at line 658 of file api_supplier_orders.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
| SupplierOrders::getLine | ( | $id, | |
| $lineid ) |
Get one supplier order line after checking access to its parent.
| int | $id | Supplier order ID |
| int | $lineid | Line ID |
Definition at line 434 of file api_supplier_orders.class.php.
References $id, _cleanObjectDatas(), and loadLineForOperation().
| SupplierOrders::index | ( | $sortfield = "t.rowid", | |
| $sortorder = 'ASC', | |||
| $limit = 100, | |||
| $page = 0, | |||
| $thirdparty_ids = '', | |||
| $product_ids = '', | |||
| $status = '', | |||
| $sqlfilters = '', | |||
| $sqlfilterlines = '', | |||
| $properties = '', | |||
| $pagination_data = false ) |
List orders.
Get a list of supplier orders
| string | $sortfield | Sort field |
| string | $sortorder | Sort order |
| int | $limit | Limit for list |
| int | $page | Page number |
| string | $thirdparty_ids | Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} |
| string | $product_ids | Product ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} |
| string | $status | Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused |
| string | $sqlfilters | Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" |
| string | $sqlfilterlines | Other criteria to filter answers separated by a comma. Syntax example "(tl.fk_product:=:'17') and (tl.price:<:'250')" |
| string | $properties | Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names |
| bool | $pagination_data | If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* |
| RestException |
Definition at line 117 of file api_supplier_orders.class.php.
References _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), and forgeSQLFromUniversalSearchCriteria().
|
protected |
Load the complete line after checking its parent and ownership.
| int | $id | Supplier order ID |
| int | $lineid | Line ID |
Definition at line 631 of file api_supplier_orders.class.php.
References $id, and loadOrderForOperation().
Referenced by deleteLine(), getLine(), and putLine().
|
protected |
Load an authorised order without sanitising its live database handle.
| int | $id | Supplier order ID |
Definition at line 611 of file api_supplier_orders.class.php.
References $id.
Referenced by loadLineForOperation().
| SupplierOrders::makeOrder | ( | $id, | |
| $date, | |||
| $method, | |||
| $comment = '' ) |
Sends an order to the vendor.
| int | $id | Order ID |
| integer | $date | Date (unix timestamp in sec) |
| int | $method | Method |
| string | $comment | Comment |
@url POST {id}/makeorder
FIXME An error 403 is returned if the request has an empty body. Error message: "Forbidden: Content type `text/plain` is not supported." Workaround: send this in the body { "date": 0, "method": 0, "comment": "" }
Definition at line 1097 of file api_supplier_orders.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
| SupplierOrders::post | ( | $request_data = null | ) |
Create supplier order object.
Example: {"ref": "auto", "ref_supplier": "1234", "socid": "1", "multicurrency_code": "SEK", "multicurrency_tx": 1, "tva_tx": 25, "note": "Imported via the REST API"}
| array | $request_data | Request data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data |
Definition at line 265 of file api_supplier_orders.class.php.
References DolibarrApi\_checkValForAPI(), _validate(), dol_now(), and sanitizeVal().
| SupplierOrders::postContact | ( | $id, | |
| $contactid, | |||
| $type, | |||
| $source ) |
Add a contact type of given supplier order.
| int | $id | Id of supplier order to update |
| int | $contactid | Id of contact/user to add |
| string | $type | Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...) |
| string | $source | Source of the contact (external, internal) |
@url POST {id}/contact/{contactid}/{type}/{source}
| RestException | 401 |
| RestException | 404 |
Definition at line 705 of file api_supplier_orders.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
| SupplierOrders::postLine | ( | $id, | |
| $request_data = null ) |
Add a line to a given supplier order.
| int | $id | Id of order to update |
| array | $request_data | OrderLine data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data |
@url POST {id}/lines
Definition at line 371 of file api_supplier_orders.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and sanitizeVal().
|
protected |
Prepare a partial update without changing the original line or writing data.
| CommandeFournisseurLigne | $line | Current line |
| array<string,mixed>|null | $request_data Fields to change |
Definition at line 558 of file api_supplier_orders.class.php.
References DolibarrApi\_checkValExtrafieldsForAPI(), and DolibarrApi\_checkValForAPI().
Referenced by putLine().
| SupplierOrders::put | ( | $id, | |
| $request_data = null ) |
Update supplier order.
| int | $id | Id of supplier order to update |
| array | $request_data | Data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data |
Definition at line 316 of file api_supplier_orders.class.php.
References $id, DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValExtrafieldsForAPI(), DolibarrApi\_checkValForAPI(), and sanitizeVal().
| SupplierOrders::putLine | ( | $id, | |
| $lineid, | |||
| $request_data = null ) |
Update selected fields of a draft supplier order line.
Omitted fields keep their current value. Dates are Unix timestamps or null. Give only one price, in company currency (HT or TTC) or order currency (HT).
| int | $id | Supplier order ID |
| int | $lineid | Line ID |
| array | $request_data | Fields to change @phan-param ?array<string,mixed> $request_data @phpstan-param ?array<string,mixed> $request_data |
Definition at line 457 of file api_supplier_orders.class.php.
References $id, _cleanObjectDatas(), loadLineForOperation(), prepareLineUpdate(), and CommandeFournisseur\STATUS_DRAFT.
| SupplierOrders::receiveOrder | ( | $id, | |
| $closeopenorder, | |||
| $comment, | |||
| $lines ) |
Receives the order, dispatches products.
Example: { "closeopenorder": 1, "comment": "", "lines": [{ "id": 14, "fk_product": 112, "qty": 18, "warehouse": 1, "price": 114, "comment": "", "eatby": 0, "sellby": 0, "batch": 0, "notrigger": 0 }] }
| int | $id | Order ID |
| integer | $closeopenorder | Close order if everything is received {@required false} |
| string | $comment | Comment {@required false} |
| array | $lines | Array of product dispatches @phan-param array<array{fk_product:string,qty:string,warehouse:string,price:string,comment:string,eatby:string,sellby:string,batch:string,id:string,notrigger:string}> $lines @phpstan-param array<array{fk_product:string,qty:string,warehouse:string,price:string,comment:string,eatby:string,sellby:string,batch:string,id:string,notrigger:string}> $lines |
@url POST {id}/receive
FIXME An error 403 is returned if the request has an empty body. Error message: "Forbidden: Content type `text/plain` is not supported."
Definition at line 1229 of file api_supplier_orders.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
| SupplierOrders::refuse | ( | $id, | |
| $comment = '' ) |
Refuse a validated order that is waiting for approval.
| int | $id | Order ID |
| string | $comment | Reason of the refusal, added to the agenda event {@required false} |
@url POST {id}/refuse
| RestException | 403 Not allowed |
| RestException | 404 Not found |
| RestException | 405 Order is not waiting for approval |
| RestException | 500 Error |
FIXME An error 403 is returned if the request has an empty body. Error message: "Forbidden: Content type `text/plain` is not supported." Workaround: send this in the body { "comment": "" }
Definition at line 1035 of file api_supplier_orders.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and CommandeFournisseur\STATUS_VALIDATED.
| SupplierOrders::settodraft | ( | $id | ) |
Set a validated or approved order back to draft.
| int | $id | Order ID |
@url POST {id}/settodraft
| RestException | 403 Not allowed |
| RestException | 404 Not found |
| RestException | 405 Order is not validated or approved |
| RestException | 500 Error |
Definition at line 909 of file api_supplier_orders.class.php.
References $id, DolibarrApi\_checkAccessToResource(), getDolGlobalString(), CommandeFournisseur\STATUS_ACCEPTED, and CommandeFournisseur\STATUS_VALIDATED.
| SupplierOrders::validate | ( | $id, | |
| $idwarehouse = 0, | |||
| $notrigger = 0 ) |
Validate an order.
| int | $id | Order ID |
| int | $idwarehouse | Warehouse ID |
| int | $notrigger | 1=Does not execute triggers, 0= execute triggers |
@url POST {id}/validate
FIXME An error 403 is returned if the request has an empty body. Error message: "Forbidden: Content type `text/plain` is not supported." Workaround: send this in the body { "idwarehouse": 0, "notrigger": 0 }
Definition at line 861 of file api_supplier_orders.class.php.
References $id, and DolibarrApi\_checkAccessToResource().