Commit 4d0b6b18863d43734675e898ab669f6720166e54

Authored by Administrator
1 parent 32d8b1c8

Importers CRUD

backend/controllers/UserController.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use Yii;
  6 +use backend\models\User;
  7 +use common\models\UserSearch;
  8 +use yii\web\Controller;
  9 +use yii\web\NotFoundHttpException;
  10 +use yii\filters\VerbFilter;
  11 +
  12 +/**
  13 + * UserController implements the CRUD actions for User model.
  14 + */
  15 +class UserController extends Controller
  16 +{
  17 + public $layout = "/column";
  18 + public function behaviors()
  19 + {
  20 + return [
  21 + 'verbs' => [
  22 + 'class' => VerbFilter::className(),
  23 + 'actions' => [
  24 + 'delete' => ['post'],
  25 + ],
  26 + ],
  27 + ];
  28 + }
  29 +
  30 + /**
  31 + * Lists all User models.
  32 + * @return mixed
  33 + */
  34 + public function actionIndex()
  35 + {
  36 + $searchModel = new UserSearch();
  37 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  38 +
  39 + return $this->render('index', [
  40 + 'searchModel' => $searchModel,
  41 + 'dataProvider' => $dataProvider,
  42 + ]);
  43 + }
  44 +
  45 + /**
  46 + * Displays a single User model.
  47 + * @param integer $id
  48 + * @return mixed
  49 + */
  50 + public function actionView($id)
  51 + {
  52 + return $this->render('view', [
  53 + 'model' => $this->findModel($id),
  54 + ]);
  55 + }
  56 +
  57 + /**
  58 + * Creates a new User model.
  59 + * If creation is successful, the browser will be redirected to the 'view' page.
  60 + * @return mixed
  61 + */
  62 + public function actionCreate()
  63 + {
  64 + $model = new User();
  65 +
  66 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  67 + return $this->redirect(['view', 'id' => $model->id]);
  68 + } else {
  69 + return $this->render('create', [
  70 + 'model' => $model,
  71 + ]);
  72 + }
  73 + }
  74 +
  75 + /**
  76 + * Updates an existing User model.
  77 + * If update is successful, the browser will be redirected to the 'view' page.
  78 + * @param integer $id
  79 + * @return mixed
  80 + */
  81 + public function actionUpdate($id)
  82 + {
  83 + $model = $this->findModel($id);
  84 +
  85 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  86 + return $this->redirect(['view', 'id' => $model->id]);
  87 + } else {
  88 + return $this->render('update', [
  89 + 'model' => $model,
  90 + ]);
  91 + }
  92 + }
  93 +
  94 + /**
  95 + * Deletes an existing User model.
  96 + * If deletion is successful, the browser will be redirected to the 'index' page.
  97 + * @param integer $id
  98 + * @return mixed
  99 + */
  100 + public function actionDelete($id)
  101 + {
  102 + $this->findModel($id)->delete();
  103 +
  104 + return $this->redirect(['index']);
  105 + }
  106 +
  107 + /**
  108 + * Finds the User model based on its primary key value.
  109 + * If the model is not found, a 404 HTTP exception will be thrown.
  110 + * @param integer $id
  111 + * @return User the loaded model
  112 + * @throws NotFoundHttpException if the model cannot be found
  113 + */
  114 + protected function findModel($id)
  115 + {
  116 + if (($model = User::findOne($id)) !== null) {
  117 + return $model;
  118 + } else {
  119 + throw new NotFoundHttpException('The requested page does not exist.');
  120 + }
  121 + }
  122 +}
backend/models/WAccounts.php deleted
1 -<?php  
2 -  
3 -namespace backend\models;  
4 -  
5 -use Yii;  
6 -  
7 -/**  
8 - * This is the model class for table "w_accounts".  
9 - *  
10 - * @property integer $id  
11 - * @property integer $if_manager  
12 - * @property string $email  
13 - * @property string $pass  
14 - * @property integer $margin_id  
15 - * @property string $name  
16 - * @property string $phones  
17 - * @property integer $country  
18 - * @property integer $city  
19 - * @property string $address  
20 - * @property string $comment  
21 - * @property integer $rating  
22 - * @property string $dt  
23 - * @property integer $is_active  
24 - * @property integer $is_firm  
25 - * @property string $last_loginin  
26 - * @property string $firm_inn  
27 - * @property string $firm_bank  
28 - * @property double $balance  
29 - * @property integer $office_id  
30 - * @property integer $is_scribe  
31 - * @property integer $set_manager_id  
32 - * @property string $phones2  
33 - * @property string $phones3  
34 - * @property integer $car  
35 - * @property integer $mod  
36 - * @property string $snumb  
37 - * @property integer $deliveries  
38 - * @property integer $1scode  
39 - * @property string $firm_ur_adr  
40 - * @property string $firm_fiz_adr  
41 - * @property string $firm_code_eg  
42 - * @property string $firm_rs  
43 - * @property string $firm_mfo  
44 - * @property string $firm_site  
45 - * @property string $company  
46 - */  
47 -class WAccounts extends \yii\db\ActiveRecord  
48 -{  
49 - /**  
50 - * @inheritdoc  
51 - */  
52 - public static function tableName()  
53 - {  
54 - return 'w_accounts';  
55 - }  
56 -  
57 - /**  
58 - * @inheritdoc  
59 - */  
60 - public function rules()  
61 - {  
62 - return [  
63 - [['if_manager', 'margin_id', 'country', 'city', 'rating', 'dt', 'is_active', 'is_firm', 'office_id', 'is_scribe', 'set_manager_id', 'car', 'mod', 'deliveries', '1scode'], 'integer'],  
64 - [['email', 'pass', 'name', 'phones', 'comment', 'dt', 'set_manager_id'], 'required'],  
65 - [['comment'], 'string'],  
66 - [['balance'], 'number'],  
67 - [['email', 'name', 'firm_site'], 'string', 'max' => 150],  
68 - [['pass'], 'string', 'max' => 30],  
69 - [['phones', 'phones2', 'phones3'], 'string', 'max' => 50],  
70 - [['address', 'firm_inn', 'firm_bank'], 'string', 'max' => 254],  
71 - [['last_loginin'], 'string', 'max' => 15],  
72 - [['snumb', 'firm_ur_adr', 'firm_fiz_adr', 'firm_code_eg', 'firm_rs', 'firm_mfo', 'company'], 'string', 'max' => 255],  
73 - [['email'], 'unique']  
74 - ];  
75 - }  
76 -  
77 - /**  
78 - * @inheritdoc  
79 - */  
80 - public function attributeLabels()  
81 - {  
82 - return [  
83 - 'id' => Yii::t('app', 'ID'),  
84 - 'if_manager' => Yii::t('app', 'If Manager'),  
85 - 'email' => Yii::t('app', 'Email'),  
86 - 'pass' => Yii::t('app', 'Pass'),  
87 - 'margin_id' => Yii::t('app', 'Margin ID'),  
88 - 'name' => Yii::t('app', 'Name'),  
89 - 'phones' => Yii::t('app', 'Phones'),  
90 - 'country' => Yii::t('app', 'Country'),  
91 - 'city' => Yii::t('app', 'City'),  
92 - 'address' => Yii::t('app', 'Address'),  
93 - 'comment' => Yii::t('app', 'Comment'),  
94 - 'rating' => Yii::t('app', 'Rating'),  
95 - 'dt' => Yii::t('app', 'Dt'),  
96 - 'is_active' => Yii::t('app', 'Is Active'),  
97 - 'is_firm' => Yii::t('app', 'Is Firm'),  
98 - 'last_loginin' => Yii::t('app', 'Last Loginin'),  
99 - 'firm_inn' => Yii::t('app', 'Firm Inn'),  
100 - 'firm_bank' => Yii::t('app', 'Firm Bank'),  
101 - 'balance' => Yii::t('app', 'Balance'),  
102 - 'office_id' => Yii::t('app', 'Office ID'),  
103 - 'is_scribe' => Yii::t('app', 'Is Scribe'),  
104 - 'set_manager_id' => Yii::t('app', 'Set Manager ID'),  
105 - 'phones2' => Yii::t('app', 'Phones2'),  
106 - 'phones3' => Yii::t('app', 'Phones3'),  
107 - 'car' => Yii::t('app', 'Car'),  
108 - 'mod' => Yii::t('app', 'Mod'),  
109 - 'snumb' => Yii::t('app', 'Snumb'),  
110 - 'deliveries' => Yii::t('app', 'Deliveries'),  
111 - '1scode' => Yii::t('app', '1scode'),  
112 - 'firm_ur_adr' => Yii::t('app', 'Firm Ur Adr'),  
113 - 'firm_fiz_adr' => Yii::t('app', 'Firm Fiz Adr'),  
114 - 'firm_code_eg' => Yii::t('app', 'Firm Code Eg'),  
115 - 'firm_rs' => Yii::t('app', 'Firm Rs'),  
116 - 'firm_mfo' => Yii::t('app', 'Firm Mfo'),  
117 - 'firm_site' => Yii::t('app', 'Firm Site'),  
118 - 'company' => Yii::t('app', 'Company'),  
119 - ];  
120 - }  
121 -}  
backend/views/layouts/column.php
@@ -292,7 +292,7 @@ $this-&gt;beginContent(&#39;@app/views/layouts/main.php&#39;); @@ -292,7 +292,7 @@ $this-&gt;beginContent(&#39;@app/views/layouts/main.php&#39;);
292 ['label' => 'Управление ролями', 'url' => ['#'], 'items' => [ 292 ['label' => 'Управление ролями', 'url' => ['#'], 'items' => [
293 ['label' => 'Покупатели', 'url' => ['accounts/index']], 293 ['label' => 'Покупатели', 'url' => ['accounts/index']],
294 ['label' => 'Поставщики', 'url' => ['importers/index']], 294 ['label' => 'Поставщики', 'url' => ['importers/index']],
295 - ['label' => 'Администраторы', 'url' => '#'], 295 + ['label' => 'Администраторы', 'url' => ['user/index']],
296 ], 296 ],
297 ], 297 ],
298 ], 298 ],