<div class="page-margin mt-0">
	<div class="wow_content popular_posts_hdr">
		<h2><svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.40417 7.37396C2.96471 5.11653 4.75469 3.37111 7.02514 2.86802L7.40337 2.78421C9.11351 2.40526 10.8858 2.40526 12.596 2.78421L12.9742 2.86802C15.2447 3.37111 17.0346 5.11653 17.5952 7.37396C18.0234 9.09846 18.0234 10.9015 17.5952 12.626C17.0346 14.8835 15.2447 16.6289 12.9742 17.132L12.596 17.2158C10.8858 17.5947 9.11351 17.5947 7.40337 17.2158L7.02514 17.132C4.75469 16.6289 2.96471 14.8835 2.40417 12.626C1.97595 10.9015 1.97595 9.09846 2.40417 7.37396Z" class="icon_main" stroke-width="1.5"/><path d="M7.40337 2.78421C9.11351 2.40526 10.8858 2.40526 12.596 2.78421L12.9742 2.86802C15.2447 3.37111 17.0346 5.11653 17.5952 7.37396C18.0234 9.09846 18.0234 10.9015 17.5952 12.626C17.0346 14.8835 15.2447 16.6289 12.9742 17.132L12.596 17.2158C10.8858 17.5947 9.11351 17.5947 7.40337 17.2158L7.02514 17.132C4.75469 16.6289 2.96471 14.8835 2.40417 12.626C2.19006 11.7638 2.08301 10.8819 2.08301 10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path fill-rule="evenodd" clip-rule="evenodd" d="M10.0002 5.83301C10.3188 5.83301 10.5771 6.07633 10.5771 6.37649V6.82112H10.641C11.7139 6.82112 12.5 7.6998 12.5 8.68212C12.5 8.98228 12.2417 9.2256 11.9231 9.2256C11.6045 9.2256 11.3462 8.98228 11.3462 8.68212C11.3462 8.20915 10.9842 7.90808 10.641 7.90808H10.5771V9.61905L11.3561 9.88588C12.0639 10.1284 12.5 10.7878 12.5 11.4862C12.5 12.3752 11.7876 13.1782 10.8055 13.1782H10.5771V13.6229C10.5771 13.923 10.3188 14.1663 10.0002 14.1663C9.68158 14.1663 9.42328 13.923 9.42328 13.6229V13.1782H9.35897C8.28606 13.1782 7.5 12.2995 7.5 11.3172C7.5 11.017 7.7583 10.7737 8.07692 10.7737C8.39555 10.7737 8.65385 11.017 8.65385 11.3172C8.65385 11.7901 9.01577 12.0912 9.35897 12.0912H9.42328V10.3804L8.64393 10.1134C7.93608 9.87093 7.5 9.21149 7.5 8.51309C7.5 7.62412 8.21243 6.82112 9.1945 6.82112H9.42328V6.37649C9.42328 6.07633 9.68158 5.83301 10.0002 5.83301ZM9.42328 7.90808H9.1945C8.94213 7.90808 8.65385 8.13347 8.65385 8.51309C8.65385 8.80339 8.83339 9.02172 9.03825 9.09189L9.42328 9.22379V7.90808ZM10.5771 10.7756V12.0912H10.8055C11.0579 12.0912 11.3462 11.8658 11.3462 11.4862C11.3462 11.1959 11.1666 10.9776 10.9618 10.9074L10.5771 10.7756Z" class="icon_main_fill"/></svg>&nbsp;<?php echo $wo['lang']['my_earnings'] ?> <?php echo Wo_GetCurrency($wo['config']['ads_currency']) . number_format($wo['setting']['balance'], 2);?></h2>
	</div>
</div>

<div class="wo_settings_page wow_content">
  
	<?php if ($wo['setting']['balance'] < $wo['config']['m_withdrawal']): ?>
	<div class="alert alert-danger">
		<?php 
			$your_balance = str_replace('{balance}',  $wo['setting']['balance'], $wo['lang']['your_funds_balance']); 
			$your_balance = str_replace('{m_withdrawal}',  $wo['config']['m_withdrawal'], $your_balance); 
			$your_balance = str_replace('$', Wo_GetCurrency($wo['config']['ads_currency']), $your_balance);
			
		?>
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-triangle"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12" y2="17"></line></svg> <?php echo $your_balance;?>
	</div>
	<?php endif ?>
	<div class="alert alert-warning"><?php echo $wo['lang']['wallet_not_withdrawable'] ?></div>
  
	<form class="setting-general-form form-horizontal" method="post">
		<div class="setting-general-alert setting-update-alert"></div>
		
		<div class="row">
				<div class="col-md-12">
					<div class="wow_form_fields">
						<label for="withdraw_method"><?php echo $wo['lang']['withdraw_method']; ?></label>  
						<select id="withdraw_method" name="withdraw_method" class="form-control" onchange="Wo_ShowWithdrawMethod(this)">
							<?php 
							$first = 0;
							foreach ($wo['config']['withdrawal_payment_method'] as $key => $value) { 
								if ($value == 1) {
									if ($first == 0) {
										$first = $key;
									}
									if ($key != 'custom') { ?>
										<option value="<?php echo $key; ?>"><?php echo $wo['lang'][$key]; ?></option>
							<?php	}elseif(!empty($wo['config']['custom_name'])){ ?>
								    <option value="<?php echo $key; ?>"><?php echo $wo['config']['custom_name']; ?></option>
							<?php }}} ?>
						</select>
					</div>
				</div>
			<div class="paypal_withdrawal" <?php echo($first == 'paypal' ? '' : 'style="display: none;"'); ?>>
				<div class="col-md-6">
					<div class="wow_form_fields">
						<label for="paypal_email"><?php echo $wo['lang']['paypal_email']; ?></label>  
						<input id="paypal_email" name="paypal_email" type="text" class="form-control input-md" value="<?php echo $wo['setting']['email']?>" autocomplete="off">
						<span class="help-block checking"></span>
					</div>
				</div>
			</div>
			<div class="transfer_to_withdrawal" <?php echo(($first == 'skrill' || $first == 'custom') ? '' : 'style="display: none;"'); ?>>
				<div class="col-md-6">
					<div class="wow_form_fields">
						<label for="transfer_to"><?php echo $wo['lang']['transfer_to']; ?></label>
						<input name="transfer_to" id="transfer_to" type="text" class="form-control input-md">
						<span class="help-block checking"></span>
					</div>
				</div>
			</div>
			<div class="col-md-6">
				<div class="wow_form_fields">
					<label for="amount"><?php echo $wo['lang']['amount']; ?></label>  
					<input name="amount" id="amount" type="text" class="form-control input-md" value="<?php echo $wo['setting']['balance'];?>">
				</div>
			</div>
				<div class="bank_withdrawal" <?php echo($first == 'bank' ? '' : 'style="display: none;"'); ?>>
					<div class="col-md-6">
						<div class="wow_form_fields">
							<label for="iban"><?php echo $wo['lang']['iban']; ?></label>  
							<input name="iban" id="iban" type="text" class="form-control input-md">
						</div>
					</div>
					<div class="col-md-6">
						<div class="wow_form_fields">
							<label for="country"><?php echo $wo['lang']['country']; ?></label>  
							<input name="country" id="country" type="text" class="form-control input-md">
						</div>
					</div>
					<div class="col-md-6">
						<div class="wow_form_fields">
							<label for="full_name"><?php echo $wo['lang']['full_name']; ?></label>  
							<input name="full_name" id="full_name" type="text" class="form-control input-md">
						</div>
					</div>
					<div class="col-md-6">
						<div class="wow_form_fields">
							<label for="swift_code"><?php echo $wo['lang']['swift_code']; ?></label>  
							<input name="swift_code" id="swift_code" type="text" class="form-control input-md">
						</div>
					</div>
					<div class="col-md-12">
						<div class="wow_form_fields">
							<label for="address"><?php echo $wo['lang']['address']; ?></label>  
							<textarea name="address" id="address" type="text" class="form-control input-md"></textarea>
						</div>
					</div>
				</div>
		</div>
		<div class="text-center">
			<button type="submit" class="btn btn-main btn-mat btn-mat-raised add_wow_loader"><?php echo $wo['lang']['request_withdrawal']; ?></button>
		</div>
		<input type="hidden" name="user_id" value="<?php echo $wo['setting']['user_id'];?>">
		<input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
	</form>
</div>

<div class="popular_posts_hdr empty">
	<h2>&nbsp;<?php echo $wo['lang']['payment_history']; ?></h2>
</div>

<div class="wow_content page-margin">
	<div class="table-responsive">
		<table class="table table-condensed setting-table wow_pymnt_table">
			<thead>
				<tr>
					<th></th>
					<th><?php echo $wo['lang']['amount']; ?></th>
					<th><?php echo $wo['lang']['requested']; ?></th>
					<th><?php echo $wo['lang']['status']; ?></th>
				</tr>
			</thead>
			<tbody>
				<?php
					$get_payment = Wo_GetPaymentsHistory($wo['setting']['user_id']);
					if (count($get_payment) > 0) {
						foreach ($get_payment as $wo['key'] => $wo['payment']) {
							$wo['key'] = ($wo['key'] + 1);
							$wo['html_class'] = 'label-warning';
							$wo['html_text'] = $wo['lang']['pending'];
							if ($wo['payment']['status'] == 1) {
								$wo['html_class'] = 'label-success';
								$wo['html_text'] = $wo['lang']['approved'];
							} else if ($wo['payment']['status'] == 2) {
								$wo['html_class'] = 'label-danger';
								$wo['html_text'] = $wo['lang']['declined'];
							}
							echo Wo_LoadPage('setting/payment-history');
						}
					}
				?>
			</tbody>
		</table>
	</div>
</div>

<script type="text/javascript">
function Wo_ShowWithdrawMethod(self) {
	if ($(self).val() == 'bank') {
		$('.paypal_withdrawal').slideUp();
		$('.transfer_to_withdrawal').slideUp();
		$('.bank_withdrawal').slideDown();
	}
	else if($(self).val() == 'paypal'){
		$('.bank_withdrawal').slideUp();
		$('.transfer_to_withdrawal').slideUp();
		$('.paypal_withdrawal').slideDown();
	}
	else{
		$('.bank_withdrawal').slideUp();
		$('.transfer_to_withdrawal').slideDown();
		$('.paypal_withdrawal').slideUp();
	}
}
$(function() {
  $('form.setting-general-form').ajaxForm({
    url: Wo_Ajax_Requests_File() + '?f=request_payment',
    beforeSend: function() {
      $('.wo_settings_page').find('.add_wow_loader').addClass('btn-loading');
    },
    success: function(data) {
      scrollToTop();
      if (data.status == 200) {
        $('.setting-general-alert').html('<div class="alert alert-success">' + data.message + '</div>');
        $('.alert-success').fadeIn('fast');
      } else if (data.errors) {
          var errors = data.errors.join("<br>");
          $('.setting-general-alert').html('<div class="alert alert-danger">' + errors + '</div>');
          $('.alert-danger').fadeIn(300);
      }
      $('.wo_settings_page').find('.add_wow_loader').removeClass('btn-loading');
    }
  });
});
</script>