Skip to content

Commit

Permalink
Added more filters
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Jan 5, 2017
1 parent b12b8d0 commit 7d07209
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 10 deletions.
18 changes: 15 additions & 3 deletions src/controllers/PrepareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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');
}
}
10 changes: 9 additions & 1 deletion src/forms/FiltersForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ class FiltersForm extends Model

public $has_domain;

public $domain_state_in;

public $exclude_unsubscribed;

public $language_in;

public function attributes()
{
return [
'client_in', 'client_state_in',
'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',
];
}
Expand All @@ -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'),
];
}
}
2 changes: 2 additions & 0 deletions src/messages/ru/hipanel:mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@
'Switch' => 'Свитч',
'Type' => 'Тип',
'Set filters to start the mailing preparation' => 'Установить фильтры для начала подготовки рассылки',
'Not set' => 'Не выбран',
'Languages' => 'Языки',
];
4 changes: 4 additions & 0 deletions src/models/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class Target extends Model

public $servers;

public $server_states;

public $domains;

public function attributes()
Expand All @@ -39,6 +41,7 @@ public function attributes()
'to',
'language',
'servers',
'server_states',
'domains',
];
}
Expand All @@ -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'),
];
}
Expand Down
42 changes: 41 additions & 1 deletion src/views/prepare/_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
?>

Expand All @@ -24,6 +27,20 @@
]) ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('language_in')->widget(\hiqdev\combo\MultipleStaticCombo::class, [
'hasId' => true,
'data' => ['' => Yii::t('hipanel:mailing', 'Not set')] + $languages,
'inputOptions' => [
'multiple' => true,
],
]) ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('exclude_unsubscribed')->checkbox() ?>
</div>

<?php if (Yii::getAlias('@server', false) !== false) : ?>
<div class="col-md-4 col-sm-6 col-xs-12 text-center">
<hr>
Expand All @@ -39,24 +56,39 @@
'multiple' => true,
]) ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('server_state_in')->widget(StaticCombo::class, [
'multiple' => true,
'hasId' => true,
'data' => $serverStates,
]) ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('server_state_in')->widget(StaticCombo::class, [
'multiple' => true,
'hasId' => true,
'data' => $serverStates,
]) ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('server_type_in')->widget(StaticCombo::class, [
'multiple' => true,
'hasId' => true,
'data' => $serverTypes,
]) ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('server_switch_like') ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('server_rack_like') ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('server_pdu_like') ?>
</div>
Expand All @@ -72,6 +104,14 @@
<?= $search->field('has_domain')->checkbox() ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('domain_state_in')->widget(StaticCombo::class, [
'multiple' => true,
'hasId' => true,
'data' => $domainStates,
]) ?>
</div>

<div class="col-md-4 col-sm-6 col-xs-12">
<?= $search->field('domain_like') ?>
</div>
Expand Down
13 changes: 8 additions & 5 deletions src/views/prepare/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +19,7 @@
?>

<?php $page = IndexPage::begin(compact('model', 'dataProvider')) ?>
<?= $page->setSearchFormData(compact(['types', 'states', 'statuses'])) ?>
<?= $page->setSearchFormData(compact(['serverTypes', 'serverStates', 'domainStates', 'languages'])) ?>

<?php $page->beginContent('show-actions') ?>
<?= $page->renderLayoutSwitcher() ?>
Expand All @@ -44,6 +46,7 @@
'to',
'language',
'servers',
'server_states',
'domains',
],
]) ?>
Expand Down

0 comments on commit 7d07209

Please sign in to comment.