Commit c25e0cd9e9a12b7eb422f1da5fba9d2bf9186a5f
1 parent
010e009e
access in admin
Showing
3 changed files
with
140 additions
and
2 deletions
Show diff stats
backend/controllers/AccountsController.php
| 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 | + * | |
| 11 | + * @property integer $id | |
| 12 | + * @property integer $if_manager | |
| 13 | + * @property string $email | |
| 14 | + * @property string $pass | |
| 15 | + * @property integer $margin_id | |
| 16 | + * @property string $name | |
| 17 | + * @property string $phones | |
| 18 | + * @property integer $country | |
| 19 | + * @property integer $city | |
| 20 | + * @property string $address | |
| 21 | + * @property string $comment | |
| 22 | + * @property integer $rating | |
| 23 | + * @property string $dt | |
| 24 | + * @property integer $is_active | |
| 25 | + * @property integer $is_firm | |
| 26 | + * @property string $last_loginin | |
| 27 | + * @property string $firm_inn | |
| 28 | + * @property string $firm_bank | |
| 29 | + * @property double $balance | |
| 30 | + * @property integer $office_id | |
| 31 | + * @property integer $is_scribe | |
| 32 | + * @property integer $set_manager_id | |
| 33 | + * @property string $phones2 | |
| 34 | + * @property string $phones3 | |
| 35 | + * @property integer $car | |
| 36 | + * @property integer $mod | |
| 37 | + * @property string $snumb | |
| 38 | + * @property integer $deliveries | |
| 39 | + * @property integer $scode | |
| 40 | + * @property string $firm_ur_adr | |
| 41 | + * @property string $firm_fiz_adr | |
| 42 | + * @property string $firm_code_eg | |
| 43 | + * @property string $firm_rs | |
| 44 | + * @property string $firm_mfo | |
| 45 | + * @property string $firm_site | |
| 46 | + * @property string $company | |
| 47 | + */ | |
| 48 | +class Accounts extends \yii\db\ActiveRecord | |
| 49 | +{ | |
| 50 | + | |
| 51 | + public $re_pass; | |
| 52 | + public $surname; | |
| 53 | + public $verifyCode; | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * @inheritdoc | |
| 57 | + */ | |
| 58 | + public static function tableName() | |
| 59 | + { | |
| 60 | + return 'w_accounts'; | |
| 61 | + } | |
| 62 | + | |
| 63 | + | |
| 64 | + public function beforeSave() | |
| 65 | + { | |
| 66 | + $date = \DateTime::createFromFormat("Y.m.d" , $this->dt); | |
| 67 | + $this->dt = $date->getTimestamp(); | |
| 68 | + | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * @inheritdoc | |
| 73 | + */ | |
| 74 | + public function rules() | |
| 75 | + { | |
| 76 | + return [ | |
| 77 | + [['if_manager', 'margin_id', 'country', 'city', 'rating', 'is_active', 'is_firm', 'office_id', 'is_scribe', 'set_manager_id', 'car', 'mod', 'deliveries', 'scode'], 'integer'], | |
| 78 | + [['email', 'pass', 'name','surname', 'phones',], 'required'], | |
| 79 | + [['comment'], 'string'], | |
| 80 | + [['balance'], 'number'], | |
| 81 | + [['email', 'name','surname', 'firm_site'], 'string', 'max' => 150], | |
| 82 | + [['pass','re_pass'], 'string', 'max' => 30], | |
| 83 | + [['phones', 'phones2', 'phones3'], 'string', 'max' => 50], | |
| 84 | + [['address', 'firm_inn', 'firm_bank'], 'string', 'max' => 254], | |
| 85 | + [['last_loginin'], 'string', 'max' => 15], | |
| 86 | + [['snumb', 'firm_ur_adr', 'firm_fiz_adr', 'firm_code_eg', 'firm_rs', 'firm_mfo', 'company'], 'string', 'max' => 255], | |
| 87 | + [['email'], 'unique'], | |
| 88 | + [['email'], 'email'], | |
| 89 | + ['re_pass', 'compare', 'compareAttribute' => 'pass'], | |
| 90 | + ['dt', 'date', 'format' => 'Y.m.d'] | |
| 91 | + ]; | |
| 92 | + } | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * @inheritdoc | |
| 96 | + */ | |
| 97 | + public function attributeLabels() | |
| 98 | + { | |
| 99 | + return [ | |
| 100 | + 'id' => 'ID', | |
| 101 | + 'if_manager' => 'Статус менеджера', | |
| 102 | + 'email' => 'E-mail (Логин)', | |
| 103 | + 'pass' => 'Пароль', | |
| 104 | + 'margin_id' => 'Тип цены', | |
| 105 | + 'name' => 'Имя', | |
| 106 | + 'phones' => 'Телефоны', | |
| 107 | + 'country' => Yii::t('app', 'Country'), | |
| 108 | + 'city' =>'Город', | |
| 109 | + 'address' => 'Адрес', | |
| 110 | + 'comment' => 'Комментарий', | |
| 111 | + 'rating' => Yii::t('app', 'Rating'), | |
| 112 | + 'dt' =>'Дата регистрации', | |
| 113 | + 'is_active' => 'Активный', | |
| 114 | + 'is_firm' => 'Юридическое лицо', | |
| 115 | + 'last_loginin' => Yii::t('app', 'Last Loginin'), | |
| 116 | + 'firm_inn' => 'ИНН', | |
| 117 | + 'firm_bank' => 'Банк', | |
| 118 | + 'balance' => Yii::t('app', 'Balance'), | |
| 119 | + 'office_id' => Yii::t('app', 'Office ID'), | |
| 120 | + 'is_scribe' => 'Подписка', | |
| 121 | + 'set_manager_id' => 'Персональный менеджер', | |
| 122 | + 'phones2' => 'Телефоны 2', | |
| 123 | + 'phones3' => 'Телефоны 3', | |
| 124 | + 'car' => Yii::t('app', 'Car'), | |
| 125 | + 'mod' => Yii::t('app', 'Mod'), | |
| 126 | + 'snumb' => 'snumb', | |
| 127 | + 'deliveries' => Yii::t('app', 'Deliveries'), | |
| 128 | + 'scode' => 'Код в 1С', | |
| 129 | + 'firm_ur_adr' => 'Юридический адрес', | |
| 130 | + 'firm_fiz_adr' => 'Физический адрес', | |
| 131 | + 'firm_code_eg' => 'Код ЭГ', | |
| 132 | + 'firm_rs' => 'Расчётный счёт', | |
| 133 | + 'firm_mfo' => 'МФО', | |
| 134 | + 'firm_site' => 'Сайт', | |
| 135 | + 'company' => 'Название фирмы', | |
| 136 | + ]; | |
| 137 | + } | |
| 138 | +} | ... | ... |
common/models/Accounts.php
| ... | ... | @@ -75,7 +75,7 @@ class Accounts extends \yii\db\ActiveRecord |
| 75 | 75 | { |
| 76 | 76 | return [ |
| 77 | 77 | [['if_manager', 'margin_id', 'country', 'city', 'rating', 'is_active', 'is_firm', 'office_id', 'is_scribe', 'set_manager_id', 'car', 'mod', 'deliveries', 'scode'], 'integer'], |
| 78 | - [['email', 'pass', 'name','surname', 'phones',], 'required'], | |
| 78 | + [['company','email', 'pass', 'name','surname', 'phones',], 'required'], | |
| 79 | 79 | [['comment'], 'string'], |
| 80 | 80 | [['balance'], 'number'], |
| 81 | 81 | [['email', 'name','surname', 'firm_site'], 'string', 'max' => 150], | ... | ... |