Your IP : 216.73.216.79


Current Path : /var/www/html/dyna-project/views/user/
Upload File :
Current File : /var/www/html/dyna-project/views/user/profile.php.20210225

<?php

use yii\helpers\Html;
use app\models\Menu;
use yii\widgets\ActiveForm;
use app\models\ParamList;
use yii\grid\GridView;

$this->title = 'Account Settings';
$this->registerJs("");
$this->registerCss(".form-group label{font-size:1.2em;color:black;font-weight:300;}");
?>
<div class="kt-subheader   kt-grid__item" id="kt_subheader">
    <div class="kt-container ">
        <div class="kt-subheader__main">
            <h3 class="kt-subheader__title"><?= $this->title; ?></h3>
            <div class="kt-subheader__breadcrumbs">
                <span class="kt-subheader__breadcrumbs-separator"></span>
                <span class="kt-subheader__breadcrumbs-link"> Home </span>
                <span class="kt-subheader__breadcrumbs-separator"></span>
                <span class="kt-subheader__breadcrumbs-link"> <?= $this->title; ?></span>
            </div>
        </div>
    </div>
</div>
<?php $form = ActiveForm::begin(['options' => ['class' => 'kt-form kt-form--label-right']]); ?>
<div class="kt-container  kt-grid__item kt-grid__item--fluid">
    <div class="kt-portlet kt-portlet--mobile">
        <div class="kt-portlet__body kt-portlet__body--fit">
            <div class="kt-portlet__body">
                <div class="row">
                    <div class="col-3">
                        <div class="form-group mb-0">
                            <label>Name</label><br>
                            <label class="kt-font-bold"><?= $model->name; ?></label>
                        </div>
                    </div>
                    <div class="col-3">
                        <div class="form-group mb-0">
                            <label>User Role</label><br>
                            <label class="kt-font-bold">
                                <?php
                                $ParamList = new ParamList();
                                echo $ParamList->getlabel(2, Yii::$app->user->identity->role);
                                ?>
                            </label>
                        </div>
                    </div>
                    <div class="col-3">
                        <div class="form-group mb-0">
                            <label>Email Address</label><br>
                            <label class="kt-font-bold"><?= $model->email; ?></label>
                        </div>
                    </div>
                    <div class="col-3">
                        <div class="form-group mb-0">
                            <label>Mobile Number</label><br>
                            <label class="kt-font-bold">+601<?= $model->phone; ?></label>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="kt-portlet kt-portlet--mobile">
        <div class="kt-portlet__body kt-portlet__body--fit">
            <div class="kt-portlet__head">
                <div class="kt-portlet__head-label">
                    <h3 class="kt-portlet__head-title">
                        Change Password
                    </h3>
                </div>
            </div>
            <div class="kt-portlet__body">
                <p class="kt-font-brand"><i class="fas fa-info-circle"></i>&nbsp;&nbsp;Password must at least 6 character with combination alphanumberic</p>
                <form>
                    <div class="row">
                        <div class="col-sm-4"><input type="password" id="new_pwd" class="form-control mb-3" placeholder="Enter your new password here" autocomplete="off"></div>
                        <div class="col-sm-4"><input type="password" id="new_pwd2" class="form-control mb-3" placeholder="Retype your new password here" autocomplete="off"></div>
                        <div class="col-sm-4"><button type="button" class="btn btn-primary" onclick="savepwd()">Change Password</button></div>
                    </div>
                    <p class="font-weight-bold kt-font-danger" id="msg"></p>
                </form>
            </div>
        </div>
    </div>
</div>
<?php ActiveForm::end(); ?>
<script>
    function savepwd() {
        var new_pwd = $('#new_pwd').val();
        var new_pwd2 = $('#new_pwd2').val();
        var Exp = /^(?=.*\d)(?=.*[A-Za-z]).{6,20}$/;
        var msg = "";

        if (new_pwd === '' || new_pwd2 === '')
            msg = "Please complete the form";
        else if (new_pwd !== new_pwd2)
            msg = "New and retype password does not match";
        else if (new_pwd.length < 6)
            msg = "New password must at least 6 character";
        else if (new_pwd.match(Exp) === null)
            msg = "New password must have combination alphanumeric";

        if (msg !== '')
            $('#msg').html(msg);
        else {
            $.ajax({
                url: "index.php?r=user/changepwd",
                method: "POST",
                data: {"new_pwd": new_pwd},
                success: function (response) {
                    if (response === 'failed')
                        $('#msg').html('Password failed to update. Please try again');
                    else {
                        swal.fire({
                            position: 'center-center',
                            type: 'success',
                            title: 'Password successfully change',
                            showConfirmButton: false,
                            timer: 1500,
                        }).then(function (result) {
                            location.reload();
                        });
                    }
                },
            });
        }
    }
</script>