Example #1
0
 public function actionIndex()
 {
     $user = Yii::$app->user;
     $dashboard = [];
     if ($user->can('partner_view')) {
         $dashboard[] = ['name' => Html::tag('b', __('Partners')), 'link' => Url::to(['partner/index']), 'count' => Partner::find()->count()];
     }
     if ($user->can('visit_view') || $user->can('visit_view_all')) {
         $dashboard[] = ['name' => __('Visits'), 'link' => Url::to(['visit/index']), 'count' => Visit::find()->count()];
     }
     if ($user->can('donate_view') || $user->can('donate_view_all')) {
         $dashboard[] = ['name' => __('Donates'), 'link' => Url::to(['donate/index']), 'count' => Donate::find()->count()];
     }
     if ($user->can('task_view') || $user->can('task_view_all')) {
         $dashboard[] = ['name' => __('Tasks'), 'link' => Url::to(['task/index']), 'count' => Task::find()->count()];
     }
     if ($user->can('newsletter_view')) {
         $dashboard[] = ['name' => __('Mailing lists'), 'link' => Url::to(['mailing-list/index']), 'count' => MailingList::find()->count()];
         $dashboard[] = ['name' => __('Newsletters'), 'link' => Url::to(['newsletter/index']), 'count' => Newsletter::find()->count()];
         $dashboard[] = ['name' => __('Printing templates'), 'link' => Url::to(['print-template/index']), 'count' => PrintTemplate::find()->count()];
     }
     if ($user->can('user_manage')) {
         $dashboard[] = ['name' => __('Users'), 'link' => Url::to(['user/index']), 'count' => User::find()->count()];
     }
     return $this->render('index', ['dashboard' => $dashboard]);
 }
Example #2
0
 public function append()
 {
     $mailingList = MailingList::findOne($this->mailing_list_id);
     $partners = Partner::findAll(explode(',', $this->partner_ids));
     foreach ($partners as $partner) {
         $mailingList->unlink('partners', $partner, true);
         $mailingList->link('partners', $partner);
     }
     return true;
 }
Example #3
0
 public function eventUpdate($event)
 {
     $model = $this->owner;
     $model->unlinkAll('mailingLists', true);
     if ($this->mailingListIds) {
         $lists = MailingList::findAll($this->mailingListIds);
         foreach ($lists as $list) {
             $model->link('mailingLists', $list);
         }
     }
 }
Example #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MailingList::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSizeLimit' => [10, 100]], 'sort' => ['defaultOrder' => ['name' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'status', $this->status]);
     if ($this->sender) {
         $query->orFilterWhere(['like', 'from_name', $this->sender]);
         $query->orFilterWhere(['like', 'from_email', $this->sender]);
         $query->orFilterWhere(['like', 'reply_to', $this->sender]);
     }
     return $dataProvider;
 }
Example #5
0
 public function getMailingList()
 {
     return $this->hasOne(MailingList::className(), ['id' => 'list_id']);
 }
Example #6
0
 public function getMailingLists()
 {
     return $this->hasMany(MailingList::className(), ['id' => 'list_id'])->viaTable('mailing_list_partner', ['partner_id' => 'id']);
 }
Example #7
0
 /**
  * Finds the MailingList model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MailingList the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MailingList::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #8
0
File: form.php Project: vsguts/crm
<?php

use app\models\MailingList;
use app\widgets\ActiveForm;
use yii\helpers\Html;
$form = ActiveForm::begin(['id' => 'print_template_form']);
echo $form->field($model, 'name')->textInput(['maxlength' => 255]);
echo $form->field($model, 'status')->dropDownList($model->getLookupItems('status'));
echo $form->field($model, 'format')->dropDownList($model->getLookupItems('format'));
echo $form->field($model, 'orientation_landscape')->checkbox(['class' => 'checkboxfix'], false);
echo $form->field($model, 'items_per_page')->textInput(['maxlength' => true]);
// Margin fields
Html::beginTag('div', ['class' => 'row']);
foreach (['margin_top', 'margin_bottom', 'margin_left', 'margin_right'] as $field) {
    $field = $form->field($model, $field, ['horizontalCssClasses' => ['offset' => 'col-sm-offset-2', 'label' => 'col-sm-7', 'wrapper' => 'col-sm-5']])->textInput(['maxlength' => true]);
    echo Html::tag('div', $field, ['class' => 'col-sm-3']);
}
Html::endTag('div');
echo $form->field($model, 'content')->hint($this->render('hint_content'))->textarea(['rows' => 6]);
// ->widget('app\widgets\Wysiwyg');
echo $form->field($model, 'wrapper_enabled')->checkbox(['class' => 'checkboxfix app-dtoggle app-dtoggle-wrapper'], false);
$textarea = $form->field($model, 'wrapper')->textarea(['rows' => 6])->hint($this->render('hint_wrapper'));
$css_class = 'app-dtoggle-wrapper-on ' . ($model->wrapper_enabled ? 'h' : '');
echo Html::tag('div', $textarea, ['class' => $css_class]);
echo $form->field($model, 'mailingListIds')->checkboxList(MailingList::find()->active()->scroll());
if (!$model->isNewRecord) {
    echo $form->field($model, 'created_at')->widget('app\\widgets\\Text', ['formatter' => 'date']);
    echo $form->field($model, 'updated_at')->widget('app\\widgets\\Text', ['formatter' => 'date']);
}
ActiveForm::end();
Example #9
0
<?php

use yii\helpers\Html;
use app\widgets\ActiveForm;
use app\widgets\Modal;
use app\models\MailingList;
$this->title = __('Add to mailing list');
Modal::begin(['size' => Modal::SIZE_LARGE, 'header' => __('Add to mailing list'), 'id' => 'append_partners', 'footer' => Html::submitButton(__('Append'), ['class' => 'btn btn-success', 'form' => 'append_partners_form'])]);
$form = ActiveForm::begin(['id' => 'append_partners_form', 'action' => ['mailing-list/append-partners'], 'options' => ['class' => 'app-ajax', 'data-c-modal' => 'append_partners']]);
echo $form->field($model, 'partner_ids', ['template' => '{input}'])->hiddenInput();
echo $form->field($model, 'mailing_list_id')->dropDownList(MailingList::find()->active()->scroll());
ActiveForm::end();
Modal::end();
Example #10
0
 public function getMailingListsCount()
 {
     return MailingList::find()->joinWith('printTemplateMailingLists')->where(['template_id' => $this->id])->count();
 }
Example #11
0
 public function getMailingListsCount()
 {
     return MailingList::find()->joinWith('newsletterMailingLists')->where(['newsletter_id' => $this->id])->count();
 }