示例#1
0
 public function actionInvalidate($id)
 {
     $code = $this->findModel($id);
     if ($code->isValid()) {
         if ($code->isUsed()) {
             $code->code_status = Code::CODE_STATUS_INVALID_USED;
         } else {
             $code->code_status = Code::CODE_STATUS_INVALID_UNUSED;
         }
         $code->save();
     }
     return $this->redirect(PollUrl::toRoute(['member/view', 'poll_id' => $code->poll_id, 'id' => $code->member_id]));
 }
示例#2
0
<?php

use yii\helpers\Html;
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
use app\models\forms\EmailForm;
use app\components\helpers\PollUrl;
echo Html::tag('p', Html::encode(Yii::t('app', 'You can use the tags <member-name>, <member-group> and <voting-code> or <voting-link> (for clickable link) to customize your message for each member.')));
?>
<div class="email-form">
<?php 
$form = ActiveForm::begin(['type' => ActiveForm::TYPE_VERTICAL, 'action' => PollUrl::toRoute(['email/sendsingle', 'member_id' => $member->id])]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 1, 'attributes' => ['subject' => ['type' => Form::INPUT_TEXT, 'options' => ['maxlength' => 255]], 'message' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['rows' => 6]]]]);
?>
    <div class="form-group">
        <?php 
echo Html::submitButton(Yii::t('app', 'Send'), ['class' => 'btn btn-primary']);
?>
    </div>
<?php 
ActiveForm::end();
?>
</div>
示例#3
0
<?php

use yii\helpers\Url;
use app\components\helpers\PollUrl;
echo $this->context->createUrl(['update', 'id' => 1]) . '<br />';
echo $this->context->createUrl(['/poll/view']) . '<br />';
echo Url::toRoute(['/poll/view', 'id' => $this->context->getPollId()]) . '<br />';
echo PollUrl::toRoute(['/poll/view']) . '<br />';
echo PollUrl::toRoute(['/member/view', 'id' => 1]) . '<br />';
echo PollUrl::toRoute(['/members/view', 'id' => 1]) . '<br />';
echo PollUrl::toRoute(['/members/view', 'id' => 1, 'poll_id' => 2]) . '<br />';
echo PollUrl::toRoute(['view', 'id' => 1]) . '<br />';
 public function createUrl($url = '', $scheme = false)
 {
     return PollUrl::toRoute($url, $scheme);
 }
示例#5
0
// 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']);
if (\Yii::$app->user->isAdmin()) {
    echo $this->render('_contact_emails_modal', ['model' => $model, 'target' => 'contactEmailsModal']);
}
$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', ['attribute' => 'codes.code_status', 'label' => Yii::t('app', 'Voting Code'), 'format' => 'raw', 'footer' => $demoCodes, 'filter' => [Code::CODE_STATUS_INVALID_UNUSED => 'Invalid Code', Code::CODE_STATUS_UNUSED => 'Unused Code', Code::CODE_STATUS_USED => 'Used Code'], 'value' => function ($data) {
    $codes = $data->codes;
    // Display the invalid tokens before the valid ones.
    usort($codes, function ($a, $b) {
        return $a->code_status > $b->code_status;
    });
    $str = Html::beginTag('ul', ['class' => 'list-unstyled']);
    foreach ($codes as $code) {
        $options = $code->getHTMLOptions();
        $str .= Html::tag('li', Html::tag('span', $code, $options));
    }
    $str .= Html::endTag('ul');
    return $str;
}]]]);
示例#6
0
<?php

use yii\helpers\Html;
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
use app\models\forms\EmailForm;
use app\components\helpers\PollUrl;
echo Html::tag('p', Html::encode(Yii::t('app', 'You can use the tags <member-name>, <member-group> and <voting-code> or <voting-link> (for clickable link) to customize your message for each member.')));
?>
<div class="email-form">
<?php 
$sendOptions = [EmailForm::EMAIL_TO_UNUSED => Yii::t('app', 'Members who haven\'t voted'), EmailForm::EMAIL_TO_USED => Yii::t('app', 'Members who have already voted'), EmailForm::EMAIL_TO_ALL => Yii::t('app', 'All Members')];
$form = ActiveForm::begin(['type' => ActiveForm::TYPE_VERTICAL, 'action' => PollUrl::toRoute(['email/sendmultiple', 'poll_id' => $poll->id])]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 1, 'attributes' => ['sendMode' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => $sendOptions, 'options' => ['prompt' => 'Please select']], 'subject' => ['type' => Form::INPUT_TEXT, 'options' => ['maxlength' => 255]], 'message' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['rows' => 6]]]]);
?>
    <div class="form-group">
        <?php 
echo Html::submitButton(Yii::t('app', 'Send'), ['class' => 'btn btn-primary']);
?>
    </div>
<?php 
ActiveForm::end();
?>
</div>
示例#7
0
use yii\helpers\Html;
use yii\bootstrap\Modal;
use yii\widgets\ActiveForm;
use app\models\forms\UploadForm;
use app\components\helpers\PollUrl;
use kartik\file\FileInput;
$model = new UploadForm();
Modal::begin(['id' => !empty($target) ? $target : 'importModal', 'header' => Html::tag('h4', Yii::t('app', 'Import From Excel'), ['class' => 'modal-title'])]);
?>
<div class="member-excel-form">
    <?php 
echo Html::tag('p', Yii::t('app', 'Importing members will delete all existing members.'));
?>
    <?php 
$form = ActiveForm::begin(['action' => PollUrl::toRoute(['member/import', 'poll_id' => $poll->id]), 'options' => ['enctype' => 'multipart/form-data']]);
?>
    <?php 
echo $form->field($model, 'excelFile')->widget(FileInput::classname(), ['pluginOptions' => ['showPreview' => false, 'showRemove' => false, 'showUpload' => false]]);
?>
    <div class="form-group">
        <?php 
echo Html::submitButton(Yii::t('app', 'Import'), ['class' => 'btn btn-success', 'data' => ['confirm' => Yii::t('app', 'This will delete all existing contacts. Are you sure you want to import?')]]);
?>
    </div>
    <?php 
ActiveForm::end();
?>
</div>
<?php 
Modal::end();