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

<?php

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

$ParamList = new ParamList();
$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']]); ?>
<?php $form->errorSummary($model); ?>
<div class="user-form">
    <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__head">
                    <div class="kt-portlet__head-label">
                        <h3 class="kt-portlet__head-title">
                            Update Profile
                        </h3>
                    </div>
                </div>
                <div class="kt-portlet__body">
                    <?php
                    $img_url = 'images/no-image.png';
                    if (!empty($model->img_url))
                        $img_url = $model->img_url;
                    echo '<div class="mb-3 text-center">
                                <img src="' . $img_url . '" style="height:100px;border:1px solid #ccc;margin-bottom:2em;">
                                ' . $form->field($model, 'file')->fileInput()->label(false) . '
                            </div>';
                    ?>
                    <div class="row">
                        <div class="col-4">
                            <?=
                            $form->field($model, 'name', ['template' =>
                                "{label}<span class='required'>*</span>{input}
                                    <span class='kt-font-danger font-weight-bold'>{error}</span>"])->textInput(['maxlength' => true]);
                            ?>
                        </div>
                        <div class="col-4">
                            <?=
                            $form->field($model, 'phone', ['template' =>
                                "{label}
                                     <div class='input-group'>
                                        <div class='input-group-prepend'><span class='input-group-text'>+601</span></div>
                                        {input}
                                     </div>
                                     <span class='kt-font-danger font-weight-bold'>{error}</span>"])->textInput(['maxlength' => true]);
                            ?>
                        </div>
                        <div class="col-4">
                            <?= $form->field($model, 'email', ['template' => "{label}<span class='required'>*</span>{input}<span class='kt-font-danger font-weight-bold'>{error}</span>"])->textInput(['maxlength' => true, 'disabled' => 'true']); ?>
                        </div>
                        <div class="col-4">
                            <?=
                                    $form->field($model, 'dept', ['template' =>
                                        "{label}<span class='required'>*</span>{input}
                                            <span class='kt-font-danger font-weight-bold'>{error}</span>"])
                                    ->dropDownList($ParamList->getparamlist2(34), ['class' => 'form-control kt-selectpicker', 'disabled' => 'false']);
                            ?>
                        </div>
                        <div class="col-4">
                            <?=
                                    $form->field($model, 'role', ['template' =>
                                        "{label}<span class='required'>*</span>{input}
                                            <span class='kt-font-danger font-weight-bold'>{error}</span>"])
                                    ->dropDownList($ParamList->getparamlist2(2), ['class' => 'form-control kt-selectpicker', 'disabled' => 'false']);
                            ?>
                        </div>
                        <div class="col-4"><?= Html::submitButton('Update Profile', ['class' => 'btn btn-info','style'=>'margin-top:2em;']) ?></div>
                    </div>


                </div>
            </div>
        </div>
    </div>
</div>
<?php ActiveForm::end(); ?>






<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__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-info" onclick="savepwd()">Change Password</button></div>
                    </div>
                    <p class="font-weight-bold kt-font-danger" id="msg"></p>
                </form>
            </div>
        </div>
    </div>
</div>

<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>