Commit da0a81b85da610569a8930d23e080ac77bea3944

Authored by Administrator
1 parent e687688f

after marge

backend/controllers/AccountsController.php
... ... @@ -2,6 +2,8 @@
2 2  
3 3 namespace backend\controllers;
4 4  
  5 +use backend\models\Margins;
  6 +use backend\models\User;
5 7 use common\models\DicCities;
6 8 use Yii;
7 9 use common\models\Accounts;
... ... @@ -65,13 +67,17 @@ class AccountsController extends Controller
65 67 $model = new Accounts();
66 68  
67 69 $cities = DicCities::find()->all();
  70 + $margin = Margins::find()->all();
  71 + $users = User::find()->all();
68 72  
69 73 if ($model->load(Yii::$app->request->post()) && $model->save()) {
70 74 return $this->redirect(['view', 'id' => $model->id]);
71 75 } else {
72 76 return $this->render('create', [
  77 + 'users' => $users,
  78 + 'margin' => $margin,
73 79 'cities' => $cities,
74   - 'model' => $model,
  80 + 'model' => $model,
75 81 ]);
76 82 }
77 83 }
... ... @@ -87,6 +93,8 @@ class AccountsController extends Controller
87 93 $model = $this->findModel($id);
88 94  
89 95 $cities = DicCities::find()->all();
  96 + $margin = Margins::find()->all();
  97 + $users = User::find()->all();
90 98  
91 99 $model->dt = date("Y.m.d" , $model->dt);
92 100  
... ... @@ -94,8 +102,10 @@ class AccountsController extends Controller
94 102 return $this->redirect(['view', 'id' => $model->id]);
95 103 } else {
96 104 return $this->render('update', [
  105 + 'users' => $users,
  106 + 'margin' => $margin,
97 107 'cities' => $cities,
98   - 'model' => $model,
  108 + 'model' => $model,
99 109 ]);
100 110 }
101 111 }
... ...
common/models/WDicCities.php renamed to backend/models/Margins.php
1 1 <?php
2 2  
3   -namespace common\models;
  3 +namespace backend\models;
4 4  
5 5 use Yii;
6 6  
7 7 /**
8   - * This is the model class for table "w_dic_cities".
  8 + * This is the model class for table "w_margins".
9 9 *
10 10 * @property integer $id
11 11 * @property string $name
12   - * @property integer $is_active
13   - * @property integer $parent
  12 + * @property double $koef
14 13 */
15   -class WDicCities extends \yii\db\ActiveRecord
  14 +class Margins extends \yii\db\ActiveRecord
16 15 {
17 16 /**
18 17 * @inheritdoc
19 18 */
20 19 public static function tableName()
21 20 {
22   - return 'w_dic_cities';
  21 + return 'w_margins';
23 22 }
24 23  
25 24 /**
... ... @@ -28,10 +27,10 @@ class WDicCities extends \yii\db\ActiveRecord
28 27 public function rules()
29 28 {
30 29 return [
31   - [['name', 'parent'], 'required'],
32   - [['is_active', 'parent'], 'integer'],
33   - [['name'], 'string', 'max' => 254],
34   - [['parent', 'name'], 'unique', 'targetAttribute' => ['parent', 'name'], 'message' => 'The combination of Name and Parent has already been taken.']
  30 + [['name', 'koef'], 'required'],
  31 + [['koef'], 'number'],
  32 + [['name'], 'string', 'max' => 100],
  33 + [['name'], 'unique']
35 34 ];
36 35 }
37 36  
... ... @@ -41,10 +40,9 @@ class WDicCities extends \yii\db\ActiveRecord
41 40 public function attributeLabels()
42 41 {
43 42 return [
44   - 'id' => Yii::t('app', 'ID'),
45   - 'name' => Yii::t('app', 'Name'),
46   - 'is_active' => Yii::t('app', 'Is Active'),
47   - 'parent' => Yii::t('app', 'Parent'),
  43 + 'id' => 'ID',
  44 + 'name' => 'Name',
  45 + 'koef' => 'Koef',
48 46 ];
49 47 }
50 48 }
... ...
backend/models/User.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +
  5 +use Yii;
  6 +
  7 +/**
  8 + * This is the model class for table "w__user".
  9 + *
  10 + * @property integer $id
  11 + * @property string $login
  12 + * @property string $password
  13 + * @property string $email
  14 + * @property integer $is_super
  15 + * @property string $name
  16 + * @property integer $office_id
  17 + * @property string $photo
  18 + * @property string $contacts
  19 + * @property integer $acl_accounts_access
  20 + * @property integer $active
  21 + */
  22 +class User extends \yii\db\ActiveRecord
  23 +{
  24 + /**
  25 + * @inheritdoc
  26 + */
  27 + public static function tableName()
  28 + {
  29 + return 'w__user';
  30 + }
  31 +
  32 + /**
  33 + * @inheritdoc
  34 + */
  35 + public function rules()
  36 + {
  37 + return [
  38 + [['login', 'password', 'email', 'name', 'office_id', 'acl_accounts_access'], 'required'],
  39 + [['is_super', 'office_id', 'acl_accounts_access', 'active'], 'integer'],
  40 + [['login', 'password', 'email', 'name', 'photo'], 'string', 'max' => 255],
  41 + [['contacts'], 'string', 'max' => 100],
  42 + [['login'], 'unique']
  43 + ];
  44 + }
  45 +
  46 + /**
  47 + * @inheritdoc
  48 + */
  49 + public function attributeLabels()
  50 + {
  51 + return [
  52 + 'id' => 'ID',
  53 + 'login' => 'Login',
  54 + 'password' => 'Password',
  55 + 'email' => 'Email',
  56 + 'is_super' => 'Is Super',
  57 + 'name' => 'Name',
  58 + 'office_id' => 'Office ID',
  59 + 'photo' => 'Photo',
  60 + 'contacts' => 'Contacts',
  61 + 'acl_accounts_access' => 'Acl Accounts Access',
  62 + 'active' => 'Active',
  63 + ];
  64 + }
  65 +}
... ...
common/models/WAccounts.php renamed to backend/models/WAccounts.php
1 1 <?php
2 2  
3   -namespace common\models;
  3 +namespace backend\models;
4 4  
5 5 use Yii;
6 6  
... ... @@ -35,7 +35,7 @@ use Yii;
35 35 * @property integer $mod
36 36 * @property string $snumb
37 37 * @property integer $deliveries
38   - * @property integer $scode
  38 + * @property integer $1scode
39 39 * @property string $firm_ur_adr
40 40 * @property string $firm_fiz_adr
41 41 * @property string $firm_code_eg
... ... @@ -60,7 +60,7 @@ class WAccounts extends \yii\db\ActiveRecord
60 60 public function rules()
61 61 {
62 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', 'scode'], 'integer'],
  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 64 [['email', 'pass', 'name', 'phones', 'comment', 'dt', 'set_manager_id'], 'required'],
65 65 [['comment'], 'string'],
66 66 [['balance'], 'number'],
... ... @@ -108,7 +108,7 @@ class WAccounts extends \yii\db\ActiveRecord
108 108 'mod' => Yii::t('app', 'Mod'),
109 109 'snumb' => Yii::t('app', 'Snumb'),
110 110 'deliveries' => Yii::t('app', 'Deliveries'),
111   - 'scode' => Yii::t('app', 'Scode'),
  111 + '1scode' => Yii::t('app', '1scode'),
112 112 'firm_ur_adr' => Yii::t('app', 'Firm Ur Adr'),
113 113 'firm_fiz_adr' => Yii::t('app', 'Firm Fiz Adr'),
114 114 'firm_code_eg' => Yii::t('app', 'Firm Code Eg'),
... ...
backend/views/accounts/_form.php
... ... @@ -39,9 +39,10 @@ use yii\helpers\ArrayHelper;
39 39  
40 40 <?= $form->field($model, 'is_scribe')->checkbox() ?>
41 41  
42   - <?= $form->field($model, 'margin_id')->textInput() ?>
43 42  
44   - <?= $form->field($model, 'set_manager_id')->textInput() ?>
  43 + <?= $form->field($model, 'margin_id')->dropDownList(ArrayHelper::map($margin, 'id', 'name'), ['prompt' => 'ะ’ั‹ะฑะตั€ะธะต ะณะพั€ะพะด']) ?>
  44 +
  45 + <?= $form->field($model, 'set_manager_id')->dropDownList(ArrayHelper::map($users, 'id', 'name'), ['prompt' => 'ะ’ั‹ะฑะตั€ะธะต ะณะพั€ะพะด']) ?>
45 46  
46 47 <?= $form->field($model, 'scode')->textInput() ?>
47 48  
... ...
common/models/Accounts.php
... ... @@ -107,9 +107,9 @@ class Accounts extends \yii\db\ActiveRecord
107 107 'phones3' => 'ะขะตะปะตั„ะพะฝั‹ 3',
108 108 'car' => Yii::t('app', 'Car'),
109 109 'mod' => Yii::t('app', 'Mod'),
110   - 'snumb' => 'ะšะพะด ะฒ 1ะก',
  110 + 'snumb' => 'snumb',
111 111 'deliveries' => Yii::t('app', 'Deliveries'),
112   - 'scode' => Yii::t('app', 'Scode'),
  112 + 'scode' => 'ะšะพะด ะฒ 1ะก',
113 113 'firm_ur_adr' => Yii::t('app', 'Firm Ur Adr'),
114 114 'firm_fiz_adr' => Yii::t('app', 'Firm Fiz Adr'),
115 115 'firm_code_eg' => Yii::t('app', 'Firm Code Eg'),
... ...
common/models/WAccountsSearch.php deleted
1   -<?php
2   -
3   -namespace common\models;
4   -
5   -use Yii;
6   -use yii\base\Model;
7   -use yii\data\ActiveDataProvider;
8   -use common\models\WAccounts;
9   -
10   -/**
11   - * WAccountsSearch represents the model behind the search form about `common\models\WAccounts`.
12   - */
13   -class WAccountsSearch extends WAccounts
14   -{
15   - /**
16   - * @inheritdoc
17   - */
18   - public function rules()
19   - {
20   - return [
21   - [['id', 'if_manager', 'margin_id', 'country', 'city', 'rating', 'dt', 'is_active', 'is_firm', 'office_id', 'is_scribe', 'set_manager_id', 'car', 'mod', 'deliveries', 'scode'], 'integer'],
22   - [['email', 'pass', 'name', 'phones', 'address', 'comment', 'last_loginin', 'firm_inn', 'firm_bank', 'phones2', 'phones3', 'snumb', 'firm_ur_adr', 'firm_fiz_adr', 'firm_code_eg', 'firm_rs', 'firm_mfo', 'firm_site', 'company'], 'safe'],
23   - [['balance'], 'number'],
24   - ];
25   - }
26   -
27   - /**
28   - * @inheritdoc
29   - */
30   - public function scenarios()
31   - {
32   - // bypass scenarios() implementation in the parent class
33   - return Model::scenarios();
34   - }
35   -
36   - /**
37   - * Creates data provider instance with search query applied
38   - *
39   - * @param array $params
40   - *
41   - * @return ActiveDataProvider
42   - */
43   - public function search($params)
44   - {
45   - $query = WAccounts::find();
46   -
47   - $dataProvider = new ActiveDataProvider([
48   - 'query' => $query,
49   - ]);
50   -
51   - $this->load($params);
52   -
53   - if (!$this->validate()) {
54   - // uncomment the following line if you do not want to return any records when validation fails
55   - // $query->where('0=1');
56   - return $dataProvider;
57   - }
58   -
59   - $query->andFilterWhere([
60   - 'id' => $this->id,
61   - 'if_manager' => $this->if_manager,
62   - 'margin_id' => $this->margin_id,
63   - 'country' => $this->country,
64   - 'city' => $this->city,
65   - 'rating' => $this->rating,
66   - 'dt' => $this->dt,
67   - 'is_active' => $this->is_active,
68   - 'is_firm' => $this->is_firm,
69   - 'balance' => $this->balance,
70   - 'office_id' => $this->office_id,
71   - 'is_scribe' => $this->is_scribe,
72   - 'set_manager_id' => $this->set_manager_id,
73   - 'car' => $this->car,
74   - 'mod' => $this->mod,
75   - 'deliveries' => $this->deliveries,
76   - 'scode' => $this->scode,
77   - ]);
78   -
79   - $query->andFilterWhere(['like', 'email', $this->email])
80   - ->andFilterWhere(['like', 'pass', $this->pass])
81   - ->andFilterWhere(['like', 'name', $this->name])
82   - ->andFilterWhere(['like', 'phones', $this->phones])
83   - ->andFilterWhere(['like', 'address', $this->address])
84   - ->andFilterWhere(['like', 'comment', $this->comment])
85   - ->andFilterWhere(['like', 'last_loginin', $this->last_loginin])
86   - ->andFilterWhere(['like', 'firm_inn', $this->firm_inn])
87   - ->andFilterWhere(['like', 'firm_bank', $this->firm_bank])
88   - ->andFilterWhere(['like', 'phones2', $this->phones2])
89   - ->andFilterWhere(['like', 'phones3', $this->phones3])
90   - ->andFilterWhere(['like', 'snumb', $this->snumb])
91   - ->andFilterWhere(['like', 'firm_ur_adr', $this->firm_ur_adr])
92   - ->andFilterWhere(['like', 'firm_fiz_adr', $this->firm_fiz_adr])
93   - ->andFilterWhere(['like', 'firm_code_eg', $this->firm_code_eg])
94   - ->andFilterWhere(['like', 'firm_rs', $this->firm_rs])
95   - ->andFilterWhere(['like', 'firm_mfo', $this->firm_mfo])
96   - ->andFilterWhere(['like', 'firm_site', $this->firm_site])
97   - ->andFilterWhere(['like', 'company', $this->company]);
98   -
99   - return $dataProvider;
100   - }
101   -}