|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?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);
- }
- }
|