dolibarr 21.0.0-alpha
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='')
 List tasks.
 
 post ($request_data=null)
 Create task object.
 
 getRoles ($id, $userid=0)
 Get time spent of a task.
 
 put ($id, $request_data=null)
 Add a task to given project.
 
 delete ($id)
 Delete task.
 
 addTimeSpent ($id, $date, $duration, $user_id=0, $note='')
 Add time spent to a task of a project.
 
 putTimeSpent ($id, $timespent_id, $date, $duration, $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.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 timespentRecordChecks ($id, $timespent_id)
 Validate task & timespent IDs for timespent API methods.
 
 _cleanObjectDatas ($object)
 Clean sensible object datas.
 
- Protected Member Functions inherited from DolibarrApi
 _checkValForAPI ($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')
 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 31 of file api_tasks.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Tasks::_cleanObjectDatas ( $object)
protected

Clean sensible object datas.

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

Reimplemented from DolibarrApi.

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

References $object.

Referenced by get(), getRoles(), and index().

◆ _validate()

Tasks::_validate ( $data)
private

Validate fields before create or update object.

Parameters
array$dataArray with data to verify
Returns
array
Exceptions
RestException

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

References $object.

Referenced by post().

◆ addTimeSpent()

Tasks::addTimeSpent ( $id,
$date,
$duration,
$user_id = 0,
$note = '' )

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" }

Parameters
int$idTask ID
datetime$dateDate (YYYY-MM-DD HH:MI:SS in GMT)
int$durationDuration in seconds (3600 = 1h)
int$user_idUser (Use 0 for connected user)
string$noteNote

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

Returns
array

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

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

◆ delete()

Tasks::delete ( $id)

Delete task.

Parameters
int$idTask ID
Returns
array

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

References DolibarrApi\_checkAccessToResource().

◆ deleteTimeSpent()

Tasks::deleteTimeSpent ( $id,
$timespent_id )

Delete time spent for a task of a project.

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

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

Returns
array

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

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

◆ get()

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

Get properties of a task object.

Return an array with task information

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 68 of file api_tasks.class.php.

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

◆ getRoles()

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

Get time spent of a task.

Parameters
int$idId of task
Returns
int

@url GET {id}/tasks Get roles a user is assigned to a task with

Parameters
int$idId of task
int$useridId of user (0 = connected user)
Returns
array Array of roles

@url GET {id}/roles

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

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

◆ index()

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

List tasks.

Get a list of tasks

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
Returns
array Array of project objects

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

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

◆ post()

Tasks::post ( $request_data = null)

Create task object.

Parameters
array$request_dataRequest data
Returns
int ID of project

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

References DolibarrApi\_checkValForAPI(), _validate(), 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

@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

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

Returns
object Update task general fields (won't touch time spent of task)
Parameters
int$idId of task to update
array$request_dataDatas
Returns
Object Updated object

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

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

◆ putTimeSpent()

Tasks::putTimeSpent ( $id,
$timespent_id,
$date,
$duration,
$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" }

Parameters
int$idTask ID
int$timespent_idTime spent ID (llx_element_time.rowid)
datetime$dateDate (YYYY-MM-DD HH:MI:SS in GMT)
int$durationDuration in seconds (3600 = 1h)
int$user_idUser (Use 0 for connected user)
string$noteNote

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

Returns
array

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

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

◆ timespentRecordChecks()

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

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 668 of file api_tasks.class.php.

Referenced by deleteTimeSpent(), and putTimeSpent().


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