<div class="form-group">
	<label class="col-sm-4 control-label" for="accountFrom">User Bank Account *</label>
	<div class="col-sm-8">
		<select name="accountFrom" id="accountFrom" class="form-control required" onchange="return change_acct_det_trans_money(this.value);">
			<?php foreach($user_accounts_listing as $accts_dets){?>
			<option value="<?php echo $accts_dets->account_id;?>"><?php echo $accts_dets->account_no.' - '.$this->config->item('bank_account_types_array_config')[$accts_dets->account_category]['name'].' ['.number_format($accts_dets->available_balance, 2).' '.$this->config->item('amt_currencies_array_config')[$accts_dets->account_cur]['name'];?> ]</option>
			<?php } ?>
		</select>
	</div>
</div>

<div class="form-group">
	<label class="col-sm-4 control-label" for="accountTo">Existing Beneficiary Account *</label>
	<div class="col-sm-8">
		<select class="form-control required" id="accountTo" name="accountTo" onchange="return chkOther(this.value);">
			<option value="">Select....</option>
<?php foreach($beneficiary_accounts as $res){?>
<option value="<?php echo $res['bef_iban_no'].'|'.$res['bef_account_name'].'|'.$res['bef_image'];?>"><?php echo $res['bef_iban_no'].' - '.$res['bef_account_name'];?></option>
<?php } ?>
<option value="other">Other</option>
		</select>
	</div>
</div>

<div id="bef_details" style="display:none;">
	<div class="form-group">
		<label class="col-sm-4 control-label" for="inputEmail3">Beneficiary Name *</label>
		<div class="col-sm-8">
			<input type="text" class="form-control benCls" id="uf_account_name" name="uf_account_name" placeholder="" value="" />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-4 control-label" for="inputEmail3">Beneficiary IBAN/Account Number *</label>
		<div class="col-sm-8">
			<input type="text" class="form-control benCls" id="uf_iban_no" name="uf_iban_no" placeholder="" value="" />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-4 control-label" for="inputEmail3">Beneficiary Bank BIC/Swift Code *</label>
		<div class="col-sm-8">
			<input type="text" class="form-control benCls" id="uf_bank_btc" name="uf_bank_btc" placeholder="" value="" />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-4 control-label" for="inputEmail3">Beneficiary Bank Name *</label>
		<div class="col-sm-8">
			<input type="text" class="form-control benCls" id="uf_bank_name_address" name="uf_bank_name_address" placeholder="" value="" />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-4 control-label" for="inputEmail3">Bank Address *</label>
		<div class="col-sm-8">
			<input type="text" class="form-control benCls" id="uf_bank_address" name="uf_bank_address" placeholder="" value="" />
		</div>
	</div>
</div>

<div class="form-group">
	<label class="col-sm-4 control-label" for="uf_transfer_amt">Amount *</label>
	<div class="col-sm-8">
		<input type="number" class="form-control required" id="uf_transfer_amt" name="uf_transfer_amt" placeholder="Enter the Amount you want to transfer." value="" />
	</div>
</div>

<div class="form-group">
	<label class="col-sm-4 control-label" for="uf_transfer_remark">Payment Description *</label>
	<div class="col-sm-8">
		<input type="text" class="form-control required" id="uf_transfer_remark" name="uf_transfer_remark" placeholder="" value="" />
	</div>
</div>

<div class="form-group">
	<label class="col-sm-4 control-label" for="dueDate">Payment Due Date *</label>
	<div class="col-sm-8">
		<input type="text" class="form-control required" id="dueDate" name="uf_paymentDue" placeholder="" value="" />
	</div>
</div>


<div class="form-group">
	<button type="submit" id="submitBtn" class="btn btn-primary">Send Money</button>
</div>

<script>
$(document).ready(function(){
	$('#debitFrm').validate({
		ignore: [], 
		highlight: function(element) {
			$(element).closest('.form-group').removeClass('has-success').addClass('has-error'); 
		},
		success: function(element) {
			element.closest('.form-group').removeClass('has-error');
			element.remove();
		},
		submitHandler: function(form){
			var site_base_url = $('#h_base_url').val();
			var form = $('#debitFrm');
			var url = site_base_url+form.attr('action');
			$.ajax({
				type: "POST",
				url: url,
				data: form.serialize(), // serializes the form's elements.
				beforeSend: function(){
					$('#submitBtn').html('Sending <i class="fa fa-spinner fa-spin"></i>');
				},
				success: function(result, status, xhr){//alert(result);
					var resultArr = result.split('|');
					if(resultArr[0]=='success'){
						window.location=site_base_url+'transactions';
					}else{
						$("html, body").animate({ scrollTop: 0 }, "slow");
						$('#result_display').html('<div class="alert alert-danger">'+result+'</div>');
						$('#submitBtn').html('Send Money');
					}
				},
				error: function(xhr, status, error_desc){				
					$("html, body").animate({ scrollTop: 0 }, "slow");
					$('#result_display').html('<div class="alert alert-danger">'+error_desc+'</div>');
					$('#submitBtn').html('Send Money');
				}
			});		
			return false;
		}
	});
	$('#dueDate').datepicker({
		format: "mm/dd/yyyy",
		autoclose: true,
		todayHighlight: true
	});
});
</script>			