File: /var/www/html/hrms-production/resources/views/admin/edit-user-password.blade.php
@extends('admin.include.master')
<style>
.error{
color: red;
font-size: 11px;
}
</style>
@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-12">
<h2>User Password Change</h2>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<!-- Main content -->
<section class="content">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card card-default">
<div class="card-body">
<form class="form-horizontal" id="frmUserPasswordChange" method="post" action="" >
<input type="hidden" name="_token" id="token" value="{{ csrf_token() }}">
<input type="hidden" name="UserId" id="UserId" value="{{ Session::get('UserId') }}">
<div class="row">
<div class="col-md-12">
<div class="form-group row">
<label for="EmployeeCode"
class="col-sm-4 col-form-label text-right">Email:</label>
<div class="col-sm-8">
<input type="text" class="form-control form-control-sm"
name="Email" id="Email" readonly="readonly" value="{{ Session::get('UserEmail') }}">
</div>
</div>
<div class="form-group row">
<label for="EmployeeCode"
class="col-sm-4 col-form-label text-right">Current Password:</label>
<div class="col-sm-8">
<input type="password" class="form-control form-control-sm"
name="ExistingPassword" id="ExistingPassword" required >
</div>
</div>
<div class="form-group row">
<label for="EmployeeCode"
class="col-sm-4 col-form-label text-right">New Password:</label>
<div class="col-sm-8">
<input type="password" class="form-control form-control-sm"
name="NewPassword" id="NewPassword" required >
</div>
</div>
<div class="form-group row">
<label for="EmployeeCode"
class="col-sm-4 col-form-label text-right">Confirm New Password:</label>
<div class="col-sm-8">
<input type="password" class="form-control form-control-sm"
name="ConfirmNewPassword" id="ConfirmNewPassword" required >
<small></small>
</div>
</div>
</div>
<div class="col-md-12">
<div class="float-right">
<button type="button" id="btn-save-job-detail"
class="btn btn-warning text-white" id="updateUserPassword" onclick="updateUserPassword();">Submit</button>
<a href="{{url('/dashboard')}}"
class="btn btn-warning text-white">Cancel</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section><br />
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
{{-- JS Start Here --}}
@endsection
<script>
function updateUserPassword() {
//event.preventDefault();
$("#frmUserPasswordChange").valid();
var token = $('#token').val();
var UserId = $('#UserId').val();
var ExistingPassword = $('#ExistingPassword').val();
var NewPassword = $('#NewPassword').val();
var ConfirmNewPassword = $('#ConfirmNewPassword').val();
if(!ExistingPassword){
Swal.fire({
icon: 'warning',
title: 'Current Password Required!',
showConfirmButton: false,
timer: 2000
});
return false;
} else if(!NewPassword){
Swal.fire({
icon: 'warning',
title: 'New Password Required!',
showConfirmButton: false,
timer: 2000
});
return false;
} else if(!ConfirmNewPassword){
Swal.fire({
icon: 'warning',
title: 'Confirm New Password Required!',
showConfirmButton: false,
timer: 2000
});
return false;
} else if(NewPassword != ConfirmNewPassword){
Swal.fire({
icon: 'warning',
title: 'Your new password and confirmation new password do not match!',
showConfirmButton: false,
timer: 2000
});
return false;
} else {
var formData = new FormData();
formData.append('_token', token);
formData.append('UserId', UserId);
formData.append('ExistingPassword', ExistingPassword);
formData.append('NewPassword', NewPassword);
$.ajax({
type: "post",
url: "{{ url('ajax/user/password/update') }}",
//data: $('form#addEmpQualificationForm').serialize(),
data : formData,
processData: false,
contentType: false,
success: function(response) {
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
icon: 'success',
title: 'Password has been changed successfully!'
});
$('form#addEmpQualificationForm').each(function() {
this.reset();
});
$('span#CheckActualWorkPlace').html('');
if(response == 2)
{
Swal.fire({
icon: 'warning',
title: 'Current Password is incorrect!',
showConfirmButton: false,
timer: 2000
});
return false;
}
else if(response == 3)
{
Swal.fire({
icon: 'warning',
title: 'User not found!',
showConfirmButton: false,
timer: 2000
});
return false;
}
else if(response == 1)
{
location.href="{{url('/dashboard')}}";
}
},
error: function(response) {
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
icon: 'error',
title: 'Something went wrong!'
})
}
});
}
}
</script>