<?php
namespace OCA\Chores\Db;
use DateTimeImmutable;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
class WorklogItem extends Entity implements JsonSerializable {
protected $teamId;
protected $choreId;
protected $doneTimestamp;
protected $submitTimestamp;
protected $memberUid;
protected $name;
protected $points;
public function __construct() {
$this->addType('id', 'string');
$this->addType('teamId', 'integer');
$this->addType('choreId', 'integer');
$this->addType('doneTimestamp', 'datetimetz_immutable');
$this->addType('submitTimestamp', 'datetimetz_immutable');
$this->addType('memberUid', 'string');
$this->addType('name', 'string');
$this->addType('points', 'integer');
}
public function getSubmitTimestamp(): string {
return $this->getSubmitTimestampDate()->format("c");
}
public function setSubmitTimestamp(string $submitTimestampStr) {
$this->submitTimestamp = new DateTimeImmutable($submitTimestampStr);
$this->markFieldUpdated("submitTimestamp");
}
public function getSubmitTimestampDate(): DateTimeImmutable {
return $this->submitTimestamp;
}
public function setSubmitTimestampDate(DateTimeImmutable $submitTimestampDate) {
$this->submitTimestamp = $submitTimestampDate;
$this->markFieldUpdated("submitTimestamp");
}
public function getDoneTimestamp(): string {
return $this->getDoneTimestampDate()->format("c");
}
public function setDoneTimestamp(string $doneTimestampStr) {
$this->doneTimestamp = new DateTimeImmutable($doneTimestampStr);
$this->markFieldUpdated("doneTimestamp");
}
public function getDoneTimestampDate(): DateTimeImmutable {
return $this->doneTimestamp;
}
public function setDoneTimestampDate(DateTimeImmutable $doneTimestampDate) {
$this->doneTimestamp = $doneTimestampDate;
$this->markFieldUpdated("doneTimestamp");
}
public function jsonSerialize() {
return [
'id' => $this->id,
'member' => $this->memberUid,
'work_time' => $this->getDoneTimestamp(),
'submit_time' => $this->getSubmitTimestamp(),
'name' => $this->name,
'points' => $this->points,
];
}
}