forked from robotomarvin/Tasker
/
Note.php
65 lines (58 loc) · 1.26 KB
/
Note.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace Models;
use Models\Base\Note as BaseNote;
use \DateTime;
/**
* Skeleton subclass for representing a row from the 'note' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class Note extends BaseNote
{
public function getFormatedDeadline(){
return $this->getDeadline()->format("d. m. Y h:m");
}
public function getStateText(){
return $this->getState();
}
public function getStateClass(){
$days = null;
$deadline = false;
if($this->getDeadline()){
$days = $this->getDeadLine()->getTimeStamp() - (new DateTime())->getTimeStamp();
$days /= 86400;
$deadline = true;
}
switch ($this->getState()) {
case 'closed':
return 'closed';
break;
case 'done':
return 'ok';
break;
case 'opened':
if(!$deadline || $days > 1)
return 'ok';
if($days > 0)
return 'soon';
return 'late';
break;
case 'wip':
if(!$deadline || $days > 0)
return 'soon';
return 'late';
break;
}
}
public function getShowPath(){
return '/notes/' . $this->getId();
}
public function getEditPath(){
return '/notes/edit/' . $this->getId();
}
}