Exemplo n.º 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]);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PrintTemplate::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSizeLimit' => [10, 100]], 'sort' => ['defaultOrder' => ['name' => SORT_ASC]]]);
     $params = $this->processParams($params);
     if (!($this->load($params) && $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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content]);
     $this->addRangeCondition($query, 'created_at');
     $this->addRangeCondition($query, 'updated_at');
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * Finds the PrintTemplate model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PrintTemplate the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PrintTemplate::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTemplate()
 {
     return $this->hasOne(PrintTemplate::className(), ['id' => 'template_id']);
 }
Exemplo n.º 5
0
 public function getTemplates()
 {
     return $this->hasMany(PrintTemplate::className(), ['id' => 'template_id'])->viaTable('print_template_mailing_list', ['list_id' => 'id']);
 }