dolibarr 24.0.0-beta
Tasks Class Reference
Inheritance diagram for Tasks:
Collaboration diagram for Tasks:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id, $includetimespent=0)
 Get properties of a task object.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $sqlfilters='', $properties='', $pagination_data=false)
 List tasks.
 
 post ($request_data=null)
 Create task object.
 
 getTimespent ($id)
 Get time spent of a task.
 
 getRoles ($id, $userid=0)
 Get roles a user is assigned to a task with.
 
 put ($id, $request_data=null)
 Add a task to given project.
 
 delete ($id)
 Delete task.
 
 getTimeSpentByID ($id, $timespent_id)
 Get time spent of a task.
 
 addTimeSpent ($id, $date, $duration, $product_id=null, $user_id=0, $note='', $progress=-1)
 Add time spent to a task of a project.
 
 putTimeSpent ($id, $timespent_id, $date, $duration, $product_id=null, $user_id=0, $note='')
 Update time spent for a task of a project.
 
 deleteTimeSpent ($id, $timespent_id)
 Delete time spent for a task of a project.
 
 getContacts ($id, $type='')
 Get contacts of given task.
 
 addContact ($id, $fk_socpeople, $type_contact, $source, $notrigger=0)
 Adds a contact to a task.
 
 deleteContact ($id, $contactid, $type)
 Delete a contact type of given task.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanObjectDatas ($object)
 Clean sensitive object data @phpstan-template T.
 
 _cleanTimeSpentObjectDatas ($object)
 Clean sensitive object data @phpstan-template T of Object.
 
- 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

 timespentRecordChecks ($id, $timespent_id)
 Validate task & timespent IDs for timespent API methods.
 
 _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 37 of file api_tasks.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Tasks::_cleanObjectDatas ( $object)
protected

Clean sensitive object data @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 845 of file api_tasks.class.php.

References $object.

Referenced by addContact(), deleteContact(), get(), getRoles(), getTimespent(), and index().

◆ _cleanTimeSpentObjectDatas()

Tasks::_cleanTimeSpentObjectDatas ( $object)
protected

Clean sensitive object data @phpstan-template T of Object.

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

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

Definition at line 899 of file api_tasks.class.php.

References $object.

Referenced by getTimeSpentByID().

◆ _validate()

Tasks::_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 1021 of file api_tasks.class.php.

References $object.

Referenced by post().

◆ addContact()

Tasks::addContact ( $id,
$fk_socpeople,
$type_contact,
$source,
$notrigger = 0 )

Adds a contact to a task.

Since
23.0.0 Initial implementation
Parameters
int$idTask ID
int$fk_socpeopleId of thirdparty contact (if source = 'external') or id of user (if source = 'internal') to link
string$type_contactType of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING
string$sourceexternal=Contact extern (llx_socpeople), internal=Contact intern (llx_user)
int$notriggerDisable all triggers

@url POST {id}/contacts

Returns
object
Exceptions
RestException304
RestException401
RestException404
RestException500 System error

Definition at line 1094 of file api_tasks.class.php.

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

◆ addTimeSpent()

Tasks::addTimeSpent ( $id,
$date,
$duration,
$product_id = null,
$user_id = 0,
$note = '',
$progress = -1 )

Add time spent to a task of a project.

You can test this API with the following input message { "date": "2016-12-31 23:15:00", "duration": 1800, "user_id": 1, "note": "My time test" }

Since
5.0.0 Initial implementation
Parameters
int$idTask ID
datetime | string$dateDate (YYYY-MM-DD HH:MI:SS in GMT) @phan-param string $date
int$durationDuration in seconds (3600 = 1h)
int$product_idThe product id that is used, default is null
int$user_idUser (Use 0 for connected user)
string$noteNote
int$progressProgress percentage (0-100). Use -1 to leave progress unchanged

@url POST {id}/addtimespent NOTE: Should be "POST {id}/timespent", since POST already implies "add"

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

Definition at line 669 of file api_tasks.class.php.

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

◆ delete()

Tasks::delete ( $id)

Delete task.

Since
5.0.0 Initial implementation
Parameters
int$idTask ID
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}
Exceptions
RestException

Definition at line 579 of file api_tasks.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ deleteContact()

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

Delete a contact type of given task.

Since
23.0.0 Initial implementation
Parameters
int$idId of task to update
int$contactidRow key of the contact in the array contact_ids.
string$typeType of the contact (BILLING, SHIPPING, CUSTOMER).
Returns
Object Object with cleaned properties

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

Exceptions
RestException401
RestException404
RestException500 System error

Definition at line 1139 of file api_tasks.class.php.

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

◆ deleteTimeSpent()

Tasks::deleteTimeSpent ( $id,
$timespent_id )

Delete time spent for a task of a project.

Since
17.0.0 Initial implementation
Parameters
int$idTask ID
int$timespent_idTime spent ID (llx_element_time.rowid)

@url DELETE {id}/timespent/{timespent_id}

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

Definition at line 789 of file api_tasks.class.php.

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

◆ get()

Tasks::get ( $id,
$includetimespent = 0 )

Get properties of a task object.

Return an array with task information

Since
5.0.0 Initial implementation
Parameters
int$idID of task
int$includetimespent0=Return only task. 1=Include a summary of time spent, 2=Include details of time spent lines
Returns
array|mixed data without useless information
Exceptions
RestException

Definition at line 76 of file api_tasks.class.php.

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

◆ getContacts()

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

Get contacts of given task.

Return an array with contact information

Since
23.0.0 Initial implementation
Parameters
int$idID of task
string$typeType of the contact
Returns
array<int,mixed> Array with cleaned properties

@url GET {id}/contacts

Exceptions
RestException

Definition at line 1051 of file api_tasks.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ getRoles()

Tasks::getRoles ( $id,
$userid = 0 )

Get roles a user is assigned to a task with.

Since
5.0.0 Initial implementation
Parameters
int$idId of task
int$useridId of user (0 = connected user)
Returns
array Array of roles @phan-return array<int,string> @phpstan-return array<int,string>

@url GET {id}/roles

Definition at line 350 of file api_tasks.class.php.

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

◆ getTimespent()

Tasks::getTimespent ( $id)

Get time spent of a task.

Since
23.0.0 Initial implementation
Parameters
int$idId of task
Returns
array<int,mixed> Array of timespent lines

@url GET {id}/timespent

Definition at line 312 of file api_tasks.class.php.

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

◆ getTimeSpentByID()

Tasks::getTimeSpentByID ( $id,
$timespent_id )

Get time spent of a task.

Since
23.0.0 Initial implementation
Parameters
int$idId of task
int$timespent_idId of timespent

@url GET {id}/getTimeSpent/{timespent_id}

Returns
Object data without useless information
Exceptions
RestException

Definition at line 619 of file api_tasks.class.php.

References $id, DolibarrApi\_checkAccessToResource(), _cleanTimeSpentObjectDatas(), and dol_syslog().

◆ index()

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

List tasks.

Get a list of tasks

Since
5.0.0 Initial implementation
Parameters
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')"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
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 project objects @phan-return Task[] @phpstan-return Task[]

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

References $conf, _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), dol_syslog(), and getEntity().

◆ post()

Tasks::post ( $request_data = null)

Create task object.

Since
5.0.0 Initial implementation
Parameters
array$request_dataRequest data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data
Returns
int ID of project

Definition at line 227 of file api_tasks.class.php.

References $conf, DolibarrApi\_checkValForAPI(), _validate(), dol_buildpath(), dol_include_once(), dol_now(), dol_print_date(), dol_syslog(), getDolGlobalString(), and sanitizeVal().

◆ put()

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

Add a task to given project.

Parameters
int$idId of project to update
array$request_dataProjectline data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url POST {id}/tasks

Returns
int Update a task of a given project
Parameters
int$idId of project to update
int$taskidId of task to update
array$request_dataProjectline data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data

@url PUT {id}/tasks/{taskid}

Returns
object Update task general fields (won't touch time spent of task)
Since
5.0.0 Initial implementation
Parameters
int$idId of task 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 527 of file api_tasks.class.php.

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

◆ putTimeSpent()

Tasks::putTimeSpent ( $id,
$timespent_id,
$date,
$duration,
$product_id = null,
$user_id = 0,
$note = '' )

Update time spent for a task of a project.

You can test this API with the following input message { "date": "2016-12-31 23:15:00", "duration": 1800, "user_id": 1, "note": "My time test" }

Since
17.0.0 Initial implementation
Parameters
int$idTask ID
int$timespent_idTime spent ID (llx_element_time.rowid)
datetime$dateDate (YYYY-MM-DD HH:MI:SS in GMT) @phan-param string $date
int$durationDuration in seconds (3600 = 1h)
int$product_idThe product id that is used, default is null
int$user_idUser (Use 0 for connected user)
string$noteNote

@url PUT {id}/timespent/{timespent_id}

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

Definition at line 739 of file api_tasks.class.php.

References $id, DolibarrApi\_checkAccessToResource(), dol_stringtotime(), and timespentRecordChecks().

◆ timespentRecordChecks()

Tasks::timespentRecordChecks ( $id,
$timespent_id )
private

Validate task & timespent IDs for timespent API methods.

Loads the selected task & timespent records.

Parameters
int$idTask ID
int$timespent_idTime spent ID (llx_element_time.rowid)
Returns
void

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

References $id, and dol_syslog().

Referenced by deleteTimeSpent(), and putTimeSpent().


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