|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* HiPanel core package |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://hipanel.com/ |
|
6
|
|
|
* @package hipanel-core |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hipanel\widgets; |
|
12
|
|
|
|
|
13
|
|
|
use yii\base\InvalidConfigException; |
|
14
|
|
|
use yii\base\Widget; |
|
15
|
|
|
use yii\db\ActiveRecord; |
|
16
|
|
|
|
|
17
|
|
|
class BulkOperation extends Widget |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var ActiveRecord |
|
21
|
|
|
*/ |
|
22
|
|
|
public $model; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var ActiveRecord[] |
|
26
|
|
|
*/ |
|
27
|
|
|
public $models; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
public $scenario; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var array |
|
36
|
|
|
*/ |
|
37
|
|
|
public $hiddenInputs = []; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
public $visibleInputs = []; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var array |
|
46
|
|
|
*/ |
|
47
|
|
|
public $dropDownInputs = []; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
public $headerTitle; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var string |
|
56
|
|
|
*/ |
|
57
|
|
|
public $bodyWarning; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var string |
|
61
|
|
|
*/ |
|
62
|
|
|
public $panelBody; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var string |
|
66
|
|
|
*/ |
|
67
|
|
|
public $submitButton; |
|
68
|
|
|
public $submitButtonOptions; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @var string |
|
72
|
|
|
*/ |
|
73
|
|
|
public $affectedObjects; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @var string |
|
77
|
|
|
*/ |
|
78
|
|
|
public $formatterField = 'name'; |
|
79
|
|
|
|
|
80
|
|
|
public function init() |
|
81
|
|
|
{ |
|
82
|
|
|
parent::init(); |
|
83
|
|
|
|
|
84
|
|
|
if ($this->model === null) { |
|
85
|
|
|
throw new InvalidConfigException('Please specify the "model" property.'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
if ($this->models === null) { |
|
89
|
|
|
throw new InvalidConfigException('Please specify the "models" property.'); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
if ($this->scenario === null) { |
|
93
|
|
|
throw new InvalidConfigException('Please specify the "scenario" property.'); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
if ($this->affectedObjects === null) { |
|
97
|
|
|
throw new InvalidConfigException('Please specify the "affectedObjects" property.'); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
if ($this->hiddenInputs === null) { |
|
101
|
|
|
$this->hiddenInputs = []; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
if ($this->dropDownInputs === null) { |
|
105
|
|
|
$this->dropDownInputs = []; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
if ($this->visibleInputs === null) { |
|
109
|
|
|
$this->visibleInputs = []; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function run() |
|
114
|
|
|
{ |
|
115
|
|
|
echo $this->render('bulk-operation', [ |
|
116
|
|
|
'model' => $this->model, |
|
117
|
|
|
'models' => $this->models, |
|
118
|
|
|
'scenario' => $this->scenario, |
|
119
|
|
|
'formatterField' => $this->formatterField, |
|
120
|
|
|
'panelBody' => $this->panelBody, |
|
121
|
|
|
'bodyWarning' => $this->bodyWarning, |
|
122
|
|
|
'hiddenInputs' => $this->hiddenInputs, |
|
123
|
|
|
'visibleInputs' => $this->visibleInputs, |
|
124
|
|
|
'dropDownInputs' => $this->dropDownInputs, |
|
125
|
|
|
'submitButton' => $this->submitButton, |
|
126
|
|
|
'submitButtonOptions' => $this->submitButtonOptions, |
|
127
|
|
|
'affectedObjects' => $this->affectedObjects, |
|
128
|
|
|
]); |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|