File: /home/cafsindia/.trash/application.1/views/password_change/manage.php
<?php
$this->load->view("partial/header");
$access_data = $this->session->userdata('access_data');
$access_add = (int)$access_data[$controller_name]['access_add'];
$access_update = (int)$access_data[$controller_name]['access_update'];
$access_delete = (int)$access_data[$controller_name]['access_delete'];
$access_search = (int)$access_data[$controller_name]['access_search'];
$access_export = (int)$access_data[$controller_name]['access_export'];
$access_import = (int)$access_data[$controller_name]['access_import'];
$page_name = ucwords(str_replace("_"," ",$controller_name));
$uniqueId = "prime_".$controller_name."_id";
?>
<style>
#new_password,#current_password,#verify_password{
text-transform: none !important;
}
</style>
<script type="text/javascript">
$(document).ready(function (){
<?php $this->load->view('partial/bootstrap_tables_locale'); ?>
$('#current_password').change(function() {
var current_password = $('#current_password').val();
var send_url = '<?php echo site_url("$controller_name/check_password"); ?>';
if(current_password.length > 0){
//Encryption
var key = '<?php echo $key; ?>';
var data = {current_password:current_password};
var encData = encrypt(key,data);
$.ajax({
type: "POST",
url: send_url,
data:encData,
contentType: 'text/plain',
success: function(data) {
var rslt = JSON.parse(data);
if(rslt.success){
toastr.success(rslt.message);
}else{
toastr.error(rslt.message);
$('#current_password').val('');
}
}
});
}
});
$('#new_password').change(function() {
var current_password = $('#current_password').val();
var new_password = $('#new_password').val();
if(current_password.length > 0){
if(new_password == current_password){
toastr.error("Same password is not allowed");
$('#new_password').val('');
}else{
toastr.success("Continue to enter in confirm password");
}
}
});
$("#save_password").submit(function(event){ event.preventDefault(); }).validate({
rules:{
current_password:'required',
new_password: {
required: true,
minlength: 6,
},
verify_password:{
equalTo: "#new_password"
},
},
submitHandler: function (form){
$("#submit").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
$('#submit').attr('disabled','disabled');
$(form).ajaxSubmit({
success: function (response){
$('#submit').attr('disabled',false);
$("#submit").html("Submit");
if(response.success){
toastr.success(response.message);
location.reload();
}else{
toastr.error(response.message);
}
},
dataType: 'json'
});
}
});
});
$("body").on('click', '.toggle-password', function() {
$(this).toggleClass("fa-eye-slash fa-eye");
var input = $("#new_password");
if (input.attr("type") === "password") {
input.attr("type", "text");
} else {
input.attr("type", "password");
}
});
</script>
<div class='row title_content'>
<div class='col-md-4 col-xs-4'>
<h1 class='page_txt'><?php echo $page_name;?></h1>
</div>
</div>
<div id="holder" class="form-inline" style="margin-top:20px;">
<?php echo form_open("$controller_name/save_password/",array("id"=>"save_password","class"=>"form-inline")); ?>
<div class="form-group">
<?php
echo form_label('Current Password', 'current_password', array('class' => "control-label required"))."<br/>";
echo form_password(array('name'=>'current_password', 'id' => 'current_password', 'class'=>'form-control','placeholder'=> "Current Password"));
?>
</div>
<div class="form-group">
<?php
echo form_label('New Password', 'new_password', array('class' => "control-label required"))."<br/>";
echo form_password(array('name'=>'new_password', 'id' => 'new_password', 'class'=>'form-control','placeholder'=> "New Password"));
?>
<span toggle="#new_password" class="fa fa-fw fa-eye-slash toggle-password" style='float:right;'></span>
</div>
<div class="form-group">
<?php
echo form_label('Confirm Password', 'verify_password', array('class' => "control-label required"))."<br/>";
echo form_password(array('name'=>'verify_password', 'id' => 'verify_password', 'class'=>'form-control','placeholder'=> "Confirm New Password"));
?>
</div>
<div class="form-group">
<button class='btn btn-primary btn-sm' id="submit" style='margin-top:20px;'>Submit</button>
</div>
<?php echo form_close(); ?>
</div>
<?php $this->load->view("partial/footer"); ?>