diff --git a/src/controllers/PrepareController.php b/src/controllers/PrepareController.php index f8d3827..4fb736d 100644 --- a/src/controllers/PrepareController.php +++ b/src/controllers/PrepareController.php @@ -58,6 +58,8 @@ public function actionIndex() 'clientTypes' => $this->getClientTypes(), 'serverTypes' => $this->getServerTypes(), 'serverStates' => $this->getServerStates(), + 'domainStates' => $this->getDomainStates(), + 'languages' => $this->getLanguages(), ]; if ($model->load(Yii::$app->request->get()) && $model->validate()) { @@ -89,16 +91,26 @@ public function actionExport() private function getClientTypes() { - return $this->getRefs('type,client'); + return $this->getRefs('type,client', 'hipanel:client'); } private function getServerTypes() { - return $this->getRefs('type,server'); + return $this->getRefs('type,device', 'hipanel:server'); } private function getServerStates() { - return $this->getRefs('state,server'); + return $this->getRefs('state,device', 'hipanel:server'); + } + + private function getDomainStates() + { + return $this->getRefs('state,domain', 'hipanel:domain'); + } + + private function getLanguages() + { + return $this->getRefs('type,lang', 'hipanel'); } } diff --git a/src/forms/FiltersForm.php b/src/forms/FiltersForm.php index 1156625..12886d9 100644 --- a/src/forms/FiltersForm.php +++ b/src/forms/FiltersForm.php @@ -39,8 +39,12 @@ class FiltersForm extends Model public $has_domain; + public $domain_state_in; + public $exclude_unsubscribed; + public $language_in; + public function attributes() { return [ @@ -48,7 +52,8 @@ public function attributes() 'seller_in', 'server_in', 'has_server', 'server_state_in', 'server_type_in', 'server_switch_like', 'server_rack_like', 'server_pdu_like', - 'domain_like', 'has_domain', + 'domain_like', 'has_domain', 'domain_state_in', + 'language_in', 'exclude_unsubscribed', ]; } @@ -75,7 +80,10 @@ public function attributeLabels() 'server_pdu_like' => Yii::t('hipanel:mailing', 'PDU'), 'has_domain' => Yii::t('hipanel:mailing', 'Has domain'), 'domain_like' => Yii::t('hipanel:mailing', 'Domain'), + 'domain_state_in' => Yii::t('hipanel:mailing', 'State'), 'exclude_unsubscribed' => Yii::t('hipanel:mailing', 'Exclude unsubscribed'), + 'language_in' => Yii::t('hipanel:mailing', 'Languages'), + 'language_unknown' => Yii::t('hipanel:mailing', 'Language is unknown'), ]; } } diff --git a/src/messages/ru/hipanel:mailing.php b/src/messages/ru/hipanel:mailing.php index f4c80b2..0b63adb 100644 --- a/src/messages/ru/hipanel:mailing.php +++ b/src/messages/ru/hipanel:mailing.php @@ -31,4 +31,6 @@ 'Switch' => 'Свитч', 'Type' => 'Тип', 'Set filters to start the mailing preparation' => 'Установить фильтры для начала подготовки рассылки', + 'Not set' => 'Не выбран', + 'Languages' => 'Языки', ]; diff --git a/src/models/Target.php b/src/models/Target.php index c5960f5..5914b2e 100644 --- a/src/models/Target.php +++ b/src/models/Target.php @@ -29,6 +29,8 @@ class Target extends Model public $servers; + public $server_states; + public $domains; public function attributes() @@ -39,6 +41,7 @@ public function attributes() 'to', 'language', 'servers', + 'server_states', 'domains', ]; } @@ -51,6 +54,7 @@ public function attributeLabels() 'to' => Yii::t('hipanel:mailing', 'Email'), 'language' => Yii::t('hipanel:mailing', 'Language'), 'servers' => Yii::t('hipanel:mailing', 'Servers'), + 'server_states' => Yii::t('hipanel:mailing', 'Server states'), 'domains' => Yii::t('hipanel:mailing', 'Domains'), ]; } diff --git a/src/views/prepare/_search.php b/src/views/prepare/_search.php index 8397462..ba1ab91 100644 --- a/src/views/prepare/_search.php +++ b/src/views/prepare/_search.php @@ -6,9 +6,12 @@ use hiqdev\combo\StaticCombo; /** - * @var \hipanel\widgets\AdvancedSearch + * @var \yii\web\View + * @var \hipanel\widgets\AdvancedSearch $search * @var array $serverStates * @var array $serverTypes + * @var array $domainStates + * @var array $languages */ ?> @@ -24,6 +27,20 @@ ]) ?> +
+ field('language_in')->widget(\hiqdev\combo\MultipleStaticCombo::class, [ + 'hasId' => true, + 'data' => ['' => Yii::t('hipanel:mailing', 'Not set')] + $languages, + 'inputOptions' => [ + 'multiple' => true, + ], + ]) ?> +
+ +
+ field('exclude_unsubscribed')->checkbox() ?> +
+

@@ -39,24 +56,39 @@ 'multiple' => true, ]) ?>
+
field('server_state_in')->widget(StaticCombo::class, [ 'multiple' => true, + 'hasId' => true, 'data' => $serverStates, ]) ?>
+ +
+ field('server_state_in')->widget(StaticCombo::class, [ + 'multiple' => true, + 'hasId' => true, + 'data' => $serverStates, + ]) ?> +
+
field('server_type_in')->widget(StaticCombo::class, [ 'multiple' => true, + 'hasId' => true, 'data' => $serverTypes, ]) ?>
+
field('server_switch_like') ?>
+
field('server_rack_like') ?>
+
field('server_pdu_like') ?>
@@ -72,6 +104,14 @@ field('has_domain')->checkbox() ?> +
+ field('domain_state_in')->widget(StaticCombo::class, [ + 'multiple' => true, + 'hasId' => true, + 'data' => $domainStates, + ]) ?> +
+
field('domain_like') ?>
diff --git a/src/views/prepare/index.php b/src/views/prepare/index.php index 33ad47f..8d332c9 100644 --- a/src/views/prepare/index.php +++ b/src/views/prepare/index.php @@ -4,11 +4,13 @@ use yii\helpers\Html; /** - * @var \yii\data\ArrayDataProvider + * @var \yii\web\View + * @var \yii\data\ArrayDataProvider $dataProvider * @var \hipanel\modules\mailing\forms\FiltersForm $model - * @var array $types - * @var array $states - * @var array $statuses + * @var array $serverTypes + * @var array $serverStates + * @var array $domainStates + * @var array $languages */ $this->title = Yii::t('hipanel:mailing', 'Mailing preparation'); $this->params['breadcrumbs'][] = $this->title; @@ -17,7 +19,7 @@ ?> -setSearchFormData(compact(['types', 'states', 'statuses'])) ?> +setSearchFormData(compact(['serverTypes', 'serverStates', 'domainStates', 'languages'])) ?> beginContent('show-actions') ?> renderLayoutSwitcher() ?> @@ -44,6 +46,7 @@ 'to', 'language', 'servers', + 'server_states', 'domains', ], ]) ?>