<?php
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
//start session

session_start();

require_once ('../admin/config/database.php');


function changePass() {

	$unam = $_SESSION['hlbank_uid_no'];
	$errorMessage = '';
	$ManagerName = $_POST['opassword'];
	$Pass = $_POST['npassword'];
	$Pass1 = $_POST['cpassword'];
	$old_pass = $ManagerName;
	$sql_2 = "SELECT pwd FROM tbl_users WHERE id = '$unam'";
	$results = dbQuery($sql_2);
	if(dbNumRows($results) > 0) {
		extract(dbFetchAssoc($results));
	if($old_pass != $pwd){
 $errorMessage = "<div class='alert alert-danger'>
 						Current Password entered is incorrect, Try again
 			  		</div>";
 			return $errorMessage;
	}else{
	if($Pass != $Pass1)
	{
 $errorMessage = "<div class='alert alert-danger'>
 						Passwords do not match!
 			  		</div>";
 			return $errorMessage;
	}else{
	$sql = "UPDATE tbl_users SET pwd = '$Pass' WHERE id = '$unam'";
	dbQuery($sql);

			$q_sql	= "SELECT * FROM settings WHERE id = '1'";
	$q_results 	= dbQuery($q_sql);
	extract(dbFetchAssoc($q_results));

	require_once 'PHPMailernew/PHPMailerAutoload.php';
	$email_content= '<div style="background: #f5f7f8;width: 100%;height: 100%; font-family: sans-serif; font-weight: 100;" class="be_container">

				<div style="background:#fff;max-width: 600px;margin: 0px auto;padding: 30px;"class="be_inner_containr"> <div class="be_header">

				<div class="be_logo" style="float: left;"> <img src="../logo/logo.png"> </div>

				<div style="clear: both;"></div>
				<div class="be_user" style="float: right"> <p>Dear: '.$fname.' '.$lname.',</p> </div>

				<div style="clear: both;"></div>

				 </div>

				<div class="be_body" style="padding: 20px;"> <p style="line-height: 25px;"> Your Password has been changed successfully,<br>If you did not initiate this changes, kindly contact our support immediately for proper action<br><br>Thank you for choosing us as your online banking partner.</p>
				<div style="margin-top: 25px;">

				<p>In case you need any further clarification for the same, please do get in touch with your Branch.</p> </div> </div> <div class="be_footer">
				<div style="border-bottom: 1px solid #ccc;"></div> <p> Please do not reply to this email. Emails sent to this address will not be answered.
				Copyright © <script type="text/javascript">document.write(new Date().getFullYear()); </script> | '.$b_name.' </p> </div> </div> </div>';


// $mail = new PHPMailer(true);
//             $mail->SMTPDebug = 0;
//             $mail->isSMTP();
//             $mail->Host = $b_url;
//             $mail->SMTPAuth = true;
//             $mail->Username = $b_email;
//             $mail->Password = $email_password;
//             $mail->SMTPSecure = 'ssl';
//             $mail->Port = '465';
//             $mail->setFrom($b_email, $b_name);
//             $mail->addAddress($email);
//             $mail->addReplyTo($b_email,$b_name);
//             $mail->isHTML(true);
//             $mail->Subject ='Account Password Change';
//             $mail->Body = $email_content;
//             $mail->send();

	$errorMessage = "<div class='alert alert-success'>
					 Your password have been updated successfully
					 </div>";
		 return $errorMessage;
	}
  }
}else
{
$errorMessage = "<div class='alert alert-danger'>
					 Error, Try again later!
					 </div>";
		 return $errorMessage;
}
}

function logOut(){
	if (isset($_SESSION['hlbank_user'])) {
		unset($_SESSION['hlbank_user']);
		//session_unregister('hlbank_user');
	}
	header('Location: ../login?Ibanking');
	exit;
}//logOut


?>
