| @@ 16-108 (lines=93) @@ | ||
| 13 | use yii\base\Event; |
|
| 14 | use yii\filters\AccessControl; |
|
| 15 | ||
| 16 | class PreOrderController extends CrudController |
|
| 17 | { |
|
| 18 | public static function modelClassName() |
|
| 19 | { |
|
| 20 | return Change::class; |
|
| 21 | } |
|
| 22 | ||
| 23 | public function behaviors() |
|
| 24 | { |
|
| 25 | return array_merge(parent::behaviors(), [ |
|
| 26 | 'access' => [ |
|
| 27 | 'class' => AccessControl::className(), |
|
| 28 | 'rules' => [ |
|
| 29 | [ |
|
| 30 | 'allow' => true, |
|
| 31 | 'roles' => ['resell'], |
|
| 32 | ], |
|
| 33 | ], |
|
| 34 | ], |
|
| 35 | ]); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function actions() |
|
| 39 | { |
|
| 40 | return [ |
|
| 41 | 'index' => [ |
|
| 42 | 'class' => IndexAction::class, |
|
| 43 | 'findOptions' => ['state' => 'new', 'class' => 'serverBuy'], |
|
| 44 | 'data' => function ($action) { |
|
| 45 | return [ |
|
| 46 | 'states' => Change::getStates(), |
|
| 47 | ]; |
|
| 48 | }, |
|
| 49 | ], |
|
| 50 | 'bulk-approve' => [ |
|
| 51 | 'class' => SmartUpdateAction::class, |
|
| 52 | 'scenario' => 'approve', |
|
| 53 | 'success' => Yii::t('hipanel/server', 'VDS were approved successfully'), |
|
| 54 | 'error' => Yii::t('hipanel/server', 'Error occurred during VDS approving'), |
|
| 55 | 'POST html' => [ |
|
| 56 | 'save' => true, |
|
| 57 | 'success' => [ |
|
| 58 | 'class' => RedirectAction::class, |
|
| 59 | ], |
|
| 60 | ], |
|
| 61 | 'on beforeSave' => function (Event $event) { |
|
| 62 | /** @var \hipanel\actions\Action $action */ |
|
| 63 | $action = $event->sender; |
|
| 64 | $comment = Yii::$app->request->post('comment'); |
|
| 65 | foreach ($action->collection->models as $model) { |
|
| 66 | $model->setAttribute('comment', $comment); |
|
| 67 | } |
|
| 68 | }, |
|
| 69 | ], |
|
| 70 | 'bulk-approve-modal' => [ |
|
| 71 | 'class' => PrepareBulkAction::class, |
|
| 72 | 'scenario' => 'approve', |
|
| 73 | 'view' => '_bulkApprove', |
|
| 74 | 'findOptions' => [ |
|
| 75 | 'state' => Change::STATE_NEW |
|
| 76 | ] |
|
| 77 | ], |
|
| 78 | 'bulk-reject' => [ |
|
| 79 | 'class' => SmartUpdateAction::class, |
|
| 80 | 'scenario' => 'reject', |
|
| 81 | 'success' => Yii::t('hipanel/server', 'VDS were rejected successfully'), |
|
| 82 | 'error' => Yii::t('hipanel/server', 'Error occurred during VDS rejecting'), |
|
| 83 | 'POST html' => [ |
|
| 84 | 'save' => true, |
|
| 85 | 'success' => [ |
|
| 86 | 'class' => RedirectAction::class, |
|
| 87 | ], |
|
| 88 | ], |
|
| 89 | 'on beforeSave' => function (Event $event) { |
|
| 90 | /** @var \hipanel\actions\Action $action */ |
|
| 91 | $action = $event->sender; |
|
| 92 | $comment = Yii::$app->request->post('comment'); |
|
| 93 | foreach ($action->collection->models as $model) { |
|
| 94 | $model->setAttribute('comment', $comment); |
|
| 95 | } |
|
| 96 | }, |
|
| 97 | ], |
|
| 98 | 'bulk-reject-modal' => [ |
|
| 99 | 'class' => PrepareBulkAction::class, |
|
| 100 | 'scenario' => 'reject', |
|
| 101 | 'view' => '_bulkReject', |
|
| 102 | 'findOptions' => [ |
|
| 103 | 'state' => Change::STATE_NEW |
|
| 104 | ] |
|
| 105 | ], |
|
| 106 | ]; |
|
| 107 | } |
|
| 108 | } |
|
| 109 | ||
| @@ 16-108 (lines=93) @@ | ||
| 13 | use yii\base\Event; |
|
| 14 | use yii\filters\AccessControl; |
|
| 15 | ||
| 16 | class RefuseController extends CrudController |
|
| 17 | { |
|
| 18 | public static function modelClassName() |
|
| 19 | { |
|
| 20 | return Change::class; |
|
| 21 | } |
|
| 22 | ||
| 23 | public function behaviors() |
|
| 24 | { |
|
| 25 | return array_merge(parent::behaviors(), [ |
|
| 26 | 'access' => [ |
|
| 27 | 'class' => AccessControl::className(), |
|
| 28 | 'rules' => [ |
|
| 29 | [ |
|
| 30 | 'allow' => true, |
|
| 31 | 'roles' => ['manage'], |
|
| 32 | ], |
|
| 33 | ], |
|
| 34 | ], |
|
| 35 | ]); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function actions() |
|
| 39 | { |
|
| 40 | return [ |
|
| 41 | 'index' => [ |
|
| 42 | 'class' => IndexAction::class, |
|
| 43 | 'findOptions' => ['state' => 'new', 'class' => 'server'], |
|
| 44 | 'data' => function ($action) { |
|
| 45 | return [ |
|
| 46 | 'states' => Change::getStates(), |
|
| 47 | ]; |
|
| 48 | }, |
|
| 49 | ], |
|
| 50 | 'bulk-approve' => [ |
|
| 51 | 'class' => SmartUpdateAction::class, |
|
| 52 | 'scenario' => 'approve', |
|
| 53 | 'success' => Yii::t('hipanel/server', 'Server refuse was approved successfully'), |
|
| 54 | 'error' => Yii::t('hipanel/server', 'Error occurred during server refuse approving'), |
|
| 55 | 'POST html' => [ |
|
| 56 | 'save' => true, |
|
| 57 | 'success' => [ |
|
| 58 | 'class' => RedirectAction::class, |
|
| 59 | ], |
|
| 60 | ], |
|
| 61 | 'on beforeSave' => function (Event $event) { |
|
| 62 | /** @var \hipanel\actions\Action $action */ |
|
| 63 | $action = $event->sender; |
|
| 64 | $comment = Yii::$app->request->post('comment'); |
|
| 65 | foreach ($action->collection->models as $model) { |
|
| 66 | $model->setAttribute('comment', $comment); |
|
| 67 | } |
|
| 68 | }, |
|
| 69 | ], |
|
| 70 | 'bulk-approve-modal' => [ |
|
| 71 | 'class' => PrepareBulkAction::class, |
|
| 72 | 'scenario' => 'approve', |
|
| 73 | 'view' => '_bulkApprove', |
|
| 74 | 'findOptions' => [ |
|
| 75 | 'state' => Change::STATE_NEW |
|
| 76 | ] |
|
| 77 | ], |
|
| 78 | 'bulk-reject' => [ |
|
| 79 | 'class' => SmartUpdateAction::class, |
|
| 80 | 'scenario' => 'reject', |
|
| 81 | 'success' => Yii::t('hipanel/server', 'Server refuse was rejected successfully'), |
|
| 82 | 'error' => Yii::t('hipanel/server', 'Error occurred during server refuse rejecting'), |
|
| 83 | 'POST html' => [ |
|
| 84 | 'save' => true, |
|
| 85 | 'success' => [ |
|
| 86 | 'class' => RedirectAction::class, |
|
| 87 | ], |
|
| 88 | ], |
|
| 89 | 'on beforeSave' => function (Event $event) { |
|
| 90 | /** @var \hipanel\actions\Action $action */ |
|
| 91 | $action = $event->sender; |
|
| 92 | $comment = Yii::$app->request->post('comment'); |
|
| 93 | foreach ($action->collection->models as $model) { |
|
| 94 | $model->setAttribute('comment', $comment); |
|
| 95 | } |
|
| 96 | }, |
|
| 97 | ], |
|
| 98 | 'bulk-reject-modal' => [ |
|
| 99 | 'class' => PrepareBulkAction::class, |
|
| 100 | 'scenario' => 'reject', |
|
| 101 | 'view' => '_bulkReject', |
|
| 102 | 'findOptions' => [ |
|
| 103 | 'state' => Change::STATE_NEW |
|
| 104 | ] |
|
| 105 | ], |
|
| 106 | ]; |
|
| 107 | } |
|
| 108 | } |
|
| 109 | ||