Since: 5.0.0 Initial implementation

class Proposals extends DolibarrApi (View source)

API class for orders

Properties

protected DoliDB $db from  DolibarrApi
Restler $r from  DolibarrApi
static string[] $FIELDS
Propal $propal

Methods

__construct()

Constructor

string|array<string, mixed>
_checkValForAPI(string $field, string|string[] $value, object $object)

Check and convert a string depending on its type/name.

object
_filterObjectProperties(object $object, string $properties)

Filter properties that will be returned on object

object
_cleanObjectDatas(object $object)

Clean sensible object datas

static 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

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 string
_forge_criteria_callback(string[] $matches)

Function to forge a SQL criteria from a Generic filter string.

object
get(int $id, int $contact_list = 1)

Get a commercial proposal

object
getByRef(string $ref, int $contact_list = 1)

Get a commercial proposal by ref

object
getByRefExt(string $ref_ext, int $contact_list = 1)

Get a commercial proposal by ref_ext

array
index(string $sortfield = "t.rowid", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $thirdparty_ids = '', string $sqlfilters = '', string $properties = '', bool $pagination_data = false, int $loadlinkedobjects = 0)

List commercial proposals

int
post(array $request_data = null)

Create a commercial proposal

array
getLines(int $id, string $sqlfilters = '')

Get lines of a commercial proposal

int
postLine(int $id, array $request_data = null)

Add a line to a commercial proposal

int
postLines(int $id, array $request_data = null)

Add lines to a commercial proposal

object|false
putLine(int $id, int $lineid, array $request_data = null)

Update a line of a commercial proposal

object|false
deleteLine(int $id, int $lineid)

Delete a line of a commercial proposal

array<int, mixed>
getContacts(int $id, string $type = '')

Get contacts of given proposal

array
postContact(int $id, int $contactid, string $type, string $source = 'external', int $notrigger = 0)

Add (link) a contact to a commercial proposal

object
deleteContact(int $id, int $contactid, string $type)

Remove (unlink) a contact from commercial proposal

object
put(int $id, array $request_data = null)

Update a commercial proposal general fields (won't change lines of commercial proposal)

array
delete(int $id)

Delete a commercial proposal

object
settodraft(int $id)

Set a commercial proposal to draft

object
validate(int $id, int $notrigger = 0)

Validate a commercial proposal

object
close(int $id, int $status, string $note_private = '', int $notrigger = 0, string $note_public = '')

Close (accept or refuse) a commercial proposal

object
setinvoiced(int $id)

Set a commercial proposal to billed

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.

Parameters

string $field

Field name

string|string[] $value

Value to check/clean

object $object Object

Return Value

string|array<string, mixed>

Value cleaned

protected object _filterObjectProperties(object $object, string $properties)

Filter properties that will be returned on object

Parameters

object $object

Object to clean

string $properties

Comma separated list of properties names

Return Value

object

Object with cleaned properties

protected object _cleanObjectDatas(object $object)

Clean sensible object datas

Parameters

object $object

Object to clean

Return Value

object

Object with cleaned properties

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

Parameters

string $resource

element to check

int $resource_id

Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).

string $dbtablename

'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional)

string $feature2

Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.

string $dbt_keyfield

Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)

string $dbt_select

Field name for select if not rowid. Not used if objectid is null (optional)

Return Value

bool

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

Parameters

string $sqlfilters

sqlfilter string

string $error

Error message

Return Value

bool|string

True if valid, False if not valid

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

Parameters

string[] $matches

Array of found string by regex search. Each entry is 1 and only 1 criteria. Example: "t.ref:like:'SO-%'", "t.date_creation:<:'20160101'", "t.date_creation:<:'2016-01-01 12:30:00'", "t.nature:is:NULL", "t.field2:isnot:NULL"

Return Value

string

Forged criteria. Example: "t.field like 'abc%'"

object get(int $id, int $contact_list = 1)

Since: 5.0.0 Initial implementation

Get a commercial proposal

Return an array with commercial proposal information

Parameters

int $id

ID of commercial proposal

int $contact_list

0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id

Return Value

object

Object with cleaned properties

Exceptions

RestException

object getByRef(string $ref, int $contact_list = 1)

Since: 12.0.0 Initial implementation

Get a commercial proposal by ref

Return an array with proposal information

Parameters

string $ref

Ref of object

int $contact_list

0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id

Return Value

object

Object with cleaned properties

Exceptions

RestException

object getByRefExt(string $ref_ext, int $contact_list = 1)

Since: 12.0.0 Initial implementation

Get a commercial proposal by ref_ext

Return an array with proposal information

Parameters

string $ref_ext

External reference of object

int $contact_list

0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id

Return Value

object

Object with cleaned properties

Exceptions

RestException

array index(string $sortfield = "t.rowid", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $thirdparty_ids = '', string $sqlfilters = '', string $properties = '', bool $pagination_data = false, int $loadlinkedobjects = 0)

Since: 5.0.0 Initial implementation

List commercial proposals

Get a list of commercial proposals

Parameters

string $sortfield

Sort field

string $sortorder

Sort order

int $limit

Limit for list

int $page

Page number

string $thirdparty_ids

Thirdparty ids to filter commercial proposals (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}

string $sqlfilters

Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'2016-01-01')"

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*

int $loadlinkedobjects

Load also linked object

Return Value

array

Array of order objects

Exceptions

RestException

int post(array $request_data = null)

Since: 5.0.0 Initial implementation

Create a commercial proposal

Parameters

array $request_data

Request data

Return Value

int

ID of proposal

Exceptions

RestException

array getLines(int $id, string $sqlfilters = '')

Since: 5.0.0 Initial implementation

Get lines of a commercial proposal

Parameters

int $id

Id of commercial proposal

string $sqlfilters

Other criteria to filter answers separated by a comma. d is the alias for proposal lines table, p is the alias for product table. "Syntax example "(p.ref:like:'SO-%') AND (d.date_start:<:'20220101')"

Return Value

array

Exceptions

RestException

int postLine(int $id, array $request_data = null)

Since: 5.0.0 Initial implementation

Add a line to a commercial proposal

Parameters

int $id

Id of commercial proposal to update

array $request_data

Commercial proposal line data

Return Value

int

Exceptions

RestException

int postLines(int $id, array $request_data = null)

Add lines to a commercial proposal

Parameters

int $id

Id of commercial proposal to update

array $request_data

Commercial proposal line data

Return Value

int

Exceptions

RestException

object|false putLine(int $id, int $lineid, array $request_data = null)

Since: 5.0.0 Initial implementation

Update a line of a commercial proposal

Parameters

int $id

Id of commercial proposal to update

int $lineid

Id of line to update

array $request_data

Commercial proposal line data

Return Value

object|false

Object with cleaned properties

Exceptions

RestException

object|false deleteLine(int $id, int $lineid)

Since: 5.0.0 Initial implementation

Delete a line of a commercial proposal

Parameters

int $id

Id of commercial proposal to update

int $lineid

Id of line to delete

Return Value

object|false

Object with cleaned properties

Exceptions

RestException
RestException

array<int, mixed> getContacts(int $id, string $type = '')

Get contacts of given proposal

Return an array with contact information

Parameters

int $id

ID of proposal

string $type

Type of the proposal

Return Value

array<int, mixed>

Array of contacts associated

Exceptions

RestException

array postContact(int $id, int $contactid, string $type, string $source = 'external', int $notrigger = 0)

Since: 10.0.0 Initial implementation

Add (link) a contact to a commercial proposal

Parameters

int $id

Id of commercial proposal to update

int $contactid

Id of contact to add

string $type

Type (code in dictionary) of the contact (BILLING, SHIPPING, CUSTOMER + possibly your own)

string $source

internal=Contact intern (llx_user), external=Contact extern (llx_socpeople)

int $notrigger

0=Enable all triggers (default), 1=Disable all triggers

Return Value

array

Exceptions

RestException
RestException
RestException
RestException

object deleteContact(int $id, int $contactid, string $type)

Since: 10.0.0 Initial implementation

Remove (unlink) a contact from commercial proposal

Parameters

int $id

Id of commercial proposal to update

int $contactid

Row key of the contact in the array contact_ids.

string $type

Type of the contact (BILLING, SHIPPING, CUSTOMER).

Return Value

object

Object with cleaned properties

Exceptions

RestException
RestException
RestException

object put(int $id, array $request_data = null)

Since: 5.0.0 Initial implementation

Update a commercial proposal general fields (won't change lines of commercial proposal)

Parameters

int $id

Id of commercial proposal to update

array $request_data Datas

Return Value

object

Object with cleaned properties

Exceptions

RestException

array delete(int $id)

Since: 5.0.0 Initial implementation

Delete a commercial proposal

Parameters

int $id

Commercial proposal ID

Return Value

array

Exceptions

RestException

object settodraft(int $id)

Since: 7.0.0 Initial implementation

Set a commercial proposal to draft

Parameters

int $id

Order ID

Return Value

object

Object with cleaned properties

Exceptions

RestException

object validate(int $id, int $notrigger = 0)

Since: 5.0.0 Initial implementation

Validate a commercial proposal

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

Parameters

int $id

Commercial proposal ID

int $notrigger

1=Does not execute triggers, 0= execute triggers

Return Value

object

Object with cleaned properties

Exceptions

RestException
RestException
RestException
RestException

object close(int $id, int $status, string $note_private = '', int $notrigger = 0, string $note_public = '')

Since: 7.0.0 Initial implementation

Close (accept or refuse) a commercial proposal

Parameters

int $id

Commercial proposal ID

int $status

Must be 2 (accepted) or 3 (refused) {@min 2}{@max 3}

string $note_private

Add this mention at end of private note

int $notrigger

Disabled triggers

string $note_public

Add this mention at end of public note

Return Value

object

Object with cleaned properties

Exceptions

RestException

object setinvoiced(int $id)

Since: 7.0.0 Initial implementation

Set a commercial proposal to billed

Parameters

int $id

Commercial proposal ID

Return Value

object

Object with cleaned properties

Exceptions

RestException