|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace hipanel\modules\finance\models; |
|
4
|
|
|
|
|
5
|
|
|
use Yii; |
|
6
|
|
|
use yii\base\Model; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class PriceSuggestionRequestForm |
|
10
|
|
|
* |
|
11
|
|
|
* @author Dmytro Naumenko <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
class PriceSuggestionRequestForm extends Model |
|
14
|
|
|
{ |
|
15
|
|
|
public const SCENARIO_PREDEFINED_OBJECT = 'predefinedObject'; |
|
16
|
|
|
|
|
17
|
|
|
public $plan_id; |
|
18
|
|
|
|
|
19
|
|
|
public $plan_type; |
|
20
|
|
|
|
|
21
|
|
|
public $template_plan_id; |
|
22
|
|
|
|
|
23
|
|
|
public $type; |
|
24
|
|
|
|
|
25
|
|
|
public $object_id; |
|
26
|
|
|
|
|
27
|
|
|
public function formName() |
|
28
|
|
|
{ |
|
29
|
|
|
return ''; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function rules() |
|
33
|
|
|
{ |
|
34
|
|
|
$result = [ |
|
35
|
|
|
[['plan_id', 'type'], 'required', 'on' => [self::SCENARIO_DEFAULT, self::SCENARIO_PREDEFINED_OBJECT]], |
|
36
|
|
|
[['object_id', 'type'], 'required', 'on' => [self::SCENARIO_DEFAULT]], |
|
37
|
|
|
[['plan_id', 'object_id', 'template_plan_id'], 'integer', 'on' => [self::SCENARIO_DEFAULT, self::SCENARIO_PREDEFINED_OBJECT]], |
|
38
|
|
|
[['type'], 'safe', 'on' => [self::SCENARIO_DEFAULT, self::SCENARIO_PREDEFINED_OBJECT]], |
|
39
|
|
|
]; |
|
40
|
|
|
if ($this->plan_type !== Plan::TYPE_TEMPLATE) { |
|
41
|
|
|
$result[] = [['template_plan_id'], 'required']; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
return $result; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function isObjectPredefined(): bool |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->scenario === self::SCENARIO_PREDEFINED_OBJECT; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function attributeLabels() |
|
53
|
|
|
{ |
|
54
|
|
|
return [ |
|
55
|
|
|
'plan_id' => Yii::t('hipanel.finance.price', 'Tariff plan'), |
|
56
|
|
|
'template_plan_id' => Yii::t('hipanel.finance.price', 'Template tariff plan'), |
|
57
|
|
|
'type' => Yii::t('hipanel', 'Type'), |
|
58
|
|
|
'object_id' => Yii::t('hipanel', 'Object'), |
|
59
|
|
|
]; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|