<commit_before><?php
use yii\helpers\Html;
use app\components\grid\GridView;
use yii\data\ArrayDataProvider;
use yii\bootstrap\Modal;
use app\models\Member;
use app\models\Code;
use app\models\forms\EmailForm;
use app\models\MemberSearch;
use app\components\helpers\PollUrl;
use yii\widgets\ActiveForm;
use kartik\widgets\AlertBlock;
use kartik\widgets\Alert;

// display all "import" flash messages
foreach (Yii::$app->getSession()->getAllFlashes() as $key => $arr) {
    if ($key === 'import') {
        foreach ($arr as $message) {
            echo AlertBlock::widget([
                'useSessionFlash' => false,
                'type' => AlertBlock::TYPE_ALERT,
                'delay' => false, // Don't automatically disappear.
                'alertSettings' => [
                    'warning' => [
                        'type' => Alert::TYPE_DANGER,
                        'body' => $message,
                    ],
                ],
            ]);
        }
    }
}

echo Html::tag('h2', Member::label(2));
echo Html::beginTag('p');

    echo Html::a(Yii::t('app', 'Add Member'), [PollUrl::toRoute(['member/create', 'poll_id' => $model->id])], ['class' => 'btn btn-success']);
    echo '&nbsp;';
    echo Html::button(Yii::t('app', 'Import From Excel'), ['class' => 'btn btn-primary', 'data' => ['toggle' => 'modal', 'target' => '#importModal']]);
    echo '&nbsp;';

    echo Html::a(Yii::t('app', 'Delete All Members'), [PollUrl::toRoute(['member/clear', 'poll_id' => $model->id])], [
        'class' => 'btn btn-danger',
        'data' => [
            'confirm' => Yii::t('app', 'Are you sure you want to delete all members?'),
        ],
    ]);
    echo '&nbsp;';

    echo Html::button(Yii::t('app', 'Send Email'), ['class' => 'btn btn-warning pull-right', 'data' => ['toggle' => 'modal', 'target' => '#emailModal']]);

echo Html::endTag('p');

// render Import modal window
echo $this->render('_import_modal', ['poll' => $model, 'target'=>'importModal']);
// render Email modal window
echo $this->render('_email_modal', ['model' => $model, 'target'=>'emailModal']);


$demoCodes = Html::beginTag('ul', ['class' => 'list-unstyled']);
$demoCodes .= Html::tag('li', Html::tag('span', 'Invalid Code', Code::getInvalidHTMLOptions()));
$demoCodes .= Html::tag('li', Html::tag('span', 'Unused Code', Code::getUnusedHTMLOptions()));
$demoCodes .= Html::tag('li', Html::tag('span', 'Used Code', Code::getUsedHTMLOptions()));
$demoCodes .= Html::endTag('ul');

echo GridView::widget([
    'dataProvider' => $memberDataProvider,
    'filterModel' => $memberSearchModel,
    'showFooter' => true,
    'columns' => [
        [
            'class' => 'app\components\grid\ActionColumn',
            'urlCreator' => function ($action, $model, $key, $index) {
                //return Yii::$app->controller->createUrl([$action, 'id'=>$key]);
                return PollUrl::toRoute(["member/$action", 'id' => $key, 'poll_id' => $model->poll_id]);
            }
        ],
        [
            'attribute' => 'name',
            'format' => 'raw',
            'value' => function ($data) {
                return Html::a(Html::encode($data->name), PollUrl::toRoute(['member/view', 'id' => $data->id, 'poll_id' => $data->poll_id]));
            }
        ],
        'group',
        //'ContactsCount', // Is this column needed? Members should not be able to have 0 contacts.
        [
            'attribute' => 'codes.code_status',
            'label' => Yii::t('app', 'Voting Code'),<commit_msg>fixed id for members-gridview in poll _members_tab<commit_after><?php
use yii\helpers\Html;
use app\components\grid\GridView;
use yii\data\ArrayDataProvider;
use yii\bootstrap\Modal;
use app\models\Member;
use app\models\Code;
use app\models\forms\EmailForm;
use app\models\MemberSearch;
use app\components\helpers\PollUrl;
use yii\widgets\ActiveForm;
use kartik\widgets\AlertBlock;
use kartik\widgets\Alert;

// display all "import" flash messages
foreach (Yii::$app->getSession()->getAllFlashes() as $key => $arr) {
    if ($key === 'import') {
        foreach ($arr as $message) {
            echo AlertBlock::widget([
                'useSessionFlash' => false,
                'type' => AlertBlock::TYPE_ALERT,
                'delay' => false, // Don't automatically disappear.
                'alertSettings' => [
                    'warning' => [
                        'type' => Alert::TYPE_DANGER,
                        'body' => $message,
                    ],
                ],
            ]);
        }
    }
}

echo Html::tag('h2', Member::label(2));
echo Html::beginTag('p');

    echo Html::a(Yii::t('app', 'Add Member'), [PollUrl::toRoute(['member/create', 'poll_id' => $model->id])], ['class' => 'btn btn-success']);
    echo '&nbsp;';
    echo Html::button(Yii::t('app', 'Import From Excel'), ['class' => 'btn btn-primary', 'data' => ['toggle' => 'modal', 'target' => '#importModal']]);
    echo '&nbsp;';

    echo Html::a(Yii::t('app', 'Delete All Members'), [PollUrl::toRoute(['member/clear', 'poll_id' => $model->id])], [
        'class' => 'btn btn-danger',
        'data' => [
            'confirm' => Yii::t('app', 'Are you sure you want to delete all members?'),
        ],
    ]);
    echo '&nbsp;';

    echo Html::button(Yii::t('app', 'Send Email'), ['class' => 'btn btn-warning pull-right', 'data' => ['toggle' => 'modal', 'target' => '#emailModal']]);

echo Html::endTag('p');

// render Import modal window
echo $this->render('_import_modal', ['poll' => $model, 'target'=>'importModal']);
// render Email modal window
echo $this->render('_email_modal', ['model' => $model, 'target'=>'emailModal']);


$demoCodes = Html::beginTag('ul', ['class' => 'list-unstyled']);
$demoCodes .= Html::tag('li', Html::tag('span', 'Invalid Code', Code::getInvalidHTMLOptions()));
$demoCodes .= Html::tag('li', Html::tag('span', 'Unused Code', Code::getUnusedHTMLOptions()));
$demoCodes .= Html::tag('li', Html::tag('span', 'Used Code', Code::getUsedHTMLOptions()));
$demoCodes .= Html::endTag('ul');

echo GridView::widget([
    'id'=>'members-gridview',
    'dataProvider' => $memberDataProvider,
    'filterModel' => $memberSearchModel,
    'showFooter' => true,
    'columns' => [
        [
            'class' => 'app\components\grid\ActionColumn',
            'urlCreator' => function ($action, $model, $key, $index) {
                //return Yii::$app->controller->createUrl([$action, 'id'=>$key]);
                return PollUrl::toRoute(["member/$action", 'id' => $key, 'poll_id' => $model->poll_id]);
            }
        ],
        [
            'attribute' => 'name',
            'format' => 'raw',
            'value' => function ($data) {
                return Html::a(Html::encode($data->name), PollUrl::toRoute(['member/view', 'id' => $data->id, 'poll_id' => $data->poll_id]));
            }
        ],
        'group',
        //'ContactsCount', // Is this column needed? Members should not be able to have 0 contacts.
        [
            'attribute' => 'codes.code_status',
            'label' => Yii::t('app', 'Voting Code'),
{'fraction_non_alphanumeric': 0.20882228191714972, 'fraction_numerical': 0.0008482963381874735, 'mean_word_length': 2.8825466520307352, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 114, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4011066', 'n_tokens_mistral': 2269, 'n_tokens_neox': 2227, 'n_words': 474}