|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace hipanel\models; |
|
4
|
|
|
|
|
5
|
|
|
use hipanel\base\Model; |
|
6
|
|
|
use hipanel\base\ModelTrait; |
|
7
|
|
|
use Yii; |
|
8
|
|
|
|
|
9
|
|
|
class Reminder extends Model |
|
10
|
|
|
{ |
|
11
|
|
|
use ModelTrait; |
|
12
|
|
|
|
|
13
|
|
|
public static $i18nDictionary = 'hipanel/reminder'; |
|
14
|
|
|
|
|
15
|
|
|
const REMINDER_SCENARIO_CREATE = 'create'; |
|
16
|
|
|
const REMINDER_SCENARIO_UPDATE = 'update'; |
|
17
|
|
|
const REMINDER_SCENARIO_DELETE = 'delete'; |
|
18
|
|
|
|
|
19
|
|
|
const REMINDER_TYPE_SITE = 'site'; |
|
20
|
|
|
const REMINDER_TYPE_MAIL = 'mail'; |
|
21
|
|
|
|
|
22
|
|
|
public static function reminderNextTimeOptions() |
|
23
|
|
|
{ |
|
24
|
|
|
return [ |
|
25
|
|
|
'15 minutes' => Yii::t('hipanel/reminder', '15m'), |
|
26
|
|
|
'30 minutes' => Yii::t('hipanel/reminder', '30m'), |
|
27
|
|
|
'1 hour' => Yii::t('hipanel/reminder', '1h'), |
|
28
|
|
|
'12 hour' => Yii::t('hipanel/reminder', '12h'), |
|
29
|
|
|
'1 day' => Yii::t('hipanel/reminder', '1d'), |
|
30
|
|
|
]; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritdoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
public function rules() |
|
37
|
|
|
{ |
|
38
|
|
|
return [ |
|
39
|
|
|
[['id', 'object_id', 'client_id', 'state_id', 'type_id'], 'integer'], |
|
40
|
|
|
[['class', 'periodicity', 'from_time', 'till_time', 'next_time'], 'string'], |
|
41
|
|
|
[['to_site'], 'boolean'], |
|
42
|
|
|
|
|
43
|
|
|
// Create |
|
44
|
|
|
[['object_id', 'type', 'periodicity', 'from_time', 'message'], 'required', 'on' => self::REMINDER_SCENARIO_CREATE], |
|
45
|
|
|
|
|
46
|
|
|
// Update |
|
47
|
|
|
[['id'], 'required', 'on' => 'update'], |
|
48
|
|
|
[['object_id', 'state_id', 'type_id'], 'integer', 'on' => self::REMINDER_SCENARIO_UPDATE], |
|
49
|
|
|
[['from_time', 'next_time', 'till_time'], 'date', 'on' => self::REMINDER_SCENARIO_UPDATE], |
|
50
|
|
|
|
|
51
|
|
|
// Delete |
|
52
|
|
|
[['id'], 'required', 'on' => self::REMINDER_SCENARIO_DELETE] |
|
53
|
|
|
]; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritdoc} |
|
58
|
|
|
*/ |
|
59
|
|
|
public function attributeLabels() |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->mergeAttributeLabels([ |
|
62
|
|
|
'periodicity' => Yii::t('hipanel/reminder', 'Periodicity'), |
|
63
|
|
|
'from_time' => Yii::t('hipanel/reminder', 'When the recall?'), |
|
64
|
|
|
'next_time' => Yii::t('hipanel/reminder', 'Next remind'), |
|
65
|
|
|
'till_time' => Yii::t('hipanel/reminder', 'Remind till'), |
|
66
|
|
|
'message' => Yii::t('hipanel/reminder', 'Message'), |
|
67
|
|
|
]); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function getObjectName() |
|
71
|
|
|
{ |
|
72
|
|
|
$result = ''; |
|
73
|
|
|
if ($this->class) { |
|
|
|
|
|
|
74
|
|
|
switch ($this->class) { |
|
|
|
|
|
|
75
|
|
|
case 'thread': |
|
76
|
|
|
$result = 'ticket'; |
|
77
|
|
|
break; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
return $result; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.