Commit 30e3d2440a959b8afc5f9cc59bc56d2e6d2286c6
1 parent
8195fc24
Forms
Showing
12 changed files
with
434 additions
and
131 deletions
Show diff stats
composer.json
| @@ -17,7 +17,8 @@ | @@ -17,7 +17,8 @@ | ||
| 17 | "php": ">=5.4.0", | 17 | "php": ">=5.4.0", |
| 18 | "yiisoft/yii2": "~2.0.6", | 18 | "yiisoft/yii2": "~2.0.6", |
| 19 | "yiisoft/yii2-bootstrap": "~2.0.0", | 19 | "yiisoft/yii2-bootstrap": "~2.0.0", |
| 20 | - "yiisoft/yii2-swiftmailer": "~2.0.0" | 20 | + "yiisoft/yii2-swiftmailer": "~2.0.0", |
| 21 | + "bower-asset/remarkable-bootstrap-notify": "*" | ||
| 21 | }, | 22 | }, |
| 22 | "require-dev": { | 23 | "require-dev": { |
| 23 | "yiisoft/yii2-debug": "~2.0.0", | 24 | "yiisoft/yii2-debug": "~2.0.0", |
frontend/assets/AppAsset.php
| @@ -22,5 +22,6 @@ class AppAsset extends AssetBundle | @@ -22,5 +22,6 @@ class AppAsset extends AssetBundle | ||
| 22 | 'yii\web\JqueryAsset', | 22 | 'yii\web\JqueryAsset', |
| 23 | 'yii\web\YiiAsset', | 23 | 'yii\web\YiiAsset', |
| 24 | 'yii\bootstrap\BootstrapAsset', | 24 | 'yii\bootstrap\BootstrapAsset', |
| 25 | + 'yii\bootstrap\BootstrapPluginAsset', | ||
| 25 | ]; | 26 | ]; |
| 26 | } | 27 | } |
frontend/assets/CabinetAsset.php
| @@ -23,5 +23,6 @@ class CabinetAsset extends AssetBundle | @@ -23,5 +23,6 @@ class CabinetAsset extends AssetBundle | ||
| 23 | 'yii\web\YiiAsset', | 23 | 'yii\web\YiiAsset', |
| 24 | 'yii\bootstrap\BootstrapAsset', | 24 | 'yii\bootstrap\BootstrapAsset', |
| 25 | 'frontend\assets\AppAsset', | 25 | 'frontend\assets\AppAsset', |
| 26 | + 'frontend\assets\NotifyAsset', | ||
| 26 | ]; | 27 | ]; |
| 27 | } | 28 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\assets; | ||
| 4 | + | ||
| 5 | +use yii\web\AssetBundle; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Notify asset bundle. | ||
| 9 | + */ | ||
| 10 | +class NotifyAsset extends AssetBundle | ||
| 11 | +{ | ||
| 12 | + public $sourcePath = '@bower/remarkable-bootstrap-notify/dist'; | ||
| 13 | + public $js = [ | ||
| 14 | + 'bootstrap-notify.js', | ||
| 15 | + ]; | ||
| 16 | + public $depends = [ | ||
| 17 | + 'yii\web\JqueryAsset', | ||
| 18 | + 'yii\bootstrap\BootstrapAsset', | ||
| 19 | + ]; | ||
| 20 | +} |
frontend/controllers/CabinetController.php
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | use common\models\User; | 4 | use common\models\User; |
| 5 | use frontend\models\UserData; | 5 | use frontend\models\UserData; |
| 6 | use frontend\models\UserPassport; | 6 | use frontend\models\UserPassport; |
| 7 | + use yii\filters\VerbFilter; | ||
| 7 | use yii\web\Controller; | 8 | use yii\web\Controller; |
| 8 | 9 | ||
| 9 | /** | 10 | /** |
| @@ -17,6 +18,12 @@ | @@ -17,6 +18,12 @@ | ||
| 17 | public function behaviors() | 18 | public function behaviors() |
| 18 | { | 19 | { |
| 19 | return [ | 20 | return [ |
| 21 | + 'verbs' => [ | ||
| 22 | + 'class' => VerbFilter::className(), | ||
| 23 | + 'actions' => [ | ||
| 24 | + 'personal' => ['post'], | ||
| 25 | + ], | ||
| 26 | + ], | ||
| 20 | ]; | 27 | ]; |
| 21 | } | 28 | } |
| 22 | 29 | ||
| @@ -44,4 +51,55 @@ | @@ -44,4 +51,55 @@ | ||
| 44 | ]); | 51 | ]); |
| 45 | } | 52 | } |
| 46 | 53 | ||
| 54 | + public function actionPersonal() | ||
| 55 | + { | ||
| 56 | + $request = \Yii::$app->request; | ||
| 57 | + $response = \Yii::$app->response; | ||
| 58 | + $response->format = $response::FORMAT_JSON; | ||
| 59 | + /** | ||
| 60 | + * @var User $user | ||
| 61 | + */ | ||
| 62 | + $user = \Yii::$app->user->identity; | ||
| 63 | + if(!$userData = $user->userData) { | ||
| 64 | + $userData = new UserData(); | ||
| 65 | + $userData->user_id = $user->id; | ||
| 66 | + } | ||
| 67 | + if($userData->load($request->post()) && $userData->save()) { | ||
| 68 | + return [ | ||
| 69 | + 'success' => true, | ||
| 70 | + 'message' => 'Данные успешно сохранены', | ||
| 71 | + ]; | ||
| 72 | + } else { | ||
| 73 | + return [ | ||
| 74 | + 'error' => true, | ||
| 75 | + 'message' => 'Ошибка сохранения данных', | ||
| 76 | + ]; | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public function actionPassport() | ||
| 81 | + { | ||
| 82 | + $request = \Yii::$app->request; | ||
| 83 | + $response = \Yii::$app->response; | ||
| 84 | + $response->format = $response::FORMAT_JSON; | ||
| 85 | + /** | ||
| 86 | + * @var User $user | ||
| 87 | + */ | ||
| 88 | + $user = \Yii::$app->user->identity; | ||
| 89 | + if(!$userPassport = $user->userPassport) { | ||
| 90 | + $userPassport = new UserPassport(); | ||
| 91 | + $userPassport->user_id = $user->id; | ||
| 92 | + } | ||
| 93 | + if($userPassport->load($request->post()) && $userPassport->save()) { | ||
| 94 | + return [ | ||
| 95 | + 'success' => true, | ||
| 96 | + 'message' => 'Данные успешно сохранены', | ||
| 97 | + ]; | ||
| 98 | + } else { | ||
| 99 | + return [ | ||
| 100 | + 'error' => true, | ||
| 101 | + 'message' => 'Ошибка сохранения данных', | ||
| 102 | + ]; | ||
| 103 | + } | ||
| 104 | + } | ||
| 47 | } | 105 | } |
frontend/models/UserData.php
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | -namespace frontend\models; | ||
| 4 | - | ||
| 5 | -use common\models\User; | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * This is the model class for table "user_data". | ||
| 9 | - * | ||
| 10 | - * @property integer $id | ||
| 11 | - * @property integer $user_id | ||
| 12 | - * @property string $name | ||
| 13 | - * @property string $surname | ||
| 14 | - * @property string $patronymic | ||
| 15 | - * @property string $phone | ||
| 16 | - * @property string $email | ||
| 17 | - * @property string $inn | ||
| 18 | - * | ||
| 19 | - * @property User $user | ||
| 20 | - */ | ||
| 21 | -class UserData extends \yii\db\ActiveRecord | ||
| 22 | -{ | 2 | + |
| 3 | + namespace frontend\models; | ||
| 4 | + | ||
| 5 | + use common\models\User; | ||
| 6 | + | ||
| 23 | /** | 7 | /** |
| 24 | - * @inheritdoc | 8 | + * This is the model class for table "user_data". |
| 9 | + * | ||
| 10 | + * @property integer $id | ||
| 11 | + * @property integer $user_id | ||
| 12 | + * @property string $name | ||
| 13 | + * @property string $surname | ||
| 14 | + * @property string $patronymic | ||
| 15 | + * @property string $phone | ||
| 16 | + * @property string $email | ||
| 17 | + * @property string $inn | ||
| 18 | + * @property User $user | ||
| 25 | */ | 19 | */ |
| 26 | - public static function tableName() | 20 | + class UserData extends \yii\db\ActiveRecord |
| 27 | { | 21 | { |
| 28 | - return 'user_data'; | 22 | + /** |
| 23 | + * @inheritdoc | ||
| 24 | + */ | ||
| 25 | + public static function tableName() | ||
| 26 | + { | ||
| 27 | + return 'user_data'; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * @inheritdoc | ||
| 32 | + */ | ||
| 33 | + public function rules() | ||
| 34 | + { | ||
| 35 | + return [ | ||
| 36 | + [ | ||
| 37 | + [ 'user_id' ], | ||
| 38 | + 'integer', | ||
| 39 | + ], | ||
| 40 | + [ | ||
| 41 | + [ | ||
| 42 | + 'name', | ||
| 43 | + 'surname', | ||
| 44 | + 'patronymic', | ||
| 45 | + 'phone', | ||
| 46 | + 'email', | ||
| 47 | + 'inn', | ||
| 48 | + ], | ||
| 49 | + 'string', | ||
| 50 | + 'max' => 255, | ||
| 51 | + ], | ||
| 52 | + [ | ||
| 53 | + [ 'user_id' ], | ||
| 54 | + 'exist', | ||
| 55 | + 'skipOnError' => true, | ||
| 56 | + 'targetClass' => User::className(), | ||
| 57 | + 'targetAttribute' => [ 'user_id' => 'id' ], | ||
| 58 | + ], | ||
| 59 | + [ | ||
| 60 | + [ 'phone' ], | ||
| 61 | + 'match', | ||
| 62 | + 'pattern' => '/\+38\s\(\d{3}\)\s\d{3}-\d{2}-\d{2}/', | ||
| 63 | + ], | ||
| 64 | + [ | ||
| 65 | + ['email'], | ||
| 66 | + 'email', | ||
| 67 | + ] | ||
| 68 | + ]; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * @inheritdoc | ||
| 73 | + */ | ||
| 74 | + public function attributeLabels() | ||
| 75 | + { | ||
| 76 | + return [ | ||
| 77 | + 'id' => 'ID', | ||
| 78 | + 'user_id' => 'User ID', | ||
| 79 | + 'name' => 'Ім\'я', | ||
| 80 | + 'surname' => 'Прізвище', | ||
| 81 | + 'patronymic' => 'По батькові', | ||
| 82 | + 'phone' => 'Телефон', | ||
| 83 | + 'email' => 'Email', | ||
| 84 | + 'inn' => 'ІНН', | ||
| 85 | + ]; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * @return \yii\db\ActiveQuery | ||
| 90 | + */ | ||
| 91 | + public function getUser() | ||
| 92 | + { | ||
| 93 | + return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); | ||
| 94 | + } | ||
| 29 | } | 95 | } |
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * @inheritdoc | ||
| 33 | - */ | ||
| 34 | - public function rules() | ||
| 35 | - { | ||
| 36 | - return [ | ||
| 37 | - [['user_id'], 'integer'], | ||
| 38 | - [['name', 'surname', 'patronymic', 'phone', 'email', 'inn'], 'string', 'max' => 255], | ||
| 39 | - [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']], | ||
| 40 | - ]; | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - /** | ||
| 44 | - * @inheritdoc | ||
| 45 | - */ | ||
| 46 | - public function attributeLabels() | ||
| 47 | - { | ||
| 48 | - return [ | ||
| 49 | - 'id' => 'ID', | ||
| 50 | - 'user_id' => 'User ID', | ||
| 51 | - 'name' => 'Name', | ||
| 52 | - 'surname' => 'Surname', | ||
| 53 | - 'patronymic' => 'Patronymic', | ||
| 54 | - 'phone' => 'Phone', | ||
| 55 | - 'email' => 'Email', | ||
| 56 | - 'inn' => 'Inn', | ||
| 57 | - ]; | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - /** | ||
| 61 | - * @return \yii\db\ActiveQuery | ||
| 62 | - */ | ||
| 63 | - public function getUser() | ||
| 64 | - { | ||
| 65 | - return $this->hasOne(User::className(), ['id' => 'user_id']); | ||
| 66 | - } | ||
| 67 | -} |
frontend/models/UserPassport.php
| @@ -47,10 +47,10 @@ class UserPassport extends \yii\db\ActiveRecord | @@ -47,10 +47,10 @@ class UserPassport extends \yii\db\ActiveRecord | ||
| 47 | return [ | 47 | return [ |
| 48 | 'id' => 'ID', | 48 | 'id' => 'ID', |
| 49 | 'user_id' => 'User ID', | 49 | 'user_id' => 'User ID', |
| 50 | - 'series' => 'Series', | ||
| 51 | - 'number' => 'Number', | ||
| 52 | - 'birthday' => 'Birthday', | ||
| 53 | - 'given_by' => 'Given By', | 50 | + 'series' => 'Серія', |
| 51 | + 'number' => '№', | ||
| 52 | + 'birthday' => 'Дата народження', | ||
| 53 | + 'given_by' => 'Ким виданий', | ||
| 54 | ]; | 54 | ]; |
| 55 | } | 55 | } |
| 56 | 56 |
| 1 | +<?php | ||
| 2 | + use frontend\models\UserPassport; | ||
| 3 | + use yii\helpers\Html; | ||
| 4 | + use yii\widgets\ActiveForm; | ||
| 5 | + use yii\widgets\Pjax; | ||
| 6 | + | ||
| 7 | + /** | ||
| 8 | + * @var UserPassport $userPassport | ||
| 9 | + * @var yii\web\View $this | ||
| 10 | + */ | ||
| 11 | + | ||
| 12 | + Pjax::begin( | ||
| 13 | + [ | ||
| 14 | + 'options' => [ | ||
| 15 | + 'class' => 'pjax_container forms-cabinet forms-2', | ||
| 16 | + ], | ||
| 17 | + ] | ||
| 18 | + ); | ||
| 19 | +?> | ||
| 20 | + <div class="title_forms">паспортні данні</div> | ||
| 21 | +<?php | ||
| 22 | + $form = ActiveForm::begin( | ||
| 23 | + [ | ||
| 24 | + 'id' => 'passport-form', | ||
| 25 | + 'action' => [ 'cabinet/passport' ], | ||
| 26 | + ] | ||
| 27 | + ); | ||
| 28 | + echo $form->field( | ||
| 29 | + $userPassport, | ||
| 30 | + 'series', | ||
| 31 | + [ | ||
| 32 | + 'options' => [ | ||
| 33 | + 'class' => 'input-wrapp-80', | ||
| 34 | + ], | ||
| 35 | + ] | ||
| 36 | + ) | ||
| 37 | + ->textInput(); | ||
| 38 | + echo $form->field( | ||
| 39 | + $userPassport, | ||
| 40 | + 'number', | ||
| 41 | + [ | ||
| 42 | + 'options' => [ | ||
| 43 | + 'class' => 'input-wrapp-220', | ||
| 44 | + ], | ||
| 45 | + ] | ||
| 46 | + ) | ||
| 47 | + ->textInput(); | ||
| 48 | + echo $form->field( | ||
| 49 | + $userPassport, | ||
| 50 | + 'birthday', | ||
| 51 | + [ | ||
| 52 | + 'options' => [ | ||
| 53 | + 'class' => 'input-wrapp-130', | ||
| 54 | + ], | ||
| 55 | + 'inputOptions' => [ | ||
| 56 | + 'class' => '_datepicer', | ||
| 57 | + ], | ||
| 58 | + ] | ||
| 59 | + ) | ||
| 60 | + ->textInput(); | ||
| 61 | + echo $form->field( | ||
| 62 | + $userPassport, | ||
| 63 | + 'given_by', | ||
| 64 | + [ | ||
| 65 | + 'options' => [ | ||
| 66 | + 'class' => 'input-wrapp-445', | ||
| 67 | + ], | ||
| 68 | + ] | ||
| 69 | + ) | ||
| 70 | + ->textarea(); | ||
| 71 | +?> | ||
| 72 | + <div class="input-wrapp btn-submit-blue"> | ||
| 73 | + <?php | ||
| 74 | + echo Html::submitButton('зберегти'); | ||
| 75 | + ?> | ||
| 76 | + </div> | ||
| 77 | +<?php | ||
| 78 | + $form::end(); | ||
| 79 | + Pjax::end(); | ||
| 80 | +?> | ||
| 0 | \ No newline at end of file | 81 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | + use frontend\models\UserData; | ||
| 3 | + use yii\helpers\Html; | ||
| 4 | + use yii\widgets\ActiveForm; | ||
| 5 | + use yii\widgets\MaskedInput; | ||
| 6 | + use yii\widgets\Pjax; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var UserData $userData | ||
| 10 | + * @var yii\web\View $this | ||
| 11 | + */ | ||
| 12 | + Pjax::begin( | ||
| 13 | + [ | ||
| 14 | + 'options' => [ | ||
| 15 | + 'class' => 'pjax_container forms-cabinet forms-1', | ||
| 16 | + ], | ||
| 17 | + ] | ||
| 18 | + ); | ||
| 19 | +?> | ||
| 20 | + <div class="title_forms">особисті данні</div> | ||
| 21 | + <?php | ||
| 22 | + $form = ActiveForm::begin( | ||
| 23 | + [ | ||
| 24 | + 'id' => 'personal-form', | ||
| 25 | + 'action' => [ 'cabinet/personal' ], | ||
| 26 | + ] | ||
| 27 | + ); | ||
| 28 | + echo $form->field( | ||
| 29 | + $userData, | ||
| 30 | + 'surname', | ||
| 31 | + [ | ||
| 32 | + 'options' => [ | ||
| 33 | + 'class' => 'input-wrapp-320', | ||
| 34 | + ], | ||
| 35 | + ] | ||
| 36 | + ) | ||
| 37 | + ->textInput(); | ||
| 38 | + echo $form->field( | ||
| 39 | + $userData, | ||
| 40 | + 'name', | ||
| 41 | + [ | ||
| 42 | + 'options' => [ | ||
| 43 | + 'class' => 'input-wrapp-320', | ||
| 44 | + ], | ||
| 45 | + ] | ||
| 46 | + ) | ||
| 47 | + ->textInput(); | ||
| 48 | + echo $form->field( | ||
| 49 | + $userData, | ||
| 50 | + 'patronymic', | ||
| 51 | + [ | ||
| 52 | + 'options' => [ | ||
| 53 | + 'class' => 'input-wrapp-320', | ||
| 54 | + ], | ||
| 55 | + ] | ||
| 56 | + ) | ||
| 57 | + ->textInput(); | ||
| 58 | + echo $form->field( | ||
| 59 | + $userData, | ||
| 60 | + 'phone', | ||
| 61 | + [ | ||
| 62 | + 'options' => [ | ||
| 63 | + 'class' => 'input-wrapp-320', | ||
| 64 | + ], | ||
| 65 | + ] | ||
| 66 | + ) | ||
| 67 | + ->widget( | ||
| 68 | + MaskedInput::className(), | ||
| 69 | + [ | ||
| 70 | + 'mask' => '+38 (099) 999-99-99', | ||
| 71 | + 'options' => [ | ||
| 72 | + 'placeholder' => '+38 (0XX) XXX-XX-XX', | ||
| 73 | + ], | ||
| 74 | + ] | ||
| 75 | + ); | ||
| 76 | + echo $form->field( | ||
| 77 | + $userData, | ||
| 78 | + 'email', | ||
| 79 | + [ | ||
| 80 | + 'options' => [ | ||
| 81 | + 'class' => 'input-wrapp-320', | ||
| 82 | + ], | ||
| 83 | + ] | ||
| 84 | + ) | ||
| 85 | + ->textInput(); | ||
| 86 | + echo $form->field( | ||
| 87 | + $userData, | ||
| 88 | + 'inn', | ||
| 89 | + [ | ||
| 90 | + 'options' => [ | ||
| 91 | + 'class' => 'input-wrapp-320', | ||
| 92 | + ], | ||
| 93 | + ] | ||
| 94 | + ) | ||
| 95 | + ->textInput(); | ||
| 96 | + ?> | ||
| 97 | + <div class="input-wrapp btn-submit-blue"> | ||
| 98 | + <?php | ||
| 99 | + echo Html::submitButton('Зберегти'); | ||
| 100 | + ?> | ||
| 101 | + </div> | ||
| 102 | + <?php | ||
| 103 | + $form::end(); | ||
| 104 | + ?> | ||
| 105 | +<?php | ||
| 106 | + Pjax::end(); | ||
| 107 | +?> | ||
| 0 | \ No newline at end of file | 108 | \ No newline at end of file |
frontend/views/cabinet/index.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | - /* @var $this yii\web\View */ | 3 | + /** |
| 4 | + * @var UserData $userData | ||
| 5 | + * @var UserPassport $userPassport | ||
| 6 | + * @var yii\web\View $this | ||
| 7 | + */ | ||
| 4 | 8 | ||
| 5 | use frontend\assets\CabinetAsset; | 9 | use frontend\assets\CabinetAsset; |
| 10 | + use frontend\models\UserData; | ||
| 11 | + use frontend\models\UserPassport; | ||
| 6 | use yii\helpers\Html; | 12 | use yii\helpers\Html; |
| 7 | 13 | ||
| 8 | CabinetAsset::register($this); | 14 | CabinetAsset::register($this); |
| @@ -14,11 +20,11 @@ | @@ -14,11 +20,11 @@ | ||
| 14 | Html::img( | 20 | Html::img( |
| 15 | '/images/cabinet/logo.png', | 21 | '/images/cabinet/logo.png', |
| 16 | [ | 22 | [ |
| 17 | - 'width' => 129, | 23 | + 'width' => 129, |
| 18 | 'height' => 52, | 24 | 'height' => 52, |
| 19 | ] | 25 | ] |
| 20 | ), | 26 | ), |
| 21 | - ['cabinet/index'], | 27 | + [ 'cabinet/index' ], |
| 22 | [ | 28 | [ |
| 23 | 'class' => 'logo-cab', | 29 | 'class' => 'logo-cab', |
| 24 | ] | 30 | ] |
| @@ -180,65 +186,20 @@ EOT; | @@ -180,65 +186,20 @@ EOT; | ||
| 180 | 186 | ||
| 181 | <div class="content-forms"> | 187 | <div class="content-forms"> |
| 182 | <div class="style cab_content_list active-cab"> | 188 | <div class="style cab_content_list active-cab"> |
| 183 | - <div class="forms-cabinet forms-1"> | ||
| 184 | - <div class="title_forms">особисті данні</div> | ||
| 185 | - <form action=""> | ||
| 186 | - <div class="input-wrapp-320"> | ||
| 187 | - <label for="input-1">Прізвище</label> | ||
| 188 | - <input id="input-1" type="text"> | ||
| 189 | - </div> | ||
| 190 | - <div class="input-wrapp-320"> | ||
| 191 | - <label for="input-2">Ім'я</label> | ||
| 192 | - <input id="input-2" type="text"> | ||
| 193 | - </div> | ||
| 194 | - <div class="input-wrapp-320"> | ||
| 195 | - <label for="input-3">По батькові</label> | ||
| 196 | - <input id="input-3" type="text"> | ||
| 197 | - </div> | ||
| 198 | - <div class="input-wrapp-320 phone-input"> | ||
| 199 | - <label for="input-5">Телефон</label> | ||
| 200 | - <input id="input-5" type="text" placeholder="+38 (0XX) XXX-XX-XX" data-plugin-inputmask="inputmask_ce696fc8"> | ||
| 201 | - </div> | ||
| 202 | - <div class="input-wrapp-320"> | ||
| 203 | - <label for="input-6">Email</label> | ||
| 204 | - <input id="input-6" type="text"> | ||
| 205 | - </div> | ||
| 206 | - <div class="input-wrapp-320"> | ||
| 207 | - <label for="input-7">ІНН</label> | ||
| 208 | - <input id="input-7" type="text"> | ||
| 209 | - </div> | ||
| 210 | - <div class="input-wrapp btn-submit-blue"> | ||
| 211 | - <button type="submit">зберегти</button> | ||
| 212 | - </div> | ||
| 213 | - </form> | ||
| 214 | - </div> | ||
| 215 | - | ||
| 216 | - <div class="forms-cabinet forms-2"> | ||
| 217 | - <div class="title_forms">паспортні данні</div> | ||
| 218 | - <form action=""> | ||
| 219 | - <div class="input-wrapp-80"> | ||
| 220 | - <label for="input-8">Серія</label> | ||
| 221 | - <input id="input-8" type="text"> | ||
| 222 | - </div> | ||
| 223 | - <div class="input-wrapp-220"> | ||
| 224 | - <label for="input-9">№</label> | ||
| 225 | - <input id="input-9" type="text"> | ||
| 226 | - </div> | ||
| 227 | - <div class="input-wrapp-130"> | ||
| 228 | - <label for="input-10">Дата народження</label> | ||
| 229 | - <input class="_datepicer" id="input-10" type="text"> | ||
| 230 | - </div> | ||
| 231 | - <div class="input-wrapp-445"> | ||
| 232 | - <label for="area-1">Виданий</label> | ||
| 233 | - <textarea name="" id="area-1"></textarea> | ||
| 234 | - </div> | ||
| 235 | - <div class="input-wrapp btn-submit-blue"> | ||
| 236 | - <button type="submit">зберегти</button> | ||
| 237 | - </div> | ||
| 238 | - </form> | ||
| 239 | - | ||
| 240 | - </div> | ||
| 241 | - | 189 | + <?php |
| 190 | + echo $this->render( | ||
| 191 | + '_personal_form', | ||
| 192 | + [ | ||
| 193 | + 'userData' => $userData, | ||
| 194 | + ] | ||
| 195 | + ); | ||
| 196 | + echo $this->render( | ||
| 197 | + '_passport_form', | ||
| 198 | + [ | ||
| 199 | + 'userPassport' => $userPassport, | ||
| 200 | + ] | ||
| 201 | + ); | ||
| 202 | + ?> | ||
| 242 | 203 | ||
| 243 | <div class="style table-forms tables-1"> | 204 | <div class="style table-forms tables-1"> |
| 244 | <div class="title_forms">Список творів</div> | 205 | <div class="title_forms">Список творів</div> |
frontend/web/css/style.css
| @@ -2017,6 +2017,16 @@ ul.btns-box3 li a img {width: 110px;height:110px;} | @@ -2017,6 +2017,16 @@ ul.btns-box3 li a img {width: 110px;height:110px;} | ||
| 2017 | padding-left: 10px; | 2017 | padding-left: 10px; |
| 2018 | width: 20%; | 2018 | width: 20%; |
| 2019 | } | 2019 | } |
| 2020 | - | ||
| 2021 | - | 2020 | +.pjax_container { |
| 2021 | + position: relative; | ||
| 2022 | +} | ||
| 2023 | +.preloader { | ||
| 2024 | + position: absolute; | ||
| 2025 | + top:0; | ||
| 2026 | + left:0; | ||
| 2027 | + bottom:0; | ||
| 2028 | + right:0; | ||
| 2029 | + background: rgba(255, 255, 255, 0.8) url("/images/cabinet/preload_min.gif") 50% 50% no-repeat; | ||
| 2030 | + z-index: 100; | ||
| 2031 | +} | ||
| 2022 | 2032 |
frontend/web/js/script.js
| @@ -185,6 +185,42 @@ $(document).ready(function(){ | @@ -185,6 +185,42 @@ $(document).ready(function(){ | ||
| 185 | } | 185 | } |
| 186 | }) | 186 | }) |
| 187 | } | 187 | } |
| 188 | + | ||
| 189 | + $(document).on('beforeSubmit', '#personal-form', function(e) { | ||
| 190 | + postForm(this); | ||
| 191 | + return false; | ||
| 192 | + }); | ||
| 193 | + | ||
| 194 | + $(document).on('beforeSubmit', '#passport-form', function(e) { | ||
| 195 | + postForm(this); | ||
| 196 | + return false; | ||
| 197 | + }); | ||
| 198 | + | ||
| 199 | + function postForm(context) { | ||
| 200 | + $.post($(context).attr('action'), $(context).serialize(), function(data) { | ||
| 201 | + var type; | ||
| 202 | + if(data.error) { | ||
| 203 | + type = 'danger'; | ||
| 204 | + } else { | ||
| 205 | + type = 'success'; | ||
| 206 | + } | ||
| 207 | + showStatus(data.message, type); | ||
| 208 | + reload($(context).parents('.pjax_container').attr('id')); | ||
| 209 | + }.bind(this)); | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + function showStatus(txt, type) { | ||
| 213 | + $.notify({ | ||
| 214 | + message: txt | ||
| 215 | + }, { | ||
| 216 | + type: type | ||
| 217 | + }); | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + function reload(id) { | ||
| 221 | + $('#'+id).prepend('<div class="preloader"></div>'); | ||
| 222 | + $.pjax.reload('#'+id); | ||
| 223 | + } | ||
| 188 | }); | 224 | }); |
| 189 | 225 | ||
| 190 | 226 |