<?php
	session_start();
	include"../../connect/db.php";
	require "SausageHTTP/SausageHTTP.php";
	csrf_verify();


 	 	if( isset($_POST['rbank']) ){
			
	 		$rbank = mysqli_real_escape_string($con,$_POST['rbank']);
	 		$accno = mysqli_real_escape_string($con,$_POST['accno']);
	 		$rname = mysqli_real_escape_string($con,$_POST['rname']);
	 		$rcode = mysqli_real_escape_string($con,$_POST['rcode']);
	 		$ifscode = mysqli_real_escape_string($con,$_POST['ifscode']);
	 		$account_type = mysqli_real_escape_string($con,$_POST['account_type']);
	 		
	 		$remarks = mysqli_real_escape_string($con,$_POST['remarks']);
	 		$transtype = "Transfer";
	 		$amt = mysqli_real_escape_string($con,$_POST['amt']);
	 		$chap = $_SESSION['chap'];
	 		$d_o_t = date("Y-m-d");	

            $seed = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); // and any other characters
            shuffle($seed); // probably optional since array_is randomized; this may be redundant
            $rand = '';
            foreach (array_rand($seed, 7) as $k) $rand .= $seed[$k];								            
	        $transId =  $rand; 
	       $sql = mysqli_query($con,"SELECT * FROM users WHERE account_num = '$accno' ");
	 		if( mysqli_num_rows($sql) != 0 ){

	 			$kunle = mysqli_query($con,"SELECT currency,fullname,balance,account_num,phone FROM users WHERE email = '$chap' ");

	 			$krow = mysqli_fetch_assoc($kunle) ;

		 		if( $krow['balance'] < $amt ){
		 			echo "broke";
		 		}
		 		else{
		 		    $sql222 = mysqli_query($con,"SELECT * FROM users WHERE account_num = '$accno' ");
                    $row = mysqli_fetch_assoc($sql222);
					$theotherchap = $accno;
					
					$theotherchapacc = $row['email'];

                    
					$account_num = $krow['account_num'];
					
 					$debit_new_amt = $krow['balance'] - $amt ;
 					$credit_new_amt = $row['balance'] + $amt ;

			          $descriptionR = '
					  <!DOCTYPE html>
					  <html>
			  
					  <head>
						  <title></title>
						  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
						  <meta name="viewport" content="width=device-width, initial-scale=1">
						  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
						  <style type="text/css">
							  @media screen {
								  @font-face {
									  font-family: `Lato`;
									  font-style: normal;
									  font-weight: 400;
									  src: local(`Lato Regular`), local(`Lato-Regular`), url(https://fonts.gstatic.com/s/lato/v11/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff) format(`woff`);
								  }
			  
								  @font-face {
									  font-family: `Lato`;
									  font-style: normal;
									  font-weight: 700;
									  src: local(`Lato Bold`), local(`Lato-Bold`), url(https://fonts.gstatic.com/s/lato/v11/qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff) format(`woff`);
								  }
			  
								  @font-face {
									  font-family: `Lato`;
									  font-style: italic;
									  font-weight: 400;
									  src: local(`Lato Italic`), local(`Lato-Italic`), url(https://fonts.gstatic.com/s/lato/v11/RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.woff) format(`woff`);
								  }
			  
								  @font-face {
									  font-family: `Lato`;
									  font-style: italic;
									  font-weight: 700;
									  src: local(`Lato Bold Italic`), local(`Lato-BoldItalic`), url(https://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si6vvxL-qU.woff) format(`woff`);
								  }
							  }
			  
							  /* CLIENT-SPECIFIC STYLES */
							  body,
							  table,
							  td,
							  a {
								  -webkit-text-size-adjust: 100%;
								  -ms-text-size-adjust: 100%;
							  }
			  
							  table,
							  td {
								  mso-table-lspace: 0pt;
								  mso-table-rspace: 0pt;
							  }
			  
							  img {
								  -ms-interpolation-mode: bbic;
							  }
			  
							  /* RESET STYLES */
							  img {
								  border: 0;
								  height: auto;
								  line-height: 100%;
								  outline: none;
								  text-decoration: none;
							  }
			  
							  table {
								  border-collapse: collapse !important;
							  }
			  
							  body {
								  height: 100% !important;
								  margin: 0 !important;
								  padding: 0 !important;
								  width: 100% !important;
							  }
			  
							  /* iOS BLUE LINKS */
							  a[x-apple-data-detectors] {
								  color: inherit !important;
								  text-decoration: none !important;
								  font-size: inherit !important;
								  font-family: inherit !important;
								  font-weight: inherit !important;
								  line-height: inherit !important;
							  }
			  
							  /* MOBILE STYLES */
							  @media screen and (max-width:600px) {
								  h1 {
									  font-size: 32px !important;
									  line-height: 32px !important;
								  }
							  }
			  
							  /* ANDROID CENTER FIX */
							  div[style*="margin: 16px 0;"] {
								  margin: 0 !important;
							  }
						  </style>
					  </head>
			  
					  <body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;">
						  <!-- HIDDEN PREHEADER TEXT -->
						  <div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: `Lato`, Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;"></div>
						  <table border="0" cellpadding="0" cellspacing="0" width="100%">
							  <!-- LOGO -->
							  <tr>
								  <td bgcolor="white" align="center">
									  <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
										  <tr>
											  <td align="center" valign="top" style="padding: 40px 10px 40px 10px;"> </td>
										  </tr>
									  </table>
								  </td>
							  </tr>
							  <tr>
								  <td bgcolor="white" align="center" style="padding: 0px 10px 0px 10px;">
									  <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
										  <tr>
											  <td bgcolor="gray" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: `Lato`, Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;">
												   <img src="https://dbhacu.com/logo.png" width="200" height="60" style="display: block; border: 0px;" />
												  <h4 style="font-size: 28px; font-weight: 400; margin: 2; color: white;">Credit Alert</h4>
											  </td>
										  </tr>
									  </table>
								  </td>
							  </tr>
							  <tr>
								  <td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;">
									  <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
										  <tr>
											  <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #666666; font-family: `Lato`, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
												  <p style="margin: 10px; color: teal; padding: 12px;">
													  <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">Your Acct: <span style="font-weight:bold"> '.$theotherchap.'</span></p>
													  <p style="margin: 10px; color:rgb(0, 0, 0); background-color: #d3d3d3;">Credited: <span  style="font-weight:bold">  '.formatCurrency($amt, $krow['currency']).'</span></p>
													  <p style="margin: 10px; color:rgb(0, 0, 0); background-color: #d3d3d3;">Date:  <span style="font-weight:bold"> '.date("Y-m-d").','.date("h:i:sa").'</span></p>
													  <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">By: <span style="font-weight:bold">'.$krow['fullname'].'</span></p>
													  <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">Type: <span style="color: rgb(3, 119, 9); font-weight:bold">Credit</span></p> 
													  <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">Bal:'.formatCurrency($credit_new_amt, $krow['currency']).'</p><br>  
												  </p>
												  <p style="margin: 10px; color: rgb(0, 0, 0); padding: 12px;">
												  <b>Remember</b>: Deutsche Bank Holdings Delaware  would Never call,sms or email requesting for your details ,PIN , token codes,
												  mobile/internet banking login details or other account related information.DO NOT respond to such messages or contact our live chat <a href="http://dbhacu.com"> Deutsche Bank Holdings Delaware  </a>
												  </p>
												  <p style="margin: 10px; color: rgb(0, 0, 0); padding: 12px;">
													   Thank you
													  for choosing  Deutsche Bank Holdings Delaware  .
													  </p>
											  </td>
										  </tr>
										  
									  </table>
								  </td>
								  
							  </tr>
							  <tr>
								  <td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;">
									  <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
										  <tr>
											  <td bgcolor="gray" align="center" style="padding: 30px 30px 30px 30px; border-radius: 4px 4px 4px 4px; color: #666666; font-family: `Lato`, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
												  <h2 style="font-size: 20px; font-weight: 400; color: #111111; margin: 0;">Need more help?</h2>
												  <p style="margin: 0;"><a href="https://dbhacu.com/contact.php" target="_blank" style="color: #FFA73B;">We&rsquo;re here to help you out</a></p>
											  </td>
										  </tr>
									  </table>
								  </td>
							  </tr>
						  </table>
					  </body>
			  
					  </html>       
				  ';
                    
                    $credited_note = "Credit! Bank Transfer Of ".$krow['currency']."".$amt." From ".$krow['fullname']." Reference $transId";
                    
			        	$row = mysqli_fetch_assoc($sql);

					$theotherchap = $accno;
					
					$theotherchapacc = $row['email'];					

					$account_num = $krow['account_num'];
					
 					$debit_new_amt = $krow['balance'] - $amt ;
 					$credit_new_amt = $row['balance'] + $amt ;
		            $descriptionC =  '
        <!DOCTYPE html>
        <html>

        <head>
            <title></title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <style type="text/css">
                @media screen {
                    @font-face {
                        font-family: `Lato`;
                        font-style: normal;
                        font-weight: 400;
                        src: local(`Lato Regular`), local(`Lato-Regular`), url(https://fonts.gstatic.com/s/lato/v11/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff) format(`woff`);
                    }

                    @font-face {
                        font-family: `Lato`;
                        font-style: normal;
                        font-weight: 700;
                        src: local(`Lato Bold`), local(`Lato-Bold`), url(https://fonts.gstatic.com/s/lato/v11/qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff) format(`woff`);
                    }

                    @font-face {
                        font-family: `Lato`;
                        font-style: italic;
                        font-weight: 400;
                        src: local(`Lato Italic`), local(`Lato-Italic`), url(https://fonts.gstatic.com/s/lato/v11/RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.woff) format(`woff`);
                    }

                    @font-face {
                        font-family: `Lato`;
                        font-style: italic;
                        font-weight: 700;
                        src: local(`Lato Bold Italic`), local(`Lato-BoldItalic`), url(https://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si6vvxL-qU.woff) format(`woff`);
                    }
                }

                /* CLIENT-SPECIFIC STYLES */
                body,
                table,
                td,
                a {
                    -webkit-text-size-adjust: 100%;
                    -ms-text-size-adjust: 100%;
                }

                table,
                td {
                    mso-table-lspace: 0pt;
                    mso-table-rspace: 0pt;
                }

                img {
                    -ms-interpolation-mode: bbic;
                }

                /* RESET STYLES */
                img {
                    border: 0;
                    height: auto;
                    line-height: 100%;
                    outline: none;
                    text-decoration: none;
                }

                table {
                    border-collapse: collapse !important;
                }

                body {
                    height: 100% !important;
                    margin: 0 !important;
                    padding: 0 !important;
                    width: 100% !important;
                }

                /* iOS BLUE LINKS */
                a[x-apple-data-detectors] {
                    color: inherit !important;
                    text-decoration: none !important;
                    font-size: inherit !important;
                    font-family: inherit !important;
                    font-weight: inherit !important;
                    line-height: inherit !important;
                }

                /* MOBILE STYLES */
                @media screen and (max-width:600px) {
                    h1 {
                        font-size: 32px !important;
                        line-height: 32px !important;
                    }
                }

                /* ANDROID CENTER FIX */
                div[style*="margin: 16px 0;"] {
                    margin: 0 !important;
                }
            </style>
        </head>

        <body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;">
            <!-- HIDDEN PREHEADER TEXT -->
            <div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: `Lato`, Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;"></div>
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <!-- LOGO -->
                <tr>
                    <td bgcolor="white" align="center">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                            <tr>
                                <td align="center" valign="top" style="padding: 40px 10px 40px 10px;"> </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="white" align="center" style="padding: 0px 10px 0px 10px;">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                            <tr>
                                <td bgcolor="gray" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: `Lato`, Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;">
                                     <img src="https://dbhacu.com/logo.png" width="200" height="60" style="display: block; border: 0px;" />
                                    <h4 style="font-size: 28px; font-weight: 400; margin: 2; color: white;">Debit Alert</h4>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                            <tr>
                                <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #666666; font-family: `Lato`, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
                                    <p style="margin: 10px; color: teal; padding: 12px;">
                                        <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">Your Acct: <span style="font-weight:bold"> '.$account_num.'</span></p>
                                        <p style="margin: 10px; color:rgb(0, 0, 0); background-color: #d3d3d3;">Debited: <span  style="font-weight:bold">  '.formatCurrency($amt, $row['currency']).'</span></p>
                                        <p style="margin: 10px; color:rgb(0, 0, 0); background-color: #d3d3d3;">Date:  <span style="font-weight:bold"> '.date("Y-m-d").','.date("h:i:sa").'</span></p>
                                        <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">TO: <span style="font-weight:bold">'.$row['fullname'].'</span></p>
                                        <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">Type: <span style="color: red; font-weight:bold"> Debit</span></p> 
                                        <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">Bal:'.formatCurrency($debit_new_amt, $krow['currency']).'</p><br>  
                                    </p>
                                    <p style="margin: 10px; color: rgb(0, 0, 0); padding: 12px;">
                                    <b>Remember</b>: Deutsche Bank Holdings Delaware  would Never call,sms or email requesting for your details ,PIN , token codes,
                                    mobile/internet banking login details or other account related information.DO NOT respond to such messages or contact our live chat <a href="http://dbhacu.com"> Deutsche Bank Holdings Delaware  </a>
                                    </p>
                                    <p style="margin: 10px; color: rgb(0, 0, 0); padding: 12px;">
                                        Thank you
                                        for choosing  Deutsche Bank Holdings Delaware  .
                                        </p>
                                    
                                </td>
                            </tr>
                            
                        </table>
                    </td>
                    
                </tr>
                <tr>
                    <td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                            <tr>
                                <td bgcolor="gray" align="center" style="padding: 30px 30px 30px 30px; border-radius: 4px 4px 4px 4px; color: #666666; font-family: `Lato`, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
                                    <h2 style="font-size: 20px; font-weight: 400; color: #111111; margin: 0;">Need more help?</h2>
                                    <p style="margin: 0;"><a href="https://dbhacu.com/index.html" target="_blank" style="color: #FFA73B;">We&rsquo;re here to help you out</a></p>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </body>

        </html>       
    ';
                                    
                    $debited_note = "Debit! Bank Transfer Of ".$row['currency']."".$amt."  From self to ".$row['fullname']."  Reference $transId" ;                                  

		 			$seyi = mysqli_query( $con,"INSERT INTO transactions (trans_id, user, description, d_o_t, type, status,rcode,ifscode,account_type,remarks) VALUES ('$transId', '$account_num', '$debited_note', '$d_o_t', 'Debit', 'SUCCESS','$rcode','$ifscode','$account_type','$remarks' ) " );

		 			if( $seyi ){

		 				$segun = mysqli_query( $con,"INSERT INTO transactions (trans_id, user, description, d_o_t, type, status,rcode,ifscode,account_type,remarks) VALUES ('$transId', '$theotherchap', '$credited_note', '$d_o_t', 'Credit', 'SUCCESS', '$rcode','$ifscode','$account_type','$remarks' ) " );

		 				if( $segun ){

		 					$credit_tran = mysqli_query($con,"UPDATE users SET balance = '$credit_new_amt' WHERE email = '$theotherchapacc' ");

		 					$debit_tran = mysqli_query($con,"UPDATE users SET balance = '$debit_new_amt' WHERE email = '$chap' ");
		 					
                                if( $debit_tran && $credit_tran ){
		 					     $sql22 = mysqli_query($con,"SELECT phone,email FROM users WHERE account_num = '$accno' ");
		 					     $rowed = mysqli_fetch_assoc($sql22);
		 					     
		 					
								$debited = $krow['phone'];
								$credited = $rowed['phone'];
								$theothers = $rowed['email'];
								 // TEXT MESSAGE SESSION START //
								$debited_notealert = "Debit Alert Of ".formatCurrency($amt, $row['currency'])." From Self Acct ".$account_num." DESC:GTCU / ".$row['fullname']." DT:".date("Y-m-d").','.date("h:i:sa"). "  Reference:".$transId." Available Balance:".formatCurrency($debit_new_amt, $row['currency'])."";                             
								$credited_notealert = "Credit Alert Of ".formatCurrency($amt, $krow['currency'])." Your Acct ".$theotherchap." DESC:GTCU / ".$krow['fullname']." DT:".date("Y-m-d").','.date("h:i:sa"). "  Reference:".$transId." Available Balance:".formatCurrency($credit_new_amt, $krow['currency'])."" ;
 
								
									 if($credited){
									     include'mail.php';
									    echo'success';
									 }
                                  // 	
								 // TEXT MESSAGE SESSION END //
							
								
								
							
		 					}
		 					else{
		 						echo "error1";
		 					}
		 				}
		 				else{
		 					echo "error2";
		 				}
		 			}
			 			

		 		}	

	 		}
	 		else{

	 			$kunle = mysqli_query($con,"SELECT currency,fullname,balance,code_level,account_num,code_status FROM users WHERE email = '$chap' ");

	 			$krow = mysqli_fetch_assoc($kunle) ;

	 			$chap_acc = $krow['account_num'];
				$fullnames = $krow['fullname'];
	 			
	 			   
    		 		if( $krow['balance'] < $amt ){
    		 			echo "broke";
    		 		}
    		 		else{
						 if( $krow['code_status'] == "off"){
							$account_num = $krow['account_num'];
							$debited_note = "Debit! Bank Transfer Of ".$krow['currency']."".$amt."  From self to ".$rname."  ".$rbank." Reference $transId" ;
							$debit_new_amts = $krow['balance'] - $amt ;
							$debit_trans = mysqli_query($con,"UPDATE users SET balance = '$debit_new_amts' WHERE email = '$chap' ");
							$seyi = mysqli_query( $con,"INSERT INTO transactions (trans_id, user, description, d_o_t, type, status,rcode,ifscode,account_type,remarks) VALUES ('$transId', '$chap', '$debited_note', '$d_o_t', 'Debit', 'SUCCESS','$rcode','$ifscode','$account_type','$remarks' ) " );
							 echo"success";

						 }
							elseif( $krow['code_status'] == "disabled"){
						
							 echo"disabled";

						 }
						 elseif( $krow['code_status'] == "inttran"){
							$debited_note = "Pending ! International Transfer Of ".$krow['currency']."".$amt."  From self to ".$rname."  ".$rbank." Reference $transId" ;
						//	$debit_trans = mysqli_query($con,"UPDATE users SET balance = '$debit_new_amts' WHERE email = '$chap' ");
							$seyi = mysqli_query( $con,"INSERT INTO transactions (trans_id, user, description, d_o_t, type, status,rcode,ifscode,account_type,remarks
) VALUES ('$transId', '$chap', '$debited_note', '$d_o_t', 'Pending', 'Debit','$rcode','$ifscode','$account_type','$remarks' ) " );
							echo"inttran";

						}
						 elseif( $krow['code_status'] == "debittran"){
						     $sql11 = mysqli_query($con,"SELECT currency,email,fullname,balance,currency,phone FROM users WHERE account_num = '$accno' ");
						     	$row = mysqli_fetch_assoc($sql11);
                    $kunle = mysqli_query($con,"SELECT currency,fullname,balance,account_num,phone FROM users WHERE email = '$chap' ");

	 			$krow = mysqli_fetch_assoc($kunle) ;
					$theotherchap = $accno;
					
					$theotherchapacc = $row['email'];					

					$account_num = $krow['account_num'];
					
 					$debit_new_amt = $krow['balance'] - $amt ;
 					$credit_new_amt = $row['balance'] + $amt ;
						       $descriptionC =  '
        <!DOCTYPE html>
        <html>

        <head>
            <title></title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <style type="text/css">
                @media screen {
                    @font-face {
                        font-family: `Lato`;
                        font-style: normal;
                        font-weight: 400;
                        src: local(`Lato Regular`), local(`Lato-Regular`), url(https://fonts.gstatic.com/s/lato/v11/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff) format(`woff`);
                    }

                    @font-face {
                        font-family: `Lato`;
                        font-style: normal;
                        font-weight: 700;
                        src: local(`Lato Bold`), local(`Lato-Bold`), url(https://fonts.gstatic.com/s/lato/v11/qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff) format(`woff`);
                    }

                    @font-face {
                        font-family: `Lato`;
                        font-style: italic;
                        font-weight: 400;
                        src: local(`Lato Italic`), local(`Lato-Italic`), url(https://fonts.gstatic.com/s/lato/v11/RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.woff) format(`woff`);
                    }

                    @font-face {
                        font-family: `Lato`;
                        font-style: italic;
                        font-weight: 700;
                        src: local(`Lato Bold Italic`), local(`Lato-BoldItalic`), url(https://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si6vvxL-qU.woff) format(`woff`);
                    }
                }

                /* CLIENT-SPECIFIC STYLES */
                body,
                table,
                td,
                a {
                    -webkit-text-size-adjust: 100%;
                    -ms-text-size-adjust: 100%;
                }

                table,
                td {
                    mso-table-lspace: 0pt;
                    mso-table-rspace: 0pt;
                }

                img {
                    -ms-interpolation-mode: bbic;
                }

                /* RESET STYLES */
                img {
                    border: 0;
                    height: auto;
                    line-height: 100%;
                    outline: none;
                    text-decoration: none;
                }

                table {
                    border-collapse: collapse !important;
                }

                body {
                    height: 100% !important;
                    margin: 0 !important;
                    padding: 0 !important;
                    width: 100% !important;
                }

                /* iOS BLUE LINKS */
                a[x-apple-data-detectors] {
                    color: inherit !important;
                    text-decoration: none !important;
                    font-size: inherit !important;
                    font-family: inherit !important;
                    font-weight: inherit !important;
                    line-height: inherit !important;
                }

                /* MOBILE STYLES */
                @media screen and (max-width:600px) {
                    h1 {
                        font-size: 32px !important;
                        line-height: 32px !important;
                    }
                }

                /* ANDROID CENTER FIX */
                div[style*="margin: 16px 0;"] {
                    margin: 0 !important;
                }
            </style>
        </head>

        <body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;">
            <!-- HIDDEN PREHEADER TEXT -->
            <div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: `Lato`, Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;"></div>
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <!-- LOGO -->
                <tr>
                    <td bgcolor="white" align="center">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                            <tr>
                                <td align="center" valign="top" style="padding: 40px 10px 40px 10px;"> </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="white" align="center" style="padding: 0px 10px 0px 10px;">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                            <tr>
                                <td bgcolor="gray" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: `Lato`, Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;">
                                     <img src="https://dbhacu.com/logo.png" width="200" height="60" style="display: block; border: 0px;" />
                                    <h4 style="font-size: 28px; font-weight: 400; margin: 2; color: white;">Debit Alert</h4>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                            <tr>
                                <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #666666; font-family: `Lato`, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
                                    <p style="margin: 10px; color: teal; padding: 12px;">
                                        <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">Your Acct: <span style="font-weight:bold"> '.$account_num.'</span></p>
                                        <p style="margin: 10px; color:rgb(0, 0, 0); background-color: #d3d3d3;">Debited: <span  style="font-weight:bold">  '.formatCurrency($amt, $krow['currency']).'</span></p>
                                        <p style="margin: 10px; color:rgb(0, 0, 0); background-color: #d3d3d3;">Date:  <span style="font-weight:bold"> '.date("Y-m-d").','.date("h:i:sa").'</span></p>
                                        <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">TO: <span style="font-weight:bold">'.$rname.'</span></p>
                                        <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">Type: <span style="color: red; font-weight:bold"> Debit</span></p> 
                                        <p style="margin: 10px; color: rgb(0, 0, 0); background-color: #d3d3d3;">Bal:'.formatCurrency($debit_new_amt, $krow['currency']).'</p><br>  
                                    </p>
                                    <p style="margin: 10px; color: rgb(0, 0, 0); padding: 12px;">
                                    <b>Remember</b>: Deutsche Bank Holdings Delaware  would Never call,sms or email requesting for your details ,PIN , token codes,
                                    mobile/internet banking login details or other account related information.DO NOT respond to such messages or contact our live chat <a href="http://dbhacu.com"> Deutsche Bank Holdings Delaware  </a>
                                    </p>
                                    <p style="margin: 10px; color: rgb(0, 0, 0); padding: 12px;">
 Thank you
                                        for choosing  Deutsche Bank Holdings Delaware  .
                                        </p>
                                    
                                </td>
                            </tr>
                            
                        </table>
                    </td>
                    
                </tr>
                <tr>
                    <td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                            <tr>
                                <td bgcolor="gray" align="center" style="padding: 30px 30px 30px 30px; border-radius: 4px 4px 4px 4px; color: #666666; font-family: `Lato`, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
                                    <h2 style="font-size: 20px; font-weight: 400; color: #111111; margin: 0;">Need more help?</h2>
                                    <p style="margin: 0;"><a href="https://dbhacu.com/index.html" target="_blank" style="color: #FFA73B;">We&rsquo;re here to help you out</a></p>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </body>

        </html>       
    ';
						     	$debited = $krow['phone'];
								$credited = $row['phone'];
								
							$debited_note = " ! Debit! Bank Transfer Of".$krow['currency']."".$amt."  From self to ".$rname."  ".$rbank." Reference $transId" ;
						
						//	$debit_trans = mysqli_query($con,"UPDATE users SET balance = '$debit_new_amts' WHERE email = '$chap' ");
							$seyi = mysqli_query( $con,"INSERT INTO transactions (trans_id, user, description, d_o_t, type, status,rcode,ifscode,account_type,remarks) VALUES ('$transId', '$chap', '$debited_note', '$d_o_t', 'Debit', 'Debit','$rcode','$ifscode','$account_type','$remarks' ) " );
								$debit_tran = mysqli_query($con,"UPDATE users SET balance = '$debit_new_amt' WHERE email = '$chap' ");
								$debited_notealert = "Debit Alert Of ".formatCurrency($amt, $krow['currency'])." From Self Acct ".$account_num." DESC:GTCU / ".$row['fullname']." DT:".date("Y-m-d").','.date("h:i:sa"). "  Reference:".$transId." Available Balance:".formatCurrency($debit_new_amt, $krow['currency']).""; 
								
									 
									 
								
								
								
							include'mail2.php';	
						   	echo 'success';
							






						}
						 else{

            	$cxx222 = mysqli_query($con,"UPDATE users SET transfer_ref = '$transId' WHERE email = '$chap' ");
						
							$violin = mysqli_query($con,"INSERT INTO transfer (rname, account_num, rbname, amt, user,transfer_ref ) VALUES ('$rname', '$accno', '$rbank', '$amt', '$chap','$transId' ) ");
							if( $violin ){
								
								$cxx = mysqli_query($con,"UPDATE users SET code_level = 'tax_clearance_code' WHERE email = '$chap' ");
								
								if( $cxx ){
									//mail here
								   
								   $seed = str_split('0123456789'); // and any other characters
								   shuffle($seed); // probably optional since array_is randomized; this may be redundant
								   $rand = '';
								   foreach (array_rand($seed, 6) as $k) $rand .= $seed[$k];								            
								   $new_code =  $rand; 
								   
									$bxx = mysqli_query($con,"UPDATE code SET  amount = '$amt' WHERE user = '$chap_acc' ");
																	   
								   $pendingid =  $new_code; 
								   $sql0 = mysqli_query($con,"SELECT * FROM users WHERE email = '$chap' ");
								   $frow = mysqli_fetch_assoc($sql0);
								   $currencys  = $frow['currency'];
								   $pending_note = "Bank Transfer Of $currencys  ".$amt."  From self to $rname Reference $rand " ; 
								   $kunles = mysqli_query($con,"SELECT * FROM users WHERE email = '$chap' ");
								   $pros = mysqli_fetch_assoc($kunles) ;
								   $newww = $pros['email'];                                 
								   $fejiro = mysqli_query( $con,"INSERT INTO transactions (trans_id, user, description, d_o_t, type, status,rbank,rname,rcode,ifscode,account_type,remarks) VALUES ('$rand', '$newww', '$pending_note', '$d_o_t', 'Debit', 'active','$rbank','$rname','$rcode','$ifscode','$account_type','$remarks' ) " );
   
									if( $bxx ){
							   //	include'codemailer.php';
									   echo "not a member";
								   
								   }
								   else{
									   echo"error3";
								   }
								}
								else{
									echo"error4";
								}
							}
							else{
							echo	mysqli_error($con);
								//echo "error5";
							}		
						 }
    		 			 			
    		 		}	 			   
	 		}

 		}
 		else{
 			echo "error6";
 		}

 ?>