Пример #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]);
 }
Пример #2
0
 public function find()
 {
     if ($this->ids) {
         return DonateModel::find()->where(['id' => $this->ids])->orderBy(['created_at' => SORT_DESC]);
     } else {
         $search = new DonateSearch();
         $dataProvider = $search->search($this->queryParams);
         $dataProvider->pagination = false;
         return $dataProvider->query;
     }
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Donate::find()->permission()->dependent();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSizeLimit' => [10, 100], 'pageParam' => 'donate-page', 'pageSizeParam' => 'donate-per-page'], 'sort' => ['defaultOrder' => ['timestamp' => SORT_DESC]]]);
     $dataProvider->sort->attributes['partner'] = ['asc' => ['partner.name' => SORT_ASC], 'desc' => ['partner.name' => SORT_DESC]];
     $dataProvider->sort->attributes['user'] = ['asc' => ['user.name' => SORT_ASC], 'desc' => ['user.name' => SORT_DESC]];
     $params = $this->processParams($params);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'partner_id' => $this->partner_id, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'notes', $this->notes]);
     $this->addRangeCondition($query, 'sum');
     $this->addRangeCondition($query, 'timestamp');
     $this->addRangeCondition($query, 'created_at');
     $this->addRangeCondition($query, 'updated_at');
     return $dataProvider;
 }