<div class="container-fluid">
    <div class="alert alert-warning">
      <i class="fa fa-question-circle fa-fw"></i>Please note that not all currencies are supported by PayPal, stripe, 2checkout, alipay. If the currency you adding isn't supported, You can set the default payment currency for each payment method from <a href="<?php echo Wo_LoadAdminLinkSettings('payment-settings'); ?>"> Payment Settings.</a>
    </div>
    <div class="block-header">
        <h2>Settings > Manage Currencies</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
    	<div class="col-lg-12 col-md-12">
            <div class="card">
                <div class="header">
                    <h2>Add Currency</h2><br>
                </div>
                <div class="body">
                     <div class="alert alert-success add-curreny-settings-alert"></div>
                    <form class="add-curreny-settings" method="POST">

                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="currency" name="currency" class="form-control">
                                <label class="form-label">Currency Code (e.g: USD)</label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="currency_symbol" name="currency_symbol" class="form-control">
                                <label class="form-label">Currency Symbol (e.g: $)</label>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <br><br>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">Add</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="col-lg-12 col-md-12">
            <div class="card">
                <div class="header">
                    <h2>Currencies</h2>
                </div>
                <div class="body">
                   <input type="hidden" id="hash_id" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                   <div class="clearfix"></div>
                   <div class="table-responsive1">
                        <table class="table table-bordered table-striped table-hover">
                            <thead>
                                <tr>
                                      <th>ID</th>
					                  <th>Currency Code</th>
					                  <th>Currency Symbol</th>
                            <th>Status</th>
					                  <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                               <?php 
				               foreach ($wo['config']['currency_array']  as $wo['currency_key'] => $wo['currency_value']) {
				                  echo Wo_LoadAdminPage('manage-currencies/list');
				                }
				               ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->

<script>
$(function () {
	$('table').DataTable();
});

function delete_currency(currency) {
  if (confirm("Are you sure you want to delete this currency?") == false) {
    return false;
  }
  $.post(Wo_Ajax_Requests_File() + '?f=admin_setting&s=remove__curreny', {currency: currency}, function(data, textStatus, xhr) {
    if (data.status == 200) {
        $('#currency_'+currency).remove();
    }
  });
}
function open_edit_currency(currency,currency_symbol,currency_id) {
  $('#defaultModal').modal('show');
  $('#edit_currency').val(currency);
  $('#edit_currency_symbol').val(currency_symbol);
  $('#edit_currency_id').val(currency_id);
}

function make_default(currency) {
  $.post(Wo_Ajax_Requests_File() + '?f=admin_setting&s=select_currency', {currency: currency}, function(data, textStatus, xhr) {
    if (data.status == 200) {
            location.reload();
    }
  });
}
function Wo_SubmitCurrencyForm() {
  $('.edit-curreny-settings').submit();
}

var form_add_site_settings = $('form.add-curreny-settings');
form_add_site_settings.ajaxForm({
    url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=add_new_curreny',
    beforeSend: function() {
        form_add_site_settings.find('.waves-effect').text('Please wait..');
    },
    success: function(data) {
        if (data.status == 200) {
            form_add_site_settings.find('.waves-effect').text('Save');
            $("html, body").animate({ scrollTop: 0 }, "slow");
            $('.add-curreny-settings-alert').html('<i class="fa fa-check"></i> Currency successfully added');
            setTimeout(function () {
                $('.add-curreny-settings-alert').empty();
                location.reload();
            }, 2000);
        }
    }
});

var form_edit_site_settings = $('form.edit-curreny-settings');
form_edit_site_settings.ajaxForm({
    url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=edit_curreny',
    beforeSend: function() {
        form_edit_site_settings.find('.waves-effect').text('Please wait..');
    },
    success: function(data) {
        if (data.status == 200) {
            form_edit_site_settings.find('.waves-effect').text('SAVE CHANGES');
            $("html, body").animate({ scrollTop: 0 }, "slow");
            $('.edit-curreny-settings-alert').html('<i class="fa fa-check"></i> Currency successfully added');
            setTimeout(function () {
                $('.edit-curreny-settings-alert').empty();
                location.reload();
            }, 2000);
        }
    }
});

</script>

<div class="modal fade" id="defaultModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header">
                <h4 class="modal-title" id="defaultModalLabel">Edit Currency</h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-success edit-curreny-settings-alert"></div>
                <form class="edit-curreny-settings" method="POST">

                    <div class="form-group form-float">
                        <div class="form-line">
                            <input type="text" id="edit_currency" name="currency" class="form-control" placeholder="Currency Code (e.g: USD)">
                        </div>
                    </div>
                    <div class="form-group form-float">
                        <div class="form-line">
                            <input type="text" id="edit_currency_symbol" name="currency_symbol" class="form-control" placeholder="Currency Symbol (e.g: $)">
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <br><br>
                    <input type="hidden" name="currency_id" id="edit_currency_id">
                    <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" onclick="Wo_SubmitCurrencyForm();" class="btn-save btn btn-link waves-effect">SAVE CHANGES</button>
                <button type="button" class="btn btn-link waves-effect" data-dismiss="modal">CLOSE</button>
            </div>
        </div>
    </div>
</div>