<?php
function website_settingdata($field_name)

          {
      include "mconnect.php";
			$data_q=mysqli_query($con,"SELECT $field_name FROM x_websitesetting WHERE x_id='1'");

			$data_array=mysqli_fetch_array($data_q);

			
			
			return $data_array[0];  

			
		  }
		  
		  
	function currencyConverter($from_Currency,$to_Currency,$amount) {
	
	 $from_to = $from_Currency."_".$to_Currency;
	
	 $url ="http://free.currencyconverterapi.com/api/v5/convert?q=$from_to&compact=y";
	$request = curl_init(); 
	 $timeOut = 0; 
	 curl_setopt ($request, CURLOPT_URL, $url); 
	 curl_setopt ($request, CURLOPT_RETURNTRANSFER, 1); 
	 
	 curl_setopt ($request, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); 
	 curl_setopt ($request, CURLOPT_CONNECTTIMEOUT, $timeOut); 
	 $response = curl_exec($request); 
	 curl_close($request); 
	 $response = explode("<span class=bld>",$response);
	 $response = explode("</span>",$response[0]);
	 $rate= preg_replace("/[^0-9\.]/", null, $response[0]);
	 
	 $amount = str_replace(",","",$amount);
	
     $converted_amount = $amount*1;
	 $converted_amount =  number_format($converted_amount,2);
	
	 
	 return $converted_amount;
	
	
}	  
		  
function main_account_currency($user_id){
	include "mconnect.php";
	 $data_q=mysqli_query($con,"SELECT a.x_currencysymbol FROM x_currency a INNER JOIN x_anotheracc b ON a.x_id = b.x_currencyid WHERE b.x_userid='$user_id' AND b.x_for_main = 'main_account'");
	 $data_array=mysqli_fetch_array($data_q);
	 return $data_array[0];
}	  
function currency_data($field_name,$symbol_id){
	include "mconnect.php";
	//echo $sql = "SELECT $field_name FROM x_currency WHERE x_id='$symbol_id'";
			$data_q=mysqli_query($con,"SELECT $field_name FROM x_currency WHERE x_id='$symbol_id'");

			$data_array=mysqli_fetch_array($data_q);

			
			
			return $data_array[0];  
	
}


function user_details($user_id,$field_name)

          {
            include "mconnect.php";
			$data_q=mysqli_query($con,"SELECT $field_name FROM x_admin WHERE x_id='$user_id'");

			$data_array=mysqli_fetch_array($data_q);

			return $data_array[0];   

			  

		  }

function product_variantfecth($pr_id,$field_name)

          {
            include "mconnect.php";
				$data_q=mysqli_query($con,"SELECT $field_name FROM x_productvariant WHERE x_id='$pr_id'");

			$data_array=mysqli_fetch_array($data_q);

			return $data_array[0];     

			  

		  }

function bankcustomer_test($c_id,$c_field)

            {

				
include "mconnect.php";
			 $test_usernameq=mysqli_query($con,"SELECT * FROM x_users WHERE $c_field='$c_id'");

			return $test_usernamerow=mysqli_num_rows($test_usernameq);

										                                              	

			}



function master_emailtest($c_id,$c_email)

            {

				
include "mconnect.php";
			 $test_usernameq=mysqli_query($con,"SELECT * FROM x_users WHERE x_id!='$c_id' and x_email='$c_email'");

			return $test_usernamerow=mysqli_num_rows($test_usernameq);

										                                              	

			}

function user_bankuser($user_id,$field_name)

          {
            include "mconnect.php";
			if(($field_name=="x_time")||($field_name=="x_status")||($field_name=="x_actype")||($field_name=="x_totalbalance")||($field_name=="x_currencyid")){
				
				$data_q=mysqli_query($con,"SELECT $field_name FROM x_anotheracc WHERE x_id='$user_id' ");
			}
			else{
				$data_q=mysqli_query($con,"SELECT $field_name FROM x_users WHERE x_id='$user_id' or x_userid = '$user_id' ");
			}
			

			$data_array=mysqli_fetch_array($data_q);

			return $data_array[0];   

			  

		  }

function credit_cardyesno($u_id,$acc_id)

             {
include "mconnect.php";
				 $data_q=mysqli_query($con,"SELECT * FROM x_creditcards WHERE x_userid='$u_id' AND x_accountid='$acc_id'");

				 return $data_row=mysqli_num_rows($data_q);

				 

			 }

	function creditcard_detailss($u_id,$u_filed)

	            {
                include "mconnect.php";
				$data_q=mysqli_query($con,"SELECT $u_filed FROM x_creditcards WHERE x_id='$u_id'");

				$data_array=mysqli_fetch_array($data_q);

				return $data_array[0];	

				}

	function card_idftech($u_id,$acc_id)

	          {
include "mconnect.php";
				 $data_q=mysqli_query($con,"SELECT x_id FROM x_creditcards WHERE x_userid='$u_id' AND x_accountid='$acc_id'");

				  $data_array=mysqli_fetch_array($data_q);

				 return $data_array[0];	

			  }

     	function otp_firsttemplate($my_otpcode,$user_inputname,$code_type)

							     {

									$bank_name=website_settingdata("x_bankname"); 

									$bank_email=website_settingdata("x_bankcontactemail"); 
									$logo1=website_settingdata("x_weburl");
$logo2="images/";
$logo3=website_settingdata("x_logo");
$bank_logo="$logo1$logo2$logo3";

									 return '<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">



<title>Mailer</title>

<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,500,300,700" rel="stylesheet" type="text/css">

<style type="text/css">

@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900italic,900,700italic,700,600italic,600,400italic,300italic,300,200italic,200);</style>



</head>



<body style="font-size:14px; font-family:arial;">





<div class="wrapper" style="width:85%; box-sizing:border-box; margin:auto; border:1px solid #ccc; background:#fff; padding:10px;">

<table width="100%">

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:35px; text-align:center; color:#00BEC6; font-weight:600;"><img src="'.$bank_logo.'"></td>

  </tr>

  

   <tr ><td style="border-bottom:5px solid #00BEC6;">&nbsp;</td></tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px; font-weight:600;">Dear '.$user_inputname.'</td>

  </tr>

  <tr style="line-height:35px;">

    <td style="color:#686C70;font-size:16px;">Your '.$code_type.' is '.$my_otpcode.'</td>

  </tr>



  

   <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">'.$bank_name.' will NEVER send you a link to any external website or request your personal banking details via e-mail, telephone or in person. You are advised to </td>

  </tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">always keep your log-on details safe and never disclose it to anyone.

Thank you for choosing '.$bank_name.'.

</td>

  </tr>

  

  

    <tr><td>&nbsp;</td></tr>

     <tr ><td style="border-bottom:2px solid #ccc;">&nbsp;</td></tr>

  

    <tr><td>&nbsp;</td></tr>

  

  

 

  

  

  

  <tr style="line-height:20px;">

    <td style="color:#686C70;font-size:13px;">The Information contained and transmitted by this E-MAIL is proprietary to '.$bank_name.' and/or its Customer and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from a disclosure under applicable law.

If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Bank. '.$bank_name.' shall not be liable for any mails sent without due authorisation or through unauthorised access.

If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited.

If you have received this communication in error, please delete this mail and notify us immediately at '.$bank_email.'

</td>

  </tr>

   </table>



</div>



</body>

</html>';

								 }

					function email_templateregister($u_name)

					            {

									$bank_name=website_settingdata("x_bankname"); 

									$bank_email=website_settingdata("x_bankcontactemail"); 	
$logo1=website_settingdata("x_weburl");
$logo2="images/";
$logo3=website_settingdata("x_logo");
$bank_logo="$logo1$logo2$logo3";
									

									return '<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">



<title>account is created</title>

<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,500,300,700" rel="stylesheet" type="text/css">

<style type="text/css">

@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900italic,900,700italic,700,600italic,600,400italic,300italic,300,200italic,200);</style>



</head>



<body style="font-size:14px; font-family:arial;">





<div class="wrapper" style="width:85%; box-sizing:border-box; margin:auto; border:1px solid #ccc; background:#fff; padding:10px;">

<table width="100%">

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:35px; text-align:center; color:#00BEC6; font-weight:600;"><img src="'.$bank_logo.'"></td>

  </tr>

  

   <tr ><td style="border-bottom:5px solid #00BEC6;">&nbsp;</td></tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px; font-weight:600;">Dear '.$u_name.'</td>

  </tr>

  <tr style="line-height:35px;">

    <td style="color:#686C70;font-size:16px;">Your account has been created successfully. Soon the account will be activated.. </td>

  </tr>



   <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">'.$bank_name.' will NEVER send you a link to any external website or request your personal banking details via e-mail, telephone or in person. You are advised to </td>

  </tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">always keep your log-on details safe and never disclose it to anyone.

Thank you for choosing '.$bank_name.'.

</td>

  </tr>

  

  

    <tr><td>&nbsp;</td></tr>

     <tr ><td style="border-bottom:2px solid #ccc;">&nbsp;</td></tr>

  

    <tr><td>&nbsp;</td></tr>

  

  

 

  

  

  

  <tr style="line-height:20px;">

    <td style="color:#686C70;font-size:13px;">The Information contained and transmitted by this E-MAIL is proprietary to '.$bank_name.' and/or its Customer and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from a disclosure under applicable law.

If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Bank. '.$bank_name.' shall not be liable for any mails sent without due authorisation or through unauthorised access.

If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited.

If you have received this communication in error, please delete this mail and notify us immediately at '.$bank_email.'

</td>

  </tr>

   </table>



</div>

</body>

</html>

';

								}

					function activated_mailertem($u_name,$ac_number)

					          {

							

							$bank_name=website_settingdata("x_bankname"); 

							$bank_email=website_settingdata("x_bankcontactemail");	  
$logo1=website_settingdata("x_weburl");
$logo2="images/";
$logo3=website_settingdata("x_logo");
$bank_logo="$logo1$logo2$logo3";
								

								

								return '<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">



<title>account is activated</title>

<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,500,300,700" rel="stylesheet" type="text/css">

<style type="text/css">

@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900italic,900,700italic,700,600italic,600,400italic,300italic,300,200italic,200);</style>



</head>



<body style="font-size:14px; font-family:arial;">





<div class="wrapper" style="width:85%; box-sizing:border-box; margin:auto; border:1px solid #ccc; background:#fff; padding:10px;">

<table width="100%">

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:35px; text-align:center; color:#00BEC6; font-weight:600;"><img src="'.$bank_logo.'"></td>

  </tr>

  

   <tr ><td style="border-bottom:5px solid #00BEC6;">&nbsp;</td></tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px; font-weight:600;">Dear '.$u_name.'</td>

  </tr>

  <tr style="line-height:35px;">

    <td style="color:#686C70;font-size:16px;">Your account has been activated successfully... </td>

  </tr>

    <tr style="line-height:35px;">

    <td style="color:#686C70;font-size:16px;">Your Account Number is '.$ac_number.' For more login info contact at your branch </td>

  </tr>

   <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">'.$bank_name.' will NEVER send you a link to any external website or request your personal banking details via e-mail, telephone or in person. You are advised to </td>

  </tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">always keep your log-on details safe and never disclose it to anyone.

Thank you for choosing '.$bank_name.'.

</td>

  </tr>

  

  

    <tr><td>&nbsp;</td></tr>

     <tr ><td style="border-bottom:2px solid #ccc;">&nbsp;</td></tr>

  

    <tr><td>&nbsp;</td></tr>

  

  

 

  

  

  

  <tr style="line-height:20px;">

    <td style="color:#686C70;font-size:13px;">The Information contained and transmitted by this E-MAIL is proprietary to '.$bank_name.' and/or its Customer and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from a disclosure under applicable law.

If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Bank. '.$bank_name.' shall not be liable for any mails sent without due authorisation or through unauthorised access.

If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited.

If you have received this communication in error, please delete this mail and notify us immediately at '.$bank_email.'

</td>

  </tr>

   </table>



</div>







</body>

</html>

';  

							  }

							  function findaccounttoname($ac_number)
							   {
                                include "mconnect.php";
							    $data_q=mysqli_query($con,"SELECT x_fname, x_lname FROM x_users a INNER JOIN x_anotheracc b ON a.x_id=b.x_userid WHERE b.x_time='$ac_number'");

			                    $data_array=mysqli_fetch_array($data_q);

			                    return $data_array[0]." ".$data_array[1]; 	
							   }

		function findtimetouserid($ac_num)
		{
					  
		  include "mconnect.php";
		  $data_q=mysqli_query($con,"SELECT a.x_id FROM x_users a INNER JOIN x_anotheracc b ON a.x_id=b.x_userid WHERE b.x_time='$ac_num'");

		  $data_array=mysqli_fetch_array($data_q);

		  return $data_array[0];   

		}
		
		function findtimetoaccountid($ac_num)
		{
					  
		  include "mconnect.php";
		  $data_q=mysqli_query($con,"SELECT x_id FROM x_anotheracc WHERE x_time='$ac_num'");

		  $data_array=mysqli_fetch_array($data_q);

		  return $data_array[0];   

		}
										   

								function unreadmessages($u_id)
								  {
                                         include "mconnect.php";
									     $data_q=mysqli_query($con,"SELECT * FROM x_chat WHERE x_userid='$u_id' and x_readstatus='U' and x_by='user'");

										 return $data_row=mysqli_num_rows($data_q);
								  } 
								  
                                function mailer_debitcredittempl($ac_num,$u_name,$a_description,$ref_num,$total_balance,$am_nt,$tr_type,$currencyid)
								   {

										 $branch_bank=website_settingdata("x_branch");   
							             $bank_name=website_settingdata("x_bankname"); 
									     $bank_email=website_settingdata("x_bankcontactemail");	  
$logo1=website_settingdata("x_weburl");
$logo2="images/";
$logo3=website_settingdata("x_logo");
$bank_logo="$logo1$logo2$logo3";
								         $live_date=date("l jS \of F Y");
									     $live_time=date('h:i:s A');
										 
									     //$currency_bank=website_settingdata("x_currencysimbol");
                                              $currency_bank = currency_data("x_currencysymbol",$currencyid);

											   return '<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">



<title>Transaction Mail</title>

<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,500,300,700" rel="stylesheet" type="text/css">

<style type="text/css">

@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900italic,900,700italic,700,600italic,600,400italic,300italic,300,200italic,200);</style>



</head>



<body style="font-size:14px; font-family:arial;">





<div class="wrapper" style="width:85%; box-sizing:border-box; margin:auto; border:1px solid #ccc; background:#fff; padding:10px;">

<table width="100%">

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:35px; text-align:center; color:#00BEC6; font-weight:600;"><img src="'.$bank_logo.'"></td>

  </tr>

  

   <tr ><td style="border-bottom:5px solid #00BEC6;">&nbsp;</td></tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px; font-weight:600;">Dear '.$u_name.'</td>

  </tr>

  <tr style="line-height:35px;">

    <td style="color:#686C70;font-size:16px;">'.$bank_name.' Transaction Alert Service</td>

  </tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">Please be informed that a '.$tr_type.' transaction occurred on your bank account.</td>

  </tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">Kindly find details of the transaction below:</td>

  </tr>

  

  </table>

  <table width="100%" >

  <tr>

    <td colspan="2" style="background:#00BBC3; padding:5px;">Transaction Details</td>

  </tr>

  <tr style="background:#D9D9D9;">

    <td style="padding:5px;">Account Number</td>

    <td style="padding:5px;">'.$ac_num.'</td>

  </tr>

  <tr style="background:#f6f6f6">

    <td style="padding:5px;">Account Name</td>

    <td style="padding:5px;">'.$u_name.'</td>

  </tr>

 <tr style="background:#D9D9D9;">

    <td style="padding:5px;">Description</td>

    <td style="padding:5px;">'.$a_description.'</td>

  </tr>

  <tr style="background:#f6f6f6">

    <td style="padding:5px;">Refrence No</td>

    <td style="padding:5px;">#'.$ref_num.'</td>

  </tr>

   <tr style="background:#D9D9D9;">

    <td style="padding:5px;">Transaction  Branch</td>

    <td style="padding:5px;">'.$branch_bank.'</td>

  </tr>

  <tr style="background:#f6f6f6">

    <td style="padding:5px;">Transaction Amount</td>

    <td style="padding:5px;">'.$currency_bank.' '.$am_nt.'</td>

  </tr>

  <tr style="background:#D9D9D9;">

       <td style="padding:5px;">Transaction Time</td> 

    <td style="padding:5px;">'.$live_time.'</td>

  </tr>

  <tr style="background:#f6f6f6">

<td style="padding:5px;">Transaction Date</td>

    <td style="padding:5px;">'.$live_date.'</td>

  </tr>

</table>







  <table width="100%">

   <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">As a result of this transaction , the balances on this account are:</td>

  </tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">Available Balance : '.$currency_bank.' '.$total_balance.'</td>

  </tr>

  

  

    <tr><td>&nbsp;</td></tr>

     <tr ><td style="font-weight:600; color:#565454; font-size:18px;">Thank you  for banking  with '.$bank_name.'</td></tr>

      <tr><td>&nbsp;</td></tr>

  <tr ><td style="border-bottom:2px solid #ccc;"></td></tr>

  

  

    <tr><td>&nbsp;</td></tr>

  

  

  

  <tr style="line-height:20px;">

    <td style="color:#686C70;font-size:13px;">The Information contained and transmitted by this E-MAIL is proprietary to '.$bank_name.' and/or its Customer and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from a disclosure under applicable law.

If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Bank. '.$bank_name.' shall not be liable for any mails sent without due authorisation or through unauthorised access.

If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited.

If you have received this communication in error, please delete this mail and notify us immediately at '.$bank_email.'

</td>

  </tr>

   </table>



</div>



</body>

</html>

';

										   }



?>