Registration

parent 83131e64
...@@ -168,6 +168,10 @@ JS; ...@@ -168,6 +168,10 @@ JS;
$opt = $element['fileOptions']; $opt = $element['fileOptions'];
if(!empty($element['empty'])) if(!empty($element['empty']))
$opt['value'] = $element['empty']; $opt['value'] = $element['empty'];
if(!empty($element['inputOptions']))
$optEl['inputOptions'] = $element['inputOptions'];
if(!empty($element['inputOptions']))
$opt['inputOptions'] = $element['inputOptions'];
switch($element['type']) { switch($element['type']) {
case 'checkbox': case 'checkbox':
$opt['data-render'] = 'switchery'; $opt['data-render'] = 'switchery';
...@@ -191,12 +195,15 @@ JS; ...@@ -191,12 +195,15 @@ JS;
case 'email': case 'email':
$tmp = $this->field($this->model, $key, $optEl)->input($element['type'], $opt); $tmp = $this->field($this->model, $key, $optEl)->input($element['type'], $opt);
if(!empty($element['hint'])) $tmp = $tmp->hint($element['hint']); if(!empty($element['hint'])) $tmp = $tmp->hint($element['hint']);
if($element['options']['label'] === false) $tmp = $tmp->label(false);
$config['options'][] = $tmp; $config['options'][] = $tmp;
break; break;
case 'password': case 'password':
//$opt['value'] = ''; //$opt['value'] = '';
$optEl['template'] = '{label}{input}<div id="'.$element['pwd-id'].'" class="is0 m-t-5"></div>{error}'; $optEl['template'] = '{label}{input}<div id="'.$element['pwd-id'].'" class="is0 m-t-5"></div>{error}';
$config['options'][] = $this->field($this->model, $key, $optEl)->input($element['type'], $opt); $tmp = $this->field($this->model, $key, $optEl)->input($element['type'], $opt);
if($element['options']['label'] === false) $tmp = $tmp->label(false);
$config['options'][] = $tmp;
break; break;
case 'hidden': case 'hidden':
$config['options'][] = $this->field($this->model, $key, $optEl)->hiddenInput($opt)->label(false); $config['options'][] = $this->field($this->model, $key, $optEl)->hiddenInput($opt)->label(false);
...@@ -209,6 +216,7 @@ JS; ...@@ -209,6 +216,7 @@ JS;
//$optEl['template'] = '{label}<div class="col-md-8">{input}</div>{error}{hint}'; //$optEl['template'] = '{label}<div class="col-md-8">{input}</div>{error}{hint}';
$tmp = $this->field($this->model, $key, $optEl)->dropDownList($element['items'],$opt); $tmp = $this->field($this->model, $key, $optEl)->dropDownList($element['items'],$opt);
if(!empty($element['hint'])) $tmp = $tmp->hint($element['hint']); if(!empty($element['hint'])) $tmp = $tmp->hint($element['hint']);
if($element['options']['label'] === false) $tmp = $tmp->label(false);
$config['options'][] = $tmp; $config['options'][] = $tmp;
break; break;
case 'listBox': case 'listBox':
...@@ -272,7 +280,8 @@ JS; ...@@ -272,7 +280,8 @@ JS;
if($button['type'] == 'htmlBlock') if($button['type'] == 'htmlBlock')
$config['options'][] = $button['value']; $config['options'][] = $button['value'];
else if($button['type'] == 'submit') else if($button['type'] == 'submit')
$config['options'][] = \yii\helpers\Html::submitButton($button['value'], ['class'=> 'btn btn-success']); $config['options'][] = (!empty($button['class'])) ? \yii\helpers\Html::submitButton($button['value'], ['class'=> $button['class']])
: \yii\helpers\Html::submitButton($button['value'], ['class'=> 'btn btn-success']);
else if($button['type'] == 'cancel') else if($button['type'] == 'cancel')
$config['options'][] = \yii\helpers\Html::resetButton($button['value'], ['class'=> 'btn btn-default']); $config['options'][] = \yii\helpers\Html::resetButton($button['value'], ['class'=> 'btn btn-default']);
else if($button['type'] == 'danger') else if($button['type'] == 'danger')
......
...@@ -121,7 +121,7 @@ JS; ...@@ -121,7 +121,7 @@ JS;
if(!empty($element['options']['label'])) if(!empty($element['options']['label']))
$optEl['labelOptions'] = ['label' => $element['options']['label']]; $optEl['labelOptions'] = ['label' => $element['options']['label']];
if(!empty($element['empty'])) if(!empty($element['empty']))
$opt['value'] = $element['empty']; $opt['value'] = $element['empty'];
switch($element['type']) { switch($element['type']) {
case 'checkbox': case 'checkbox':
$opt['data-render'] = 'switchery'; $opt['data-render'] = 'switchery';
...@@ -186,6 +186,7 @@ JS; ...@@ -186,6 +186,7 @@ JS;
$config['options'][] = '<div style="clear: both;"></div>'; $config['options'][] = '<div style="clear: both;"></div>';
/* **************** */ /* **************** */
} }
unset($config['elements']); unset($config['elements']);
if($meta) { if($meta) {
//die(print_r($model->metaTag)); //die(print_r($model->metaTag));
......
...@@ -6,6 +6,7 @@ use common\components\BaseController; ...@@ -6,6 +6,7 @@ use common\components\BaseController;
use common\modules\school\models\Courses; use common\modules\school\models\Courses;
use common\modules\school\models\SearchCourses; use common\modules\school\models\SearchCourses;
use common\modules\school\models\SearchLessons; use common\modules\school\models\SearchLessons;
use common\modules\users\models\User;
class CourseController extends BaseController class CourseController extends BaseController
{ {
...@@ -23,7 +24,9 @@ class CourseController extends BaseController ...@@ -23,7 +24,9 @@ class CourseController extends BaseController
$search = \Yii::$app->request->queryParams; $search = \Yii::$app->request->queryParams;
$dataProvider = $searchModel->search($search); $dataProvider = $searchModel->search($search);
return $this->render('index', ['dataProvider' => $dataProvider]); $modelUser = new User();
$form = new \common\components\BaseForm('/common/modules/users/forms/RegistrationUserForm', $modelUser);
return $this->render('index', ['dataProvider' => $dataProvider, 'form' => $form->out]);
} }
public function actionView($id) public function actionView($id)
......
...@@ -26,7 +26,6 @@ class Courses extends \common\components\ActiveRecordModel ...@@ -26,7 +26,6 @@ class Courses extends \common\components\ActiveRecordModel
self::TYPE_DV => 'в разработке', self::TYPE_DV => 'в разработке',
]; ];
public static function tableName() public static function tableName()
{ {
return 'courses'; return 'courses';
......
...@@ -49,12 +49,9 @@ ...@@ -49,12 +49,9 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-4 col-xs-6 col-sm-12"> <div class="col-md-4 col-xs-6 col-sm-12">
<form class="sh_reg_form"> <?php
<input type="text" class="input_st field-input required alphanumeric" placeholder="Ваше имя*"> echo $form;
<input type="tel" class="input_st field-input required alphanumeric" placeholder="Телефон*"> ?>
<input type="email" class="input_st field-input required email" placeholder="E-mail*">
<button class="save-button sh_bt_send">Записаться</button>
</form>
<div class="usl">Проходя регистрацию вы подтверждаете<br><a href="#">согласие на обработку персональных данных.</a></div> <div class="usl">Проходя регистрацию вы подтверждаете<br><a href="#">согласие на обработку персональных данных.</a></div>
</div> </div>
<div class="col-md-8 col-xs-6 col-sm-12"> <div class="col-md-8 col-xs-6 col-sm-12">
......
...@@ -46,7 +46,7 @@ class UserController extends \common\components\BaseController { ...@@ -46,7 +46,7 @@ class UserController extends \common\components\BaseController {
} }
public function loadModel($id) { public function loadModel($id, $scopes = array(), $attribute = NULL) {
$model = User::model()->findByPk((int)$id); $model = User::model()->findByPk((int)$id);
if ($model === null) { if ($model === null) {
$this->pageNotFound(); $this->pageNotFound();
...@@ -104,14 +104,15 @@ class UserController extends \common\components\BaseController { ...@@ -104,14 +104,15 @@ class UserController extends \common\components\BaseController {
public function actionRegistration() { public function actionRegistration() {
$model = new User; die('');
$model = new User();
$model->scenario = User::SCENARIO_REGISTRATION; $model->scenario = User::SCENARIO_REGISTRATION;
$form = new BaseForm('users.RegistrationForm', $model); /* $form = new BaseForm('users.RegistrationForm', $model);
$this->performAjaxValidation($model); $this->performAjaxValidation($model);
unset($form->elements['captcha']); unset($form->elements['captcha']);
$is_created = false; $is_created = false;*/
if (isset($_POST['User'])) { if (isset($_POST['User'])) {
$model->attributes = $_POST['User']; $model->attributes = $_POST['User'];
......
<?php
use yii\helpers\Url;
use common\modules\users\models\User;
$elements = [
'name' => ['type' => 'text', 'placeholder'=>"Ваше имя*", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'email' => ['type' => 'text', 'placeholder'=>"E-mail*", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'password' => ['type' => 'password', 'placeholder'=>"Придумайте пароль*", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'password_c' => ['type' => 'password', 'placeholder'=>"Повторите пароль*", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'phone' => ['type' => 'text', 'placeholder'=>"Телефон", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'teltext' => '<div class="teltext-block">Для участие в проводимых конкурсах укажите Ваш реальный номер телефона,
что бы мы смогли вас оповестить о результатах</div>',
'occupation' => [
'type' => 'dropdownlist',
'items' => User::$occupation_list,
'placeholder'=>"Род занятий",
'options'=>['label'=>false],
'empty'=>'Чем вы занимаетесь',
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']
],
];
return [
'activeForm'=>[
'id' => 'sh_reg_form',
'options' => [
//'onsubmit'=>"ajaxSubmit(url: ".Url::toRoute(['/users/user/registration']).")";
'enctype' => 'multipart/form-data'
],
],
'elements' => $elements,
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Записаться', 'class'=>"save-button sh_bt_send"]
]
];
...@@ -16,7 +16,12 @@ use \common\modules\rbac\models\AuthAssignment; ...@@ -16,7 +16,12 @@ use \common\modules\rbac\models\AuthAssignment;
class User extends \common\components\ActiveRecordModel implements IdentityInterface class User extends \common\components\ActiveRecordModel implements IdentityInterface
{ {
const PAGE_SIZE = 10; const PAGE_SIZE = 10;
const OCCUPATION_CHIEF_IT = 1;
const OCCUPATION_MANAGER_IT = 2;
const OCCUPATION_CREATOR = 3;
const OCCUPATION_NOT_IT = 4;
const STATUS_ACTIVE = 'active'; const STATUS_ACTIVE = 'active';
const STATUS_NEW = 'new'; const STATUS_NEW = 'new';
const STATUS_BLOCKED = 'blocked'; const STATUS_BLOCKED = 'blocked';
...@@ -63,6 +68,14 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -63,6 +68,14 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public $tmp; //for external using. no delete! public $tmp; //for external using. no delete!
// public $post; // public $post;
public static $occupation_list = [
self::OCCUPATION_CHIEF_IT => 'Руководитель в IT сфере',
self::OCCUPATION_MANAGER_IT => 'Менеджер в IT сфере',
self::OCCUPATION_CREATOR => 'Разработчик',
self::OCCUPATION_NOT_IT => 'Не работаю в IT',
];
public function behaviors() public function behaviors()
{ {
return [ return [
...@@ -91,7 +104,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -91,7 +104,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
"send_email" => "Отправить уведомление на почту", "send_email" => "Отправить уведомление на почту",
"generate_new" => "Сгенерировать пароль автоматически", "generate_new" => "Сгенерировать пароль автоматически",
"post" => "Должность", "post" => "Должность",
"status" => "Активен / заблокирован" "status" => "Активен / заблокирован",
"occupation" => "Род занятий",
)); ));
return $attrs; return $attrs;
...@@ -136,7 +150,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -136,7 +150,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self::SCENARIO_CHANGE_PASSWORD, self::SCENARIO_CHANGE_PASSWORD,
self::SCENARIO_CREATE, self::SCENARIO_CREATE,
], 'message' => 'Пожалуйста, укажите пароль'], ], 'message' => 'Пожалуйста, укажите пароль'],
[['password'], 'string', 'min' => 4, 'on' => [ [['password'], 'string', 'min' => 7, 'on' => [
self::SCENARIO_REGISTRATION, self::SCENARIO_REGISTRATION,
self::SCENARIO_CHANGE_PASSWORD, self::SCENARIO_CHANGE_PASSWORD,
self::SCENARIO_UPDATE, self::SCENARIO_UPDATE,
...@@ -183,6 +197,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -183,6 +197,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self::SCENARIO_SEARCH, self::SCENARIO_SEARCH,
self::SCENARIO_CREATE, self::SCENARIO_CREATE,
]], ]],
[['occupation'], 'integer', 'max' => 11],
[['tmp','role','sort','fio','name', 'surname','email', 'mobile_phone'], 'safe'], [['tmp','role','sort','fio','name', 'surname','email', 'mobile_phone'], 'safe'],
]; ];
} }
......
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160204_213447_add_field_to_users_table extends Migration
{
public function safeUp()
{
$this->addColumn('users', 'occupation', Schema::TYPE_INTEGER . '(11)');
}
public function safeDown()
{
$this->dropColumn('users', 'occupation');
}
}
...@@ -22,6 +22,7 @@ return [ ...@@ -22,6 +22,7 @@ return [
'school' => ['class' => 'common\modules\school\Module',], 'school' => ['class' => 'common\modules\school\Module',],
'bids' => ['class' => 'common\modules\bids\Module'], 'bids' => ['class' => 'common\modules\bids\Module'],
'testings' => ['class' => 'common\modules\testings\Module',], 'testings' => ['class' => 'common\modules\testings\Module',],
'users' => ['class' => 'common\modules\users\users',],
'sitemap' => [ 'sitemap' => [
'class' => 'himiklab\sitemap\Sitemap', 'class' => 'himiklab\sitemap\Sitemap',
'models' => [ 'models' => [
......
...@@ -22,4 +22,5 @@ ...@@ -22,4 +22,5 @@
<?php $this->registerJsFile('/js/jquery.inputmask.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/jquery.inputmask.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/inputmask.phone.extensions.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/inputmask.phone.extensions.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/common.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/common.js', ['position' => yii\web\View::POS_END ]);?>
\ No newline at end of file <?php $this->registerJsFile('/js/jquery.form.js', ['position' => yii\web\View::POS_END ]);?>
\ No newline at end of file
...@@ -11458,4 +11458,10 @@ h6 { ...@@ -11458,4 +11458,10 @@ h6 {
} }
.row li{ .row li{
list-style: none; list-style: none;
}
.teltext-block{
margin-top: -40px;
margin-bottom: 15px;
color: #698387;
font-size: 14px;
} }
\ No newline at end of file
...@@ -580,4 +580,67 @@ jQuery(document).ready(function(){ ...@@ -580,4 +580,67 @@ jQuery(document).ready(function(){
$(this).parent().toggleClass("box_off_hide"); $(this).parent().toggleClass("box_off_hide");
}); });
}); });
\ No newline at end of file // prepare the form when the DOM is ready
$(document).ready(function() {
var options = {
//target: '#output2', // target element(s) to be updated with server response
beforeSubmit: showRequest, // pre-submit callback
success: showResponse, // post-submit callback
// other available options:
url: '/users/user/registration' // override for form's 'action' attribute
//type: type // 'get' or 'post', override for form's 'method' attribute
//dataType: null // 'xml', 'script', or 'json' (expected server response type)
//clearForm: true // clear all form fields after successful submit
//resetForm: true // reset the form after successful submit
// $.ajax options can be used here too, for example:
//timeout: 3000
};
// bind to the form's submit event
$('#sh_reg_form').submit(function() {
// inside event callbacks 'this' is the DOM element so we first
// wrap it in a jQuery object and then invoke ajaxSubmit
$(this).ajaxSubmit(options);
// !!! Important !!!
// always return false to prevent standard browser submit and page navigation
return false;
});
});
// pre-submit callback
function showRequest(formData, jqForm, options) {
// formData is an array; here we use $.param to convert it to a string to display it
// but the form plugin does this for you automatically when it submits the data
var queryString = $.param(formData);
// jqForm is a jQuery object encapsulating the form element. To access the
// DOM element for the form do this:
// var formElement = jqForm[0];
//alert('About to submit: \n\n' + queryString);
// here we could return false to prevent the form from being submitted;
// returning anything other than false will allow the form submit to continue
return true;
}
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
// for normal html responses, the first argument to the success callback
// is the XMLHttpRequest object's responseText property
// if the ajaxSubmit method was passed an Options Object with the dataType
// property set to 'xml' then the first argument to the success callback
// is the XMLHttpRequest object's responseXML property
// if the ajaxSubmit method was passed an Options Object with the dataType
// property set to 'json' then the first argument to the success callback
// is the json data object returned by the server
//alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
// '\n\nThe output div should have already been updated with the responseText.');
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment