|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Finance module for HiPanel |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
|
7
|
|
|
* @package hipanel-module-finance |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace hipanel\modules\finance\models; |
|
13
|
|
|
|
|
14
|
|
|
use Yii; |
|
15
|
|
|
|
|
16
|
|
|
class Bill extends \hipanel\base\Model |
|
17
|
|
|
{ |
|
18
|
|
|
use \hipanel\base\ModelTrait; |
|
19
|
|
|
|
|
20
|
|
|
public $time_from; |
|
21
|
|
|
public $time_till; |
|
22
|
|
|
|
|
23
|
|
|
const SCENARIO_CREATE = 'create'; |
|
24
|
|
|
const SCENARIO_UPDATE = 'update'; |
|
25
|
|
|
const SCENARIO_DELETE = 'delete'; |
|
26
|
|
|
|
|
27
|
|
|
public static $i18nDictionary = 'hipanel/finance'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* {@inheritdoc} |
|
31
|
|
|
*/ |
|
32
|
|
|
public function rules() |
|
33
|
|
|
{ |
|
34
|
|
|
return [ |
|
35
|
|
|
[['client_id', 'seller_id', 'id'], 'integer'], |
|
36
|
|
|
[['object_id', 'tariff_id'], 'integer'], |
|
37
|
|
|
[['client', 'seller', 'bill'], 'safe'], |
|
38
|
|
|
[['domain', 'server'], 'safe'], |
|
39
|
|
|
[['sum', 'balance', 'quantity'], 'number'], |
|
40
|
|
|
[['currency', 'label', 'descr'], 'safe'], |
|
41
|
|
|
[['object', 'domains', 'tariff'], 'safe'], |
|
42
|
|
|
[['type', 'gtype', 'class'], 'safe'], |
|
43
|
|
|
[['class_label'], 'safe'], |
|
44
|
|
|
[['type_label', 'gtype_label'], 'safe'], |
|
45
|
|
|
[['time'], 'date', 'format' => 'php:d.m.Y H:i:s'], |
|
46
|
|
|
|
|
47
|
|
|
[['id'], 'required', 'on' => [self::SCENARIO_UPDATE, self::SCENARIO_DELETE]], |
|
48
|
|
|
[['client_id'], 'integer', 'on' => [self::SCENARIO_CREATE]], |
|
49
|
|
|
[['currency', 'sum', 'type', 'label'], 'required', 'on' => [self::SCENARIO_CREATE, self::SCENARIO_UPDATE]], |
|
50
|
|
|
[['client_id', 'sum', 'time'], 'required', 'on' => [self::SCENARIO_CREATE]], |
|
51
|
|
|
[['client'], 'safe', 'on' => [self::SCENARIO_CREATE]], |
|
52
|
|
|
]; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* {@inheritdoc} |
|
57
|
|
|
*/ |
|
58
|
|
|
public function attributeLabels() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->mergeAttributeLabels([ |
|
61
|
|
|
'client' => Yii::t('hipanel', 'Client'), |
|
62
|
|
|
'time' => Yii::t('hipanel', 'Time'), |
|
63
|
|
|
'currency' => Yii::t('hipanel', 'Currency'), |
|
64
|
|
|
'balance' => Yii::t('hipanel', 'Balance'), |
|
65
|
|
|
'gtype' => Yii::t('hipanel', 'Type'), |
|
66
|
|
|
'gtype_label' => Yii::t('hipanel', 'Type'), |
|
67
|
|
|
'sum' => Yii::t('hipanel/finance', 'Sum'), |
|
68
|
|
|
'tariff' => Yii::t('hipanel/finance', 'Tariff'), |
|
69
|
|
|
'tariff_id' => Yii::t('hipanel/finance', 'Tariff'), |
|
70
|
|
|
]); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function prepareToCopy() |
|
74
|
|
|
{ |
|
75
|
|
|
$this->id = null; |
|
|
|
|
|
|
76
|
|
|
$this->setIsNewRecord(true); |
|
77
|
|
|
|
|
78
|
|
|
return true; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write 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.