<!-- Modal -->
<div class="modal fade" id="beneficiary-modal" tabindex="-1" role="dialog" aria-labelledby="beneficiary-modal" aria-hidden="true">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" id="beneficiary-modal">Choose Beneficiary</h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
				<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<div class="modal-body">
			
				<div class='search-bx d-none'>
					<input type='text' placeholder='search beneficiary' class='form-control'>
				</div>
				
				<?php 
					foreach( $bx as $beneficiary ):
				?>
					<div class='d-flex p-2 my-2 border text-muted text-nowrap text-truncate '>
						<div class='pr-3'>
							<a href='javascript:void(0)' class='text-info'>
								<i class='fas fa-university'></i>
							</a>
						</div>
						<div class='position-relative w-100'>
							<div class=''>
								<h6 class='mb-0'><?php echo $beneficiary['name']; ?></h6>
								<p class='mb-0 text-warning'><small><?php echo $beneficiary['account']; ?></small></p>
								<p class='mb-0'><small><?php echo $beneficiary['bank']; ?></small></p>
							</div>
							<a href='javascript:void(0)' data-sbx='<?php echo base64_encode(json_encode($beneficiary)); ?>'></a>
						</div>
					</div>
				<?php endforeach; ?>
				
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
			</div>
		</div>
	</div>
</div>

<?php
	events::addListener("@footer", function() {
?>
<script>
	$("[data-sbx]").click(function() {
		var info = JSON.parse(atob(this.dataset.sbx));
		$("#beneficiary-modal").modal('hide');
		$("input[name='beneficiary']").val( info.name );
		$("input[name='tacctno']").val( info.account );
		$("select[name='bank_name']").val( info.bank );
		if( $("select[name='country']").length ) {
			$("select[name='country']").val( info.country );
		}
	});
</script>
<?php }); ?>