<?php

require __dir__ . '/init.php';

$bx = beneficiary_of( $__user['id'], "method = 'international'" );

events::addListener("@header", function() {
	echo "<style>
		[data-sbx] {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
		}
	</style>";
});

template::get_header();

?>
	
	<?php template::title("International Wire Transfer"); ?>

	<div class="row">
		<div class="col-lg-12">
			<div class="sparkline12-list shadow-reset mg-t-30">
			
				<div class="sparkline12-hd">
					<div class="main-sparkline12-hd">
						<button class="btn btn-primary">
						International Wire Transfer
						</button> &nbsp;&nbsp; 
						<a href="md.php"><button class="btn btn-primary">Mobile Deposit</button></a>	
					</div>
				</div>
				
				<div class='my-4'></div>
				
				<div class="sparkline12-graph">
					<div class="basic-login-form-ad">
						<div class="row">
							<div class="col-lg-12">
								<div class="all-form-element-inner">
								
									<form action="im.php" method="post">
									
										<?php 
											template::alert( $_SESSION['transfer_error'] ?? null, 'warning' ); 
											if( isset($_SESSION['transfer_error']) ) unset($_SESSION['transfer_error']);
										?>
										
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">From</label>
												</div>
												<div class="col-lg-6">
													<select type="text" class="form-control">
														<option value="<?php echo $__user['acctno'] ?>">
															<?php echo $__user['acctno'] ?> &nbsp;| &nbsp;$<?php echo number_format($__user['balance']); ?>
														</option>
													</select>
												</div>
											</div>
										</div>
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Date</label>
												</div>
												<div class="col-lg-3">
													<input type="text" name="date" value="<?php echo date("m-d-y");?>" readonly="true" class="form-control" />
												</div>
											</div>
										</div>
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Amount</label>
												</div>
												<div class="col-lg-6">
													<input type="double" name="amount" id="amount" class="form-control mb-1" />
													<input type="double" id="charge-display" placeholder="Transaction charges is displayed here" readonly="true" class="form-control">
												</div>
											</div>
										</div>
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Beneciary</label>
												</div>
												<div class="col-lg-6">
													<input type="text" class="form-control" name="beneficiary"  maxlength="160" value=""  placeholder="Beneficiary's Name or Organization Name"/>
													<?php if( !empty($bx) ): ?>
														<a href='javascript:void(0)' class='mt-1 d-inline-block' data-toggle="modal" data-target="#beneficiary-modal">
															<i class='far fa-star'></i> Choose Beneficiary
														</a><!-- Button trigger modal -->
													<?php endif; ?>
												</div>
											</div>
										</div>
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Beneficiary Account</label>
												</div>
												<div class="col-lg-6">
													<input type="text"  name="tacctno" placeholder='Account No' class="form-control" />
												</div>
											</div>
										</div>
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Beneficiary Country</label>
												</div>
												<div class="col-lg-3">
													<?php help::countries_dropdown(); ?>
												</div>
											</div>
										</div>
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Beneficiary Bank Name</label>
												</div>
												<div class="col-lg-3">
													<input name='bank_name' type='text' class='form-control' placeholder='Bank Name' required>
												</div>
											</div>
										</div>
										<input type="hidden" name="swift" value="4521369875" />
										<input type="hidden" name="description" value="" />
										<input type="hidden" name="method" value="international" />
										<div class='form-group'>
											<div class='row'>
												<div class='col-lg-9 ml-auto'>
													<div class='form-check'>
														<input type='hidden' name="save_beneficiary" value='0'>
														<input type='checkbox' class='form-check-input' id='benz' name="save_beneficiary" value='1'>
														<label class='form-check-label' for='benz'>Save Beneficiary</label>
													</div>
												</div>
											</div>
										</div>
										<div class="form-group">
											<div class="row">
												<div class="col-lg-3">
													<label class="login2 pull-right pull-right-pro">Details</label>
												</div>
												<div class="col-lg-6">
													<textarea name="comments" type="text" class="form-control" rows="3" placeholder="Narration" ></textarea>
												</div>
											</div>
										</div>
										<div>
											<label class="checkbox">
												<input type="checkbox" class="form-controls" name="condition" required>
												<p>
													<span class="short-content">I agree with terms and conditions of international payments</span>
												</p>
											</label>
											<div class="hidden condition-details" name="conditiond">
											</div>
										</div>
										<div class="form-group">
											<div class="login-btn-inner">
												<div class="row">
													<div class="col-lg-3"></div>
													<div class="col-lg-6">
														<div class="login-horizental cancel-wp pull-left">
															<button class="btn btn-sm btn-primary login-submit-cs" name="transfer" type="submit">Transfer</button>
														</div>
													</div>
												</div>
											</div>
										</div>
										
									</form>
									
								</div>
							</div>
						</div>
					</div>
				</div>
				
			</div>
		</div>
	</div>


<?php 
	
	if( !empty($bx) ) require_once __dir__ . '/sections/beneficiary-modal.php';
	
	events::addListener("@footer", function() { 
		global $settings;
		$ch = $settings->get('charges');
?>
<script>
	$("#amount").on('input', function() {
		var charges = <?php echo empty($ch) ? 0 : (int)$ch; ?>;
		var output = Number(this.value) * charges * 0.01;
		if( isNaN(output) ) return;
		else output = output.toFixed(2);
		$("#charge-display").val( `\$${output} Charges` );
	});
</script>
<?php }); ?>


<?php template::get_footer(); ?>  