dolibarr 25.0.0-alpha
Tickets Class Reference
Inheritance diagram for Tickets:
Collaboration diagram for Tickets:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id, $contact_list=1)
 Get properties of a Ticket object.
 
 getByTrackId ($track_id, $contact_list=1)
 Get properties of a Ticket object from track id.
 
 getByRef ($ref, $contact_list=1)
 Get properties of a Ticket object from ref.
 
 index ($socid=0, $sortfield="t.rowid", $sortorder="ASC", $limit=100, $page=0, $sqlfilters='', $properties='', $loadcontacts=0, $pagination_data=false)
 List tickets.
 
 post ($request_data=null)
 Create ticket object.
 
 postNewMessage ($request_data=null)
 Add a new message to an existing ticket identified by property ->track_id into request.
 
 put ($id, $request_data=null)
 Update ticket.
 
 close ($id, $cancel=0)
 Close a ticket, or cancel it.
 
 assign ($id, $fk_user_assign=0)
 Assign a ticket to a user, or unassign it.
 
 delete ($id)
 Delete ticket.
 
 postContact (int $id, int $contactid, string $type, string $source="external", int $notrigger=0)
 Add a contact type of given ticket.
 
 deleteContact (int $id, int $contactid, string $type, string $source="external")
 Unlink a contact type of given ticket.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _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

 getCommon ($id=0, $track_id='', $ref='', $contact_list=1)
 Get properties of a Ticket object Return an array with ticket information.
 
 canManage ()
 Whether the API user may close and assign tickets, as on the ticket card.
 
 _validate ($data)
 Validate fields before create or update object.
 
 _validateMessage ($data)
 Validate fields before create or update object message.
 

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.
 

Detailed Description

Definition at line 35 of file api_tickets.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Tickets::_cleanObjectDatas ( $object)
protected

Clean sensible object datas @phpstan-template T.

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

@phpstan-param T $object @phpstan-return T

Reimplemented from DolibarrApi.

Definition at line 811 of file api_tickets.class.php.

References $object, and _cleanObjectDatas().

Referenced by _cleanObjectDatas(), getCommon(), and index().

◆ _validate()

Tickets::_validate ( $data)
private

Validate fields before create or update object.

Parameters
?array<string,string>$data Data to validate
Returns
array<string,string>
Exceptions
RestException

Definition at line 761 of file api_tickets.class.php.

Referenced by post().

◆ _validateMessage()

Tickets::_validateMessage ( $data)
private

Validate fields before create or update object message.

Parameters
?array<string,string>$data Data to validate
Returns
array<string,string>
Exceptions
RestException

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

Referenced by postNewMessage().

◆ assign()

Tickets::assign ( $id,
$fk_user_assign = 0 )

Assign a ticket to a user, or unassign it.

Same as the assignment of the ticket card: the status follows the assignment, the TICKET_ASSIGNED trigger runs (notification of the user) and the internal "SUPPORTTEC" contact of the ticket becomes the assigned user.

Parameters
int$idTicket ID
int$fk_user_assignRowid of an active user, 0 to unassign
Returns
Object Ticket after the change

@url POST {id}/assign

Exceptions
RestException400 Unknown or inactive user
RestException403 Not allowed
RestException404 Ticket not found
RestException500 Error when assigning

Definition at line 660 of file api_tickets.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and canManage().

◆ canManage()

Tickets::canManage ( )
private

Whether the API user may close and assign tickets, as on the ticket card.

Returns
bool

Definition at line 710 of file api_tickets.class.php.

References getDolGlobalString().

Referenced by assign(), and close().

◆ close()

Tickets::close ( $id,
$cancel = 0 )

Close a ticket, or cancel it.

Same as the Close and Abandon buttons of the ticket card: the status, the closing date and the progress are set by core, and the TICKET_CLOSE trigger runs (notifications, linked interventions).

Parameters
int$idTicket ID
int$cancel1 to cancel (abandon) the ticket instead of closing it
Returns
Object Ticket after the change

@url POST {id}/close

Exceptions
RestException403 Not allowed
RestException404 Ticket not found
RestException409 Ticket already closed or canceled
RestException500 Error when closing

Definition at line 621 of file api_tickets.class.php.

References $id, DolibarrApi\_checkAccessToResource(), and canManage().

◆ delete()

Tickets::delete ( $id)

Delete ticket.

Parameters
int$idTicket ID
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}

Definition at line 727 of file api_tickets.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ deleteContact()

Tickets::deleteContact ( int $id,
int $contactid,
string $type,
string $source = "external" )

Unlink a contact type of given ticket.

Since
12.0.0 Initial implementation
Parameters
int$idId of ticket to update
int$contactidId of contact
string$typeType of the contact (BILLING, SHIPPING, CUSTOMER).
string$sourceinternal=Contact intern (llx_user), external=Contact extern (llx_socpeople)

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

Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}
Exceptions
RestException401
RestException404
RestException500 System error

Definition at line 1022 of file api_tickets.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ get()

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

Get properties of a Ticket object.

Return an array with ticket information

Parameters
int$idID of ticket
int$contact_list0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
Returns
Object Object with cleaned properties
Exceptions
RestException401
RestException403
RestException404

Definition at line 81 of file api_tickets.class.php.

References $id, and getCommon().

◆ getByRef()

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

Get properties of a Ticket object from ref.

Return an array with ticket information

Parameters
string$refReference for ticket
int$contact_list0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
Returns
array|mixed Data without useless information

@url GET ref/{ref}

Exceptions
RestException401
RestException403
RestException404

Definition at line 121 of file api_tickets.class.php.

References getCommon().

◆ getByTrackId()

Tickets::getByTrackId ( $track_id,
$contact_list = 1 )

Get properties of a Ticket object from track id.

Return an array with ticket information

Parameters
string$track_idTracking ID of ticket
int$contact_list0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
Returns
array|mixed Data without useless information

@url GET track_id/{track_id}

Exceptions
RestException401
RestException403
RestException404

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

References getCommon().

◆ getCommon()

Tickets::getCommon ( $id = 0,
$track_id = '',
$ref = '',
$contact_list = 1 )
private

Get properties of a Ticket object Return an array with ticket information.

Parameters
int$idID of ticket
string$track_idTracking ID of ticket
string$refReference for ticket
int$contact_list0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses
Returns
array|mixed Data without useless information

Definition at line 136 of file api_tickets.class.php.

References $conf, $id, DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), and dolGetFirstLastname().

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

◆ index()

Tickets::index ( $socid = 0,
$sortfield = "t.rowid",
$sortorder = "ASC",
$limit = 100,
$page = 0,
$sqlfilters = '',
$properties = '',
$loadcontacts = 0,
$pagination_data = false )

List tickets.

Get a list of tickets

Parameters
int$socidFilter list with thirdparty ID
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:>:'20160101') and (t.fk_statut:=:1)"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
int$loadcontactsLoad also contacts/addresses (0=No, 1=Yes)
bool$pagination_dataIf this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
Returns
array Array of ticket objects @phan-return Ticket[]|array{data:Ticket[],pagination:array{total:int,page:int,page_count:int,limit:int}} @phpstan-return Ticket[]|array{data:Ticket[],pagination:array{total:int,page:int,page_count:int,limit:int}}

Definition at line 235 of file api_tickets.class.php.

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

◆ post()

Tickets::post ( $request_data = null)

Create ticket object.

Parameters
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
int ID of ticket

Definition at line 354 of file api_tickets.class.php.

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

◆ postContact()

Tickets::postContact ( int $id,
int $contactid,
string $type,
string $source = "external",
int $notrigger = 0 )

Add a contact type of given ticket.

Parameters
int$idId of ticket to update
int$contactidId of contact to add
string$typeType (code in dictionary) of the contact (BILLING, SHIPPING, CUSTOMER + possibly your own)
string$sourceinternal=Contact intern (llx_user), external=Contact extern (llx_socpeople)
int$notrigger0=Enable all triggers (default), 1=Disable all triggers
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}

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

Exceptions
RestException400
RestException401
RestException403
RestException404
RestException503

Definition at line 912 of file api_tickets.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ postNewMessage()

Tickets::postNewMessage ( $request_data = null)

Add a new message to an existing ticket identified by property ->track_id into request.

Parameters
array$request_dataRequest data @phan-param ?array<string,mixed> $request_data @phpstan-param ?array<string,mixed> $request_data
Returns
int|array ID of ticket, or ticket/action IDs when requested @phan-return int|array{ticket_id:int,action_id:int} @phpstan-return int|array{ticket_id:int,action_id:int}

Definition at line 410 of file api_tickets.class.php.

References $conf, DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValForAPI(), _validateMessage(), dol_is_dir(), dol_mkdir(), dol_move(), dol_now(), dol_sanitizeFileName(), and sanitizeVal().

◆ put()

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

Update ticket.

Parameters
int$idId of ticket to update
array$request_dataData @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
Object Updated object

Definition at line 548 of file api_tickets.class.php.

References $id, DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValExtrafieldsForAPI(), DolibarrApi\_checkValForAPI(), and sanitizeVal().


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