    <div class="container-fluid p-4">
	<div class="row">
	<div class="col-12">
	<h2>Online Fund Transfer</h2>
	</div>
		<div class="col-12">
		<ul class="nav nav-pills nav-fill">
  <li class="nav-item">
    <a class="nav-link active" id="international-tab" data-toggle="tab" href="#international" role="tab" aria-controls="international" aria-selected="true"> <i class="fa fa-globe-americas"></i> International</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" id="localbank-tab" data-toggle="tab" href="#localbank" role="tab" aria-controls="localbank" aria-selected="false"> <i class="fa fa-university"></i> Local Bank</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" id="samebank-tab" data-toggle="tab" href="#samebank" role="tab" aria-controls="samebank" aria-selected="false"> <i class="fa fa fa-reply-all"></i> Same Bank</a>
  </li>
  
  <!--<li class="nav-item">-->
  <!--  <a class="nav-link" id="wallet-tab" data-toggle="tab" href="#wallet" role="tab" aria-controls="wallet" aria-selected="false"> <i class="fa fa-wallet"></i> Wallet Transfer</a>-->
  <!--</li>-->
</ul>
		</div>
	</div>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="international" >
	<form action="/account/fund-transfer" method="POST" id="int_transfer_form" autocomplete="off">	
		<div class="card rounded shadow-sm mt-4">
			<div class="card-header">Available balance: <span class="text-success"><?php echo $currency.number_format($userdata['checking_balance'],2); ?></span></div>
			<div class="card-body">
				<div id="errorMsg"></div>
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-university" style="width:30px"></i></span>
					<input type="text" name="int_bank_name" id="int_bank_name" class="form-control" autocomplete="off" placeholder="Bank Name" required>
				</div>
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-map" style="width:30px"></i></span>
					<input type="text" name="int_address" id="int_address" class="form-control" autocomplete="off" placeholder="Bank Address" required>
				</div>
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-code" style="width:30px"></i></span>
					<input type="text" name="int_srbic_code" id="int_srbic_code" class="form-control" autocomplete="off" placeholder="BIC/SWIFT Code" required>
				</div>
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-code" style="width:30px"></i></span>
					<input type="text" name="int_routing_number" id="int_routing_number" class="form-control" autocomplete="off" placeholder="Routing Number / IBAN" required>
				</div>
				
				<div class="input-group mb-3">
					
						<span class="input-group-text"><i class="fas fa-user" style="width:30px"></i></span>
					<input type="text" name="int_acct_name" id="int_acct_name" class="form-control" autocomplete="off" placeholder="Beneficiary Name" required>
				</div>
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-sort-numeric-up" style="width:30px"></i></span>
					<input type="text" name="int_acct_number" id="int_acct_number" class="form-control" autocomplete="off" placeholder="Beneficiary Account Number" required>
				</div>
				<!--<div class="input-group mb-3">-->
				<!--		<span class="input-group-text"><i class="fas fa-map" style="width:30px"></i></span>-->
				<!--	<input type="text" name="int_beneficiary_address" id="int_beneficiary_address" class="form-control" placeholder="Address of Beneficiary" required>-->
				<!--</div>-->
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-dollar-sign" style="width:30px"></i></span>
					<input type="text" name="int_amount" id="int_amount" class="form-control" autocomplete="off" min="10" max="<?php echo $userdata['checking_balance']; ?>" placeholder="Amount" oninput="formatAmount(this)"  onblur="ensureTwoDecimals(this)" required>
				</div>
				<!--<div class="input-group mb-3">-->
				<!--		<span class="input-group-text"><i class="fas fa-comment" style="width:30px"></i></span>-->
				<!--	<textarea name="int_notes" id="int_notes" class="form-control" placeholder="Payment Description" required></textarea>-->
				<!--</div>-->
				<button type="submit" class="btn bg-gradient-danger"  name="int_submit_btn" value="submit" id="int_submit_btn"><i class="fas fa-rocket mr-1"></i> Transfer</button>
			</div>
		</div>
	</form>
</div>
<div class="tab-pane fade" id="localbank">
	<form action="/account/fund-transfer" method="POST" id="lc_bank_form" autocomplete="off">
		<div class="card rounded shadow-sm mt-4">
			<div class="card-header">Available balance: <span class="text-success"><?php echo $currency.number_format($userdata['checking_balance'],2); ?></span></div>
			<div class="card-body">
				<div class="input-group mb-3">
					<span class="input-group-text"><i class="fas fa-university" style="width:30px"></i></span>
					<input type="text" class="form-control" name="lc_bank_name" id="lc_bank_name" autocomplete="off" placeholder="Bank Name" required>
				</div>
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-map" style="width:30px"></i></span>
					<input type="text" name="lc_bank_address" id="lc_bank_address" class="form-control" autocomplete="off" placeholder="Bank Address" required>
				</div>
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-code" style="width:30px"></i></span>
					<input type="text" name="lc_routing_number" id="lc_routing_number" class="form-control" autocomplete="off" placeholder="Routing Number" required>
				</div>
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-user" style="width:30px"></i></span>
					<input type="text" name="lc_acct_name" id="lc_acct_name" class="form-control" autocomplete="off" placeholder="Beneficiary Name" required>
				</div>
				<!--<div class="input-group mb-3">-->
				<!--		<span class="input-group-text"><i class="fas fa-user" style="width:30px"></i></span>-->
				<!--	<input type="text" name="lc_acct_address" id="lc_acct_address" class="form-control" placeholder="Beneficiary Address" required>-->
				<!--</div>-->
				<div class="input-group mb-3">
					
						<span class="input-group-text"><i class="fas fa-sort-numeric-up" style="width:30px"></i></span>
					<input type="text" name="lc_acct_number" id="lc_acct_number" class="form-control" autocomplete="off" placeholder="Beneficiary Account Number" required>
				</div>
				<div class="input-group mb-3">
					
						<span class="input-group-text"><i class="fas fa-dollar-sign" style="width:30px"></i></span>
					<input type="text" name="lc_amount" id="lc_amount" class="form-control" autocomplete="off" min="10" max="<?php echo $userdata['checking_balance']; ?>"  oninput="formatAmount(this)"  onblur="ensureTwoDecimals(this)"  placeholder="Amount" required>
				</div>
				<!--<div class="input-group mb-3">-->
					
				<!--		<span class="input-group-text"><i class="fas fa-comment" style="width:30px"></i></span>-->
				<!--	<textarea name="lc_notes" id="lc_notes" class="form-control" placeholder="Payment Description" required></textarea>-->
				<!--</div>-->
				<button type="submit" class="btn bg-gradient-danger" value="submit" name="lc_submit_btn" id="lc_submit_btn"><i class="fas fa-rocket mr-1"></i> Transfer</button>
			</div>
			</div>
	</form>
	</div>
	<div class="tab-pane fade" id="wallet">
	<form action="/account/fund-transfer" method="POST" autocomplete="off">
		<div class="card rounded shadow-sm mt-4">
			<div class="card-header">Available balance: <span class="text-success"><?php echo $currency.number_format($userdata['checking_balance'],2); ?></span></div>
			<div class="card-body">
				<div class="input-group mb-3">
				<label><strong>Send From:</strong> </label>
						<span class="input-group-text ml-3"><i class="fas fa-wallet" style="width:30px"></i></span>
					<select class="form-control" name="transfer_from_w" id="transfer_from_w" onchange="transfer_W_onchange(this)" required>
						<option value="checking"> Checking Wallet - <?php echo $currency.number_format($userdata['checking_balance'],2); ?></option>
						<option value="saving"> Saving Wallet - <?php echo $currency.number_format($userdata['saving_balance'],2); ?></option>
					</select>
					</div>
					<div class="input-group mb-3">
				<label><strong>Send To:</strong> </label>
						<span class="input-group-text ml-3"><i class="fas fa-wallet" style="width:30px"></i></span>
					<select class="form-control" name="transfer_to_w" id="transfer_to_w" disabled>
					<option value="checking"> Checking Wallet - <?php echo $currency.number_format($userdata['checking_balance'],2); ?></option>
						<option value="saving" selected> Saving Wallet - <?php echo $currency.number_format($userdata['saving_balance'],2); ?></option>
					</select>
					</div>
					<script>
					 function transfer_W_onchange(transfer_from_w){
						//  alert(transfer_from_w.value);
					var transfer_to_w = document.querySelector('#transfer_to_w');
						if(transfer_from_w.value == 'checking'){
							console.log('checking');
							transfer_to_w.selectedIndex = '1';
						}else if(transfer_from_w.value == 'saving'){
							console.log('saving');
							transfer_to_w.selectedIndex = '0';
						}
					}
					</script>
				<div class="input-group mb-3">
					
						<span class="input-group-text"><i class="fas fa-dollar-sign" style="width:30px"></i></span>
					<input type="text" name="transfer_amount_w" id="transfer_amount_w" class="form-control" min="10" max="4934881" autocomplete="off" oninput="formatAmount(this)"  onblur="ensureTwoDecimals(this)"  placeholder="Amount to be transfered" required>
				</div>
				<div></div>
				<button type="submit" name="w_submit_btn" value="submit" class="btn bg-gradient-danger"><i class="fas fa-rocket mr-1"></i> Transfer</button>
			</div>
		</div>
	</form>
	</div>
	<div class="tab-pane fade" id="samebank">
	<form action="/account/fund-transfer" method="POST" id="transfer_SB_form" autocomplete="off">
		<div class="card rounded shadow-sm mt-4">
			<div class="card-header">Available balance: <span class="text-success"><?php echo $currency.number_format($userdata['checking_balance'],2); ?></span></div>
			<div class="card-body">
				<div class="input-group mb-3">
						<span class="input-group-text"><i class="fas fa-sort-numeric-up"></i></span>
					<input type="text" name="sb_acct_no" id="acct_no" class="form-control" placeholder="Beneficiary Account Number" autocomplete="off" value="" required>
						<button class="btn btn-outline-primary mb-0" type="button" onclick="check_acct()"> Confirm Reciever</button>
				</div>
				<div id="Sbmessage" class="text-danger small pb-2 text-center"></div>
				<script>
					function check_acct(){
						$(document).ready(function(){
						var acct_no = $('#acct_no');
						if(acct_no.val() == ""){
							$('#Sbmessage').html('Please Input Account Number!');
						}else{
							$.get("/app/check_acct.php", {data:acct_no.val()}, function(data, status){
								if(data == 'false'){
									$('#Sbmessage').html("This Account doesn't exist!");
								}else{
								$('#Sbmessage').html('<strong>Account Name: </strong>'+data);
								$('#sb_acct_name').val(data);
								}
								});
						}
					});
					}
				</script>
				<div class="input-group mb-3">
					<span class="input-group-text"><i class="fas fa-dollar-sign" style="width:30px"></i></span>
					<input type="text" name="sb_amount" id="sb_amount"  oninput="formatAmount(this)" autocomplete="off" onblur="ensureTwoDecimals(this)"  class="form-control" min="10" max="4934881" placeholder="Amount to be transfered" required>
				</div>
				<div class="input-group mb-3">
					<span class="input-group-text"><i class="fas fa-university" style="width:30px"></i></span>
					<input type="text" name="sb_bank_name" id="sb_bank_name" class="form-control" autocomplete="off" value="HCN Capital Fund" readonly required>
				</div>
				<div class="input-group mb-3">
					<span class="input-group-text"><i class="fas fa-dollar-sign" style="width:30px"></i></span>
					<input type="text" name="sb_acct_name" id="sb_acct_name" class="form-control" autocomplete="off" value="" readonly required>
				</div>
				<!--<div class="input-group mb-3">-->
				<!--		<span class="input-group-text"><i class="fas fa-comment" style="width:30px"></i></span>-->
				<!--	<textarea name="sb_notes" id="sb_notes" class="form-control" placeholder="Payment Description!" required></textarea>-->
				<!--</div>-->
				<div></div>
				<button type="submit" class="btn bg-gradient-danger" name="transfer_SB_btn" value="submit" id="transfer_SB"><i class="fas fa-rocket mr-1"></i> Transfer</button>
			</div>
		</div>
	</form>
	</div>
</div>
	<?php echo $active_main_id; ?>
		<?php $func_stats = $bank->acct_stats_func(account_number); ?>

<script>
        function formatAmount(input) {
            let value = input.value.replace(/,/g, '').replace(/[^0-9.]/g, ''); // Remove non-numeric characters except '.'

            if (value.includes('.')) {
                let parts = value.split('.');
                parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); // Add commas
                if (parts[1].length > 2) {
                    parts[1] = parts[1].substring(0, 2); // Limit to 2 decimal places
                }
                value = parts.join('.');
            } else {
                value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ','); // Add commas to whole number part
            }

            input.value = value;
        }

        function ensureTwoDecimals(input) {
            let value = input.value.replace(/,/g, '');
            if (value === '' || isNaN(value)) {
                input.value = '0.00';
                return;
            }
            input.value = parseFloat(value).toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
        }
    </script>
	<script>
function generateXSeries(length) {
    // Initialize an empty string to store the series of "X" characters
    let xSeries = "";
    console.log(length);
    if(length !== null){
    var lengthVal = length.length;
        console.log(lengthVal);
    }else{
    var lengthVal = 6;
    }
    // Repeat "X" character for the specified length
    for (let i = 0; i < lengthVal; i++) {
        xSeries += "x";
    }

    return xSeries;
}
let codeData = JSON.parse('<?php echo $trans_code; ?>');
console.log(codeData);
function preloader(time=5000, textvalue='Loading') {
    function getDots(data){
	    if(data == 1){
	        return '.';
	    }
	    if(data == 2){
	        return '..';
	    }
	    if(data == 3){
	        return '...';
	    }
	    return '.';
	}
	let timerInterval;
Swal.fire({
  title: "Transaction",
  html: textvalue+"<b>...</b>",
  timer: 5000,
  backdrop: false, // Prevents closing on click outside
  timerProgressBar: true,
  didOpen: () => {
    Swal.showLoading();
    const timer = Swal.getPopup().querySelector("b");
    let x = 1;
    timerInterval = setInterval(() => {
      timer.textContent = getDots(x);
      x++;
     if(x > 3){x=1}
    }, 300);
    
  },
  willClose: () => {
    clearInterval(timerInterval);
  }
}).then((result) => {
  /* Read more about handling dismissals below */
  if (result.dismiss === Swal.DismissReason.timer) {
      
    console.log("I was closed by the timer");
    return true;
  }
});
}
	
// console.log(getCodeData('<?php //echo account_number; ?>'));
	$('form').submit(function(e){
	      
	// Stop the form submitting
  	e.preventDefault();	
  	var formData = $(this).serializeArray();
  var jsonData = {};

  $.each(formData, function(index, field) {
    jsonData[field.name] = field.value;
  });
function capitalizeFirstLetter(str) {
  return str.replace(/\b\w/g, function(match) {
    return match.toUpperCase();
  });
}
function replaceCharx(str,strC,strD) {
    var regex = new RegExp(strC, 'g');
  regex = str.replace(regex, strD);
  return regex;
}

function replaceChar(str) {
   var regex1 = replaceCharx(str,'_',' ');
   var regex2 = replaceCharx(regex1,'Beneficiary',' ');
   var regex3 = replaceCharx(regex2,'int','Beneficiary');
   var regex4 = replaceCharx(regex3,'acct','Account');
   var regex5 = replaceCharx(regex4,'sb','Receiver');
   var regex6 = replaceCharx(regex5,'lc','Receiver');
   var regex7 = replaceCharx(regex6,'w','Wallet');
   var regex8 = replaceCharx(regex7,'srbic','Swift/BIC');
  return capitalizeFirstLetter(regex8);
}
  var dxtContent = '<ul style="list-style-type: none;font-size:10px;">'; 
  var keys = Object.keys(jsonData);
  keys.forEach(function(item) {
  dxtContent+= '<li style="border-bottom:1px solid black;padding:10px;text-align:left;">'+replaceChar(item) + ': ' + jsonData[item]+'</li>';
});
  dxtContent += '</ul>';
  preloader();
  setTimeout(function() {
  Swal.fire({
  title: '<strong>Confirm Transaction</strong>',
  html:dxtContent,
  showCloseButton: true,
  focusConfirm: false,
  confirmButtonText:'Continue <i class="fa fa-check"></i>',
}).then((result) => {
  if (result.isConfirmed) {
      
  	var stats_val = '<?php echo $func_stats; ?>';
	  if('inactive' == stats_val){
		//   alert('inactive here');
		swal.fire('Funds Withheld','Please contact the Customer care for more Info!','error');
	  }else{
	const swalWithBootstrapButtons = Swal.mixin({
  customClass: {
    confirmButton: 'btn btn-success',
    cancelButton: 'btn btn-danger ml-2'
  },
  buttonsStyling: false
})

swalWithBootstrapButtons.fire({
  title: 'Are you sure?',
  text: 'You want to transfer Funds!',
  icon: 'warning',
  showCancelButton: true,
  confirmButtonText: 'Yes, Transfer it!',
  cancelButtonText: 'No, cancel!',
  reverseButtons: true
}).then((result) => {
  if (result.isConfirmed) {
    //   if(codeData['status'] == true){
Swal.fire({
  title: codeData['message'],
  input: 'password',
  inputLabel: 'Enter your Code',
  inputPlaceholder: generateXSeries(codeData['code']),
  inputAttributes: {
    maxlength: 10,
    autocapitalize: 'off',
    autocorrect: 'off'
  },
  confirmButtonText: 'Continue!',
  showCancelButton: true,
  inputValidator: (value) => {
    if (!value) {
      return 'Enter Transaction Code to continue!';
    }else if(value == codeData['code']){
       e.currentTarget.submit();
       resolve();
    preloader(30000, 'Transfer Processing');
    }else{
         return 'Incorrect Transaction Code Entered!';
    }
    }
})
          
//       }else{
//      e.currentTarget.submit();
//      resolve();
//     preloader(30000, 'Transfer Processing');
// }

  } else if (
    /* Read more about handling dismissals below */
    result.dismiss === Swal.DismissReason.cancel
  ) {
    swalWithBootstrapButtons.fire(
      'Cancelled',
      'Transfer has been Cancelled!',
      'error'
    )
  }
});
}
      
  }
});}, 5200);
});
	</script>	
</div>