|
- <?php
-
-
-
- namespace backend\controllers;
-
- use common\helpers\CSV;
- use common\helpers\Price;
- use http\Exception\InvalidArgumentException;
- use yii\data\ActiveDataProvider;
- use yii\filters\AccessControl;
-
- class CreditController extends BackendController
- {
- public function behaviors()
- {
- return [
- 'access' => [
- 'class' => AccessControl::class,
- 'rules' => [
- [
- 'allow' => true,
- 'roles' => ['@'],
- 'matchCallback' => function ($rule, $action) {
- return $this->getUserModule()
- ->getAuthorizationChecker()
- ->isGrantedAsProducer($this->getUserCurrent());
- }
- ]
- ],
- ],
- ];
- }
-
- public function actionIndex()
- {
- $userModule = $this->getUserModule();
- $userProducerModule = $this->getUserProducerModule();
-
- $dataProviderUsersWithNegativeCredit = new ActiveDataProvider([
- 'query' => $userModule->queryUsersWithNegativeCredit(),
- 'sort' => false,
- 'pagination' => [
- 'pageSize' => 30,
- ],
- ]);
-
- return $this->render('index', [
- 'sumUserProducerCredits' => $userProducerModule->sumUserProducerCredits(),
- 'dataProviderUsersWithNegativeCredit' => $dataProviderUsersWithNegativeCredit
- ]);
- }
-
- public function actionExportUsers(string $type)
- {
- $this->getUserModule()->exportUsersCreditAsCsv($type);
- }
- }
|