Commit 71fd564a by Tobin

checker password reset

parent 50a24ea2
......@@ -155,5 +155,37 @@ class Checker extends CI_Controller {
$this->load->view('template',$template);
}
function resetPassword($checker_id = ''){
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
if(empty($checker_id) || !is_numeric($checker_id = decode_param($checker_id))){
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Checker/viewCheckers'));
}
$unique_id = $this->Checker_model->resetPassword($checker_id);
$checkerData = $this->Checker_model->getCheckerData('','',$checker_id);
if(empty($unique_id) || empty($checkerData)){
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Checker/viewCheckers'));
}
$subject = "New Password for Checker Account";
$email_id = $checkerData->username;
$message = "<html>
<body>
New password of your Checker Account for the username
<strong>".$checkerData->username."</strong> is <strong>".$unique_id."</strong><br>
</body>
</html>";
$this->load->model('Api_model');
$this->Api_model->send_mail($subject,$email_id,$message);
$flashMsg = array('message'=>'New Password Generated..!','class'=>'success');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Checker/viewCheckers'));
}
}
?>
\ No newline at end of file
......@@ -4,15 +4,16 @@ class Checker_model extends CI_Model {
parent::_construct();
}
public function getCheckerData($provider_id='',$view=''){
public function getCheckerData($provider_id='',$view='',$checker_id=''){
$cond = (!empty($view))?" CHK.status IN ($view) ":" CHK.status != '2' ";
$cond .= (!empty($checker_id))?" AND CHK.id='$checker_id' ":"";
$cond .= (!empty($provider_id))?" AND PRV.provider_id='$provider_id' ":"";
$checkerData = $this->db->query("SELECT CHK.*,PRV.name
FROM checker AS CHK
INNER JOIN provider AS PRV ON (CHK.provider_id=PRV.provider_id)
WHERE $cond");
return $checkerData->result();
FROM checker AS CHK
INNER JOIN provider AS PRV ON (CHK.provider_id=PRV.provider_id)
WHERE $cond");
return (!empty($checker_id))?$checkerData->row_array():$checkerData->result();
}
public function createChecker($checkerData = array()){
......@@ -34,5 +35,15 @@ class Checker_model extends CI_Model {
$status = $this->db->update('checker',array('status'=>$status),array('id'=>$id));
return $status;
}
public function resetPassword($checker_id = ''){
if(empty($checker_id)){
return 0;
}
$unique_id = rand(11111111,99999999);
$status = $this->db->update('checker',array('password'=>md5($unique_id),'status'=>1),
array('id'=>$checker_id));
return ($status)?$unique_id:0;
}
}
?>
\ No newline at end of file
......@@ -88,6 +88,9 @@
<?= ($checker->status == 1)?'Active':'De-activate' ?>
</th>
<td class="center">
<a class="btn btn-sm btn-link" style="margin-top:-13px;" href="<?= base_url('Checker/resetPassword/'.encode_param($checker->id)) ?>">
<i class="fa fa-fw fa-key"></i>Reset Password
</a><br>
<a class="btn btn-sm btn-danger" onclick="confirmDelete(jQuery(this),'Checker/changeStatus',{'checker_id':'<?=encode_param($checker->id)?>'})"
status="2"><i class="fa fa-fw fa-trash"></i>Delete
</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment