Commit 2fd0fce6ff59a8681a39629bbc5807b1c0f0eec7

Authored by Administrator
1 parent 878c38e8

VItaliy 04.12.2015

common/models/Accounts.php
... ... @@ -51,6 +51,9 @@ use yii\db\ActiveRecord;
51 51 class Accounts extends ActiveRecord implements IdentityInterface
52 52 {
53 53  
  54 + /**
  55 + * @var
  56 + */
54 57 public $re_pass;
55 58 public $surname;
56 59 public $country_region;
... ... @@ -69,6 +72,9 @@ class Accounts extends ActiveRecord implements IdentityInterface
69 72 }
70 73  
71 74  
  75 + /**
  76 + * @return bool
  77 + */
72 78 public function beforeSave()
73 79 {
74 80 $this->dt = time();
... ... @@ -84,7 +90,7 @@ class Accounts extends ActiveRecord implements IdentityInterface
84 90 {
85 91 return [
86 92 [['if_manager', 'margin_id', 'country', 'city', 'rating', 'is_active', 'is_firm', 'office_id', 'is_scribe', 'set_manager_id', 'car', 'mod', 'deliveries', 'scode'], 'integer'],
87   - [['company','email', 'pass', 'name','surname', 'phones',], 'required'],
  93 + [['company','email', 'pass', 'name', 'phones',], 'required'],
88 94 [['comment'], 'string'],
89 95 [['balance'], 'number'],
90 96 [['email', 'name','surname', 'firm_site'], 'string', 'max' => 150],
... ... @@ -95,9 +101,6 @@ class Accounts extends ActiveRecord implements IdentityInterface
95 101 [['snumb', 'firm_ur_adr', 'firm_fiz_adr', 'firm_code_eg', 'firm_rs', 'firm_mfo', 'company'], 'string', 'max' => 255],
96 102 [['email'], 'unique'],
97 103 [['email'], 'email'],
98   - ['re_pass', 'compare', 'compareAttribute' => 'pass'],
99   - ['verifyCode', 'captcha'],
100   - ['dt', 'date', 'format' => 'Y.m.d'],
101 104 [['rating','if_manager','set_manager_id','balance'], 'default', 'value' => '0'],
102 105 [['is_active','margin_id','office_id','is_scribe'], 'default', 'value' => '1'],
103 106 [['comment'], 'default', 'value' => 'Новый пользователь'],
... ...
frontend/controllers/SiteController.php
... ... @@ -2,6 +2,7 @@
2 2 namespace frontend\controllers;
3 3  
4 4 use common\models\Accounts;
  5 +use frontend\models\AccountsForm;
5 6 use common\models\News;
6 7 use common\models\Slider;
7 8 use common\models\Team;
... ... @@ -338,15 +339,21 @@ class SiteController extends Controller
338 339  
339 340 $this->layout = '/internal';
340 341  
341   - $model = new Accounts();
  342 + $model = new AccountsForm();
342 343  
343   - if ($model->load(Yii::$app->request->post()) ) {
  344 + if ($model->load(Yii::$app->request->post()) && $model->validate() ) {
344 345  
345   - $model->generateAuthKey();
346 346  
347   - $model->save();
348 347  
349   - if (Yii::$app->getUser()->login($model)) {
  348 + $accounts = new Accounts();
  349 +
  350 + $accounts->load(Yii::$app->request->post());
  351 +
  352 + $accounts->generateAuthKey();
  353 +
  354 + $accounts->save();
  355 +
  356 + if (Yii::$app->getUser()->login($accounts)) {
350 357  
351 358 return $this->goHome();
352 359  
... ... @@ -369,13 +376,16 @@ class SiteController extends Controller
369 376 $this->layout = '/internal';
370 377  
371 378 $model = new PasswordResetRequestForm();
  379 +
372 380 if ($model->load(Yii::$app->request->post()) && $model->validate()) {
373 381  
374 382 if ($model->sendEmail()) {
  383 +
375 384 Yii::$app->session->setFlash('success', 'Для того, чтобы изменить пароль, перейдите по ссылке, которая придет Вам на email');
376 385  
377 386 return $this->goHome();
378 387 } else {
  388 + die('here2');
379 389 Yii::$app->session->setFlash('error', 'Пользователя с таким e-mail в базе не существует');
380 390 }
381 391 }
... ...
frontend/models/AccountsForm.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace frontend\models;
  4 +
  5 +use common\models\Accounts;
  6 +use yii\base\Model;
  7 +use Yii;
  8 +/**
  9 + * This is the model class for table "w_accounts".
  10 + *
  11 + *
  12 + * @property integer $id
  13 + * @property integer $if_manager
  14 + * @property string $email
  15 + * @property string $auth_key
  16 + * @property string $pass
  17 + * @property integer $margin_id
  18 + * @property string $name
  19 + * @property string $phones
  20 + * @property integer $country
  21 + * @property integer $city
  22 + * @property string $address
  23 + * @property string $comment
  24 + * @property integer $rating
  25 + * @property string $dt
  26 + * @property integer $is_active
  27 + * @property integer $is_firm
  28 + * @property string $last_loginin
  29 + * @property string $firm_inn
  30 + * @property string $firm_bank
  31 + * @property double $balance
  32 + * @property integer $office_id
  33 + * @property integer $is_scribe
  34 + * @property integer $set_manager_id
  35 + * @property string $phones2
  36 + * @property string $phones3
  37 + * @property integer $car
  38 + * @property integer $mod
  39 + * @property string $snumb
  40 + * @property integer $deliveries
  41 + * @property integer $scode
  42 + * @property string $firm_ur_adr
  43 + * @property string $firm_fiz_adr
  44 + * @property string $firm_code_eg
  45 + * @property string $firm_rs
  46 + * @property string $firm_mfo
  47 + * @property string $firm_site
  48 + * @property string $company
  49 + */
  50 +class AccountsForm extends Model
  51 +{
  52 +
  53 + public $re_pass;
  54 + public $surname;
  55 + public $country_region;
  56 + public $verifyCode;
  57 + public $auth_key;
  58 + public $password_hash;
  59 + public $password_reset_token;
  60 +
  61 +
  62 +
  63 + /**
  64 + * @inheritdoc
  65 + */
  66 + public function rules()
  67 + {
  68 + return [
  69 + [['if_manager', 'margin_id', 'country', 'city', 'rating', 'is_active', 'is_firm', 'office_id', 'is_scribe', 'set_manager_id', 'car', 'mod', 'deliveries', 'scode'], 'integer'],
  70 + [['company','email', 'pass', 'name','surname', 'phones',], 'required'],
  71 + [['comment'], 'string'],
  72 + [['balance'], 'number'],
  73 + [['email', 'name','surname', 'firm_site'], 'string', 'max' => 150],
  74 + [['pass','re_pass'], 'string', 'max' => 30],
  75 + [['phones', 'phones2', 'phones3'], 'string', 'max' => 50],
  76 + [['address', 'firm_inn', 'firm_bank'], 'string', 'max' => 254],
  77 + [['last_loginin'], 'string', 'max' => 15],
  78 + [['snumb', 'firm_ur_adr', 'firm_fiz_adr', 'firm_code_eg', 'firm_rs', 'firm_mfo', 'company'], 'string', 'max' => 255],
  79 + [['email'], 'unique'],
  80 + [['email'], 'email'],
  81 + ['re_pass', 'compare', 'compareAttribute' => 'pass'],
  82 + ['verifyCode', 'captcha'],
  83 + ['dt', 'date', 'format' => 'Y.m.d'],
  84 + [['rating','if_manager','set_manager_id','balance'], 'default', 'value' => '0'],
  85 + [['is_active','margin_id','office_id','is_scribe'], 'default', 'value' => '1'],
  86 + [['comment'], 'default', 'value' => 'Новый пользователь'],
  87 + ];
  88 + }
  89 +
  90 + /**
  91 + * @inheritdoc
  92 + */
  93 + public function attributeLabels()
  94 + {
  95 + return [
  96 + 'id' => 'ID',
  97 + 'if_manager' => 'Статус менеджера',
  98 + 'email' => 'E-mail (Логин)',
  99 + 'pass' => 'Пароль',
  100 + 'margin_id' => 'Тип цены',
  101 + 'name' => 'Имя',
  102 + 'phones' => 'Телефоны',
  103 + 'country' => Yii::t('app', 'Country'),
  104 + 'city' =>'Город',
  105 + 'address' => 'Адрес',
  106 + 'comment' => 'Комментарий',
  107 + 'rating' => Yii::t('app', 'Rating'),
  108 + 'dt' =>'Дата регистрации',
  109 + 'is_active' => 'Активный',
  110 + 'is_firm' => 'Юридическое лицо',
  111 + 'last_loginin' => Yii::t('app', 'Last Loginin'),
  112 + 'firm_inn' => 'ИНН',
  113 + 'firm_bank' => 'Банк',
  114 + 'balance' => Yii::t('app', 'Balance'),
  115 + 'office_id' => Yii::t('app', 'Office ID'),
  116 + 'is_scribe' => 'Подписка',
  117 + 'set_manager_id' => 'Персональный менеджер',
  118 + 'phones2' => 'Телефоны 2',
  119 + 'phones3' => 'Телефоны 3',
  120 + 'car' => Yii::t('app', 'Car'),
  121 + 'mod' => Yii::t('app', 'Mod'),
  122 + 'snumb' => 'snumb',
  123 + 'deliveries' => Yii::t('app', 'Deliveries'),
  124 + 'scode' => 'Код в 1С',
  125 + 'firm_ur_adr' => 'Юридический адрес',
  126 + 'firm_fiz_adr' => 'Физический адрес',
  127 + 'firm_code_eg' => 'Код ЭГ',
  128 + 'firm_rs' => 'Расчётный счёт',
  129 + 'firm_mfo' => 'МФО',
  130 + 'firm_site' => 'Сайт',
  131 + 'company' => 'Название фирмы',
  132 + 'country_region' => 'Регион'
  133 + ];
  134 + }
  135 +
  136 +
  137 +
  138 +
  139 +
  140 +
  141 +
  142 +}
... ...
frontend/models/PasswordResetRequestForm.php
... ... @@ -45,11 +45,15 @@ class PasswordResetRequestForm extends Model
45 45 $user->generatePasswordResetToken();
46 46 }
47 47  
  48 +
  49 +
48 50 if ($user->save()) {
  51 +
49 52 $form = array();
50 53 $form ['email'] = $user->email;
51 54 $form ['name'] = $user->name;
52 55 $form ['pass'] = $user->pass;
  56 + die(var_dump(Emails::get('remide',$form,$form ['email'])));
53 57 return Emails::get('remide',$form,$form ['email']);
54 58  
55 59 }
... ...
frontend/views/layouts/main.php
... ... @@ -8,7 +8,7 @@ use yii\widgets\ActiveForm;
8 8 use \yii\widgets\Menu;
9 9 use \yii\helpers\Url;
10 10 use common\models\Callback;
11   -use \common\models\Accounts;
  11 +use \frontend\models\AccountsForm;
12 12 use \yii\helpers\ArrayHelper;
13 13 use \common\models\DicCities;
14 14 use \common\models\Deliveries;
... ... @@ -410,41 +410,41 @@ use \common\models\UserLoginForm;
410 410 <div class="registration_for_person">
411 411 <?php $form = ActiveForm::begin(['options' => ['enctype'=> 'multipart/form-data'], 'method'=>'post','action' => '/site/signup']); ?>
412 412  
413   - <?= $form->field(new Accounts(), 'is_firm')->hiddenInput(['value'=>'0'])->label(false) ?>
  413 + <?= $form->field(new AccountsForm(), 'is_firm')->hiddenInput(['value'=>'0'])->label(false) ?>
414 414  
415   - <?= $form->field(new Accounts(), 'company')->hiddenInput(['value'=>'Частное лицо'])->label(false) ?>
  415 + <?= $form->field(new AccountsForm(), 'company')->hiddenInput(['value'=>'Частное лицо'])->label(false) ?>
416 416  
417   - <?= $form->field(new Accounts(), 'name')->textInput(['maxlength' => 45,'placeholder'=>'Имя'])->label(false) ?>
  417 + <?= $form->field(new AccountsForm(), 'name')->textInput(['maxlength' => 45,'placeholder'=>'Имя'])->label(false) ?>
418 418  
419   - <?= $form->field(new Accounts(), 'surname')->textInput(['maxlength' => 45,'placeholder'=>'Фамилия'])->label(false) ?>
  419 + <?= $form->field(new AccountsForm(), 'surname')->textInput(['maxlength' => 45,'placeholder'=>'Фамилия'])->label(false) ?>
420 420  
421   - <?= $form->field(new Accounts(), 'phones')->textInput(['maxlength' => 45,'placeholder'=>'Телефон'])->label(false) ?>
  421 + <?= $form->field(new AccountsForm(), 'phones')->textInput(['maxlength' => 45,'placeholder'=>'Телефон'])->label(false) ?>
422 422  
423   - <?= $form->field(new Accounts(), 'email')->textInput(['maxlength' => 45,'placeholder'=>'E-mail','class'=>'form-control telephone_registration'])->label(false) ?>
  423 + <?= $form->field(new AccountsForm(), 'email')->textInput(['maxlength' => 45,'placeholder'=>'E-mail','class'=>'form-control telephone_registration'])->label(false) ?>
424 424  
425   - <?= $form->field(new Accounts(), 'pass')->passwordInput(['maxlength' => 45,'placeholder'=>'Пароль','class'=>'form-control telephone_registration'])->label(false) ?>
  425 + <?= $form->field(new AccountsForm(), 'pass')->passwordInput(['maxlength' => 45,'placeholder'=>'Пароль','class'=>'form-control telephone_registration'])->label(false) ?>
426 426  
427   - <?= $form->field(new Accounts(), 're_pass')->passwordInput(['maxlength' => 45,'placeholder'=>'Пароль','class'=>'form-control telephone_registration'])->label(false) ?>
  427 + <?= $form->field(new AccountsForm(), 're_pass')->passwordInput(['maxlength' => 45,'placeholder'=>'Пароль','class'=>'form-control telephone_registration'])->label(false) ?>
428 428  
429   - <?= $form->field(new Accounts(), 'country',['options'=>['class'=>'selectize_item2' ]])->dropDownList(
  429 + <?= $form->field(new AccountsForm(), 'country',['options'=>['class'=>'selectize_item2' ]])->dropDownList(
430 430 ArrayHelper::map(DicCities::find()->where(['parent' => 0])->all(), 'id', 'name'),
431 431 ['prompt' => 'Выберите область']
432 432 )->label(false);
433 433 ?>
434 434  
435   - <?= $form->field(new Accounts(), 'city',['options'=>['class'=>'selectize_item2' ]])->dropDownList(
  435 + <?= $form->field(new AccountsForm(), 'city',['options'=>['class'=>'selectize_item2' ]])->dropDownList(
436 436 [],
437 437 ['prompt' => 'Выберите город']
438 438 )->label(false);
439 439 ?>
440 440  
441   - <?= $form->field(new Accounts(), 'deliveries',['options'=>['class'=>'selectize_item2' ]])->dropDownList(
  441 + <?= $form->field(new AccountsForm(), 'deliveries',['options'=>['class'=>'selectize_item2' ]])->dropDownList(
442 442 ArrayHelper::map(Deliveries::find()->all(), 'id', 'name'),
443 443 ['prompt' => 'Выберите тип перевозки']
444 444 )->label(false);
445 445 ?>
446 446  
447   - <?= $form->field(new Accounts(), 'verifyCode')->widget(Captcha::className(), [
  447 + <?= $form->field(new AccountsForm(), 'verifyCode')->widget(Captcha::className(), [
448 448 'options'=>['placeholder'=>'Введите код' ],
449 449 'template' => '<div>{input}</div><div class="row"><div class="col-lg-3">{image}</div></div>',
450 450 ])->label(false); ?>
... ... @@ -457,142 +457,6 @@ use \common\models\UserLoginForm;
457 457 </div>
458 458  
459 459  
460   -
461   -
462   -
463   -
464   -<!---->
465   -<!---->
466   -<!-- <form action="" method="post" id="registration_form">-->
467   -<!-- <h3>Заявка на регистрацию</h3>-->
468   -<!-- <div class="purple_registration active_button" style=" border-radius:12px 0 0 0 " id="person"><p>Частное лицо</p></div><div id="company" class="purple_registration"><p>Оптовик</p></div>-->
469   -<!-- <div class="registration_holder">-->
470   -<!---->
471   -<!-- <div class="registration_for_person">-->
472   -<!---->
473   -<!---->
474   -<!-- <input type="text" name="familyname" id="family_name" placeholder="Фамилия-->
475   -<!-- " minlength="2" required=""><span class='star'>*</span>-->
476   -<!---->
477   -<!-- <input name="name" id="name" placeholder="Имя" minlength="2" type="text" required=""><span class='star1'>*</span>-->
478   -<!-- <input type="email" name="email" id="email_registration" placeholder="email" minlength="10" required=""><span class='star2'>*</span>-->
479   -<!---->
480   -<!-- <input type="phone" name="telephone" id="telephone_registration" placeholder="Телефон" minlength="7" required=""><span class='star3'>*</span>-->
481   -<!-- <input type="telephone" name="telephone" id="telephone_registration_add" placeholder="Телефон"><span class='star4'>*</span>-->
482   -<!-- <p class="add_telephone" style="font-size: 14px;-->
483   -<!-- margin-right: 12px;-->
484   -<!-- margin-top: 10px;">добавить еще 1 телефон</p>-->
485   -<!-- <p>Фактический адрес</p>-->
486   -<!-- <div class="selectize_item2">-->
487   -<!---->
488   -<!---->
489   -<!-- <select class="area">-->
490   -<!-- <option value="" disabled="" selected="">Выберите область</option>-->
491   -<!-- <option value="2">Выбери меня!</option>-->
492   -<!-- <option value="3">Выбери меня!</option>-->
493   -<!-- <option value="5">Меня!</option>-->
494   -<!-- <option value="4">Меня</option>-->
495   -<!-- </select>-->
496   -<!---->
497   -<!-- </div>-->
498   -<!-- <div class="selectize_item2">-->
499   -<!---->
500   -<!---->
501   -<!-- <select class="city">-->
502   -<!-- <option value="" disabled="" selected="">Выберите город</option>-->
503   -<!-- <option value="2">Выбери меня!</option>-->
504   -<!-- <option value="3">Выбери меня!</option>-->
505   -<!-- <option value="5">Меня!</option>-->
506   -<!-- <option value="4">Меня</option>-->
507   -<!-- </select>-->
508   -<!---->
509   -<!-- </div>-->
510   -<!-- <div class="selectize_item2">-->
511   -<!---->
512   -<!---->
513   -<!-- <select class="steel1">-->
514   -<!-- <option value="" disabled="" selected="">Перевозчик</option>-->
515   -<!-- <option value="2">Выбери меня!</option>-->
516   -<!-- <option value="3">Выбери меня!</option>-->
517   -<!-- <option value="5">Меня!</option>-->
518   -<!-- <option value="4">Меня</option>-->
519   -<!-- </select>-->
520   -<!---->
521   -<!-- </div>-->
522   -<!---->
523   -<!-- <input type="text" placeholder="Введите код" id="code_input" required="4"><span class='star5'>*</span>-->
524   -<!-- <div class="code_generate">-->
525   -<!-- <img src="/images/code_generator.png">-->
526   -<!-- </div>-->
527   -<!-- <button class="purple" type="submit" value="Submit">Зарегистрироваться</button>-->
528   -<!---->
529   -<!---->
530   -<!-- </div>-->
531   -<!-- <div class="registration_for_company">-->
532   -<!---->
533   -<!-- <input type="text" name="fullname" id="company_name" placeholder="Компания-->
534   -<!-- " minlength="2" required="">-->
535   -<!-- <input type="text" name="fullname" id="family_name" placeholder="Фамилия-->
536   -<!-- " minlength="2" required=""><span class='star'>*</span>-->
537   -<!---->
538   -<!-- <input type="" name="name" id="name" placeholder="Имя" minlength="2" required=""><span class='star1'>*</span>-->
539   -<!-- <input type="email" name="email" id="email_registration" placeholder="email" minlength="10" required=""><span class='star3'>*</span>-->
540   -<!---->
541   -<!-- <input type="telephone" name="telephone" id="telephone_registration" placeholder="Телефон" minlength="7" required=""><span class='star4'>*</span><span class='star6'>*</span>-->
542   -<!-- <input type="telephone" name="telephone" id="telephone_registration_add1" placeholder="Телефон" style="display:none">-->
543   -<!-- <p class="add_telephone1" style="font-size: 14px;-->
544   -<!-- margin-right: 12px;-->
545   -<!-- margin-top: 10px;">добавить еще 1 телефон</p>-->
546   -<!-- <p>Фактический адрес</p>-->
547   -<!-- <div class="selectize_item2">-->
548   -<!---->
549   -<!---->
550   -<!-- <select class="area">-->
551   -<!-- <option value="" disabled="" selected="">Выберите область</option>-->
552   -<!-- <option value="2">Выбери меня!</option>-->
553   -<!-- <option value="3">Выбери меня!</option>-->
554   -<!-- <option value="5">Меня!</option>-->
555   -<!-- <option value="4">Меня</option>-->
556   -<!-- </select>-->
557   -<!---->
558   -<!-- </div>-->
559   -<!-- <div class="selectize_item2">-->
560   -<!---->
561   -<!---->
562   -<!-- <select class="city">-->
563   -<!-- <option value="" disabled="" selected="">Выберите город</option>-->
564   -<!-- <option value="2">Выбери меня!</option>-->
565   -<!-- <option value="3">Выбери меня!</option>-->
566   -<!-- <option value="5">Меня!</option>-->
567   -<!-- <option value="4">Меня</option>-->
568   -<!-- </select>-->
569   -<!---->
570   -<!-- </div>-->
571   -<!-- <div class="selectize_item2">-->
572   -<!---->
573   -<!---->
574   -<!-- <select class="steel1">-->
575   -<!-- <option value="" disabled="" selected="">Перевозчик</option>-->
576   -<!-- <option value="2">Выбери меня!</option>-->
577   -<!-- <option value="3">Выбери меня!</option>-->
578   -<!-- <option value="5">Меня!</option>-->
579   -<!-- <option value="4">Меня</option>-->
580   -<!-- </select>-->
581   -<!---->
582   -<!-- </div>-->
583   -<!---->
584   -<!-- <input type="text" placeholder="Введите код" id="code_input" required='4'>-->
585   -<!-- <div class="code_generate">-->
586   -<!-- <img src="/images/code_generator.png">-->
587   -<!-- </div><span class='star5'>*</span>-->
588   -<!-- <button class="purple" type="submit" value="Submit">Зарегистрироваться</button>-->
589   -<!---->
590   -<!---->
591   -<!-- </div>-->
592   -<!-- </div></form>-->
593   -
594   -
595   -
596 460 </div>
597 461 </div>
598 462  
... ...