Add function to update the event percent + const

This commit is contained in:
Tobias Sekan 2020-05-19 08:07:21 +02:00 committed by GitHub
parent cb9cbfb922
commit 223224d12c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -343,6 +343,20 @@ class ActionComm extends CommonObject
*/
public $errors_to;
/**
* Typical value for a event that is in a todo state
*/
const EVENT_TODO = 0;
/**
* Typical value for a event that is in a progress state
*/
const EVENT_IN_PROGRESS = 50;
/**
* Typical value for a event that is in a finished state
*/
const EVENT_FINISHED = 100;
/**
* Constructor
@ -2021,4 +2035,32 @@ class ActionComm extends CommonObject
return $error;
}
/**
* Udpate the percent value of a event with the given id
*
* @param int $id The id of the event
* @param int $percent The new percent value for the event
* @return int 1 when update of the event was suscessfull, otherwise -1
*/
public function updatePercent($id, $percent)
{
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm ";
$sql .= " SET percent = '".$percent."'";
$sql .= " WHERE id=".$id;
if ($this->db->query($sql))
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
$this->error = $this->db->lasterror();
return -1;
}
}
}