diff --git a/backend/controllers/UserController.php b/backend/controllers/UserController.php new file mode 100644 index 0000000..fec9436 --- /dev/null +++ b/backend/controllers/UserController.php @@ -0,0 +1,122 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all User models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new UserSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single User model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new User model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new User(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing User model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing User model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the User model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return User the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = User::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/models/WAccounts.php b/backend/models/WAccounts.php deleted file mode 100644 index 2eb0601..0000000 --- a/backend/models/WAccounts.php +++ /dev/null @@ -1,121 +0,0 @@ - 150], - [['pass'], 'string', 'max' => 30], - [['phones', 'phones2', 'phones3'], 'string', 'max' => 50], - [['address', 'firm_inn', 'firm_bank'], 'string', 'max' => 254], - [['last_loginin'], 'string', 'max' => 15], - [['snumb', 'firm_ur_adr', 'firm_fiz_adr', 'firm_code_eg', 'firm_rs', 'firm_mfo', 'company'], 'string', 'max' => 255], - [['email'], 'unique'] - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => Yii::t('app', 'ID'), - 'if_manager' => Yii::t('app', 'If Manager'), - 'email' => Yii::t('app', 'Email'), - 'pass' => Yii::t('app', 'Pass'), - 'margin_id' => Yii::t('app', 'Margin ID'), - 'name' => Yii::t('app', 'Name'), - 'phones' => Yii::t('app', 'Phones'), - 'country' => Yii::t('app', 'Country'), - 'city' => Yii::t('app', 'City'), - 'address' => Yii::t('app', 'Address'), - 'comment' => Yii::t('app', 'Comment'), - 'rating' => Yii::t('app', 'Rating'), - 'dt' => Yii::t('app', 'Dt'), - 'is_active' => Yii::t('app', 'Is Active'), - 'is_firm' => Yii::t('app', 'Is Firm'), - 'last_loginin' => Yii::t('app', 'Last Loginin'), - 'firm_inn' => Yii::t('app', 'Firm Inn'), - 'firm_bank' => Yii::t('app', 'Firm Bank'), - 'balance' => Yii::t('app', 'Balance'), - 'office_id' => Yii::t('app', 'Office ID'), - 'is_scribe' => Yii::t('app', 'Is Scribe'), - 'set_manager_id' => Yii::t('app', 'Set Manager ID'), - 'phones2' => Yii::t('app', 'Phones2'), - 'phones3' => Yii::t('app', 'Phones3'), - 'car' => Yii::t('app', 'Car'), - 'mod' => Yii::t('app', 'Mod'), - 'snumb' => Yii::t('app', 'Snumb'), - 'deliveries' => Yii::t('app', 'Deliveries'), - '1scode' => Yii::t('app', '1scode'), - 'firm_ur_adr' => Yii::t('app', 'Firm Ur Adr'), - 'firm_fiz_adr' => Yii::t('app', 'Firm Fiz Adr'), - 'firm_code_eg' => Yii::t('app', 'Firm Code Eg'), - 'firm_rs' => Yii::t('app', 'Firm Rs'), - 'firm_mfo' => Yii::t('app', 'Firm Mfo'), - 'firm_site' => Yii::t('app', 'Firm Site'), - 'company' => Yii::t('app', 'Company'), - ]; - } -} diff --git a/backend/views/layouts/column.php b/backend/views/layouts/column.php index cc7b1a8..a00f095 100644 --- a/backend/views/layouts/column.php +++ b/backend/views/layouts/column.php @@ -292,7 +292,7 @@ $this->beginContent('@app/views/layouts/main.php'); ['label' => 'Управление ролями', 'url' => ['#'], 'items' => [ ['label' => 'Покупатели', 'url' => ['accounts/index']], ['label' => 'Поставщики', 'url' => ['importers/index']], - ['label' => 'Администраторы', 'url' => '#'], + ['label' => 'Администраторы', 'url' => ['user/index']], ], ], ], -- libgit2 0.21.4