|
|
@ -3,9 +3,11 @@ |
|
|
|
use common\modules\forms\entities\FormMessage; |
|
|
|
use common\modules\forms\entities\FormMessage; |
|
|
|
use yii\grid\ActionColumn; |
|
|
|
use yii\grid\ActionColumn; |
|
|
|
use yii\helpers\Html; |
|
|
|
use yii\helpers\Html; |
|
|
|
|
|
|
|
use yii\helpers\Url; |
|
|
|
use yii\grid\GridView; |
|
|
|
use yii\grid\GridView; |
|
|
|
use yii\helpers\ArrayHelper; |
|
|
|
use yii\helpers\ArrayHelper; |
|
|
|
use common\modules\forms\entities\Form; |
|
|
|
use common\modules\forms\entities\Form; |
|
|
|
|
|
|
|
use backend\widgets\grid\CheckBoxColumn; |
|
|
|
|
|
|
|
|
|
|
|
/* @var $this yii\web\View */ |
|
|
|
/* @var $this yii\web\View */ |
|
|
|
/* @var $searchModel \common\modules\forms\forms\FormMessageSearch */ |
|
|
|
/* @var $searchModel \common\modules\forms\forms\FormMessageSearch */ |
|
|
@ -13,15 +15,118 @@ use common\modules\forms\entities\Form; |
|
|
|
|
|
|
|
|
|
|
|
$this->title = Yii::t('form', 'Messages'); |
|
|
|
$this->title = Yii::t('form', 'Messages'); |
|
|
|
$this->params['breadcrumbs'][] = $this->title; |
|
|
|
$this->params['breadcrumbs'][] = $this->title; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$js = <<<JS |
|
|
|
|
|
|
|
var body = $('body'); |
|
|
|
|
|
|
|
$('.select-on-check-all').addClass('grid_checkbox'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
body.on('change', '.grid_checkbox', function(e) { |
|
|
|
|
|
|
|
var button = $('#groupActions'); |
|
|
|
|
|
|
|
if (!multiSelected()) { |
|
|
|
|
|
|
|
button.attr('disabled', 'disabled'); |
|
|
|
|
|
|
|
button.addClass('disabled'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
button.removeAttr('disabled'); |
|
|
|
|
|
|
|
button.removeClass('disabled'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
JS; |
|
|
|
|
|
|
|
$this->registerJs($js, $this::POS_READY); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$deleteConfirmMessage = Yii::t('form', 'Are you sure you want to delete selected messages?'); |
|
|
|
|
|
|
|
$deleteSelectedUrl = Url::to(['delete-selected']); |
|
|
|
|
|
|
|
$unreadSelectedUrl = Url::to(['unread-selected']); |
|
|
|
|
|
|
|
$readSelectedUrl = Url::to(['read-selected']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$js2 = <<<JS2 |
|
|
|
|
|
|
|
function getRows() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var ids = new Array(); |
|
|
|
|
|
|
|
$('input[name="gridSelection[]"]:checked').each(function() { |
|
|
|
|
|
|
|
ids.push(this.value); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return ids; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function multiSelected() { |
|
|
|
|
|
|
|
var result = false; |
|
|
|
|
|
|
|
$('input[name="gridSelection[]"]:checked').each(function() { |
|
|
|
|
|
|
|
result = true; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function deleteSelected() { |
|
|
|
|
|
|
|
if (confirm('{$deleteConfirmMessage}')) { |
|
|
|
|
|
|
|
var ids = JSON.stringify(getRows()); |
|
|
|
|
|
|
|
$.post( "{$deleteSelectedUrl}", { ids: ids}) |
|
|
|
|
|
|
|
.done(function( data ) { |
|
|
|
|
|
|
|
document.location.reload(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function unreadSelected() { |
|
|
|
|
|
|
|
var ids = JSON.stringify(getRows()); |
|
|
|
|
|
|
|
$.post( "{$unreadSelectedUrl}", { ids: ids}) |
|
|
|
|
|
|
|
.done(function( data ) { |
|
|
|
|
|
|
|
document.location.reload(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function readSelected() { |
|
|
|
|
|
|
|
var ids = JSON.stringify(getRows()); |
|
|
|
|
|
|
|
$.post( "{$readSelectedUrl}", { ids: ids}) |
|
|
|
|
|
|
|
.done(function( data ) { |
|
|
|
|
|
|
|
document.location.reload(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JS2; |
|
|
|
|
|
|
|
$this->registerJs($js2, $this::POS_HEAD); |
|
|
|
?> |
|
|
|
?> |
|
|
|
<div class="messages-index"> |
|
|
|
<div class="messages-index"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div style="margin-bottom: 10px;"> |
|
|
|
|
|
|
|
<div class="btn-group"> |
|
|
|
|
|
|
|
<?= Html::a(Yii::t('form', 'Group actions {caret}', ['caret' => '<span class="caret">']), '#', [ |
|
|
|
|
|
|
|
'class' => 'btn btn-default dropdown-toggle disabled', |
|
|
|
|
|
|
|
'id' => 'groupActions', |
|
|
|
|
|
|
|
'disabled' => 'disabled', |
|
|
|
|
|
|
|
'data-toggle' => 'dropdown', |
|
|
|
|
|
|
|
'aria-haspopup' => 'true', |
|
|
|
|
|
|
|
'aria-expanded' => 'false', |
|
|
|
|
|
|
|
]) ?> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="dropdown-menu"> |
|
|
|
|
|
|
|
<li><?= Html::a(Yii::t('form', 'Mark as read'), '#', [ |
|
|
|
|
|
|
|
'onclick' => new \yii\web\JsExpression('readSelected()'), |
|
|
|
|
|
|
|
]) ?></li> |
|
|
|
|
|
|
|
<li><?= Html::a(Yii::t('form', 'Mark as unread'), '#', [ |
|
|
|
|
|
|
|
'onclick' => new \yii\web\JsExpression('unreadSelected()'), |
|
|
|
|
|
|
|
]) ?></li> |
|
|
|
|
|
|
|
<li role="separator" class="divider"></li> |
|
|
|
|
|
|
|
<li><?= Html::a(Yii::t('form', 'Delete selected'), '#', [ |
|
|
|
|
|
|
|
'onclick' => new \yii\web\JsExpression('deleteSelected()'), |
|
|
|
|
|
|
|
]) ?></li> |
|
|
|
|
|
|
|
</ul> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div class="box"> |
|
|
|
<div class="box"> |
|
|
|
<div class="box-body"> |
|
|
|
<div class="box-body"> |
|
|
|
<?= GridView::widget([ |
|
|
|
<?= GridView::widget([ |
|
|
|
'dataProvider' => $dataProvider, |
|
|
|
'dataProvider' => $dataProvider, |
|
|
|
'filterModel' => $searchModel, |
|
|
|
'filterModel' => $searchModel, |
|
|
|
'columns' => [ |
|
|
|
'columns' => [ |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
'class' => CheckBoxColumn::class, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
'attribute' => 'id', |
|
|
|
|
|
|
|
'options' => ['style' => 'width: 50px;'], |
|
|
|
|
|
|
|
'contentOptions' => ['class' => 'text-center'], |
|
|
|
|
|
|
|
], |
|
|
|
[ |
|
|
|
[ |
|
|
|
'label' => Yii::t('form', 'Date'), |
|
|
|
'label' => Yii::t('form', 'Date'), |
|
|
|
'attribute' => 'created_at', |
|
|
|
'attribute' => 'created_at', |
|
|
@ -43,6 +148,7 @@ $this->params['breadcrumbs'][] = $this->title; |
|
|
|
], |
|
|
|
], |
|
|
|
[ |
|
|
|
[ |
|
|
|
'class' => ActionColumn::class, |
|
|
|
'class' => ActionColumn::class, |
|
|
|
|
|
|
|
'template' => '{view} {delete}', |
|
|
|
'options' => ['style' => 'width: 100px;'], |
|
|
|
'options' => ['style' => 'width: 100px;'], |
|
|
|
'contentOptions' => ['class' => 'text-center'], |
|
|
|
'contentOptions' => ['class' => 'text-center'], |
|
|
|
], |
|
|
|
], |
|
|
|