|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Finance module for HiPanel |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
|
6
|
|
|
* @package hipanel-module-finance |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hipanel\modules\finance\models; |
|
12
|
|
|
|
|
13
|
|
|
use hipanel\modules\client\models\Contact; |
|
14
|
|
|
use Yii; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class Requisite. |
|
18
|
|
|
*/ |
|
19
|
|
|
class Requisite extends Contact |
|
20
|
|
|
{ |
|
21
|
|
|
/* |
|
22
|
|
|
* @return array the list of attributes for this record |
|
23
|
|
|
*/ |
|
24
|
|
|
use \hipanel\base\ModelTrait; |
|
25
|
|
|
|
|
26
|
|
|
public static function tableName() |
|
27
|
|
|
{ |
|
28
|
|
|
return 'requisite'; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function rules() |
|
32
|
|
|
{ |
|
33
|
|
|
return array_merge(parent::rules(), [ |
|
34
|
|
|
[['id', 'client_id', 'recipient_id'], 'integer'], |
|
35
|
|
|
[['id'], 'required', 'on' => ['reserve-number', 'set-templates', 'set-serie']], |
|
36
|
|
|
[['client_id', 'recipient_id'], 'required', 'on' => ['reserve-number']], |
|
37
|
|
|
[['invoice_id', 'acceptance_id', 'contract_id', 'probation_id', 'internal_invoice_id'], 'safe'], |
|
38
|
|
|
[['serie'], 'safe'], |
|
39
|
|
|
[['serie'], 'required', 'on' => ['set-serie', 'update']], |
|
40
|
|
|
[['invoice_id'], 'required', 'on' => ['set-templates', 'update']], |
|
41
|
|
|
[['invoice_name', 'acceptance_name', 'contract_name', 'probation_name', 'internal_invoice_name'], 'safe'], |
|
42
|
|
|
]); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function isRequisite() |
|
46
|
|
|
{ |
|
47
|
|
|
return (boolean) $this->is_requisite; |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function isEmpty($fields) : bool |
|
51
|
|
|
{ |
|
52
|
|
|
$fields = is_string($fields) ? array_map(function($v) { |
|
53
|
|
|
return trim($v); |
|
54
|
|
|
}, explode(",", $fields)) : $fields; |
|
55
|
|
|
|
|
56
|
|
|
foreach ($fields as $field) { |
|
57
|
|
|
if (!empty($this->$field)) { |
|
58
|
|
|
return false; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return true; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function attributeLabels() |
|
66
|
|
|
{ |
|
67
|
|
|
return array_merge(parent::attributeLabels(), [ |
|
68
|
|
|
'serie' => Yii::t('hipanel:finance', 'Serie'), |
|
69
|
|
|
'invoice_id' => Yii::t('hipanel:finance', 'Invoice template'), |
|
70
|
|
|
'acceptance_id' => Yii::t('hipanel:finance', 'Acceptance template'), |
|
71
|
|
|
'contract_id' => Yii::t('hipanel:finance', 'Contract template'), |
|
72
|
|
|
'probation_id' => Yii::t('hipanel:finance', 'Probation template'), |
|
73
|
|
|
'requisites' => Yii::t('hipanel:finance', 'Requisites'), |
|
74
|
|
|
'invoice_name' => Yii::t('hipanel:finance', 'Invoice template'), |
|
75
|
|
|
'acceptance_name' => Yii::t('hipanel:finance', 'Acceptance template'), |
|
76
|
|
|
'contract_name' => Yii::t('hipanel:finance', 'Contract template'), |
|
77
|
|
|
'probation_name' => Yii::t('hipanel:finance', 'Probation template'), |
|
78
|
|
|
'recipient_id' => Yii::t('hipanel:finance', 'Recipient'), |
|
79
|
|
|
]); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
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.