<?php 

$TCodes = $settings->get('transfer_codes');

if( !empty($__user['acone']) && empty($_POST['secured']) && !empty($TCodes) ):
	
	template::get_header();

	template::title( "Transfer Process" );
	
?>

	<div class='row'>
		<div class='col-lg-8 m-auto'>
				
			<div class='card'>
				<div class='card-body'>
					
					<form method='post' id='code-form'>
						<fieldset>
						
						<?php
							$code_range = array_keys($TCodes);
							foreach( $code_range as $name ):
								$codex = $TCodes[$name];
						?>
						
							<div class='form-group d-none' data-name='<?php echo $name; ?>'>
							
								<label class='form-label'><?php echo strtoupper($name); ?></label>
								<input type='number' class='form-control' name='code' placeholder='Enter <?php echo strtoupper($name); ?> code here' required>
								<input type='hidden' class='form-control' name='type' value='<?php echo $name; ?>'>
								
								<div class='error mt-2 d-none' style='font-size: 12px;'></div>
								
								<div class='mt-2 text-right'>
									<?php if( $codex['code_type'] == 'auto' ): ?>
									<a href='javascript:void(0)' class='text-decoration-none' data-mail='<?php echo $name; ?>'>
										<i class='fa fa-envelope'></i> Get <?php echo strtoupper($name); ?> Code
									</a>
									<?php else: ?>
										Please contact your bank for <?php echo strtoupper($name); ?> code
									<?php endif; ?>
								</div>
								
							</div>
							
							<?php endforeach; ?>
							
							<div class=''>
								<button class='btn btn-primary'>
									Continue
								</button>
							</div>
						
						</fieldset>
					</form>
					
					<form method='post' class='d-none' id='complete-form'>
						<?php foreach( $_POST as $key => $value ): ?>
						<input type='hidden' name='<?php echo $key; ?>' value='<?php echo $value; ?>'>
						<?php endforeach; ?>
						<input type='hidden' name='secured' value='1'>
						<div class='alert alert-info text-center'>
							All security system has been confirm
						</div>
						<button class='btn btn-primary btn-block'>
							Proceed with transfer
						</button>
					</form>
					
					<hr>
					
					<div class="form-group" id="process">
						<div class="progress" style="height:30px">
							<div style="height:30px; width: 0%;" class="progress-bar progress-bar-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">0%
							</div>
						</div>
					</div>
					
				</div>
			</div>
	
		</div>
	</div>
	
	<?php events::addListener("@footer", function() { ?>
		<script src='sections/transfer-codes.js'></script>
	<?php }); ?>
	
<?php
	
	template::get_footer();
	
	exit;
endif;