{% include 'header.twig' %}

<style>.body{background-image: url('app/views/Simplify/image/Background.png');background-position: 0px 0px;background-repeat: repeat;background-size: 300%;width: 100%;}</style>

<div class="wrapper-content">
    <div class="wrapper-content__header">
          </div>


 <div class="wrapper-content">
    <div class="wrapper-content__header">
          </div>
    <div class="wrapper-content__body">
        
        
        
        
        
        
        {% if PageText %} 
      <div id="block_107">
    <div class="text-block-with-card ">
        <div class="bg"></div>
        <div class="divider-top"></div>
        <div class="divider-bottom"></div>
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="component_card_1">
                        <div class="card">
                            <div class="text-block__description">
        {{ contentText }}
      </div>
    </div>
</div>
    </div>
  </div></div></div></div>
{% endif %} 
      <!-- Main variables *content* -->
      <div id="block_47">
          <div class="block-bg">
              <div class="bg-image">
                  
              </div></div>
              <div class="block-divider-top">
                  <svg width="100%" height="100%" viewBox="0 0 1280 140" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg"><g fill="currentColor"><path d="M504.854,80.066c7.812,0,14.893,0.318,21.41,0.879 c-25.925,22.475-56.093,40.852-102.946,40.852c-20.779,0-37.996-2.349-52.898-6.07C413.517,107.295,434.056,80.066,504.854,80.066z M775.938,51.947c19.145,18.596,39.097,35.051,77.956,35.051c46.907,0,62.299-14.986,80.912-24.98 c-21.357-15.783-46.804-28.348-85.489-28.348C816.829,33.671,794.233,41.411,775.938,51.947z" fill-opacity=".3"/><path d="M1200.112,46.292c39.804,0,59.986,22.479,79.888,39.69v16.805 c-19.903-10.835-40.084-21.777-79.888-21.777c-72.014,0-78.715,43.559-147.964,43.559c-56.84,0-81.247-35.876-117.342-62.552 c9.309-4.998,19.423-8.749,34.69-8.749c55.846,0,61.99,39.617,115.602,39.617C1143.177,92.887,1142.618,46.292,1200.112,46.292z M80.011,115.488c-40.006,0-60.008-12.206-80.011-29.506v16.806c20.003,10.891,40.005,21.782,80.011,21.782 c80.004,0,78.597-30.407,137.669-30.407c55.971,0,62.526,24.026,126.337,24.026c9.858,0,18.509-0.916,26.404-2.461 c-57.186-14.278-80.177-48.808-138.66-48.808C154.698,66.919,131.801,115.488,80.011,115.488z M526.265,80.945 c56.848,4.902,70.056,28.726,137.193,28.726c54.001,0,73.43-35.237,112.48-57.724C751.06,27.782,727.548,0,665.691,0 C597.381,0,567.086,45.555,526.265,80.945z" fill-opacity=".5"/><path d="M0,0v85.982c20.003,17.3,40.005,29.506,80.011,29.506c51.791,0,74.688-48.569,151.751-48.569 c58.482,0,81.473,34.531,138.66,48.808c43.096-8.432,63.634-35.662,134.433-35.662c7.812,0,14.893,0.318,21.41,0.879 C567.086,45.555,597.381,0,665.691,0c61.856,0,85.369,27.782,110.246,51.947c18.295-10.536,40.891-18.276,73.378-18.276 c38.685,0,64.132,12.564,85.489,28.348c9.309-4.998,19.423-8.749,34.69-8.749c55.846,0,61.99,39.617,115.602,39.617 c58.08,0,57.521-46.595,115.015-46.595c39.804,0,59.986,22.479,79.888,39.69V0H0z"/></g></svg></div>
                  <div class="container">
                      <div class="add-funds__form">

     
                  
                  <div class="component_card">
                        <div class="card">
    <div class="col-md-12">
      
     
        {% if error %}
          <div class="alert alert-dismissible alert-danger">
            <button type="button" class="close" data-dismiss="alert">×</button>
            {{ errorText }}
          </div>
        {% endif %}
        {% if success %}
          <div class="alert alert-dismissible alert-success">
            <button type="button" class="close" data-dismiss="alert">×</button>
            {{ successText }}
          </div>
		  
{#<meta http-equiv="refresh" content="0; URL=/" />#}
        {% endif %}
      </div>

 
    <div class="col-md-12">

      
          <div class="well">
       
        
  
              <form method="post" action="addfunds">

                <div class="form-group">
												<label for="method" class="control-label">{{ lang['addfunds.method'] }}</label>
												<select class="form-control" id="payment_method" name="payment_type">
													{% for method in site["paymentMethods"] %}
														<option value="{{ method['id'] }}">{{ method['name'] }}</option>
													{% endfor %}
												</select>
											</div>
											<div id="addfunds_fields"></div>
										</form>
										<div id="formSubmitResponseMessage"></div>
										<div id="formSubmitResponseContent"></div>
									</div>
								</div>
							</div>
						</div>
					


    
                                                     
                                                                                 
</div></div></div><div id="block_2"><div class="block-bg"></div><div class="container"><div class="add-funds__list">
    <div class="row mb-3">
        <div class="col-lg-12">
            <div class="table-bg component_table ">
                <div class="table-wr table-responsive">
                    <table class="table">
                        <thead>
                        <tr>
              <th>ID</th>
              <th>Amount</th>
              <th class="width-40">Method</th>
              <th>Date</th>
            </tr>
          </thead>
          <tbody>
<td colspan="9">
            {% for payment in payments %}
              <tr>
                <td><span class="badge badge-pill badge-secondary">{{ payment['id'] }} </td>
                
                <td><span class="badge badge-pill badge-success"> {{ payment['amount'] }}  </td>  
                <td class="width-40">{{ payment['name'] }}</td>
                <td>{{ payment['date'] }}</td>

                
              </tr>
            {% endfor %}
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
				<div class="divider-top"></div>
        <div class="divider-bottom"></div>
        <div class="container ludd">
 {% if contentText2 %}
 <div class="card mt-4 mb-4 ">	
{{ contentText2 }}
</div>
{% endif %}
</div>
</div>
							</div>
						</div>
					

			{% include 'footer.twig' %}

			<script>
				var paymentMethods = {{ site["paymentMethodsJSON"] }};
			</script>
			<script>
				const addfundsRoute = "/addfunds";
function addfundsInit() {
var addfundsForm = $("#addfundsForm");
var fields = $("#addfunds_fields");
var selectedMethod = $("#payment_method").val();
var instructions = paymentMethods[selectedMethod][0].instructions;
$.ajax({
url: addfundsRoute,
data: "action=getForm&selectedMethod=" + selectedMethod,
type: "POST",
success: function (json) {
if (json.success == true) {
if (instructions.length > 0) {
var methodInstruction = '<div class="form-group"><label class="control-label">Instructions</label><div class="panel-body border-solid border-rounded">' + instructions + '</div></div>';
} else {
var methodInstruction = "";
} fields.html(methodInstruction + json.content);
extraFeeInit(selectedMethod);
}
}
});
}

function extraFeeInit(method) {
var fee = parseFloat(paymentMethods[method][0].fee).toFixed(2);
var fields = $("#fee_fields");
if (fee > 0) {
fields.html('<div class="form-group"><label class="control-label">Extra fee</label><input type="text" class="form-control" id="methodExtraFee" disabled value="0.00"/></div><div class="form-group"><label class="control-label">Total Amount</label><input type="text" id="totalAmount" class="form-control" disabled value="0.00" /></div>');
}
}
function preparePrice(t) {
n = 2;
var r = (t = $.trim(t.toString().replace(",", "."))).split(".");
return void 0 !== r[1] && (r[1] = r[1].replace(/0+$/g, ""), r[1].length > n && (n = 2 < r[1].length ? 2 : r[1].length)),
1e3 <= (t =( t = parseFloat(t)).toFixed(n)) && (t = t.toString().replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, "$1" + "")),
t = t.toString().replace(/\.(\d+)$/g, "." + "$1");
return t.toFixed(n)
}
$(document).ready(function () {
$(document).on("keyup", "#paymentAmount", function () {
var selectedMethod = $("#payment_method").val();
var amount = parseFloat($(this).val());
var feePercentage = parseFloat(paymentMethods[selectedMethod][0].fee);
var feeInput = $("#methodExtraFee");
var totalAmountInput = $("#totalAmount");
var fee = amount * (feePercentage / 100);
feeInput.val(preparePrice(fee));
totalAmountInput.val(preparePrice(amount + fee));
});
addfundsInit();
});
$("#payment_method").change(function () {
addfundsInit();
});

$("#addfundsForm").submit(function (e) {
e.preventDefault();
var data = $(this).serialize();

$.ajax({
url: addfundsRoute,
data: data,
type: "POST",
success: function (json) {
if (json.success == true) {
var msgDiv = $("#formSubmitResponseMessage");
msgDiv.html('<div class="alert alert-success alert-dismissible fade show mt-2" role="alert">' + json.message + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
var contentDiv = $("#formSubmitResponseContent");
contentDiv.html(json.content);
} else {
var msgDiv = $("#formSubmitResponseMessage");
msgDiv.html('<div class="alert alert-danger alert-dismissible fade show mt-2" role="alert">' + json.message + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
}
}

});
});
			</script>
